Search in sources :

Example 51 with MySqlStatementParser

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

the class DALParserTest method test_show_slaveHosts.

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

Example 52 with MySqlStatementParser

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

the class DALParserTest method test_show_procedure_status_2.

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

Example 53 with MySqlStatementParser

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

the class DALParserTest method test_show_engine.

public void test_show_engine() throws Exception {
    String sql = "SHOW ENGINE INNODB STATUS";
    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 STATUS", output);
}
Also used : MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser) MySqlShowEngineStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowEngineStatement)

Example 54 with MySqlStatementParser

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

the class DALParserTest method test_show_key.

public void test_show_key() throws Exception {
    String sql = "SHOW keys from tb1 from db";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowKeysStatement show = (MySqlShowKeysStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW KEYS FROM db.tb1", output);
}
Also used : MySqlShowKeysStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowKeysStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 55 with MySqlStatementParser

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

the class DALParserTest method test_open_tables_1.

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