Merge pull request #1132 from wenshao/master

improved sql parser
This commit is contained in:
wenshao
2016-03-19 14:34:12 +08:00
27 changed files with 737 additions and 96 deletions
@@ -25,6 +25,9 @@ public class SQLOver extends SQLObjectImpl {
protected final List<SQLExpr> partitionBy = new ArrayList<SQLExpr>();
protected SQLOrderBy orderBy;
// for db2
protected SQLExpr of;
public SQLOver(){
}
@@ -38,6 +41,7 @@ public class SQLOver extends SQLObjectImpl {
if (visitor.visit(this)) {
acceptChild(visitor, this.partitionBy);
acceptChild(visitor, this.orderBy);
acceptChild(visitor, this.of);
}
visitor.endVisit(this);
}
@@ -53,6 +57,17 @@ public class SQLOver extends SQLObjectImpl {
this.orderBy = orderBy;
}
public SQLExpr getOf() {
return of;
}
public void setOf(SQLExpr of) {
if (of != null) {
of.setParent(this);
}
this.of = of;
}
public List<SQLExpr> getPartitionBy() {
return partitionBy;
}
@@ -36,6 +36,7 @@ public class DB2Lexer extends Lexer {
map.put("FIRST", Token.FIRST);
map.put("ONLY", Token.ONLY);
map.put("OPTIMIZE", Token.OPTIMIZE);
map.put("OF", Token.OF);
DEFAULT_DB2_KEYWORDS = new Keywords(map);
}
@@ -25,15 +25,14 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
*/
public class MysqlForeignKey extends SQLForeignKeyImpl {
private SQLName indexName;
private SQLName indexName;
private boolean hasConstraint;
private boolean hasConstraint;
private Match referenceMatch;
private Match referenceMatch;
private On referenceOn;
private Option referenceOption;
protected Option onUpdate;
protected Option onDelete;
public SQLName getIndexName() {
return indexName;
@@ -78,25 +77,25 @@ public class MysqlForeignKey extends SQLForeignKeyImpl {
this.referenceMatch = referenceMatch;
}
public On getReferenceOn() {
return referenceOn;
public Option getOnUpdate() {
return onUpdate;
}
public void setReferenceOn(On referenceOn) {
this.referenceOn = referenceOn;
public void setOnUpdate(Option onUpdate) {
this.onUpdate = onUpdate;
}
public Option getReferenceOption() {
return referenceOption;
public Option getOnDelete() {
return onDelete;
}
public void setReferenceOption(Option referenceOption) {
this.referenceOption = referenceOption;
public void setOnDelete(Option onDelete) {
this.onDelete = onDelete;
}
public static enum Option {
RESTRICT("RESTRICT"), CASCADE("CASCADE"), SET_NULL("SET NULL"), NO_ACTION("NO ACTION");
RESTRICT("RESTRICT"), CASCADE("CASCADE"), SET_NULL("SET NULL"), NO_ACTION("NO ACTION");
public final String name;
public final String name_lcase;
@@ -113,27 +112,25 @@ public class MysqlForeignKey extends SQLForeignKeyImpl {
}
public static enum Match {
FULL("FULL"),
PARTIAL("PARTIAL"),
SIMPLE("SIMPLE");
FULL("FULL"), PARTIAL("PARTIAL"), SIMPLE("SIMPLE");
public final String name;
public final String name_lcase;
Match(String name) {
Match(String name){
this.name = name;
this.name_lcase = name.toLowerCase();
}
}
public static enum On {
DELETE("DELETE"), //
UPDATE("UPDATE");
DELETE("DELETE"), //
UPDATE("UPDATE");
public final String name;
public final String name_lcase;
On(String name) {
On(String name){
this.name = name;
this.name_lcase = name.toLowerCase();
}
@@ -116,7 +116,8 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
} else if (lexer.token() == Token.CONSTRAINT //
|| lexer.token() == Token.PRIMARY //
|| lexer.token() == Token.UNIQUE) {
stmt.getTableElementList().add(parseConstraint());
SQLTableConstraint constraint = this.parseConstraint();
stmt.getTableElementList().add(constraint);
} else if (lexer.token() == (Token.INDEX)) {
lexer.nextToken();
@@ -144,6 +145,12 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
}
}
accept(Token.RPAREN);
if (identifierEquals("USING")) {
lexer.nextToken();
idx.setIndexType(lexer.stringVal());
lexer.nextToken();
}
stmt.getTableElementList().add(idx);
} else if (lexer.token() == (Token.KEY)) {
@@ -41,7 +41,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.MySqlPrimaryKey;
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlUnique;
import com.alibaba.druid.sql.dialect.mysql.ast.MysqlForeignKey;
import com.alibaba.druid.sql.dialect.mysql.ast.MysqlForeignKey.Match;
import com.alibaba.druid.sql.dialect.mysql.ast.MysqlForeignKey.On;
import com.alibaba.druid.sql.dialect.mysql.ast.MysqlForeignKey.Option;
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr;
@@ -834,39 +833,56 @@ public class MySqlExprParser extends SQLExprParser {
}
}
if (lexer.token() == Token.ON) {
while (lexer.token() == Token.ON) {
lexer.nextToken();
if (lexer.token() == Token.DELETE) {
fk.setReferenceOn(On.DELETE);
lexer.nextToken();
Option option = parseReferenceOption();
fk.setOnDelete(option);
} else if (lexer.token() == Token.UPDATE) {
fk.setReferenceOn(On.UPDATE);
lexer.nextToken();
Option option = parseReferenceOption();
fk.setOnUpdate(option);
} else {
throw new ParserException("syntax error, expect DELETE or UPDATE, actual " + lexer.token() + " "
+ lexer.stringVal());
}
lexer.nextToken();
if (lexer.token() == Token.RESTRICT) {
fk.setReferenceOption(Option.RESTRICT);
} else if (identifierEquals("CASCADE")) {
fk.setReferenceOption(Option.CASCADE);
} else if (lexer.token() == Token.SET) {
accept(Token.NULL);
fk.setReferenceOption(Option.SET_NULL);
} else if (identifierEquals("ON")) {
lexer.nextToken();
if (identifierEquals("ACTION")) {
fk.setReferenceOption(Option.NO_ACTION);
} else {
throw new ParserException("syntax error, expect ACTION, actual " + lexer.token() + " "
+ lexer.stringVal());
}
}
lexer.nextToken();
}
return fk;
}
protected Option parseReferenceOption() {
Option option;
if (lexer.token() == Token.RESTRICT || identifierEquals("RESTRICT")) {
option = Option.RESTRICT;
lexer.nextToken();
} else if (identifierEquals("CASCADE")) {
option = Option.CASCADE;
lexer.nextToken();
} else if (lexer.token() == Token.SET) {
lexer.nextToken();
accept(Token.NULL);
option = Option.SET_NULL;
} else if (identifierEquals("ON")) {
lexer.nextToken();
if (identifierEquals("ACTION")) {
option = Option.NO_ACTION;
lexer.nextToken();
} else {
throw new ParserException("syntax error, expect ACTION, actual " + lexer.token() + " "
+ lexer.stringVal());
}
} else {
throw new ParserException("syntax error, expect ACTION, actual " + lexer.token() + " "
+ lexer.stringVal());
}
return option;
}
protected SQLAggregateExpr parseAggregateExprRest(SQLAggregateExpr aggregateExpr) {
if (lexer.token() == Token.ORDER) {
SQLOrderBy orderBy = this.parseOrderBy();
@@ -54,7 +54,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.MySqlPrimaryKey;
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlUnique;
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlUseIndexHint;
import com.alibaba.druid.sql.dialect.mysql.ast.MysqlForeignKey;
import com.alibaba.druid.sql.dialect.mysql.ast.MysqlForeignKey.Option;
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlCaseStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlCaseStatement.MySqlWhenStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlCursorDeclareStatement;
@@ -2816,15 +2815,14 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
print0(ucase ? match.name : match.name_lcase);
}
MysqlForeignKey.On on = x.getReferenceOn();
if (on != null) {
print0(ucase ? " ON " : " on ");
print0(ucase ? on.name : on.name_lcase);
print(' ');
Option option = x.getReferenceOption();
if (option != null) {
print0(ucase ? option.name : option.name_lcase);
}
if (x.getOnDelete() != null) {
print0(ucase ? " ON DELETE " : " on delete ");
print0(ucase ? x.getOnDelete().name : x.getOnDelete().name_lcase);
}
if (x.getOnDelete() != null) {
print0(ucase ? " ON UPDATE " : " on update ");
print0(ucase ? x.getOnDelete().name : x.getOnDelete().name_lcase);
}
return false;
}
@@ -196,7 +196,7 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
ident = expr.toString();
}
if (subQueryMap.containsKey(ident)) {
if (containsSubQuery(ident)) {
return false;
}
@@ -575,7 +575,7 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
if (table != null) {
this.aliasMap.put(x.getAlias(), table);
}
this.subQueryMap.put(x.getAlias(), x.getSelect());
addSubQuery(x.getAlias(), x.getSelect());
this.setCurrentTable(x.getAlias());
}
@@ -650,7 +650,7 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
if (alias != null) {
putAliasMap(aliasMap, alias, null);
subQueryMap.put(alias, x.getSubQuery());
addSubQuery(alias, x.getSubQuery());
}
}
x.getSubQuery().accept(this);
@@ -107,7 +107,7 @@ public class PGSchemaStatVisitor extends SchemaStatVisitor implements PGASTVisit
if (alias != null) {
aliasMap.put(alias, null);
subQueryMap.put(alias, x.getQuery());
addSubQuery(alias, x.getQuery());
}
}
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2101 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.dialect.teradata.ast;
import com.alibaba.druid.sql.ast.SQLObject;
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2101 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.dialect.teradata.parser;
import com.alibaba.druid.sql.parser.Lexer;
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2101 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.dialect.teradata.parser;
import java.util.HashMap;
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2101 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.dialect.teradata.parser;
import com.alibaba.druid.sql.parser.Lexer;
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2101 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.dialect.teradata.visitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2101 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.dialect.teradata.visitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitorAdapter;
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2101 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.dialect.teradata.visitor;
import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2101 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.dialect.teradata.visitor;
import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
@@ -1036,6 +1036,12 @@ public class SQLExprParser extends SQLParser {
}
over.setOrderBy(parseOrderBy());
if (lexer.token() == Token.OF) {
lexer.nextToken();
SQLExpr of = this.expr();
over.setOf(of);
}
accept(Token.RPAREN);
aggregateExpr.setOver(over);
@@ -1632,9 +1632,16 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
printAndAccept(x.getPartitionBy(), ", ");
print(' ');
}
if (x.getOrderBy() != null) {
x.getOrderBy().accept(this);
}
if (x.getOf() != null) {
print0(ucase ? " OF " : " of ");
x.getOf().accept(this);
}
print(')');
return false;
}
@@ -113,6 +113,7 @@ import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
import com.alibaba.druid.sql.ast.statement.SQLShowTablesStatement;
import com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource;
import com.alibaba.druid.sql.ast.statement.SQLTableElement;
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
import com.alibaba.druid.sql.ast.statement.SQLTruncateStatement;
import com.alibaba.druid.sql.ast.statement.SQLUpdateStatement;
import com.alibaba.druid.sql.ast.statement.SQLUseStatement;
@@ -310,7 +311,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
}
public boolean visit(SQLIdentifierExpr x) {
if (subQueryMap.containsKey(currentTable)) {
if (containsSubQuery(currentTable)) {
return false;
}
@@ -331,7 +332,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
if (x.getOwner() instanceof SQLIdentifierExpr) {
String owner = ((SQLIdentifierExpr) x.getOwner()).getName();
if (subQueryMap.containsKey(owner)) {
if (containsSubQuery(owner)) {
return false;
}
@@ -499,8 +500,14 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
if (owner instanceof SQLIdentifierExpr) {
String tableName = ((SQLIdentifierExpr) owner).getName();
String table = tableName;
if (aliasMap.containsKey(table)) {
table = aliasMap.get(table);
String tableNameLower = tableName.toLowerCase();
if (aliasMap.containsKey(tableNameLower)) {
table = aliasMap.get(tableNameLower);
}
if (containsSubQuery(tableNameLower)) {
table = null;
}
if (variants.containsKey(table)) {
@@ -726,7 +733,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
if (x.getOwner() instanceof SQLIdentifierExpr) {
String owner = ((SQLIdentifierExpr) x.getOwner()).getName();
if (subQueryMap.containsKey(owner)) {
if (containsSubQuery(owner)) {
return false;
}
@@ -736,6 +743,10 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
Column column = addColumn(owner, x.getName());
x.putAttribute(ATTR_COLUMN, column);
if (column != null) {
if (isParentGroupBy(x)) {
this.groupByColumns.add(column);
}
if (column != null) {
setColumn(x, column);
}
@@ -772,15 +783,25 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
}
protected Column handleSubQueryColumn(String owner, String alias) {
SQLObject query = subQueryMap.get(owner);
SQLObject query = getSubQuery(owner);
if (query == null) {
return null;
}
return handleSubQueryColumn(alias, query);
}
protected Column handleSubQueryColumn(String alias, SQLObject query) {
if (query instanceof SQLSelect) {
query = ((SQLSelect) query).getQuery();
}
SQLSelectQueryBlock queryBlock = null;
List<SQLSelectItem> selectList = null;
if (query instanceof SQLSelectQueryBlock) {
selectList = ((SQLSelectQueryBlock) query).getSelectList();
queryBlock = (SQLSelectQueryBlock) query;
selectList = queryBlock.getSelectList();
}
if (selectList != null) {
@@ -791,19 +812,30 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
String itemAlias = item.getAlias();
SQLExpr itemExpr = item.getExpr();
String ident = itemAlias;
if (itemAlias == null) {
if (itemExpr instanceof SQLIdentifierExpr) {
itemAlias = itemExpr.toString();
ident = itemAlias = itemExpr.toString();
} else if (itemExpr instanceof SQLPropertyExpr) {
itemAlias = ((SQLPropertyExpr) itemExpr).getName();
ident = itemExpr.toString();
}
}
if (alias.equalsIgnoreCase(itemAlias)) {
Column column = (Column) itemExpr.getAttribute(ATTR_COLUMN);
return column;
if (column != null) {
return column;
} else {
SQLTableSource from = queryBlock.getFrom();
if (from instanceof SQLSubqueryTableSource) {
SQLSelect select = ((SQLSubqueryTableSource) from).getSelect();
Column subQueryColumn = handleSubQueryColumn(ident, select);
return subQueryColumn;
}
}
}
}
}
@@ -813,7 +845,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
public boolean visit(SQLIdentifierExpr x) {
String currentTable = getCurrentTable();
if (subQueryMap.containsKey(currentTable)) {
if (containsSubQuery(currentTable)) {
return false;
}
@@ -826,6 +858,10 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
Column column;
if (currentTable != null) {
column = addColumn(currentTable, ident);
if (column != null && isParentGroupBy(x)) {
this.groupByColumns.add(column);
}
x.putAttribute(ATTR_COLUMN, column);
} else {
column = handleUnkownColumn(ident);
@@ -854,6 +890,18 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
return isParentSelectItem(parent.getParent());
}
private boolean isParentGroupBy(SQLObject parent) {
if (parent == null) {
return false;
}
if (parent instanceof SQLSelectGroupByClause) {
return true;
}
return isParentGroupBy(parent.getParent());
}
private void setColumn(SQLExpr x, Column column) {
SQLObject current = x;
@@ -906,7 +954,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
public boolean visit(SQLAllColumnExpr x) {
String currentTable = getCurrentTable();
if (subQueryMap.containsKey(currentTable)) {
if (containsSubQuery(currentTable)) {
return false;
}
@@ -966,7 +1014,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
if (aliasMap != null && alias != null) {
putAliasMap(aliasMap, alias, null);
subQueryMap.put(alias, x.getSubQuery().getQuery());
addSubQuery(alias, x.getSubQuery().getQuery());
}
x.getSubQuery().accept(this);
@@ -975,7 +1023,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
if (aliasMap != null && alias != null) {
putAliasMap(aliasMap, alias, null);
subQueryMap.put(alias, x.getSubQuery().getQuery());
addSubQuery(alias, x.getSubQuery().getQuery());
}
}
@@ -990,10 +1038,29 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
Map<String, String> aliasMap = getAliasMap();
if (aliasMap != null && x.getAlias() != null) {
putAliasMap(aliasMap, x.getAlias(), null);
subQueryMap.put(x.getAlias(), query);
addSubQuery(x.getAlias(), query);
}
return false;
}
protected void addSubQuery(String alias, SQLObject query) {
String alias_lcase = alias.toLowerCase();
subQueryMap.put(alias_lcase, query);
}
protected SQLObject getSubQuery(String alias) {
String alias_lcase = alias.toLowerCase();
return subQueryMap.get(alias_lcase);
}
protected boolean containsSubQuery(String alias) {
if (alias == null) {
return false;
}
String alias_lcase = alias.toLowerCase();
return subQueryMap.containsKey(alias_lcase);
}
protected boolean isSimpleExprTableSource(SQLExprTableSource x) {
return x.getExpr() instanceof SQLName;
@@ -1007,7 +1074,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
return false;
}
if (subQueryMap.containsKey(ident)) {
if (containsSubQuery(ident)) {
return false;
}
@@ -217,6 +217,10 @@ public class TableStat {
private Column right;
private String operator;
public Relationship(){
}
public Column getLeft() {
return left;
}
@@ -394,7 +398,7 @@ public class TableStat {
private boolean join;
private Map<String, Object> attributes = new HashMap<String, Object>();
private transient String fullName;
public Column(){
@@ -414,7 +418,7 @@ public class TableStat {
this.table = table;
this.fullName = null;
}
public String getFullName() {
if (fullName == null) {
if (table != null) {
@@ -423,7 +427,7 @@ public class TableStat {
fullName = table + '.' + name;
}
}
return fullName;
}
@@ -501,7 +505,7 @@ public class TableStat {
public boolean equals(Object obj) {
if (!(obj instanceof Column)) {
if (!(obj instanceof Column)) {
return false;
}
@@ -532,16 +536,16 @@ public class TableStat {
}
public static enum Mode {
Insert(1), //
Update(2), //
Delete(4), //
Select(8), //
Merge(16), //
Truncate(32), //
Alter(64), //
Drop(128), //
DropIndex(256), //
CreateIndex(512)//
Insert(1), //
Update(2), //
Delete(4), //
Select(8), //
Merge(16), //
Truncate(32), //
Alter(64), //
Drop(128), //
DropIndex(256), //
CreateIndex(512)//
; //
public final int mark;