improved sql parser.

This commit is contained in:
wenshao
2017-09-11 16:41:40 +08:00
parent 20c3f9304e
commit a9474ac6d0
33 changed files with 536 additions and 150 deletions
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
@@ -25,36 +25,36 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.util.FnvHash;
public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery, SQLReplaceable {
private boolean bracket = false;
protected int distionOption;
protected final List<SQLSelectItem> selectList = new ArrayList<SQLSelectItem>();
private boolean bracket = false;
protected int distionOption;
protected final List<SQLSelectItem> selectList = new ArrayList<SQLSelectItem>();
protected SQLTableSource from;
protected SQLExprTableSource into;
protected SQLExpr where;
protected SQLTableSource from;
protected SQLExprTableSource into;
protected SQLExpr where;
// for oracle & oceanbase
protected SQLExpr startWith;
protected SQLExpr connectBy;
protected boolean prior = false;
protected boolean noCycle = false;
protected SQLOrderBy orderBySiblings;
protected SQLExpr startWith;
protected SQLExpr connectBy;
protected boolean prior = false;
protected boolean noCycle = false;
protected SQLOrderBy orderBySiblings;
protected SQLSelectGroupByClause groupBy;
protected SQLOrderBy orderBy;
protected boolean parenthesized = false;
protected boolean forUpdate = false;
protected boolean noWait = false;
protected SQLExpr waitTime;
protected SQLLimit limit;
protected SQLSelectGroupByClause groupBy;
protected SQLOrderBy orderBy;
protected boolean parenthesized = false;
protected boolean forUpdate = false;
protected boolean noWait = false;
protected SQLExpr waitTime;
protected SQLLimit limit;
// for oracle
protected List<SQLExpr> forUpdateOf;
protected List<SQLExpr> distributeBy;
protected List<SQLExpr> forUpdateOf;
protected List<SQLExpr> distributeBy;
protected List<SQLSelectOrderByItem> sortBy;
protected String cachedSelectList; // optimized for SelectListCache
public SQLSelectQueryBlock(){
}
@@ -397,6 +397,15 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
return forUpdateOf.size();
}
public void cloneSelectListTo(SQLSelectQueryBlock x) {
x.distionOption = distionOption;
for (SQLSelectItem item : this.selectList) {
SQLSelectItem item2 = item.clone();
item2.setParent(x);
x.selectList.add(item2);
}
}
public void cloneTo(SQLSelectQueryBlock x) {
x.distionOption = distionOption;
@@ -580,4 +589,12 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
setLimit(limit);
}
public String getCachedSelectList() {
return cachedSelectList;
}
public void setCachedSelectList(String cachedSelectList) {
this.cachedSelectList = cachedSelectList;
}
}