mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -28,8 +28,15 @@ public class SQLAllExpr extends SQLExprImpl {
|
||||
}
|
||||
|
||||
public SQLAllExpr(SQLSelect select){
|
||||
setSubQuery(select);
|
||||
}
|
||||
|
||||
this.subQuery = select;
|
||||
public SQLAllExpr clone() {
|
||||
SQLAllExpr x = new SQLAllExpr();
|
||||
if (subQuery != null) {
|
||||
x.setSubQuery(subQuery.clone());
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public SQLSelect getSubQuery() {
|
||||
@@ -37,6 +44,9 @@ public class SQLAllExpr extends SQLExprImpl {
|
||||
}
|
||||
|
||||
public void setSubQuery(SQLSelect subQuery) {
|
||||
if (subQuery != null) {
|
||||
subQuery.setParent(this);
|
||||
}
|
||||
this.subQuery = subQuery;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,15 @@ public class SQLAnyExpr extends SQLExprImpl {
|
||||
}
|
||||
|
||||
public SQLAnyExpr(SQLSelect select){
|
||||
setSubQuery(select);
|
||||
}
|
||||
|
||||
this.subQuery = select;
|
||||
public SQLAnyExpr clone() {
|
||||
SQLAnyExpr x = new SQLAnyExpr();
|
||||
if (subQuery != null) {
|
||||
x.setSubQuery(subQuery.clone());
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public SQLSelect getSubQuery() {
|
||||
@@ -42,6 +49,9 @@ public class SQLAnyExpr extends SQLExprImpl {
|
||||
}
|
||||
|
||||
public void setSubQuery(SQLSelect subQuery) {
|
||||
if (subQuery != null) {
|
||||
subQuery.setParent(this);
|
||||
}
|
||||
this.subQuery = subQuery;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,19 @@ public class SQLArrayExpr extends SQLExprImpl {
|
||||
|
||||
private List<SQLExpr> values = new ArrayList<SQLExpr>();
|
||||
|
||||
public SQLArrayExpr clone() {
|
||||
SQLArrayExpr x = new SQLArrayExpr();
|
||||
if (expr != null) {
|
||||
x.setExpr(expr.clone());
|
||||
}
|
||||
for (SQLExpr value : values) {
|
||||
SQLExpr value2 = value.clone();
|
||||
value2.setParent(x);
|
||||
x.values.add(value2);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public SQLExpr getExpr() {
|
||||
return expr;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,21 @@ public class SQLBetweenExpr extends SQLExprImpl implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
public SQLBetweenExpr clone() {
|
||||
SQLBetweenExpr x = new SQLBetweenExpr();
|
||||
if (testExpr != null) {
|
||||
x.setTestExpr(testExpr.clone());
|
||||
}
|
||||
x.not = not;
|
||||
if (beginExpr != null) {
|
||||
x.setBeginExpr(beginExpr.clone());
|
||||
}
|
||||
if (endExpr != null) {
|
||||
x.setEndExpr(endExpr.clone());
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public SQLBetweenExpr(SQLExpr testExpr, SQLExpr beginExpr, SQLExpr endExpr){
|
||||
setTestExpr(testExpr);
|
||||
setBeginExpr(beginExpr);
|
||||
|
||||
@@ -97,4 +97,15 @@ public class SQLCastExpr extends SQLExprImpl {
|
||||
public SQLDataType computeDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public SQLCastExpr clone() {
|
||||
SQLCastExpr x = new SQLCastExpr();
|
||||
if (expr != null) {
|
||||
x.setExpr(expr.clone());
|
||||
}
|
||||
if (dataType != null) {
|
||||
x.setDataType(dataType.clone());
|
||||
}
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,22 @@ public class SQLCurrentOfCursorExpr extends SQLExprImpl {
|
||||
this.cursorName = cursorName;
|
||||
}
|
||||
|
||||
public SQLCurrentOfCursorExpr clone() {
|
||||
SQLCurrentOfCursorExpr x = new SQLCurrentOfCursorExpr();
|
||||
if (cursorName != null) {
|
||||
x.setCursorName(cursorName.clone());
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public SQLName getCursorName() {
|
||||
return cursorName;
|
||||
}
|
||||
|
||||
public void setCursorName(SQLName cursorName) {
|
||||
if (cursorName != null) {
|
||||
cursorName.setParent(this);
|
||||
}
|
||||
this.cursorName = cursorName;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,23 @@ import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExplainStatement;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLGroupingSetExpr extends SQLExprImpl {
|
||||
|
||||
private final List<SQLExpr> parameters = new ArrayList<SQLExpr>();
|
||||
|
||||
public SQLGroupingSetExpr clone() {
|
||||
SQLGroupingSetExpr x = new SQLGroupingSetExpr();
|
||||
for (SQLExpr p : parameters) {
|
||||
SQLExpr p2 = p.clone();
|
||||
p2.setParent(x);
|
||||
x.parameters.add(p2);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public List<SQLExpr> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,15 @@ public class SQLSomeExpr extends SQLExprImpl {
|
||||
}
|
||||
|
||||
public SQLSomeExpr(SQLSelect select){
|
||||
this.setSubQuery(select);
|
||||
}
|
||||
|
||||
this.subQuery = select;
|
||||
public SQLSomeExpr clone() {
|
||||
SQLSomeExpr x = new SQLSomeExpr();
|
||||
if (subQuery != null) {
|
||||
x.setSubQuery(subQuery.clone());
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public SQLSelect getSubQuery() {
|
||||
@@ -42,6 +49,9 @@ public class SQLSomeExpr extends SQLExprImpl {
|
||||
}
|
||||
|
||||
public void setSubQuery(SQLSelect subQuery) {
|
||||
if (subQuery != null) {
|
||||
subQuery.setParent(this);
|
||||
}
|
||||
this.subQuery = subQuery;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,14 @@ public class SQLTimestampExpr extends SQLExprImpl {
|
||||
|
||||
}
|
||||
|
||||
public SQLTimestampExpr clone() {
|
||||
SQLTimestampExpr x = new SQLTimestampExpr();
|
||||
x.literal = literal;
|
||||
x.timeZone = timeZone;
|
||||
x.withTimeZone = withTimeZone;
|
||||
return x;
|
||||
}
|
||||
|
||||
public String getLiteral() {
|
||||
return literal;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,15 @@ public class SQLUnaryExpr extends SQLExprImpl implements Serializable {
|
||||
this.setExpr(expr);
|
||||
}
|
||||
|
||||
public SQLUnaryExpr clone() {
|
||||
SQLUnaryExpr x = new SQLUnaryExpr();
|
||||
if (expr != null) {
|
||||
x.setExpr(expr.clone());
|
||||
}
|
||||
x.operator = operator;
|
||||
return x;
|
||||
}
|
||||
|
||||
public SQLUnaryOperator getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user