Conflicts:
	src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlStatementParser.java
	src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlASTVisitor.java
	src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlASTVisitorAdapter.java
	src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java
	src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlSchemaStatVisitor.java
	src/test/java/com/alibaba/druid/bvt/sql/cobar/DALParserTest.java
This commit is contained in:
温少
2012-05-16 08:08:02 +08:00
2 changed files with 82 additions and 59 deletions
@@ -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());
}
@@ -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) {
}
}