mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
mysql parser show PRIVILEGES
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 MySqlShowPluginsStatement extends MySqlStatementImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
+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 MySqlShowPrivilegesStatement extends MySqlStatementImpl {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,8 @@ 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.MySqlShowOpenTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPluginsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPrivilegesStatement;
|
||||
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;
|
||||
@@ -821,6 +823,18 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (identifierEquals("PLUGINS")) {
|
||||
lexer.nextToken();
|
||||
MySqlShowPluginsStatement stmt = new MySqlShowPluginsStatement();
|
||||
return stmt;
|
||||
}
|
||||
|
||||
if (identifierEquals("PRIVILEGES")) {
|
||||
lexer.nextToken();
|
||||
MySqlShowPrivilegesStatement stmt = new MySqlShowPrivilegesStatement();
|
||||
return stmt;
|
||||
}
|
||||
|
||||
throw new ParserException("TODO " + lexer.stringVal());
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ 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.MySqlShowOpenTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPluginsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPrivilegesStatement;
|
||||
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;
|
||||
@@ -351,4 +353,12 @@ public interface MySqlASTVisitor extends SQLASTVisitor {
|
||||
boolean visit(MySqlShowOpenTablesStatement x);
|
||||
|
||||
void endVisit(MySqlShowOpenTablesStatement x);
|
||||
|
||||
boolean visit(MySqlShowPluginsStatement x);
|
||||
|
||||
void endVisit(MySqlShowPluginsStatement x);
|
||||
|
||||
boolean visit(MySqlShowPrivilegesStatement x);
|
||||
|
||||
void endVisit(MySqlShowPrivilegesStatement x);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ 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.MySqlShowOpenTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPluginsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPrivilegesStatement;
|
||||
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;
|
||||
@@ -761,4 +763,24 @@ public class MySqlASTVisitorAdapter extends SQLASTVisitorAdapter implements
|
||||
public void endVisit(MySqlShowOpenTablesStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowPluginsStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowPluginsStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowPrivilegesStatement x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowPrivilegesStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,8 @@ 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.MySqlShowOpenTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPluginsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPrivilegesStatement;
|
||||
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;
|
||||
@@ -1905,4 +1907,26 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
public void endVisit(MySqlShowOpenTablesStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowPluginsStatement x) {
|
||||
print("SHOW PLUGINS");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowPluginsStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowPrivilegesStatement x) {
|
||||
print("SHOW PRIVILEGES");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowPrivilegesStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ 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.MySqlShowOpenTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPluginsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPrivilegesStatement;
|
||||
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;
|
||||
@@ -824,4 +826,24 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
public void endVisit(MySqlShowOpenTablesStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowPluginsStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowPluginsStatement x) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlShowPrivilegesStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlShowPrivilegesStatement x) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ 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.MySqlShowOpenTablesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPluginsStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlShowPrivilegesStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
@@ -752,6 +754,24 @@ public class DALParserTest extends TestCase {
|
||||
Assert.assertEquals("SHOW OPEN TABLES FROM mysql WHERE 1 = 1", output);
|
||||
}
|
||||
|
||||
public void test_show_open_plugins() throws Exception {
|
||||
String sql = "SHOW plugins";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
MySqlShowPluginsStatement show = (MySqlShowPluginsStatement) parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(show);
|
||||
Assert.assertEquals("SHOW PLUGINS", output);
|
||||
}
|
||||
|
||||
public void test_show_PRIVILEGES() throws Exception {
|
||||
String sql = "SHOW PRIVILEGES";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
MySqlShowPrivilegesStatement show = (MySqlShowPrivilegesStatement) parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(show);
|
||||
Assert.assertEquals("SHOW PRIVILEGES", output);
|
||||
}
|
||||
|
||||
//
|
||||
// public void testShow() throws Exception {
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user