enhance sql parser & add test

This commit is contained in:
温少
2012-02-23 20:58:23 +08:00
17 changed files with 132 additions and 3 deletions
@@ -112,6 +112,7 @@ public class MySqlLexer extends Lexer {
map.put("KILL", Token.KILL);
map.put("IDENTIFIED", Token.IDENTIFIED);
map.put("PASSWORD", Token.PASSWORD);
map.put("DUAL", Token.DUAL);
DEFAULT_MYSQL_KEYWORDS = new Keywords(map);
}
@@ -768,7 +768,7 @@ public class MySqlStatementParser extends SQLStatementParser {
if (identifierEquals("ROWS")) {
lexer.nextToken();
acceptIdentifier("IDENTIFIED");
accept(Token.IDENTIFIED);
accept(Token.BY);
SQLExpr rowsIdentifiedBy = exprParser.expr();
stmt.setRowsIdentifiedBy(rowsIdentifiedBy);
@@ -5,6 +5,7 @@ import java.util.Map;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlKey;
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlPrimaryKey;
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlBinaryExpr;
@@ -43,6 +44,13 @@ import com.alibaba.druid.stat.TableStat.Mode;
public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlASTVisitor {
public boolean visit(SQLSelectStatement x) {
aliasLocal.set(new HashMap<String, String>());
aliasLocal.get().put("DUAL", null);
return true;
}
//DUAL
public boolean visit(MySqlDeleteStatement x) {
aliasLocal.set(new HashMap<String, String>());