mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sqlwall: 'hints' and 'start transaction'
This commit is contained in:
+13
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLCommentHint;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
@@ -24,6 +27,8 @@ public class MySqlLockTableStatement extends MySqlStatementImpl {
|
||||
private SQLExprTableSource tableSource;
|
||||
|
||||
private LockType lockType;
|
||||
|
||||
private List<SQLCommentHint> hints;
|
||||
|
||||
public SQLExprTableSource getTableSource() {
|
||||
return tableSource;
|
||||
@@ -64,4 +69,12 @@ public class MySqlLockTableStatement extends MySqlStatementImpl {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public List<SQLCommentHint> getHints() {
|
||||
return hints;
|
||||
}
|
||||
|
||||
public void setHints(List<SQLCommentHint> hints) {
|
||||
this.hints = hints;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-2
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLCommentHint;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
@@ -22,8 +25,9 @@ import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlShowIndexesStatement extends MySqlStatementImpl implements MySqlShowStatement {
|
||||
|
||||
private SQLName table;
|
||||
private SQLName database;
|
||||
private SQLName table;
|
||||
private SQLName database;
|
||||
private List<SQLCommentHint> hints;
|
||||
|
||||
public SQLName getTable() {
|
||||
return table;
|
||||
@@ -54,4 +58,12 @@ public class MySqlShowIndexesStatement extends MySqlStatementImpl implements MyS
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLCommentHint> getHints() {
|
||||
return hints;
|
||||
}
|
||||
|
||||
public void setHints(List<SQLCommentHint> hints) {
|
||||
this.hints = hints;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-3
@@ -15,14 +15,19 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLCommentHint;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlStartTransactionStatement extends MySqlStatementImpl {
|
||||
|
||||
private boolean consistentSnapshot = false;
|
||||
private boolean consistentSnapshot = false;
|
||||
|
||||
private boolean begin = false;
|
||||
private boolean work = false;
|
||||
private boolean begin = false;
|
||||
private boolean work = false;
|
||||
|
||||
private List<SQLCommentHint> hints;
|
||||
|
||||
public boolean isConsistentSnapshot() {
|
||||
return consistentSnapshot;
|
||||
@@ -53,4 +58,12 @@ public class MySqlStartTransactionStatement extends MySqlStatementImpl {
|
||||
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public List<SQLCommentHint> getHints() {
|
||||
return hints;
|
||||
}
|
||||
|
||||
public void setHints(List<SQLCommentHint> hints) {
|
||||
this.hints = hints;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -654,6 +654,9 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
stmt.setLockType(LockType.LOW_PRIORITY_WRITE);
|
||||
}
|
||||
|
||||
if(lexer.token() == Token.HINT) {
|
||||
stmt.setHints(this.exprParser.parseHints());
|
||||
}
|
||||
statementList.add(stmt);
|
||||
return true;
|
||||
}
|
||||
@@ -1101,6 +1104,10 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
stmt.setDatabase(database);
|
||||
}
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.HINT) {
|
||||
stmt.setHints(this.exprParser.parseHints());
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -1492,6 +1499,10 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
stmt.setWork(true);
|
||||
}
|
||||
}
|
||||
|
||||
if(lexer.token() == Token.HINT) {
|
||||
stmt.setHints(this.exprParser.parseHints());
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -2123,6 +2134,10 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
SQLVariantRefExpr varRef = (SQLVariantRefExpr) stmt.getItems().get(0).getTarget();
|
||||
varRef.setGlobal(true);
|
||||
}
|
||||
|
||||
if(lexer.token() == Token.HINT) {
|
||||
stmt.setHints(this.exprParser.parseHints());
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@@ -1118,6 +1118,14 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
if (x.isConsistentSnapshot()) {
|
||||
print(" WITH CONSISTENT SNAPSHOT");
|
||||
}
|
||||
|
||||
List<SQLCommentHint> hints = x.getHints();
|
||||
if (hints != null && !hints.isEmpty()) {
|
||||
print(" ");
|
||||
for (SQLCommentHint hint : hints) {
|
||||
hint.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (x.isBegin()) {
|
||||
print(" BEGIN");
|
||||
@@ -2130,6 +2138,14 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
x.getTable().accept(this);
|
||||
}
|
||||
|
||||
List<SQLCommentHint> hints = x.getHints();
|
||||
if (hints != null && !hints.isEmpty()) {
|
||||
print(" ");
|
||||
for (SQLCommentHint hint : hints) {
|
||||
hint.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -2664,6 +2680,14 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(' ');
|
||||
print(x.getLockType().name);
|
||||
}
|
||||
|
||||
List<SQLCommentHint> hints = x.getHints();
|
||||
if (hints != null && !hints.isEmpty()) {
|
||||
print(" ");
|
||||
for (SQLCommentHint hint : hints) {
|
||||
hint.accept(this);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user