mysql parser show

This commit is contained in:
温少
2012-05-16 12:58:32 +08:00
parent 009a426ce9
commit 35ee96c6ed
9 changed files with 303 additions and 7 deletions
@@ -46,6 +46,9 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowProcedureStatu
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowProcessListStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowProfileStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowProfilesStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowRelayLogEventsStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowSlaveHostsStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowSlaveStatusStatement;
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
import com.alibaba.druid.sql.parser.Token;
@@ -860,6 +863,42 @@ public class DALParserTest extends TestCase {
Assert.assertEquals("SHOW PROFILE ALL, BLOCK IO, CONTEXT SWITCHES, CPU, IPC, MEMORY, PAGE FAULTS, SOURCE, SWAPS FOR QUERY 2 LIMIT 2, 1", output);
}
public void test_show_relayLogEvents() throws Exception {
String sql = "SHOW RELAYLOG EVENTS";
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", output);
}
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);
}
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);
}
public void test_show_slaveStatus() throws Exception {
String sql = "SHOW SLAVE Status";
MySqlStatementParser parser = new MySqlStatementParser(sql);
MySqlShowSlaveStatusStatement show = (MySqlShowSlaveStatusStatement) parser.parseStatementList().get(0);
parser.match(Token.EOF);
String output = SQLUtils.toMySqlString(show);
Assert.assertEquals("SHOW SLAVE STATUS", output);
}
//
// public void testShow() throws Exception {
//