Search in sources :

Example 31 with MySqlStatementParser

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

the class DALParserTest method test_show_events_2.

public void test_show_events_2() throws Exception {
    String sql = "SHOW EVENTS in x";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowEventsStatement show = (MySqlShowEventsStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW EVENTS FROM x", output);
}
Also used : MySqlShowEventsStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEventsStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 32 with MySqlStatementParser

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

the class DALParserTest method test_show_engine_2.

public void test_show_engine_2() throws Exception {
    String sql = "SHOW ENGINE INNODB mutex";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowEngineStatement show = (MySqlShowEngineStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW ENGINE INNODB MUTEX", output);
}
Also used : MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser) MySqlShowEngineStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEngineStatement)

Example 33 with MySqlStatementParser

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

the class DALParserTest method test_show_create_table.

public void test_show_create_table() throws Exception {
    String sql = "SHOW CREATE table x";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowCreateTableStatement show = (MySqlShowCreateTableStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW CREATE TABLE x", output);
}
Also used : MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser) MySqlShowCreateTableStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowCreateTableStatement)

Example 34 with MySqlStatementParser

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

the class DALParserTest method test_show_binaryLogs.

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

Example 35 with MySqlStatementParser

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

the class DALParserTest method test_show_events_1.

public void test_show_events_1() throws Exception {
    String sql = "SHOW EVENTS from x";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowEventsStatement show = (MySqlShowEventsStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW EVENTS FROM x", output);
}
Also used : MySqlShowEventsStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEventsStatement) 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