mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
mysql sql parser support wait_n & no_wat
This commit is contained in:
+18
@@ -47,6 +47,8 @@ public class MySqlSelectQueryBlock extends SQLSelectQueryBlock implements MySqlO
|
||||
private List<SQLExpr> procedureArgumentList;
|
||||
|
||||
private boolean forUpdate = false;
|
||||
private boolean noWait = false;
|
||||
private SQLExpr waitTime;
|
||||
private boolean lockInShareMode = false;
|
||||
|
||||
private List<SQLCommentHint> hints;
|
||||
@@ -81,6 +83,22 @@ public class MySqlSelectQueryBlock extends SQLSelectQueryBlock implements MySqlO
|
||||
public void setForUpdate(boolean forUpdate) {
|
||||
this.forUpdate = forUpdate;
|
||||
}
|
||||
|
||||
public boolean isNoWait() {
|
||||
return noWait;
|
||||
}
|
||||
|
||||
public void setNoWait(boolean noWait) {
|
||||
this.noWait = noWait;
|
||||
}
|
||||
|
||||
public SQLExpr getWaitTime() {
|
||||
return waitTime;
|
||||
}
|
||||
|
||||
public void setWaitTime(SQLExpr waitTime) {
|
||||
this.waitTime = waitTime;
|
||||
}
|
||||
|
||||
public boolean isLockInShareMode() {
|
||||
return lockInShareMode;
|
||||
|
||||
@@ -179,6 +179,15 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
accept(Token.UPDATE);
|
||||
|
||||
queryBlock.setForUpdate(true);
|
||||
|
||||
if (identifierEquals("NO_WAIT")) {
|
||||
lexer.nextToken();
|
||||
queryBlock.setNoWait(true);
|
||||
} else if (identifierEquals("WAIT")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr waitTime = this.exprParser.primary();
|
||||
queryBlock.setWaitTime(waitTime);
|
||||
}
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LOCK) {
|
||||
|
||||
@@ -287,6 +287,12 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
if (x.isForUpdate()) {
|
||||
println();
|
||||
print0(ucase ? "FOR UPDATE" : "for update");
|
||||
if (x.isNoWait()) {
|
||||
print0(ucase ? " NO_WAIT" : " no_wait");
|
||||
} else if (x.getWaitTime() != null) {
|
||||
print0(ucase ? " WAIT " : " wait ");
|
||||
x.getWaitTime().accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (x.isLockInShareMode()) {
|
||||
|
||||
Reference in New Issue
Block a user