mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
+13
-28
@@ -22,7 +22,6 @@ import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObjectImpl;
|
||||
import com.alibaba.druid.sql.ast.SQLOrderBy;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
@@ -30,43 +29,29 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
@SuppressWarnings("serial")
|
||||
public class MySqlSelectQueryBlock extends SQLSelectQueryBlock {
|
||||
|
||||
private boolean hignPriority;
|
||||
private boolean straightJoin;
|
||||
private boolean hignPriority;
|
||||
private boolean straightJoin;
|
||||
|
||||
private boolean smallResult;
|
||||
private boolean bigResult;
|
||||
private boolean bufferResult;
|
||||
private Boolean cache;
|
||||
private boolean calcFoundRows;
|
||||
private boolean smallResult;
|
||||
private boolean bigResult;
|
||||
private boolean bufferResult;
|
||||
private Boolean cache;
|
||||
private boolean calcFoundRows;
|
||||
|
||||
private SQLOrderBy orderBy;
|
||||
private SQLOrderBy orderBy;
|
||||
|
||||
private Limit limit;
|
||||
private Limit limit;
|
||||
|
||||
private SQLName procedureName;
|
||||
private List<SQLExpr> procedureArgumentList = new ArrayList<SQLExpr>();
|
||||
private SQLName procedureName;
|
||||
private List<SQLExpr> procedureArgumentList = new ArrayList<SQLExpr>();
|
||||
|
||||
private SQLExprTableSource into;
|
||||
|
||||
private boolean forUpdate = false;
|
||||
private boolean lockInShareMode = false;
|
||||
private boolean forUpdate = false;
|
||||
private boolean lockInShareMode = false;
|
||||
|
||||
public MySqlSelectQueryBlock(){
|
||||
|
||||
}
|
||||
|
||||
public SQLExprTableSource getInto() {
|
||||
return into;
|
||||
}
|
||||
|
||||
public void setInto(SQLExpr into) {
|
||||
this.into = new SQLExprTableSource(into);
|
||||
}
|
||||
|
||||
public void setInto(SQLExprTableSource into) {
|
||||
this.into = into;
|
||||
}
|
||||
|
||||
public boolean isForUpdate() {
|
||||
return forUpdate;
|
||||
}
|
||||
|
||||
@@ -111,53 +111,58 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
|
||||
if (lexer.token() == (Token.INTO)) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("OUTFILE");
|
||||
|
||||
MySqlOutFileExpr outFile = new MySqlOutFileExpr();
|
||||
outFile.setFile(expr());
|
||||
|
||||
queryBlock.setInto(outFile);
|
||||
|
||||
if (identifierEquals("FIELDS") || identifierEquals("COLUMNS")) {
|
||||
if (identifierEquals("OUTFILE")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("TERMINATED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
}
|
||||
outFile.setColumnsTerminatedBy((SQLLiteralExpr) expr());
|
||||
MySqlOutFileExpr outFile = new MySqlOutFileExpr();
|
||||
outFile.setFile(expr());
|
||||
|
||||
if (identifierEquals("OPTIONALLY")) {
|
||||
queryBlock.setInto(outFile);
|
||||
|
||||
if (identifierEquals("FIELDS") || identifierEquals("COLUMNS")) {
|
||||
lexer.nextToken();
|
||||
outFile.setColumnsEnclosedOptionally(true);
|
||||
|
||||
if (identifierEquals("TERMINATED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
}
|
||||
outFile.setColumnsTerminatedBy((SQLLiteralExpr) expr());
|
||||
|
||||
if (identifierEquals("OPTIONALLY")) {
|
||||
lexer.nextToken();
|
||||
outFile.setColumnsEnclosedOptionally(true);
|
||||
}
|
||||
|
||||
if (identifierEquals("ENCLOSED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setColumnsEnclosedBy((SQLLiteralExpr) expr());
|
||||
}
|
||||
|
||||
if (identifierEquals("ESCAPED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setColumnsEscaped((SQLLiteralExpr) expr());
|
||||
}
|
||||
}
|
||||
|
||||
if (identifierEquals("ENCLOSED")) {
|
||||
if (identifierEquals("LINES")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setColumnsEnclosedBy((SQLLiteralExpr) expr());
|
||||
}
|
||||
|
||||
if (identifierEquals("ESCAPED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setColumnsEscaped((SQLLiteralExpr) expr());
|
||||
}
|
||||
}
|
||||
|
||||
if (identifierEquals("LINES")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("STARTING")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setLinesStartingBy((SQLLiteralExpr) expr());
|
||||
} else {
|
||||
identifierEquals("TERMINATED");
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setLinesTerminatedBy((SQLLiteralExpr) expr());
|
||||
if (identifierEquals("STARTING")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setLinesStartingBy((SQLLiteralExpr) expr());
|
||||
} else {
|
||||
identifierEquals("TERMINATED");
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
outFile.setLinesTerminatedBy((SQLLiteralExpr) expr());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
queryBlock.setInto(this.createExprParser().name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +203,8 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
|
||||
if (lexer.token() == Token.INTO) {
|
||||
lexer.nextToken();
|
||||
throw new ParserException("TODO");
|
||||
SQLExpr expr = this.createExprParser().name();
|
||||
queryBlock.setInto(expr);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.FOR) {
|
||||
|
||||
Reference in New Issue
Block a user