Search in sources :

Example 26 with MySqlStatementParser

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

the class DALParserTest method test_show_create_function.

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

Example 27 with MySqlStatementParser

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

the class DALParserTest method test_show_index_1.

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

Example 28 with MySqlStatementParser

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

the class DALParserTest method test_show_function_code.

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

Example 29 with MySqlStatementParser

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

the class DALParserTest method testSetTxn_1.

public void testSetTxn_1() throws Exception {
    String sql = "SET global transaction ISOLATION LEVEL READ COMMITTED";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlSetTransactionStatement set = (MySqlSetTransactionStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(set);
    Assert.assertEquals("SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED", output);
}
Also used : MySqlSetTransactionStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetTransactionStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)

Example 30 with MySqlStatementParser

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

the class DALParserTest method testSetTxn_0.

public void testSetTxn_0() throws Exception {
    String sql = "SET transaction ISOLATION LEVEL READ UNCOMMITTED";
    MySqlStatementParser parser = new MySqlStatementParser(sql);
    MySqlSetTransactionStatement set = (MySqlSetTransactionStatement) parser.parseStatementList().get(0);
    parser.match(Token.EOF);
    String output = SQLUtils.toMySqlString(set);
    Assert.assertEquals("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED", output);
}
Also used : MySqlSetTransactionStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSetTransactionStatement) 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