mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
+43
-43
@@ -80,14 +80,14 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
accept(Token.CREATE);
|
||||
}
|
||||
|
||||
if (identifierEquals("TEMPORARY")) {
|
||||
if (lexer.identifierEquals("TEMPORARY")) {
|
||||
lexer.nextToken();
|
||||
stmt.setType(SQLCreateTableStatement.Type.GLOBAL_TEMPORARY);
|
||||
}
|
||||
|
||||
accept(Token.TABLE);
|
||||
|
||||
if (lexer.token() == Token.IF || identifierEquals("IF")) {
|
||||
if (lexer.token() == Token.IF || lexer.identifierEquals("IF")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.NOT);
|
||||
accept(Token.EXISTS);
|
||||
@@ -132,7 +132,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
}
|
||||
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals("USING")) {
|
||||
lexer.nextToken();
|
||||
idx.setIndexType(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
@@ -149,7 +149,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
accept(Token.RPAREN);
|
||||
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals("USING")) {
|
||||
lexer.nextToken();
|
||||
idx.setIndexType(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
@@ -190,7 +190,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("ENGINE")) {
|
||||
if (lexer.identifierEquals("ENGINE")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -199,7 +199,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("AUTO_INCREMENT")) {
|
||||
if (lexer.identifierEquals("AUTO_INCREMENT")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -208,7 +208,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("AVG_ROW_LENGTH")) {
|
||||
if (lexer.identifierEquals("AVG_ROW_LENGTH")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -227,7 +227,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("CHECKSUM")) {
|
||||
if (lexer.identifierEquals("CHECKSUM")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -245,7 +245,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("CONNECTION")) {
|
||||
if (lexer.identifierEquals("CONNECTION")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -254,7 +254,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("DATA")) {
|
||||
if (lexer.identifierEquals("DATA")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("DIRECTORY");
|
||||
if (lexer.token() == Token.EQ) {
|
||||
@@ -264,7 +264,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("DELAY_KEY_WRITE")) {
|
||||
if (lexer.identifierEquals("DELAY_KEY_WRITE")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -273,7 +273,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("INDEX")) {
|
||||
if (lexer.identifierEquals("INDEX")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("DIRECTORY");
|
||||
if (lexer.token() == Token.EQ) {
|
||||
@@ -283,7 +283,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("INSERT_METHOD")) {
|
||||
if (lexer.identifierEquals("INSERT_METHOD")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -292,7 +292,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("KEY_BLOCK_SIZE")) {
|
||||
if (lexer.identifierEquals("KEY_BLOCK_SIZE")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -301,7 +301,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("MAX_ROWS")) {
|
||||
if (lexer.identifierEquals("MAX_ROWS")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -310,7 +310,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("MIN_ROWS")) {
|
||||
if (lexer.identifierEquals("MIN_ROWS")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -319,7 +319,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("PACK_KEYS")) {
|
||||
if (lexer.identifierEquals("PACK_KEYS")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -328,7 +328,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("PASSWORD")) {
|
||||
if (lexer.identifierEquals("PASSWORD")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -337,7 +337,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("ROW_FORMAT")) {
|
||||
if (lexer.identifierEquals("ROW_FORMAT")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -346,7 +346,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("STATS_AUTO_RECALC")) {
|
||||
if (lexer.identifierEquals("STATS_AUTO_RECALC")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -356,7 +356,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("STATS_PERSISTENT")) {
|
||||
if (lexer.identifierEquals("STATS_PERSISTENT")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -366,7 +366,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("STATS_SAMPLE_PAGES")) {
|
||||
if (lexer.identifierEquals("STATS_SAMPLE_PAGES")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -395,7 +395,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
TableSpaceOption option = new TableSpaceOption();
|
||||
option.setName(this.exprParser.name());
|
||||
|
||||
if (identifierEquals("STORAGE")) {
|
||||
if (lexer.identifierEquals("STORAGE")) {
|
||||
lexer.nextToken();
|
||||
option.setStorage(this.exprParser.name());
|
||||
}
|
||||
@@ -404,7 +404,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("TABLEGROUP")) {
|
||||
if (lexer.identifierEquals("TABLEGROUP")) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLName tableGroup = this.exprParser.name();
|
||||
@@ -412,7 +412,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("TYPE")) {
|
||||
if (lexer.identifierEquals("TYPE")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.EQ);
|
||||
stmt.getTableOptions().put("TYPE", this.exprParser.expr());
|
||||
@@ -427,7 +427,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
SQLPartitionBy partitionClause;
|
||||
|
||||
boolean linera = false;
|
||||
if (identifierEquals("LINEAR")) {
|
||||
if (lexer.identifierEquals("LINEAR")) {
|
||||
lexer.nextToken();
|
||||
linera = true;
|
||||
}
|
||||
@@ -456,7 +456,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
partitionClause = clause;
|
||||
|
||||
partitionClauseRest(clause);
|
||||
} else if (identifierEquals("HASH")) {
|
||||
} else if (lexer.identifierEquals("HASH")) {
|
||||
lexer.nextToken();
|
||||
SQLPartitionByHash clause = new SQLPartitionByHash();
|
||||
|
||||
@@ -476,13 +476,13 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
|
||||
partitionClauseRest(clause);
|
||||
|
||||
} else if (identifierEquals("RANGE")) {
|
||||
} else if (lexer.identifierEquals("RANGE")) {
|
||||
SQLPartitionByRange clause = partitionByRange();
|
||||
partitionClause = clause;
|
||||
|
||||
partitionClauseRest(clause);
|
||||
|
||||
} else if (identifierEquals("LIST")) {
|
||||
} else if (lexer.identifierEquals("LIST")) {
|
||||
lexer.nextToken();
|
||||
SQLPartitionByList clause = new SQLPartitionByList();
|
||||
|
||||
@@ -582,7 +582,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
|
||||
protected void partitionClauseRest(SQLPartitionBy clause) {
|
||||
if (identifierEquals("PARTITIONS")) {
|
||||
if (lexer.identifierEquals("PARTITIONS")) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLIntegerExpr countExpr = this.exprParser.integerExpr();
|
||||
@@ -592,7 +592,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
if (lexer.token() == Token.PARTITION) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("NUM")) {
|
||||
if (lexer.identifierEquals("NUM")) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
@@ -601,14 +601,14 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
clause.putAttribute("ads.partition", Boolean.TRUE);
|
||||
}
|
||||
|
||||
if (identifierEquals("SUBPARTITION")) {
|
||||
if (lexer.identifierEquals("SUBPARTITION")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
|
||||
SQLSubPartitionBy subPartitionByClause = null;
|
||||
|
||||
boolean linear = false;
|
||||
if (identifierEquals("LINEAR")) {
|
||||
if (lexer.identifierEquals("LINEAR")) {
|
||||
lexer.nextToken();
|
||||
linear = true;
|
||||
}
|
||||
@@ -634,7 +634,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
|
||||
subPartitionByClause = subPartitionKey;
|
||||
|
||||
} else if (identifierEquals("HASH")) {
|
||||
} else if (lexer.identifierEquals("HASH")) {
|
||||
lexer.nextToken();
|
||||
SQLSubPartitionByHash subPartitionHash = new SQLSubPartitionByHash();
|
||||
|
||||
@@ -652,7 +652,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
accept(Token.RPAREN);
|
||||
subPartitionByClause = subPartitionHash;
|
||||
|
||||
} else if (identifierEquals("LIST")) {
|
||||
} else if (lexer.identifierEquals("LIST")) {
|
||||
lexer.nextToken();
|
||||
MySqlSubPartitionByList subPartitionList = new MySqlSubPartitionByList();
|
||||
|
||||
@@ -660,7 +660,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
lexer.nextToken();
|
||||
SQLExpr expr = this.exprParser.expr();
|
||||
|
||||
if (expr instanceof SQLIdentifierExpr && (identifierEquals("bigint") || identifierEquals("long"))) {
|
||||
if (expr instanceof SQLIdentifierExpr && (lexer.identifierEquals("bigint") || lexer.identifierEquals("long"))) {
|
||||
String dataType = lexer.stringVal();
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -690,7 +690,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
subPartitionByClause = subPartitionList;
|
||||
}
|
||||
|
||||
if (identifierEquals("SUBPARTITION")) {
|
||||
if (lexer.identifierEquals("SUBPARTITION")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("OPTIONS");
|
||||
accept(Token.LPAREN);
|
||||
@@ -703,7 +703,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
subPartitionByClause.getOptions().add(option);
|
||||
}
|
||||
|
||||
if (identifierEquals("SUBPARTITIONS")) {
|
||||
if (lexer.identifierEquals("SUBPARTITIONS")) {
|
||||
lexer.nextToken();
|
||||
Number intValue = lexer.integerValue();
|
||||
SQLNumberExpr numExpr = new SQLNumberExpr(intValue);
|
||||
@@ -720,7 +720,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
|
||||
private boolean parseTableOptionCharsetOrCollate(MySqlCreateTableStatement stmt) {
|
||||
if (identifierEquals("CHARACTER")) {
|
||||
if (lexer.identifierEquals("CHARACTER")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.SET);
|
||||
if (lexer.token() == Token.EQ) {
|
||||
@@ -730,7 +730,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (identifierEquals("CHARSET")) {
|
||||
if (lexer.identifierEquals("CHARSET")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -739,7 +739,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (identifierEquals("COLLATE")) {
|
||||
if (lexer.identifierEquals("COLLATE")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -783,7 +783,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
|
||||
// 5.5语法 USING BTREE 放在index 名字后
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals("USING")) {
|
||||
lexer.nextToken();
|
||||
key.setIndexType(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
@@ -813,7 +813,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
key.setName(name);
|
||||
}
|
||||
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals("USING")) {
|
||||
lexer.nextToken();
|
||||
key.setIndexType(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -57,6 +57,7 @@ import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.SQLSelectParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
import com.alibaba.druid.util.FNVUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class MySqlExprParser extends SQLExprParser {
|
||||
@@ -85,7 +86,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
public SQLExpr relationalRest(SQLExpr expr) {
|
||||
if (identifierEquals("REGEXP")) {
|
||||
if (lexer.identifierEquals(FNVUtils.REGEXP)) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = equality();
|
||||
|
||||
@@ -117,7 +118,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
public SQLExpr notRationalRest(SQLExpr expr) {
|
||||
if (identifierEquals("REGEXP")) {
|
||||
if (lexer.identifierEquals("REGEXP")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = primary();
|
||||
|
||||
@@ -132,7 +133,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
public SQLExpr primary() {
|
||||
final Token tok = lexer.token();
|
||||
|
||||
if (identifierEquals("outfile")) {
|
||||
if (lexer.identifierEquals(FNVUtils.OUTFILE)) {
|
||||
lexer.nextToken();
|
||||
SQLExpr file = primary();
|
||||
SQLExpr expr = new MySqlOutFileExpr(file);
|
||||
@@ -214,7 +215,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
|
||||
MySqlCharExpr mysqlCharExpr = new MySqlCharExpr(charValue);
|
||||
mysqlCharExpr.setCharset(identExpr.getName());
|
||||
if (identifierEquals("COLLATE")) {
|
||||
if (lexer.identifierEquals("COLLATE")) {
|
||||
lexer.nextToken();
|
||||
|
||||
String collate = lexer.stringVal();
|
||||
@@ -398,7 +399,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
|
||||
if (lexer.token() == Token.IN) {
|
||||
lexer.nextToken();
|
||||
if (identifierEquals("NATURAL")) {
|
||||
if (lexer.identifierEquals("NATURAL")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("LANGUAGE");
|
||||
acceptIdentifier("MODE");
|
||||
@@ -410,7 +411,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
} else {
|
||||
matchAgainstExpr.setSearchModifier(SearchModifier.IN_NATURAL_LANGUAGE_MODE);
|
||||
}
|
||||
} else if (identifierEquals("BOOLEAN")) {
|
||||
} else if (lexer.identifierEquals("BOOLEAN")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("MODE");
|
||||
matchAgainstExpr.setSearchModifier(SearchModifier.IN_BOOLEAN_MODE);
|
||||
@@ -434,7 +435,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
exprList(methodInvokeExpr.getParameters(), methodInvokeExpr);
|
||||
}
|
||||
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals(FNVUtils.USING)) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException("syntax error. " + lexer.info());
|
||||
@@ -556,12 +557,12 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
SQLExpr expr = this.expr();
|
||||
column.setOnUpdate(expr);
|
||||
}
|
||||
if (identifierEquals("CHARSET")) {
|
||||
if (lexer.identifierEquals("CHARSET")) {
|
||||
lexer.nextToken();
|
||||
MySqlCharExpr charSetCollateExpr=new MySqlCharExpr();
|
||||
charSetCollateExpr.setCharset(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
if (identifierEquals("COLLATE")) {
|
||||
if (lexer.identifierEquals("COLLATE")) {
|
||||
lexer.nextToken();
|
||||
charSetCollateExpr.setCollate(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
@@ -569,13 +570,13 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
column.setCharsetExpr(charSetCollateExpr);
|
||||
return parseColumnRest(column);
|
||||
}
|
||||
if (identifierEquals("AUTO_INCREMENT")) {
|
||||
if (lexer.identifierEquals("AUTO_INCREMENT")) {
|
||||
lexer.nextToken();
|
||||
column.setAutoIncrement(true);
|
||||
return parseColumnRest(column);
|
||||
}
|
||||
|
||||
if (identifierEquals("precision") && column.getDataType().getName().equalsIgnoreCase("double")) {
|
||||
if (lexer.identifierEquals("precision") && column.getDataType().getName().equalsIgnoreCase("double")) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
@@ -583,7 +584,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
throw new ParserException("syntax error " + lexer.info());
|
||||
}
|
||||
|
||||
if (identifierEquals("STORAGE")) {
|
||||
if (lexer.identifierEquals("STORAGE")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr expr = expr();
|
||||
column.setStorage(expr);
|
||||
@@ -597,12 +598,12 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
if (identifierEquals("STORED")) {
|
||||
if (lexer.identifierEquals("STORED")) {
|
||||
lexer.nextToken();
|
||||
column.setSorted(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("VIRTUAL")) {
|
||||
if (lexer.identifierEquals("VIRTUAL")) {
|
||||
lexer.nextToken();
|
||||
column.setVirtual(true);
|
||||
}
|
||||
@@ -615,12 +616,12 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
protected SQLDataType parseDataTypeRest(SQLDataType dataType) {
|
||||
super.parseDataTypeRest(dataType);
|
||||
|
||||
if (identifierEquals("UNSIGNED")) {
|
||||
if (lexer.identifierEquals("UNSIGNED")) {
|
||||
lexer.nextToken();
|
||||
dataType.getAttributes().put("UNSIGNED", true);
|
||||
}
|
||||
|
||||
if (identifierEquals("ZEROFILL")) {
|
||||
if (lexer.identifierEquals("ZEROFILL")) {
|
||||
lexer.nextToken();
|
||||
dataType.getAttributes().put("ZEROFILL", true);
|
||||
}
|
||||
@@ -708,7 +709,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
accept(Token.LITERAL_CHARS);
|
||||
}
|
||||
|
||||
if (identifierEquals("COLLATE")) {
|
||||
if (lexer.identifierEquals("COLLATE")) {
|
||||
MySqlCharExpr charsetExpr = new MySqlCharExpr(charset);
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -779,7 +780,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
|
||||
MySqlPrimaryKey primaryKey = new MySqlPrimaryKey();
|
||||
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals("USING")) {
|
||||
lexer.nextToken();
|
||||
primaryKey.setIndexType(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
@@ -823,7 +824,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
//5.5语法 USING BTREE 放在index 名字后
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals("USING")) {
|
||||
lexer.nextToken();
|
||||
unique.setIndexType(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
@@ -848,7 +849,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
}
|
||||
accept(Token.RPAREN);
|
||||
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals("USING")) {
|
||||
lexer.nextToken();
|
||||
unique.setIndexType(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
@@ -880,12 +881,12 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
this.names(fk.getReferencedColumns());
|
||||
accept(Token.RPAREN);
|
||||
|
||||
if (identifierEquals("MATCH")) {
|
||||
if (identifierEquals("FULL")) {
|
||||
if (lexer.identifierEquals("MATCH")) {
|
||||
if (lexer.identifierEquals("FULL")) {
|
||||
fk.setReferenceMatch(Match.FULL);
|
||||
} else if (identifierEquals("PARTIAL")) {
|
||||
} else if (lexer.identifierEquals("PARTIAL")) {
|
||||
fk.setReferenceMatch(Match.PARTIAL);
|
||||
} else if (identifierEquals("SIMPLE")) {
|
||||
} else if (lexer.identifierEquals("SIMPLE")) {
|
||||
fk.setReferenceMatch(Match.SIMPLE);
|
||||
}
|
||||
}
|
||||
@@ -913,19 +914,19 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
|
||||
protected Option parseReferenceOption() {
|
||||
Option option;
|
||||
if (lexer.token() == Token.RESTRICT || identifierEquals("RESTRICT")) {
|
||||
if (lexer.token() == Token.RESTRICT || lexer.identifierEquals("RESTRICT")) {
|
||||
option = Option.RESTRICT;
|
||||
lexer.nextToken();
|
||||
} else if (identifierEquals("CASCADE")) {
|
||||
} else if (lexer.identifierEquals("CASCADE")) {
|
||||
option = Option.CASCADE;
|
||||
lexer.nextToken();
|
||||
} else if (lexer.token() == Token.SET) {
|
||||
lexer.nextToken();
|
||||
accept(Token.NULL);
|
||||
option = Option.SET_NULL;
|
||||
} else if (identifierEquals("ON")) {
|
||||
} else if (lexer.identifierEquals("ON")) {
|
||||
lexer.nextToken();
|
||||
if (identifierEquals("ACTION")) {
|
||||
if (lexer.identifierEquals("ACTION")) {
|
||||
option = Option.NO_ACTION;
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
@@ -945,7 +946,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
SQLOrderBy orderBy = this.parseOrderBy();
|
||||
aggregateExpr.putAttribute("ORDER BY", orderBy);
|
||||
}
|
||||
if (identifierEquals("SEPARATOR")) {
|
||||
if (lexer.identifierEquals("SEPARATOR")) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLExpr seperator = this.primary();
|
||||
@@ -986,7 +987,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
|
||||
for (;;) {
|
||||
boolean storage = false;
|
||||
if (identifierEquals("DATA")) {
|
||||
if (lexer.identifierEquals("DATA")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("DIRECTORY");
|
||||
if (lexer.token() == Token.EQ) {
|
||||
@@ -1007,22 +1008,22 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
lexer.nextToken();
|
||||
}
|
||||
partitionDef.setIndexDirectory(this.expr());
|
||||
} else if (identifierEquals("MAX_ROWS")) {
|
||||
} else if (lexer.identifierEquals("MAX_ROWS")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
SQLExpr maxRows = this.primary();
|
||||
partitionDef.setMaxRows(maxRows);
|
||||
} else if (identifierEquals("MIN_ROWS")) {
|
||||
} else if (lexer.identifierEquals("MIN_ROWS")) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
SQLExpr minRows = this.primary();
|
||||
partitionDef.setMaxRows(minRows);
|
||||
} else if (identifierEquals("ENGINE") || //
|
||||
(storage = (lexer.token() == Token.STORAGE || identifierEquals("STORAGE")))) {
|
||||
} else if (lexer.identifierEquals("ENGINE") || //
|
||||
(storage = (lexer.token() == Token.STORAGE || lexer.identifierEquals("STORAGE")))) {
|
||||
if (storage) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
@@ -21,11 +21,7 @@ import static com.alibaba.druid.sql.parser.LayoutCharacters.EOI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.druid.sql.parser.Keywords;
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.NotAllowCommentException;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
import com.alibaba.druid.sql.parser.*;
|
||||
|
||||
public class MySqlLexer extends Lexer {
|
||||
|
||||
@@ -216,6 +212,9 @@ public class MySqlLexer extends Lexer {
|
||||
}
|
||||
|
||||
public void scanIdentifier() {
|
||||
hash_lower = 0;
|
||||
hash = 0;
|
||||
|
||||
final char first = ch;
|
||||
|
||||
if (ch == 'b' && charAt(pos + 1) == '\'') {
|
||||
@@ -274,9 +273,14 @@ public class MySqlLexer extends Lexer {
|
||||
throw new ParserException("illegal identifier. " + info());
|
||||
}
|
||||
|
||||
long hashCode = 0xcbf29ce484222325L;
|
||||
hashCode ^= ((ch >= 'A' && ch <= 'Z') ? (ch + 32) : ch);
|
||||
hashCode *= 0x100000001b3L;
|
||||
hash_lower = 0xcbf29ce484222325L;
|
||||
hash = 0xcbf29ce484222325L;
|
||||
|
||||
hash_lower ^= ((ch >= 'A' && ch <= 'Z') ? (ch + 32) : ch);
|
||||
hash_lower *= 0x100000001b3L;
|
||||
|
||||
hash ^= ch;
|
||||
hash *= 0x100000001b3L;
|
||||
|
||||
mark = pos;
|
||||
bufPos = 1;
|
||||
@@ -290,25 +294,28 @@ public class MySqlLexer extends Lexer {
|
||||
|
||||
bufPos++;
|
||||
|
||||
hashCode ^= ((ch >= 'A' && ch <= 'Z') ? (ch + 32) : ch);
|
||||
hashCode *= 0x100000001b3L;
|
||||
hash_lower ^= ((ch >= 'A' && ch <= 'Z') ? (ch + 32) : ch);
|
||||
hash_lower *= 0x100000001b3L;
|
||||
|
||||
hash ^= ch;
|
||||
hash *= 0x100000001b3L;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
this.ch = charAt(pos);
|
||||
|
||||
Token tok = keywods.getKeyword(hashCode);
|
||||
Token tok = keywods.getKeyword(hash_lower);
|
||||
if (tok != null) {
|
||||
token = tok;
|
||||
if (token == Token.IDENTIFIER) {
|
||||
stringVal = SymbolTable.global.addSymbol(text, mark, bufPos, hash);
|
||||
} else {
|
||||
stringVal = null;
|
||||
}
|
||||
} else {
|
||||
token = Token.IDENTIFIER;
|
||||
}
|
||||
|
||||
if (token == Token.IDENTIFIER) {
|
||||
stringVal = addSymbol();
|
||||
} else {
|
||||
stringVal = null;
|
||||
stringVal = SymbolTable.global.addSymbol(text, mark, bufPos, hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
-21
@@ -93,7 +93,7 @@ public class MySqlSelectIntoParser extends SQLSelectParser {
|
||||
if (lexer.token() == (Token.DISTINCT)) {
|
||||
queryBlock.setDistionOption(SQLSetQuantifier.DISTINCT);
|
||||
lexer.nextToken();
|
||||
} else if (identifierEquals("DISTINCTROW")) {
|
||||
} else if (lexer.identifierEquals("DISTINCTROW")) {
|
||||
queryBlock.setDistionOption(SQLSetQuantifier.DISTINCTROW);
|
||||
lexer.nextToken();
|
||||
} else if (lexer.token() == (Token.ALL)) {
|
||||
@@ -101,42 +101,42 @@ public class MySqlSelectIntoParser extends SQLSelectParser {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("HIGH_PRIORITY")) {
|
||||
if (lexer.identifierEquals("HIGH_PRIORITY")) {
|
||||
queryBlock.setHignPriority(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("STRAIGHT_JOIN")) {
|
||||
if (lexer.identifierEquals("STRAIGHT_JOIN")) {
|
||||
queryBlock.setStraightJoin(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_SMALL_RESULT")) {
|
||||
if (lexer.identifierEquals("SQL_SMALL_RESULT")) {
|
||||
queryBlock.setSmallResult(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_BIG_RESULT")) {
|
||||
if (lexer.identifierEquals("SQL_BIG_RESULT")) {
|
||||
queryBlock.setBigResult(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_BUFFER_RESULT")) {
|
||||
if (lexer.identifierEquals("SQL_BUFFER_RESULT")) {
|
||||
queryBlock.setBufferResult(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_CACHE")) {
|
||||
if (lexer.identifierEquals("SQL_CACHE")) {
|
||||
queryBlock.setCache(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_NO_CACHE")) {
|
||||
if (lexer.identifierEquals("SQL_NO_CACHE")) {
|
||||
queryBlock.setCache(false);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_CALC_FOUND_ROWS")) {
|
||||
if (lexer.identifierEquals("SQL_CALC_FOUND_ROWS")) {
|
||||
queryBlock.setCalcFoundRows(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class MySqlSelectIntoParser extends SQLSelectParser {
|
||||
if (lexer.token() == (Token.INTO)) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("OUTFILE")) {
|
||||
if (lexer.identifierEquals("OUTFILE")) {
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlOutFileExpr outFile = new MySqlOutFileExpr();
|
||||
@@ -225,42 +225,42 @@ public class MySqlSelectIntoParser extends SQLSelectParser {
|
||||
|
||||
queryBlock.setInto(outFile);
|
||||
|
||||
if (identifierEquals("FIELDS") || identifierEquals("COLUMNS")) {
|
||||
if (lexer.identifierEquals("FIELDS") || lexer.identifierEquals("COLUMNS")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("TERMINATED")) {
|
||||
if (lexer.identifierEquals("TERMINATED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
}
|
||||
outFile.setColumnsTerminatedBy((SQLLiteralExpr) expr());
|
||||
|
||||
if (identifierEquals("OPTIONALLY")) {
|
||||
if (lexer.identifierEquals("OPTIONALLY")) {
|
||||
lexer.nextToken();
|
||||
outFile.setColumnsEnclosedOptionally(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("ENCLOSED")) {
|
||||
if (lexer.identifierEquals("ENCLOSED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setColumnsEnclosedBy((SQLLiteralExpr) expr());
|
||||
}
|
||||
|
||||
if (identifierEquals("ESCAPED")) {
|
||||
if (lexer.identifierEquals("ESCAPED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setColumnsEscaped((SQLLiteralExpr) expr());
|
||||
}
|
||||
}
|
||||
|
||||
if (identifierEquals("LINES")) {
|
||||
if (lexer.identifierEquals("LINES")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("STARTING")) {
|
||||
if (lexer.identifierEquals("STARTING")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setLinesStartingBy((SQLLiteralExpr) expr());
|
||||
} else {
|
||||
identifierEquals("TERMINATED");
|
||||
lexer.identifierEquals("TERMINATED");
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setLinesTerminatedBy((SQLLiteralExpr) expr());
|
||||
@@ -273,7 +273,7 @@ public class MySqlSelectIntoParser extends SQLSelectParser {
|
||||
}
|
||||
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals("USING")) {
|
||||
return tableSource;
|
||||
}
|
||||
|
||||
@@ -284,14 +284,14 @@ public class MySqlSelectIntoParser extends SQLSelectParser {
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (identifierEquals("IGNORE")) {
|
||||
if (lexer.identifierEquals("IGNORE")) {
|
||||
lexer.nextToken();
|
||||
MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (identifierEquals("FORCE")) {
|
||||
if (lexer.identifierEquals("FORCE")) {
|
||||
lexer.nextToken();
|
||||
MySqlForceIndexHint hint = new MySqlForceIndexHint();
|
||||
parseIndexHint(hint);
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.SQLSelectParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
import com.alibaba.druid.util.FNVUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -99,53 +100,54 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
this.exprParser.parseHints(queryBlock.getHints());
|
||||
}
|
||||
|
||||
if (lexer.token() == (Token.DISTINCT)) {
|
||||
Token token = lexer.token();
|
||||
if (token == (Token.DISTINCT)) {
|
||||
queryBlock.setDistionOption(SQLSetQuantifier.DISTINCT);
|
||||
lexer.nextToken();
|
||||
} else if (identifierEquals("DISTINCTROW")) {
|
||||
} else if (lexer.identifierEquals(FNVUtils.DISTINCTROW)) {
|
||||
queryBlock.setDistionOption(SQLSetQuantifier.DISTINCTROW);
|
||||
lexer.nextToken();
|
||||
} else if (lexer.token() == (Token.ALL)) {
|
||||
} else if (token == (Token.ALL)) {
|
||||
queryBlock.setDistionOption(SQLSetQuantifier.ALL);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("HIGH_PRIORITY")) {
|
||||
if (lexer.identifierEquals(FNVUtils.HIGH_PRIORITY)) {
|
||||
queryBlock.setHignPriority(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("STRAIGHT_JOIN")) {
|
||||
if (lexer.identifierEquals(FNVUtils.STRAIGHT_JOIN)) {
|
||||
queryBlock.setStraightJoin(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_SMALL_RESULT")) {
|
||||
if (lexer.identifierEquals(FNVUtils.SQL_SMALL_RESULT)) {
|
||||
queryBlock.setSmallResult(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_BIG_RESULT")) {
|
||||
if (lexer.identifierEquals(FNVUtils.SQL_BIG_RESULT)) {
|
||||
queryBlock.setBigResult(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_BUFFER_RESULT")) {
|
||||
if (lexer.identifierEquals(FNVUtils.SQL_BUFFER_RESULT)) {
|
||||
queryBlock.setBufferResult(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_CACHE")) {
|
||||
if (lexer.identifierEquals(FNVUtils.SQL_CACHE)) {
|
||||
queryBlock.setCache(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_NO_CACHE")) {
|
||||
if (lexer.identifierEquals(FNVUtils.SQL_NO_CACHE)) {
|
||||
queryBlock.setCache(false);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("SQL_CALC_FOUND_ROWS")) {
|
||||
if (lexer.identifierEquals(FNVUtils.SQL_CALC_FOUND_ROWS)) {
|
||||
queryBlock.setCalcFoundRows(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
@@ -182,10 +184,10 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
|
||||
queryBlock.setForUpdate(true);
|
||||
|
||||
if (identifierEquals("NO_WAIT") || identifierEquals("NOWAIT")) {
|
||||
if (lexer.identifierEquals("NO_WAIT") || lexer.identifierEquals("NOWAIT")) {
|
||||
lexer.nextToken();
|
||||
queryBlock.setNoWait(true);
|
||||
} else if (identifierEquals("WAIT")) {
|
||||
} else if (lexer.identifierEquals("WAIT")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr waitTime = this.exprParser.primary();
|
||||
queryBlock.setWaitTime(waitTime);
|
||||
@@ -257,32 +259,32 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("LOW_PRIORITY")) {
|
||||
if (lexer.identifierEquals("LOW_PRIORITY")) {
|
||||
lexer.nextToken();
|
||||
update.setLowPriority(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("IGNORE")) {
|
||||
if (lexer.identifierEquals("IGNORE")) {
|
||||
lexer.nextToken();
|
||||
update.setIgnore(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("COMMIT_ON_SUCCESS")) {
|
||||
if (lexer.identifierEquals("COMMIT_ON_SUCCESS")) {
|
||||
lexer.nextToken();
|
||||
update.setCommitOnSuccess(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("ROLLBACK_ON_FAIL")) {
|
||||
if (lexer.identifierEquals("ROLLBACK_ON_FAIL")) {
|
||||
lexer.nextToken();
|
||||
update.setRollBackOnFail(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("QUEUE_ON_PK")) {
|
||||
if (lexer.identifierEquals("QUEUE_ON_PK")) {
|
||||
lexer.nextToken();
|
||||
update.setQueryOnPk(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("TARGET_AFFECT_ROW")) {
|
||||
if (lexer.identifierEquals("TARGET_AFFECT_ROW")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr targetAffectRow = this.exprParser.expr();
|
||||
update.setTargetAffectRow(targetAffectRow);
|
||||
@@ -319,7 +321,7 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
if (lexer.token() == (Token.INTO)) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("OUTFILE")) {
|
||||
if (lexer.identifierEquals("OUTFILE")) {
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlOutFileExpr outFile = new MySqlOutFileExpr();
|
||||
@@ -327,42 +329,42 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
|
||||
queryBlock.setInto(outFile);
|
||||
|
||||
if (identifierEquals("FIELDS") || identifierEquals("COLUMNS")) {
|
||||
if (lexer.identifierEquals("FIELDS") || lexer.identifierEquals("COLUMNS")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("TERMINATED")) {
|
||||
if (lexer.identifierEquals("TERMINATED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
}
|
||||
outFile.setColumnsTerminatedBy(expr());
|
||||
|
||||
if (identifierEquals("OPTIONALLY")) {
|
||||
if (lexer.identifierEquals("OPTIONALLY")) {
|
||||
lexer.nextToken();
|
||||
outFile.setColumnsEnclosedOptionally(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("ENCLOSED")) {
|
||||
if (lexer.identifierEquals("ENCLOSED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setColumnsEnclosedBy((SQLLiteralExpr) expr());
|
||||
}
|
||||
|
||||
if (identifierEquals("ESCAPED")) {
|
||||
if (lexer.identifierEquals("ESCAPED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setColumnsEscaped((SQLLiteralExpr) expr());
|
||||
}
|
||||
}
|
||||
|
||||
if (identifierEquals("LINES")) {
|
||||
if (lexer.identifierEquals("LINES")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("STARTING")) {
|
||||
if (lexer.identifierEquals("STARTING")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setLinesStartingBy((SQLLiteralExpr) expr());
|
||||
} else {
|
||||
identifierEquals("TERMINATED");
|
||||
lexer.identifierEquals("TERMINATED");
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setLinesTerminatedBy((SQLLiteralExpr) expr());
|
||||
@@ -395,14 +397,14 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (identifierEquals("IGNORE")) {
|
||||
if (lexer.identifierEquals("IGNORE")) {
|
||||
lexer.nextToken();
|
||||
MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (identifierEquals("FORCE")) {
|
||||
if (lexer.identifierEquals("FORCE")) {
|
||||
lexer.nextToken();
|
||||
MySqlForceIndexHint hint = new MySqlForceIndexHint();
|
||||
parseIndexHint(hint);
|
||||
@@ -420,7 +422,7 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
}
|
||||
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
|
||||
if (identifierEquals("USING")) {
|
||||
if (lexer.identifierEquals(FNVUtils.USING)) {
|
||||
return tableSource;
|
||||
}
|
||||
|
||||
@@ -431,14 +433,14 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (identifierEquals("IGNORE")) {
|
||||
if (lexer.identifierEquals(FNVUtils.IGNORE)) {
|
||||
lexer.nextToken();
|
||||
MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (identifierEquals("FORCE")) {
|
||||
if (lexer.identifierEquals(FNVUtils.FORCE)) {
|
||||
lexer.nextToken();
|
||||
MySqlForceIndexHint hint = new MySqlForceIndexHint();
|
||||
parseIndexHint(hint);
|
||||
|
||||
@@ -149,12 +149,12 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
this.getExprParser().parseHints(deleteStatement.getHints());
|
||||
}
|
||||
|
||||
if (identifierEquals(LOW_PRIORITY)) {
|
||||
if (lexer.identifierEquals(LOW_PRIORITY)) {
|
||||
deleteStatement.setLowPriority(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (identifierEquals("QUICK")) {
|
||||
if (lexer.identifierEquals("QUICK")) {
|
||||
deleteStatement.setQuick(true);
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
@@ -124,11 +124,12 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(' ');
|
||||
}
|
||||
|
||||
if (SQLSetQuantifier.ALL == x.getDistionOption()) {
|
||||
final int distionOption = x.getDistionOption();
|
||||
if (SQLSetQuantifier.ALL == distionOption) {
|
||||
print0(ucase ? "ALL " : "all ");
|
||||
} else if (SQLSetQuantifier.DISTINCT == x.getDistionOption()) {
|
||||
} else if (SQLSetQuantifier.DISTINCT == distionOption) {
|
||||
print0(ucase ? "DISTINCT " : "distinct ");
|
||||
} else if (SQLSetQuantifier.DISTINCTROW == x.getDistionOption()) {
|
||||
} else if (SQLSetQuantifier.DISTINCTROW == distionOption) {
|
||||
print0(ucase ? "DISTINCTROW " : "distinctrow ");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user