refactor sql parser. improved db2 sql support. bug fixed for issue #2033

This commit is contained in:
wenshao
2017-10-09 15:47:16 +08:00
parent 08cc982f2e
commit f4d3310734
26 changed files with 583 additions and 186 deletions
@@ -19,16 +19,12 @@ import java.util.ArrayList;
import java.util.List;
public abstract class SQLPartitionBy extends SQLObjectImpl {
protected SQLSubPartitionBy subPartitionBy;
protected SQLExpr partitionsCount;
protected boolean linear;
protected List<SQLPartition> partitions = new ArrayList<SQLPartition>();
protected List<SQLName> storeIn = new ArrayList<SQLName>();
protected List<SQLExpr> columns = new ArrayList<SQLExpr>();
public List<SQLPartition> getPartitions() {
return partitions;
@@ -75,6 +71,17 @@ public abstract class SQLPartitionBy extends SQLObjectImpl {
return storeIn;
}
public List<SQLExpr> getColumns() {
return columns;
}
public void addColumn(SQLExpr column) {
if (column != null) {
column.setParent(this);
}
this.columns.add(column);
}
public void cloneTo(SQLPartitionBy x) {
if (subPartitionBy != null) {
x.setSubPartitionBy(subPartitionBy.clone());
@@ -19,22 +19,9 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLPartitionByHash extends SQLPartitionBy {
protected SQLExpr expr;
// for aliyun ads
protected boolean key;
public SQLExpr getExpr() {
return expr;
}
public void setExpr(SQLExpr expr) {
if (expr != null) {
expr.setParent(this);
}
this.expr = expr;
}
public boolean isKey() {
return key;
}
@@ -46,7 +33,6 @@ public class SQLPartitionByHash extends SQLPartitionBy {
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, expr);
acceptChild(visitor, partitionsCount);
acceptChild(visitor, getPartitions());
acceptChild(visitor, subPartitionBy);
@@ -57,12 +43,14 @@ public class SQLPartitionByHash extends SQLPartitionBy {
public SQLPartitionByHash clone() {
SQLPartitionByHash x = new SQLPartitionByHash();
if (expr != null) {
x.setExpr(expr.clone());
}
x.key = key;
for (SQLExpr column : columns) {
SQLExpr c2 = column.clone();
c2.setParent(x);
x.columns.add(c2);
}
return x;
}
}
@@ -21,15 +21,9 @@ import java.util.List;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLPartitionByList extends SQLPartitionBy {
protected SQLExpr expr;
protected List<SQLName> columns = new ArrayList<SQLName>();
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, expr);
acceptChild(visitor, columns);
acceptChild(visitor, partitionsCount);
acceptChild(visitor, getPartitions());
@@ -38,37 +32,11 @@ public class SQLPartitionByList extends SQLPartitionBy {
visitor.endVisit(this);
}
public SQLExpr getExpr() {
return expr;
}
public void setExpr(SQLExpr expr) {
if (expr != null) {
expr.setParent(this);
}
this.expr = expr;
}
public List<SQLName> getColumns() {
return columns;
}
public void addColumn(SQLName column) {
if (column != null) {
column.setParent(this);
}
this.columns.add(column);
}
public SQLPartitionByList clone() {
SQLPartitionByList x = new SQLPartitionByList();
if (expr != null) {
x.setExpr(expr.clone());
}
for (SQLName column : columns) {
SQLName c2 = column.clone();
for (SQLExpr column : columns) {
SQLExpr c2 = column.clone();
c2.setParent(x);
x.columns.add(c2);
}
@@ -21,29 +21,12 @@ import java.util.List;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLPartitionByRange extends SQLPartitionBy {
protected List<SQLName> columns = new ArrayList<SQLName>();
protected SQLExpr interval;
// mysql
protected SQLExpr expr;
public SQLPartitionByRange() {
}
public List<SQLName> getColumns() {
return columns;
}
public void addColumn(SQLName column) {
if (column != null) {
column.setParent(this);
}
this.columns.add(column);
}
public SQLExpr getInterval() {
return interval;
}
@@ -56,22 +39,10 @@ public class SQLPartitionByRange extends SQLPartitionBy {
this.interval = interval;
}
public SQLExpr getExpr() {
return expr;
}
public void setExpr(SQLExpr expr) {
if (expr != null) {
expr.setParent(this);
}
this.expr = expr;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, columns);
acceptChild(visitor, expr);
acceptChild(visitor, interval);
acceptChild(visitor, storeIn);
acceptChild(visitor, partitions);
@@ -82,16 +53,12 @@ public class SQLPartitionByRange extends SQLPartitionBy {
public SQLPartitionByRange clone() {
SQLPartitionByRange x = new SQLPartitionByRange();
if (expr != null) {
x.setExpr(expr.clone());
}
if (interval != null) {
x.setInterval(interval.clone());
}
for (SQLName column : columns) {
SQLName c2 = column.clone();
for (SQLExpr column : columns) {
SQLExpr c2 = column.clone();
c2.setParent(x);
x.columns.add(c2);
}
@@ -39,15 +39,19 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
protected List<SQLTableElement> tableElementList = new ArrayList<SQLTableElement>();
// for postgresql
private SQLExprTableSource inherits;
protected SQLExprTableSource inherits;
protected SQLSelect select;
protected SQLExpr comment;
protected SQLExprTableSource like;
protected SQLExprTableSource like;
protected Boolean compress;
protected Boolean logging;
protected SQLName tablespace;
protected SQLPartitionBy partitioning;
public SQLCreateTableStatement(){
@@ -176,6 +180,45 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
this.like = like;
}
public Boolean getCompress() {
return compress;
}
public void setCompress(Boolean compress) {
this.compress = compress;
}
public Boolean getLogging() {
return logging;
}
public void setLogging(Boolean logging) {
this.logging = logging;
}
public SQLName getTablespace() {
return tablespace;
}
public void setTablespace(SQLName tablespace) {
if (tablespace != null) {
tablespace.setParent(this);
}
this.tablespace = tablespace;
}
public SQLPartitionBy getPartitioning() {
return partitioning;
}
public void setPartitioning(SQLPartitionBy partitioning) {
if (partitioning != null) {
partitioning.setParent(this);
}
this.partitioning = partitioning;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
@@ -0,0 +1,21 @@
/*
* 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.dialect.db2.ast;
import com.alibaba.druid.sql.ast.SQLStatement;
public interface DB2Statement extends SQLStatement, DB2Object {
}
@@ -0,0 +1,63 @@
/*
* 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.dialect.db2.ast.stmt;
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
import com.alibaba.druid.sql.dialect.db2.ast.DB2Statement;
import com.alibaba.druid.sql.dialect.db2.visitor.DB2ASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class DB2CreateTableStatement extends SQLCreateTableStatement implements DB2Statement {
private boolean dataCaptureNone;
private boolean dataCaptureChanges;
public boolean isDataCaptureNone() {
return dataCaptureNone;
}
public void setDataCaptureNone(boolean dataCaptureNone) {
this.dataCaptureNone = dataCaptureNone;
}
public boolean isDataCaptureChanges() {
return dataCaptureChanges;
}
public void setDataCaptureChanges(boolean dataCaptureChanges) {
this.dataCaptureChanges = dataCaptureChanges;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor instanceof DB2ASTVisitor) {
accept0((DB2ASTVisitor) visitor);
return;
}
super.accept0(visitor);
}
@Override
public void accept0(DB2ASTVisitor visitor) {
if (visitor.visit(this)) {
this.acceptChild(visitor, tableSource);
this.acceptChild(visitor, tableElementList);
this.acceptChild(visitor, inherits);
this.acceptChild(visitor, select);
}
visitor.endVisit(this);
}
}
@@ -0,0 +1,177 @@
/*
* 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.dialect.db2.parser;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLPartitionBy;
import com.alibaba.druid.sql.ast.SQLPartitionByHash;
import com.alibaba.druid.sql.ast.statement.*;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2CreateTableStatement;
import com.alibaba.druid.sql.parser.ParserException;
import com.alibaba.druid.sql.parser.SQLCreateTableParser;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.alibaba.druid.sql.parser.Token;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.JdbcConstants;
public class DB2CreateTableParser extends SQLCreateTableParser {
public DB2CreateTableParser(String sql) {
super(new DB2ExprParser(sql));
}
public DB2CreateTableParser(SQLExprParser exprParser) {
super(exprParser);
}
public SQLCreateTableStatement parseCreateTable(boolean acceptCreate) {
DB2CreateTableStatement createTable = newCreateStatement();
if (acceptCreate) {
if (lexer.hasComment() && lexer.isKeepComments()) {
createTable.addBeforeComment(lexer.readAndResetComments());
}
accept(Token.CREATE);
}
if (lexer.identifierEquals("GLOBAL")) {
lexer.nextToken();
if (lexer.identifierEquals("TEMPORARY")) {
lexer.nextToken();
createTable.setType(SQLCreateTableStatement.Type.GLOBAL_TEMPORARY);
} else {
throw new ParserException("syntax error " + lexer.info());
}
} else if (lexer.token() == Token.IDENTIFIER && lexer.stringVal().equalsIgnoreCase("LOCAL")) {
lexer.nextToken();
if (lexer.token() == Token.IDENTIFIER && lexer.stringVal().equalsIgnoreCase("TEMPORAY")) {
lexer.nextToken();
createTable.setType(SQLCreateTableStatement.Type.LOCAL_TEMPORARY);
} else {
throw new ParserException("syntax error. " + lexer.info());
}
}
accept(Token.TABLE);
createTable.setName(this.exprParser.name());
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
for (; ; ) {
Token token = lexer.token();
if (token == Token.IDENTIFIER
&& lexer.stringVal().equalsIgnoreCase("SUPPLEMENTAL")
&& JdbcConstants.ORACLE.equals(dbType)) {
this.parseCreateTableSupplementalLogingProps(createTable);
} else if (token == Token.IDENTIFIER //
|| token == Token.LITERAL_ALIAS) {
SQLColumnDefinition column = this.exprParser.parseColumn();
createTable.getTableElementList().add(column);
} else if (token == Token.PRIMARY //
|| token == Token.UNIQUE //
|| token == Token.CHECK //
|| token == Token.CONSTRAINT
|| token == Token.FOREIGN) {
SQLConstraint constraint = this.exprParser.parseConstaint();
constraint.setParent(createTable);
createTable.getTableElementList().add((SQLTableElement) constraint);
} else if (token == Token.TABLESPACE) {
throw new ParserException("TODO " + lexer.info());
} else {
SQLColumnDefinition column = this.exprParser.parseColumn();
createTable.getTableElementList().add(column);
}
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
if (lexer.token() == Token.RPAREN) { // compatible for sql server
break;
}
continue;
}
break;
}
accept(Token.RPAREN);
if (lexer.identifierEquals("INHERITS")) {
lexer.nextToken();
accept(Token.LPAREN);
SQLName inherits = this.exprParser.name();
createTable.setInherits(new SQLExprTableSource(inherits));
accept(Token.RPAREN);
}
}
if (lexer.token() == Token.AS) {
lexer.nextToken();
SQLSelect select = this.createSQLSelectParser().select();
createTable.setSelect(select);
}
for (;;) {
if (lexer.identifierEquals(FnvHash.Constants.DATA)) {
lexer.nextToken();
acceptIdentifier("CAPTURE");
if (lexer.identifierEquals(FnvHash.Constants.NONE)) {
lexer.nextToken();
createTable.setDataCaptureNone(true);
continue;
}
throw new ParserException("TODO " + lexer.info());
} else if (lexer.token() == Token.IN) {
lexer.nextToken();
if (lexer.token() == Token.DATABASE) {
throw new ParserException("TODO " + lexer.info());
} else if (lexer.identifierEquals("tablespace")) {
throw new ParserException("TODO " + lexer.info());
} else {
SQLName tablespace = this.exprParser.name();
createTable.setTablespace(tablespace);
}
continue;
} else if (lexer.identifierEquals(FnvHash.Constants.PARTITIONING)) {
SQLPartitionByHash partitionBy = new SQLPartitionByHash();
lexer.nextToken();
accept(Token.KEY);
accept(Token.LPAREN);
this.exprParser.exprList(partitionBy.getColumns(), partitionBy);
accept(Token.RPAREN);
accept(Token.USING);
acceptIdentifier("HASHING");
createTable.setPartitioning(partitionBy);
continue;
}
break;
}
return createTable;
}
protected DB2CreateTableStatement newCreateStatement() {
return new DB2CreateTableStatement();
}
}
@@ -19,10 +19,7 @@ import java.util.List;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2ValuesStatement;
import com.alibaba.druid.sql.parser.Lexer;
import com.alibaba.druid.sql.parser.SQLParserFeature;
import com.alibaba.druid.sql.parser.SQLStatementParser;
import com.alibaba.druid.sql.parser.Token;
import com.alibaba.druid.sql.parser.*;
public class DB2StatementParser extends SQLStatementParser {
@@ -53,4 +50,8 @@ public class DB2StatementParser extends SQLStatementParser {
return false;
}
public SQLCreateTableParser getSQLCreateTableParser() {
return new DB2CreateTableParser(this.exprParser);
}
}
@@ -15,6 +15,7 @@
*/
package com.alibaba.druid.sql.dialect.db2.visitor;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2CreateTableStatement;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2SelectQueryBlock;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2ValuesStatement;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
@@ -28,4 +29,7 @@ public interface DB2ASTVisitor extends SQLASTVisitor {
boolean visit(DB2ValuesStatement x);
void endVisit(DB2ValuesStatement x);
boolean visit(DB2CreateTableStatement x);
void endVisit(DB2CreateTableStatement x);
}
@@ -15,6 +15,7 @@
*/
package com.alibaba.druid.sql.dialect.db2.visitor;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2CreateTableStatement;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2SelectQueryBlock;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2ValuesStatement;
import com.alibaba.druid.sql.visitor.SQLASTVisitorAdapter;
@@ -41,4 +42,14 @@ public class DB2ASTVisitorAdapter extends SQLASTVisitorAdapter implements DB2AST
}
@Override
public boolean visit(DB2CreateTableStatement x) {
return false;
}
@Override
public void endVisit(DB2CreateTableStatement x) {
}
}
@@ -25,6 +25,7 @@ import com.alibaba.druid.sql.ast.expr.SQLInListExpr;
import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr;
import com.alibaba.druid.sql.ast.statement.SQLSelectGroupByClause;
import com.alibaba.druid.sql.ast.statement.SQLSelectItem;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2CreateTableStatement;
import com.alibaba.druid.sql.visitor.ExportParameterVisitor;
import com.alibaba.druid.sql.visitor.ExportParameterVisitorUtils;
@@ -120,4 +121,8 @@ public class DB2ExportParameterVisitor extends DB2OutputVisitor implements Expor
return true;
}
@Override
public void endVisit(DB2CreateTableStatement x) {
}
}
@@ -15,11 +15,12 @@
*/
package com.alibaba.druid.sql.dialect.db2.visitor;
import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.druid.sql.ast.SQLOrderBy;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLPartitionBy;
import com.alibaba.druid.sql.ast.expr.SQLBinaryOperator;
import com.alibaba.druid.sql.ast.statement.SQLSelect;
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2CreateTableStatement;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2SelectQueryBlock;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2ValuesStatement;
import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;
@@ -77,7 +78,40 @@ public class DB2OutputVisitor extends SQLASTOutputVisitor implements DB2ASTVisit
public void endVisit(DB2ValuesStatement x) {
}
@Override
public boolean visit(DB2CreateTableStatement x) {
printCreateTable(x, true);
if (x.isDataCaptureNone()) {
println();
print("DATA CAPTURE NONE");
} else if (x.isDataCaptureChanges()) {
println();
print("DATA CAPTURE CHANGES");
}
SQLName tablespace = x.getTablespace();
if (tablespace != null) {
println();
print("IN ");
tablespace.accept(this);
}
SQLPartitionBy partitionBy = x.getPartitioning();
if (partitionBy != null) {
println();
partitionBy.accept(this);
}
return false;
}
@Override
public void endVisit(DB2CreateTableStatement x) {
}
protected void printOperator(SQLBinaryOperator operator) {
if (operator == SQLBinaryOperator.Concat) {
print0(ucase ? "CONCAT" : "concat");
@@ -15,12 +15,13 @@
*/
package com.alibaba.druid.sql.dialect.db2.visitor;
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2CreateTableStatement;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2SelectQueryBlock;
import com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2ValuesStatement;
import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
import com.alibaba.druid.util.JdbcConstants;
import com.alibaba.druid.util.JdbcUtils;
public class DB2SchemaStatVisitor extends SchemaStatVisitor implements DB2ASTVisitor {
public DB2SchemaStatVisitor() {
@@ -46,4 +47,14 @@ public class DB2SchemaStatVisitor extends SchemaStatVisitor implements DB2ASTVis
public void endVisit(DB2ValuesStatement x) {
}
@Override
public boolean visit(DB2CreateTableStatement x) {
return visit((SQLCreateTableStatement) x);
}
@Override
public void endVisit(DB2CreateTableStatement x) {
}
}
@@ -42,8 +42,6 @@ public class MySqlCreateTableStatement extends SQLCreateTableStatement implement
private Map<String, SQLObject> tableOptions = new LinkedHashMap<String, SQLObject>();
private SQLPartitionBy partitioning;
private List<SQLCommentHint> hints = new ArrayList<SQLCommentHint>();
private List<SQLCommentHint> optionHints = new ArrayList<SQLCommentHint>();
@@ -70,14 +68,6 @@ public class MySqlCreateTableStatement extends SQLCreateTableStatement implement
this.tableOptions = tableOptions;
}
public SQLPartitionBy getPartitioning() {
return partitioning;
}
public void setPartitioning(SQLPartitionBy partitioning) {
this.partitioning = partitioning;
}
public Map<String, SQLObject> getTableOptions() {
return tableOptions;
}
@@ -18,6 +18,7 @@ package com.alibaba.druid.sql.dialect.mysql.ast.statement;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLPartitionBy;
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject;
@@ -26,8 +27,6 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class MySqlPartitionByKey extends SQLPartitionBy implements MySqlObject {
private List<SQLName> columns = new ArrayList<SQLName>();
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor instanceof MySqlASTVisitor) {
@@ -48,21 +47,10 @@ public class MySqlPartitionByKey extends SQLPartitionBy implements MySqlObject {
visitor.endVisit(this);
}
public List<SQLName> getColumns() {
return columns;
}
public void addColumn(SQLName column) {
if (column != null) {
column.setParent(this);
}
this.columns.add(column);
}
public void cloneTo(MySqlPartitionByKey x) {
super.cloneTo(x);
for (SQLName column : columns) {
SQLName c2 = column.clone();
for (SQLExpr column : columns) {
SQLExpr c2 = column.clone();
c2.setParent(x);
x.columns.add(c2);
}
@@ -483,7 +483,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
}
accept(Token.LPAREN);
clause.setExpr(this.exprParser.expr());
this.exprParser.exprList(clause.getColumns(), clause);
accept(Token.RPAREN);
partitionClause = clause;
@@ -501,7 +501,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
clause.setExpr(this.exprParser.expr());
clause.addColumn(this.exprParser.expr());
accept(Token.RPAREN);
} else {
acceptIdentifier("COLUMNS");
@@ -576,7 +576,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
clause.setExpr(this.exprParser.expr());
clause.addColumn(this.exprParser.expr());
accept(Token.RPAREN);
} else {
acceptIdentifier("COLUMNS");
@@ -51,7 +51,8 @@ public class NameResolveVisitor extends OracleASTVisitorAdapter {
SQLTableSource tableSource = null;
if (hash == FnvHash.Constants.LEVEL
|| hash == FnvHash.Constants.CONNECT_BY_ISCYCLE) {
|| hash == FnvHash.Constants.CONNECT_BY_ISCYCLE
|| hash == FnvHash.Constants.SYSTIMESTAMP) {
return false;
}
@@ -36,8 +36,6 @@ import java.util.List;
public class OracleCreateTableStatement extends SQLCreateTableStatement implements OracleDDLStatement, OracleSegmentAttributes {
private SQLName tablespace;
private boolean inMemoryMetadata;
private boolean cursorSpecificSegment;
@@ -54,8 +52,7 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
private Integer maxtrans;
private Integer pctincrease;
private Boolean logging;
private Boolean compress;
private Integer compressLevel;
private boolean compressForOltp;
@@ -64,8 +61,6 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
private Boolean cache;
private SQLPartitionBy partitioning;
private DeferredSegmentCreation deferredSegmentCreation;
private Boolean enableRowMovement;
@@ -122,14 +117,6 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
this.deferredSegmentCreation = deferredSegmentCreation;
}
public SQLPartitionBy getPartitioning() {
return partitioning;
}
public void setPartitioning(SQLPartitionBy partitioning) {
this.partitioning = partitioning;
}
public Boolean getCache() {
return cache;
}
@@ -154,22 +141,6 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
this.onCommitDeleteRows = onCommitDeleteRows;
}
public Boolean getLogging() {
return logging;
}
public void setLogging(Boolean logging) {
this.logging = logging;
}
public Boolean getCompress() {
return compress;
}
public void setCompress(Boolean compress) {
this.compress = compress;
}
public Integer getCompressLevel() {
return compressLevel;
}
@@ -242,14 +213,6 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
this.inMemoryMetadata = inMemoryMetadata;
}
public SQLName getTablespace() {
return tablespace;
}
public void setTablespace(SQLName tablespace) {
this.tablespace = tablespace;
}
protected void accept0(SQLASTVisitor visitor) {
accept0((OracleASTVisitor) visitor);
}
@@ -333,7 +333,7 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
SQLPartitionByList partitionByList = new SQLPartitionByList();
accept(Token.LPAREN);
partitionByList.setExpr(this.exprParser.expr());
partitionByList.addColumn(this.exprParser.expr());
accept(Token.RPAREN);
this.getExprParser().parsePartitionByRest(partitionByList);
@@ -1731,7 +1731,7 @@ public class OracleExprParser extends SQLExprParser {
}
accept(Token.LPAREN);
partitionByHash.setExpr(this.expr());
this.exprList(partitionByHash.getColumns(), partitionByHash);
accept(Token.RPAREN);
return partitionByHash;
}
@@ -119,15 +119,6 @@ public class SQLCreateTableParser extends SQLDDLParser {
break;
}
// while
// (this.tokenList.current().equals(OracleToken.ConstraintToken)) {
// parseConstaint(table.getConstraints());
//
// if (this.tokenList.current().equals(OracleToken.CommaToken))
// ;
// lexer.nextToken();
// }
accept(Token.RPAREN);
if (lexer.identifierEquals("INHERITS")) {
@@ -4530,9 +4530,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
@Override
public boolean visit(SQLPartitionByRange x) {
print0(ucase ? "PARTITION BY RANGE" : "partition by range");
if (x.getExpr() != null) {
if (x.getColumns().size() == 1) {
print0(" (");
x.getExpr().accept(this);
x.getColumns().get(0).accept(this);
print(')');
} else {
if (JdbcConstants.MYSQL.equals(getDbType())) {
@@ -4572,9 +4572,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
@Override
public boolean visit(SQLPartitionByList x) {
print0(ucase ? "PARTITION BY LIST " : "partition by list ");
if (x.getExpr() != null) {
if (x.getColumns().size() == 1) {
print('(');
x.getExpr().accept(this);
x.getColumns().get(0).accept(this);
print0(")");
} else {
print0(ucase ? "COLUMNS (" : "columns (");
@@ -4601,7 +4601,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
}
print('(');
x.getExpr().accept(this);
printAndAccept(x.getColumns(), ", ");
print(')');
printPartitionsCountAndSubPartitions(x);
@@ -510,5 +510,7 @@ public final class FnvHash {
long NUMTODSINTERVAL = fnv1a_64_lower("NUMTODSINTERVAL");
long LATERAL = fnv1a_64_lower("LATERAL");
long NONE = fnv1a_64_lower("NONE");
long PARTITIONING = fnv1a_64_lower("PARTITIONING");
}
}