improved sql parser.

This commit is contained in:
wenshao
2017-06-29 15:19:57 +08:00
parent 2f6e406e33
commit bdbc39ec3c
39 changed files with 963 additions and 185 deletions
@@ -23,6 +23,8 @@ public class SQLSubPartition extends SQLObjectImpl {
protected SQLPartitionValue values;
private SQLName tableSpace;
public SQLName getName() {
return name;
}
@@ -45,10 +47,22 @@ public class SQLSubPartition extends SQLObjectImpl {
this.values = values;
}
public SQLName getTableSpace() {
return tableSpace;
}
public void setTableSpace(SQLName tableSpace) {
if (tableSpace != null) {
tableSpace.setParent(this);
}
this.tableSpace = tableSpace;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
acceptChild(visitor, tableSpace);
acceptChild(visitor, values);
}
visitor.endVisit(this);
@@ -22,9 +22,9 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
private String name;
protected String name;
private transient String lowerName;
private transient String lowerName;
private transient Boolean parameter;
public SQLIdentifierExpr(){
@@ -132,4 +132,8 @@ public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
public SQLIdentifierExpr clone() {
return new SQLIdentifierExpr(this.name);
}
public String normalizedName() {
return SQLUtils.normalize(name);
}
}
@@ -15,6 +15,7 @@
*/
package com.alibaba.druid.sql.ast.expr;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLExprImpl;
import com.alibaba.druid.sql.ast.SQLName;
@@ -138,4 +139,18 @@ public class SQLPropertyExpr extends SQLExprImpl implements SQLName {
return false;
}
public String normalizedName() {
String ownerName;
if (owner instanceof SQLIdentifierExpr) {
ownerName = ((SQLIdentifierExpr) owner).normalizedName();
} else if (owner instanceof SQLPropertyExpr) {
ownerName = ((SQLPropertyExpr) owner).normalizedName();
} else {
ownerName = owner.toString();
}
return ownerName + '.' + SQLUtils.normalize(name);
}
}