mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug for mysql parser
This commit is contained in:
@@ -26,7 +26,7 @@ public class SQLDropTableStatement extends SQLStatementImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<SQLName> tableNames = new ArrayList<SQLName>();
|
||||
protected List<SQLName> tableNames = new ArrayList<SQLName>();
|
||||
|
||||
public SQLDropTableStatement(){
|
||||
|
||||
@@ -48,7 +48,6 @@ public class SQLDropTableStatement extends SQLStatementImpl {
|
||||
tableNames.add(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDropTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class MySqlDropTableStatement extends SQLDropTableStatement implements MySqlStatement {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private boolean ifExists = false;
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor instanceof MySqlASTVisitor) {
|
||||
accept0((MySqlASTVisitor) visitor);
|
||||
} else {
|
||||
throw new IllegalArgumentException("not support visitor type : " + visitor.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
this.acceptChild(visitor, tableNames);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public boolean isIfExists() {
|
||||
return ifExists;
|
||||
}
|
||||
|
||||
public void setIfExists(boolean ifExists) {
|
||||
this.ifExists = ifExists;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject;
|
||||
|
||||
public interface MySqlStatement extends SQLStatement, MySqlObject {
|
||||
|
||||
}
|
||||
+1
-1
@@ -19,7 +19,7 @@ import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public abstract class MySqlStatementImpl extends SQLStatementImpl {
|
||||
public abstract class MySqlStatementImpl extends SQLStatementImpl implements MySqlStatement {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ public class MySqlLexer extends Lexer {
|
||||
map.put("ANY", Token.ANY);
|
||||
map.put("TRUNCATE", Token.TRUNCATE);
|
||||
map.put("USER", Token.USER);
|
||||
map.put("IF", Token.IF);
|
||||
|
||||
map.put("TRUE", Token.TRUE);
|
||||
map.put("FALSE", Token.FALSE);
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDropTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
|
||||
@@ -36,6 +37,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlBinlogStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateUserStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropUser;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlExecuteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
|
||||
@@ -986,4 +988,30 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
protected SQLDropTableStatement parseDropTable(boolean acceptDrop) {
|
||||
if (acceptDrop) {
|
||||
accept(Token.DROP);
|
||||
}
|
||||
accept(Token.TABLE);
|
||||
|
||||
MySqlDropTableStatement stmt = new MySqlDropTableStatement();
|
||||
|
||||
if (lexer.token() == Token.IF) {
|
||||
lexer.nextToken();
|
||||
accept(Token.EXISTS);
|
||||
stmt.setIfExists(true);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
SQLName name = this.exprParser.name();
|
||||
stmt.getTableNames().add(name);
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlBinlogStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateUserStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropUser;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlExecuteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
|
||||
@@ -50,131 +51,135 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
|
||||
boolean visit(MySqlBooleanExpr x);
|
||||
boolean visit(MySqlBooleanExpr x);
|
||||
|
||||
void endVisit(MySqlBooleanExpr x);
|
||||
void endVisit(MySqlBooleanExpr x);
|
||||
|
||||
boolean visit(MySqlSelectQueryBlock.Limit x);
|
||||
boolean visit(MySqlSelectQueryBlock.Limit x);
|
||||
|
||||
void endVisit(MySqlSelectQueryBlock.Limit x);
|
||||
void endVisit(MySqlSelectQueryBlock.Limit x);
|
||||
|
||||
boolean visit(MySqlTableIndex x);
|
||||
boolean visit(MySqlTableIndex x);
|
||||
|
||||
void endVisit(MySqlTableIndex x);
|
||||
void endVisit(MySqlTableIndex x);
|
||||
|
||||
boolean visit(MySqlKey x);
|
||||
boolean visit(MySqlKey x);
|
||||
|
||||
void endVisit(MySqlKey x);
|
||||
void endVisit(MySqlKey x);
|
||||
|
||||
boolean visit(MySqlPrimaryKey x);
|
||||
boolean visit(MySqlPrimaryKey x);
|
||||
|
||||
void endVisit(MySqlPrimaryKey x);
|
||||
void endVisit(MySqlPrimaryKey x);
|
||||
|
||||
void endVisit(MySqlIntervalExpr x);
|
||||
void endVisit(MySqlIntervalExpr x);
|
||||
|
||||
boolean visit(MySqlIntervalExpr x);
|
||||
boolean visit(MySqlIntervalExpr x);
|
||||
|
||||
void endVisit(MySqlExtractExpr x);
|
||||
void endVisit(MySqlExtractExpr x);
|
||||
|
||||
boolean visit(MySqlExtractExpr x);
|
||||
boolean visit(MySqlExtractExpr x);
|
||||
|
||||
void endVisit(MySqlMatchAgainstExpr x);
|
||||
void endVisit(MySqlMatchAgainstExpr x);
|
||||
|
||||
boolean visit(MySqlMatchAgainstExpr x);
|
||||
boolean visit(MySqlMatchAgainstExpr x);
|
||||
|
||||
void endVisit(MySqlBinaryExpr x);
|
||||
void endVisit(MySqlBinaryExpr x);
|
||||
|
||||
boolean visit(MySqlBinaryExpr x);
|
||||
boolean visit(MySqlBinaryExpr x);
|
||||
|
||||
void endVisit(MySqlPrepareStatement x);
|
||||
void endVisit(MySqlPrepareStatement x);
|
||||
|
||||
boolean visit(MySqlPrepareStatement x);
|
||||
boolean visit(MySqlPrepareStatement x);
|
||||
|
||||
void endVisit(MySqlExecuteStatement x);
|
||||
void endVisit(MySqlExecuteStatement x);
|
||||
|
||||
boolean visit(MySqlExecuteStatement x);
|
||||
boolean visit(MySqlExecuteStatement x);
|
||||
|
||||
void endVisit(MySqlDeleteStatement x);
|
||||
void endVisit(MySqlDeleteStatement x);
|
||||
|
||||
boolean visit(MySqlDeleteStatement x);
|
||||
boolean visit(MySqlDeleteStatement x);
|
||||
|
||||
void endVisit(MySqlInsertStatement x);
|
||||
void endVisit(MySqlInsertStatement x);
|
||||
|
||||
boolean visit(MySqlInsertStatement x);
|
||||
boolean visit(MySqlInsertStatement x);
|
||||
|
||||
void endVisit(MySqlLoadDataInFileStatement x);
|
||||
void endVisit(MySqlLoadDataInFileStatement x);
|
||||
|
||||
boolean visit(MySqlLoadDataInFileStatement x);
|
||||
boolean visit(MySqlLoadDataInFileStatement x);
|
||||
|
||||
void endVisit(MySqlLoadXmlStatement x);
|
||||
void endVisit(MySqlLoadXmlStatement x);
|
||||
|
||||
boolean visit(MySqlLoadXmlStatement x);
|
||||
boolean visit(MySqlLoadXmlStatement x);
|
||||
|
||||
void endVisit(MySqlReplicateStatement x);
|
||||
void endVisit(MySqlReplicateStatement x);
|
||||
|
||||
boolean visit(MySqlReplicateStatement x);
|
||||
boolean visit(MySqlReplicateStatement x);
|
||||
|
||||
void endVisit(MySqlSelectGroupBy x);
|
||||
void endVisit(MySqlSelectGroupBy x);
|
||||
|
||||
boolean visit(MySqlSelectGroupBy x);
|
||||
boolean visit(MySqlSelectGroupBy x);
|
||||
|
||||
void endVisit(MySqlStartTransactionStatement x);
|
||||
void endVisit(MySqlStartTransactionStatement x);
|
||||
|
||||
boolean visit(MySqlStartTransactionStatement x);
|
||||
boolean visit(MySqlStartTransactionStatement x);
|
||||
|
||||
void endVisit(MySqlCommitStatement x);
|
||||
void endVisit(MySqlCommitStatement x);
|
||||
|
||||
boolean visit(MySqlCommitStatement x);
|
||||
boolean visit(MySqlCommitStatement x);
|
||||
|
||||
void endVisit(MySqlRollbackStatement x);
|
||||
void endVisit(MySqlRollbackStatement x);
|
||||
|
||||
boolean visit(MySqlRollbackStatement x);
|
||||
boolean visit(MySqlRollbackStatement x);
|
||||
|
||||
void endVisit(MySqlShowColumnsStatement x);
|
||||
void endVisit(MySqlShowColumnsStatement x);
|
||||
|
||||
boolean visit(MySqlShowColumnsStatement x);
|
||||
boolean visit(MySqlShowColumnsStatement x);
|
||||
|
||||
void endVisit(MySqlShowTablesStatement x);
|
||||
void endVisit(MySqlShowTablesStatement x);
|
||||
|
||||
boolean visit(MySqlShowTablesStatement x);
|
||||
boolean visit(MySqlShowTablesStatement x);
|
||||
|
||||
void endVisit(MySqlShowDatabasesStatement x);
|
||||
void endVisit(MySqlShowDatabasesStatement x);
|
||||
|
||||
boolean visit(MySqlShowDatabasesStatement x);
|
||||
boolean visit(MySqlShowDatabasesStatement x);
|
||||
|
||||
void endVisit(MySqlShowWarningsStatement x);
|
||||
void endVisit(MySqlShowWarningsStatement x);
|
||||
|
||||
boolean visit(MySqlShowWarningsStatement x);
|
||||
boolean visit(MySqlShowWarningsStatement x);
|
||||
|
||||
void endVisit(MySqlShowStatusStatement x);
|
||||
void endVisit(MySqlShowStatusStatement x);
|
||||
|
||||
boolean visit(MySqlShowStatusStatement x);
|
||||
boolean visit(MySqlShowStatusStatement x);
|
||||
|
||||
void endVisit(CobarShowStatus x);
|
||||
void endVisit(CobarShowStatus x);
|
||||
|
||||
boolean visit(CobarShowStatus x);
|
||||
boolean visit(CobarShowStatus x);
|
||||
|
||||
void endVisit(MySqlKillStatement x);
|
||||
void endVisit(MySqlKillStatement x);
|
||||
|
||||
boolean visit(MySqlKillStatement x);
|
||||
boolean visit(MySqlKillStatement x);
|
||||
|
||||
void endVisit(MySqlBinlogStatement x);
|
||||
void endVisit(MySqlBinlogStatement x);
|
||||
|
||||
boolean visit(MySqlBinlogStatement x);
|
||||
|
||||
void endVisit(MySqlResetStatement x);
|
||||
|
||||
boolean visit(MySqlResetStatement x);
|
||||
|
||||
void endVisit(MySqlDropUser x);
|
||||
|
||||
boolean visit(MySqlDropUser x);
|
||||
|
||||
void endVisit(MySqlCreateUserStatement x);
|
||||
|
||||
boolean visit(MySqlCreateUserStatement x);
|
||||
|
||||
void endVisit(MySqlCreateUserStatement.UserSpecification x);
|
||||
|
||||
boolean visit(MySqlCreateUserStatement.UserSpecification x);
|
||||
boolean visit(MySqlBinlogStatement x);
|
||||
|
||||
void endVisit(MySqlResetStatement x);
|
||||
|
||||
boolean visit(MySqlResetStatement x);
|
||||
|
||||
void endVisit(MySqlDropUser x);
|
||||
|
||||
boolean visit(MySqlDropUser x);
|
||||
|
||||
void endVisit(MySqlCreateUserStatement x);
|
||||
|
||||
boolean visit(MySqlCreateUserStatement x);
|
||||
|
||||
void endVisit(MySqlCreateUserStatement.UserSpecification x);
|
||||
|
||||
boolean visit(MySqlCreateUserStatement.UserSpecification x);
|
||||
|
||||
void endVisit(MySqlDropTableStatement x);
|
||||
|
||||
boolean visit(MySqlDropTableStatement x);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateUserStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateUserStatement.UserSpecification;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropUser;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlExecuteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
|
||||
@@ -377,5 +378,15 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements
|
||||
public boolean visit(MySqlDropUser x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlDropTableStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlDropTableStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateUserStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropUser;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlExecuteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
|
||||
@@ -1307,4 +1308,20 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
printAndAccept(x.getUsers(), ", ");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlDropTableStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlDropTableStatement x) {
|
||||
print("DROP TABLE ");
|
||||
if (x.isIfExists()) {
|
||||
print("IF EXISTS ");
|
||||
}
|
||||
|
||||
printAndAccept(x.getTableNames(), ", ");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Map;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDropTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlPrimaryKey;
|
||||
@@ -18,6 +19,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCommitStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateUserStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateUserStatement.UserSpecification;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDropUser;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlExecuteStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
|
||||
@@ -433,4 +435,12 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
public boolean visit(MySqlDropUser x) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void endVisit(MySqlDropTableStatement x) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean visit(MySqlDropTableStatement x) {
|
||||
return visit((SQLDropTableStatement) x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,8 +115,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
SQLDataType dataType = new SQLDataTypeImpl(typeName);
|
||||
parseDataTypeRest(dataType);
|
||||
return dataType;
|
||||
return parseDataTypeRest(dataType);
|
||||
}
|
||||
|
||||
public boolean isAggreateFunction(String word) {
|
||||
|
||||
@@ -1056,50 +1056,53 @@ public class SQLExprParser extends SQLParser {
|
||||
String typeName = typeExpr.toString();
|
||||
|
||||
SQLDataType dataType = new SQLDataTypeImpl(typeName);
|
||||
parseDataTypeRest(dataType);
|
||||
return dataType;
|
||||
return parseDataTypeRest(dataType);
|
||||
}
|
||||
|
||||
protected void parseDataTypeRest(SQLDataType dataType) {
|
||||
protected SQLDataType parseDataTypeRest(SQLDataType dataType) {
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
exprList(dataType.getArguments());
|
||||
accept(Token.RPAREN);
|
||||
|
||||
return parseCharTypeRest(dataType);
|
||||
}
|
||||
|
||||
return dataType;
|
||||
}
|
||||
|
||||
protected SQLDataType parseCharType() throws ParserException {
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
protected boolean isCharType(SQLDataType dataType) {
|
||||
String dataTypeName = dataType.getName();
|
||||
|
||||
return "char".equalsIgnoreCase(dataTypeName) //
|
||||
|| "varchar".equalsIgnoreCase(dataTypeName)
|
||||
|| "nchar".equalsIgnoreCase(dataTypeName)
|
||||
|| "nvarchar".equalsIgnoreCase(dataTypeName)
|
||||
//
|
||||
;
|
||||
}
|
||||
|
||||
protected SQLDataType parseCharTypeRest(SQLDataType dataType) {
|
||||
if (!isCharType(dataType)) {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
String typeName = lexer.stringVal();
|
||||
SQLCharactorDataType charType = new SQLCharactorDataType(dataType.getName());
|
||||
charType.getArguments().addAll(dataType.getArguments());
|
||||
|
||||
lexer.nextToken();
|
||||
SQLCharactorDataType dataType = new SQLCharactorDataType(typeName);
|
||||
if (lexer.token() == (Token.LPAREN)) {
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException("syntax error " + lexer.token() + " " + lexer.stringVal());
|
||||
}
|
||||
|
||||
if (identifierEquals("CHARACTER")) {
|
||||
lexer.nextToken();
|
||||
exprList(dataType.getArguments());
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
|
||||
if (lexer.stringVal().equalsIgnoreCase("CHARACTER")) {
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
|
||||
if (!lexer.stringVal().equalsIgnoreCase("SET")) {
|
||||
throw new ParserException();
|
||||
}
|
||||
accept(Token.SET);
|
||||
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
dataType.setCharSetName(lexer.stringVal());
|
||||
charType.setCharSetName(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
@@ -1109,12 +1112,12 @@ public class SQLExprParser extends SQLParser {
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
dataType.setCollate(lexer.stringVal());
|
||||
charType.setCollate(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
return dataType;
|
||||
return charType;
|
||||
}
|
||||
|
||||
public void accept(Token token) {
|
||||
|
||||
Reference in New Issue
Block a user