mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sql parser
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 1999-2011 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.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLDropSequenceStatement extends SQLStatementImpl implements SQLDDLStatement {
|
||||
|
||||
private SQLName name;
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, name);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(SQLName name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,13 @@ public class SQLDropTableStatement extends SQLStatementImpl implements SQLDDLSta
|
||||
|
||||
protected List<SQLExprTableSource> tableSources = new ArrayList<SQLExprTableSource>();
|
||||
|
||||
private boolean purge;
|
||||
|
||||
protected boolean cascade = false;
|
||||
protected boolean restrict = false;
|
||||
protected boolean ifExists = false;
|
||||
private boolean temporary = false;
|
||||
|
||||
public SQLDropTableStatement(){
|
||||
|
||||
}
|
||||
@@ -65,4 +72,45 @@ public class SQLDropTableStatement extends SQLStatementImpl implements SQLDDLSta
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public boolean isPurge() {
|
||||
return purge;
|
||||
}
|
||||
|
||||
public void setPurge(boolean purge) {
|
||||
this.purge = purge;
|
||||
}
|
||||
|
||||
public boolean isIfExists() {
|
||||
return ifExists;
|
||||
}
|
||||
|
||||
public void setIfExists(boolean ifExists) {
|
||||
this.ifExists = ifExists;
|
||||
}
|
||||
|
||||
public boolean isCascade() {
|
||||
return cascade;
|
||||
}
|
||||
|
||||
public void setCascade(boolean cascade) {
|
||||
this.cascade = cascade;
|
||||
}
|
||||
|
||||
public boolean isRestrict() {
|
||||
return restrict;
|
||||
}
|
||||
|
||||
public void setRestrict(boolean restrict) {
|
||||
this.restrict = restrict;
|
||||
}
|
||||
|
||||
public boolean isTemporary() {
|
||||
return temporary;
|
||||
}
|
||||
|
||||
public void setTemporary(boolean temporary) {
|
||||
this.temporary = temporary;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.alibaba.druid.sql.ast.statement;
|
||||
|
||||
/*
|
||||
* Copyright 1999-2011 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.
|
||||
*/
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLDropTriggerStatement extends SQLStatementImpl implements SQLDDLStatement {
|
||||
|
||||
private SQLName name;
|
||||
|
||||
public SQLName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(SQLName name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, name);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 1999-2011 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLDropUserStatement extends SQLStatementImpl implements SQLDDLStatement {
|
||||
|
||||
private List<SQLExpr> users = new ArrayList<SQLExpr>(2);
|
||||
|
||||
public List<SQLExpr> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(List<SQLExpr> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, users);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,10 @@ public class SQLDropViewStatement extends SQLStatementImpl implements SQLDDLStat
|
||||
|
||||
protected List<SQLExprTableSource> tableSources = new ArrayList<SQLExprTableSource>();
|
||||
|
||||
protected boolean cascade = false;
|
||||
protected boolean restrict = false;
|
||||
protected boolean ifExists = false;
|
||||
|
||||
public SQLDropViewStatement(){
|
||||
|
||||
}
|
||||
@@ -58,6 +62,14 @@ public class SQLDropViewStatement extends SQLStatementImpl implements SQLDDLStat
|
||||
tableSources.add(tableSource);
|
||||
}
|
||||
|
||||
public boolean isCascade() {
|
||||
return cascade;
|
||||
}
|
||||
|
||||
public void setCascade(boolean cascade) {
|
||||
this.cascade = cascade;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
@@ -65,4 +77,21 @@ public class SQLDropViewStatement extends SQLStatementImpl implements SQLDDLStat
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public boolean isRestrict() {
|
||||
return restrict;
|
||||
}
|
||||
|
||||
public void setRestrict(boolean restrict) {
|
||||
this.restrict = restrict;
|
||||
}
|
||||
|
||||
public boolean isIfExists() {
|
||||
return ifExists;
|
||||
}
|
||||
|
||||
public void setIfExists(boolean ifExists) {
|
||||
this.ifExists = ifExists;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,13 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLTruncateStatement extends SQLStatementImpl {
|
||||
|
||||
protected List<SQLExprTableSource> tableSources = new ArrayList<SQLExprTableSource>(2);
|
||||
protected List<SQLExprTableSource> tableSources = new ArrayList<SQLExprTableSource>(2);
|
||||
|
||||
private boolean purgeSnapshotLog = false;
|
||||
|
||||
private boolean only;
|
||||
private Boolean restartIdentity;
|
||||
private Boolean cascade;
|
||||
|
||||
public List<SQLExprTableSource> getTableSources() {
|
||||
return tableSources;
|
||||
@@ -47,4 +53,36 @@ public class SQLTruncateStatement extends SQLStatementImpl {
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public boolean isPurgeSnapshotLog() {
|
||||
return purgeSnapshotLog;
|
||||
}
|
||||
|
||||
public void setPurgeSnapshotLog(boolean purgeSnapshotLog) {
|
||||
this.purgeSnapshotLog = purgeSnapshotLog;
|
||||
}
|
||||
|
||||
public boolean isOnly() {
|
||||
return only;
|
||||
}
|
||||
|
||||
public void setOnly(boolean only) {
|
||||
this.only = only;
|
||||
}
|
||||
|
||||
public Boolean getRestartIdentity() {
|
||||
return restartIdentity;
|
||||
}
|
||||
|
||||
public void setRestartIdentity(Boolean restartIdentity) {
|
||||
this.restartIdentity = restartIdentity;
|
||||
}
|
||||
|
||||
public Boolean getCascade() {
|
||||
return cascade;
|
||||
}
|
||||
|
||||
public void setCascade(Boolean cascade) {
|
||||
this.cascade = cascade;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user