mysql parser show PRIVILEGES

This commit is contained in:
温少
2012-05-16 10:52:16 +08:00
parent 31cb9182ec
commit dec53a1105
8 changed files with 140 additions and 0 deletions
@@ -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);
}
}
@@ -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) {
}
}