Search in sources :

Example 36 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.

public void test_show_procedure_status() throws Exception {
    String sql = "SHOW procedure status like '%'";
    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 LIKE '%'", output);
}
Also used : MySqlShowProcedureStatusStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowProcedureStatusStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 37 with MySqlStatementParser

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

the class DALParserTest method test_show_create_database.

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

Example 38 with MySqlStatementParser

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

the class DALParserTest method test_show_columns_1.

public void test_show_columns_1() throws Exception {
    String sql = "show columns from events where Field = 'name'";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlShowColumnsStatement show = (MySqlShowColumnsStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(show);
    Assert.assertEquals("SHOW COLUMNS FROM events WHERE Field = 'name'", output);
}
Also used : MySqlShowColumnsStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowColumnsStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 39 with MySqlStatementParser

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

the class DALParserTest method test_show_key_1.

public void test_show_key_1() throws Exception {
    String sql = "SHOW keys in tb1 in 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 40 with MySqlStatementParser

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

the class DALParserTest method test_show_engines.

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