mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
mysql parser show
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
|
||||
public class MySqlShowMasterStatusStatement extends MySqlStatementImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatemen
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowIndexesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowKeysStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowWarningsStatement;
|
||||
@@ -524,8 +525,12 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
if (identifierEquals("MASTER")) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("LOGS");
|
||||
return new MySqlShowMasterLogsStatement();
|
||||
if (identifierEquals("LOGS")) {
|
||||
lexer.nextToken();
|
||||
return new MySqlShowMasterLogsStatement();
|
||||
}
|
||||
acceptIdentifier("STATUS");
|
||||
return new MySqlShowMasterStatusStatement();
|
||||
}
|
||||
|
||||
if (identifierEquals("CHARACTER")) {
|
||||
|
||||
@@ -72,6 +72,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatemen
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowIndexesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowKeysStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowWarningsStatement;
|
||||
@@ -341,4 +342,8 @@ public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
boolean visit(MySqlShowKeysStatement x);
|
||||
|
||||
void endVisit(MySqlShowKeysStatement x);
|
||||
|
||||
boolean visit(MySqlShowMasterStatusStatement x);
|
||||
|
||||
void endVisit(MySqlShowMasterStatusStatement x);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatemen
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowIndexesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowKeysStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowWarningsStatement;
|
||||
@@ -739,4 +740,14 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements
|
||||
public void endVisit(MySqlShowKeysStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowMasterStatusStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowMasterStatusStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatemen
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowIndexesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowKeysStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowWarningsStatement;
|
||||
@@ -1865,4 +1866,15 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
public void endVisit(MySqlShowKeysStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowMasterStatusStatement x) {
|
||||
print("SHOW MASTER STATUS");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowMasterStatusStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatemen
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowIndexesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowKeysStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowWarningsStatement;
|
||||
@@ -802,4 +803,14 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
public void endVisit(MySqlShowKeysStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowMasterStatusStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowMasterStatusStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowGrantsStatemen
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowIndexesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowKeysStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterLogsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowMasterStatusStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
@@ -696,6 +697,15 @@ public class DALParserTest extends TestCase {
|
||||
Assert.assertEquals("SHOW KEYS FROM db.tb1", output);
|
||||
}
|
||||
|
||||
public void test_master_status() throws Exception {
|
||||
String sql = "SHOW MASTER STATUS";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
MySqlShowMasterStatusStatement show = (MySqlShowMasterStatusStatement) parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(show);
|
||||
Assert.assertEquals("SHOW MASTER STATUS", output);
|
||||
}
|
||||
|
||||
//
|
||||
// public void testShow() throws Exception {
|
||||
// sql = "SHOW master status";
|
||||
|
||||
Reference in New Issue
Block a user