sql parser support mysql 5.7 & oceanbase 1.0

This commit is contained in:
高铁
2016-02-29 23:12:13 +08:00
parent bebef5ea9e
commit 0ee24a11d4
44 changed files with 2675 additions and 957 deletions
@@ -29,6 +29,7 @@ import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.druid.sql.ast.SQLOrderBy;
import com.alibaba.druid.sql.ast.SQLOrderingSpecification;
import com.alibaba.druid.sql.ast.SQLOver;
import com.alibaba.druid.sql.ast.SQLPartitionValue;
import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr;
import com.alibaba.druid.sql.ast.expr.SQLAggregateOption;
import com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr;
@@ -185,6 +186,12 @@ public class SQLExprParser extends SQLParser {
}
return expr;
}
public SQLIntegerExpr integerExpr() {
SQLIntegerExpr intExpr = new SQLIntegerExpr(lexer.integerValue());
accept(Token.LITERAL_INT);
return intExpr;
}
public SQLExpr primary() {
List<String> beforeComments = null;
@@ -1902,4 +1909,45 @@ public class SQLExprParser extends SQLParser {
return expr;
}
public SQLPartitionValue parsePartitionValues() {
if (lexer.token() != Token.VALUES) {
return null;
}
lexer.nextToken();
SQLPartitionValue values = null;
if (lexer.token() == Token.IN) {
lexer.nextToken();
values = new SQLPartitionValue(SQLPartitionValue.Operator.In);
accept(Token.LPAREN);
this.exprList(values.getItems(), values);
accept(Token.RPAREN);
} else if (identifierEquals("LESS")) {
lexer.nextToken();
acceptIdentifier("THAN");
values = new SQLPartitionValue(SQLPartitionValue.Operator.LessThan);
if (identifierEquals("MAXVALUE")) {
SQLIdentifierExpr maxValue = new SQLIdentifierExpr(lexer.stringVal());
lexer.nextToken();
maxValue.setParent(values);
values.addItem(maxValue);
} else {
accept(Token.LPAREN);
this.exprList(values.getItems(), values);
accept(Token.RPAREN);
}
} else if (lexer.token() == Token.LPAREN) {
values = new SQLPartitionValue(SQLPartitionValue.Operator.List);
lexer.nextToken();
this.exprList(values.getItems(), values);
accept(Token.RPAREN);
}
return values;
}
}