mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
db2 sql parser support select_for_update. fixed issue #1322
This commit is contained in:
@@ -33,7 +33,10 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
protected SQLExpr where;
|
||||
protected SQLSelectGroupByClause groupBy;
|
||||
protected SQLOrderBy orderBy;
|
||||
protected boolean parenthesized = false;
|
||||
protected boolean parenthesized = false;
|
||||
protected boolean forUpdate = false;
|
||||
protected boolean noWait = false;
|
||||
protected SQLExpr waitTime;
|
||||
|
||||
public SQLSelectQueryBlock(){
|
||||
|
||||
@@ -117,6 +120,30 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
public void setParenthesized(boolean parenthesized) {
|
||||
this.parenthesized = parenthesized;
|
||||
}
|
||||
|
||||
public boolean isForUpdate() {
|
||||
return forUpdate;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
|
||||
@@ -116,9 +116,15 @@ public class DB2SelectParser extends SQLSelectParser {
|
||||
|
||||
if (lexer.token() == Token.FOR) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("READ");
|
||||
accept(Token.ONLY);
|
||||
queryBlock.setForReadOnly(true);
|
||||
|
||||
if (lexer.token() == Token.UPDATE) {
|
||||
queryBlock.setForUpdate(true);
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
acceptIdentifier("READ");
|
||||
accept(Token.ONLY);
|
||||
queryBlock.setForReadOnly(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.OPTIMIZE) {
|
||||
|
||||
@@ -58,6 +58,9 @@ public class DB2OutputVisitor extends SQLASTOutputVisitor implements DB2ASTVisit
|
||||
if (x.isForReadOnly()) {
|
||||
println();
|
||||
print0(ucase ? "FOR READ ONLY" : "for read only");
|
||||
} else if (x.isForUpdate()) {
|
||||
println();
|
||||
print0(ucase ? "FOR UPDATE" : "for update");
|
||||
}
|
||||
|
||||
if (x.getIsolation() != null) {
|
||||
|
||||
-28
@@ -22,7 +22,6 @@ import com.alibaba.druid.sql.ast.SQLCommentHint;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObjectImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLOrderBy;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
@@ -44,9 +43,6 @@ public class MySqlSelectQueryBlock extends SQLSelectQueryBlock implements MySqlO
|
||||
private SQLName procedureName;
|
||||
private List<SQLExpr> procedureArgumentList;
|
||||
|
||||
private boolean forUpdate = false;
|
||||
private boolean noWait = false;
|
||||
private SQLExpr waitTime;
|
||||
private boolean lockInShareMode = false;
|
||||
|
||||
private List<SQLCommentHint> hints;
|
||||
@@ -74,30 +70,6 @@ public class MySqlSelectQueryBlock extends SQLSelectQueryBlock implements MySqlO
|
||||
this.hints = hints;
|
||||
}
|
||||
|
||||
public boolean isForUpdate() {
|
||||
return forUpdate;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user