improved mysql/oracle sql parser.

This commit is contained in:
wenshao
2017-05-20 22:03:21 +08:00
parent ae0ae2e9e0
commit ac4b6059f0
53 changed files with 1449 additions and 296 deletions
@@ -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;
@@ -15,6 +15,7 @@
*/
package com.alibaba.druid.sql.dialect.oracle.ast;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
@@ -31,4 +32,8 @@ public abstract class OracleSQLObjectImpl extends SQLObjectImpl implements Oracl
}
public abstract void accept0(OracleASTVisitor visitor);
public SQLExpr clone() {
throw new UnsupportedOperationException();
}
}
@@ -41,6 +41,11 @@ public class OracleLobStorageClause extends OracleSQLObjectImpl {
private Boolean compress;
private Boolean keepDuplicate;
private boolean retention;
private OracleStorageClause storageClause;
private SQLExpr pctversion;
@Override
public void accept0(OracleASTVisitor visitor) {
@@ -127,4 +132,33 @@ public class OracleLobStorageClause extends OracleSQLObjectImpl {
this.keepDuplicate = keepDuplicate;
}
public boolean isRetention() {
return retention;
}
public void setRetention(boolean retention) {
this.retention = retention;
}
public OracleStorageClause getStorageClause() {
return storageClause;
}
public void setStorageClause(OracleStorageClause storageClause) {
if (storageClause != null) {
storageClause.setParent(this);
}
this.storageClause = storageClause;
}
public SQLExpr getPctversion() {
return pctversion;
}
public void setPctversion(SQLExpr pctversion) {
if (pctversion != null) {
pctversion.setParent(this);
}
this.pctversion = pctversion;
}
}
@@ -150,4 +150,6 @@ public class OracleStorageClause extends OracleSQLObjectImpl {
public static enum FlashCacheType {
KEEP, NONE, DEFAULT
}
}
@@ -57,6 +57,15 @@ public class OracleAnalyticWindowing extends SQLObjectImpl implements OracleExpr
this.type = type;
}
public SQLExpr clone() {
OracleAnalyticWindowing x = new OracleAnalyticWindowing();
x.type = type;
if (expr != null) {
this.setExpr(expr.clone());
}
return x;
}
public static enum Type {
ROWS, RANGE;
}
@@ -106,4 +106,15 @@ public class OracleDbLinkExpr extends SQLExprImpl implements SQLName, OracleExpr
}
return true;
}
public OracleDbLinkExpr clone() {
OracleDbLinkExpr x = new OracleDbLinkExpr();
if (expr != null) {
expr = expr.clone();
}
x.dbLink = dbLink;
return x;
}
}
@@ -53,9 +53,13 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
private Boolean cache;
private SQLPartitionBy partitioning;
private SQLPartitionBy partitioning;
private DeferredSegmentCreation deferredSegmentCreation;
private boolean forOLTP;
private Boolean enableRowMovement;
public OracleCreateTableStatement() {
super (JdbcConstants.ORACLE);
@@ -206,9 +210,28 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
}
public void setStorage(OracleStorageClause storage) {
if (storage != null) {
storage.setParent(this);
}
this.storage = storage;
}
public boolean isForOLTP() {
return forOLTP;
}
public void setForOLTP(boolean forOLTP) {
this.forOLTP = forOLTP;
}
public Boolean getEnableRowMovement() {
return enableRowMovement;
}
public void setEnableRowMovement(Boolean enableRowMovement) {
this.enableRowMovement = enableRowMovement;
}
public void accept0(OracleASTVisitor visitor) {
if (visitor.visit(this)) {
this.acceptChild(visitor, tableSource);
@@ -21,14 +21,15 @@ import java.util.List;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.statement.SQLPrimaryKey;
import com.alibaba.druid.sql.ast.statement.SQLPrimaryKeyImpl;
import com.alibaba.druid.sql.ast.statement.SQLTableElement;
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class OraclePrimaryKey extends OracleSQLObjectImpl implements OracleConstraint, SQLPrimaryKey, SQLTableElement {
public class OraclePrimaryKey extends SQLPrimaryKeyImpl implements OracleConstraint, SQLPrimaryKey, SQLTableElement {
private SQLName name;
private List<SQLExpr> columns = new ArrayList<SQLExpr>();
private OracleUsingIndexClause using;
private SQLName exceptionsInto;
@@ -36,6 +37,11 @@ public class OraclePrimaryKey extends OracleSQLObjectImpl implements OracleConst
private Initially initially;
private Boolean deferrable;
@Override
protected void accept0(SQLASTVisitor visitor) {
this.accept0((OracleASTVisitor) visitor);
}
@Override
public void accept0(OracleASTVisitor visitor) {
if (visitor.visit(this)) {
@@ -67,10 +73,6 @@ public class OraclePrimaryKey extends OracleSQLObjectImpl implements OracleConst
return columns;
}
public void setColumns(List<SQLExpr> columns) {
this.columns = columns;
}
public OracleUsingIndexClause getUsing() {
return using;
}
@@ -21,8 +21,6 @@ import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class OracleSelect extends SQLSelect {
private OracleSelectForUpdate forUpdate;
private OracleSelectRestriction restriction;
public OracleSelect(){
@@ -37,14 +35,6 @@ public class OracleSelect extends SQLSelect {
this.restriction = restriction;
}
public OracleSelectForUpdate getForUpdate() {
return this.forUpdate;
}
public void setForUpdate(OracleSelectForUpdate forUpdate) {
this.forUpdate = forUpdate;
}
public void output(StringBuffer buf) {
this.query.output(buf);
buf.append(" ");
@@ -64,7 +54,6 @@ public class OracleSelect extends SQLSelect {
acceptChild(visitor, this.query);
acceptChild(visitor, this.restriction);
acceptChild(visitor, this.orderBy);
acceptChild(visitor, this.forUpdate);
}
visitor.endVisit(this);
}
@@ -20,6 +20,7 @@ import java.util.List;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLCommentHint;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
import com.alibaba.druid.sql.dialect.oracle.ast.clause.ModelClause;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
@@ -31,6 +32,9 @@ public class OracleSelectQueryBlock extends SQLSelectQueryBlock {
private ModelClause modelClause;
private final List<SQLExpr> forUpdateOf = new ArrayList<SQLExpr>(1);
private boolean skipLocked = false;
public OracleSelectQueryBlock(){
}
@@ -47,6 +51,18 @@ public class OracleSelectQueryBlock extends SQLSelectQueryBlock {
return this.hints;
}
public List<SQLExpr> getForUpdateOf() {
return forUpdateOf;
}
public boolean isSkipLocked() {
return skipLocked;
}
public void setSkipLocked(boolean skipLocked) {
this.skipLocked = skipLocked;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor instanceof OracleASTVisitor) {
@@ -68,6 +84,7 @@ public class OracleSelectQueryBlock extends SQLSelectQueryBlock {
acceptChild(visitor, this.connectBy);
acceptChild(visitor, this.groupBy);
acceptChild(visitor, this.modelClause);
acceptChild(visitor, this.forUpdateOf);
}
visitor.endVisit(this);
}
@@ -0,0 +1,78 @@
/*
* 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.oracle.ast.stmt;
import com.alibaba.druid.sql.ast.statement.SQLTableElement;
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
/**
* Created by wenshao on 20/05/2017.
*/
public class OracleSupplementalIdKey extends OracleSQLObjectImpl implements SQLTableElement {
private boolean all;
private boolean primaryKey;
private boolean unique;
private boolean uniqueIndex;
private boolean foreignKey;
@Override
public void accept0(OracleASTVisitor visitor) {
visitor.visit(this);
visitor.endVisit(this);
}
public boolean isAll() {
return all;
}
public void setAll(boolean all) {
this.all = all;
}
public boolean isPrimaryKey() {
return primaryKey;
}
public void setPrimaryKey(boolean primaryKey) {
this.primaryKey = primaryKey;
}
public boolean isUnique() {
return unique;
}
public void setUnique(boolean unique) {
this.unique = unique;
}
public boolean isForeignKey() {
return foreignKey;
}
public void setForeignKey(boolean foreignKey) {
this.foreignKey = foreignKey;
}
public boolean isUniqueIndex() {
return uniqueIndex;
}
public void setUniqueIndex(boolean uniqueIndex) {
this.uniqueIndex = uniqueIndex;
}
}
@@ -1,73 +1,72 @@
/*
* 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.oracle.ast.stmt;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
public class OracleSelectForUpdate extends OracleSQLObjectImpl {
private final List<SQLExpr> of = new ArrayList<SQLExpr>();
private boolean notWait = false;
private SQLExpr wait;
private boolean skipLocked = false;
public OracleSelectForUpdate(){
}
public boolean isNotWait() {
return notWait;
}
public void setNotWait(boolean notWait) {
this.notWait = notWait;
}
public SQLExpr getWait() {
return wait;
}
public void setWait(SQLExpr wait) {
this.wait = wait;
}
public boolean isSkipLocked() {
return skipLocked;
}
public void setSkipLocked(boolean skipLocked) {
this.skipLocked = skipLocked;
}
public void accept0(OracleASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, this.of);
acceptChild(visitor, this.wait);
}
visitor.endVisit(this);
}
public List<SQLExpr> getOf() {
return this.of;
}
}
/*
* 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.oracle.ast.stmt;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.statement.SQLTableElement;
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import java.util.ArrayList;
import java.util.List;
/**
* Created by wenshao on 20/05/2017.
*/
public class OracleSupplementalLogGrp extends OracleSQLObjectImpl implements SQLTableElement {
private SQLName group;
private List<SQLName> columns = new ArrayList<SQLName>();
private boolean always = false;
@Override
public void accept0(OracleASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, group);
acceptChild(visitor, columns);
}
visitor.endVisit(this);
}
public SQLName getGroup() {
return group;
}
public void setGroup(SQLName group) {
if (group != null) {
group.setParent(this);
}
this.group = group;
}
public List<SQLName> getColumns() {
return columns;
}
public void addColumn(SQLName column) {
if (column != null) {
column.setParent(this);
}
this.columns.add(column);
}
public boolean isAlways() {
return always;
}
public void setAlways(boolean always) {
this.always = always;
}
}
@@ -21,6 +21,9 @@ import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
import com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleStorageClause;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class OracleUsingIndexClause extends OracleSQLObjectImpl {
private SQLName index;
@@ -37,6 +40,12 @@ public class OracleUsingIndexClause extends OracleSQLObjectImpl {
private OracleStorageClause storage;
private Integer compress = null;
private boolean nocompress = false;
private Boolean logging = null;
private List<PartitionedItem> localPartitionIndex = new ArrayList<PartitionedItem>();
public OracleUsingIndexClause(){
}
@@ -123,4 +132,57 @@ public class OracleUsingIndexClause extends OracleSQLObjectImpl {
this.maxtrans = maxtrans;
}
public Integer getCompress() {
return compress;
}
public void setCompress(Integer compress) {
this.compress = compress;
}
public boolean isNocompress() {
return nocompress;
}
public void setNocompress(boolean nocompress) {
this.nocompress = nocompress;
}
public Boolean getLogging() {
return logging;
}
public void setLogging(Boolean logging) {
this.logging = logging;
}
public List<PartitionedItem> getLocalPartitionIndex() {
return localPartitionIndex;
}
public static class PartitionedItem extends OracleSQLObjectImpl {
private SQLName partition;
private SQLName tablespace;
@Override
public void accept0(OracleASTVisitor visitor) {
}
public SQLName getPartition() {
return partition;
}
public void setPartition(SQLName partition) {
this.partition = partition;
}
public SQLName getTablespace() {
return tablespace;
}
public void setTablespace(SQLName tablespace) {
this.tablespace = tablespace;
}
}
}
@@ -27,16 +27,21 @@ import com.alibaba.druid.sql.ast.SQLSubPartition;
import com.alibaba.druid.sql.ast.SQLSubPartitionBy;
import com.alibaba.druid.sql.ast.SQLSubPartitionByHash;
import com.alibaba.druid.sql.ast.SQLSubPartitionByList;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
import com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleLobStorageClause;
import com.alibaba.druid.sql.dialect.oracle.ast.clause.OracleStorageClause;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleCreateTableStatement;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleCreateTableStatement.DeferredSegmentCreation;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelect;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSupplementalIdKey;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSupplementalLogGrp;
import com.alibaba.druid.sql.parser.Lexer;
import com.alibaba.druid.sql.parser.ParserException;
import com.alibaba.druid.sql.parser.SQLCreateTableParser;
import com.alibaba.druid.sql.parser.Token;
import com.sun.org.apache.xpath.internal.operations.Bool;
public class OracleCreateTableParser extends SQLCreateTableParser {
@@ -76,6 +81,10 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
lexer.nextToken();
stmt.setLogging(Boolean.TRUE);
continue;
} else if (identifierEquals("NOLOGGING")) {
lexer.nextToken();
stmt.setLogging(Boolean.FALSE);
continue;
} else if (lexer.token() == Token.CACHE) {
lexer.nextToken();
stmt.setCache(Boolean.TRUE);
@@ -84,10 +93,48 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
lexer.nextToken();
stmt.setCache(Boolean.FALSE);
continue;
} else if (lexer.token() == Token.NOCOMPRESS) {
} else if (lexer.token() == Token.ENABLE) {
lexer.nextToken();
if (lexer.token() == Token.ROW) {
lexer.nextToken();
acceptIdentifier("MOVEMENT");
stmt.setEnableRowMovement(Boolean.TRUE);
} else {
throw new ParserException("TODO : " + lexer.info());
}
//stmt.setEnable(Boolean.TRUE);
continue;
} else if (lexer.token() == Token.DISABLE) {
lexer.nextToken();
if (lexer.token() == Token.ROW) {
lexer.nextToken();
acceptIdentifier("MOVEMENT");
stmt.setEnableRowMovement(Boolean.FALSE);
} else {
throw new ParserException("TODO : " + lexer.info());
}
//stmt.setEnable(Boolean.FALSE);
continue;
} else if (lexer.token() == Token.NOCOMPRESS || identifierEquals("NOCOMPRESS")) {
lexer.nextToken();
stmt.setCompress(Boolean.FALSE);
continue;
} else if (identifierEquals("COMPRESS")) {
lexer.nextToken();
stmt.setCompress(Boolean.TRUE);
continue;
} else if (lexer.token() == Token.FOR) {
lexer.nextToken();
if (lexer.token() == Token.ALL) {
lexer.nextToken();
throw new ParserException("TODO : " + lexer.info());
} else if (identifierEquals("OLTP")) {
lexer.nextToken();
stmt.setForOLTP(true);
} else {
throw new ParserException("TODO : " + lexer.info());
}
continue;
} else if (lexer.token() == Token.ON) {
lexer.nextToken();
accept(Token.COMMIT);
@@ -104,8 +151,16 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
continue;
} else if (identifierEquals("organization")) {
lexer.nextToken();
accept(Token.INDEX);
stmt.setOrganizationIndex(true);
if (lexer.token() == Token.INDEX) {
lexer.nextToken();
stmt.setOrganizationIndex(true);
} else if (identifierEquals("EXTERNAL")) {
lexer.nextToken();
accept(Token.LPAREN);
throw new ParserException("TODO " + lexer.info());
} else {
throw new ParserException("TODO " + lexer.info());
}
continue;
} else if (lexer.token() == Token.PCTFREE) {
lexer.nextToken();
@@ -142,7 +197,7 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
stmt.setDeferredSegmentCreation(DeferredSegmentCreation.DEFERRED);
}
continue;
} else if (identifierEquals("PARTITION")) {
} else if (lexer.token() == Token.PARTITION) {
lexer.nextToken();
accept(Token.BY);
@@ -155,6 +210,22 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
} else if (identifierEquals("HASH")) {
SQLPartitionByHash partitionByHash = partitionByHash();
partitionClauseRest(partitionByHash);
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
for (;;) {
SQLPartition partition = this.parsePartition();
partitionByHash.addPartition(partition);
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
} else if (lexer.token() == Token.RPAREN) {
lexer.nextToken();
break;
}
throw new ParserException("TODO : " + lexer.token() + " " + lexer.stringVal());
}
}
stmt.setPartitioning(partitionByHash);
continue;
} else if (identifierEquals("LIST")) {
@@ -260,6 +331,7 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
clause.setSubPartitionBy(subPartitionBy);
}
accept(Token.LPAREN);
for (;;) {
@@ -279,7 +351,7 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
}
protected SQLPartition parsePartition() {
acceptIdentifier("PARTITION");
accept(Token.PARTITION);
SQLPartition partition = new SQLPartition();
partition.setName(this.exprParser.name());
@@ -310,6 +382,47 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
SQLExpr subPartitionsCount = this.exprParser.primary();
partition.setSubPartitionsCount(subPartitionsCount);
}
for (;;) {
if (lexer.token() == Token.TABLESPACE) {
lexer.nextToken();
partition.setTablespace(this.exprParser.name());
continue;
} else if (lexer.token() == Token.PCTFREE) {
lexer.nextToken();
partition.setPtcfree(this.exprParser.expr());
continue;
} else if (identifierEquals("PCTUSED")) {
lexer.nextToken();
partition.setPctused(this.exprParser.expr());
continue;
} else if (lexer.token() == Token.STORAGE) {
OracleStorageClause storage = ((OracleExprParser) this.exprParser).parseStorage();
partition.setStorage(storage);
continue;
} else if (lexer.token() == Token.INITRANS) {
lexer.nextToken();
partition.setInitrans(this.exprParser.expr());
continue;
} else if (lexer.token() == Token.MAXTRANS) {
lexer.nextToken();
partition.setMaxtrans(this.exprParser.expr());
continue;
} else if (lexer.token() == Token.NOCOMPRESS) {
lexer.nextToken();
partition.setCompress(Boolean.FALSE);
continue;
} else if (identifierEquals("COMPRESS")) {
lexer.nextToken();
partition.setCompress(Boolean.TRUE);
continue;
} else if (lexer.token() == Token.LOB) {
OracleLobStorageClause lobStorage = ((OracleExprParser) this.exprParser).parseLobStorage();
partition.setLobStorage(lobStorage);
continue;
}
break;
}
return partition;
}
@@ -393,4 +506,91 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
throw new ParserException("TODO : " + lexer.token() + " " + lexer.stringVal());
}
protected void parseCreateTableSupplementalLogingProps(SQLCreateTableStatement stmt) {
acceptIdentifier("SUPPLEMENTAL");
acceptIdentifier("LOG");
if (lexer.token() == Token.GROUP) {
lexer.nextToken();
OracleSupplementalLogGrp logGrp = new OracleSupplementalLogGrp();
logGrp.setGroup(this.exprParser.name());
accept(Token.LPAREN);
for (;;) {
SQLName column = this.exprParser.name();
if (identifierEquals("NO")) {
lexer.nextToken();
acceptIdentifier("LOG");
column.putAttribute("NO LOG", Boolean.TRUE);
}
logGrp.addColumn(column);
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
}
if (lexer.token() == Token.RPAREN) {
break;
}
throw new ParserException("TODO " + lexer.info());
}
accept(Token.RPAREN);
if (identifierEquals("ALWAYS")) {
lexer.nextToken();
logGrp.setAlways(true);
}
logGrp.setParent(stmt);
stmt.getTableElementList().add(logGrp);
} else {
acceptIdentifier("DATA");
OracleSupplementalIdKey idKey = new OracleSupplementalIdKey();
accept(Token.LPAREN);
for (;;) {
if (lexer.token() == Token.ALL) {
lexer.nextToken();
idKey.setAll(true);
} else if (lexer.token() == Token.PRIMARY) {
lexer.nextToken();
accept(Token.KEY);
idKey.setPrimaryKey(true);
} else if (lexer.token() == Token.UNIQUE) {
lexer.nextToken();
if (lexer.token() == Token.INDEX) {
lexer.nextToken();
idKey.setUniqueIndex(true);
} else {
idKey.setUnique(true);
}
} else if (lexer.token() == Token.FOREIGN) {
lexer.nextToken();
accept(Token.KEY);
idKey.setForeignKey(true);
}
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
}
if (lexer.token() == Token.RPAREN) {
break;
}
throw new ParserException("TODO " + lexer.info());
}
accept(Token.RPAREN);
acceptIdentifier("COLUMNS");
idKey.setParent(stmt);
stmt.getTableElementList().add(idKey);
}
}
}
@@ -211,8 +211,13 @@ public class OracleExprParser extends SQLExprParser {
lexer.nextToken();
} else if (identifierEquals("LONG")) {
lexer.nextToken();
acceptIdentifier("RAW");
typeName = "LONG RAW";
if (identifierEquals("RAW")) {
lexer.nextToken();
typeName = "LONG RAW";
} else {
typeName = "LONG";
}
} else {
SQLName typeExpr = name();
typeName = typeExpr.toString();
@@ -788,7 +793,7 @@ public class OracleExprParser extends SQLExprParser {
lexer.nextToken();
accept(Token.LPAREN);
if (identifierEquals("PARTITION")) {
if (lexer.token() == Token.PARTITION) {
lexer.nextToken();
accept(Token.BY);
@@ -1028,7 +1033,7 @@ public class OracleExprParser extends SQLExprParser {
private OracleUsingIndexClause parseUsingIndex() {
accept(Token.USING);
accept(Token.INDEX);
OracleUsingIndexClause using = new OracleUsingIndexClause();
for (;;) {
@@ -1065,9 +1070,50 @@ public class OracleExprParser extends SQLExprParser {
OracleStorageClause storage = parseStorage();
using.setStorage(storage);
continue;
} else if (identifierEquals("LOCAL")) {
lexer.nextToken();
accept(Token.LPAREN);
// http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5010.htm#i2125897
for (;;) {
accept(Token.PARTITION);
OracleUsingIndexClause.PartitionedItem item = new OracleUsingIndexClause.PartitionedItem();
item.setPartition(this.name());
if (lexer.token() == Token.TABLESPACE) {
lexer.nextToken();
item.setTablespace(this.name());
}
using.getLocalPartitionIndex().add(item);
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
} else if (lexer.token() == Token.RPAREN) {
break;
} else {
throw new ParserException("TODO " + lexer.token());
}
}
accept(Token.RPAREN);
continue;
} else if (identifierEquals("NOLOGGING")) {
lexer.nextToken();
using.setLogging(Boolean.FALSE);
continue;
} else if (identifierEquals("COMPRESS")) {
throw new ParserException("TODO " + lexer.token());
} else if (lexer.token() == Token.IDENTIFIER) {
using.setTablespace(this.name());
break;
} else if (lexer.token() == Token.NOCOMPRESS || identifierEquals("NOCOMPRESS")) {
lexer.nextToken();
using.setNocompress(true);
continue;
} else if (lexer.token() == Token.LOGGING || identifierEquals("LOGGING")) {
lexer.nextToken();
using.setLogging(Boolean.TRUE);
continue;
} else {
break;
}
@@ -1081,6 +1127,21 @@ public class OracleExprParser extends SQLExprParser {
if (lexer.token() == Token.ENABLE) {
lexer.nextToken();
column.setEnable(Boolean.TRUE);
} else if (lexer.token() == Token.ENABLE) {
lexer.nextToken();
column.setEnable(true);
} else if (identifierEquals("VALIDATE")) {
lexer.nextToken();
column.setValidate(Boolean.TRUE);
} else if (identifierEquals("NOVALIDATE")) {
lexer.nextToken();
column.setValidate(Boolean.FALSE);
} else if (identifierEquals("RELY")) {
lexer.nextToken();
column.setRely(Boolean.TRUE);
} else if (identifierEquals("NORELY")) {
lexer.nextToken();
column.setRely(Boolean.FALSE);
}
return column;
@@ -1140,6 +1201,13 @@ public class OracleExprParser extends SQLExprParser {
accept(Token.ROW);
clause.setEnable(true);
continue;
} else if (lexer.token() == Token.DISABLE) {
lexer.nextToken();
accept(Token.STORAGE);
accept(Token.IN);
accept(Token.ROW);
clause.setEnable(false);
continue;
}
if (lexer.token() == Token.CHUNK) {
@@ -1169,6 +1237,24 @@ public class OracleExprParser extends SQLExprParser {
clause.setKeepDuplicate(true);
continue;
}
if (identifierEquals("PCTVERSION")) {
lexer.nextToken();
clause.setPctversion(this.expr());
continue;
}
if (identifierEquals("RETENTION")) {
lexer.nextToken();
clause.setRetention(true);
continue;
}
if (lexer.token() == Token.STORAGE) {
OracleStorageClause storageClause = this.parseStorage();
clause.setStorageClause(storageClause);
continue;
}
break;
}
@@ -1342,7 +1428,7 @@ public class OracleExprParser extends SQLExprParser {
return constraint;
}
protected SQLForeignKeyConstraint createForeignKey() {
protected OracleForeignKey createForeignKey() {
return new OracleForeignKey();
}
@@ -112,6 +112,8 @@ public class OracleLexer extends Lexer {
map.put("INITIALLY", Token.INITIALLY);
map.put("FETCH", Token.FETCH);
map.put("TABLESPACE", Token.TABLESPACE);
map.put("PARTITION", Token.PARTITION);
DEFAULT_ORACLE_KEYWORDS = new Keywords(map);
}
@@ -216,7 +218,7 @@ public class OracleLexer extends Lexer {
bufPos++;
}
for (;;) {
for (;!isEOF();) {
if (ch == '*' && charAt(pos + 1) == '/') {
bufPos += 2;
scanChar();
@@ -48,7 +48,6 @@ import com.alibaba.druid.sql.dialect.oracle.ast.clause.PartitionExtensionClause;
import com.alibaba.druid.sql.dialect.oracle.ast.clause.SampleClause;
import com.alibaba.druid.sql.dialect.oracle.ast.clause.SearchClause;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelect;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelectForUpdate;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelectJoin;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelectPivot;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelectQueryBlock;
@@ -82,35 +81,43 @@ public class OracleSelectParser extends SQLSelectParser {
SQLOrderBy orderBy = this.parseOrderBy();
select.setOrderBy(orderBy);
if (orderBy != null && query instanceof SQLSelectQueryBlock) {
SQLSelectQueryBlock queryBlock = (SQLSelectQueryBlock) query;
parseFetchClause(queryBlock);
OracleSelectQueryBlock queryBlock = null;
if (query instanceof SQLSelectQueryBlock) {
queryBlock = (OracleSelectQueryBlock) query;
if (orderBy != null) {
parseFetchClause(queryBlock);
}
}
if (lexer.token() == (Token.FOR)) {
if (queryBlock == null) {
throw new ParserException("TODO");
}
lexer.nextToken();
accept(Token.UPDATE);
OracleSelectForUpdate forUpdate = new OracleSelectForUpdate();
queryBlock.setForUpdate(true);
// OracleSelectForUpdate forUpdate = new OracleSelectForUpdate();
if (lexer.token() == Token.OF) {
lexer.nextToken();
this.exprParser.exprList(forUpdate.getOf(), forUpdate);
this.exprParser.exprList(queryBlock.getForUpdateOf(), queryBlock);
}
if (lexer.token() == Token.NOWAIT) {
lexer.nextToken();
forUpdate.setNotWait(true);
queryBlock.setNoWait(true);
} else if (lexer.token() == Token.WAIT) {
lexer.nextToken();
forUpdate.setWait(this.exprParser.primary());
queryBlock.setWaitTime(this.exprParser.primary());
} else if (identifierEquals("SKIP")) {
lexer.nextToken();
acceptIdentifier("LOCKED");
forUpdate.setSkipLocked(true);
queryBlock.setSkipLocked(true);
}
select.setForUpdate(forUpdate);
}
if (select.getOrderBy() == null) {
@@ -518,7 +525,7 @@ public class OracleSelectParser extends SQLSelectParser {
}
private void parseQueryPartitionClause(ModelColumnClause modelColumnClause) {
if (identifierEquals("PARTITION")) {
if (lexer.token() == Token.PARTITION) {
QueryPartitionClause queryPartitionClause = new QueryPartitionClause();
lexer.nextToken();
@@ -568,6 +575,16 @@ public class OracleSelectParser extends SQLSelectParser {
@Override
public SQLTableSource parseTableSource() {
SQLTableSource tableSource = parseTableSourcePrimary();
if (tableSource instanceof OracleSelectTableSource) {
return parseTableSourceRest((OracleSelectTableSource) tableSource);
}
return parseTableSourceRest(tableSource);
}
public SQLTableSource parseTableSourcePrimary() {
if (lexer.token() == (Token.LPAREN)) {
lexer.nextToken();
OracleSelectSubqueryTableSource tableSource;
@@ -582,7 +599,7 @@ public class OracleSelectParser extends SQLSelectParser {
parsePivot((OracleSelectTableSource) tableSource);
return parseTableSourceRest(tableSource);
return tableSource;
}
if (lexer.token() == (Token.SELECT)) {
@@ -602,7 +619,7 @@ public class OracleSelectParser extends SQLSelectParser {
parsePivot(tableReference);
}
return parseTableSourceRest(tableReference);
return tableReference;
}
private void parseTableSourceQueryTableExpr(OracleSelectTableReference tableReference) {
@@ -637,7 +654,7 @@ public class OracleSelectParser extends SQLSelectParser {
tableReference.setSampleClause(sample);
}
if (identifierEquals("PARTITION")) {
if (lexer.token() == Token.PARTITION) {
lexer.nextToken();
PartitionExtensionClause partition = new PartitionExtensionClause();
@@ -742,6 +759,22 @@ public class OracleSelectParser extends SQLSelectParser {
return null;
}
protected SQLTableSource primaryTableSourceRest(SQLTableSource tableSource) {
if (tableSource instanceof OracleSelectTableSource) {
if (lexer.token() == Token.AS) {
lexer.nextToken();
if (lexer.token() == Token.OF) {
((OracleSelectTableSource)tableSource).setFlashback(flashback());
}
tableSource.setAlias(tableAlias());
}
}
return tableSource;
}
protected SQLTableSource parseTableSourceRest(OracleSelectTableSource tableSource) {
if (lexer.token() == Token.AS) {
lexer.nextToken();
@@ -761,7 +794,7 @@ public class OracleSelectParser extends SQLSelectParser {
this.exprParser.parseHints(tableSource.getHints());
}
OracleSelectJoin.JoinType joinType = null;
SQLJoinTableSource.JoinType joinType = null;
if (lexer.token() == Token.LEFT) {
lexer.nextToken();
@@ -769,7 +802,7 @@ public class OracleSelectParser extends SQLSelectParser {
lexer.nextToken();
}
accept(Token.JOIN);
joinType = OracleSelectJoin.JoinType.LEFT_OUTER_JOIN;
joinType = SQLJoinTableSource.JoinType.LEFT_OUTER_JOIN;
}
if (lexer.token() == Token.RIGHT) {
@@ -778,7 +811,7 @@ public class OracleSelectParser extends SQLSelectParser {
lexer.nextToken();
}
accept(Token.JOIN);
joinType = OracleSelectJoin.JoinType.RIGHT_OUTER_JOIN;
joinType = SQLJoinTableSource.JoinType.RIGHT_OUTER_JOIN;
}
if (lexer.token() == Token.FULL) {
@@ -787,35 +820,39 @@ public class OracleSelectParser extends SQLSelectParser {
lexer.nextToken();
}
accept(Token.JOIN);
joinType = OracleSelectJoin.JoinType.FULL_OUTER_JOIN;
joinType = SQLJoinTableSource.JoinType.FULL_OUTER_JOIN;
}
if (lexer.token() == Token.INNER) {
lexer.nextToken();
accept(Token.JOIN);
joinType = OracleSelectJoin.JoinType.INNER_JOIN;
joinType = SQLJoinTableSource.JoinType.INNER_JOIN;
}
if (lexer.token() == Token.CROSS) {
lexer.nextToken();
accept(Token.JOIN);
joinType = OracleSelectJoin.JoinType.CROSS_JOIN;
joinType = SQLJoinTableSource.JoinType.CROSS_JOIN;
}
if (lexer.token() == Token.JOIN) {
lexer.nextToken();
joinType = OracleSelectJoin.JoinType.JOIN;
joinType = SQLJoinTableSource.JoinType.JOIN;
}
if (lexer.token() == (Token.COMMA)) {
lexer.nextToken();
joinType = OracleSelectJoin.JoinType.COMMA;
joinType = SQLJoinTableSource.JoinType.COMMA;
}
if (joinType != null) {
OracleSelectJoin join = new OracleSelectJoin();
join.setLeft(tableSource);
join.setJoinType(joinType);
join.setRight(parseTableSource());
SQLTableSource right;
right = parseTableSourcePrimary();
right.setAlias(this.tableAlias());
join.setRight(right);
if (lexer.token() == Token.ON) {
lexer.nextToken();
@@ -262,7 +262,7 @@ public class OracleStatementParser extends SQLStatementParser {
statementList.add(this.parseSelect());
continue;
} else {
throw new ParserException("TODO : " + lexer.token() + " " + lexer.stringVal());
throw new ParserException("TODO : " + lexer.info());
}
}
@@ -495,7 +495,7 @@ public class OracleStatementParser extends SQLStatementParser {
break;
}
throw new ParserException("TODO : " + lexer.token() + " " + lexer.stringVal());
throw new ParserException("TODO : " + lexer.info());
}
}
@@ -935,7 +935,7 @@ public class OracleStatementParser extends SQLStatementParser {
continue;
} else if (lexer.token() == Token.TRUNCATE) {
lexer.nextToken();
if (identifierEquals("PARTITION")) {
if (lexer.token() == Token.PARTITION) {
lexer.nextToken();
OracleAlterTableTruncatePartition item = new OracleAlterTableTruncatePartition();
item.setName(this.exprParser.name());
@@ -1005,7 +1005,7 @@ public class OracleStatementParser extends SQLStatementParser {
SQLAlterTableDropColumnItem item = new SQLAlterTableDropColumnItem();
this.exprParser.names(item.getColumns());
stmt.addItem(item);
} else if (identifierEquals("PARTITION")) {
} else if (lexer.token() == Token.PARTITION) {
lexer.nextToken();
OracleAlterTableDropPartition item = new OracleAlterTableDropPartition();
item.setName(this.exprParser.name());
@@ -1023,7 +1023,7 @@ public class OracleStatementParser extends SQLStatementParser {
private void parseAlterTableSplit(SQLAlterTableStatement stmt) {
lexer.nextToken();
if (identifierEquals("PARTITION")) {
if (lexer.token() == Token.PARTITION) {
lexer.nextToken();
OracleAlterTableSplitPartition item = new OracleAlterTableSplitPartition();
item.setName(this.exprParser.name());
@@ -1043,7 +1043,7 @@ public class OracleStatementParser extends SQLStatementParser {
for (;;) {
NestedTablePartitionSpec spec = new NestedTablePartitionSpec();
acceptIdentifier("PARTITION");
accept(Token.PARTITION);
spec.setPartition(this.exprParser.name());
for (;;) {
@@ -69,8 +69,6 @@ public interface OracleASTVisitor extends SQLASTVisitor {
void endVisit(OracleOuterExpr x);
void endVisit(OracleSelectForUpdate x);
void endVisit(OracleSelectJoin x);
void endVisit(OracleSelectPivot x);
@@ -103,8 +101,6 @@ public interface OracleASTVisitor extends SQLASTVisitor {
boolean visit(OracleOuterExpr x);
boolean visit(OracleSelectForUpdate x);
boolean visit(OracleSelectJoin x);
boolean visit(OracleSelectPivot x);
@@ -444,4 +440,12 @@ public interface OracleASTVisitor extends SQLASTVisitor {
boolean visit(OracleCheck x);
void endVisit(OracleCheck x);
boolean visit(OracleSupplementalIdKey x);
void endVisit(OracleSupplementalIdKey x);
boolean visit(OracleSupplementalLogGrp x);
void endVisit(OracleSupplementalLogGrp x);
}
@@ -107,11 +107,6 @@ public class OracleASTVisitorAdapter extends SQLASTVisitorAdapter implements Ora
}
@Override
public void endVisit(OracleSelectForUpdate x) {
}
@Override
public void endVisit(OracleSelectJoin x) {
@@ -194,12 +189,6 @@ public class OracleASTVisitorAdapter extends SQLASTVisitorAdapter implements Ora
return true;
}
@Override
public boolean visit(OracleSelectForUpdate x) {
return true;
}
@Override
public boolean visit(OracleSelectJoin x) {
@@ -1078,4 +1067,23 @@ public class OracleASTVisitorAdapter extends SQLASTVisitorAdapter implements Ora
}
@Override
public boolean visit(OracleSupplementalIdKey x) {
return true;
}
@Override
public void endVisit(OracleSupplementalIdKey x) {
}
@Override
public boolean visit(OracleSupplementalLogGrp x) {
return true;
}
@Override
public void endVisit(OracleSupplementalLogGrp x) {
}
}
@@ -300,11 +300,6 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
x.getRestriction().accept(this);
}
if (x.getForUpdate() != null) {
println();
x.getForUpdate().accept(this);
}
SQLOrderBy orderBy = x.getOrderBy();
if (orderBy != null) {
boolean hasFirst = false;
@@ -322,25 +317,6 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
return false;
}
public boolean visit(OracleSelectForUpdate x) {
print0(ucase ? "FOR UPDATE" : "for update");
if (x.getOf().size() > 0) {
print('(');
printAndAccept(x.getOf(), ", ");
print(')');
}
if (x.isNotWait()) {
print0(ucase ? " NOWAIT" : " nowait");
} else if (x.isSkipLocked()) {
print0(ucase ? " SKIP LOCKED" : " skip locked");
} else if (x.getWait() != null) {
print0(ucase ? " WAIT " : " wait ");
x.getWait().accept(this);
}
return false;
}
public boolean visit(OracleSelectJoin x) {
x.getLeft().accept(this);
@@ -502,6 +478,25 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
printFetchFirst(x);
if (x.isForUpdate()) {
println();
print0(ucase ? "FOR UPDATE" : "for update");
if (x.getForUpdateOf().size() > 0) {
print('(');
printAndAccept(x.getForUpdateOf(), ", ");
print(')');
}
if (x.isNoWait()) {
print0(ucase ? " NOWAIT" : " nowait");
} else if (x.isSkipLocked()) {
print0(ucase ? " SKIP LOCKED" : " skip locked");
} else if (x.getWaitTime() != null) {
print0(ucase ? " WAIT " : " wait ");
x.getWaitTime().accept(this);
}
}
return false;
}
@@ -715,11 +710,6 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
}
@Override
public void endVisit(OracleSelectForUpdate x) {
}
@Override
public void endVisit(OracleSelectJoin x) {
@@ -2058,6 +2048,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
}
protected void printConstraintState(OracleConstraint x) {
incrementIndent();
if (x.getUsing() != null) {
println();
x.getUsing().accept(this);
@@ -2089,6 +2080,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
print0(ucase ? " NOT DEFERRABLE" : " not deferrable");
}
}
decrementIndent();
}
@Override
@@ -2149,12 +2141,12 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
print0(ucase ? "NOCACHE" : "nocache");
}
if (x.getCompress() == Boolean.TRUE) {
println();
print0(ucase ? "COMPRESS" : "compress");
} else if (x.getCompress() == Boolean.FALSE) {
if (x.getCompress() == Boolean.FALSE) {
println();
print0(ucase ? "NOCOMPRESS" : "nocompress");
} else if (x.getCompress() == Boolean.TRUE) {
println();
print0(ucase ? "COMPRESS" : "compress");
}
if (x.getLogging() == Boolean.TRUE) {
@@ -2806,34 +2798,41 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
x.getIndex().accept(this);
} else {
if (x.getPtcfree() != null) {
print0(ucase ? " PCTFREE " : " pctfree ");
println();
print0(ucase ? "PCTFREE " : "pctfree ");
x.getPtcfree().accept(this);
}
if (x.getInitrans() != null) {
print0(ucase ? " INITRANS " : " initrans ");
println();
print0(ucase ? "INITRANS " : "initrans ");
x.getInitrans().accept(this);
}
if (x.getMaxtrans() != null) {
print0(ucase ? " MAXTRANS " : " maxtrans ");
println();
print0(ucase ? "MAXTRANS " : "maxtrans ");
x.getMaxtrans().accept(this);
}
if (x.isComputeStatistics()) {
print0(ucase ? " COMPUTE STATISTICS" : " compute statistics");
println();
print0(ucase ? "COMPUTE STATISTICS" : "compute statistics");
}
if (x.getTablespace() != null) {
print0(ucase ? " TABLESPACE " : " tablespace ");
println();
print0(ucase ? "TABLESPACE " : "tablespace ");
x.getTablespace().accept(this);
}
if (x.getEnable() != null) {
if (x.getEnable().booleanValue()) {
print0(ucase ? " ENABLE" : " enable");
println();
print0(ucase ? "ENABLE" : "enable");
} else {
print0(ucase ? " DISABLE" : " disable");
println();
print0(ucase ? "DISABLE" : "disable");
}
}
@@ -2841,6 +2840,20 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
println();
x.getStorage().accept(this);
}
if (x.isNocompress()) {
println();
print0(ucase ? "NOCOMPRESS" : "nocompress");
}
if (x.getLogging() != null) {
println();
if (x.getLogging().booleanValue()) {
print0(ucase ? "LOGGING" : "logging");
} else {
print0(ucase ? "NOLOGGING" : "nologging");
}
}
}
return false;
@@ -2885,6 +2898,15 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
} else {
print0(ucase ? "DISABLE STORAGE IN ROW" : "disable storage in row");
}
first = false;
}
if (x.getStorageClause() != null) {
if (!first) {
print(' ');
}
x.getStorageClause().accept(this);
first = false;
}
if (x.getChunk() != null) {
@@ -2893,6 +2915,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
}
print0(ucase ? "CHUNK " : "chunk ");
x.getChunk().accept(this);
first = false;
}
if (x.getCache() != null) {
@@ -2912,6 +2935,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
print0(ucase ? " NOLOGGING" : " nologging");
}
}
first = false;
}
if (x.getCompress() != null) {
@@ -2923,6 +2947,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
} else {
print0(ucase ? "NOCOMPRESS" : "nocompress");
}
first = false;
}
if (x.getKeepDuplicate() != null) {
@@ -2934,6 +2959,15 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
} else {
print0(ucase ? "DEDUPLICATE" : "deduplicate");
}
first = false;
}
if (x.isRetention()) {
if (!first) {
print(' ');
}
print0(ucase ? "RETENTION" : "retention");
first = false;
}
print(')');
@@ -3023,4 +3057,74 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
return false;
}
@Override
public boolean visit(OracleSupplementalIdKey x) {
print0(ucase ? "SUPPLEMENTAL LOG DATA (" : "supplemental log data (");
int count = 0;
if (x.isAll()) {
print0(ucase ? "ALL" : "all");
count++;
}
if (x.isPrimaryKey()) {
if (count != 0) {
print0(", ");
}
print0(ucase ? "PRIMARY KEY" : "primary key");
count++;
}
if (x.isUnique()) {
if (count != 0) {
print0(", ");
}
print0(ucase ? "UNIQUE" : "unique");
count++;
}
if (x.isUniqueIndex()) {
if (count != 0) {
print0(", ");
}
print0(ucase ? "UNIQUE INDEX" : "unique index");
count++;
}
if (x.isForeignKey()) {
if (count != 0) {
print0(", ");
}
print0(ucase ? "FOREIGHN KEY" : "foreighn key");
count++;
}
print0(ucase ? ") COLUMNS" : ") columns");
return false;
}
@Override
public void endVisit(OracleSupplementalIdKey x) {
}
@Override
public boolean visit(OracleSupplementalLogGrp x) {
print0(ucase ? "SUPPLEMENTAL LOG GROUP " : "supplemental log group ");
x.getGroup().accept(this);
print0(" (");
printAndAccept(x.getColumns(), ", ");
print(')');
if (x.isAlways()) {
print0(ucase ? " ALWAYS" : " always");
}
return false;
}
@Override
public void endVisit(OracleSupplementalLogGrp x) {
}
}
@@ -326,11 +326,6 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
}
@Override
public void endVisit(OracleSelectForUpdate x) {
}
@Override
public void endVisit(OracleSelectJoin x) {
@@ -402,12 +397,6 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
return true;
}
@Override
public boolean visit(OracleSelectForUpdate x) {
return true;
}
@Override
public boolean visit(OracleSelectJoin x) {
super.visit(x);
@@ -1410,4 +1399,24 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
public void endVisit(OracleCheck x) {
}
@Override
public boolean visit(OracleSupplementalIdKey x) {
return true;
}
@Override
public void endVisit(OracleSupplementalIdKey x) {
}
@Override
public boolean visit(OracleSupplementalLogGrp x) {
return true;
}
@Override
public void endVisit(OracleSupplementalLogGrp x) {
}
}
@@ -111,4 +111,11 @@ public class SQLServerObjectReferenceExpr extends SQLServerObjectImpl implements
this.schema = schema;
}
public SQLServerObjectReferenceExpr clone() {
SQLServerObjectReferenceExpr x = new SQLServerObjectReferenceExpr();
x.server = server;
x.database = database;
x.schema = schema;
return x;
}
}