mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
sql parser support mysql 5.7 & oceanbase 1.0
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user