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:
+15
-2
@@ -19,6 +19,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLIfStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
|
||||
@@ -33,7 +34,7 @@ public class MySqlCaseStatement extends MySqlStatementImpl{
|
||||
//case expr
|
||||
private SQLExpr condition;
|
||||
//when statement list
|
||||
private List<MySqlWhenStatement> whenList=new ArrayList<MySqlCaseStatement.MySqlWhenStatement>();
|
||||
private List<MySqlWhenStatement> whenList = new ArrayList<MySqlCaseStatement.MySqlWhenStatement>();
|
||||
//else statement
|
||||
private SQLIfStatement.Else elseItem;
|
||||
|
||||
@@ -76,7 +77,19 @@ public class MySqlCaseStatement extends MySqlStatementImpl{
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
List<SQLObject> children = new ArrayList<SQLObject>();
|
||||
children.addAll(children);
|
||||
children.addAll(whenList);
|
||||
children.addAll(whenList);
|
||||
if (elseItem != null) {
|
||||
children.add(elseItem);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* case when statement
|
||||
* @author zz
|
||||
|
||||
+5
@@ -19,6 +19,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLDeclareItem;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlStatementImpl;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
@@ -49,4 +50,8 @@ public class MySqlDeclareStatement extends MySqlStatementImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getChildren() {
|
||||
return varList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,13 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.clause;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlStatementImpl;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zz [455910092@qq.com]
|
||||
@@ -47,5 +51,10 @@ public class MySqlLeaveStatement extends MySqlStatementImpl {
|
||||
public void setLabelName(String labelName) {
|
||||
this.labelName = labelName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,13 +17,17 @@ package com.alibaba.druid.sql.dialect.mysql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntervalUnit;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MySqlExtractExpr extends SQLExprImpl implements MySqlExpr {
|
||||
|
||||
private SQLExpr value;
|
||||
private MySqlIntervalUnit unit;
|
||||
private SQLIntervalUnit unit;
|
||||
|
||||
public MySqlExtractExpr(){
|
||||
}
|
||||
@@ -48,19 +52,25 @@ public class MySqlExtractExpr extends SQLExprImpl implements MySqlExpr {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public MySqlIntervalUnit getUnit() {
|
||||
public SQLIntervalUnit getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(MySqlIntervalUnit unit) {
|
||||
public void setUnit(SQLIntervalUnit unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
MySqlASTVisitor mysqlVisitor = (MySqlASTVisitor) visitor;
|
||||
mysqlVisitor.visit(this);
|
||||
if (mysqlVisitor.visit(this)) {
|
||||
acceptChild(visitor, value);
|
||||
}
|
||||
mysqlVisitor.endVisit(this);
|
||||
}
|
||||
@Override
|
||||
public List getChildren() {
|
||||
return Collections.singletonList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2017 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class MySqlIntervalExpr extends SQLExprImpl implements MySqlExpr {
|
||||
|
||||
private SQLExpr value;
|
||||
private MySqlIntervalUnit unit;
|
||||
|
||||
public MySqlIntervalExpr(){
|
||||
}
|
||||
|
||||
public MySqlIntervalExpr clone() {
|
||||
MySqlIntervalExpr x = new MySqlIntervalExpr();
|
||||
if (value != null) {
|
||||
x.setValue(value.clone());
|
||||
}
|
||||
x.unit = unit;
|
||||
return x;
|
||||
}
|
||||
|
||||
public SQLExpr getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(SQLExpr value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public MySqlIntervalUnit getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(MySqlIntervalUnit unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void output(StringBuffer buf) {
|
||||
value.output(buf);
|
||||
buf.append(' ');
|
||||
buf.append(unit.name());
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
MySqlASTVisitor mysqlVisitor = (MySqlASTVisitor) visitor;
|
||||
if (mysqlVisitor.visit(this)) {
|
||||
acceptChild(visitor, this.value);
|
||||
}
|
||||
mysqlVisitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((unit == null) ? 0 : unit.hashCode());
|
||||
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
MySqlIntervalExpr other = (MySqlIntervalExpr) obj;
|
||||
if (unit != other.unit) {
|
||||
return false;
|
||||
}
|
||||
if (value == null) {
|
||||
if (other.value != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!value.equals(other.value)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2017 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.expr;
|
||||
|
||||
public enum MySqlIntervalUnit {
|
||||
YEAR, YEAR_MONTH,
|
||||
|
||||
QUARTER,
|
||||
|
||||
MONTH, WEEK, DAY, DAY_HOUR, DAY_MINUTE, DAY_SECOND, DAY_MICROSECOND,
|
||||
|
||||
HOUR, HOUR_MINUTE, HOUR_SECOND, HOUR_MICROSECOND,
|
||||
|
||||
MINUTE, MINUTE_SECOND, MINUTE_MICROSECOND,
|
||||
|
||||
SECOND, SECOND_MICROSECOND,
|
||||
|
||||
MICROSECOND;
|
||||
|
||||
public final String name_lcase;
|
||||
|
||||
private MySqlIntervalUnit() {
|
||||
this.name_lcase = name().toLowerCase();
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.expr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
@@ -101,6 +103,14 @@ public class MySqlMatchAgainstExpr extends SQLExprImpl implements MySqlExpr {
|
||||
mysqlVisitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getChildren() {
|
||||
List<SQLObject> children = new ArrayList<SQLObject>();
|
||||
children.addAll(this.columns);
|
||||
children.add(this.against);
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -21,6 +21,9 @@ import com.alibaba.druid.sql.ast.SQLOrderingSpecification;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MySqlOrderingExpr extends SQLExprImpl implements MySqlExpr {
|
||||
|
||||
protected SQLExpr expr;
|
||||
@@ -55,6 +58,11 @@ public class MySqlOrderingExpr extends SQLExprImpl implements MySqlExpr {
|
||||
mysqlVisitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getChildren() {
|
||||
return Collections.singletonList(this.expr);
|
||||
}
|
||||
|
||||
public SQLExpr getExpr() {
|
||||
return expr;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MySqlOutFileExpr extends MySqlObjectImpl implements SQLExpr {
|
||||
|
||||
private SQLExpr file;
|
||||
@@ -50,6 +53,11 @@ public class MySqlOutFileExpr extends MySqlObjectImpl implements SQLExpr {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getChildren() {
|
||||
return Collections.singletonList(file);
|
||||
}
|
||||
|
||||
public SQLExpr getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.util.FnvHash;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MySqlUserName extends MySqlExprImpl implements SQLName, Cloneable {
|
||||
|
||||
private String userName;
|
||||
@@ -72,6 +76,11 @@ public class MySqlUserName extends MySqlExprImpl implements SQLName, Cloneable {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public long nameHashCode64() {
|
||||
if (userNameHashCod64 == 0
|
||||
&& userName != null) {
|
||||
|
||||
+12
@@ -16,10 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlExecuteStatement extends MySqlStatementImpl {
|
||||
@@ -46,4 +48,14 @@ public class MySqlExecuteStatement extends MySqlStatementImpl {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
List<SQLObject> children = new ArrayList<SQLObject>();
|
||||
if (statementName != null) {
|
||||
children.add(statementName);
|
||||
}
|
||||
children.addAll(this.parameters);
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -16,9 +16,11 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlKillStatement extends MySqlStatementImpl {
|
||||
@@ -56,4 +58,9 @@ public class MySqlKillStatement extends MySqlStatementImpl {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
+31
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
@@ -191,6 +192,36 @@ public class MySqlLoadDataInFileStatement extends MySqlStatementImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
List<SQLObject> children = new ArrayList<SQLObject>();
|
||||
if (fileName != null) {
|
||||
children.add(fileName);
|
||||
}
|
||||
if (tableName != null) {
|
||||
children.add(tableName);
|
||||
}
|
||||
if (columnsTerminatedBy != null) {
|
||||
children.add(columnsTerminatedBy);
|
||||
}
|
||||
if (columnsEnclosedBy != null) {
|
||||
children.add(columnsEnclosedBy);
|
||||
}
|
||||
if (columnsEscaped != null) {
|
||||
children.add(columnsEscaped);
|
||||
}
|
||||
if (linesStartingBy != null) {
|
||||
children.add(linesStartingBy);
|
||||
}
|
||||
if (linesTerminatedBy != null) {
|
||||
children.add(linesTerminatedBy);
|
||||
}
|
||||
if (ignoreLinesNumber != null) {
|
||||
children.add(ignoreLinesNumber);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
|
||||
public List<SQLExpr> getColumns() {
|
||||
return columns;
|
||||
|
||||
+20
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
@@ -143,4 +144,23 @@ public class MySqlLoadXmlStatement extends MySqlStatementImpl {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
List<SQLObject> children = new ArrayList<SQLObject>();
|
||||
if (fileName != null) {
|
||||
children.add(fileName);
|
||||
}
|
||||
if (tableName != null) {
|
||||
children.add(tableName);
|
||||
}
|
||||
if (rowsIdentifiedBy != null) {
|
||||
children.add(rowsIdentifiedBy);
|
||||
}
|
||||
if (ignoreLinesNumber != null) {
|
||||
children.add(ignoreLinesNumber);
|
||||
}
|
||||
children.addAll(this.setList);
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -17,8 +17,12 @@ package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MySqlPrepareStatement extends MySqlStatementImpl {
|
||||
|
||||
private SQLName name;
|
||||
@@ -55,4 +59,16 @@ public class MySqlPrepareStatement extends MySqlStatementImpl {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
List<SQLObject> children = new ArrayList<SQLObject>();
|
||||
if (name != null) {
|
||||
children.add(name);
|
||||
}
|
||||
if (this.from != null) {
|
||||
children.add(from);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -15,8 +15,12 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MySqlSetTransactionStatement extends MySqlStatementImpl {
|
||||
|
||||
private Boolean global;
|
||||
@@ -54,4 +58,8 @@ public class MySqlSetTransactionStatement extends MySqlStatementImpl {
|
||||
this.accessModel = accessModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -16,8 +16,13 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MySqlShowCharacterSetStatement extends MySqlStatementImpl implements MySqlShowStatement {
|
||||
|
||||
private SQLExpr where;
|
||||
@@ -47,4 +52,9 @@ public class MySqlShowCharacterSetStatement extends MySqlStatementImpl implement
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Arrays.<SQLObject>asList(this.where, pattern);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
@@ -17,10 +17,14 @@ package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MySqlShowColumnsStatement extends MySqlStatementImpl implements MySqlShowStatement {
|
||||
|
||||
private boolean full;
|
||||
@@ -85,4 +89,21 @@ public class MySqlShowColumnsStatement extends MySqlStatementImpl implements MyS
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
List<SQLObject> children = new ArrayList<SQLObject>();
|
||||
if (table != null) {
|
||||
children.add(table);
|
||||
}
|
||||
if (database != null) {
|
||||
children.add(database);
|
||||
}
|
||||
if (like != null) {
|
||||
children.add(like);
|
||||
}
|
||||
if (where != null) {
|
||||
children.add(where);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MySqlStatementImpl extends SQLStatementImpl implements MySqlStatement {
|
||||
|
||||
public MySqlStatementImpl() {
|
||||
@@ -38,4 +41,8 @@ public abstract class MySqlStatementImpl extends SQLStatementImpl implements MyS
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
throw new UnsupportedOperationException(this.getClass().getName());
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
throw new UnsupportedOperationException(this.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MysqlDeallocatePrepareStatement extends MySqlStatementImpl {
|
||||
|
||||
private SQLName statementName;
|
||||
@@ -37,4 +41,8 @@ public class MysqlDeallocatePrepareStatement extends MySqlStatementImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(statementName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ import com.alibaba.druid.sql.dialect.mysql.ast.MysqlForeignKey.Match;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MysqlForeignKey.Option;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalUnit;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntervalExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntervalUnit;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr.SearchModifier;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
@@ -352,7 +352,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
String unitVal = lexer.stringVal();
|
||||
MySqlIntervalUnit unit = MySqlIntervalUnit.valueOf(unitVal.toUpperCase());
|
||||
SQLIntervalUnit unit = SQLIntervalUnit.valueOf(unitVal.toUpperCase());
|
||||
lexer.nextToken();
|
||||
|
||||
accept(Token.FROM);
|
||||
@@ -441,9 +441,9 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
String unit = lexer.stringVal();
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlIntervalExpr intervalExpr = new MySqlIntervalExpr();
|
||||
SQLIntervalExpr intervalExpr = new SQLIntervalExpr();
|
||||
intervalExpr.setValue(value);
|
||||
intervalExpr.setUnit(MySqlIntervalUnit.valueOf(unit.toUpperCase()));
|
||||
intervalExpr.setUnit(SQLIntervalUnit.valueOf(unit.toUpperCase()));
|
||||
return intervalExpr;
|
||||
} else {
|
||||
return primaryRest(methodInvokeExpr);
|
||||
@@ -458,9 +458,9 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
String unit = lexer.stringVal();
|
||||
lexer.nextToken();
|
||||
|
||||
MySqlIntervalExpr intervalExpr = new MySqlIntervalExpr();
|
||||
SQLIntervalExpr intervalExpr = new SQLIntervalExpr();
|
||||
intervalExpr.setValue(value);
|
||||
intervalExpr.setUnit(MySqlIntervalUnit.valueOf(unit.toUpperCase()));
|
||||
intervalExpr.setUnit(SQLIntervalUnit.valueOf(unit.toUpperCase()));
|
||||
|
||||
return intervalExpr;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlRepeatStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
|
||||
@@ -63,10 +63,6 @@ public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
|
||||
void endVisit(MysqlForeignKey x);
|
||||
|
||||
void endVisit(MySqlIntervalExpr x);
|
||||
|
||||
boolean visit(MySqlIntervalExpr x);
|
||||
|
||||
void endVisit(MySqlExtractExpr x);
|
||||
|
||||
boolean visit(MySqlExtractExpr x);
|
||||
|
||||
+3
-5
@@ -34,7 +34,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlRepeatStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
|
||||
@@ -78,13 +78,11 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements MySq
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlIntervalExpr x) {
|
||||
|
||||
public void endVisit(SQLIntervalExpr x) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlIntervalExpr x) {
|
||||
|
||||
public boolean visit(SQLIntervalExpr x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlRepeatStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
|
||||
@@ -689,21 +688,6 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlIntervalExpr x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlIntervalExpr x) {
|
||||
print0(ucase ? "INTERVAL " : "interval ");
|
||||
SQLExpr value = x.getValue();
|
||||
value.accept(this);
|
||||
print(' ');
|
||||
print0(ucase ? x.getUnit().name() : x.getUnit().name_lcase);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlExtractExpr x) {
|
||||
print0(ucase ? "EXTRACT(" : "extract(");
|
||||
|
||||
+1
-17
@@ -15,12 +15,9 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.visitor;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLDeclareItem;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.*;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlForceIndexHint;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlIgnoreIndexHint;
|
||||
@@ -41,7 +38,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlRepeatStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
|
||||
@@ -55,8 +52,6 @@ import com.alibaba.druid.stat.TableStat.Mode;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlASTVisitor {
|
||||
|
||||
public MySqlSchemaStatVisitor() {
|
||||
@@ -172,17 +167,6 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlIntervalExpr x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlIntervalExpr x) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlExtractExpr x) {
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.odps.ast;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
@@ -22,6 +23,9 @@ import com.alibaba.druid.sql.dialect.odps.visitor.OdpsASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OdpsShowStatisticStmt extends SQLStatementImpl {
|
||||
|
||||
private SQLExprTableSource tableSource;
|
||||
@@ -49,4 +53,9 @@ public class OdpsShowStatisticStmt extends SQLStatementImpl {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(this.tableSource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,15 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLDataType;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLOver;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleAnalytic extends SQLOver implements OracleExpr {
|
||||
|
||||
private OracleAnalyticWindowing windowing;
|
||||
@@ -42,6 +47,19 @@ public class OracleAnalytic extends SQLOver implements OracleExpr {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
List<SQLObject> children = new ArrayList<SQLObject>();
|
||||
children.addAll(this.partitionBy);
|
||||
if (this.orderBy != null) {
|
||||
children.add(orderBy);
|
||||
}
|
||||
if (this.windowing != null) {
|
||||
children.add(windowing);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
public OracleAnalyticWindowing getWindowing() {
|
||||
return this.windowing;
|
||||
}
|
||||
|
||||
+9
@@ -16,10 +16,14 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleAnalyticWindowing extends SQLObjectImpl implements OracleExpr {
|
||||
|
||||
private Type type;
|
||||
@@ -69,4 +73,9 @@ public class OracleAnalyticWindowing extends SQLObjectImpl implements OracleExpr
|
||||
public static enum Type {
|
||||
ROWS, RANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(this.expr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleArgumentExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
|
||||
private String argumentName;
|
||||
@@ -67,4 +71,10 @@ public class OracleArgumentExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(this.value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,10 +15,14 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLNumericLiteralExpr;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleBinaryFloatExpr extends SQLNumericLiteralExpr implements OracleExpr {
|
||||
|
||||
private Float value;
|
||||
@@ -36,6 +40,11 @@ public class OracleBinaryFloatExpr extends SQLNumericLiteralExpr implements Orac
|
||||
return new OracleBinaryFloatExpr(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number getNumber() {
|
||||
return value;
|
||||
|
||||
@@ -16,10 +16,14 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelect;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleCursorExpr extends SQLExprImpl implements OracleExpr {
|
||||
|
||||
private SQLSelect query;
|
||||
@@ -60,6 +64,11 @@ public class OracleCursorExpr extends SQLExprImpl implements OracleExpr {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(this.query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -16,10 +16,15 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleDatetimeExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
|
||||
private SQLExpr expr;
|
||||
@@ -72,4 +77,9 @@ public class OracleDatetimeExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Arrays.<SQLObject>asList(this.expr, this.timeZone);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,14 @@ package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
import com.alibaba.druid.util.FnvHash;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleDbLinkExpr extends SQLExprImpl implements SQLName, OracleExpr {
|
||||
|
||||
private SQLExpr expr;
|
||||
@@ -74,6 +78,11 @@ public class OracleDbLinkExpr extends SQLExprImpl implements SQLName, OracleExpr
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(this.expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
long value = hashCode64();
|
||||
@@ -97,12 +106,10 @@ public class OracleDbLinkExpr extends SQLExprImpl implements SQLName, OracleExpr
|
||||
|
||||
public OracleDbLinkExpr clone() {
|
||||
OracleDbLinkExpr x = new OracleDbLinkExpr();
|
||||
|
||||
if (expr != null) {
|
||||
expr = expr.clone();
|
||||
x.setExpr(expr.clone());
|
||||
}
|
||||
x.dbLink = dbLink;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,14 @@ package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleIntervalExpr extends SQLExprImpl implements SQLLiteralExpr, OracleExpr {
|
||||
|
||||
private SQLExpr value;
|
||||
@@ -47,6 +51,11 @@ public class OracleIntervalExpr extends SQLExprImpl implements SQLLiteralExpr, O
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(this.value);
|
||||
}
|
||||
|
||||
public SQLExpr getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,13 @@ package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleIsSetExpr extends SQLExprImpl implements OracleExpr {
|
||||
|
||||
private SQLExpr nestedTable;
|
||||
@@ -63,6 +67,11 @@ public class OracleIsSetExpr extends SQLExprImpl implements OracleExpr {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(this.nestedTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -17,9 +17,13 @@ package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleOuterExpr extends SQLExprImpl implements OracleExpr {
|
||||
|
||||
private SQLExpr expr;
|
||||
@@ -67,6 +71,11 @@ public class OracleOuterExpr extends SQLExprImpl implements OracleExpr {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(this.expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -16,9 +16,14 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleRangeExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
|
||||
private SQLExpr lowBound;
|
||||
@@ -42,6 +47,10 @@ public class OracleRangeExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Arrays.<SQLObject>asList(this.lowBound, this.upBound);
|
||||
}
|
||||
|
||||
public SQLExpr getLowBound() {
|
||||
return lowBound;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleSizeExpr extends OracleSQLObjectImpl implements OracleExpr {
|
||||
|
||||
private SQLExpr value;
|
||||
@@ -42,6 +46,10 @@ public class OracleSizeExpr extends OracleSQLObjectImpl implements OracleExpr {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(value);
|
||||
}
|
||||
|
||||
public SQLExpr getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -15,10 +15,15 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleSysdateExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
|
||||
private String option;
|
||||
@@ -42,4 +47,13 @@ public class OracleSysdateExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
x.option = option;
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>emptyList();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return SQLUtils.toOracleString(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,14 @@ package com.alibaba.druid.sql.dialect.oracle.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLDataType;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleTreatExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
|
||||
private SQLExpr expr;
|
||||
@@ -65,6 +70,10 @@ public class OracleTreatExpr extends OracleSQLObjectImpl implements SQLExpr {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Arrays.<SQLObject>asList(this.expr, this.type);
|
||||
}
|
||||
|
||||
public OracleTreatExpr clone() {
|
||||
OracleTreatExpr x = new OracleTreatExpr();
|
||||
|
||||
|
||||
+15
@@ -17,9 +17,13 @@ package com.alibaba.druid.sql.dialect.oracle.ast.stmt;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OracleLockTableStatement extends OracleStatementImpl {
|
||||
|
||||
private SQLExprTableSource table;
|
||||
@@ -76,6 +80,17 @@ public class OracleLockTableStatement extends OracleStatementImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
List<SQLObject> children = new ArrayList<SQLObject>();
|
||||
if (table != null) {
|
||||
children.add(table);
|
||||
}
|
||||
if (wait != null) {
|
||||
children.add(wait);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
public static enum LockMode {
|
||||
ROW_SHARE,
|
||||
ROW_EXCLUSIVE,
|
||||
|
||||
@@ -108,6 +108,9 @@ public class OracleSelectParser extends SQLSelectParser {
|
||||
if (lexer.token() == Token.OF) {
|
||||
lexer.nextToken();
|
||||
this.exprParser.exprList(queryBlock.getForUpdateOf(), queryBlock);
|
||||
} else if (lexer.token() == Token.LPAREN
|
||||
&& queryBlock.isForUpdate()) {
|
||||
this.exprParser.exprList(queryBlock.getForUpdateOf(), queryBlock);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.NOWAIT) {
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PGBoxExpr extends PGExprImpl {
|
||||
|
||||
private SQLExpr value;
|
||||
@@ -46,6 +50,10 @@ public class PGBoxExpr extends PGExprImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PGCidrExpr extends PGExprImpl {
|
||||
|
||||
private SQLExpr value;
|
||||
@@ -46,6 +50,10 @@ public class PGCidrExpr extends PGExprImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PGCircleExpr extends PGExprImpl {
|
||||
|
||||
private SQLExpr value;
|
||||
@@ -46,6 +50,11 @@ public class PGCircleExpr extends PGExprImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PGExtractExpr extends PGExprImpl {
|
||||
|
||||
private PGDateField field;
|
||||
@@ -59,6 +63,10 @@ public class PGExtractExpr extends PGExprImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PGInetExpr extends PGExprImpl {
|
||||
|
||||
private SQLExpr value;
|
||||
@@ -46,6 +50,10 @@ public class PGInetExpr extends PGExprImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2017 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
/**
|
||||
* Created by tianzhen.wtz on 2014/12/29 0029 16:10.
|
||||
* 类说明:
|
||||
*/
|
||||
public class PGIntervalExpr extends SQLExprImpl implements SQLLiteralExpr,PGExpr{
|
||||
|
||||
private SQLExpr value;
|
||||
|
||||
|
||||
public SQLExpr getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(SQLExpr value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept0(PGASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PGIntervalExpr that = (PGIntervalExpr) o;
|
||||
|
||||
if (value != null ? !value.equals(that.value) : that.value != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return value != null ? value.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
this.accept0((PGASTVisitor) visitor);
|
||||
}
|
||||
|
||||
public PGIntervalExpr clone() {
|
||||
PGIntervalExpr x = new PGIntervalExpr();
|
||||
if (value != null) {
|
||||
x.setValue(value.clone());
|
||||
}
|
||||
return x;
|
||||
}
|
||||
}
|
||||
+9
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PGLineSegmentsExpr extends PGExprImpl {
|
||||
|
||||
private SQLExpr value;
|
||||
@@ -46,6 +50,11 @@ public class PGLineSegmentsExpr extends PGExprImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PGMacAddrExpr extends PGExprImpl {
|
||||
|
||||
@@ -47,6 +51,10 @@ public class PGMacAddrExpr extends PGExprImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PGPointExpr extends PGExprImpl {
|
||||
|
||||
private SQLExpr value;
|
||||
@@ -46,6 +50,10 @@ public class PGPointExpr extends PGExprImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PGPolygonExpr extends PGExprImpl {
|
||||
|
||||
@@ -47,6 +51,10 @@ public class PGPolygonExpr extends PGExprImpl {
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>singletonList(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -17,21 +17,13 @@ package com.alibaba.druid.sql.dialect.postgresql.parser;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLDataType;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLArrayExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLTimestampExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLUnaryExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLUnaryOperator;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.*;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGBoxExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCidrExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCircleExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGDateField;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGInetExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGLineSegmentsExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGMacAddrExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGPointExpr;
|
||||
@@ -125,7 +117,7 @@ public class PGExprParser extends SQLExprParser {
|
||||
@Override
|
||||
protected SQLExpr parseInterval() {
|
||||
accept(Token.INTERVAL);
|
||||
PGIntervalExpr intervalExpr=new PGIntervalExpr();
|
||||
SQLIntervalExpr intervalExpr = new SQLIntervalExpr();
|
||||
if (lexer.token() != Token.LITERAL_CHARS) {
|
||||
return new SQLIdentifierExpr("INTERVAL");
|
||||
}
|
||||
|
||||
@@ -101,10 +101,6 @@ public interface PGASTVisitor extends SQLASTVisitor {
|
||||
|
||||
boolean visit(PGLineSegmentsExpr x);
|
||||
|
||||
void endVisit(PGIntervalExpr x);
|
||||
|
||||
boolean visit(PGIntervalExpr x);
|
||||
|
||||
void endVisit(PGShowStatement x);
|
||||
|
||||
boolean visit(PGShowStatement x);
|
||||
|
||||
-11
@@ -20,7 +20,6 @@ import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCidrExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCircleExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGInetExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGLineSegmentsExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGMacAddrExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGPointExpr;
|
||||
@@ -238,16 +237,6 @@ public class PGASTVisitorAdapter extends SQLASTVisitorAdapter implements PGASTVi
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(PGIntervalExpr x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(PGIntervalExpr x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(PGShowStatement x) {
|
||||
|
||||
|
||||
+104
-14
@@ -23,13 +23,11 @@ import com.alibaba.druid.sql.ast.expr.*;
|
||||
import com.alibaba.druid.sql.ast.statement.*;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.expr.*;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.*;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleOutputVisitor;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGBoxExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCidrExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCircleExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGInetExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGLineSegmentsExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGMacAddrExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGPointExpr;
|
||||
@@ -551,18 +549,6 @@ public class PGOutputVisitor extends SQLASTOutputVisitor implements PGASTVisitor
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(PGIntervalExpr x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(PGIntervalExpr x) {
|
||||
print0(ucase ? "INTERVAL " : "interval ");
|
||||
x.getValue().accept(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(PGLineSegmentsExpr x) {
|
||||
|
||||
@@ -873,4 +859,108 @@ public class PGOutputVisitor extends SQLASTOutputVisitor implements PGASTVisitor
|
||||
visit((SQLUnique) x);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(OracleSelectSubqueryTableSource x) {
|
||||
print('(');
|
||||
this.indentCount++;
|
||||
println();
|
||||
x.getSelect().accept(this);
|
||||
this.indentCount--;
|
||||
println();
|
||||
print(')');
|
||||
|
||||
if (x.getPivot() != null) {
|
||||
println();
|
||||
x.getPivot().accept(this);
|
||||
}
|
||||
|
||||
printFlashback(x.getFlashback());
|
||||
|
||||
if ((x.getAlias() != null) && (x.getAlias().length() != 0)) {
|
||||
print(' ');
|
||||
print0(x.getAlias());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(OracleSelectJoin x) {
|
||||
x.getLeft().accept(this);
|
||||
SQLTableSource right = x.getRight();
|
||||
|
||||
if (x.getJoinType() == SQLJoinTableSource.JoinType.COMMA) {
|
||||
print0(", ");
|
||||
x.getRight().accept(this);
|
||||
} else {
|
||||
boolean isRoot = x.getParent() instanceof SQLSelectQueryBlock;
|
||||
if (isRoot) {
|
||||
this.indentCount++;
|
||||
}
|
||||
|
||||
println();
|
||||
print0(ucase ? x.getJoinType().name : x.getJoinType().name_lcase);
|
||||
print(' ');
|
||||
|
||||
if (right instanceof SQLJoinTableSource) {
|
||||
print('(');
|
||||
right.accept(this);
|
||||
print(')');
|
||||
} else {
|
||||
right.accept(this);
|
||||
}
|
||||
|
||||
if (isRoot) {
|
||||
this.indentCount--;
|
||||
}
|
||||
|
||||
if (x.getCondition() != null) {
|
||||
print0(ucase ? " ON " : " on ");
|
||||
x.getCondition().accept(this);
|
||||
print(' ');
|
||||
}
|
||||
|
||||
if (x.getUsing().size() > 0) {
|
||||
print0(ucase ? " USING (" : " using (");
|
||||
printAndAccept(x.getUsing(), ", ");
|
||||
print(')');
|
||||
}
|
||||
|
||||
printFlashback(x.getFlashback());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(OracleDbLinkExpr x) {
|
||||
SQLExpr expr = x.getExpr();
|
||||
if (expr != null) {
|
||||
expr.accept(this);
|
||||
print('@');
|
||||
}
|
||||
print0(x.getDbLink());
|
||||
return false;
|
||||
}
|
||||
|
||||
public void endVisit(OracleDbLinkExpr x) {
|
||||
|
||||
}
|
||||
|
||||
public boolean visit(OracleDeleteStatement x) {
|
||||
return visit((SQLDeleteStatement) x);
|
||||
}
|
||||
|
||||
private void printFlashback(SQLExpr flashback) {
|
||||
if (flashback == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
println();
|
||||
|
||||
if (flashback instanceof SQLBetweenExpr) {
|
||||
flashback.accept(this);
|
||||
} else {
|
||||
print0(ucase ? "AS OF " : "as of ");
|
||||
flashback.accept(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-12
@@ -18,7 +18,6 @@ package com.alibaba.druid.sql.dialect.postgresql.visitor;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
|
||||
@@ -27,7 +26,6 @@ import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCidrExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGCircleExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGExtractExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGInetExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGIntervalExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGLineSegmentsExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGMacAddrExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGPointExpr;
|
||||
@@ -311,16 +309,6 @@ public class PGSchemaStatVisitor extends SchemaStatVisitor implements PGASTVisit
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(PGIntervalExpr x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(PGIntervalExpr x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(PGLineSegmentsExpr x) {
|
||||
|
||||
|
||||
+8
@@ -17,12 +17,16 @@ package com.alibaba.druid.sql.dialect.sqlserver.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerObjectImpl;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;
|
||||
import com.alibaba.druid.util.FnvHash;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SQLServerObjectReferenceExpr extends SQLServerObjectImpl implements SQLServerExpr, SQLName {
|
||||
|
||||
private String server;
|
||||
@@ -151,4 +155,8 @@ public class SQLServerObjectReferenceExpr extends SQLServerObjectImpl implements
|
||||
}
|
||||
return hashCode64;
|
||||
}
|
||||
|
||||
public List<SQLObject> getChildren() {
|
||||
return Collections.<SQLObject>emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user