mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved mysql parser.
This commit is contained in:
@@ -3449,7 +3449,9 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
if (lexer.token() == Token.COLUMN) {
|
||||
lexer.nextToken();
|
||||
parseAlterTableAddColumn(stmt);
|
||||
} else if (lexer.token() == Token.INDEX || lexer.identifierEquals("FULLTEXT")) {
|
||||
} else if (lexer.token() == Token.INDEX
|
||||
|| lexer.identifierEquals(FnvHash.Constants.FULLTEXT)
|
||||
|| lexer.identifierEquals(FnvHash.Constants.SPATIAL)) {
|
||||
SQLAlterTableAddIndex item = parseAlterTableAddIndex();
|
||||
item.setParent(stmt);
|
||||
stmt.addItem(item);
|
||||
@@ -3539,10 +3541,6 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
stmt.addItem(item);
|
||||
} else if (lexer.identifierEquals(FULLTEXT)) {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
} else if (lexer.identifierEquals(SPATIAL)) {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
} else {
|
||||
parseAlterTableAddColumn(stmt);
|
||||
}
|
||||
|
||||
@@ -2755,9 +2755,12 @@ public class SQLStatementParser extends SQLParser {
|
||||
protected SQLAlterTableAddIndex parseAlterTableAddIndex() {
|
||||
SQLAlterTableAddIndex item = new SQLAlterTableAddIndex();
|
||||
|
||||
if (lexer.identifierEquals("FULLTEXT")) {
|
||||
if (lexer.identifierEquals(FnvHash.Constants.FULLTEXT)) {
|
||||
lexer.nextToken();
|
||||
item.setType("FULLTEXT");
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.SPATIAL)) {
|
||||
lexer.nextToken();
|
||||
item.setType("SPATIAL");
|
||||
}
|
||||
|
||||
if (lexer.token == Token.UNIQUE) {
|
||||
|
||||
@@ -3811,11 +3811,13 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLUnique x) {
|
||||
if (x.getName() != null) {
|
||||
SQLName name = x.getName();
|
||||
if (name != null) {
|
||||
print0(ucase ? "CONSTRAINT " : "constraint ");
|
||||
x.getName().accept(this);
|
||||
name.accept(this);
|
||||
print(' ');
|
||||
}
|
||||
|
||||
print0(ucase ? "UNIQUE (" : "unique (");
|
||||
printAndAccept(x.getColumns(), ", ");
|
||||
print(')');
|
||||
@@ -3824,9 +3826,10 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLPrimaryKeyImpl x) {
|
||||
if (x.getName() != null) {
|
||||
SQLName name = x.getName();
|
||||
if (name != null) {
|
||||
print0(ucase ? "CONSTRAINT " : "constraint ");
|
||||
x.getName().accept(this);
|
||||
name.accept(this);
|
||||
print(' ');
|
||||
}
|
||||
|
||||
@@ -3839,7 +3842,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
print('(');
|
||||
printAndAccept(x.getColumns(), ", ");
|
||||
print(')');
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3854,11 +3857,13 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLColumnReference x) {
|
||||
if (x.getName() != null) {
|
||||
SQLName name = x.getName();
|
||||
if (name != null) {
|
||||
print0(ucase ? "CONSTRAINT " : "constraint ");
|
||||
x.getName().accept(this);
|
||||
name.accept(this);
|
||||
print(' ');
|
||||
}
|
||||
|
||||
print0(ucase ? "REFERENCES " : "references ");
|
||||
x.getTable().accept(this);
|
||||
print0(" (");
|
||||
|
||||
Reference in New Issue
Block a user