mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
mysql parser
This commit is contained in:
@@ -34,6 +34,8 @@ import com.alibaba.druid.sql.ast.statement.SQLDropViewStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertInto;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLReleaseSavePointStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSavePointStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSetStatement;
|
||||
@@ -166,12 +168,25 @@ public class SQLStatementParser extends SQLParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("RELEASE")) {
|
||||
SQLStatement stmt = parseReleaseSavePoint();
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("SAVEPOINT")) {
|
||||
SQLStatement stmt = parseSavePoint();
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("ROLLBACK")) {
|
||||
SQLRollbackStatement stmt = parseRollback();
|
||||
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parseStatementListDialect(statementList)) {
|
||||
continue;
|
||||
}
|
||||
@@ -192,6 +207,27 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
}
|
||||
|
||||
public SQLRollbackStatement parseRollback() {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("WORK")) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
SQLRollbackStatement stmt = new SQLRollbackStatement();
|
||||
|
||||
if (identifierEquals("TO")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("SAVEPOINT")) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
stmt.setTo(this.exprParser.name());
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLUseStatement parseUse() {
|
||||
accept(Token.USE);
|
||||
SQLUseStatement stmt = new SQLUseStatement();
|
||||
@@ -206,6 +242,14 @@ public class SQLStatementParser extends SQLParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseReleaseSavePoint() {
|
||||
acceptIdentifier("RELEASE");
|
||||
acceptIdentifier("SAVEPOINT");
|
||||
SQLReleaseSavePointStatement stmt = new SQLReleaseSavePointStatement();
|
||||
stmt.setName(this.exprParser.name());
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseAlter() {
|
||||
accept(Token.ALTER);
|
||||
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
|
||||
|
||||
Reference in New Issue
Block a user