版本号
1.2.6
问题
SQL解析失败
复现代码
SQLUtils.parseSingleStatement("CREATE SEQUENCE table_name_id_seq as integer", DbType.postgresql) -- error
SQLUtils.parseSingleStatement("CREATE SEQUENCE table_name_id_seq ", DbType.postgresql) -- ok
定位问题
- 源文件:
com.alibaba.druid.sql.parser.SQLStatementParser#parseCreateSequence
- 待修复代码片段
for (;;) {
if (lexer.token() == Token.START || lexer.identifierEquals(FnvHash.Constants.START)) {
lexer.nextToken();
accept(Token.WITH);
stmt.setStartWith(this.exprParser.expr());
continue;
} else if (lexer.identifierEquals(FnvHash.Constants.INCREMENT)) {
lexer.nextToken();
accept(Token.BY);
stmt.setIncrementBy(this.exprParser.expr());
continue;
} else if (lexer.token() == Token.CACHE || lexer.identifierEquals(FnvHash.Constants.CACHE)) {
lexer.nextToken();
stmt.setCache(Boolean.TRUE);
if (lexer.token() == Token.LITERAL_INT) {
stmt.setCacheValue(this.exprParser.primary());
}
continue;
} else if (lexer.token == Token.WITH) {
lexer.nextToken();
accept(Token.CACHE);
stmt.setCache(true);
continue;
} else if (lexer.token() == Token.NOCACHE || lexer.identifierEquals(FnvHash.Constants.NOCACHE)) {
lexer.nextToken();
stmt.setCache(Boolean.FALSE);
continue;
} else if (lexer.token() == Token.ORDER) {
lexer.nextToken();
stmt.setOrder(Boolean.TRUE);
continue;
} else if (lexer.identifierEquals("NOORDER")) {
lexer.nextToken();
stmt.setOrder(Boolean.FALSE);
continue;
} else if (lexer.identifierEquals("CYCLE")) {
lexer.nextToken();
stmt.setCycle(Boolean.TRUE);
continue;
} else if (lexer.identifierEquals(FnvHash.Constants.NOCYCLE)) {
lexer.nextToken();
stmt.setCycle(Boolean.FALSE);
continue;
} else if (lexer.identifierEquals("MINVALUE")) {
lexer.nextToken();
stmt.setMinValue(this.exprParser.expr());
continue;
} else if (lexer.identifierEquals("MAXVALUE")) {
lexer.nextToken();
stmt.setMaxValue(this.exprParser.expr());
continue;
} else if (lexer.identifierEquals("NOMAXVALUE")) {
lexer.nextToken();
stmt.setNoMaxValue(true);
continue;
} else if (lexer.identifierEquals("NOMINVALUE")) {
lexer.nextToken();
stmt.setNoMinValue(true);
continue;
}
// fixme 需要考虑AS token的情况
break;
}
1条答案
按热度按时间rdrgkggo1#
up!