mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
兼容lock table 和unlock table语法
This commit is contained in:
@@ -675,8 +675,16 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
if (lexer.token() == Token.LOCK) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier(TABLES);
|
||||
|
||||
String val = lexer.stringVal();
|
||||
boolean isLockTables = TABLES.equalsIgnoreCase(val) && lexer.token() == Token.IDENTIFIER;
|
||||
boolean isLockTable = "TABLE".equalsIgnoreCase(val) && lexer.token() == Token.TABLE;
|
||||
if (isLockTables || isLockTable) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
setErrorEndPos(lexer.pos());
|
||||
throw new ParserException("syntax error, expect TABLES or TABLE, actual " + lexer.token());
|
||||
}
|
||||
|
||||
MySqlLockTableStatement stmt = new MySqlLockTableStatement();
|
||||
stmt.setTableSource(this.exprParser.name());
|
||||
|
||||
@@ -694,6 +702,8 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier(WRITE);
|
||||
stmt.setLockType(LockType.LOW_PRIORITY_WRITE);
|
||||
} else {
|
||||
throw new ParserException("syntax error, expect READ or WRITE, actual " + lexer.token());
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.HINT) {
|
||||
@@ -705,8 +715,16 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
if (identifierEquals("UNLOCK")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier(TABLES);
|
||||
String val = lexer.stringVal();
|
||||
boolean isUnLockTables = TABLES.equalsIgnoreCase(val) && lexer.token() == Token.IDENTIFIER;
|
||||
boolean isUnLockTable = "TABLE".equalsIgnoreCase(val) && lexer.token() == Token.TABLE;
|
||||
statementList.add(new MySqlUnlockTablesStatement());
|
||||
if (isUnLockTables || isUnLockTable) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
setErrorEndPos(lexer.pos());
|
||||
throw new ParserException("syntax error, expect TABLES or TABLE, actual " + lexer.token());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user