improved sql parser.

This commit is contained in:
wenshao
2017-08-03 10:41:23 +08:00
parent 9df6894d83
commit b0c38aef68
70 changed files with 1091 additions and 109 deletions
@@ -27,4 +27,9 @@ public class MySqlForceIndexHint extends MySqlIndexHintImpl {
visitor.endVisit(this);
}
public MySqlForceIndexHint clone() {
MySqlForceIndexHint x = new MySqlForceIndexHint();
cloneTo(x);
return x;
}
}
@@ -27,4 +27,9 @@ public class MySqlIgnoreIndexHint extends MySqlIndexHintImpl {
visitor.endVisit(this);
}
public MySqlIgnoreIndexHint clone() {
MySqlIgnoreIndexHint x = new MySqlIgnoreIndexHint();
cloneTo(x);
return x;
}
}
@@ -46,4 +46,14 @@ public abstract class MySqlIndexHintImpl extends MySqlObjectImpl implements MySq
this.indexList = indexList;
}
public abstract MySqlIndexHintImpl clone();
public void cloneTo(MySqlIndexHintImpl x) {
x.option = option;
for (SQLName name : indexList) {
SQLName name2 = name.clone();
name2.setParent(x);
x.indexList.add(name2);
}
}
}
@@ -27,4 +27,9 @@ public class MySqlUseIndexHint extends MySqlIndexHintImpl {
visitor.endVisit(this);
}
public MySqlUseIndexHint clone() {
MySqlUseIndexHint x = new MySqlUseIndexHint();
cloneTo(x);
return x;
}
}
@@ -34,6 +34,21 @@ public class MySqlInsertStatement extends SQLInsertStatement {
private final List<SQLExpr> duplicateKeyUpdate = new ArrayList<SQLExpr>();
public void cloneTo(MySqlInsertStatement x) {
super.cloneTo(x);
x.lowPriority = lowPriority;
x.delayed = delayed;
x.highPriority = highPriority;
x.ignore = ignore;
x.rollbackOnFail = rollbackOnFail;
for (SQLExpr e : duplicateKeyUpdate) {
SQLExpr e2 = e.clone();
e2.setParent(x);
x.duplicateKeyUpdate.add(e2);
}
}
public List<SQLExpr> getDuplicateKeyUpdate() {
return duplicateKeyUpdate;
}
@@ -102,4 +117,10 @@ public class MySqlInsertStatement extends SQLInsertStatement {
visitor.endVisit(this);
}
public SQLInsertStatement clone() {
MySqlInsertStatement x = new MySqlInsertStatement();
cloneTo(x);
return x;
}
}
@@ -69,4 +69,32 @@ public class NameResolveVisitor extends OracleASTVisitorAdapter {
}
return true;
}
public boolean visit(SQLPropertyExpr x) {
String ownerName = x.getOwnernName();
if (ownerName == null) {
return super.visit(x);
}
for (SQLObject parent = x.getParent(); parent != null; parent = parent.getParent()) {
if (parent instanceof SQLSelectQueryBlock) {
SQLSelectQueryBlock queryBlock = (SQLSelectQueryBlock) parent;
SQLTableSource tableSource = queryBlock.findTableSource(ownerName);
if (tableSource == null) {
continue;
}
String alias = tableSource.getAlias();
if (tableSource != null
&& ownerName.equalsIgnoreCase(alias)
&& !ownerName.equals(alias)) {
x.setOwner(alias);
}
break;
}
}
return super.visit(x);
}
}