improve sql parser for sql server

This commit is contained in:
wenshao
2013-08-05 21:48:47 +08:00
parent a55ea486b9
commit 8bf50f9179
12 changed files with 522 additions and 13 deletions
@@ -96,7 +96,7 @@ public class SQLExprParser extends SQLParser {
lexer.nextToken();
SQLExpr expr = new SQLAllColumnExpr();
if (lexer.token() == Token.DOT) {
lexer.nextToken();
accept(Token.STAR);
@@ -706,7 +706,52 @@ public class SQLExprParser extends SQLParser {
identName = lexer.stringVal();
lexer.nextToken();
} else {
throw new ParserException("error " + lexer.token());
switch (lexer.token()) {
case MODEL:
case PCTFREE:
case INITRANS:
case MAXTRANS:
case SEGMENT:
case CREATION:
case IMMEDIATE:
case DEFERRED:
case STORAGE:
case NEXT:
case MINEXTENTS:
case MAXEXTENTS:
case MAXSIZE:
case PCTINCREASE:
case FLASH_CACHE:
case CELL_FLASH_CACHE:
case KEEP:
case NONE:
case LOB:
case STORE:
case ROW:
case CHUNK:
case CACHE:
case NOCACHE:
case LOGGING:
case NOCOMPRESS:
case KEEP_DUPLICATES:
case EXCEPTIONS:
case PURGE:
case INITIALLY:
case END:
case COMMENT:
case ENABLE:
case DISABLE:
case SEQUENCE:
case USER:
case ANALYZE:
case OPTIMIZE:
case GRANT:
identName = lexer.stringVal();
lexer.nextToken();
break;
default:
throw new ParserException("error " + lexer.token());
}
}
SQLName name = new SQLIdentifierExpr(identName);
@@ -1382,6 +1427,13 @@ public class SQLExprParser extends SQLParser {
column.getConstaints().add(check);
return parseColumnRest(column);
}
if (lexer.token == Token.DEFAULT) {
lexer.nextToken();
SQLExpr expr = this.expr();
column.setDefaultExpr(expr);
return parseColumnRest(column);
}
throw new ParserException("TODO : " + lexer.token() + " " + lexer.stringVal());
}