mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved mysql parser add_index support. for issue #1645
This commit is contained in:
@@ -2126,6 +2126,16 @@ public class SQLStatementParser extends SQLParser {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
item.setName(this.exprParser.name());
|
||||
|
||||
if (JdbcConstants.MYSQL.equals(dbType)) {
|
||||
if (identifierEquals("USING")) {
|
||||
lexer.nextToken();
|
||||
String indexType = lexer.stringVal;
|
||||
item.setType(indexType);
|
||||
accept(Token.IDENTIFIER);
|
||||
}
|
||||
}
|
||||
|
||||
accept(Token.LPAREN);
|
||||
}
|
||||
|
||||
|
||||
@@ -2799,8 +2799,12 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
@Override
|
||||
public boolean visit(SQLAlterTableAddIndex x) {
|
||||
print0(ucase ? "ADD " : "add ");
|
||||
if (x.getType() != null) {
|
||||
print0(x.getType());
|
||||
String type = x.getType();
|
||||
|
||||
boolean mysql = JdbcConstants.MYSQL.equals(dbType);
|
||||
|
||||
if (type != null && !mysql) {
|
||||
print0(type);
|
||||
print(' ');
|
||||
}
|
||||
|
||||
@@ -2818,6 +2822,13 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
x.getName().accept(this);
|
||||
print(' ');
|
||||
}
|
||||
|
||||
if (type != null && mysql) {
|
||||
print0(ucase ? "USING " : "using ");
|
||||
print0(type);
|
||||
print(' ');
|
||||
}
|
||||
|
||||
print('(');
|
||||
printAndAccept(x.getItems(), ", ");
|
||||
print(')');
|
||||
|
||||
Reference in New Issue
Block a user