mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
mysql parser
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.alibaba.druid.sql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLReleaseSavePointStatement extends SQLStatementImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private SQLExpr name;
|
||||
|
||||
public SQLExpr getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(SQLExpr name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, name);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
+31
-10
@@ -15,17 +15,24 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class MySqlRollbackStatement extends MySqlStatementImpl {
|
||||
public class MySqlRollbackStatement extends SQLRollbackStatement implements MySqlStatement {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private boolean work = false;
|
||||
|
||||
private Boolean chain;
|
||||
private Boolean release;
|
||||
|
||||
private SQLExpr force;
|
||||
|
||||
public MySqlRollbackStatement(){
|
||||
|
||||
}
|
||||
|
||||
public Boolean getChain() {
|
||||
return chain;
|
||||
}
|
||||
@@ -42,17 +49,31 @@ public class MySqlRollbackStatement extends MySqlStatementImpl {
|
||||
this.release = release;
|
||||
}
|
||||
|
||||
public boolean isWork() {
|
||||
return work;
|
||||
}
|
||||
|
||||
public void setWork(boolean work) {
|
||||
this.work = work;
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor instanceof MySqlASTVisitor) {
|
||||
accept0((MySqlASTVisitor) visitor);
|
||||
} else {
|
||||
throw new IllegalArgumentException("not support visitor type : " + visitor.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, getTo());
|
||||
acceptChild(visitor, getForce());
|
||||
}
|
||||
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLExpr getForce() {
|
||||
return force;
|
||||
}
|
||||
|
||||
public void setForce(SQLExpr force) {
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1329,14 +1329,14 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public MySqlRollbackStatement parseRollback() throws ParserException {
|
||||
@Override
|
||||
public MySqlRollbackStatement parseRollback() {
|
||||
acceptIdentifier("ROLLBACK");
|
||||
|
||||
MySqlRollbackStatement stmt = new MySqlRollbackStatement();
|
||||
|
||||
if (identifierEquals("WORK")) {
|
||||
lexer.nextToken();
|
||||
stmt.setWork(true);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.AND) {
|
||||
@@ -1350,6 +1350,16 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
stmt.setChain(Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (identifierEquals("TO")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("SAVEPOINT")) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
stmt.setTo(this.exprParser.name());
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLUpdateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlIgnoreIndexHint;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlKey;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlPrimaryKey;
|
||||
@@ -165,7 +164,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
if (x.isHignPriority()) {
|
||||
print("HIGH_PRIORITY ");
|
||||
}
|
||||
|
||||
|
||||
if (x.isStraightJoin()) {
|
||||
print("STRAIGHT_JOIN ");
|
||||
}
|
||||
@@ -1028,10 +1027,6 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
public boolean visit(MySqlRollbackStatement x) {
|
||||
print("ROLLBACK");
|
||||
|
||||
if (x.isWork()) {
|
||||
print(" WORK");
|
||||
}
|
||||
|
||||
if (x.getChain() != null) {
|
||||
if (x.getChain().booleanValue()) {
|
||||
print(" AND CHAIN");
|
||||
@@ -1048,6 +1043,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
}
|
||||
|
||||
if (x.getTo() != null) {
|
||||
print(" TO ");
|
||||
x.getTo().accept(this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1465,11 +1465,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
@Override
|
||||
public boolean visit(MySqlUpdateStatement x) {
|
||||
print("UPDATE ");
|
||||
|
||||
|
||||
if (x.isLowPriority()) {
|
||||
print("LOW_PRIORITY ");
|
||||
}
|
||||
|
||||
|
||||
if (x.isIgnore()) {
|
||||
print("IGNORE ");
|
||||
}
|
||||
@@ -1491,12 +1491,12 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
x.getWhere().setParent(x);
|
||||
x.getWhere().accept(this);
|
||||
}
|
||||
|
||||
|
||||
if (x.getOrderBy() != null) {
|
||||
println();
|
||||
x.getOrderBy().accept(this);
|
||||
}
|
||||
|
||||
|
||||
if (x.getLimit() != null) {
|
||||
println();
|
||||
x.getLimit().accept(this);
|
||||
@@ -2404,9 +2404,9 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlUseIndexHint x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlIgnoreIndexHint x) {
|
||||
print("IGNORE INDEX ");
|
||||
@@ -2420,10 +2420,10 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(')');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlIgnoreIndexHint x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean visit(SQLExprTableSource x) {
|
||||
@@ -2433,7 +2433,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(' ');
|
||||
print(x.getAlias());
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < x.getHints().size(); ++i) {
|
||||
print(' ');
|
||||
x.getHints().get(i).accept(this);
|
||||
|
||||
@@ -127,7 +127,6 @@ public class OracleLexer extends Lexer {
|
||||
map.put("ELSE", Token.ELSE);
|
||||
map.put("GOTO", Token.GOTO);
|
||||
map.put("COMMIT", Token.COMMIT);
|
||||
map.put("ROLLBACK", Token.ROLLBACK);
|
||||
map.put("SAVEPOINT", Token.SAVEPOINT);
|
||||
map.put("CROSS", Token.CROSS);
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLConstaint;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDropTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertInto;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelect;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
||||
@@ -383,20 +382,6 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.ROLLBACK) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLRollbackStatement stmt = new SQLRollbackStatement();
|
||||
|
||||
if (identifierEquals("TO")) {
|
||||
lexer.nextToken();
|
||||
stmt.setTo(this.exprParser.name());
|
||||
}
|
||||
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.SAVEPOINT) {
|
||||
lexer.nextToken();
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.visitor;
|
||||
|
||||
import com.alibaba.druid.sql.ast.expr.SQLObjectCreateExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleHint;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleOrderBy;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.clause.CycleClause;
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
package com.alibaba.druid.sql.dialect.oracle.visitor;
|
||||
|
||||
import com.alibaba.druid.sql.ast.expr.SQLObjectCreateExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleHint;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleOrderBy;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.clause.CycleClause;
|
||||
|
||||
@@ -34,8 +34,8 @@ import com.alibaba.druid.sql.ast.statement.SQLAlterTableItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource.JoinType;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelect;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.oracle.ast.OracleHint;
|
||||
|
||||
-1
@@ -16,7 +16,6 @@ import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelect;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -160,7 +160,6 @@ public enum Token {
|
||||
LOOP("LOOP"),
|
||||
GOTO("GOTO"),
|
||||
COMMIT("COMMIT"),
|
||||
ROLLBACK("ROLLBACK"),
|
||||
SAVEPOINT("SAVEPOINT"),
|
||||
CROSS("CROSS"),
|
||||
|
||||
|
||||
@@ -69,11 +69,12 @@ import com.alibaba.druid.sql.ast.statement.SQLDropTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDropViewStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLRollbackStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSavePointStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource.JoinType;
|
||||
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.SQLSelect;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectGroupByClause;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectItem;
|
||||
@@ -1072,6 +1073,13 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLReleaseSavePointStatement x) {
|
||||
print("RELEASE SAVEPOINT ");
|
||||
x.getName().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLRollbackStatement x) {
|
||||
print("ROLLBACK");
|
||||
|
||||
@@ -66,6 +66,7 @@ import com.alibaba.druid.sql.ast.statement.SQLDropViewStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource;
|
||||
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.SQLSelect;
|
||||
@@ -365,4 +366,8 @@ public interface SQLASTVisitor {
|
||||
boolean visit(SQLRollbackStatement x);
|
||||
|
||||
void endVisit(SQLRollbackStatement x);
|
||||
|
||||
boolean visit(SQLReleaseSavePointStatement x);
|
||||
|
||||
void endVisit(SQLReleaseSavePointStatement x);
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource;
|
||||
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.SQLSelect;
|
||||
@@ -650,4 +651,13 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
|
||||
public void endVisit(SQLRollbackStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLReleaseSavePointStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(SQLReleaseSavePointStatement x) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
||||
public class MTSParserTest extends TestCase {
|
||||
|
||||
public void test_mts_0() throws Exception {
|
||||
String sql = " savepoint xx";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
@@ -18,4 +18,58 @@ public class MTSParserTest extends TestCase {
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("SAVEPOINT xx", output);
|
||||
}
|
||||
|
||||
public void test_mts_1() throws Exception {
|
||||
String sql = " savepoint SAVEPOINT";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("SAVEPOINT SAVEPOINT", output);
|
||||
}
|
||||
|
||||
public void test_mts_2() throws Exception {
|
||||
String sql = " savepoInt `select`";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("SAVEPOINT `select`", output);
|
||||
}
|
||||
|
||||
public void test_mts_3() throws Exception {
|
||||
String sql = "Release sAVEPOINT xx ";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("RELEASE SAVEPOINT xx", output);
|
||||
}
|
||||
|
||||
public void test_rollback_0() throws Exception {
|
||||
String sql = "rollBack to x1";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("ROLLBACK TO x1", output);
|
||||
}
|
||||
|
||||
public void test_rollback_1() throws Exception {
|
||||
String sql = "rollBack work to x1";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("ROLLBACK TO x1", output);
|
||||
}
|
||||
|
||||
public void test_rollback_2() throws Exception {
|
||||
String sql = "rollBack work to savepoint x1";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("ROLLBACK TO x1", output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user