diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlStatementParser.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlStatementParser.java index e32af84abe..8fe3883d40 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlStatementParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlStatementParser.java @@ -718,6 +718,29 @@ public class MySqlStatementParser extends SQLStatementParser { //MySqlShowFunctionStatusStatement + if (identifierEquals("ENGINE")) { + lexer.nextToken(); + MySqlShowEngineStatement stmt = new MySqlShowEngineStatement(); + stmt.setName(this.exprParser.name()); + stmt.setOption(MySqlShowEngineStatement.Option.valueOf(lexer.stringVal().toUpperCase())); + lexer.nextToken(); + return stmt; + } + + if (identifierEquals("STORAGE")) { + lexer.nextToken(); + acceptIdentifier("ENGINES"); + MySqlShowEnginesStatement stmt = new MySqlShowEnginesStatement(); + stmt.setStorage(true); + return stmt; + } + + if (identifierEquals("ENGINES")) { + lexer.nextToken(); + MySqlShowEnginesStatement stmt = new MySqlShowEnginesStatement(); + return stmt; + } + throw new ParserException("TODO " + lexer.stringVal()); } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java index 5824953e26..8e277e1a1d 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java @@ -1698,6 +1698,65 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV } + @Override + public boolean visit(MySqlShowEventsStatement x) { + print("SHOW EVENTS"); + if (x.getSchema() != null) { + print(" FROM "); + x.getSchema().accept(this); + } + + if (x.getLike() != null) { + print(" LIKE "); + x.getLike().accept(this); + } + + if (x.getWhere() != null) { + print(" WHERE "); + x.getWhere().accept(this); + } + + return false; + } + + @Override + public void endVisit(MySqlShowEventsStatement x) { + + } + + @Override + public boolean visit(MySqlShowFunctionCodeStatement x) { + print("SHOW FUNCTION CODE "); + x.getName().accept(this); + return false; + } + + @Override + public void endVisit(MySqlShowFunctionCodeStatement x) { + + } + + @Override + public boolean visit(MySqlShowFunctionStatusStatement x) { + print("SHOW FUNCTION STATUS"); + if (x.getLike() != null) { + print(" LIKE "); + x.getLike().accept(this); + } + + if (x.getWhere() != null) { + print(" WHERE "); + x.getWhere().accept(this); + } + + return false; + } + + @Override + public void endVisit(MySqlShowFunctionStatusStatement x) { + + } + @Override public boolean visit(MySqlShowEnginesStatement x) { if (x.isStorage()) { @@ -1731,63 +1790,4 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV public void endVisit(MySqlShowErrorsStatement x) { } - - @Override - public boolean visit(MySqlShowEventsStatement x) { - print("SHOW EVENTS"); - if (x.getSchema() != null) { - print(" FROM "); - x.getSchema().accept(this); - } - - if (x.getLike() != null) { - print(" LIKE "); - x.getLike().accept(this); - } - - if (x.getWhere() != null) { - print(" WHERE "); - x.getWhere().accept(this); - } - - return false; - } - - @Override - public void endVisit(MySqlShowEventsStatement x) { - - } - - @Override - public boolean visit(MySqlShowFunctionCodeStatement x) { - print("SHOW FUNCTION CODE "); - x.getName().accept(this); - return false; - } - - @Override - public void endVisit(MySqlShowFunctionCodeStatement x) { - - } - - @Override - public boolean visit(MySqlShowFunctionStatusStatement x) { - print("SHOW FUNCTION STATUS"); - if (x.getLike() != null) { - print(" LIKE "); - x.getLike().accept(this); - } - - if (x.getWhere() != null) { - print(" WHERE "); - x.getWhere().accept(this); - } - - return false; - } - - @Override - public void endVisit(MySqlShowFunctionStatusStatement x) { - - } }