improved sql parser.

This commit is contained in:
wenshao
2017-08-31 16:34:15 +08:00
parent 947059f715
commit e0b0cca579
17 changed files with 358 additions and 92 deletions
@@ -132,6 +132,13 @@ public class SQLAlterTableStatement extends SQLStatementImpl implements SQLDDLSt
return (SQLName) getTableSource().getExpr();
}
public long nameHashCode64() {
if (getTableSource() == null) {
return 0L;
}
return ((SQLName) getTableSource().getExpr()).nameHashCode64();
}
public void setName(SQLName name) {
this.setTableSource(new SQLExprTableSource(name));
}
@@ -601,11 +601,13 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
}
public boolean apply(SQLDropIndexStatement x) {
long indexNameHashCode64 = x.getIndexName().nameHashCode64();
for (int i = tableElementList.size() - 1; i >= 0; i--) {
SQLTableElement e = tableElementList.get(i);
if (e instanceof SQLUniqueConstraint) {
SQLUniqueConstraint unique = (SQLUniqueConstraint) e;
if (SQLUtils.nameEquals(unique.getName(), x.getIndexName())) {
if (unique.getName().nameHashCode64() == indexNameHashCode64) {
tableElementList.remove(i);
return true;
}
@@ -643,7 +645,10 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
return false;
}
SQLColumnDefinition column = this.findColumn(propertyExpr.getName());
SQLColumnDefinition column
= this.findColumn(
propertyExpr.nameHashCode64());
if (column != null) {
column.setComment(comment.clone());
}
@@ -74,9 +74,7 @@ public class SQLWithSubqueryClause extends SQLObjectImpl {
protected SQLSelect subQuery;
protected SQLStatement returningStatement;
public Entry clone() {
Entry x = new Entry();
protected void cloneTo(Entry x) {
for (SQLName column : columns) {
SQLName column2 = column.clone();
column2.setParent(x);
@@ -87,6 +85,14 @@ public class SQLWithSubqueryClause extends SQLObjectImpl {
x.setSubQuery(subQuery.clone());
}
if (returningStatement != null) {
setReturningStatement(returningStatement.clone());
}
}
public Entry clone() {
Entry x = new Entry();
cloneTo(x);
return x;
}