mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved mysql/oracle sql parser.
This commit is contained in:
@@ -19,5 +19,7 @@ import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
|
||||
|
||||
public abstract class MySqlExprImpl extends MySqlObjectImpl implements SQLExpr {
|
||||
|
||||
public SQLExpr clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,4 +122,8 @@ public class MySqlOutFileExpr extends MySqlObjectImpl implements SQLExpr {
|
||||
this.ignoreLinesNumber = ignoreLinesNumber;
|
||||
}
|
||||
|
||||
public SQLExpr clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.alibaba.druid.sql.dialect.mysql.ast.expr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
|
||||
public class MySqlUserName extends MySqlExprImpl implements SQLName {
|
||||
public class MySqlUserName extends MySqlExprImpl implements SQLName, Cloneable {
|
||||
|
||||
private String userName;
|
||||
private String host;
|
||||
@@ -52,4 +52,11 @@ public class MySqlUserName extends MySqlExprImpl implements SQLName {
|
||||
public String toString() {
|
||||
return getSimpleName();
|
||||
}
|
||||
|
||||
public MySqlUserName clone() {
|
||||
MySqlUserName x = new MySqlUserName();
|
||||
x.userName = userName;
|
||||
x.host = host;
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,6 +374,38 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected SQLTableSource primaryTableSourceRest(SQLTableSource tableSource) {
|
||||
if (lexer.token() == Token.USE) {
|
||||
lexer.nextToken();
|
||||
MySqlUseIndexHint hint = new MySqlUseIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (identifierEquals("IGNORE")) {
|
||||
lexer.nextToken();
|
||||
MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (identifierEquals("FORCE")) {
|
||||
lexer.nextToken();
|
||||
MySqlForceIndexHint hint = new MySqlForceIndexHint();
|
||||
parseIndexHint(hint);
|
||||
tableSource.getHints().add(hint);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.PARTITION) {
|
||||
lexer.nextToken();
|
||||
accept(Token.LPAREN);
|
||||
this.exprParser.names(((SQLExprTableSource) tableSource).getPartitions(), tableSource);
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
return tableSource;
|
||||
}
|
||||
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
|
||||
if (identifierEquals("USING")) {
|
||||
return tableSource;
|
||||
|
||||
Reference in New Issue
Block a user