Search in sources :

Example 1 with MTSSavepointStatement

use of com.alibaba.cobar.parser.ast.stmt.mts.MTSSavepointStatement in project cobar by alibaba.

the class MySQLMTSParser method savepoint.

/**
     * first token <code>SAVEPOINT</code> is scanned but not yet consumed
     */
public MTSSavepointStatement savepoint() throws SQLSyntaxErrorException {
    // matchIdentifier("SAVEPOINT"); // for performance issue, change to
    // follow:
    lexer.nextToken();
    Identifier id = identifier();
    match(EOF);
    return new MTSSavepointStatement(id);
}
Also used : MTSSavepointStatement(com.alibaba.cobar.parser.ast.stmt.mts.MTSSavepointStatement) Identifier(com.alibaba.cobar.parser.ast.expression.primary.Identifier)

Example 2 with MTSSavepointStatement

use of com.alibaba.cobar.parser.ast.stmt.mts.MTSSavepointStatement in project cobar by alibaba.

the class MySQLMTSParserTest method testSavepint.

public void testSavepint() throws SQLSyntaxErrorException {
    String sql = "  savepoint 123e123e";
    MySQLMTSParser parser = new MySQLMTSParser(new MySQLLexer(sql));
    MTSSavepointStatement savepoint = parser.savepoint();
    String output = output2MySQL(savepoint, sql);
    Assert.assertEquals("SAVEPOINT 123e123e", output);
    Assert.assertEquals("123e123e", savepoint.getSavepoint().getIdText());
    sql = "  savepoint SAVEPOINT";
    parser = new MySQLMTSParser(new MySQLLexer(sql));
    savepoint = parser.savepoint();
    output = output2MySQL(savepoint, sql);
    Assert.assertEquals("SAVEPOINT SAVEPOINT", output);
    Assert.assertEquals("SAVEPOINT", savepoint.getSavepoint().getIdText());
    sql = "  savepoInt `select`";
    parser = new MySQLMTSParser(new MySQLLexer(sql));
    savepoint = parser.savepoint();
    output = output2MySQL(savepoint, sql);
    Assert.assertEquals("SAVEPOINT `select`", output);
    Assert.assertEquals("`select`", savepoint.getSavepoint().getIdText());
}
Also used : MySQLLexer(com.alibaba.cobar.parser.recognizer.mysql.lexer.MySQLLexer) MTSSavepointStatement(com.alibaba.cobar.parser.ast.stmt.mts.MTSSavepointStatement)

Aggregations

MTSSavepointStatement (com.alibaba.cobar.parser.ast.stmt.mts.MTSSavepointStatement)2 Identifier (com.alibaba.cobar.parser.ast.expression.primary.Identifier)1 MySQLLexer (com.alibaba.cobar.parser.recognizer.mysql.lexer.MySQLLexer)1