Search in sources :

Example 91 with MySqlStatementParser

use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser in project druid by alibaba.

the class DALParserTest method testSet_3.

public void testSet_3() throws Exception {
    String sql = "SET @usrVar1 := ?, @@`var2` =1, @@var3:=?, @'var\\'3'=?";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    SQLSetStatement set = (SQLSetStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(set);
    Assert.assertEquals("SET @usrVar1 = ?, @@`var2` = 1, @@var3 = ?, @'var\\'3' = ?", output);
}
Also used : SQLSetStatement(com.alibaba.druid.sql.ast.statement.SQLSetStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 92 with MySqlStatementParser

use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser in project druid by alibaba.

the class DALParserTest method test_show_databases_2.

public void test_show_databases_2() throws Exception {
    String sql = "SHOW DATABASES WHERE `Database` = 'mysql'";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowDatabasesStatement show = (MySqlShowDatabasesStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW DATABASES WHERE `Database` = 'mysql'", output);
}
Also used : MySqlShowDatabasesStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowDatabasesStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 93 with MySqlStatementParser

use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser in project druid by alibaba.

the class DALParserTest method test_show_status.

public void test_show_status() throws Exception {
    String sql = "SHOW STATUS LIKE 'Key%'";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowStatusStatement show = (MySqlShowStatusStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW STATUS LIKE 'Key%'", output);
}
Also used : MySqlShowStatusStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 94 with MySqlStatementParser

use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser in project druid by alibaba.

the class DALParserTest method test_show_function_status_2.

public void test_show_function_status_2() throws Exception {
    String sql = "SHOW function status ";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowFunctionStatusStatement show = (MySqlShowFunctionStatusStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW FUNCTION STATUS", output);
}
Also used : MySqlShowFunctionStatusStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowFunctionStatusStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 95 with MySqlStatementParser

use of com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser in project druid by alibaba.

the class DALParserTest method test_show_relayLogEvents_1.

public void test_show_relayLogEvents_1() throws Exception {
    String sql = "SHOW RELAYLOG EVENTS IN 'x' from 3 limit 5,6";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowRelayLogEventsStatement show = (MySqlShowRelayLogEventsStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW RELAYLOG EVENTS IN 'x' FROM 3 LIMIT 5, 6", output);
}
Also used : MySqlShowRelayLogEventsStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowRelayLogEventsStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Aggregations

MySqlStatementParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)1025 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)915 SQLStatementParser (com.alibaba.druid.sql.parser.SQLStatementParser)382 MySqlSchemaStatVisitor (com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor)343 Column (com.alibaba.druid.stat.TableStat.Column)73 Test (org.junit.Test)30 MysqlTest (com.alibaba.druid.sql.MysqlTest)29 MySqlOutputVisitor (com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor)20 MySqlInsertStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement)19 MySqlSelectQueryBlock (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock)18 SQLSelectStatement (com.alibaba.druid.sql.ast.statement.SQLSelectStatement)17 SQLSelect (com.alibaba.druid.sql.ast.statement.SQLSelect)16 SchemaStatVisitor (com.alibaba.druid.sql.visitor.SchemaStatVisitor)9 TableStat (com.alibaba.druid.stat.TableStat)9 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)8 SQLUtils (com.alibaba.druid.sql.SQLUtils)6 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)5 SQLInsertStatement (com.alibaba.druid.sql.ast.statement.SQLInsertStatement)5 SQLSetStatement (com.alibaba.druid.sql.ast.statement.SQLSetStatement)5 MySqlCreateTableStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement)5