mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor sql parser.
This commit is contained in:
-78
@@ -1,78 +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.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class MySqlRollbackStatement extends SQLRollbackStatement implements MySqlStatement {
|
||||
|
||||
private Boolean chain;
|
||||
private Boolean release;
|
||||
|
||||
private SQLExpr force;
|
||||
|
||||
public MySqlRollbackStatement(){
|
||||
super (JdbcConstants.MYSQL);
|
||||
}
|
||||
|
||||
public Boolean getChain() {
|
||||
return chain;
|
||||
}
|
||||
|
||||
public void setChain(Boolean chain) {
|
||||
this.chain = chain;
|
||||
}
|
||||
|
||||
public Boolean getRelease() {
|
||||
return release;
|
||||
}
|
||||
|
||||
public void setRelease(Boolean release) {
|
||||
this.release = release;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor instanceof MySqlASTVisitor) {
|
||||
accept0((MySqlASTVisitor) visitor);
|
||||
} else {
|
||||
throw new IllegalArgumentException("not support visitor type : " + visitor.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, getTo());
|
||||
acceptChild(visitor, getForce());
|
||||
}
|
||||
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLExpr getForce() {
|
||||
return force;
|
||||
}
|
||||
|
||||
public void setForce(SQLExpr force) {
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -79,7 +79,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPrepareStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlResetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetCharSetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetNamesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetPasswordStatement;
|
||||
@@ -1644,10 +1643,10 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MySqlRollbackStatement parseRollback() {
|
||||
public SQLRollbackStatement parseRollback() {
|
||||
acceptIdentifier("ROLLBACK");
|
||||
|
||||
MySqlRollbackStatement stmt = new MySqlRollbackStatement();
|
||||
SQLRollbackStatement stmt = new SQLRollbackStatement();
|
||||
|
||||
if (identifierEquals("WORK")) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -68,7 +68,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPrepareStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlResetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetCharSetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetNamesStatement;
|
||||
@@ -190,10 +189,6 @@ public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
|
||||
boolean visit(MySqlReplaceStatement x);
|
||||
|
||||
void endVisit(MySqlRollbackStatement x);
|
||||
|
||||
boolean visit(MySqlRollbackStatement x);
|
||||
|
||||
void endVisit(MySqlShowColumnsStatement x);
|
||||
|
||||
boolean visit(MySqlShowColumnsStatement x);
|
||||
|
||||
@@ -70,7 +70,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPrepareStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlResetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetCharSetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetNamesStatement;
|
||||
@@ -280,17 +279,6 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements MySq
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlRollbackStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlRollbackStatement x) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowColumnsStatement x) {
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPrepareStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlResetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetCharSetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetNamesStatement;
|
||||
@@ -1222,13 +1221,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlRollbackStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlRollbackStatement x) {
|
||||
public boolean visit(SQLRollbackStatement x) {
|
||||
print0(ucase ? "ROLLBACK" : "rollback");
|
||||
|
||||
if (x.getChain() != null) {
|
||||
|
||||
@@ -85,7 +85,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlPrepareStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlResetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetCharSetStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetNamesStatement;
|
||||
@@ -409,17 +408,6 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlRollbackStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlRollbackStatement x) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowColumnsStatement x) {
|
||||
|
||||
|
||||
@@ -91,6 +91,25 @@ public class OracleSelectJoin extends SQLJoinTableSource implements OracleSelect
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
OracleSelectJoin that = (OracleSelectJoin) o;
|
||||
|
||||
if (pivot != null ? !pivot.equals(that.pivot) : that.pivot != null) return false;
|
||||
return flashback != null ? flashback.equals(that.flashback) : that.flashback == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = pivot != null ? pivot.hashCode() : 0;
|
||||
result = 31 * result + (flashback != null ? flashback.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString () {
|
||||
return SQLUtils.toOracleString(this);
|
||||
}
|
||||
|
||||
+27
-1
@@ -110,7 +110,33 @@ public class OracleSelectTableReference extends SQLExprTableSource implements Or
|
||||
buf.append(this.alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
OracleSelectTableReference that = (OracleSelectTableReference) o;
|
||||
|
||||
if (only != that.only) return false;
|
||||
if (pivot != null ? !pivot.equals(that.pivot) : that.pivot != null) return false;
|
||||
if (partition != null ? !partition.equals(that.partition) : that.partition != null) return false;
|
||||
if (sampleClause != null ? !sampleClause.equals(that.sampleClause) : that.sampleClause != null) return false;
|
||||
return flashback != null ? flashback.equals(that.flashback) : that.flashback == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (only ? 1 : 0);
|
||||
result = 31 * result + (pivot != null ? pivot.hashCode() : 0);
|
||||
result = 31 * result + (partition != null ? partition.hashCode() : 0);
|
||||
result = 31 * result + (sampleClause != null ? sampleClause.hashCode() : 0);
|
||||
result = 31 * result + (flashback != null ? flashback.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString () {
|
||||
return SQLUtils.toOracleString(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user