diff --git a/.gitignore b/.gitignore index 1c344c9..7a349aa 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /.project /bin /.DS_Store +/.idea +halodal.iml \ No newline at end of file diff --git a/src/main/java/halo/dal/DALCurrentStatus.java b/src/main/java/halo/dal/DALCurrentStatus.java index 93b134f..91c9eec 100644 --- a/src/main/java/halo/dal/DALCurrentStatus.java +++ b/src/main/java/halo/dal/DALCurrentStatus.java @@ -9,6 +9,8 @@ */ public class DALCurrentStatus { + public static final String DEFAULT_DS_KEY="default_ds"; + private static final ThreadLocal dsKeyTL = new ThreadLocal(); private static final ThreadLocal dalCustomInfoTL = new ThreadLocal(); @@ -20,6 +22,8 @@ public static void setDsKey(String dsKey) { dsKeyTL.set(dsKey); } + public static void setDefaultDsKey(){ dsKeyTL.set(DEFAULT_DS_KEY);} + public static String getDsKey() { String key = dsKeyTL.get(); if (key == null) { diff --git a/src/main/java/halo/dal/DALFactory.java b/src/main/java/halo/dal/DALFactory.java index d9a3c71..3024257 100644 --- a/src/main/java/halo/dal/DALFactory.java +++ b/src/main/java/halo/dal/DALFactory.java @@ -49,6 +49,7 @@ public void setPartitionParserFactory( this.partitionParserFactory = partitionParserFactory; } + public PartitionParserFactory getPartitionParserFactory() { return partitionParserFactory; } diff --git a/src/main/java/halo/dal/analysis/ColumnExper.java b/src/main/java/halo/dal/analysis/ColumnExper.java index d20cd46..cada34a 100644 --- a/src/main/java/halo/dal/analysis/ColumnExper.java +++ b/src/main/java/halo/dal/analysis/ColumnExper.java @@ -1,5 +1,8 @@ package halo.dal.analysis; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + public class ColumnExper { private String column; @@ -15,7 +18,9 @@ public class ColumnExper { "!=",// ">",// "<",// - "=" // + "=" ,// + "=<",// 等价于 <= + "in" // 等价于 = }; public static final SQLExpressionSymbol[] symbolsEnum = new SQLExpressionSymbol[] {// @@ -25,7 +30,9 @@ public class ColumnExper { SQLExpressionSymbol.NOT_EQUAL2, // SQLExpressionSymbol.BIGGER,// SQLExpressionSymbol.SMALLER, // - SQLExpressionSymbol.EQUAL // + SQLExpressionSymbol.EQUAL, // + SQLExpressionSymbol.SMALLER_EQUAL,// + SQLExpressionSymbol.EQUAL,// }; /** @@ -117,4 +124,10 @@ public void setColumn(String column) { this.column = null; } } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } + } \ No newline at end of file diff --git a/src/main/java/halo/dal/analysis/SQLExpression.java b/src/main/java/halo/dal/analysis/SQLExpression.java index 5003ffa..e6507b0 100644 --- a/src/main/java/halo/dal/analysis/SQLExpression.java +++ b/src/main/java/halo/dal/analysis/SQLExpression.java @@ -1,5 +1,8 @@ package halo.dal.analysis; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + public class SQLExpression { private String column; @@ -31,4 +34,9 @@ public void setColumn(String column) { public void setValue(Object value) { this.value = value; } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } } diff --git a/src/main/java/halo/dal/analysis/SQLInfo.java b/src/main/java/halo/dal/analysis/SQLInfo.java index 1ec06d8..1cc1615 100644 --- a/src/main/java/halo/dal/analysis/SQLInfo.java +++ b/src/main/java/halo/dal/analysis/SQLInfo.java @@ -23,4 +23,12 @@ public interface SQLInfo { * @param sqlExpression */ void addSQLExpression(String logicTableName, SQLExpression sqlExpression); + + /** + * 获取操作类型 (读写分离的时候可以用) + * + * @return + */ + SQLType getSQLType(); + } \ No newline at end of file diff --git a/src/main/java/halo/dal/analysis/SQLStruct.java b/src/main/java/halo/dal/analysis/SQLStruct.java index 08cab94..5d61f6d 100644 --- a/src/main/java/halo/dal/analysis/SQLStruct.java +++ b/src/main/java/halo/dal/analysis/SQLStruct.java @@ -1,5 +1,9 @@ package halo.dal.analysis; +import halo.dal.analysis.antlr.AntlrParserDelegate; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -17,6 +21,8 @@ public class SQLStruct { */ private boolean canParse; + private SQLType sqlType=null; + private Map alias_nameMap = new HashMap(2); private Map name_aliasMap = new HashMap(2); @@ -70,6 +76,23 @@ public void addTable(String name, String alias) { } } + public void setSqlType(int flag){ + if(flag== AntlrParserDelegate.SQLOP_INSERT){ + sqlType=SQLType.INSERT; + }else if(flag== AntlrParserDelegate.SQLOP_DELETE){ + sqlType=SQLType.DELETE; + }else if(flag== AntlrParserDelegate.SQLOP_UPDATE){ + sqlType=SQLType.UPDATE; + }else if(flag== AntlrParserDelegate.SQLOP_SELECT){ + sqlType=SQLType.SELECT; + } + } + + public SQLType getSqlType(){ + return sqlType; + } + + public boolean isCanParse() { return canParse; } @@ -89,4 +112,9 @@ public String getTableNameByAalias(String alias) { public List getTableNames() { return tableNames; } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } } \ No newline at end of file diff --git a/src/main/java/halo/dal/analysis/SQLType.java b/src/main/java/halo/dal/analysis/SQLType.java new file mode 100644 index 0000000..51b9fe9 --- /dev/null +++ b/src/main/java/halo/dal/analysis/SQLType.java @@ -0,0 +1,8 @@ +package halo.dal.analysis; + +/** + * Created by zhouxiliang on 2015/10/22. + */ +public enum SQLType { + INSERT , DELETE , UPDATE , SELECT; +} diff --git a/src/main/java/halo/dal/analysis/antlr/SQLInfoImpl.java b/src/main/java/halo/dal/analysis/antlr/SQLInfoImpl.java index dd73a14..fd1704a 100644 --- a/src/main/java/halo/dal/analysis/antlr/SQLInfoImpl.java +++ b/src/main/java/halo/dal/analysis/antlr/SQLInfoImpl.java @@ -2,6 +2,9 @@ import halo.dal.analysis.SQLExpression; import halo.dal.analysis.SQLInfo; +import halo.dal.analysis.SQLType; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; import java.util.ArrayList; import java.util.HashMap; @@ -14,6 +17,8 @@ public class SQLInfoImpl implements SQLInfo { private final Map logic_realMap = new HashMap(); + private SQLType sqlType; + public SQLExpression[] getSQLExpressions(String columnName) { String lowerColumnName = columnName.toLowerCase(); SQLExpression[] lowerArr = sqlExpressionMap.get(lowerColumnName); @@ -71,6 +76,14 @@ public void addSQLExpression(String logicTableName, } } + public SQLType getSQLType() { + return sqlType; + } + + public void setSQLType(SQLType type) { + this.sqlType=type; + } + public String getRealTable(String logic) { return logic_realMap.get(logic); } @@ -78,4 +91,9 @@ public String getRealTable(String logic) { public void setRealTable(String logic, String real) { logic_realMap.put(logic, real); } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + } } diff --git a/src/main/java/halo/dal/analysis/antlr/v3/AntlrV3SQLAnalyzer.java b/src/main/java/halo/dal/analysis/antlr/v3/AntlrV3SQLAnalyzer.java index f398e9d..f0fb712 100644 --- a/src/main/java/halo/dal/analysis/antlr/v3/AntlrV3SQLAnalyzer.java +++ b/src/main/java/halo/dal/analysis/antlr/v3/AntlrV3SQLAnalyzer.java @@ -38,6 +38,7 @@ public SQLInfo analyse(String sql, SQLStruct sqlStruct, Object[] values, info.addSQLExpression(o.getLogicTableName(), sqlExpression); i++; } + info.setSQLType(sqlStruct.getSqlType()); return info; } @@ -71,6 +72,8 @@ public SQLStruct parse(String sql, Map context) { columnExper.setSqlExpressionSymbol(colExpr.getOp()); sqlStruct.addColumnExper(columnExper); } + //设置sql操作类型 + sqlStruct.setSqlType(delegate.getSqlOp()); return sqlStruct; } @@ -117,4 +120,26 @@ public String outPutSQL(String sql, SQLStruct sqlStruct, SQLInfo sqlInfo, } return _sql; } + + public static void main(String[] args) { + AntlrV3SQLAnalyzer antlrV3SQLAnalyzer=new AntlrV3SQLAnalyzer(); + String sql="insert into table ( id ,name ) values ( ? ,?) "; + String sql1="update table set id = ? ,name=? where cnt = ?"; + String sql2="delete * from table where cnt = ?"; + String sql3="select * from table where cnt = ?"; + String sql4="update user set 1 =1 where uid=? and (age>=? or age<=?) and (sex between ? and ?) and time<=sysdate()"; + String sql5= "select gatewayeve0_.ID as ID1_, gatewayeve0_.ADAPTER_ID as ADAPTER2_1_, " + + "gatewayeve0_.ADAPTER_MEMO as ADAPTER3_1_, gatewayeve0_.ADAPTER_NAME as ADAPTER4_1_, " + + "gatewayeve0_.CREATETIME as CREATETIME1_, gatewayeve0_.END_DATE as END6_1_, " + + "gatewayeve0_.EVENT_ID as EVENT7_1_, gatewayeve0_.EVENT_STATUS as EVENT8_1_, " + + "gatewayeve0_.EVENT_TYPE as EVENT9_1_, gatewayeve0_.LASTUPDTIME as LASTUPD10_1_, " + + "gatewayeve0_.MERCHANT_ID as MERCHANT11_1_, gatewayeve0_.MERCHANT_NAME as MERCHANT12_1_, " + + "gatewayeve0_.NAME as NAME1_, gatewayeve0_.OPRID as OPRID1_, " + + "gatewayeve0_.START_DATE as START15_1_ " + + "from gateway_event gatewayeve0_ " + + "where 1=1 and gatewayeve0_.EVENT_STATUS=?"; + SQLStruct sqlStruct=antlrV3SQLAnalyzer.parse(sql4,null); + System.out.println(sqlStruct); + System.out.println(sqlStruct.getColumnExpers().size()); + } } diff --git a/src/main/java/halo/dal/analysis/antlr/zxl/AntlrV3SQL.g b/src/main/java/halo/dal/analysis/antlr/zxl/AntlrV3SQL.g new file mode 100644 index 0000000..96543ef --- /dev/null +++ b/src/main/java/halo/dal/analysis/antlr/zxl/AntlrV3SQL.g @@ -0,0 +1,277 @@ +grammar AntlrV3SQL; + +@header { +import java.util.List; +import java.util.ArrayList; +} + +@members { + private AntlrParserDelegate antlrParserDelegate; + + public void setAntlrParserDelegate(AntlrParserDelegate antlrParserDelegate) { + this.antlrParserDelegate = antlrParserDelegate; + } + +@Override + public void reportError(RecognitionException e) { + } + +} + +start : + sql_insert|sql_delete|sql_update|sql_select; + +sql_insert + : + INSERT INTO table '\(' insertColumn (',' insertColumn)* '\)' VALUES '\(' (PRE_SET|(',' PRE_SET))* '\)' + {this.antlrParserDelegate.setSqlOp(AntlrParserDelegate.SQLOP_INSERT);} + ; + +sql_delete + : + DELETE FROM table (WHERE kv_sql)? + {this.antlrParserDelegate.setSqlOp(AntlrParserDelegate.SQLOP_DELETE);} + ; + +sql_update + : + UPDATE table SET kv (',' kv)* (WHERE kv_sql)? + {this.antlrParserDelegate.setSqlOp(AntlrParserDelegate.SQLOP_UPDATE);} + ; + +sql_select + : + SELECT select_columns (','db2_paging)? FROM (sqlAfterFrom|inner_select) (WHERE kv_sql)? (orderby|groupby|having)* + {this.antlrParserDelegate.setSqlOp(AntlrParserDelegate.SQLOP_SELECT);} + ; + +sqlAfterFrom + : + tables ((FULL|CROSS|INNER|LEFT|RIGHT) JOIN table (ON column_name '=' column_name)?)*; + +kv_sql_wrapper + : + kv_sql | '\(' kv_sql '\)' + ; +kv_sql : + kv ( and_or (kv | '\(' kv (and_or kv)* '\)') )* + ; + +inner_select + : + '\(' sql_select '\)' AS? BASIC_NAME? + ; + +func + : + BASIC_NAME '\(' (BASIC_NAME|'*')? '\)' + ; + +func_and_alias + : + func (AS? BASIC_NAME)? + ; + +select_column_and_alias + : + column_name (AS? BASIC_NAME)? + ; + +select_column + : + select_column_and_alias|func_and_alias|'*' + ; + +select_columns + : + select_column (',' select_column)* + ; + +and_or : + AND|OR + ; + +table : + table_name ((AS)? alias)? { + if (this.antlrParserDelegate != null) { + this.antlrParserDelegate.onFindTable( $table_name.text, $alias.text); + } + }; + +tables : + (table (',' table)*) + ; + +table_name + : + BASIC_NAME (('.') BASIC_NAME)? + ; + +alias : + BASIC_NAME + ; + +column_name + : + BASIC_NAME (('.') BASIC_NAME)? + ; + +insertColumn + : + column_name + { + if (this.antlrParserDelegate != null) { + this.antlrParserDelegate.onFindColExper( + $column_name.text, "="); + } + } + ; + + +kv : + (column_name op (PRE_SET|'\(' PRE_SET '\)')) + { + if (this.antlrParserDelegate != null) { + this.antlrParserDelegate.onFindColExper( $column_name.text, $op.text); + } + } + | + column_name op TEXT_STRING + | + (column_name BETWEEN PRE_SET AND PRE_SET) + { + this.antlrParserDelegate.onFindColExper($column_name.text, ">="); + this.antlrParserDelegate.onFindColExper($column_name.text, "=<"); + } + | + column_name op column_name + | + column_name op func2 + | + column_name op '\(' sql_select '\)' + | + (column_name op '\(' inexpr '\)' ) + { + if (this.antlrParserDelegate != null) { + String s=$inexpr.text; + int cnt=s.split(",").length; + for(int i=0;i'|'>='|'<'|'<='|'!='|'<>'|IN|EXISTS) + ; + +orderby : + ORDER BY column_name (DESC|ASC)? (',' column_name (DESC|ASC)?)* + ; + +groupby : + GROUP BY column_name (',' column_name)* + ; + +having : + HAVING (column_name|func) op (column_name|func|TEXT_STRING|PRE_SET) + ; + +db2_paging + : + ROWNUMBER'\(''\)' OVER'\('orderby '\)' (AS)? BASIC_NAME + ; + +SELECT :S E L E C T; +INSERT :I N S E R T; +UPDATE :U P D A T E; +DELETE :D E L E T E; +ROWNUMBER + :R O W N U M B E R; +OVER :O V E R; +BETWEEN :B E T W E E N; +AND :A N D; +OR :O R; +WHERE :W H E R E; +GROUP :G R O U P; +HAVING :H A V I N G; +BY :B Y; +ORDER :O R D E R; +DESC :D E S C; +ASC :A S C; +SET :S E T; +ON :O N; +FULL :F U L L; +INNER :I N N E R; +AS :A S; +FROM :F R O M; +LEFT :L E F T; +RIGHT :R I G H T; +CROSS :C R O S S; +JOIN :J O I N; +VALUES :V A L U E S; +INTO :I N T O; +IN :I N; +EXISTS :E X I S T S; +PRE_SET :'?'; + +BASIC_NAME + : + ('a'..'z'|'A'..'Z'|'0'..'9'|'_')+; + +TEXT_STRING: + ('\'' + ( + options{greedy=true;}: ~('\'' | '\r' | '\n' ) | '\'' '\'' + )* + '\'' ) + + ; + +WS : ( ' ' + | '\t' + | '\r' + | '\n' + ) {$channel=HIDDEN;} + ; + + +fragment A:('a'|'A'); +fragment B:('b'|'B'); +fragment C:('c'|'C'); +fragment D:('d'|'D'); +fragment E:('e'|'E'); +fragment F:('f'|'F'); +fragment G:('g'|'G'); +fragment H:('h'|'H'); +fragment I:('i'|'I'); +fragment J:('j'|'J'); +fragment K:('k'|'K'); +fragment L:('l'|'L'); +fragment M:('m'|'M'); +fragment N:('n'|'N'); +fragment O:('o'|'O'); +fragment P:('p'|'P'); +fragment Q:('q'|'Q'); +fragment R:('r'|'R'); +fragment S:('s'|'S'); +fragment T:('t'|'T'); +fragment U:('u'|'U'); +fragment V:('v'|'V'); +fragment W:('w'|'W'); +fragment X:('x'|'X'); +fragment Y:('y'|'Y'); +fragment Z:('z'|'Z'); \ No newline at end of file diff --git a/src/main/java/halo/dal/analysis/antlr/zxl/AntlrV3SQLAnalyzer.java b/src/main/java/halo/dal/analysis/antlr/zxl/AntlrV3SQLAnalyzer.java new file mode 100644 index 0000000..84c4b5a --- /dev/null +++ b/src/main/java/halo/dal/analysis/antlr/zxl/AntlrV3SQLAnalyzer.java @@ -0,0 +1,139 @@ +package halo.dal.analysis.antlr.zxl; + +import halo.dal.analysis.*; +import halo.dal.analysis.antlr.*; +import halo.dal.analysis.antlr.zxl.AntlrV3SQLLexer; +import halo.dal.analysis.antlr.zxl.AntlrV3SQLParser; +import org.antlr.runtime.ANTLRStringStream; +import org.antlr.runtime.CommonTokenStream; +import org.antlr.runtime.RecognitionException; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class AntlrV3SQLAnalyzer implements SQLAnalyzer { + + protected final static String SQL_BLANK = " "; + + public SQLInfo analyse(String sql, SQLStruct sqlStruct, Object[] values, + Map context) { + SQLInfoImpl info = new SQLInfoImpl(); + SQLExpression sqlExpression; + int i = 0; + for (ColumnExper o : sqlStruct.getColumnExpers()) { + sqlExpression = new SQLExpression(); + sqlExpression.setColumn(o.getColumn()); + sqlExpression.setSqlExpressionSymbol(o.getSqlExpressionSymbol()); + sqlExpression.setValue(values[i]); + info.addSQLExpression(o.getLogicTableName(), sqlExpression); + i++; + } + info.setSQLType(sqlStruct.getSqlType()); + return info; + } + + public SQLStruct parse(String sql, Map context) { + halo.dal.analysis.antlr.zxl.AntlrV3SQLLexer lexer = new AntlrV3SQLLexer(new ANTLRStringStream(sql)); + CommonTokenStream tokens = new CommonTokenStream(lexer); + AntlrV3SQLParser parser = new AntlrV3SQLParser(tokens); + AntlrParserDelegate delegate = new DefAntlrParserDelegate(); + parser.setAntlrParserDelegate(delegate); + try { + parser.start(); + } + catch (RecognitionException e) { + throw new RuntimeException(e); + } + SQLStruct sqlStruct = new SQLStruct(); + if (!delegate.isHasTable()) { + sqlStruct.setCanParse(false); + return sqlStruct; + } + sqlStruct.setCanParse(true); + Table table; + for (int i = 0; i < delegate.getTables().size(); i++) { + table = delegate.getTables().get(i); + sqlStruct.addTable(table.getName(), table.getAlias()); + } + ColumnExper columnExper; + for (ColExpr colExpr : delegate.getColExprs()) { + columnExper = new ColumnExper(); + columnExper.setColumn(colExpr.getColumn()); + columnExper.setSqlExpressionSymbol(colExpr.getOp()); + sqlStruct.addColumnExper(columnExper); + } + //设置sql操作类型 + sqlStruct.setSqlType(delegate.getSqlOp()); + return sqlStruct; + } + + public String outPutSQL(String sql, SQLStruct sqlStruct, SQLInfo sqlInfo, + ParsedTableInfo parsedTableInfo) { + List list = new ArrayList(); + List newList = new ArrayList(); + String realTableName; + for (String tableName : sqlStruct.getTableNames()) { + realTableName = parsedTableInfo.getRealTable(tableName); + if (realTableName != null) { + String alias = sqlStruct.getAliasByTableName(tableName); + boolean isSame = alias != null && alias.endsWith(tableName); + if (!isSame) { + list.add(SQL_BLANK + tableName + "."); + newList.add(SQL_BLANK + realTableName + "."); + } + list.add(SQL_BLANK + tableName + SQL_BLANK); + newList.add(SQL_BLANK + realTableName + SQL_BLANK); + list.add(SQL_BLANK + tableName + "("); + newList.add(" " + realTableName + "("); + list.add("," + tableName + SQL_BLANK); + newList.add("," + realTableName + SQL_BLANK); + } + } + String fmtSql = sql.replaceAll("\\. {1,}", "\\.").trim(); + String _sql = StringUtils.replaceEach(fmtSql, + list.toArray(new String[list.size()]), + newList.toArray(new String[newList.size()])); + // 解决sql结束字符串为表名,无法解析的问题例如 delete form user + String str; + for (String tableName : sqlStruct.getTableNames()) { + realTableName = parsedTableInfo.getRealTable(tableName); + if (realTableName != null) { + str = SQL_BLANK + tableName; + int idx = _sql.lastIndexOf(str); + if (idx == -1) { + continue; + } + if (_sql.substring(idx).equals(str)) { + _sql = _sql.substring(0, idx) + SQL_BLANK + realTableName; + } + } + } + return _sql; + } + + public static void main(String[] args) { + AntlrV3SQLAnalyzer antlrV3SQLAnalyzer=new AntlrV3SQLAnalyzer(); + String sql="insert into table ( id ,name ) values ( ? ,?) "; + String sql1="update table set id = ? ,name=? where cnt = ?"; + String sql2="delete * from table where cnt = ?"; + String sql3="select * from table where cnt = ?"; + String sql4="delete from user where uid=? and (age>=? or age<=?) and (sex between ? and ?) and time<=sysdate()"; + String sql5= "SELECT count(*), \n" + + "count(*) as kk,\n" + + "count(*) kk0,\n" + + "GATEWAYEVE0_.ID AS ID1_, \n" + + "GATEWAYEVE0_.NAME NAME1_, \n" + + "GATEWAYEVE0_.START_DATE AS START15_1_ \n" + + "FROM gateway_event1 GATEWAYEVE0_ , table2 as t2\n" + + "WHERE 1=? and 1=2 or 3.5=6.7 and b='s do' and time=sysdate() \n" + + "or name=substring(a.b,'c',b,b.c,'') and kk=substring('') \n" + + "and name >= ? and name > ? and uid in ( ? ,? )\n" + +// "and uid in (select * from user where sex=? order by gid desc group by ss having a=b.c) \n" + + " AND GATEWAYEVE0_.EVENT_STATUS=?"; + SQLStruct sqlStruct=antlrV3SQLAnalyzer.parse(sql5,null); + System.out.println(sqlStruct); + System.out.println(sqlStruct.getColumnExpers().size()); + } +} diff --git a/src/main/java/halo/dal/analysis/antlr/zxl/AntlrV3SQLLexer.java b/src/main/java/halo/dal/analysis/antlr/zxl/AntlrV3SQLLexer.java new file mode 100644 index 0000000..8c29b9e --- /dev/null +++ b/src/main/java/halo/dal/analysis/antlr/zxl/AntlrV3SQLLexer.java @@ -0,0 +1,2843 @@ +package halo.dal.analysis.antlr.zxl;// $ANTLR 3.4 AntlrV3SQL.g 2015-10-22 18:48:42 + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings({"all", "warnings", "unchecked"}) +public class AntlrV3SQLLexer extends Lexer { + public static final int EOF=-1; + public static final int T__64=64; + public static final int T__65=65; + public static final int T__66=66; + public static final int T__67=67; + public static final int T__68=68; + public static final int T__69=69; + public static final int T__70=70; + public static final int T__71=71; + public static final int T__72=72; + public static final int T__73=73; + public static final int T__74=74; + public static final int T__75=75; + public static final int A=4; + public static final int AND=5; + public static final int AS=6; + public static final int ASC=7; + public static final int B=8; + public static final int BASIC_NAME=9; + public static final int BETWEEN=10; + public static final int BY=11; + public static final int C=12; + public static final int CROSS=13; + public static final int D=14; + public static final int DELETE=15; + public static final int DESC=16; + public static final int E=17; + public static final int EXISTS=18; + public static final int F=19; + public static final int FROM=20; + public static final int FULL=21; + public static final int G=22; + public static final int GROUP=23; + public static final int H=24; + public static final int HAVING=25; + public static final int I=26; + public static final int IN=27; + public static final int INNER=28; + public static final int INSERT=29; + public static final int INTO=30; + public static final int J=31; + public static final int JOIN=32; + public static final int K=33; + public static final int L=34; + public static final int LEFT=35; + public static final int M=36; + public static final int N=37; + public static final int O=38; + public static final int ON=39; + public static final int OR=40; + public static final int ORDER=41; + public static final int OVER=42; + public static final int P=43; + public static final int PRE_SET=44; + public static final int Q=45; + public static final int R=46; + public static final int RIGHT=47; + public static final int ROWNUMBER=48; + public static final int S=49; + public static final int SELECT=50; + public static final int SET=51; + public static final int T=52; + public static final int TEXT_STRING=53; + public static final int U=54; + public static final int UPDATE=55; + public static final int V=56; + public static final int VALUES=57; + public static final int W=58; + public static final int WHERE=59; + public static final int WS=60; + public static final int X=61; + public static final int Y=62; + public static final int Z=63; + + // delegates + // delegators + public Lexer[] getDelegates() { + return new Lexer[] {}; + } + + public AntlrV3SQLLexer() {} + public AntlrV3SQLLexer(CharStream input) { + this(input, new RecognizerSharedState()); + } + public AntlrV3SQLLexer(CharStream input, RecognizerSharedState state) { + super(input,state); + } + public String getGrammarFileName() { return "AntlrV3SQL.g"; } + + // $ANTLR start "T__64" + public final void mT__64() throws RecognitionException { + try { + int _type = T__64; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:2:7: ( '!=' ) + // AntlrV3SQL.g:2:9: '!=' + { + match("!="); + + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__64" + + // $ANTLR start "T__65" + public final void mT__65() throws RecognitionException { + try { + int _type = T__65; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:3:7: ( '*' ) + // AntlrV3SQL.g:3:9: '*' + { + match('*'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__65" + + // $ANTLR start "T__66" + public final void mT__66() throws RecognitionException { + try { + int _type = T__66; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:4:7: ( ',' ) + // AntlrV3SQL.g:4:9: ',' + { + match(','); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__66" + + // $ANTLR start "T__67" + public final void mT__67() throws RecognitionException { + try { + int _type = T__67; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:5:7: ( '.' ) + // AntlrV3SQL.g:5:9: '.' + { + match('.'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__67" + + // $ANTLR start "T__68" + public final void mT__68() throws RecognitionException { + try { + int _type = T__68; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:6:7: ( '<' ) + // AntlrV3SQL.g:6:9: '<' + { + match('<'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__68" + + // $ANTLR start "T__69" + public final void mT__69() throws RecognitionException { + try { + int _type = T__69; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:7:7: ( '<=' ) + // AntlrV3SQL.g:7:9: '<=' + { + match("<="); + + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__69" + + // $ANTLR start "T__70" + public final void mT__70() throws RecognitionException { + try { + int _type = T__70; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:8:7: ( '<>' ) + // AntlrV3SQL.g:8:9: '<>' + { + match("<>"); + + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__70" + + // $ANTLR start "T__71" + public final void mT__71() throws RecognitionException { + try { + int _type = T__71; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:9:7: ( '=' ) + // AntlrV3SQL.g:9:9: '=' + { + match('='); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__71" + + // $ANTLR start "T__72" + public final void mT__72() throws RecognitionException { + try { + int _type = T__72; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:10:7: ( '>' ) + // AntlrV3SQL.g:10:9: '>' + { + match('>'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__72" + + // $ANTLR start "T__73" + public final void mT__73() throws RecognitionException { + try { + int _type = T__73; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:11:7: ( '>=' ) + // AntlrV3SQL.g:11:9: '>=' + { + match(">="); + + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__73" + + // $ANTLR start "T__74" + public final void mT__74() throws RecognitionException { + try { + int _type = T__74; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:12:7: ( '\\(' ) + // AntlrV3SQL.g:12:9: '\\(' + { + match('('); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__74" + + // $ANTLR start "T__75" + public final void mT__75() throws RecognitionException { + try { + int _type = T__75; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:13:7: ( '\\)' ) + // AntlrV3SQL.g:13:9: '\\)' + { + match(')'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T__75" + + // $ANTLR start "SELECT" + public final void mSELECT() throws RecognitionException { + try { + int _type = SELECT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:198:8: ( S E L E C T ) + // AntlrV3SQL.g:198:9: S E L E C T + { + mS(); + + + mE(); + + + mL(); + + + mE(); + + + mC(); + + + mT(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "SELECT" + + // $ANTLR start "INSERT" + public final void mINSERT() throws RecognitionException { + try { + int _type = INSERT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:199:9: ( I N S E R T ) + // AntlrV3SQL.g:199:10: I N S E R T + { + mI(); + + + mN(); + + + mS(); + + + mE(); + + + mR(); + + + mT(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "INSERT" + + // $ANTLR start "UPDATE" + public final void mUPDATE() throws RecognitionException { + try { + int _type = UPDATE; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:200:8: ( U P D A T E ) + // AntlrV3SQL.g:200:9: U P D A T E + { + mU(); + + + mP(); + + + mD(); + + + mA(); + + + mT(); + + + mE(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "UPDATE" + + // $ANTLR start "DELETE" + public final void mDELETE() throws RecognitionException { + try { + int _type = DELETE; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:201:8: ( D E L E T E ) + // AntlrV3SQL.g:201:9: D E L E T E + { + mD(); + + + mE(); + + + mL(); + + + mE(); + + + mT(); + + + mE(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "DELETE" + + // $ANTLR start "ROWNUMBER" + public final void mROWNUMBER() throws RecognitionException { + try { + int _type = ROWNUMBER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:203:2: ( R O W N U M B E R ) + // AntlrV3SQL.g:203:3: R O W N U M B E R + { + mR(); + + + mO(); + + + mW(); + + + mN(); + + + mU(); + + + mM(); + + + mB(); + + + mE(); + + + mR(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "ROWNUMBER" + + // $ANTLR start "OVER" + public final void mOVER() throws RecognitionException { + try { + int _type = OVER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:204:6: ( O V E R ) + // AntlrV3SQL.g:204:7: O V E R + { + mO(); + + + mV(); + + + mE(); + + + mR(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "OVER" + + // $ANTLR start "BETWEEN" + public final void mBETWEEN() throws RecognitionException { + try { + int _type = BETWEEN; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:205:9: ( B E T W E E N ) + // AntlrV3SQL.g:205:10: B E T W E E N + { + mB(); + + + mE(); + + + mT(); + + + mW(); + + + mE(); + + + mE(); + + + mN(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "BETWEEN" + + // $ANTLR start "AND" + public final void mAND() throws RecognitionException { + try { + int _type = AND; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:206:5: ( A N D ) + // AntlrV3SQL.g:206:6: A N D + { + mA(); + + + mN(); + + + mD(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "AND" + + // $ANTLR start "OR" + public final void mOR() throws RecognitionException { + try { + int _type = OR; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:207:4: ( O R ) + // AntlrV3SQL.g:207:5: O R + { + mO(); + + + mR(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "OR" + + // $ANTLR start "WHERE" + public final void mWHERE() throws RecognitionException { + try { + int _type = WHERE; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:208:7: ( W H E R E ) + // AntlrV3SQL.g:208:8: W H E R E + { + mW(); + + + mH(); + + + mE(); + + + mR(); + + + mE(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "WHERE" + + // $ANTLR start "GROUP" + public final void mGROUP() throws RecognitionException { + try { + int _type = GROUP; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:209:7: ( G R O U P ) + // AntlrV3SQL.g:209:8: G R O U P + { + mG(); + + + mR(); + + + mO(); + + + mU(); + + + mP(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "GROUP" + + // $ANTLR start "HAVING" + public final void mHAVING() throws RecognitionException { + try { + int _type = HAVING; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:210:8: ( H A V I N G ) + // AntlrV3SQL.g:210:9: H A V I N G + { + mH(); + + + mA(); + + + mV(); + + + mI(); + + + mN(); + + + mG(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "HAVING" + + // $ANTLR start "BY" + public final void mBY() throws RecognitionException { + try { + int _type = BY; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:211:4: ( B Y ) + // AntlrV3SQL.g:211:5: B Y + { + mB(); + + + mY(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "BY" + + // $ANTLR start "ORDER" + public final void mORDER() throws RecognitionException { + try { + int _type = ORDER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:212:7: ( O R D E R ) + // AntlrV3SQL.g:212:8: O R D E R + { + mO(); + + + mR(); + + + mD(); + + + mE(); + + + mR(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "ORDER" + + // $ANTLR start "DESC" + public final void mDESC() throws RecognitionException { + try { + int _type = DESC; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:213:6: ( D E S C ) + // AntlrV3SQL.g:213:7: D E S C + { + mD(); + + + mE(); + + + mS(); + + + mC(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "DESC" + + // $ANTLR start "ASC" + public final void mASC() throws RecognitionException { + try { + int _type = ASC; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:214:5: ( A S C ) + // AntlrV3SQL.g:214:6: A S C + { + mA(); + + + mS(); + + + mC(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "ASC" + + // $ANTLR start "SET" + public final void mSET() throws RecognitionException { + try { + int _type = SET; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:215:5: ( S E T ) + // AntlrV3SQL.g:215:6: S E T + { + mS(); + + + mE(); + + + mT(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "SET" + + // $ANTLR start "ON" + public final void mON() throws RecognitionException { + try { + int _type = ON; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:216:4: ( O N ) + // AntlrV3SQL.g:216:5: O N + { + mO(); + + + mN(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "ON" + + // $ANTLR start "FULL" + public final void mFULL() throws RecognitionException { + try { + int _type = FULL; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:217:6: ( F U L L ) + // AntlrV3SQL.g:217:7: F U L L + { + mF(); + + + mU(); + + + mL(); + + + mL(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "FULL" + + // $ANTLR start "INNER" + public final void mINNER() throws RecognitionException { + try { + int _type = INNER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:218:7: ( I N N E R ) + // AntlrV3SQL.g:218:8: I N N E R + { + mI(); + + + mN(); + + + mN(); + + + mE(); + + + mR(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "INNER" + + // $ANTLR start "AS" + public final void mAS() throws RecognitionException { + try { + int _type = AS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:219:4: ( A S ) + // AntlrV3SQL.g:219:5: A S + { + mA(); + + + mS(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "AS" + + // $ANTLR start "FROM" + public final void mFROM() throws RecognitionException { + try { + int _type = FROM; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:220:6: ( F R O M ) + // AntlrV3SQL.g:220:7: F R O M + { + mF(); + + + mR(); + + + mO(); + + + mM(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "FROM" + + // $ANTLR start "LEFT" + public final void mLEFT() throws RecognitionException { + try { + int _type = LEFT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:221:6: ( L E F T ) + // AntlrV3SQL.g:221:7: L E F T + { + mL(); + + + mE(); + + + mF(); + + + mT(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "LEFT" + + // $ANTLR start "RIGHT" + public final void mRIGHT() throws RecognitionException { + try { + int _type = RIGHT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:222:7: ( R I G H T ) + // AntlrV3SQL.g:222:8: R I G H T + { + mR(); + + + mI(); + + + mG(); + + + mH(); + + + mT(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "RIGHT" + + // $ANTLR start "CROSS" + public final void mCROSS() throws RecognitionException { + try { + int _type = CROSS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:223:7: ( C R O S S ) + // AntlrV3SQL.g:223:8: C R O S S + { + mC(); + + + mR(); + + + mO(); + + + mS(); + + + mS(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "CROSS" + + // $ANTLR start "JOIN" + public final void mJOIN() throws RecognitionException { + try { + int _type = JOIN; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:224:6: ( J O I N ) + // AntlrV3SQL.g:224:7: J O I N + { + mJ(); + + + mO(); + + + mI(); + + + mN(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "JOIN" + + // $ANTLR start "VALUES" + public final void mVALUES() throws RecognitionException { + try { + int _type = VALUES; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:225:8: ( V A L U E S ) + // AntlrV3SQL.g:225:9: V A L U E S + { + mV(); + + + mA(); + + + mL(); + + + mU(); + + + mE(); + + + mS(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "VALUES" + + // $ANTLR start "INTO" + public final void mINTO() throws RecognitionException { + try { + int _type = INTO; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:226:6: ( I N T O ) + // AntlrV3SQL.g:226:7: I N T O + { + mI(); + + + mN(); + + + mT(); + + + mO(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "INTO" + + // $ANTLR start "IN" + public final void mIN() throws RecognitionException { + try { + int _type = IN; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:227:4: ( I N ) + // AntlrV3SQL.g:227:5: I N + { + mI(); + + + mN(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "IN" + + // $ANTLR start "EXISTS" + public final void mEXISTS() throws RecognitionException { + try { + int _type = EXISTS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:228:8: ( E X I S T S ) + // AntlrV3SQL.g:228:9: E X I S T S + { + mE(); + + + mX(); + + + mI(); + + + mS(); + + + mT(); + + + mS(); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "EXISTS" + + // $ANTLR start "PRE_SET" + public final void mPRE_SET() throws RecognitionException { + try { + int _type = PRE_SET; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:229:9: ( '?' ) + // AntlrV3SQL.g:229:10: '?' + { + match('?'); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "PRE_SET" + + // $ANTLR start "BASIC_NAME" + public final void mBASIC_NAME() throws RecognitionException { + try { + int _type = BASIC_NAME; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:232:2: ( ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )+ ) + // AntlrV3SQL.g:233:2: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )+ + { + // AntlrV3SQL.g:233:2: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )+ + int cnt1=0; + loop1: + do { + int alt1=2; + int LA1_0 = input.LA(1); + + if ( ((LA1_0 >= '0' && LA1_0 <= '9')||(LA1_0 >= 'A' && LA1_0 <= 'Z')||LA1_0=='_'||(LA1_0 >= 'a' && LA1_0 <= 'z')) ) { + alt1=1; + } + + + switch (alt1) { + case 1 : + // AntlrV3SQL.g: + { + if ( (input.LA(1) >= '0' && input.LA(1) <= '9')||(input.LA(1) >= 'A' && input.LA(1) <= 'Z')||input.LA(1)=='_'||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + break; + + default : + if ( cnt1 >= 1 ) break loop1; + EarlyExitException eee = + new EarlyExitException(1, input); + throw eee; + } + cnt1++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "BASIC_NAME" + + // $ANTLR start "TEXT_STRING" + public final void mTEXT_STRING() throws RecognitionException { + try { + int _type = TEXT_STRING; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:235:12: ( ( '\\'' ( options {greedy=true; } :~ ( '\\'' | '\\r' | '\\n' ) | '\\'' '\\'' )* '\\'' ) ) + // AntlrV3SQL.g:236:4: ( '\\'' ( options {greedy=true; } :~ ( '\\'' | '\\r' | '\\n' ) | '\\'' '\\'' )* '\\'' ) + { + // AntlrV3SQL.g:236:4: ( '\\'' ( options {greedy=true; } :~ ( '\\'' | '\\r' | '\\n' ) | '\\'' '\\'' )* '\\'' ) + // AntlrV3SQL.g:236:5: '\\'' ( options {greedy=true; } :~ ( '\\'' | '\\r' | '\\n' ) | '\\'' '\\'' )* '\\'' + { + match('\''); + + // AntlrV3SQL.g:237:5: ( options {greedy=true; } :~ ( '\\'' | '\\r' | '\\n' ) | '\\'' '\\'' )* + loop2: + do { + int alt2=3; + int LA2_0 = input.LA(1); + + if ( (LA2_0=='\'') ) { + int LA2_1 = input.LA(2); + + if ( (LA2_1=='\'') ) { + alt2=2; + } + + + } + else if ( ((LA2_0 >= '\u0000' && LA2_0 <= '\t')||(LA2_0 >= '\u000B' && LA2_0 <= '\f')||(LA2_0 >= '\u000E' && LA2_0 <= '&')||(LA2_0 >= '(' && LA2_0 <= '\uFFFF')) ) { + alt2=1; + } + + + switch (alt2) { + case 1 : + // AntlrV3SQL.g:238:31: ~ ( '\\'' | '\\r' | '\\n' ) + { + if ( (input.LA(1) >= '\u0000' && input.LA(1) <= '\t')||(input.LA(1) >= '\u000B' && input.LA(1) <= '\f')||(input.LA(1) >= '\u000E' && input.LA(1) <= '&')||(input.LA(1) >= '(' && input.LA(1) <= '\uFFFF') ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + break; + case 2 : + // AntlrV3SQL.g:238:56: '\\'' '\\'' + { + match('\''); + + match('\''); + + } + break; + + default : + break loop2; + } + } while (true); + + + match('\''); + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "TEXT_STRING" + + // $ANTLR start "WS" + public final void mWS() throws RecognitionException { + try { + int _type = WS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // AntlrV3SQL.g:244:5: ( ( ' ' | '\\t' | '\\r' | '\\n' ) ) + // AntlrV3SQL.g:244:9: ( ' ' | '\\t' | '\\r' | '\\n' ) + { + if ( (input.LA(1) >= '\t' && input.LA(1) <= '\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + _channel=HIDDEN; + + } + + state.type = _type; + state.channel = _channel; + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "WS" + + // $ANTLR start "A" + public final void mA() throws RecognitionException { + try { + // AntlrV3SQL.g:252:11: ( ( 'a' | 'A' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='A'||input.LA(1)=='a' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "A" + + // $ANTLR start "B" + public final void mB() throws RecognitionException { + try { + // AntlrV3SQL.g:253:11: ( ( 'b' | 'B' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='B'||input.LA(1)=='b' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "B" + + // $ANTLR start "C" + public final void mC() throws RecognitionException { + try { + // AntlrV3SQL.g:254:11: ( ( 'c' | 'C' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='C'||input.LA(1)=='c' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "C" + + // $ANTLR start "D" + public final void mD() throws RecognitionException { + try { + // AntlrV3SQL.g:255:11: ( ( 'd' | 'D' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='D'||input.LA(1)=='d' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "D" + + // $ANTLR start "E" + public final void mE() throws RecognitionException { + try { + // AntlrV3SQL.g:256:11: ( ( 'e' | 'E' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='E'||input.LA(1)=='e' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "E" + + // $ANTLR start "F" + public final void mF() throws RecognitionException { + try { + // AntlrV3SQL.g:257:11: ( ( 'f' | 'F' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='F'||input.LA(1)=='f' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "F" + + // $ANTLR start "G" + public final void mG() throws RecognitionException { + try { + // AntlrV3SQL.g:258:11: ( ( 'g' | 'G' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='G'||input.LA(1)=='g' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "G" + + // $ANTLR start "H" + public final void mH() throws RecognitionException { + try { + // AntlrV3SQL.g:259:11: ( ( 'h' | 'H' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='H'||input.LA(1)=='h' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "H" + + // $ANTLR start "I" + public final void mI() throws RecognitionException { + try { + // AntlrV3SQL.g:260:11: ( ( 'i' | 'I' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='I'||input.LA(1)=='i' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "I" + + // $ANTLR start "J" + public final void mJ() throws RecognitionException { + try { + // AntlrV3SQL.g:261:11: ( ( 'j' | 'J' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='J'||input.LA(1)=='j' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "J" + + // $ANTLR start "K" + public final void mK() throws RecognitionException { + try { + // AntlrV3SQL.g:262:11: ( ( 'k' | 'K' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='K'||input.LA(1)=='k' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "K" + + // $ANTLR start "L" + public final void mL() throws RecognitionException { + try { + // AntlrV3SQL.g:263:11: ( ( 'l' | 'L' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='L'||input.LA(1)=='l' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "L" + + // $ANTLR start "M" + public final void mM() throws RecognitionException { + try { + // AntlrV3SQL.g:264:11: ( ( 'm' | 'M' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='M'||input.LA(1)=='m' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "M" + + // $ANTLR start "N" + public final void mN() throws RecognitionException { + try { + // AntlrV3SQL.g:265:11: ( ( 'n' | 'N' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='N'||input.LA(1)=='n' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "N" + + // $ANTLR start "O" + public final void mO() throws RecognitionException { + try { + // AntlrV3SQL.g:266:11: ( ( 'o' | 'O' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='O'||input.LA(1)=='o' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "O" + + // $ANTLR start "P" + public final void mP() throws RecognitionException { + try { + // AntlrV3SQL.g:267:11: ( ( 'p' | 'P' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='P'||input.LA(1)=='p' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "P" + + // $ANTLR start "Q" + public final void mQ() throws RecognitionException { + try { + // AntlrV3SQL.g:268:11: ( ( 'q' | 'Q' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='Q'||input.LA(1)=='q' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "Q" + + // $ANTLR start "R" + public final void mR() throws RecognitionException { + try { + // AntlrV3SQL.g:269:11: ( ( 'r' | 'R' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='R'||input.LA(1)=='r' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "R" + + // $ANTLR start "S" + public final void mS() throws RecognitionException { + try { + // AntlrV3SQL.g:270:11: ( ( 's' | 'S' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='S'||input.LA(1)=='s' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "S" + + // $ANTLR start "T" + public final void mT() throws RecognitionException { + try { + // AntlrV3SQL.g:271:11: ( ( 't' | 'T' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='T'||input.LA(1)=='t' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "T" + + // $ANTLR start "U" + public final void mU() throws RecognitionException { + try { + // AntlrV3SQL.g:272:11: ( ( 'u' | 'U' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='U'||input.LA(1)=='u' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "U" + + // $ANTLR start "V" + public final void mV() throws RecognitionException { + try { + // AntlrV3SQL.g:273:11: ( ( 'v' | 'V' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='V'||input.LA(1)=='v' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "V" + + // $ANTLR start "W" + public final void mW() throws RecognitionException { + try { + // AntlrV3SQL.g:274:11: ( ( 'w' | 'W' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='W'||input.LA(1)=='w' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "W" + + // $ANTLR start "X" + public final void mX() throws RecognitionException { + try { + // AntlrV3SQL.g:275:11: ( ( 'x' | 'X' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='X'||input.LA(1)=='x' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "X" + + // $ANTLR start "Y" + public final void mY() throws RecognitionException { + try { + // AntlrV3SQL.g:276:11: ( ( 'y' | 'Y' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='Y'||input.LA(1)=='y' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "Y" + + // $ANTLR start "Z" + public final void mZ() throws RecognitionException { + try { + // AntlrV3SQL.g:277:11: ( ( 'z' | 'Z' ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)=='Z'||input.LA(1)=='z' ) { + input.consume(); + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse; + } + + + } + + + } + finally { + // do for sure before leaving + } + } + // $ANTLR end "Z" + + public void mTokens() throws RecognitionException { + // AntlrV3SQL.g:1:8: ( T__64 | T__65 | T__66 | T__67 | T__68 | T__69 | T__70 | T__71 | T__72 | T__73 | T__74 | T__75 | SELECT | INSERT | UPDATE | DELETE | ROWNUMBER | OVER | BETWEEN | AND | OR | WHERE | GROUP | HAVING | BY | ORDER | DESC | ASC | SET | ON | FULL | INNER | AS | FROM | LEFT | RIGHT | CROSS | JOIN | VALUES | INTO | IN | EXISTS | PRE_SET | BASIC_NAME | TEXT_STRING | WS ) + int alt3=46; + alt3 = dfa3.predict(input); + switch (alt3) { + case 1 : + // AntlrV3SQL.g:1:10: T__64 + { + mT__64(); + + + } + break; + case 2 : + // AntlrV3SQL.g:1:16: T__65 + { + mT__65(); + + + } + break; + case 3 : + // AntlrV3SQL.g:1:22: T__66 + { + mT__66(); + + + } + break; + case 4 : + // AntlrV3SQL.g:1:28: T__67 + { + mT__67(); + + + } + break; + case 5 : + // AntlrV3SQL.g:1:34: T__68 + { + mT__68(); + + + } + break; + case 6 : + // AntlrV3SQL.g:1:40: T__69 + { + mT__69(); + + + } + break; + case 7 : + // AntlrV3SQL.g:1:46: T__70 + { + mT__70(); + + + } + break; + case 8 : + // AntlrV3SQL.g:1:52: T__71 + { + mT__71(); + + + } + break; + case 9 : + // AntlrV3SQL.g:1:58: T__72 + { + mT__72(); + + + } + break; + case 10 : + // AntlrV3SQL.g:1:64: T__73 + { + mT__73(); + + + } + break; + case 11 : + // AntlrV3SQL.g:1:70: T__74 + { + mT__74(); + + + } + break; + case 12 : + // AntlrV3SQL.g:1:76: T__75 + { + mT__75(); + + + } + break; + case 13 : + // AntlrV3SQL.g:1:82: SELECT + { + mSELECT(); + + + } + break; + case 14 : + // AntlrV3SQL.g:1:89: INSERT + { + mINSERT(); + + + } + break; + case 15 : + // AntlrV3SQL.g:1:96: UPDATE + { + mUPDATE(); + + + } + break; + case 16 : + // AntlrV3SQL.g:1:103: DELETE + { + mDELETE(); + + + } + break; + case 17 : + // AntlrV3SQL.g:1:110: ROWNUMBER + { + mROWNUMBER(); + + + } + break; + case 18 : + // AntlrV3SQL.g:1:120: OVER + { + mOVER(); + + + } + break; + case 19 : + // AntlrV3SQL.g:1:125: BETWEEN + { + mBETWEEN(); + + + } + break; + case 20 : + // AntlrV3SQL.g:1:133: AND + { + mAND(); + + + } + break; + case 21 : + // AntlrV3SQL.g:1:137: OR + { + mOR(); + + + } + break; + case 22 : + // AntlrV3SQL.g:1:140: WHERE + { + mWHERE(); + + + } + break; + case 23 : + // AntlrV3SQL.g:1:146: GROUP + { + mGROUP(); + + + } + break; + case 24 : + // AntlrV3SQL.g:1:152: HAVING + { + mHAVING(); + + + } + break; + case 25 : + // AntlrV3SQL.g:1:159: BY + { + mBY(); + + + } + break; + case 26 : + // AntlrV3SQL.g:1:162: ORDER + { + mORDER(); + + + } + break; + case 27 : + // AntlrV3SQL.g:1:168: DESC + { + mDESC(); + + + } + break; + case 28 : + // AntlrV3SQL.g:1:173: ASC + { + mASC(); + + + } + break; + case 29 : + // AntlrV3SQL.g:1:177: SET + { + mSET(); + + + } + break; + case 30 : + // AntlrV3SQL.g:1:181: ON + { + mON(); + + + } + break; + case 31 : + // AntlrV3SQL.g:1:184: FULL + { + mFULL(); + + + } + break; + case 32 : + // AntlrV3SQL.g:1:189: INNER + { + mINNER(); + + + } + break; + case 33 : + // AntlrV3SQL.g:1:195: AS + { + mAS(); + + + } + break; + case 34 : + // AntlrV3SQL.g:1:198: FROM + { + mFROM(); + + + } + break; + case 35 : + // AntlrV3SQL.g:1:203: LEFT + { + mLEFT(); + + + } + break; + case 36 : + // AntlrV3SQL.g:1:208: RIGHT + { + mRIGHT(); + + + } + break; + case 37 : + // AntlrV3SQL.g:1:214: CROSS + { + mCROSS(); + + + } + break; + case 38 : + // AntlrV3SQL.g:1:220: JOIN + { + mJOIN(); + + + } + break; + case 39 : + // AntlrV3SQL.g:1:225: VALUES + { + mVALUES(); + + + } + break; + case 40 : + // AntlrV3SQL.g:1:232: INTO + { + mINTO(); + + + } + break; + case 41 : + // AntlrV3SQL.g:1:237: IN + { + mIN(); + + + } + break; + case 42 : + // AntlrV3SQL.g:1:240: EXISTS + { + mEXISTS(); + + + } + break; + case 43 : + // AntlrV3SQL.g:1:247: PRE_SET + { + mPRE_SET(); + + + } + break; + case 44 : + // AntlrV3SQL.g:1:255: BASIC_NAME + { + mBASIC_NAME(); + + + } + break; + case 45 : + // AntlrV3SQL.g:1:266: TEXT_STRING + { + mTEXT_STRING(); + + + } + break; + case 46 : + // AntlrV3SQL.g:1:278: WS + { + mWS(); + + + } + break; + + } + + } + + + protected DFA3 dfa3 = new DFA3(this); + static final String DFA3_eotS = + "\5\uffff\1\41\1\uffff\1\43\2\uffff\21\34\11\uffff\1\34\1\75\5\34"+ + "\1\107\1\111\1\34\1\113\1\34\1\115\13\34\1\132\1\uffff\11\34\1\uffff"+ + "\1\34\1\uffff\1\34\1\uffff\1\146\1\uffff\1\147\13\34\1\uffff\2\34"+ + "\1\165\2\34\1\170\2\34\1\173\2\34\2\uffff\3\34\1\u0081\1\u0082\1"+ + "\u0083\1\34\1\u0085\4\34\1\u008a\1\uffff\2\34\1\uffff\1\34\1\u008e"+ + "\1\uffff\1\u008f\1\34\1\u0091\1\u0092\1\34\3\uffff\1\u0094\1\uffff"+ + "\2\34\1\u0097\1\u0098\1\uffff\1\u0099\1\u009a\1\34\2\uffff\1\34"+ + "\2\uffff\1\u009d\1\uffff\1\u009e\1\u009f\4\uffff\1\34\1\u00a1\3"+ + "\uffff\1\34\1\uffff\1\u00a3\1\uffff"; + static final String DFA3_eofS = + "\u00a4\uffff"; + static final String DFA3_minS = + "\1\11\4\uffff\1\75\1\uffff\1\75\2\uffff\1\105\1\116\1\120\1\105"+ + "\1\111\1\116\1\105\1\116\1\110\1\122\1\101\1\122\1\105\1\122\1\117"+ + "\1\101\1\130\11\uffff\1\114\1\60\1\104\1\114\1\127\1\107\1\105\2"+ + "\60\1\124\1\60\1\104\1\60\1\105\1\117\1\126\1\114\1\117\1\106\1"+ + "\117\1\111\1\114\1\111\1\105\1\60\1\uffff\2\105\1\117\1\101\1\105"+ + "\1\103\1\116\1\110\1\122\1\uffff\1\105\1\uffff\1\127\1\uffff\1\60"+ + "\1\uffff\1\60\1\122\1\125\1\111\1\114\1\115\1\124\1\123\1\116\1"+ + "\125\1\123\1\103\1\uffff\2\122\1\60\2\124\1\60\1\125\1\124\1\60"+ + "\1\122\1\105\2\uffff\1\105\1\120\1\116\3\60\1\123\1\60\1\105\3\124"+ + "\1\60\1\uffff\2\105\1\uffff\1\115\1\60\1\uffff\1\60\1\105\2\60\1"+ + "\107\3\uffff\1\60\1\uffff\2\123\2\60\1\uffff\2\60\1\102\2\uffff"+ + "\1\116\2\uffff\1\60\1\uffff\2\60\4\uffff\1\105\1\60\3\uffff\1\122"+ + "\1\uffff\1\60\1\uffff"; + static final String DFA3_maxS = + "\1\172\4\uffff\1\76\1\uffff\1\75\2\uffff\1\145\1\156\1\160\1\145"+ + "\1\157\1\166\1\171\1\163\1\150\1\162\1\141\1\165\1\145\1\162\1\157"+ + "\1\141\1\170\11\uffff\1\164\1\172\1\144\1\163\1\167\1\147\1\145"+ + "\2\172\1\164\1\172\1\144\1\172\1\145\1\157\1\166\1\154\1\157\1\146"+ + "\1\157\1\151\1\154\1\151\1\145\1\172\1\uffff\2\145\1\157\1\141\1"+ + "\145\1\143\1\156\1\150\1\162\1\uffff\1\145\1\uffff\1\167\1\uffff"+ + "\1\172\1\uffff\1\172\1\162\1\165\1\151\1\154\1\155\1\164\1\163\1"+ + "\156\1\165\1\163\1\143\1\uffff\2\162\1\172\2\164\1\172\1\165\1\164"+ + "\1\172\1\162\1\145\2\uffff\1\145\1\160\1\156\3\172\1\163\1\172\1"+ + "\145\3\164\1\172\1\uffff\2\145\1\uffff\1\155\1\172\1\uffff\1\172"+ + "\1\145\2\172\1\147\3\uffff\1\172\1\uffff\2\163\2\172\1\uffff\2\172"+ + "\1\142\2\uffff\1\156\2\uffff\1\172\1\uffff\2\172\4\uffff\1\145\1"+ + "\172\3\uffff\1\162\1\uffff\1\172\1\uffff"; + static final String DFA3_acceptS = + "\1\uffff\1\1\1\2\1\3\1\4\1\uffff\1\10\1\uffff\1\13\1\14\21\uffff"+ + "\1\53\1\54\1\55\1\56\1\6\1\7\1\5\1\12\1\11\31\uffff\1\51\11\uffff"+ + "\1\25\1\uffff\1\36\1\uffff\1\31\1\uffff\1\41\14\uffff\1\35\13\uffff"+ + "\1\24\1\34\15\uffff\1\50\2\uffff\1\33\2\uffff\1\22\5\uffff\1\37"+ + "\1\42\1\43\1\uffff\1\46\4\uffff\1\40\3\uffff\1\44\1\32\1\uffff\1"+ + "\26\1\27\1\uffff\1\45\2\uffff\1\15\1\16\1\17\1\20\2\uffff\1\30\1"+ + "\47\1\52\1\uffff\1\23\1\uffff\1\21"; + static final String DFA3_specialS = + "\u00a4\uffff}>"; + static final String[] DFA3_transitionS = { + "\2\36\2\uffff\1\36\22\uffff\1\36\1\1\5\uffff\1\35\1\10\1\11"+ + "\1\2\1\uffff\1\3\1\uffff\1\4\1\uffff\12\34\2\uffff\1\5\1\6\1"+ + "\7\1\33\1\uffff\1\21\1\20\1\27\1\15\1\32\1\25\1\23\1\24\1\13"+ + "\1\30\1\34\1\26\2\34\1\17\2\34\1\16\1\12\1\34\1\14\1\31\1\22"+ + "\3\34\4\uffff\1\34\1\uffff\1\21\1\20\1\27\1\15\1\32\1\25\1\23"+ + "\1\24\1\13\1\30\1\34\1\26\2\34\1\17\2\34\1\16\1\12\1\34\1\14"+ + "\1\31\1\22\3\34", + "", + "", + "", + "", + "\1\37\1\40", + "", + "\1\42", + "", + "", + "\1\44\37\uffff\1\44", + "\1\45\37\uffff\1\45", + "\1\46\37\uffff\1\46", + "\1\47\37\uffff\1\47", + "\1\51\5\uffff\1\50\31\uffff\1\51\5\uffff\1\50", + "\1\54\3\uffff\1\53\3\uffff\1\52\27\uffff\1\54\3\uffff\1\53"+ + "\3\uffff\1\52", + "\1\55\23\uffff\1\56\13\uffff\1\55\23\uffff\1\56", + "\1\57\4\uffff\1\60\32\uffff\1\57\4\uffff\1\60", + "\1\61\37\uffff\1\61", + "\1\62\37\uffff\1\62", + "\1\63\37\uffff\1\63", + "\1\65\2\uffff\1\64\34\uffff\1\65\2\uffff\1\64", + "\1\66\37\uffff\1\66", + "\1\67\37\uffff\1\67", + "\1\70\37\uffff\1\70", + "\1\71\37\uffff\1\71", + "\1\72\37\uffff\1\72", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "\1\73\7\uffff\1\74\27\uffff\1\73\7\uffff\1\74", + "\12\34\7\uffff\15\34\1\77\4\34\1\76\1\100\6\34\4\uffff\1\34"+ + "\1\uffff\15\34\1\77\4\34\1\76\1\100\6\34", + "\1\101\37\uffff\1\101", + "\1\102\6\uffff\1\103\30\uffff\1\102\6\uffff\1\103", + "\1\104\37\uffff\1\104", + "\1\105\37\uffff\1\105", + "\1\106\37\uffff\1\106", + "\12\34\7\uffff\3\34\1\110\26\34\4\uffff\1\34\1\uffff\3\34\1"+ + "\110\26\34", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\112\37\uffff\1\112", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\114\37\uffff\1\114", + "\12\34\7\uffff\2\34\1\116\27\34\4\uffff\1\34\1\uffff\2\34\1"+ + "\116\27\34", + "\1\117\37\uffff\1\117", + "\1\120\37\uffff\1\120", + "\1\121\37\uffff\1\121", + "\1\122\37\uffff\1\122", + "\1\123\37\uffff\1\123", + "\1\124\37\uffff\1\124", + "\1\125\37\uffff\1\125", + "\1\126\37\uffff\1\126", + "\1\127\37\uffff\1\127", + "\1\130\37\uffff\1\130", + "\1\131\37\uffff\1\131", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "", + "\1\133\37\uffff\1\133", + "\1\134\37\uffff\1\134", + "\1\135\37\uffff\1\135", + "\1\136\37\uffff\1\136", + "\1\137\37\uffff\1\137", + "\1\140\37\uffff\1\140", + "\1\141\37\uffff\1\141", + "\1\142\37\uffff\1\142", + "\1\143\37\uffff\1\143", + "", + "\1\144\37\uffff\1\144", + "", + "\1\145\37\uffff\1\145", + "", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\150\37\uffff\1\150", + "\1\151\37\uffff\1\151", + "\1\152\37\uffff\1\152", + "\1\153\37\uffff\1\153", + "\1\154\37\uffff\1\154", + "\1\155\37\uffff\1\155", + "\1\156\37\uffff\1\156", + "\1\157\37\uffff\1\157", + "\1\160\37\uffff\1\160", + "\1\161\37\uffff\1\161", + "\1\162\37\uffff\1\162", + "", + "\1\163\37\uffff\1\163", + "\1\164\37\uffff\1\164", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\166\37\uffff\1\166", + "\1\167\37\uffff\1\167", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\171\37\uffff\1\171", + "\1\172\37\uffff\1\172", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\174\37\uffff\1\174", + "\1\175\37\uffff\1\175", + "", + "", + "\1\176\37\uffff\1\176", + "\1\177\37\uffff\1\177", + "\1\u0080\37\uffff\1\u0080", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\u0084\37\uffff\1\u0084", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\u0086\37\uffff\1\u0086", + "\1\u0087\37\uffff\1\u0087", + "\1\u0088\37\uffff\1\u0088", + "\1\u0089\37\uffff\1\u0089", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "", + "\1\u008b\37\uffff\1\u008b", + "\1\u008c\37\uffff\1\u008c", + "", + "\1\u008d\37\uffff\1\u008d", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\u0090\37\uffff\1\u0090", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\u0093\37\uffff\1\u0093", + "", + "", + "", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "", + "\1\u0095\37\uffff\1\u0095", + "\1\u0096\37\uffff\1\u0096", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\1\u009b\37\uffff\1\u009b", + "", + "", + "\1\u009c\37\uffff\1\u009c", + "", + "", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "", + "", + "", + "", + "\1\u00a0\37\uffff\1\u00a0", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "", + "", + "", + "\1\u00a2\37\uffff\1\u00a2", + "", + "\12\34\7\uffff\32\34\4\uffff\1\34\1\uffff\32\34", + "" + }; + + static final short[] DFA3_eot = DFA.unpackEncodedString(DFA3_eotS); + static final short[] DFA3_eof = DFA.unpackEncodedString(DFA3_eofS); + static final char[] DFA3_min = DFA.unpackEncodedStringToUnsignedChars(DFA3_minS); + static final char[] DFA3_max = DFA.unpackEncodedStringToUnsignedChars(DFA3_maxS); + static final short[] DFA3_accept = DFA.unpackEncodedString(DFA3_acceptS); + static final short[] DFA3_special = DFA.unpackEncodedString(DFA3_specialS); + static final short[][] DFA3_transition; + + static { + int numStates = DFA3_transitionS.length; + DFA3_transition = new short[numStates][]; + for (int i=0; i", "", "", "", "A", "AND", "AS", "ASC", "B", "BASIC_NAME", "BETWEEN", "BY", "C", "CROSS", "D", "DELETE", "DESC", "E", "EXISTS", "F", "FROM", "FULL", "G", "GROUP", "H", "HAVING", "I", "IN", "INNER", "INSERT", "INTO", "J", "JOIN", "K", "L", "LEFT", "M", "N", "O", "ON", "OR", "ORDER", "OVER", "P", "PRE_SET", "Q", "R", "RIGHT", "ROWNUMBER", "S", "SELECT", "SET", "T", "TEXT_STRING", "U", "UPDATE", "V", "VALUES", "W", "WHERE", "WS", "X", "Y", "Z", "'!='", "'*'", "','", "'.'", "'<'", "'<='", "'<>'", "'='", "'>'", "'>='", "'\\('", "'\\)'" + }; + + public static final int EOF=-1; + public static final int T__64=64; + public static final int T__65=65; + public static final int T__66=66; + public static final int T__67=67; + public static final int T__68=68; + public static final int T__69=69; + public static final int T__70=70; + public static final int T__71=71; + public static final int T__72=72; + public static final int T__73=73; + public static final int T__74=74; + public static final int T__75=75; + public static final int A=4; + public static final int AND=5; + public static final int AS=6; + public static final int ASC=7; + public static final int B=8; + public static final int BASIC_NAME=9; + public static final int BETWEEN=10; + public static final int BY=11; + public static final int C=12; + public static final int CROSS=13; + public static final int D=14; + public static final int DELETE=15; + public static final int DESC=16; + public static final int E=17; + public static final int EXISTS=18; + public static final int F=19; + public static final int FROM=20; + public static final int FULL=21; + public static final int G=22; + public static final int GROUP=23; + public static final int H=24; + public static final int HAVING=25; + public static final int I=26; + public static final int IN=27; + public static final int INNER=28; + public static final int INSERT=29; + public static final int INTO=30; + public static final int J=31; + public static final int JOIN=32; + public static final int K=33; + public static final int L=34; + public static final int LEFT=35; + public static final int M=36; + public static final int N=37; + public static final int O=38; + public static final int ON=39; + public static final int OR=40; + public static final int ORDER=41; + public static final int OVER=42; + public static final int P=43; + public static final int PRE_SET=44; + public static final int Q=45; + public static final int R=46; + public static final int RIGHT=47; + public static final int ROWNUMBER=48; + public static final int S=49; + public static final int SELECT=50; + public static final int SET=51; + public static final int T=52; + public static final int TEXT_STRING=53; + public static final int U=54; + public static final int UPDATE=55; + public static final int V=56; + public static final int VALUES=57; + public static final int W=58; + public static final int WHERE=59; + public static final int WS=60; + public static final int X=61; + public static final int Y=62; + public static final int Z=63; + + // delegates + public Parser[] getDelegates() { + return new Parser[] {}; + } + + // delegators + + + public AntlrV3SQLParser(TokenStream input) { + this(input, new RecognizerSharedState()); + } + public AntlrV3SQLParser(TokenStream input, RecognizerSharedState state) { + super(input, state); + } + + public String[] getTokenNames() { return AntlrV3SQLParser.tokenNames; } + public String getGrammarFileName() { return "AntlrV3SQL.g"; } + + + private AntlrParserDelegate antlrParserDelegate; + + public void setAntlrParserDelegate(AntlrParserDelegate antlrParserDelegate) { + this.antlrParserDelegate = antlrParserDelegate; + } + + @Override + public void reportError(RecognitionException e) { + } + + + + + // $ANTLR start "start" + // AntlrV3SQL.g:21:1: start : ( sql_insert | sql_delete | sql_update | sql_select ); + public final void start() throws RecognitionException { + try { + // AntlrV3SQL.g:21:7: ( sql_insert | sql_delete | sql_update | sql_select ) + int alt1=4; + switch ( input.LA(1) ) { + case INSERT: + { + alt1=1; + } + break; + case DELETE: + { + alt1=2; + } + break; + case UPDATE: + { + alt1=3; + } + break; + case SELECT: + { + alt1=4; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 1, 0, input); + + throw nvae; + + } + + switch (alt1) { + case 1 : + // AntlrV3SQL.g:22:2: sql_insert + { + pushFollow(FOLLOW_sql_insert_in_start23); + sql_insert(); + + state._fsp--; + + + } + break; + case 2 : + // AntlrV3SQL.g:22:13: sql_delete + { + pushFollow(FOLLOW_sql_delete_in_start25); + sql_delete(); + + state._fsp--; + + + } + break; + case 3 : + // AntlrV3SQL.g:22:24: sql_update + { + pushFollow(FOLLOW_sql_update_in_start27); + sql_update(); + + state._fsp--; + + + } + break; + case 4 : + // AntlrV3SQL.g:22:35: sql_select + { + pushFollow(FOLLOW_sql_select_in_start29); + sql_select(); + + state._fsp--; + + + } + break; + + } + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "start" + + + + // $ANTLR start "sql_insert" + // AntlrV3SQL.g:24:1: sql_insert : INSERT INTO table '\\(' insertColumn ( ',' insertColumn )* '\\)' VALUES '\\(' ( PRE_SET | ( ',' PRE_SET ) )* '\\)' ; + public final void sql_insert() throws RecognitionException { + try { + // AntlrV3SQL.g:25:2: ( INSERT INTO table '\\(' insertColumn ( ',' insertColumn )* '\\)' VALUES '\\(' ( PRE_SET | ( ',' PRE_SET ) )* '\\)' ) + // AntlrV3SQL.g:26:2: INSERT INTO table '\\(' insertColumn ( ',' insertColumn )* '\\)' VALUES '\\(' ( PRE_SET | ( ',' PRE_SET ) )* '\\)' + { + match(input,INSERT,FOLLOW_INSERT_in_sql_insert40); + + match(input,INTO,FOLLOW_INTO_in_sql_insert42); + + pushFollow(FOLLOW_table_in_sql_insert44); + table(); + + state._fsp--; + + + match(input,74,FOLLOW_74_in_sql_insert46); + + pushFollow(FOLLOW_insertColumn_in_sql_insert48); + insertColumn(); + + state._fsp--; + + + // AntlrV3SQL.g:26:38: ( ',' insertColumn )* + loop2: + do { + int alt2=2; + int LA2_0 = input.LA(1); + + if ( (LA2_0==66) ) { + alt2=1; + } + + + switch (alt2) { + case 1 : + // AntlrV3SQL.g:26:39: ',' insertColumn + { + match(input,66,FOLLOW_66_in_sql_insert51); + + pushFollow(FOLLOW_insertColumn_in_sql_insert53); + insertColumn(); + + state._fsp--; + + + } + break; + + default : + break loop2; + } + } while (true); + + + match(input,75,FOLLOW_75_in_sql_insert57); + + match(input,VALUES,FOLLOW_VALUES_in_sql_insert59); + + match(input,74,FOLLOW_74_in_sql_insert61); + + // AntlrV3SQL.g:26:75: ( PRE_SET | ( ',' PRE_SET ) )* + loop3: + do { + int alt3=3; + int LA3_0 = input.LA(1); + + if ( (LA3_0==PRE_SET) ) { + alt3=1; + } + else if ( (LA3_0==66) ) { + alt3=2; + } + + + switch (alt3) { + case 1 : + // AntlrV3SQL.g:26:76: PRE_SET + { + match(input,PRE_SET,FOLLOW_PRE_SET_in_sql_insert64); + + } + break; + case 2 : + // AntlrV3SQL.g:26:84: ( ',' PRE_SET ) + { + // AntlrV3SQL.g:26:84: ( ',' PRE_SET ) + // AntlrV3SQL.g:26:85: ',' PRE_SET + { + match(input,66,FOLLOW_66_in_sql_insert67); + + match(input,PRE_SET,FOLLOW_PRE_SET_in_sql_insert69); + + } + + + } + break; + + default : + break loop3; + } + } while (true); + + + match(input,75,FOLLOW_75_in_sql_insert74); + + this.antlrParserDelegate.setSqlOp(AntlrParserDelegate.SQLOP_INSERT); + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "sql_insert" + + + + // $ANTLR start "sql_delete" + // AntlrV3SQL.g:30:1: sql_delete : DELETE FROM table ( WHERE kv_sql )? ; + public final void sql_delete() throws RecognitionException { + try { + // AntlrV3SQL.g:31:2: ( DELETE FROM table ( WHERE kv_sql )? ) + // AntlrV3SQL.g:32:2: DELETE FROM table ( WHERE kv_sql )? + { + match(input,DELETE,FOLLOW_DELETE_in_sql_delete91); + + match(input,FROM,FOLLOW_FROM_in_sql_delete93); + + pushFollow(FOLLOW_table_in_sql_delete95); + table(); + + state._fsp--; + + + // AntlrV3SQL.g:32:20: ( WHERE kv_sql )? + int alt4=2; + int LA4_0 = input.LA(1); + + if ( (LA4_0==WHERE) ) { + alt4=1; + } + switch (alt4) { + case 1 : + // AntlrV3SQL.g:32:21: WHERE kv_sql + { + match(input,WHERE,FOLLOW_WHERE_in_sql_delete98); + + pushFollow(FOLLOW_kv_sql_in_sql_delete100); + kv_sql(); + + state._fsp--; + + + } + break; + + } + + + this.antlrParserDelegate.setSqlOp(AntlrParserDelegate.SQLOP_DELETE); + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "sql_delete" + + + + // $ANTLR start "sql_update" + // AntlrV3SQL.g:36:1: sql_update : UPDATE table SET kv ( ',' kv )* ( WHERE kv_sql )? ; + public final void sql_update() throws RecognitionException { + try { + // AntlrV3SQL.g:37:2: ( UPDATE table SET kv ( ',' kv )* ( WHERE kv_sql )? ) + // AntlrV3SQL.g:38:2: UPDATE table SET kv ( ',' kv )* ( WHERE kv_sql )? + { + match(input,UPDATE,FOLLOW_UPDATE_in_sql_update119); + + pushFollow(FOLLOW_table_in_sql_update121); + table(); + + state._fsp--; + + + match(input,SET,FOLLOW_SET_in_sql_update123); + + pushFollow(FOLLOW_kv_in_sql_update125); + kv(); + + state._fsp--; + + + // AntlrV3SQL.g:38:22: ( ',' kv )* + loop5: + do { + int alt5=2; + int LA5_0 = input.LA(1); + + if ( (LA5_0==66) ) { + alt5=1; + } + + + switch (alt5) { + case 1 : + // AntlrV3SQL.g:38:23: ',' kv + { + match(input,66,FOLLOW_66_in_sql_update128); + + pushFollow(FOLLOW_kv_in_sql_update130); + kv(); + + state._fsp--; + + + } + break; + + default : + break loop5; + } + } while (true); + + + // AntlrV3SQL.g:38:32: ( WHERE kv_sql )? + int alt6=2; + int LA6_0 = input.LA(1); + + if ( (LA6_0==WHERE) ) { + alt6=1; + } + switch (alt6) { + case 1 : + // AntlrV3SQL.g:38:33: WHERE kv_sql + { + match(input,WHERE,FOLLOW_WHERE_in_sql_update135); + + pushFollow(FOLLOW_kv_sql_in_sql_update137); + kv_sql(); + + state._fsp--; + + + } + break; + + } + + + this.antlrParserDelegate.setSqlOp(AntlrParserDelegate.SQLOP_UPDATE); + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "sql_update" + + + + // $ANTLR start "sql_select" + // AntlrV3SQL.g:42:1: sql_select : SELECT select_columns ( ',' db2_paging )? FROM ( sqlAfterFrom | inner_select ) ( WHERE kv_sql )? ( orderby | groupby | having )* ; + public final void sql_select() throws RecognitionException { + try { + // AntlrV3SQL.g:43:2: ( SELECT select_columns ( ',' db2_paging )? FROM ( sqlAfterFrom | inner_select ) ( WHERE kv_sql )? ( orderby | groupby | having )* ) + // AntlrV3SQL.g:44:2: SELECT select_columns ( ',' db2_paging )? FROM ( sqlAfterFrom | inner_select ) ( WHERE kv_sql )? ( orderby | groupby | having )* + { + match(input,SELECT,FOLLOW_SELECT_in_sql_select157); + + pushFollow(FOLLOW_select_columns_in_sql_select159); + select_columns(); + + state._fsp--; + + + // AntlrV3SQL.g:44:24: ( ',' db2_paging )? + int alt7=2; + int LA7_0 = input.LA(1); + + if ( (LA7_0==66) ) { + alt7=1; + } + switch (alt7) { + case 1 : + // AntlrV3SQL.g:44:25: ',' db2_paging + { + match(input,66,FOLLOW_66_in_sql_select162); + + pushFollow(FOLLOW_db2_paging_in_sql_select163); + db2_paging(); + + state._fsp--; + + + } + break; + + } + + + match(input,FROM,FOLLOW_FROM_in_sql_select167); + + // AntlrV3SQL.g:44:46: ( sqlAfterFrom | inner_select ) + int alt8=2; + int LA8_0 = input.LA(1); + + if ( (LA8_0==BASIC_NAME) ) { + alt8=1; + } + else if ( (LA8_0==74) ) { + alt8=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 8, 0, input); + + throw nvae; + + } + switch (alt8) { + case 1 : + // AntlrV3SQL.g:44:47: sqlAfterFrom + { + pushFollow(FOLLOW_sqlAfterFrom_in_sql_select170); + sqlAfterFrom(); + + state._fsp--; + + + } + break; + case 2 : + // AntlrV3SQL.g:44:60: inner_select + { + pushFollow(FOLLOW_inner_select_in_sql_select172); + inner_select(); + + state._fsp--; + + + } + break; + + } + + + // AntlrV3SQL.g:44:74: ( WHERE kv_sql )? + int alt9=2; + int LA9_0 = input.LA(1); + + if ( (LA9_0==WHERE) ) { + alt9=1; + } + switch (alt9) { + case 1 : + // AntlrV3SQL.g:44:75: WHERE kv_sql + { + match(input,WHERE,FOLLOW_WHERE_in_sql_select176); + + pushFollow(FOLLOW_kv_sql_in_sql_select178); + kv_sql(); + + state._fsp--; + + + } + break; + + } + + + // AntlrV3SQL.g:44:90: ( orderby | groupby | having )* + loop10: + do { + int alt10=4; + switch ( input.LA(1) ) { + case ORDER: + { + alt10=1; + } + break; + case GROUP: + { + alt10=2; + } + break; + case HAVING: + { + alt10=3; + } + break; + + } + + switch (alt10) { + case 1 : + // AntlrV3SQL.g:44:91: orderby + { + pushFollow(FOLLOW_orderby_in_sql_select183); + orderby(); + + state._fsp--; + + + } + break; + case 2 : + // AntlrV3SQL.g:44:99: groupby + { + pushFollow(FOLLOW_groupby_in_sql_select185); + groupby(); + + state._fsp--; + + + } + break; + case 3 : + // AntlrV3SQL.g:44:107: having + { + pushFollow(FOLLOW_having_in_sql_select187); + having(); + + state._fsp--; + + + } + break; + + default : + break loop10; + } + } while (true); + + + this.antlrParserDelegate.setSqlOp(AntlrParserDelegate.SQLOP_SELECT); + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "sql_select" + + + + // $ANTLR start "sqlAfterFrom" + // AntlrV3SQL.g:48:1: sqlAfterFrom : tables ( ( FULL | CROSS | INNER | LEFT | RIGHT ) JOIN table ( ON column_name '=' column_name )? )* ; + public final void sqlAfterFrom() throws RecognitionException { + try { + // AntlrV3SQL.g:49:2: ( tables ( ( FULL | CROSS | INNER | LEFT | RIGHT ) JOIN table ( ON column_name '=' column_name )? )* ) + // AntlrV3SQL.g:50:2: tables ( ( FULL | CROSS | INNER | LEFT | RIGHT ) JOIN table ( ON column_name '=' column_name )? )* + { + pushFollow(FOLLOW_tables_in_sqlAfterFrom204); + tables(); + + state._fsp--; + + + // AntlrV3SQL.g:50:9: ( ( FULL | CROSS | INNER | LEFT | RIGHT ) JOIN table ( ON column_name '=' column_name )? )* + loop12: + do { + int alt12=2; + int LA12_0 = input.LA(1); + + if ( (LA12_0==CROSS||LA12_0==FULL||LA12_0==INNER||LA12_0==LEFT||LA12_0==RIGHT) ) { + alt12=1; + } + + + switch (alt12) { + case 1 : + // AntlrV3SQL.g:50:10: ( FULL | CROSS | INNER | LEFT | RIGHT ) JOIN table ( ON column_name '=' column_name )? + { + if ( input.LA(1)==CROSS||input.LA(1)==FULL||input.LA(1)==INNER||input.LA(1)==LEFT||input.LA(1)==RIGHT ) { + input.consume(); + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + + match(input,JOIN,FOLLOW_JOIN_in_sqlAfterFrom219); + + pushFollow(FOLLOW_table_in_sqlAfterFrom221); + table(); + + state._fsp--; + + + // AntlrV3SQL.g:50:51: ( ON column_name '=' column_name )? + int alt11=2; + int LA11_0 = input.LA(1); + + if ( (LA11_0==ON) ) { + alt11=1; + } + switch (alt11) { + case 1 : + // AntlrV3SQL.g:50:52: ON column_name '=' column_name + { + match(input,ON,FOLLOW_ON_in_sqlAfterFrom224); + + pushFollow(FOLLOW_column_name_in_sqlAfterFrom226); + column_name(); + + state._fsp--; + + + match(input,71,FOLLOW_71_in_sqlAfterFrom228); + + pushFollow(FOLLOW_column_name_in_sqlAfterFrom230); + column_name(); + + state._fsp--; + + + } + break; + + } + + + } + break; + + default : + break loop12; + } + } while (true); + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "sqlAfterFrom" + + + + // $ANTLR start "kv_sql_wrapper" + // AntlrV3SQL.g:52:1: kv_sql_wrapper : ( kv_sql | '\\(' kv_sql '\\)' ); + public final void kv_sql_wrapper() throws RecognitionException { + try { + // AntlrV3SQL.g:53:2: ( kv_sql | '\\(' kv_sql '\\)' ) + int alt13=2; + int LA13_0 = input.LA(1); + + if ( (LA13_0==BASIC_NAME) ) { + alt13=1; + } + else if ( (LA13_0==74) ) { + alt13=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 13, 0, input); + + throw nvae; + + } + switch (alt13) { + case 1 : + // AntlrV3SQL.g:54:2: kv_sql + { + pushFollow(FOLLOW_kv_sql_in_kv_sql_wrapper244); + kv_sql(); + + state._fsp--; + + + } + break; + case 2 : + // AntlrV3SQL.g:54:11: '\\(' kv_sql '\\)' + { + match(input,74,FOLLOW_74_in_kv_sql_wrapper248); + + pushFollow(FOLLOW_kv_sql_in_kv_sql_wrapper250); + kv_sql(); + + state._fsp--; + + + match(input,75,FOLLOW_75_in_kv_sql_wrapper252); + + } + break; + + } + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "kv_sql_wrapper" + + + + // $ANTLR start "kv_sql" + // AntlrV3SQL.g:56:1: kv_sql : kv ( and_or ( kv | '\\(' kv ( and_or kv )* '\\)' ) )* ; + public final void kv_sql() throws RecognitionException { + try { + // AntlrV3SQL.g:56:8: ( kv ( and_or ( kv | '\\(' kv ( and_or kv )* '\\)' ) )* ) + // AntlrV3SQL.g:57:2: kv ( and_or ( kv | '\\(' kv ( and_or kv )* '\\)' ) )* + { + pushFollow(FOLLOW_kv_in_kv_sql263); + kv(); + + state._fsp--; + + + // AntlrV3SQL.g:57:5: ( and_or ( kv | '\\(' kv ( and_or kv )* '\\)' ) )* + loop16: + do { + int alt16=2; + int LA16_0 = input.LA(1); + + if ( (LA16_0==AND||LA16_0==OR) ) { + alt16=1; + } + + + switch (alt16) { + case 1 : + // AntlrV3SQL.g:57:7: and_or ( kv | '\\(' kv ( and_or kv )* '\\)' ) + { + pushFollow(FOLLOW_and_or_in_kv_sql267); + and_or(); + + state._fsp--; + + + // AntlrV3SQL.g:57:14: ( kv | '\\(' kv ( and_or kv )* '\\)' ) + int alt15=2; + int LA15_0 = input.LA(1); + + if ( (LA15_0==BASIC_NAME) ) { + alt15=1; + } + else if ( (LA15_0==74) ) { + alt15=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 15, 0, input); + + throw nvae; + + } + switch (alt15) { + case 1 : + // AntlrV3SQL.g:57:15: kv + { + pushFollow(FOLLOW_kv_in_kv_sql270); + kv(); + + state._fsp--; + + + } + break; + case 2 : + // AntlrV3SQL.g:57:20: '\\(' kv ( and_or kv )* '\\)' + { + match(input,74,FOLLOW_74_in_kv_sql274); + + pushFollow(FOLLOW_kv_in_kv_sql276); + kv(); + + state._fsp--; + + + // AntlrV3SQL.g:57:28: ( and_or kv )* + loop14: + do { + int alt14=2; + int LA14_0 = input.LA(1); + + if ( (LA14_0==AND||LA14_0==OR) ) { + alt14=1; + } + + + switch (alt14) { + case 1 : + // AntlrV3SQL.g:57:29: and_or kv + { + pushFollow(FOLLOW_and_or_in_kv_sql279); + and_or(); + + state._fsp--; + + + pushFollow(FOLLOW_kv_in_kv_sql281); + kv(); + + state._fsp--; + + + } + break; + + default : + break loop14; + } + } while (true); + + + match(input,75,FOLLOW_75_in_kv_sql285); + + } + break; + + } + + + } + break; + + default : + break loop16; + } + } while (true); + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "kv_sql" + + + + // $ANTLR start "inner_select" + // AntlrV3SQL.g:60:1: inner_select : '\\(' sql_select '\\)' ( AS )? ( BASIC_NAME )? ; + public final void inner_select() throws RecognitionException { + try { + // AntlrV3SQL.g:61:2: ( '\\(' sql_select '\\)' ( AS )? ( BASIC_NAME )? ) + // AntlrV3SQL.g:62:2: '\\(' sql_select '\\)' ( AS )? ( BASIC_NAME )? + { + match(input,74,FOLLOW_74_in_inner_select302); + + pushFollow(FOLLOW_sql_select_in_inner_select304); + sql_select(); + + state._fsp--; + + + match(input,75,FOLLOW_75_in_inner_select306); + + // AntlrV3SQL.g:62:23: ( AS )? + int alt17=2; + int LA17_0 = input.LA(1); + + if ( (LA17_0==AS) ) { + alt17=1; + } + switch (alt17) { + case 1 : + // AntlrV3SQL.g:62:23: AS + { + match(input,AS,FOLLOW_AS_in_inner_select308); + + } + break; + + } + + + // AntlrV3SQL.g:62:27: ( BASIC_NAME )? + int alt18=2; + int LA18_0 = input.LA(1); + + if ( (LA18_0==BASIC_NAME) ) { + alt18=1; + } + switch (alt18) { + case 1 : + // AntlrV3SQL.g:62:27: BASIC_NAME + { + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_inner_select311); + + } + break; + + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "inner_select" + + + + // $ANTLR start "func" + // AntlrV3SQL.g:65:1: func : BASIC_NAME '\\(' ( BASIC_NAME | '*' )? '\\)' ; + public final void func() throws RecognitionException { + try { + // AntlrV3SQL.g:66:2: ( BASIC_NAME '\\(' ( BASIC_NAME | '*' )? '\\)' ) + // AntlrV3SQL.g:67:2: BASIC_NAME '\\(' ( BASIC_NAME | '*' )? '\\)' + { + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_func324); + + match(input,74,FOLLOW_74_in_func326); + + // AntlrV3SQL.g:67:18: ( BASIC_NAME | '*' )? + int alt19=2; + int LA19_0 = input.LA(1); + + if ( (LA19_0==BASIC_NAME||LA19_0==65) ) { + alt19=1; + } + switch (alt19) { + case 1 : + // AntlrV3SQL.g: + { + if ( input.LA(1)==BASIC_NAME||input.LA(1)==65 ) { + input.consume(); + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + + } + break; + + } + + + match(input,75,FOLLOW_75_in_func335); + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "func" + + + + // $ANTLR start "func_and_alias" + // AntlrV3SQL.g:70:1: func_and_alias : func ( ( AS )? BASIC_NAME )? ; + public final void func_and_alias() throws RecognitionException { + try { + // AntlrV3SQL.g:71:2: ( func ( ( AS )? BASIC_NAME )? ) + // AntlrV3SQL.g:72:2: func ( ( AS )? BASIC_NAME )? + { + pushFollow(FOLLOW_func_in_func_and_alias349); + func(); + + state._fsp--; + + + // AntlrV3SQL.g:72:7: ( ( AS )? BASIC_NAME )? + int alt21=2; + int LA21_0 = input.LA(1); + + if ( (LA21_0==AS||LA21_0==BASIC_NAME) ) { + alt21=1; + } + switch (alt21) { + case 1 : + // AntlrV3SQL.g:72:8: ( AS )? BASIC_NAME + { + // AntlrV3SQL.g:72:8: ( AS )? + int alt20=2; + int LA20_0 = input.LA(1); + + if ( (LA20_0==AS) ) { + alt20=1; + } + switch (alt20) { + case 1 : + // AntlrV3SQL.g:72:8: AS + { + match(input,AS,FOLLOW_AS_in_func_and_alias352); + + } + break; + + } + + + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_func_and_alias355); + + } + break; + + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "func_and_alias" + + + + // $ANTLR start "select_column_and_alias" + // AntlrV3SQL.g:75:1: select_column_and_alias : column_name ( ( AS )? BASIC_NAME )? ; + public final void select_column_and_alias() throws RecognitionException { + try { + // AntlrV3SQL.g:76:2: ( column_name ( ( AS )? BASIC_NAME )? ) + // AntlrV3SQL.g:77:2: column_name ( ( AS )? BASIC_NAME )? + { + pushFollow(FOLLOW_column_name_in_select_column_and_alias369); + column_name(); + + state._fsp--; + + + // AntlrV3SQL.g:77:14: ( ( AS )? BASIC_NAME )? + int alt23=2; + int LA23_0 = input.LA(1); + + if ( (LA23_0==AS||LA23_0==BASIC_NAME) ) { + alt23=1; + } + switch (alt23) { + case 1 : + // AntlrV3SQL.g:77:15: ( AS )? BASIC_NAME + { + // AntlrV3SQL.g:77:15: ( AS )? + int alt22=2; + int LA22_0 = input.LA(1); + + if ( (LA22_0==AS) ) { + alt22=1; + } + switch (alt22) { + case 1 : + // AntlrV3SQL.g:77:15: AS + { + match(input,AS,FOLLOW_AS_in_select_column_and_alias372); + + } + break; + + } + + + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_select_column_and_alias375); + + } + break; + + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "select_column_and_alias" + + + + // $ANTLR start "select_column" + // AntlrV3SQL.g:80:1: select_column : ( select_column_and_alias | func_and_alias | '*' ); + public final void select_column() throws RecognitionException { + try { + // AntlrV3SQL.g:81:2: ( select_column_and_alias | func_and_alias | '*' ) + int alt24=3; + int LA24_0 = input.LA(1); + + if ( (LA24_0==BASIC_NAME) ) { + int LA24_1 = input.LA(2); + + if ( (LA24_1==74) ) { + alt24=2; + } + else if ( (LA24_1==AS||LA24_1==BASIC_NAME||LA24_1==FROM||(LA24_1 >= 66 && LA24_1 <= 67)) ) { + alt24=1; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 24, 1, input); + + throw nvae; + + } + } + else if ( (LA24_0==65) ) { + alt24=3; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 24, 0, input); + + throw nvae; + + } + switch (alt24) { + case 1 : + // AntlrV3SQL.g:82:2: select_column_and_alias + { + pushFollow(FOLLOW_select_column_and_alias_in_select_column389); + select_column_and_alias(); + + state._fsp--; + + + } + break; + case 2 : + // AntlrV3SQL.g:82:26: func_and_alias + { + pushFollow(FOLLOW_func_and_alias_in_select_column391); + func_and_alias(); + + state._fsp--; + + + } + break; + case 3 : + // AntlrV3SQL.g:82:41: '*' + { + match(input,65,FOLLOW_65_in_select_column393); + + } + break; + + } + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "select_column" + + + + // $ANTLR start "select_columns" + // AntlrV3SQL.g:85:1: select_columns : select_column ( ',' select_column )* ; + public final void select_columns() throws RecognitionException { + try { + // AntlrV3SQL.g:86:2: ( select_column ( ',' select_column )* ) + // AntlrV3SQL.g:87:2: select_column ( ',' select_column )* + { + pushFollow(FOLLOW_select_column_in_select_columns406); + select_column(); + + state._fsp--; + + + // AntlrV3SQL.g:87:16: ( ',' select_column )* + loop25: + do { + int alt25=2; + int LA25_0 = input.LA(1); + + if ( (LA25_0==66) ) { + int LA25_1 = input.LA(2); + + if ( (LA25_1==BASIC_NAME||LA25_1==65) ) { + alt25=1; + } + + + } + + + switch (alt25) { + case 1 : + // AntlrV3SQL.g:87:17: ',' select_column + { + match(input,66,FOLLOW_66_in_select_columns409); + + pushFollow(FOLLOW_select_column_in_select_columns411); + select_column(); + + state._fsp--; + + + } + break; + + default : + break loop25; + } + } while (true); + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "select_columns" + + + + // $ANTLR start "and_or" + // AntlrV3SQL.g:90:1: and_or : ( AND | OR ); + public final void and_or() throws RecognitionException { + try { + // AntlrV3SQL.g:90:8: ( AND | OR ) + // AntlrV3SQL.g: + { + if ( input.LA(1)==AND||input.LA(1)==OR ) { + input.consume(); + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "and_or" + + + + // $ANTLR start "table" + // AntlrV3SQL.g:94:1: table : table_name ( ( AS )? alias )? ; + public final void table() throws RecognitionException { + table_name_return table_name1 =null; + + alias_return alias2 =null; + + + try { + // AntlrV3SQL.g:94:7: ( table_name ( ( AS )? alias )? ) + // AntlrV3SQL.g:95:2: table_name ( ( AS )? alias )? + { + pushFollow(FOLLOW_table_name_in_table441); + table_name1=table_name(); + + state._fsp--; + + + // AntlrV3SQL.g:95:13: ( ( AS )? alias )? + int alt27=2; + int LA27_0 = input.LA(1); + + if ( (LA27_0==AS||LA27_0==BASIC_NAME) ) { + alt27=1; + } + switch (alt27) { + case 1 : + // AntlrV3SQL.g:95:14: ( AS )? alias + { + // AntlrV3SQL.g:95:14: ( AS )? + int alt26=2; + int LA26_0 = input.LA(1); + + if ( (LA26_0==AS) ) { + alt26=1; + } + switch (alt26) { + case 1 : + // AntlrV3SQL.g:95:15: AS + { + match(input,AS,FOLLOW_AS_in_table445); + + } + break; + + } + + + pushFollow(FOLLOW_alias_in_table449); + alias2=alias(); + + state._fsp--; + + + } + break; + + } + + + + if (this.antlrParserDelegate != null) { + this.antlrParserDelegate.onFindTable( (table_name1!=null?input.toString(table_name1.start,table_name1.stop):null), (alias2!=null?input.toString(alias2.start,alias2.stop):null)); + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "table" + + + + // $ANTLR start "tables" + // AntlrV3SQL.g:101:1: tables : ( table ( ',' table )* ) ; + public final void tables() throws RecognitionException { + try { + // AntlrV3SQL.g:101:8: ( ( table ( ',' table )* ) ) + // AntlrV3SQL.g:102:2: ( table ( ',' table )* ) + { + // AntlrV3SQL.g:102:2: ( table ( ',' table )* ) + // AntlrV3SQL.g:102:3: table ( ',' table )* + { + pushFollow(FOLLOW_table_in_tables465); + table(); + + state._fsp--; + + + // AntlrV3SQL.g:102:9: ( ',' table )* + loop28: + do { + int alt28=2; + int LA28_0 = input.LA(1); + + if ( (LA28_0==66) ) { + alt28=1; + } + + + switch (alt28) { + case 1 : + // AntlrV3SQL.g:102:10: ',' table + { + match(input,66,FOLLOW_66_in_tables468); + + pushFollow(FOLLOW_table_in_tables470); + table(); + + state._fsp--; + + + } + break; + + default : + break loop28; + } + } while (true); + + + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "tables" + + + public static class table_name_return extends ParserRuleReturnScope { + }; + + + // $ANTLR start "table_name" + // AntlrV3SQL.g:105:1: table_name : BASIC_NAME ( ( '.' ) BASIC_NAME )? ; + public final table_name_return table_name() throws RecognitionException { + table_name_return retval = new table_name_return(); + retval.start = input.LT(1); + + + try { + // AntlrV3SQL.g:106:2: ( BASIC_NAME ( ( '.' ) BASIC_NAME )? ) + // AntlrV3SQL.g:107:2: BASIC_NAME ( ( '.' ) BASIC_NAME )? + { + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_table_name486); + + // AntlrV3SQL.g:107:13: ( ( '.' ) BASIC_NAME )? + int alt29=2; + int LA29_0 = input.LA(1); + + if ( (LA29_0==67) ) { + alt29=1; + } + switch (alt29) { + case 1 : + // AntlrV3SQL.g:107:14: ( '.' ) BASIC_NAME + { + // AntlrV3SQL.g:107:14: ( '.' ) + // AntlrV3SQL.g:107:15: '.' + { + match(input,67,FOLLOW_67_in_table_name490); + + } + + + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_table_name493); + + } + break; + + } + + + } + + retval.stop = input.LT(-1); + + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "table_name" + + + public static class alias_return extends ParserRuleReturnScope { + }; + + + // $ANTLR start "alias" + // AntlrV3SQL.g:110:1: alias : BASIC_NAME ; + public final alias_return alias() throws RecognitionException { + alias_return retval = new alias_return(); + retval.start = input.LT(1); + + + try { + // AntlrV3SQL.g:110:7: ( BASIC_NAME ) + // AntlrV3SQL.g:111:2: BASIC_NAME + { + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_alias506); + + } + + retval.stop = input.LT(-1); + + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "alias" + + + public static class column_name_return extends ParserRuleReturnScope { + }; + + + // $ANTLR start "column_name" + // AntlrV3SQL.g:114:1: column_name : BASIC_NAME ( ( '.' ) BASIC_NAME )? ; + public final column_name_return column_name() throws RecognitionException { + column_name_return retval = new column_name_return(); + retval.start = input.LT(1); + + + try { + // AntlrV3SQL.g:115:2: ( BASIC_NAME ( ( '.' ) BASIC_NAME )? ) + // AntlrV3SQL.g:116:2: BASIC_NAME ( ( '.' ) BASIC_NAME )? + { + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_column_name518); + + // AntlrV3SQL.g:116:13: ( ( '.' ) BASIC_NAME )? + int alt30=2; + int LA30_0 = input.LA(1); + + if ( (LA30_0==67) ) { + alt30=1; + } + switch (alt30) { + case 1 : + // AntlrV3SQL.g:116:14: ( '.' ) BASIC_NAME + { + // AntlrV3SQL.g:116:14: ( '.' ) + // AntlrV3SQL.g:116:15: '.' + { + match(input,67,FOLLOW_67_in_column_name522); + + } + + + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_column_name525); + + } + break; + + } + + + } + + retval.stop = input.LT(-1); + + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "column_name" + + + + // $ANTLR start "insertColumn" + // AntlrV3SQL.g:119:1: insertColumn : column_name ; + public final void insertColumn() throws RecognitionException { + column_name_return column_name3 =null; + + + try { + // AntlrV3SQL.g:120:2: ( column_name ) + // AntlrV3SQL.g:121:2: column_name + { + pushFollow(FOLLOW_column_name_in_insertColumn539); + column_name3=column_name(); + + state._fsp--; + + + + if (this.antlrParserDelegate != null) { + this.antlrParserDelegate.onFindColExper( + (column_name3!=null?input.toString(column_name3.start,column_name3.stop):null), "="); + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "insertColumn" + + + + // $ANTLR start "kv" + // AntlrV3SQL.g:131:1: kv : ( ( column_name op ( PRE_SET | '\\(' PRE_SET '\\)' ) ) | column_name op TEXT_STRING | ( column_name BETWEEN PRE_SET AND PRE_SET ) | column_name op column_name | column_name op func2 | column_name op '\\(' sql_select '\\)' | ( column_name op '\\(' inexpr '\\)' ) ); + public final void kv() throws RecognitionException { + column_name_return column_name4 =null; + + op_return op5 =null; + + column_name_return column_name6 =null; + + inexpr_return inexpr7 =null; + + column_name_return column_name8 =null; + + op_return op9 =null; + + + try { + // AntlrV3SQL.g:131:4: ( ( column_name op ( PRE_SET | '\\(' PRE_SET '\\)' ) ) | column_name op TEXT_STRING | ( column_name BETWEEN PRE_SET AND PRE_SET ) | column_name op column_name | column_name op func2 | column_name op '\\(' sql_select '\\)' | ( column_name op '\\(' inexpr '\\)' ) ) + int alt32=7; + int LA32_0 = input.LA(1); + + if ( (LA32_0==BASIC_NAME) ) { + switch ( input.LA(2) ) { + case 67: + { + int LA32_2 = input.LA(3); + + if ( (LA32_2==BASIC_NAME) ) { + int LA32_5 = input.LA(4); + + if ( (LA32_5==EXISTS||LA32_5==IN||LA32_5==64||(LA32_5 >= 68 && LA32_5 <= 73)) ) { + switch ( input.LA(5) ) { + case PRE_SET: + { + alt32=1; + } + break; + case 74: + { + int LA32_7 = input.LA(6); + + if ( (LA32_7==PRE_SET) ) { + int LA32_10 = input.LA(7); + + if ( (LA32_10==75) ) { + alt32=1; + } + else if ( (LA32_10==66) ) { + alt32=7; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 32, 10, input); + + throw nvae; + + } + } + else if ( (LA32_7==SELECT) ) { + alt32=6; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 32, 7, input); + + throw nvae; + + } + } + break; + case TEXT_STRING: + { + alt32=2; + } + break; + case BASIC_NAME: + { + int LA32_9 = input.LA(6); + + if ( (LA32_9==74) ) { + alt32=5; + } + else if ( (LA32_9==EOF||LA32_9==AND||LA32_9==GROUP||LA32_9==HAVING||(LA32_9 >= OR && LA32_9 <= ORDER)||LA32_9==WHERE||(LA32_9 >= 66 && LA32_9 <= 67)||LA32_9==75) ) { + alt32=4; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 32, 9, input); + + throw nvae; + + } + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 32, 3, input); + + throw nvae; + + } + + } + else if ( (LA32_5==BETWEEN) ) { + alt32=3; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 32, 5, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 32, 2, input); + + throw nvae; + + } + } + break; + case EXISTS: + case IN: + case 64: + case 68: + case 69: + case 70: + case 71: + case 72: + case 73: + { + switch ( input.LA(3) ) { + case PRE_SET: + { + alt32=1; + } + break; + case 74: + { + int LA32_7 = input.LA(4); + + if ( (LA32_7==PRE_SET) ) { + int LA32_10 = input.LA(5); + + if ( (LA32_10==75) ) { + alt32=1; + } + else if ( (LA32_10==66) ) { + alt32=7; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 32, 10, input); + + throw nvae; + + } + } + else if ( (LA32_7==SELECT) ) { + alt32=6; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 32, 7, input); + + throw nvae; + + } + } + break; + case TEXT_STRING: + { + alt32=2; + } + break; + case BASIC_NAME: + { + int LA32_9 = input.LA(4); + + if ( (LA32_9==74) ) { + alt32=5; + } + else if ( (LA32_9==EOF||LA32_9==AND||LA32_9==GROUP||LA32_9==HAVING||(LA32_9 >= OR && LA32_9 <= ORDER)||LA32_9==WHERE||(LA32_9 >= 66 && LA32_9 <= 67)||LA32_9==75) ) { + alt32=4; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 32, 9, input); + + throw nvae; + + } + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 32, 3, input); + + throw nvae; + + } + + } + break; + case BETWEEN: + { + alt32=3; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 32, 1, input); + + throw nvae; + + } + + } + else { + NoViableAltException nvae = + new NoViableAltException("", 32, 0, input); + + throw nvae; + + } + switch (alt32) { + case 1 : + // AntlrV3SQL.g:132:2: ( column_name op ( PRE_SET | '\\(' PRE_SET '\\)' ) ) + { + // AntlrV3SQL.g:132:2: ( column_name op ( PRE_SET | '\\(' PRE_SET '\\)' ) ) + // AntlrV3SQL.g:132:3: column_name op ( PRE_SET | '\\(' PRE_SET '\\)' ) + { + pushFollow(FOLLOW_column_name_in_kv556); + column_name4=column_name(); + + state._fsp--; + + + pushFollow(FOLLOW_op_in_kv558); + op5=op(); + + state._fsp--; + + + // AntlrV3SQL.g:132:18: ( PRE_SET | '\\(' PRE_SET '\\)' ) + int alt31=2; + int LA31_0 = input.LA(1); + + if ( (LA31_0==PRE_SET) ) { + alt31=1; + } + else if ( (LA31_0==74) ) { + alt31=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 31, 0, input); + + throw nvae; + + } + switch (alt31) { + case 1 : + // AntlrV3SQL.g:132:19: PRE_SET + { + match(input,PRE_SET,FOLLOW_PRE_SET_in_kv561); + + } + break; + case 2 : + // AntlrV3SQL.g:132:27: '\\(' PRE_SET '\\)' + { + match(input,74,FOLLOW_74_in_kv563); + + match(input,PRE_SET,FOLLOW_PRE_SET_in_kv565); + + match(input,75,FOLLOW_75_in_kv567); + + } + break; + + } + + + } + + + + if (this.antlrParserDelegate != null) { + this.antlrParserDelegate.onFindColExper( (column_name4!=null?input.toString(column_name4.start,column_name4.stop):null), (op5!=null?input.toString(op5.start,op5.stop):null)); + } + + + } + break; + case 2 : + // AntlrV3SQL.g:139:2: column_name op TEXT_STRING + { + pushFollow(FOLLOW_column_name_in_kv578); + column_name(); + + state._fsp--; + + + pushFollow(FOLLOW_op_in_kv580); + op(); + + state._fsp--; + + + match(input,TEXT_STRING,FOLLOW_TEXT_STRING_in_kv582); + + } + break; + case 3 : + // AntlrV3SQL.g:141:2: ( column_name BETWEEN PRE_SET AND PRE_SET ) + { + // AntlrV3SQL.g:141:2: ( column_name BETWEEN PRE_SET AND PRE_SET ) + // AntlrV3SQL.g:141:3: column_name BETWEEN PRE_SET AND PRE_SET + { + pushFollow(FOLLOW_column_name_in_kv589); + column_name6=column_name(); + + state._fsp--; + + + match(input,BETWEEN,FOLLOW_BETWEEN_in_kv591); + + match(input,PRE_SET,FOLLOW_PRE_SET_in_kv593); + + match(input,AND,FOLLOW_AND_in_kv595); + + match(input,PRE_SET,FOLLOW_PRE_SET_in_kv597); + + } + + + + this.antlrParserDelegate.onFindColExper((column_name6!=null?input.toString(column_name6.start,column_name6.stop):null), ">="); + this.antlrParserDelegate.onFindColExper((column_name6!=null?input.toString(column_name6.start,column_name6.stop):null), "=<"); + + + } + break; + case 4 : + // AntlrV3SQL.g:147:2: column_name op column_name + { + pushFollow(FOLLOW_column_name_in_kv608); + column_name(); + + state._fsp--; + + + pushFollow(FOLLOW_op_in_kv610); + op(); + + state._fsp--; + + + pushFollow(FOLLOW_column_name_in_kv612); + column_name(); + + state._fsp--; + + + } + break; + case 5 : + // AntlrV3SQL.g:149:2: column_name op func2 + { + pushFollow(FOLLOW_column_name_in_kv618); + column_name(); + + state._fsp--; + + + pushFollow(FOLLOW_op_in_kv620); + op(); + + state._fsp--; + + + pushFollow(FOLLOW_func2_in_kv622); + func2(); + + state._fsp--; + + + } + break; + case 6 : + // AntlrV3SQL.g:151:2: column_name op '\\(' sql_select '\\)' + { + pushFollow(FOLLOW_column_name_in_kv628); + column_name(); + + state._fsp--; + + + pushFollow(FOLLOW_op_in_kv630); + op(); + + state._fsp--; + + + match(input,74,FOLLOW_74_in_kv632); + + pushFollow(FOLLOW_sql_select_in_kv634); + sql_select(); + + state._fsp--; + + + match(input,75,FOLLOW_75_in_kv636); + + } + break; + case 7 : + // AntlrV3SQL.g:153:2: ( column_name op '\\(' inexpr '\\)' ) + { + // AntlrV3SQL.g:153:2: ( column_name op '\\(' inexpr '\\)' ) + // AntlrV3SQL.g:153:3: column_name op '\\(' inexpr '\\)' + { + pushFollow(FOLLOW_column_name_in_kv643); + column_name8=column_name(); + + state._fsp--; + + + pushFollow(FOLLOW_op_in_kv645); + op9=op(); + + state._fsp--; + + + match(input,74,FOLLOW_74_in_kv647); + + pushFollow(FOLLOW_inexpr_in_kv649); + inexpr7=inexpr(); + + state._fsp--; + + + match(input,75,FOLLOW_75_in_kv652); + + } + + + + if (this.antlrParserDelegate != null) { + String s=(inexpr7!=null?input.toString(inexpr7.start,inexpr7.stop):null); + int cnt=s.split(",").length; + for(int i=0;i' | '>=' | '<' | '<=' | '!=' | '<>' | IN | EXISTS ) ; + public final op_return op() throws RecognitionException { + op_return retval = new op_return(); + retval.start = input.LT(1); + + + try { + // AntlrV3SQL.g:177:2: ( ( '=' | '>' | '>=' | '<' | '<=' | '!=' | '<>' | IN | EXISTS ) ) + // AntlrV3SQL.g: + { + if ( input.LA(1)==EXISTS||input.LA(1)==IN||input.LA(1)==64||(input.LA(1) >= 68 && input.LA(1) <= 73) ) { + input.consume(); + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + + } + + retval.stop = input.LT(-1); + + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return retval; + } + // $ANTLR end "op" + + + + // $ANTLR start "orderby" + // AntlrV3SQL.g:181:1: orderby : ORDER BY column_name ( DESC | ASC )? ( ',' column_name ( DESC | ASC )? )* ; + public final void orderby() throws RecognitionException { + try { + // AntlrV3SQL.g:181:9: ( ORDER BY column_name ( DESC | ASC )? ( ',' column_name ( DESC | ASC )? )* ) + // AntlrV3SQL.g:182:2: ORDER BY column_name ( DESC | ASC )? ( ',' column_name ( DESC | ASC )? )* + { + match(input,ORDER,FOLLOW_ORDER_in_orderby765); + + match(input,BY,FOLLOW_BY_in_orderby767); + + pushFollow(FOLLOW_column_name_in_orderby769); + column_name(); + + state._fsp--; + + + // AntlrV3SQL.g:182:23: ( DESC | ASC )? + int alt38=2; + int LA38_0 = input.LA(1); + + if ( (LA38_0==ASC||LA38_0==DESC) ) { + alt38=1; + } + switch (alt38) { + case 1 : + // AntlrV3SQL.g: + { + if ( input.LA(1)==ASC||input.LA(1)==DESC ) { + input.consume(); + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + + } + break; + + } + + + // AntlrV3SQL.g:182:35: ( ',' column_name ( DESC | ASC )? )* + loop40: + do { + int alt40=2; + int LA40_0 = input.LA(1); + + if ( (LA40_0==66) ) { + alt40=1; + } + + + switch (alt40) { + case 1 : + // AntlrV3SQL.g:182:36: ',' column_name ( DESC | ASC )? + { + match(input,66,FOLLOW_66_in_orderby779); + + pushFollow(FOLLOW_column_name_in_orderby781); + column_name(); + + state._fsp--; + + + // AntlrV3SQL.g:182:52: ( DESC | ASC )? + int alt39=2; + int LA39_0 = input.LA(1); + + if ( (LA39_0==ASC||LA39_0==DESC) ) { + alt39=1; + } + switch (alt39) { + case 1 : + // AntlrV3SQL.g: + { + if ( input.LA(1)==ASC||input.LA(1)==DESC ) { + input.consume(); + state.errorRecovery=false; + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + throw mse; + } + + + } + break; + + } + + + } + break; + + default : + break loop40; + } + } while (true); + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "orderby" + + + + // $ANTLR start "groupby" + // AntlrV3SQL.g:185:1: groupby : GROUP BY column_name ( ',' column_name )* ; + public final void groupby() throws RecognitionException { + try { + // AntlrV3SQL.g:185:9: ( GROUP BY column_name ( ',' column_name )* ) + // AntlrV3SQL.g:186:2: GROUP BY column_name ( ',' column_name )* + { + match(input,GROUP,FOLLOW_GROUP_in_groupby802); + + match(input,BY,FOLLOW_BY_in_groupby804); + + pushFollow(FOLLOW_column_name_in_groupby806); + column_name(); + + state._fsp--; + + + // AntlrV3SQL.g:186:23: ( ',' column_name )* + loop41: + do { + int alt41=2; + int LA41_0 = input.LA(1); + + if ( (LA41_0==66) ) { + alt41=1; + } + + + switch (alt41) { + case 1 : + // AntlrV3SQL.g:186:24: ',' column_name + { + match(input,66,FOLLOW_66_in_groupby809); + + pushFollow(FOLLOW_column_name_in_groupby811); + column_name(); + + state._fsp--; + + + } + break; + + default : + break loop41; + } + } while (true); + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "groupby" + + + + // $ANTLR start "having" + // AntlrV3SQL.g:189:1: having : HAVING ( column_name | func ) op ( column_name | func | TEXT_STRING | PRE_SET ) ; + public final void having() throws RecognitionException { + try { + // AntlrV3SQL.g:189:8: ( HAVING ( column_name | func ) op ( column_name | func | TEXT_STRING | PRE_SET ) ) + // AntlrV3SQL.g:190:2: HAVING ( column_name | func ) op ( column_name | func | TEXT_STRING | PRE_SET ) + { + match(input,HAVING,FOLLOW_HAVING_in_having824); + + // AntlrV3SQL.g:190:9: ( column_name | func ) + int alt42=2; + int LA42_0 = input.LA(1); + + if ( (LA42_0==BASIC_NAME) ) { + int LA42_1 = input.LA(2); + + if ( (LA42_1==74) ) { + alt42=2; + } + else if ( (LA42_1==EXISTS||LA42_1==IN||LA42_1==64||(LA42_1 >= 67 && LA42_1 <= 73)) ) { + alt42=1; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 42, 1, input); + + throw nvae; + + } + } + else { + NoViableAltException nvae = + new NoViableAltException("", 42, 0, input); + + throw nvae; + + } + switch (alt42) { + case 1 : + // AntlrV3SQL.g:190:10: column_name + { + pushFollow(FOLLOW_column_name_in_having827); + column_name(); + + state._fsp--; + + + } + break; + case 2 : + // AntlrV3SQL.g:190:22: func + { + pushFollow(FOLLOW_func_in_having829); + func(); + + state._fsp--; + + + } + break; + + } + + + pushFollow(FOLLOW_op_in_having832); + op(); + + state._fsp--; + + + // AntlrV3SQL.g:190:31: ( column_name | func | TEXT_STRING | PRE_SET ) + int alt43=4; + switch ( input.LA(1) ) { + case BASIC_NAME: + { + int LA43_1 = input.LA(2); + + if ( (LA43_1==74) ) { + alt43=2; + } + else if ( (LA43_1==EOF||LA43_1==GROUP||LA43_1==HAVING||LA43_1==ORDER||LA43_1==67||LA43_1==75) ) { + alt43=1; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 43, 1, input); + + throw nvae; + + } + } + break; + case TEXT_STRING: + { + alt43=3; + } + break; + case PRE_SET: + { + alt43=4; + } + break; + default: + NoViableAltException nvae = + new NoViableAltException("", 43, 0, input); + + throw nvae; + + } + + switch (alt43) { + case 1 : + // AntlrV3SQL.g:190:32: column_name + { + pushFollow(FOLLOW_column_name_in_having835); + column_name(); + + state._fsp--; + + + } + break; + case 2 : + // AntlrV3SQL.g:190:44: func + { + pushFollow(FOLLOW_func_in_having837); + func(); + + state._fsp--; + + + } + break; + case 3 : + // AntlrV3SQL.g:190:49: TEXT_STRING + { + match(input,TEXT_STRING,FOLLOW_TEXT_STRING_in_having839); + + } + break; + case 4 : + // AntlrV3SQL.g:190:61: PRE_SET + { + match(input,PRE_SET,FOLLOW_PRE_SET_in_having841); + + } + break; + + } + + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "having" + + + + // $ANTLR start "db2_paging" + // AntlrV3SQL.g:193:1: db2_paging : ROWNUMBER '\\(' '\\)' OVER '\\(' orderby '\\)' ( AS )? BASIC_NAME ; + public final void db2_paging() throws RecognitionException { + try { + // AntlrV3SQL.g:194:2: ( ROWNUMBER '\\(' '\\)' OVER '\\(' orderby '\\)' ( AS )? BASIC_NAME ) + // AntlrV3SQL.g:195:2: ROWNUMBER '\\(' '\\)' OVER '\\(' orderby '\\)' ( AS )? BASIC_NAME + { + match(input,ROWNUMBER,FOLLOW_ROWNUMBER_in_db2_paging855); + + match(input,74,FOLLOW_74_in_db2_paging856); + + match(input,75,FOLLOW_75_in_db2_paging857); + + match(input,OVER,FOLLOW_OVER_in_db2_paging859); + + match(input,74,FOLLOW_74_in_db2_paging860); + + pushFollow(FOLLOW_orderby_in_db2_paging861); + orderby(); + + state._fsp--; + + + match(input,75,FOLLOW_75_in_db2_paging863); + + // AntlrV3SQL.g:195:41: ( AS )? + int alt44=2; + int LA44_0 = input.LA(1); + + if ( (LA44_0==AS) ) { + alt44=1; + } + switch (alt44) { + case 1 : + // AntlrV3SQL.g:195:42: AS + { + match(input,AS,FOLLOW_AS_in_db2_paging866); + + } + break; + + } + + + match(input,BASIC_NAME,FOLLOW_BASIC_NAME_in_db2_paging870); + + } + + } + catch (RecognitionException re) { + reportError(re); + recover(input,re); + } + + finally { + // do for sure before leaving + } + return ; + } + // $ANTLR end "db2_paging" + + // Delegated rules + + + + + public static final BitSet FOLLOW_sql_insert_in_start23 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_sql_delete_in_start25 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_sql_update_in_start27 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_sql_select_in_start29 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_INSERT_in_sql_insert40 = new BitSet(new long[]{0x0000000040000000L}); + public static final BitSet FOLLOW_INTO_in_sql_insert42 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_table_in_sql_insert44 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_74_in_sql_insert46 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_insertColumn_in_sql_insert48 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000804L}); + public static final BitSet FOLLOW_66_in_sql_insert51 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_insertColumn_in_sql_insert53 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000804L}); + public static final BitSet FOLLOW_75_in_sql_insert57 = new BitSet(new long[]{0x0200000000000000L}); + public static final BitSet FOLLOW_VALUES_in_sql_insert59 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_74_in_sql_insert61 = new BitSet(new long[]{0x0000100000000000L,0x0000000000000804L}); + public static final BitSet FOLLOW_PRE_SET_in_sql_insert64 = new BitSet(new long[]{0x0000100000000000L,0x0000000000000804L}); + public static final BitSet FOLLOW_66_in_sql_insert67 = new BitSet(new long[]{0x0000100000000000L}); + public static final BitSet FOLLOW_PRE_SET_in_sql_insert69 = new BitSet(new long[]{0x0000100000000000L,0x0000000000000804L}); + public static final BitSet FOLLOW_75_in_sql_insert74 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_DELETE_in_sql_delete91 = new BitSet(new long[]{0x0000000000100000L}); + public static final BitSet FOLLOW_FROM_in_sql_delete93 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_table_in_sql_delete95 = new BitSet(new long[]{0x0800000000000002L}); + public static final BitSet FOLLOW_WHERE_in_sql_delete98 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_kv_sql_in_sql_delete100 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_UPDATE_in_sql_update119 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_table_in_sql_update121 = new BitSet(new long[]{0x0008000000000000L}); + public static final BitSet FOLLOW_SET_in_sql_update123 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_kv_in_sql_update125 = new BitSet(new long[]{0x0800000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_66_in_sql_update128 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_kv_in_sql_update130 = new BitSet(new long[]{0x0800000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_WHERE_in_sql_update135 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_kv_sql_in_sql_update137 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_SELECT_in_sql_select157 = new BitSet(new long[]{0x0000000000000200L,0x0000000000000002L}); + public static final BitSet FOLLOW_select_columns_in_sql_select159 = new BitSet(new long[]{0x0000000000100000L,0x0000000000000004L}); + public static final BitSet FOLLOW_66_in_sql_select162 = new BitSet(new long[]{0x0001000000000000L}); + public static final BitSet FOLLOW_db2_paging_in_sql_select163 = new BitSet(new long[]{0x0000000000100000L}); + public static final BitSet FOLLOW_FROM_in_sql_select167 = new BitSet(new long[]{0x0000000000000200L,0x0000000000000400L}); + public static final BitSet FOLLOW_sqlAfterFrom_in_sql_select170 = new BitSet(new long[]{0x0800020002800002L}); + public static final BitSet FOLLOW_inner_select_in_sql_select172 = new BitSet(new long[]{0x0800020002800002L}); + public static final BitSet FOLLOW_WHERE_in_sql_select176 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_kv_sql_in_sql_select178 = new BitSet(new long[]{0x0000020002800002L}); + public static final BitSet FOLLOW_orderby_in_sql_select183 = new BitSet(new long[]{0x0000020002800002L}); + public static final BitSet FOLLOW_groupby_in_sql_select185 = new BitSet(new long[]{0x0000020002800002L}); + public static final BitSet FOLLOW_having_in_sql_select187 = new BitSet(new long[]{0x0000020002800002L}); + public static final BitSet FOLLOW_tables_in_sqlAfterFrom204 = new BitSet(new long[]{0x0000800810202002L}); + public static final BitSet FOLLOW_set_in_sqlAfterFrom207 = new BitSet(new long[]{0x0000000100000000L}); + public static final BitSet FOLLOW_JOIN_in_sqlAfterFrom219 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_table_in_sqlAfterFrom221 = new BitSet(new long[]{0x0000808810202002L}); + public static final BitSet FOLLOW_ON_in_sqlAfterFrom224 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_column_name_in_sqlAfterFrom226 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000080L}); + public static final BitSet FOLLOW_71_in_sqlAfterFrom228 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_column_name_in_sqlAfterFrom230 = new BitSet(new long[]{0x0000800810202002L}); + public static final BitSet FOLLOW_kv_sql_in_kv_sql_wrapper244 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_74_in_kv_sql_wrapper248 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_kv_sql_in_kv_sql_wrapper250 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000800L}); + public static final BitSet FOLLOW_75_in_kv_sql_wrapper252 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_kv_in_kv_sql263 = new BitSet(new long[]{0x0000010000000022L}); + public static final BitSet FOLLOW_and_or_in_kv_sql267 = new BitSet(new long[]{0x0000000000000200L,0x0000000000000400L}); + public static final BitSet FOLLOW_kv_in_kv_sql270 = new BitSet(new long[]{0x0000010000000022L}); + public static final BitSet FOLLOW_74_in_kv_sql274 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_kv_in_kv_sql276 = new BitSet(new long[]{0x0000010000000020L,0x0000000000000800L}); + public static final BitSet FOLLOW_and_or_in_kv_sql279 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_kv_in_kv_sql281 = new BitSet(new long[]{0x0000010000000020L,0x0000000000000800L}); + public static final BitSet FOLLOW_75_in_kv_sql285 = new BitSet(new long[]{0x0000010000000022L}); + public static final BitSet FOLLOW_74_in_inner_select302 = new BitSet(new long[]{0x0004000000000000L}); + public static final BitSet FOLLOW_sql_select_in_inner_select304 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000800L}); + public static final BitSet FOLLOW_75_in_inner_select306 = new BitSet(new long[]{0x0000000000000242L}); + public static final BitSet FOLLOW_AS_in_inner_select308 = new BitSet(new long[]{0x0000000000000202L}); + public static final BitSet FOLLOW_BASIC_NAME_in_inner_select311 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_BASIC_NAME_in_func324 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_74_in_func326 = new BitSet(new long[]{0x0000000000000200L,0x0000000000000802L}); + public static final BitSet FOLLOW_75_in_func335 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_func_in_func_and_alias349 = new BitSet(new long[]{0x0000000000000242L}); + public static final BitSet FOLLOW_AS_in_func_and_alias352 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_BASIC_NAME_in_func_and_alias355 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_column_name_in_select_column_and_alias369 = new BitSet(new long[]{0x0000000000000242L}); + public static final BitSet FOLLOW_AS_in_select_column_and_alias372 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_BASIC_NAME_in_select_column_and_alias375 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_select_column_and_alias_in_select_column389 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_func_and_alias_in_select_column391 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_65_in_select_column393 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_select_column_in_select_columns406 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_66_in_select_columns409 = new BitSet(new long[]{0x0000000000000200L,0x0000000000000002L}); + public static final BitSet FOLLOW_select_column_in_select_columns411 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_table_name_in_table441 = new BitSet(new long[]{0x0000000000000242L}); + public static final BitSet FOLLOW_AS_in_table445 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_alias_in_table449 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_table_in_tables465 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_66_in_tables468 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_table_in_tables470 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_BASIC_NAME_in_table_name486 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000008L}); + public static final BitSet FOLLOW_67_in_table_name490 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_BASIC_NAME_in_table_name493 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_BASIC_NAME_in_alias506 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_BASIC_NAME_in_column_name518 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000008L}); + public static final BitSet FOLLOW_67_in_column_name522 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_BASIC_NAME_in_column_name525 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_column_name_in_insertColumn539 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_column_name_in_kv556 = new BitSet(new long[]{0x0000000008040000L,0x00000000000003F1L}); + public static final BitSet FOLLOW_op_in_kv558 = new BitSet(new long[]{0x0000100000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_PRE_SET_in_kv561 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_74_in_kv563 = new BitSet(new long[]{0x0000100000000000L}); + public static final BitSet FOLLOW_PRE_SET_in_kv565 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000800L}); + public static final BitSet FOLLOW_75_in_kv567 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_column_name_in_kv578 = new BitSet(new long[]{0x0000000008040000L,0x00000000000003F1L}); + public static final BitSet FOLLOW_op_in_kv580 = new BitSet(new long[]{0x0020000000000000L}); + public static final BitSet FOLLOW_TEXT_STRING_in_kv582 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_column_name_in_kv589 = new BitSet(new long[]{0x0000000000000400L}); + public static final BitSet FOLLOW_BETWEEN_in_kv591 = new BitSet(new long[]{0x0000100000000000L}); + public static final BitSet FOLLOW_PRE_SET_in_kv593 = new BitSet(new long[]{0x0000000000000020L}); + public static final BitSet FOLLOW_AND_in_kv595 = new BitSet(new long[]{0x0000100000000000L}); + public static final BitSet FOLLOW_PRE_SET_in_kv597 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_column_name_in_kv608 = new BitSet(new long[]{0x0000000008040000L,0x00000000000003F1L}); + public static final BitSet FOLLOW_op_in_kv610 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_column_name_in_kv612 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_column_name_in_kv618 = new BitSet(new long[]{0x0000000008040000L,0x00000000000003F1L}); + public static final BitSet FOLLOW_op_in_kv620 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_func2_in_kv622 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_column_name_in_kv628 = new BitSet(new long[]{0x0000000008040000L,0x00000000000003F1L}); + public static final BitSet FOLLOW_op_in_kv630 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_74_in_kv632 = new BitSet(new long[]{0x0004000000000000L}); + public static final BitSet FOLLOW_sql_select_in_kv634 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000800L}); + public static final BitSet FOLLOW_75_in_kv636 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_column_name_in_kv643 = new BitSet(new long[]{0x0000000008040000L,0x00000000000003F1L}); + public static final BitSet FOLLOW_op_in_kv645 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_74_in_kv647 = new BitSet(new long[]{0x0000100000000000L}); + public static final BitSet FOLLOW_inexpr_in_kv649 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000800L}); + public static final BitSet FOLLOW_75_in_kv652 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_PRE_SET_in_inexpr668 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000004L}); + public static final BitSet FOLLOW_66_in_inexpr670 = new BitSet(new long[]{0x0000100000000000L}); + public static final BitSet FOLLOW_PRE_SET_in_inexpr672 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_66_in_inexpr675 = new BitSet(new long[]{0x0000100000000000L}); + public static final BitSet FOLLOW_PRE_SET_in_inexpr677 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_BASIC_NAME_in_func2690 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_74_in_func2694 = new BitSet(new long[]{0x0020000000000200L,0x0000000000000800L}); + public static final BitSet FOLLOW_column_name_in_func2702 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000804L}); + public static final BitSet FOLLOW_TEXT_STRING_in_func2704 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000804L}); + public static final BitSet FOLLOW_66_in_func2708 = new BitSet(new long[]{0x0020000000000200L}); + public static final BitSet FOLLOW_column_name_in_func2711 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000804L}); + public static final BitSet FOLLOW_TEXT_STRING_in_func2713 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000804L}); + public static final BitSet FOLLOW_75_in_func2723 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ORDER_in_orderby765 = new BitSet(new long[]{0x0000000000000800L}); + public static final BitSet FOLLOW_BY_in_orderby767 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_column_name_in_orderby769 = new BitSet(new long[]{0x0000000000010082L,0x0000000000000004L}); + public static final BitSet FOLLOW_66_in_orderby779 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_column_name_in_orderby781 = new BitSet(new long[]{0x0000000000010082L,0x0000000000000004L}); + public static final BitSet FOLLOW_GROUP_in_groupby802 = new BitSet(new long[]{0x0000000000000800L}); + public static final BitSet FOLLOW_BY_in_groupby804 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_column_name_in_groupby806 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_66_in_groupby809 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_column_name_in_groupby811 = new BitSet(new long[]{0x0000000000000002L,0x0000000000000004L}); + public static final BitSet FOLLOW_HAVING_in_having824 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_column_name_in_having827 = new BitSet(new long[]{0x0000000008040000L,0x00000000000003F1L}); + public static final BitSet FOLLOW_func_in_having829 = new BitSet(new long[]{0x0000000008040000L,0x00000000000003F1L}); + public static final BitSet FOLLOW_op_in_having832 = new BitSet(new long[]{0x0020100000000200L}); + public static final BitSet FOLLOW_column_name_in_having835 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_func_in_having837 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_TEXT_STRING_in_having839 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_PRE_SET_in_having841 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_ROWNUMBER_in_db2_paging855 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_74_in_db2_paging856 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000800L}); + public static final BitSet FOLLOW_75_in_db2_paging857 = new BitSet(new long[]{0x0000040000000000L}); + public static final BitSet FOLLOW_OVER_in_db2_paging859 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000400L}); + public static final BitSet FOLLOW_74_in_db2_paging860 = new BitSet(new long[]{0x0000020000000000L}); + public static final BitSet FOLLOW_orderby_in_db2_paging861 = new BitSet(new long[]{0x0000000000000000L,0x0000000000000800L}); + public static final BitSet FOLLOW_75_in_db2_paging863 = new BitSet(new long[]{0x0000000000000240L}); + public static final BitSet FOLLOW_AS_in_db2_paging866 = new BitSet(new long[]{0x0000000000000200L}); + public static final BitSet FOLLOW_BASIC_NAME_in_db2_paging870 = new BitSet(new long[]{0x0000000000000002L}); + +} \ No newline at end of file diff --git a/src/main/java/halo/dal/sql/DALDataSource.java b/src/main/java/halo/dal/sql/DALDataSource.java index 9e361a3..8d57798 100644 --- a/src/main/java/halo/dal/sql/DALDataSource.java +++ b/src/main/java/halo/dal/sql/DALDataSource.java @@ -46,6 +46,11 @@ private DataSource getCurrentDataSource() { return ds; } + /** + * 真正的connection by zxl + * @return + * @throws SQLException + */ public Connection getCurrentConnection() throws SQLException { return this.getCurrentDataSource().getConnection(); } @@ -60,6 +65,11 @@ public void setDataSourceMap(Map dataSourceMap) { this.dataSourceMap = dataSourceMap; } + /** + * 代理connection by zxl + * @return + * @throws SQLException + */ public Connection getConnection() throws SQLException { return new DALConnection(this); } diff --git a/src/main/java/halo/dal/sql/DALPreparedStatement.java b/src/main/java/halo/dal/sql/DALPreparedStatement.java index 62f34f9..b28d835 100644 --- a/src/main/java/halo/dal/sql/DALPreparedStatement.java +++ b/src/main/java/halo/dal/sql/DALPreparedStatement.java @@ -150,8 +150,9 @@ private void prepare() throws SQLException { if (sqlStruct.isCanParse()) { sqlInfo = dalFactory.getSqlAnalyzer().analyse(sql, sqlStruct, values.toArray(new Object[values.size()]), context); + //这儿可能会替换原始 sql语句 + this.parsePartition(sqlStruct, sqlInfo); } - this.parsePartition(sqlStruct, sqlInfo); this.initRealPreparedStatement(); if (this.maxFieldSize != 0) { ps.setMaxFieldSize(maxFieldSize); @@ -217,13 +218,19 @@ private void parsePartition(SQLStruct sqlStruct, SQLInfo sqlInfo) + parser.getClass().getName() + " can not be null : " + table); } + if (partitionTableInfo.getRealTable() == null) { + throw new DALRunTimeException( + "partitionTableInfo return from " + + parser.getClass().getName() + + " #getRealTable() can not be null : " + table); + } parsedTableInfo.setRealTable(table, partitionTableInfo.getRealTable()); } } - // 如果不需要解析路由,就设置默认数据源 - if (partitionTableInfo == null) { -// DALCurrentStatus.setDefaultDsKey(); + // 如果不需要解析路由,或者路由器未设置数据源,就设置默认数据源 + if (partitionTableInfo == null || partitionTableInfo.getDsName()==null) { + DALCurrentStatus.setDefaultDsKey(); } // 设置解析后的数据源 else { @@ -509,16 +516,42 @@ public boolean isWrapperFor(Class iface) throws SQLException { return ps.isWrapperFor(iface); } + /** + * 分库分表入口 + * @return + * @throws SQLException + */ public ResultSet executeQuery() throws SQLException { this.prepare(); return ps.executeQuery(); } + /** + * 分库分表入口 + * @return + * @throws SQLException + */ public int executeUpdate() throws SQLException { this.prepare(); return ps.executeUpdate(); } + /** + * 分库分表入口 + * @return + * @throws SQLException + */ + public boolean execute() throws SQLException { + this.prepare(); + return ps.execute(); + } + + /** + * 拦截参数设置 + * @param parameterIndex + * @param sqlType + * @throws SQLException + */ public void setNull(int parameterIndex, int sqlType) throws SQLException { this.dalParameters.set(DALParameters.MN_SETNULL_I_I, parameterIndex, new Object[] { sqlType }); @@ -606,7 +639,7 @@ public void setUnicodeStream(int parameterIndex, InputStream x, int length) public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { this.dalParameters.set(DALParameters.MN_SETBINARYSTREAM_I_IN_I, - parameterIndex, new Object[] { x, length }); + parameterIndex, new Object[]{x, length}); } public void clearParameters() throws SQLException { @@ -624,13 +657,10 @@ public void setObject(int parameterIndex, Object x, int targetSqlType) public void setObject(int parameterIndex, Object x) throws SQLException { this.dalParameters.set(DALParameters.MN_SETOBJECT_I_O, parameterIndex, - new Object[] { x }); + new Object[]{x}); } - public boolean execute() throws SQLException { - this.prepare(); - return ps.execute(); - } + public void addBatch() throws SQLException { throw new SQLException("do not support batch"); diff --git a/src/test/java/example/QueryTest.java b/src/test/java/example/QueryTest.java index 642415a..2b334f5 100644 --- a/src/test/java/example/QueryTest.java +++ b/src/test/java/example/QueryTest.java @@ -8,8 +8,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import java.sql.Timestamp; -import java.sql.Types; import javax.annotation.Resource; @@ -27,8 +25,8 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration({ "/querytest.xml" }) -@Transactional +@ContextConfiguration({"/querytest.xml"}) +//@Transactional public class QueryTest { @Resource @@ -38,17 +36,11 @@ public class QueryTest { public void insert() { DALCustomInfo dalCustomInfo = new DALCustomInfo(); dalCustomInfo.setDsKey("ds01"); - dalCustomInfo.setRealTable("user", "user0"); - DALCurrentStatus.setCustomInfo(dalCustomInfo); + dalCustomInfo.setRealTable("person", "person2"); +// DALCurrentStatus.setCustomInfo(dalCustomInfo); final long time = System.currentTimeMillis() / 1000; final long userid; - final String sql = "insert into user" + "(userid," + "nick," + "sex," - + "addr," + "intro," + "createtime," + "uuid," + "uuid2," - + "uuid3," + "uuid4," + "uuid5," + "uuid6," + "uuid7," - + "uuid8," + "uuid9," + "uuid10," + "uuid11," + "uuid12)" - + "values" + "(" + "?," + "?," + "?," + "?," + "?," + "?," - + "?," + "?," + "?," + "?," + "?," + "?," + "?," + "?," + "?," - + "?," + "?," + "?" + ")"; + final String sql = "insert into person ( pid , name , level) values ( ? ,? ,?)"; // insert into daltest1,user1 userid = jdbcTemplate.execute(new PreparedStatementCreator() { @@ -56,24 +48,9 @@ public PreparedStatement createPreparedStatement(Connection con) throws SQLException { PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); - ps.setLong(1, 0);// <{userid: }>, - ps.setString(2, "akwei");// <{nick: }>, - ps.setNull(3, 0);// <{sex: }>, - ps.setString(4, "addr");// <{addr: }>, - ps.setString(5, "intro");// <{intro: }>, - ps.setTimestamp(6, new Timestamp(time));// <{createtime: }>, - ps.setLong(7, Long.MAX_VALUE);// <{uuid: }>, - ps.setDouble(8, Types.NULL);// <{uuid2: }>, - ps.setDouble(9, 90.8);// <{uuid3: }>, - ps.setFloat(10, 89.7f);// <{uuid4: }>, - ps.setFloat(11, Types.NULL);// <{uuid5: }>, - ps.setInt(12, 10);// <{uuid6: }>, - ps.setNull(13, Types.NULL);// <{uuid7: }>, - ps.setInt(14, 80);// <{uuid8: }>, - ps.setNull(15, Types.NULL);// <{uuid9: }>, - ps.setNull(16, Types.NULL);// <{uuid10: }>, - ps.setInt(17, Integer.MAX_VALUE);// <{uuid11: }>, - ps.setNull(18, Types.NULL);// <{uuid12: }> + ps.setLong(1, 2);// <{pid: }>, + ps.setString(2, "zxl");// <{name: }>, + ps.setInt(3, 1);// <{level: }>, return ps; } }, new PreparedStatementCallback() { @@ -88,35 +65,17 @@ public Long doInPreparedStatement(PreparedStatement ps) return 0L; } }); + if(userid==0){ + Assert.fail("user id is 0 !"); + } // update daltest0.user0 - DALCurrentStatus.setCustomInfo(dalCustomInfo); - String sql2 = "update user set " + "nick = ?," + "sex = ?," - + "addr = ?," + "intro = ?," + "createtime = ?," + "uuid = ?," - + "uuid2 = ?," + "uuid3 = ?," + "uuid4 = ?," + "uuid5 = ?," - + "uuid6 = ?," + "uuid7 = ?," + "uuid8 = ?," + "uuid9 = ?," - + "uuid10 = ?," + "uuid11 = ?," + "uuid12 = ?" - + " WHERE userid=?"; +// DALCurrentStatus.setCustomInfo(dalCustomInfo); + String sql2 = "update person set name = ? where pid = ?"; int res = jdbcTemplate.update(sql2, new PreparedStatementSetter() { public void setValues(PreparedStatement ps) throws SQLException { - ps.setString(1, "akwei");// <{nick: }>, - ps.setNull(2, 1);// <{sex: }>, - ps.setString(3, "addr");// <{addr: }>, - ps.setString(4, "intro");// <{intro: }>, - ps.setTimestamp(5, new Timestamp(time));// <{createtime: }>, - ps.setLong(6, Long.MAX_VALUE);// <{uuid: }>, - ps.setDouble(7, Types.NULL);// <{uuid2: }>, - ps.setDouble(8, 90.8);// <{uuid3: }>, - ps.setFloat(9, 89.7f);// <{uuid4: }>, - ps.setFloat(10, Types.NULL);// <{uuid5: }>, - ps.setInt(11, 10);// <{uuid6: }>, - ps.setNull(12, Types.NULL);// <{uuid7: }>, - ps.setInt(13, 80);// <{uuid8: }>, - ps.setNull(14, Types.NULL);// <{uuid9: }>, - ps.setNull(15, Types.NULL);// <{uuid10: }>, - ps.setInt(16, Integer.MAX_VALUE);// <{uuid11: }>, - ps.setNull(17, Types.NULL);// <{uuid12: }> - ps.setLong(18, userid); + ps.setString(1, "zxlzxl");// <{name: }>, + ps.setLong(2,2); } }); if (res != 1) { diff --git a/src/test/java/hibernate-spring.xml b/src/test/java/hibernate-spring.xml index 21d2ca8..95b4d0d 100644 --- a/src/test/java/hibernate-spring.xml +++ b/src/test/java/hibernate-spring.xml @@ -13,33 +13,31 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/src/test/java/unittest/QueryTest.java b/src/test/java/unittest/QueryTest.java index bd69c1d..4fb9c32 100644 --- a/src/test/java/unittest/QueryTest.java +++ b/src/test/java/unittest/QueryTest.java @@ -29,7 +29,7 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration({ "/querytest.xml" }) +@ContextConfiguration({"/querytest.xml"}) @Transactional public class QueryTest { diff --git a/src/test/java/unittest/SQLAnalyzerTest.java b/src/test/java/unittest/SQLAnalyzerTest.java index c0f265d..b34f2ff 100644 --- a/src/test/java/unittest/SQLAnalyzerTest.java +++ b/src/test/java/unittest/SQLAnalyzerTest.java @@ -33,6 +33,8 @@ public void delete() { Object[] values = new Object[] { 1, 50, 10, 1, 2 }; SQLStruct sqlStruct = sqlAnalyzer.parse(sql, context); SQLInfo sqlInfo = sqlAnalyzer.analyse(sql, sqlStruct, values, context); + System.out.println(sqlStruct); + System.out.println(sqlInfo); Assert.assertEquals(1, sqlStruct.getTableNames().size()); Assert.assertEquals("user", sqlStruct.getTableNames().get(0)); ParsedTableInfo parsedTableInfo = new ParsedTableInfo(); @@ -42,7 +44,9 @@ public void delete() { // no where sql = "delete from user"; sqlStruct = sqlAnalyzer.parse(sql, context); - sqlInfo = sqlAnalyzer.analyse(sql, sqlStruct, null, context); + sqlInfo = sqlAnalyzer.analyse(sql, sqlStruct, values, context); + System.out.println(sqlStruct); + System.out.println(sqlInfo); Assert.assertEquals(1, sqlStruct.getTableNames().size()); Assert.assertEquals("user", sqlStruct.getTableNames().get(0)); sql2 = sqlAnalyzer.outPutSQL(sql, sqlStruct, sqlInfo, parsedTableInfo); diff --git a/src/test/java/unittest/parser/PersonParser.java b/src/test/java/unittest/parser/PersonParser.java index 216e794..5db32c8 100644 --- a/src/test/java/unittest/parser/PersonParser.java +++ b/src/test/java/unittest/parser/PersonParser.java @@ -19,22 +19,21 @@ public class PersonParser implements PartitionParser { public PartitionTableInfo parse(String tableLogicName, SQLInfo sqlInfo, ConnectionStatus connectionStatus) { - PartitionTableInfo partitionTableInfo = new PartitionTableInfo(); + SQLExpression[] sqlExpressions = sqlInfo - .getSQLExpressions("person.level"); + .getSQLExpressions("pid"); + if(sqlExpressions==null) return null; for (SQLExpression e : sqlExpressions) { if (e.getSqlExpressionSymbol() == SQLExpressionSymbol.EQUAL) { - Integer l = (Integer) e.getValue(); - if (l.intValue() % 2 == 0) { - partitionTableInfo.setRealTable("person0"); - partitionTableInfo.setDsName("ds00"); - } - else { - partitionTableInfo.setRealTable("person0"); - partitionTableInfo.setDsName("ds01"); - } + long l = (Long) e.getValue(); + long dsNumber=(l%4)>1?1:0; + long tableNumber=l%4; + PartitionTableInfo partitionTableInfo = new PartitionTableInfo(); + partitionTableInfo.setRealTable("person"+tableNumber); + partitionTableInfo.setDsName("ds0"+dsNumber); + return partitionTableInfo; } } - return partitionTableInfo; + return null; } } diff --git a/src/test/java/querytest.xml b/src/test/resources/querytest.xml similarity index 60% rename from src/test/java/querytest.xml rename to src/test/resources/querytest.xml index 94b1742..ce4661a 100644 --- a/src/test/java/querytest.xml +++ b/src/test/resources/querytest.xml @@ -1,84 +1,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file