imporoved sql parser.

This commit is contained in:
wenshao
2017-10-15 03:13:30 +08:00
parent 0527591d6a
commit 7da600e088
117 changed files with 9172 additions and 491 deletions
@@ -32,6 +32,9 @@ public class SQLDataTypeImpl extends SQLObjectImpl implements SQLDataType {
private boolean withLocalTimeZone = false;
private String dbType;
private boolean unsigned;
private boolean zerofill;
public SQLDataTypeImpl(){
}
@@ -149,9 +152,27 @@ public class SQLDataTypeImpl extends SQLObjectImpl implements SQLDataType {
x.withTimeZone = withTimeZone;
x.withLocalTimeZone = withLocalTimeZone;
x.zerofill = zerofill;
x.unsigned = unsigned;
}
public String toString() {
return SQLUtils.toSQLString(this, dbType);
}
public boolean isUnsigned() {
return unsigned;
}
public void setUnsigned(boolean unsigned) {
this.unsigned = unsigned;
}
public boolean isZerofill() {
return zerofill;
}
public void setZerofill(boolean zerofill) {
this.zerofill = zerofill;
}
}
@@ -50,11 +50,11 @@ public class SQLAnyExpr extends SQLExprImpl {
return this.subQuery;
}
public void setSubQuery(SQLSelect subQuery) {
if (subQuery != null) {
subQuery.setParent(this);
public void setSubQuery(SQLSelect x) {
if (x != null) {
x.setParent(this);
}
this.subQuery = subQuery;
this.subQuery = x;
}
public void output(StringBuffer buf) {
@@ -0,0 +1,54 @@
/*
* 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.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import com.alibaba.druid.sql.ast.statement.SQLAlterTableItem;
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLAlterCharacter extends SQLObjectImpl implements SQLAlterTableItem {
private SQLExpr characterSet;
private SQLExpr collate;
public void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, characterSet);
acceptChild(visitor, collate);
}
visitor.endVisit(this);
}
public SQLExpr getCharacterSet() {
return characterSet;
}
public void setCharacterSet(SQLExpr characterSet) {
this.characterSet = characterSet;
}
public SQLExpr getCollate() {
return collate;
}
public void setCollate(SQLExpr collate) {
this.collate = collate;
}
}
@@ -28,6 +28,8 @@ public class SQLAlterDatabaseStatement extends SQLStatementImpl implements SQLAl
private SQLName name;
private boolean upgradeDataDirectoryName;
private SQLAlterCharacter character;
public SQLAlterDatabaseStatement() {
@@ -48,6 +50,17 @@ public class SQLAlterDatabaseStatement extends SQLStatementImpl implements SQLAl
this.name = name;
}
public SQLAlterCharacter getCharacter() {
return character;
}
public void setCharacter(SQLAlterCharacter character) {
if (character != null) {
character.setParent(this);
}
this.character = character;
}
public boolean isUpgradeDataDirectoryName() {
return upgradeDataDirectoryName;
}
@@ -15,6 +15,7 @@
*/
package com.alibaba.druid.sql.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
@@ -25,6 +26,11 @@ public class SQLAlterFunctionStatement extends SQLStatementImpl {
private boolean debug;
private boolean reuseSettings;
private SQLExpr comment;
private boolean languageSql;
private boolean containsSql;
private SQLExpr sqlSecurity;
public boolean isDebug() {
return debug;
}
@@ -44,6 +50,17 @@ public class SQLAlterFunctionStatement extends SQLStatementImpl {
this.name = name;
}
public SQLExpr getComment() {
return comment;
}
public void setComment(SQLExpr comment) {
if (comment != null) {
comment.setParent(this);
}
this.comment = comment;
}
public boolean isReuseSettings() {
return reuseSettings;
}
@@ -52,10 +69,39 @@ public class SQLAlterFunctionStatement extends SQLStatementImpl {
this.reuseSettings = x;
}
public boolean isLanguageSql() {
return languageSql;
}
public void setLanguageSql(boolean languageSql) {
this.languageSql = languageSql;
}
public boolean isContainsSql() {
return containsSql;
}
public void setContainsSql(boolean containsSql) {
this.containsSql = containsSql;
}
public SQLExpr getSqlSecurity() {
return sqlSecurity;
}
public void setSqlSecurity(SQLExpr sqlSecurity) {
if (sqlSecurity != null) {
sqlSecurity.setParent(this);
}
this.sqlSecurity = sqlSecurity;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
acceptChild(visitor, comment);
acceptChild(visitor, sqlSecurity);
}
visitor.endVisit(this);
}
@@ -0,0 +1,105 @@
/*
* 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.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleAlterStatement;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleStatementImpl;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLAlterProcedureStatement extends SQLStatementImpl implements SQLAlterStatement {
private SQLExpr name;
private boolean compile = false;
private boolean reuseSettings = false;
private SQLExpr comment;
private boolean languageSql;
private boolean containsSql;
private SQLExpr sqlSecurity;
public void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
}
visitor.endVisit(this);
}
public SQLExpr getName() {
return name;
}
public void setName(SQLExpr name) {
this.name = name;
}
public boolean isCompile() {
return compile;
}
public void setCompile(boolean compile) {
this.compile = compile;
}
public boolean isReuseSettings() {
return reuseSettings;
}
public void setReuseSettings(boolean reuseSettings) {
this.reuseSettings = reuseSettings;
}
public boolean isLanguageSql() {
return languageSql;
}
public void setLanguageSql(boolean languageSql) {
this.languageSql = languageSql;
}
public boolean isContainsSql() {
return containsSql;
}
public void setContainsSql(boolean containsSql) {
this.containsSql = containsSql;
}
public SQLExpr getSqlSecurity() {
return sqlSecurity;
}
public void setSqlSecurity(SQLExpr sqlSecurity) {
if (sqlSecurity != null) {
sqlSecurity.setParent(this);
}
this.sqlSecurity = sqlSecurity;
}
public SQLExpr getComment() {
return comment;
}
public void setComment(SQLExpr comment) {
if (comment != null) {
comment.setParent(this);
}
this.comment = comment;
}
}
@@ -18,6 +18,7 @@ package com.alibaba.druid.sql.ast.statement;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlKey;
@@ -39,6 +40,8 @@ public class SQLAlterTableAddIndex extends SQLObjectImpl implements SQLAlterTabl
private boolean key = false;
protected SQLExpr comment;
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
@@ -122,4 +125,15 @@ public class SQLAlterTableAddIndex extends SQLObjectImpl implements SQLAlterTabl
}
x.setIndexType(type);
}
public SQLExpr getComment() {
return comment;
}
public void setComment(SQLExpr comment) {
if (comment != null) {
comment.setParent(this);
}
this.comment = comment;
}
}
@@ -0,0 +1,279 @@
/*
* 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.ast.statement;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.*;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLAlterViewStatement extends SQLStatementImpl implements SQLCreateStatement {
private boolean force = false;
// protected SQLName name;
protected SQLSelect subQuery;
protected boolean ifNotExists = false;
protected String algorithm;
protected SQLName definer;
protected String sqlSecurity;
protected SQLExprTableSource tableSource;
protected final List<SQLTableElement> columns = new ArrayList<SQLTableElement>();
private boolean withCheckOption;
private boolean withCascaded;
private boolean withLocal;
private boolean withReadOnly;
private SQLLiteralExpr comment;
public SQLAlterViewStatement(){
}
public SQLAlterViewStatement(String dbType){
super(dbType);
}
public String computeName() {
if (tableSource == null) {
return null;
}
SQLExpr expr = tableSource.getExpr();
if (expr instanceof SQLName) {
String name = ((SQLName) expr).getSimpleName();
return SQLUtils.normalize(name);
}
return null;
}
public String getSchema() {
SQLName name = getName();
if (name == null) {
return null;
}
if (name instanceof SQLPropertyExpr) {
return ((SQLPropertyExpr) name).getOwnernName();
}
return null;
}
public SQLName getName() {
if (tableSource == null) {
return null;
}
return (SQLName) tableSource.getExpr();
}
public void setName(SQLName name) {
this.setTableSource(new SQLExprTableSource(name));
}
public void setName(String name) {
this.setName(new SQLIdentifierExpr(name));
}
public SQLExprTableSource getTableSource() {
return tableSource;
}
public void setTableSource(SQLExprTableSource tableSource) {
if (tableSource != null) {
tableSource.setParent(this);
}
this.tableSource = tableSource;
}
public boolean isWithCheckOption() {
return withCheckOption;
}
public void setWithCheckOption(boolean withCheckOption) {
this.withCheckOption = withCheckOption;
}
public boolean isWithCascaded() {
return withCascaded;
}
public void setWithCascaded(boolean withCascaded) {
this.withCascaded = withCascaded;
}
public boolean isWithLocal() {
return withLocal;
}
public void setWithLocal(boolean withLocal) {
this.withLocal = withLocal;
}
public boolean isWithReadOnly() {
return withReadOnly;
}
public void setWithReadOnly(boolean withReadOnly) {
this.withReadOnly = withReadOnly;
}
public SQLSelect getSubQuery() {
return subQuery;
}
public void setSubQuery(SQLSelect subQuery) {
if (subQuery != null) {
subQuery.setParent(this);
}
this.subQuery = subQuery;
}
public List<SQLTableElement> getColumns() {
return columns;
}
public void addColumn(SQLTableElement column) {
if (column != null) {
column.setParent(this);
}
this.columns.add(column);
}
public boolean isIfNotExists() {
return ifNotExists;
}
public void setIfNotExists(boolean ifNotExists) {
this.ifNotExists = ifNotExists;
}
public SQLLiteralExpr getComment() {
return comment;
}
public void setComment(SQLLiteralExpr comment) {
if (comment != null) {
comment.setParent(this);
}
this.comment = comment;
}
public String getAlgorithm() {
return algorithm;
}
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
public SQLName getDefiner() {
return definer;
}
public void setDefiner(SQLName definer) {
if (definer != null) {
definer.setParent(this);
}
this.definer = definer;
}
public String getSqlSecurity() {
return sqlSecurity;
}
public void setSqlSecurity(String sqlSecurity) {
this.sqlSecurity = sqlSecurity;
}
public boolean isForce() {
return force;
}
public void setForce(boolean force) {
this.force = force;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, this.tableSource);
acceptChild(visitor, this.columns);
acceptChild(visitor, this.comment);
acceptChild(visitor, this.subQuery);
}
visitor.endVisit(this);
}
public List<SQLObject> getChildren() {
List<SQLObject> children = new ArrayList<SQLObject>();
if (tableSource != null) {
children.add(tableSource);
}
children.addAll(this.columns);
if (comment != null) {
children.add(comment);
}
if (subQuery != null) {
children.add(subQuery);
}
return children;
}
public SQLAlterViewStatement clone() {
SQLAlterViewStatement x = new SQLAlterViewStatement();
x.force = force;
if (subQuery != null) {
x.setSubQuery(subQuery.clone());
}
x.ifNotExists = ifNotExists;
x.algorithm = algorithm;
if (definer != null) {
x.setDefiner(definer.clone());
}
x.sqlSecurity = sqlSecurity;
if (tableSource != null) {
x.setTableSource(tableSource.clone());
}
for (SQLTableElement column : columns) {
SQLTableElement column2 = column.clone();
column2.setParent(x);
x.columns.add(column2);
}
x.withCheckOption = withCheckOption;
x.withCascaded = withCascaded;
x.withLocal = withLocal;
x.withReadOnly = withReadOnly;
if (comment != null) {
x.setComment(comment.clone());
}
return x;
}
}
@@ -26,6 +26,14 @@ public class SQLColumnReference extends SQLConstraintImpl implements SQLColumnCo
private SQLName table;
private List<SQLName> columns = new ArrayList<SQLName>();
private SQLForeignKeyImpl.Match referenceMatch;
protected SQLForeignKeyImpl.Option onUpdate;
protected SQLForeignKeyImpl.Option onDelete;
public SQLColumnReference() {
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
@@ -65,7 +73,34 @@ public class SQLColumnReference extends SQLConstraintImpl implements SQLColumnCo
x.columns.add(columnCloned);
}
x.referenceMatch = referenceMatch;
x.onUpdate = onUpdate;
x.onDelete = onDelete;
return x;
}
public SQLForeignKeyImpl.Match getReferenceMatch() {
return referenceMatch;
}
public void setReferenceMatch(SQLForeignKeyImpl.Match referenceMatch) {
this.referenceMatch = referenceMatch;
}
public SQLForeignKeyImpl.Option getOnUpdate() {
return onUpdate;
}
public void setOnUpdate(SQLForeignKeyImpl.Option onUpdate) {
this.onUpdate = onUpdate;
}
public SQLForeignKeyImpl.Option getOnDelete() {
return onDelete;
}
public void setOnDelete(SQLForeignKeyImpl.Option onDelete) {
this.onDelete = onDelete;
}
}
@@ -39,6 +39,8 @@ public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLCrea
// for mysql
private String using;
private SQLExpr comment;
public SQLCreateIndexStatement(){
}
@@ -168,6 +170,20 @@ public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLCrea
}
x.type = type;
x.using = using;
if (comment != null) {
x.setComment(comment.clone());
}
return x;
}
public SQLExpr getComment() {
return comment;
}
public void setComment(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.comment = x;
}
}
@@ -24,11 +24,11 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLCreateTriggerStatement extends SQLStatementImpl implements SQLCreateStatement {
private SQLName name;
private boolean orReplace = false;
private TriggerType triggerType;
private SQLName definer;
private boolean update;
private boolean delete;
private boolean insert;
@@ -153,11 +153,11 @@ public class SQLCreateTriggerStatement extends SQLStatementImpl implements SQLCr
return when;
}
public void setWhen(SQLExpr when) {
if (when != null) {
when.setParent(this);
public void setWhen(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.when = when;
this.when = x;
}
public boolean isUpdate() {
@@ -184,6 +184,17 @@ public class SQLCreateTriggerStatement extends SQLStatementImpl implements SQLCr
this.insert = insert;
}
public SQLName getDefiner() {
return definer;
}
public void setDefiner(SQLName x) {
if (x != null) {
x.setParent(this);
}
this.definer = x;
}
public static enum TriggerType {
BEFORE, AFTER, INSTEAD_OF
}
@@ -0,0 +1,75 @@
/*
* 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.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLDropEventStatement extends SQLStatementImpl implements SQLDropStatement {
private SQLExpr name;
private boolean ifExists;
public SQLDropEventStatement() {
}
public SQLDropEventStatement(String dbType) {
super (dbType);
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
}
visitor.endVisit(this);
}
public SQLExpr getName() {
return name;
}
public void setName(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.name = x;
}
public boolean isIfExists() {
return ifExists;
}
public void setIfExists(boolean ifExists) {
this.ifExists = ifExists;
}
@Override
public List<SQLObject> getChildren() {
List<SQLObject> children = new ArrayList<SQLObject>();
if (name != null) {
children.add(name);
}
return children;
}
}
@@ -28,6 +28,9 @@ public class SQLDropIndexStatement extends SQLStatementImpl implements SQLDropSt
private SQLName indexName;
private SQLExprTableSource tableName;
private SQLExpr algorithm;
private SQLExpr lockOption;
public SQLDropIndexStatement() {
@@ -57,11 +60,35 @@ public class SQLDropIndexStatement extends SQLStatementImpl implements SQLDropSt
this.tableName = tableName;
}
public SQLExpr getAlgorithm() {
return algorithm;
}
public void setAlgorithm(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.algorithm = x;
}
public SQLExpr getLockOption() {
return lockOption;
}
public void setLockOption(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.lockOption = x;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, indexName);
acceptChild(visitor, tableName);
acceptChild(visitor, algorithm);
acceptChild(visitor, lockOption);
}
visitor.endVisit(this);
}
@@ -0,0 +1,79 @@
/*
* 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.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLDropLogFileGroupStatement extends SQLStatementImpl implements SQLDropStatement {
private SQLExpr name;
private SQLExpr engine;
public SQLDropLogFileGroupStatement() {
}
public SQLDropLogFileGroupStatement(String dbType) {
super (dbType);
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
acceptChild(visitor, engine);
}
visitor.endVisit(this);
}
public SQLExpr getName() {
return name;
}
public void setName(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.name = x;
}
public SQLExpr getEngine() {
return engine;
}
public void setEngine(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.engine = x;
}
@Override
public List<SQLObject> getChildren() {
List<SQLObject> children = new ArrayList<SQLObject>();
if (name != null) {
children.add(name);
}
return children;
}
}
@@ -0,0 +1,74 @@
/*
* 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.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLDropServerStatement extends SQLStatementImpl implements SQLDropStatement {
private SQLExpr name;
private boolean ifExists;
public SQLDropServerStatement() {
}
public SQLDropServerStatement(String dbType) {
super (dbType);
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
}
visitor.endVisit(this);
}
public SQLExpr getName() {
return name;
}
public void setName(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.name = x;
}
@Override
public List<SQLObject> getChildren() {
List<SQLObject> children = new ArrayList<SQLObject>();
if (name != null) {
children.add(name);
}
return children;
}
public boolean isIfExists() {
return ifExists;
}
public void setIfExists(boolean ifExists) {
this.ifExists = ifExists;
}
}
@@ -15,6 +15,7 @@
*/
package com.alibaba.druid.sql.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
@@ -23,6 +24,7 @@ public class SQLDropTableSpaceStatement extends SQLStatementImpl implements SQLD
private SQLName name;
private boolean ifExists;
private SQLExpr engine;
public SQLDropTableSpaceStatement() {
@@ -44,11 +46,22 @@ public class SQLDropTableSpaceStatement extends SQLStatementImpl implements SQLD
return name;
}
public void setName(SQLName name) {
if (name != null) {
name.setParent(this);
public void setName(SQLName x) {
if (x != null) {
x.setParent(this);
}
this.name = name;
this.name = x;
}
public SQLExpr getEngine() {
return engine;
}
public void setEngine(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.engine = x;
}
public boolean isIfExists() {
@@ -0,0 +1,53 @@
/*
* 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.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLStatementImpl;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleStatementImpl;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLExprStatement extends SQLStatementImpl {
private SQLExpr expr;
public SQLExprStatement(){
}
public SQLExprStatement(SQLExpr expr){
this.expr = expr;
}
@Override
public void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, expr);
}
visitor.endVisit(this);
}
public SQLExpr getExpr() {
return expr;
}
public void setExpr(SQLExpr expr) {
this.expr = expr;
}
}
@@ -123,4 +123,47 @@ public class SQLForeignKeyImpl extends SQLConstraintImpl implements SQLForeignKe
cloneTo(x);
return x;
}
public static enum Match {
FULL("FULL"), PARTIAL("PARTIAL"), SIMPLE("SIMPLE");
public final String name;
public final String name_lcase;
Match(String name){
this.name = name;
this.name_lcase = name.toLowerCase();
}
}
public static enum On {
DELETE("DELETE"), //
UPDATE("UPDATE");
public final String name;
public final String name_lcase;
On(String name){
this.name = name;
this.name_lcase = name.toLowerCase();
}
}
public static enum Option {
RESTRICT("RESTRICT"), CASCADE("CASCADE"), SET_NULL("SET NULL"), NO_ACTION("NO ACTION");
public final String name;
public final String name_lcase;
Option(String name){
this.name = name;
this.name_lcase = name.toLowerCase();
}
public String getText() {
return name;
}
}
}
@@ -1,3 +1,18 @@
/*
* 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.ast.statement;
import com.alibaba.druid.sql.ast.SQLStatementImpl;