improved mysql parser. bug fixed for issue #2263

This commit is contained in:
wenshao
2018-01-22 22:58:33 +08:00
parent 752546f2a0
commit b7214015a2
4 changed files with 56 additions and 0 deletions
@@ -25,6 +25,7 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLAlterTableDiscardPartition extends SQLObjectImpl implements SQLAlterTableItem {
private final List<SQLName> partitions = new ArrayList<SQLName>(4);
private boolean tablespace;
public List<SQLName> getPartitions() {
return partitions;
@@ -44,4 +45,12 @@ public class SQLAlterTableDiscardPartition extends SQLObjectImpl implements SQLA
}
visitor.endVisit(this);
}
public boolean isTablespace() {
return tablespace;
}
public void setTablespace(boolean tablespace) {
this.tablespace = tablespace;
}
}
@@ -3712,6 +3712,11 @@ public class MySqlStatementParser extends SQLStatementParser {
this.exprParser.names(item.getPartitions(), item);
}
if (lexer.token() == Token.TABLESPACE) {
lexer.nextToken();
item.setTablespace(true);
}
stmt.addItem(item);
} else {
accept(Token.TABLESPACE);
@@ -5188,6 +5188,11 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
public boolean visit(SQLAlterTableDiscardPartition x) {
print0(ucase ? "DISCARD PARTITION " : "discard partition ");
printPartitions(x.getPartitions());
if (x.isTablespace()) {
print0(ucase ? " TABLESPACE" : " tablespace");
}
return false;
}