mysql sql parser support wait_n & no_wat

This commit is contained in:
高铁
2016-06-25 12:13:08 +08:00
parent b08480b88f
commit 59cc507f42
5 changed files with 177 additions and 0 deletions
@@ -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()) {