Search in sources :

Example 6 with SQLSetStatement

use of com.alibaba.druid.sql.ast.statement.SQLSetStatement in project druid by alibaba.

the class DALParserTest method testSet_4.

public void testSet_4() throws Exception {
    String sql = "SET GLOBAL var1=1, SESSION var2:=2";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    SQLSetStatement set = (SQLSetStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(set);
    Assert.assertEquals("SET @@global.var1 = 1, @@var2 = 2", output);
}
Also used : SQLSetStatement(com.alibaba.druid.sql.ast.statement.SQLSetStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 7 with SQLSetStatement

use of com.alibaba.druid.sql.ast.statement.SQLSetStatement in project druid by alibaba.

the class DALParserTest method testSet_5.

public void testSet_5() throws Exception {
    String sql = "SET @@GLOBAL. var1=1, SESSION var2:=2";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    SQLSetStatement set = (SQLSetStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(set);
    Assert.assertEquals("SET @@global.var1 = 1, @@var2 = 2", output);
}
Also used : SQLSetStatement(com.alibaba.druid.sql.ast.statement.SQLSetStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Aggregations

SQLSetStatement (com.alibaba.druid.sql.ast.statement.SQLSetStatement)7 MySqlStatementParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)5 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)1 SQLName (com.alibaba.druid.sql.ast.SQLName)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLExprTableSource (com.alibaba.druid.sql.ast.statement.SQLExprTableSource)1 OdpsSetLabelStatement (com.alibaba.druid.sql.dialect.odps.ast.OdpsSetLabelStatement)1 SQLASTOutputVisitor (com.alibaba.druid.sql.visitor.SQLASTOutputVisitor)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1