mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for oracle sql parser
This commit is contained in:
@@ -70,6 +70,7 @@ public class CharTypes {
|
||||
// identifierFlags['`'] = true;
|
||||
identifierFlags['_'] = true;
|
||||
identifierFlags['$'] = true;
|
||||
identifierFlags['#'] = true;
|
||||
}
|
||||
|
||||
public static boolean isIdentifierChar(char c) {
|
||||
|
||||
@@ -252,7 +252,13 @@ public class Lexer {
|
||||
scanChar();
|
||||
token = COLONEQ;
|
||||
} else {
|
||||
token = COLON;
|
||||
if (isDigit(ch)) {
|
||||
unscan();
|
||||
scanVariable();
|
||||
} else {
|
||||
unscan();
|
||||
scanVariable();
|
||||
}
|
||||
}
|
||||
return;
|
||||
case '.':
|
||||
|
||||
@@ -552,7 +552,7 @@ public class SQLExprParser extends SQLParser {
|
||||
}
|
||||
}
|
||||
|
||||
public final SQLName name() throws ParserException {
|
||||
public SQLName name() throws ParserException {
|
||||
String identName;
|
||||
if (lexer.token() == Token.LITERAL_ALIAS) {
|
||||
identName = '"' + lexer.stringVal() + '"';
|
||||
@@ -570,8 +570,8 @@ public class SQLExprParser extends SQLParser {
|
||||
if (lexer.token() == Token.DOT) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException("error");
|
||||
if (lexer.token() != Token.LITERAL_ALIAS && lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException("error, " + lexer.token());
|
||||
}
|
||||
|
||||
name = new SQLPropertyExpr(name, lexer.stringVal());
|
||||
|
||||
@@ -114,7 +114,7 @@ public class SQLParser {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
setErrorEndPos(lexer.pos());
|
||||
throw new SQLParseException("syntax error, expect " + token + ", actual " + lexer.token());
|
||||
throw new SQLParseException("syntax error, expect " + token + ", actual " + lexer.token() + " " + lexer.stringVal());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.alibaba.druid.sql.ast.statement.SQLUpdateStatement;
|
||||
|
||||
public class SQLStatementParser extends SQLParser {
|
||||
|
||||
protected final SQLExprParser exprParser;
|
||||
protected SQLExprParser exprParser;
|
||||
|
||||
public SQLStatementParser(String sql){
|
||||
super(sql);
|
||||
@@ -173,12 +173,18 @@ public class SQLStatementParser extends SQLParser {
|
||||
parseInsert0(insertStatement, true);
|
||||
}
|
||||
|
||||
protected void parseInsert0_hinits(SQLInsertInto insertStatement) {
|
||||
|
||||
}
|
||||
|
||||
protected void parseInsert0(SQLInsertInto insertStatement, boolean acceptSubQuery) {
|
||||
accept(Token.INTO);
|
||||
|
||||
SQLName tableName = this.exprParser.name();
|
||||
insertStatement.setTableName(tableName);
|
||||
|
||||
|
||||
parseInsert0_hinits(insertStatement);
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
insertStatement.setAlias(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -151,6 +151,10 @@ public enum Token {
|
||||
ERRORS("ERRORS"),
|
||||
REJECT("REJECT"),
|
||||
UNLIMITED("UNLIMITED"),
|
||||
BEGIN("BEGIN"),
|
||||
EXCLUSIVE("EXCLUSIVE"),
|
||||
MODE("MODE"),
|
||||
WAIT("WAIT"),
|
||||
|
||||
// transact-sql
|
||||
TOP("TOP"),
|
||||
|
||||
Reference in New Issue
Block a user