Commit e3ffd66c by mayong

1.2.15

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

/.settings
/.classpath
/.project
/target/
/bin
/logs
/conf
/*.pid
/*.iml
/*.log
/tomcat
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mei1.rebuild</groupId>
<artifactId>druid</artifactId>
<version>1.2.15</version>
<properties>
<javafx.version>8</javafx.version>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
</properties>
<distributionManagement>
<repository>
<id>mei1-repository-release</id>
<url>http://nexus.mei1.info/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>mei1-repository-snapshot</id>
<url>http://nexus.mei1.info/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
\ No newline at end of file
package com.alibaba.druid;
import com.alibaba.druid.util.FnvHash;
public enum DbType {
other(1 << 0),
jtds(1 << 1),
hsql(1 << 2),
db2(1 << 3),
postgresql(1 << 4),
sqlserver(1 << 5),
oracle(1 << 6),
mysql(1 << 7),
mariadb(1 << 8),
derby(1 << 9),
hive(1 << 10),
h2(1 << 11),
dm(1 << 12), // dm.jdbc.driver.DmDriver
kingbase(1 << 13),
gbase(1 << 14),
oceanbase(1 << 15),
informix(1 << 16),
odps(1 << 17),
teradata(1 << 18),
phoenix(1 << 19),
edb(1 << 20),
kylin(1 << 21), // org.apache.kylin.jdbc.Driver
sqlite(1 << 22),
ads(1 << 23),
presto(1 << 24),
elastic_search(1 << 25), // com.alibaba.xdriver.elastic.jdbc.ElasticDriver
hbase(1 << 26),
drds(1 << 27),
clickhouse(1 << 28),
blink(1 << 29),
antspark(1 << 30),
oceanbase_oracle(1 << 31),
polardb(1L << 32),
ali_oracle(1L << 33),
mock(1L << 34),
sybase(1L << 35),
highgo(1L << 36),
/**
* 非常成熟的开源mpp数据库
*/
greenplum(1L << 37),
/**
* 华为的mpp数据库
*/
gaussdb(1L << 38),
trino(1L << 39),
oscar(1L << 40),
tidb(1L << 41),
tydb(1L << 42),
ingres(0),
cloudscape(0),
timesten(0),
as400(0),
sapdb(0),
kdb(0),
log4jdbc(0),
xugu(0),
firebirdsql(0),
JSQLConnect(0),
JTurbo(0),
interbase(0),
pointbase(0),
edbc(0),
mimer(0);
public final long mask;
public final long hashCode64;
private DbType(long mask) {
this.mask = mask;
this.hashCode64 = FnvHash.hashCode64(name());
}
public static long of(DbType... types) {
long value = 0;
for (DbType type : types) {
value |= type.mask;
}
return value;
}
public static DbType of(String name) {
if (name == null || name.isEmpty()) {
return null;
}
if ("aliyun_ads".equalsIgnoreCase(name)) {
return ads;
}
try {
return valueOf(name);
} catch (Exception e) {
return null;
}
}
public final boolean equals(String other) {
return this == of(other);
}
}
/*
* Copyright 1999-2018 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;
public class DruidRuntimeException extends RuntimeException {
private static final long serialVersionUID = 1L;
public DruidRuntimeException() {
super();
}
public DruidRuntimeException(String message, Throwable cause) {
super(message, cause);
}
public DruidRuntimeException(String message) {
super(message);
}
public DruidRuntimeException(Throwable cause) {
super(cause);
}
}
package com.alibaba.druid;
public class FastsqlColumnAmbiguousException extends FastsqlException {
public FastsqlColumnAmbiguousException() {
}
public FastsqlColumnAmbiguousException(String msg) {
super(msg);
}
}
/*
* 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;
public class FastsqlException extends RuntimeException {
private static final long serialVersionUID = 1L;
public FastsqlException() {
super();
}
public FastsqlException(String message, Throwable cause) {
super(message, cause);
}
public FastsqlException(String message) {
super(message);
}
public FastsqlException(Throwable cause) {
super(cause);
}
}
/*
* Copyright 1999-2018 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;
public final class VERSION {
public static final int MajorVersion = 1;
public static final int MinorVersion = 2;
public static final int RevisionVersion = 15;
public static String getVersionNumber() {
return VERSION.MajorVersion + "." + VERSION.MinorVersion + "." + VERSION.RevisionVersion;
}
}
package com.alibaba.druid.sql.ast;
public enum AutoIncrementType {
GROUP("GROUP"), SIMPLE("SIMPLE"),
SIMPLE_CACHE("SIMPLE WITH CACHE"), TIME("TIME");
private final String keyword;
public String getKeyword() {
return this.keyword;
}
private AutoIncrementType(String keyword) {
this.keyword = keyword;
}
}
package com.alibaba.druid.sql.ast;
public enum ClusteringType {
Range,
Hash
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
import com.alibaba.druid.sql.ast.statement.SQLTableSourceImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLAdhocTableSource extends SQLTableSourceImpl {
private SQLCreateTableStatement definition;
public SQLAdhocTableSource(SQLCreateTableStatement definition) {
setDefinition(definition);
}
@Override
protected void accept0(SQLASTVisitor v) {
if (v.visit(this)) {
if (definition != null) {
definition.accept(v);
}
}
v.endVisit(this);
}
public SQLCreateTableStatement getDefinition() {
return definition;
}
public void setDefinition(SQLCreateTableStatement x) {
if (x != null) {
x.setParent(this);
}
this.definition = x;
}
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLAnnIndex extends SQLObjectImpl {
private int indexType;
private int rtIndexType;
private Distance distance;
public SQLAnnIndex clone() {
SQLAnnIndex x = new SQLAnnIndex();
x.indexType = indexType;
x.rtIndexType = rtIndexType;
x.distance = distance;
return x;
}
@Override
protected void accept0(SQLASTVisitor v) {
v.visit(this);
v.endVisit(this);
}
public void setIndexType(String type) {
this.indexType = IndexType.of(type);
}
public void setIndexType(IndexType indexType, boolean state) {
if (state) {
this.indexType |= indexType.mask;
} else {
this.indexType &= ~indexType.mask;
}
}
public void setRtIndexType(IndexType indexType, boolean state) {
if (state) {
this.rtIndexType |= indexType.mask;
} else {
this.rtIndexType &= ~indexType.mask;
}
}
public void setRtIndexType(String type) {
this.rtIndexType = IndexType.of(type);
}
public int getIndexType() {
return indexType;
}
public int getRtIndexType() {
return rtIndexType;
}
public Distance getDistance() {
return distance;
}
public void setDistance(Distance distance) {
this.distance = distance;
}
public void setDistance(String distance) {
if (distance == null) {
this.distance = null;
return;
}
if (distance.equalsIgnoreCase("Hamming")) {
this.distance = Distance.Hamming;
} else if (distance.equalsIgnoreCase("SquaredEuclidean")) {
this.distance = Distance.SquaredEuclidean;
} else if (distance.equalsIgnoreCase("DotProduct")) {
this.distance = Distance.DotProduct;
}
}
public static enum IndexType {
Flat(1), FastIndex(2);
public final int mask;
IndexType(int ordinal) {
mask = (1 << ordinal);
}
private static int of(String type) {
if (type == null || type.length() == 0) {
return 0;
}
int v = 0;
String[] items = type.split(",");
for (String item : items) {
if (item.trim().equalsIgnoreCase("Flat")) {
v |= Flat.mask;
} else if (item.trim().equalsIgnoreCase("FastIndex")
|| item.trim().equalsIgnoreCase("FAST_INDEX")) {
v |= FastIndex.mask;
}
}
return v;
}
}
public enum Distance {
Hamming,
SquaredEuclidean,
DotProduct // desc
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
/**
* Created by wenshao on 29/05/2017.
*/
public class SQLArgument extends SQLObjectImpl {
private SQLParameter.ParameterType type;
private SQLExpr expr;
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, expr);
}
visitor.endVisit(this);
}
public SQLArgument clone() {
SQLArgument x = new SQLArgument();
x.type = type;
if (expr != null) {
x.setExpr(expr.clone());
}
return x;
}
public SQLParameter.ParameterType getType() {
return type;
}
public SQLExpr getExpr() {
return expr;
}
public void setType(SQLParameter.ParameterType type) {
this.type = type;
}
public void setExpr(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.expr = x;
}
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.util.FnvHash;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
public class SQLArrayDataType extends SQLObjectImpl implements SQLDataType {
public static final SQLArrayDataType ARRYA_CHAR = new SQLArrayDataType(SQLCharExpr.DATA_TYPE);
private DbType dbType;
private SQLDataType componentType;
private List<SQLExpr> arguments = new ArrayList<SQLExpr>();
public SQLArrayDataType(SQLDataType componentType) {
setComponentType(componentType);
}
public SQLArrayDataType(SQLDataType componentType, DbType dbType) {
this.dbType = dbType;
setComponentType(componentType);
}
@Override
public String getName() {
return "ARRAY";
}
@Override
public long nameHashCode64() {
return FnvHash.Constants.ARRAY;
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException();
}
@Override
public List<SQLExpr> getArguments() {
return arguments;
}
@Override
public Boolean getWithTimeZone() {
return null;
}
@Override
public void setWithTimeZone(Boolean value) {
throw new UnsupportedOperationException();
}
@Override
public boolean isWithLocalTimeZone() {
return false;
}
@Override
public void setWithLocalTimeZone(boolean value) {
throw new UnsupportedOperationException();
}
@Override
public void setDbType(DbType dbType) {
this.dbType = dbType;
}
@Override
public DbType getDbType() {
return dbType;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, componentType);
}
visitor.endVisit(this);
}
public SQLArrayDataType clone() {
SQLArrayDataType x = new SQLArrayDataType(componentType.clone());
x.dbType = dbType;
for (SQLExpr arg : arguments) {
SQLExpr item = arg.clone();
item.setParent(x);
x.arguments.add(item);
}
return x;
}
public SQLDataType getComponentType() {
return componentType;
}
public void setComponentType(SQLDataType x) {
if (x != null) {
x.setParent(this);
}
this.componentType = x;
}
public int jdbcType() {
return Types.ARRAY;
}
@Override
public boolean isInt() {
return false;
}
@Override
public boolean isNumberic() {
return false;
}
@Override
public boolean isString() {
return false;
}
@Override
public boolean hasKeyLength() {
return false;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLCommentHint extends SQLObjectImpl implements SQLHint {
private String text;
public SQLCommentHint() {
}
public SQLCommentHint(String text) {
this.text = text;
}
public String getText() {
return this.text;
}
public void setText(String text) {
this.text = text;
}
protected void accept0(SQLASTVisitor visitor) {
visitor.visit(this);
visitor.endVisit(this);
}
public SQLCommentHint clone() {
return new SQLCommentHint(text);
}
public String toString() {
return "/*" + text + "*/";
}
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLCurrentTimeExpr extends SQLExprImpl {
private final Type type;
public SQLCurrentTimeExpr(Type type) {
if (type == null) {
throw new NullPointerException();
}
this.type = type;
}
@Override
protected void accept0(SQLASTVisitor v) {
v.visit(this);
v.endVisit(this);
}
public Type getType() {
return type;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (getClass() != o.getClass()) {
return false;
}
SQLCurrentTimeExpr that = (SQLCurrentTimeExpr) o;
return type == that.type;
}
@Override
public int hashCode() {
return type.hashCode();
}
public SQLCurrentTimeExpr clone() {
return new SQLCurrentTimeExpr(type);
}
public static enum Type {
CURRENT_TIME("CURRENT_TIME"),
CURRENT_DATE("CURRENT_DATE"),
CURDATE("CURDATE"),
CURTIME("CURTIME"),
CURRENT_TIMESTAMP("CURRENT_TIMESTAMP"),
LOCALTIME("LOCALTIME"),
LOCALTIMESTAMP("LOCALTIMESTAMP"),
SYSDATE("SYSDATE");
public final String name;
public final String nameLCase;
Type(String name) {
this.name = name;
this.nameLCase = name.toLowerCase();
}
}
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLCurrentUserExpr extends SQLExprImpl {
public SQLCurrentUserExpr() {
}
@Override
protected void accept0(SQLASTVisitor v) {
v.visit(this);
v.endVisit(this);
}
@Override
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (this == o) {
return true;
}
return getClass() == o.getClass();
}
@Override
public int hashCode() {
return 0;
}
public SQLCurrentUserExpr clone() {
return new SQLCurrentUserExpr();
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
import java.util.List;
public interface SQLDataType extends SQLObject {
String getName();
long nameHashCode64();
void setName(String name);
List<SQLExpr> getArguments();
Boolean getWithTimeZone();
void setWithTimeZone(Boolean value);
boolean isWithLocalTimeZone();
void setWithLocalTimeZone(boolean value);
SQLDataType clone();
void setDbType(DbType dbType);
DbType getDbType();
int jdbcType();
interface Constants {
String CHAR = "CHAR";
String NCHAR = "NCHAR";
String VARCHAR = "VARCHAR";
String VARBINARY = "VARBINARY";
String DATE = "DATE";
String TIMESTAMP = "TIMESTAMP";
String XML = "XML";
String DECIMAL = "DECIMAL";
String NUMBER = "NUMBER";
String REAL = "REAL";
String DOUBLE_PRECISION = "DOUBLE PRECISION";
String DOUBLE = "DOUBLE";
String TINYINT = "TINYINT";
String SMALLINT = "SMALLINT";
String INT = "INT";
String BIGINT = "BIGINT";
String TEXT = "TEXT";
String BYTEA = "BYTEA";
String BOOLEAN = "BOOLEAN";
String FLOAT = "FLOAT";
}
boolean isInt();
boolean isNumberic();
public boolean isString();
public boolean hasKeyLength();
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLDataTypeRefExpr extends SQLExprImpl {
private SQLDataType dataType;
public SQLDataTypeRefExpr(SQLDataType dataType) {
this.dataType = dataType;
}
public SQLDataType getDataType() {
return dataType;
}
public void setDataType(SQLDataType x) {
if (x != null) {
x.setParent(this);
}
this.dataType = x;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SQLDataTypeRefExpr that = (SQLDataTypeRefExpr) o;
return dataType != null ? dataType.equals(that.dataType) : that.dataType == null;
}
@Override
public int hashCode() {
return dataType != null ? dataType.hashCode() : 0;
}
@Override
protected void accept0(SQLASTVisitor v) {
if (v.visit(this)) {
acceptChild(v, dataType);
}
v.endVisit(this);
}
@Override
public SQLExpr clone() {
return new SQLDataTypeRefExpr(
dataType == null
? null
: dataType.clone());
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
public interface SQLDbTypedObject extends SQLObject {
DbType getDbType();
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.statement.SQLTableElement;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLDeclareItem extends SQLObjectImpl implements SQLObjectWithDataType, SQLReplaceable {
protected Type type;
protected SQLName name;
protected SQLDataType dataType;
protected SQLExpr value;
protected List<SQLTableElement> tableElementList = new ArrayList<SQLTableElement>();
protected transient SQLObject resolvedObject;
public SQLDeclareItem() {
}
public SQLDeclareItem(SQLName name, SQLDataType dataType) {
this.setName(name);
this.setDataType(dataType);
}
public SQLDeclareItem(SQLName name, SQLDataType dataType, SQLExpr value) {
this.setName(name);
this.setDataType(dataType);
this.setValue(value);
}
public boolean replace(SQLExpr expr, SQLExpr target) {
if (name == expr) {
setName((SQLName) target);
return true;
}
if (value == expr) {
setValue(target);
return true;
}
return false;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, this.name);
acceptChild(visitor, this.dataType);
acceptChild(visitor, this.value);
acceptChild(visitor, this.tableElementList);
}
visitor.endVisit(this);
}
public SQLName getName() {
return name;
}
public void setName(SQLName name) {
if (name != null) {
name.setParent(this);
}
this.name = name;
}
public SQLDataType getDataType() {
return dataType;
}
public void setDataType(SQLDataType dataType) {
if (dataType != null) {
dataType.setParent(this);
}
this.dataType = dataType;
}
public SQLExpr getValue() {
return value;
}
public void setValue(SQLExpr value) {
if (value != null) {
value.setParent(this);
}
this.value = value;
}
public List<SQLTableElement> getTableElementList() {
return tableElementList;
}
public void setTableElementList(List<SQLTableElement> tableElementList) {
this.tableElementList = tableElementList;
}
public enum Type {
TABLE, LOCAL, CURSOR;
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public SQLObject getResolvedObject() {
return resolvedObject;
}
public void setResolvedObject(SQLObject resolvedObject) {
this.resolvedObject = resolvedObject;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import java.util.List;
public interface SQLExpr extends SQLObject, Cloneable {
SQLExpr clone();
SQLDataType computeDataType();
List<SQLObject> getChildren();
SQLCommentHint getHint();
}
package com.alibaba.druid.sql.ast;
import java.util.Comparator;
public class SQLExprComparor implements Comparator<SQLExpr> {
public static final SQLExprComparor instance = new SQLExprComparor();
@Override
public int compare(SQLExpr a, SQLExpr b) {
return compareTo(a, b);
}
public static int compareTo(SQLExpr a, SQLExpr b) {
if (a == null && b == null) {
return 0;
}
if (a == null) {
return -1;
}
if (b == null) {
return 1;
}
if (a.getClass() == b.getClass() && a instanceof Comparable) {
return ((Comparable) a).compareTo(b);
}
return a.getClass().getName().compareTo(b.getClass().getName());
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import java.util.List;
public abstract class SQLExprImpl extends SQLObjectImpl implements SQLExpr {
public SQLExprImpl() {
}
public abstract boolean equals(Object o);
public abstract int hashCode();
public abstract SQLExpr clone();
public SQLDataType computeDataType() {
return null;
}
@Override
public List<SQLObject> getChildren() {
return null;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
public interface SQLHint extends SQLObject {
SQLHint clone();
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem;
import java.util.List;
public interface SQLIndex extends SQLObject {
List<SQLName> getCovering();
List<SQLSelectOrderByItem> getColumns();
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
/**
* version 1.0
* Author zzy
* Date 2019-06-04 11:48
*/
public class SQLIndexOptions extends SQLObjectImpl {
private String indexType; // Using btree/hash
private SQLExpr keyBlockSize;
private String parserName;
private SQLExpr comment;
private String algorithm;
private String lock;
private boolean invisible;
private boolean visible;
private boolean global;
private boolean local;
private List<SQLAssignItem> otherOptions = new ArrayList<SQLAssignItem>();
public SQLIndexOptions() {
}
public String getIndexType() {
return indexType;
}
public void setIndexType(String indexType) {
this.indexType = indexType;
}
public SQLExpr getKeyBlockSize() {
return keyBlockSize;
}
public boolean isGlobal() {
return global;
}
public void setGlobal(boolean global) {
this.global = global;
}
public boolean isLocal() {
return local;
}
public void setLocal(boolean local) {
this.local = local;
}
public void setKeyBlockSize(SQLExpr keyBlockSize) {
if (keyBlockSize != null) {
if (getParent() != null && getParent().getParent() != null) {
keyBlockSize.setParent(getParent().getParent());
} else {
keyBlockSize.setParent(this);
}
}
this.keyBlockSize = keyBlockSize;
// Old parser code put it in options list.
if (keyBlockSize != null && getParent() != null && getParent() instanceof SQLIndexDefinition) {
SQLIndexDefinition parent = (SQLIndexDefinition) getParent();
SQLAssignItem assignItem = new SQLAssignItem(new SQLIdentifierExpr("KEY_BLOCK_SIZE"), keyBlockSize);
if (getParent() != null && getParent().getParent() != null) {
assignItem.setParent(getParent().getParent());
} else {
assignItem.setParent(this);
}
parent.getCompatibleOptions().add(assignItem);
}
}
public String getParserName() {
return parserName;
}
public void setParserName(String parserName) {
this.parserName = parserName;
}
public SQLExpr getComment() {
return comment;
}
public void setComment(SQLExpr comment) {
if (comment != null) {
if (getParent() != null && getParent().getParent() != null) {
comment.setParent(getParent().getParent());
} else {
comment.setParent(this);
}
}
this.comment = comment;
}
public String getAlgorithm() {
return algorithm;
}
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
// Old parser code put it in options list.
if (algorithm != null && getParent() != null && getParent() instanceof SQLIndexDefinition) {
SQLIndexDefinition parent = (SQLIndexDefinition) getParent();
SQLAssignItem assignItem = new SQLAssignItem(new SQLIdentifierExpr("ALGORITHM"), new SQLIdentifierExpr(algorithm));
if (getParent() != null && getParent().getParent() != null) {
assignItem.setParent(getParent().getParent());
} else {
assignItem.setParent(this);
}
parent.getCompatibleOptions().add(assignItem);
}
}
public String getLock() {
return lock;
}
public void setLock(String lock) {
this.lock = lock;
// Old parser code put it in options list.
if (lock != null && getParent() != null && getParent() instanceof SQLIndexDefinition) {
SQLIndexDefinition parent = (SQLIndexDefinition) getParent();
SQLAssignItem assignItem = new SQLAssignItem(new SQLIdentifierExpr("LOCK"), new SQLIdentifierExpr(lock));
if (getParent() != null && getParent().getParent() != null) {
assignItem.setParent(getParent().getParent());
} else {
assignItem.setParent(this);
}
parent.getCompatibleOptions().add(assignItem);
}
}
public boolean isInvisible() {
return invisible;
}
public void setInvisible(boolean invisible) {
this.invisible = invisible;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public List<SQLAssignItem> getOtherOptions() {
return otherOptions;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
visitor.visit(this);
visitor.endVisit(this);
}
public void cloneTo(SQLIndexOptions options) {
SQLObject parent;
if (options.getParent() != null && options.getParent().getParent() != null) {
parent = options.getParent().getParent();
} else {
parent = options;
}
options.indexType = indexType;
if (keyBlockSize != null) {
options.keyBlockSize = keyBlockSize.clone();
options.keyBlockSize.setParent(parent);
}
options.parserName = parserName;
if (comment != null) {
options.comment = comment.clone();
options.comment.setParent(parent);
}
options.algorithm = algorithm;
options.lock = lock;
for (SQLAssignItem item : otherOptions) {
SQLAssignItem item1 = item.clone();
item1.setParent(parent);
options.otherOptions.add(item1);
}
options.invisible = invisible;
options.global = global;
options.local = local;
}
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLJSONValueExpr extends SQLExprImpl {
private SQLExpr json;
private SQLExpr path;
@Override
public boolean equals(Object o) {
return false;
}
@Override
public int hashCode() {
return 0;
}
@Override
protected void accept0(SQLASTVisitor v) {
}
@Override
public SQLExpr clone() {
return null;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public final class SQLKeep extends SQLObjectImpl {
protected DenseRank denseRank;
protected SQLOrderBy orderBy;
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, this.orderBy);
}
visitor.endVisit(this);
}
public DenseRank getDenseRank() {
return denseRank;
}
public void setDenseRank(DenseRank denseRank) {
this.denseRank = denseRank;
}
public SQLOrderBy getOrderBy() {
return orderBy;
}
public void setOrderBy(SQLOrderBy orderBy) {
if (orderBy != null) {
orderBy.setParent(this);
}
this.orderBy = orderBy;
}
public SQLKeep clone() {
SQLKeep x = new SQLKeep();
x.denseRank = denseRank;
if (orderBy != null) {
x.setOrderBy(orderBy.clone());
}
return x;
}
public static enum DenseRank {
FIRST,
LAST
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Created by wenshao on 16/9/25.
*/
public final class SQLLimit extends SQLObjectImpl implements SQLReplaceable {
private SQLExpr rowCount;
private SQLExpr offset;
private List<SQLExpr> by;
public SQLLimit() {
}
public SQLLimit(int rowCount) {
this.setRowCount(new SQLIntegerExpr(rowCount));
}
public SQLLimit(SQLExpr rowCount) {
this.setRowCount(rowCount);
}
public SQLLimit(SQLExpr offset, SQLExpr rowCount) {
this.setOffset(offset);
this.setRowCount(rowCount);
}
public SQLExpr getRowCount() {
return rowCount;
}
public void setRowCount(SQLExpr rowCount) {
if (rowCount != null) {
rowCount.setParent(this);
}
this.rowCount = rowCount;
}
public void setRowCount(int rowCount) {
this.setRowCount(new SQLIntegerExpr(rowCount));
}
public SQLExpr getOffset() {
return offset;
}
public void setOffset(int offset) {
this.setOffset(new SQLIntegerExpr(offset));
}
public void setOffset(SQLExpr offset) {
if (offset != null) {
offset.setParent(this);
}
this.offset = offset;
}
public void merge(SQLLimit other) {
if (other == null) {
return;
}
if (other.offset != null) {
if (this.offset == null) {
this.offset = other.offset.clone();
}
}
if (other.rowCount != null) {
if (this.rowCount == null) {
this.rowCount = other.rowCount.clone();
}
}
if (other.by != null) {
for (SQLExpr item : other.by) {
addBy(item.clone());
}
}
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
if (offset != null) {
offset.accept(visitor);
}
if (rowCount != null) {
rowCount.accept(visitor);
}
if (by != null) {
for (SQLExpr item : by) {
item.accept(visitor);
}
}
}
visitor.endVisit(this);
}
public SQLLimit clone() {
SQLLimit x = new SQLLimit();
if (offset != null) {
x.setOffset(offset.clone());
}
if (rowCount != null) {
x.setRowCount(rowCount.clone());
}
if (by != null) {
for (SQLExpr item : by) {
x.addBy(item);
}
}
if (attributes != null) {
x.attributes = (HashMap) ((HashMap) attributes).clone();
}
return x;
}
public void addBy(SQLExpr item) {
if (item == null) {
return;
}
if (by == null) {
by = new ArrayList<>(1);
}
by.add(item);
item.setParent(this);
}
public List<SQLExpr> getBy() {
return by;
}
@Override
public boolean replace(SQLExpr expr, SQLExpr target) {
if (rowCount == expr) {
setRowCount(target);
return true;
}
if (offset == expr) {
setOffset(target);
return true;
}
return false;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SQLLimit limit = (SQLLimit) o;
if (rowCount != null ? !rowCount.equals(limit.rowCount) : limit.rowCount != null) {
return false;
}
return offset != null ? offset.equals(limit.offset) : limit.offset == null;
}
@Override
public int hashCode() {
int result = rowCount != null ? rowCount.hashCode() : 0;
result = 31 * result + (offset != null ? offset.hashCode() : 0);
return result;
}
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.util.FnvHash;
import java.sql.Types;
import java.util.Collections;
import java.util.List;
public class SQLMapDataType extends SQLObjectImpl implements SQLDataType {
public static final SQLMapDataType MAP_CHAR_CHAR = new SQLMapDataType(SQLCharExpr.DATA_TYPE, SQLCharExpr.DATA_TYPE);
private DbType dbType;
private SQLDataType keyType;
private SQLDataType valueType;
public SQLMapDataType() {
}
public SQLMapDataType(SQLDataType keyType, SQLDataType valueType) {
this.setKeyType(keyType);
this.setValueType(valueType);
}
public SQLMapDataType(SQLDataType keyType, SQLDataType valueType, DbType dbType) {
this.setKeyType(keyType);
this.setValueType(valueType);
this.dbType = dbType;
}
@Override
public String getName() {
return "MAP";
}
@Override
public long nameHashCode64() {
return FnvHash.Constants.MAP;
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException();
}
@Override
public List<SQLExpr> getArguments() {
return Collections.emptyList();
}
@Override
public Boolean getWithTimeZone() {
return null;
}
@Override
public void setWithTimeZone(Boolean value) {
throw new UnsupportedOperationException();
}
@Override
public boolean isWithLocalTimeZone() {
return false;
}
@Override
public void setWithLocalTimeZone(boolean value) {
throw new UnsupportedOperationException();
}
@Override
public void setDbType(DbType dbType) {
this.dbType = dbType;
}
@Override
public DbType getDbType() {
return dbType;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, keyType);
acceptChild(visitor, valueType);
}
visitor.endVisit(this);
}
public SQLMapDataType clone() {
SQLMapDataType x = new SQLMapDataType();
x.dbType = dbType;
if (keyType != null) {
x.setKeyType(keyType.clone());
}
if (valueType != null) {
x.setValueType(valueType.clone());
}
return x;
}
public SQLDataType getKeyType() {
return keyType;
}
public void setKeyType(SQLDataType x) {
if (x != null) {
x.setParent(this);
}
this.keyType = x;
}
public SQLDataType getValueType() {
return valueType;
}
public void setValueType(SQLDataType x) {
if (x != null) {
x.setParent(this);
}
this.valueType = x;
}
public int jdbcType() {
return Types.OTHER;
}
@Override
public boolean isInt() {
return false;
}
@Override
public boolean isNumberic() {
return false;
}
@Override
public boolean isString() {
return false;
}
@Override
public boolean hasKeyLength() {
return false;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
public interface SQLName extends SQLExpr {
String getSimpleName();
SQLName clone();
long nameHashCode64();
long hashCode64();
SQLColumnDefinition getResolvedColumn();
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.List;
import java.util.Map;
public interface SQLObject {
void accept(SQLASTVisitor visitor);
SQLObject clone();
SQLObject getParent();
void setParent(SQLObject parent);
Map<String, Object> getAttributes();
boolean containsAttribute(String name);
Object getAttribute(String name);
void putAttribute(String name, Object value);
Map<String, Object> getAttributesDirect();
void output(StringBuffer buf);
void output(Appendable buf);
void addBeforeComment(String comment);
void addBeforeComment(List<String> comments);
List<String> getBeforeCommentsDirect();
void addAfterComment(String comment);
void addAfterComment(List<String> comments);
List<String> getAfterCommentsDirect();
boolean hasBeforeComment();
boolean hasAfterComment();
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject;
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObject;
import com.alibaba.druid.sql.dialect.postgresql.ast.PGSQLObject;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public abstract class SQLObjectImpl implements SQLObject {
protected SQLObject parent;
protected Map<String, Object> attributes;
protected SQLCommentHint hint;
protected int sourceLine;
protected int sourceColumn;
public SQLObjectImpl() {
}
public final void accept(SQLASTVisitor visitor) {
if (visitor == null) {
throw new IllegalArgumentException();
}
visitor.preVisit(this);
accept0(visitor);
visitor.postVisit(this);
}
protected abstract void accept0(SQLASTVisitor v);
protected final void acceptChild(SQLASTVisitor visitor, List<? extends SQLObject> children) {
if (children == null) {
return;
}
for (int i = 0; i < children.size(); i++) {
acceptChild(visitor, children.get(i));
}
}
protected final void acceptChild(SQLASTVisitor visitor, SQLObject child) {
if (child == null) {
return;
}
child.accept(visitor);
}
public void output(StringBuffer buf) {
output((Appendable) buf);
}
public void output(Appendable buf) {
DbType dbType = null;
if (this instanceof OracleSQLObject) {
dbType = DbType.oracle;
} else if (this instanceof MySqlObject) {
dbType = DbType.mysql;
} else if (this instanceof PGSQLObject) {
dbType = DbType.postgresql;
} else if (this instanceof SQLDbTypedObject) {
dbType = ((SQLDbTypedObject) this).getDbType();
}
accept(
SQLUtils.createOutputVisitor(buf, dbType)
);
}
public String toString() {
StringBuffer buf = new StringBuffer();
output(buf);
return buf.toString();
}
public SQLObject getParent() {
return parent;
}
public void setParent(SQLObject parent) {
this.parent = parent;
}
public Map<String, Object> getAttributes() {
if (attributes == null) {
attributes = new HashMap<String, Object>(1);
}
return attributes;
}
public Object getAttribute(String name) {
if (attributes == null) {
return null;
}
return attributes.get(name);
}
public boolean containsAttribute(String name) {
if (attributes == null) {
return false;
}
return attributes.containsKey(name);
}
public void putAttribute(String name, Object value) {
if (attributes == null) {
attributes = new HashMap<String, Object>(1);
}
attributes.put(name, value);
}
public Map<String, Object> getAttributesDirect() {
return attributes;
}
@SuppressWarnings("unchecked")
public void addBeforeComment(String comment) {
if (comment == null) {
return;
}
if (attributes == null) {
attributes = new HashMap<String, Object>(1);
}
List<String> comments = (List<String>) attributes.get("rowFormat.before_comment");
if (comments == null) {
comments = new ArrayList<String>(2);
attributes.put("rowFormat.before_comment", comments);
}
comments.add(comment);
}
@SuppressWarnings("unchecked")
public void addBeforeComment(List<String> comments) {
if (attributes == null) {
attributes = new HashMap<String, Object>(1);
}
List<String> attrComments = (List<String>) attributes.get("rowFormat.before_comment");
if (attrComments == null) {
attributes.put("rowFormat.before_comment", comments);
} else {
attrComments.addAll(comments);
}
}
@SuppressWarnings("unchecked")
public List<String> getBeforeCommentsDirect() {
if (attributes == null) {
return null;
}
return (List<String>) attributes.get("rowFormat.before_comment");
}
@SuppressWarnings("unchecked")
public void addAfterComment(String comment) {
if (attributes == null) {
attributes = new HashMap<String, Object>(1);
}
List<String> comments = (List<String>) attributes.get("rowFormat.after_comment");
if (comments == null) {
comments = new ArrayList<String>(2);
attributes.put("rowFormat.after_comment", comments);
}
comments.add(comment);
}
@SuppressWarnings("unchecked")
public void addAfterComment(List<String> comments) {
if (comments == null) {
return;
}
if (attributes == null) {
attributes = new HashMap<String, Object>(1);
}
List<String> attrComments = (List<String>) attributes.get("rowFormat.after_comment");
if (attrComments == null) {
attributes.put("rowFormat.after_comment", comments);
} else {
attrComments.addAll(comments);
}
}
@SuppressWarnings("unchecked")
public List<String> getAfterCommentsDirect() {
if (attributes == null) {
return null;
}
return (List<String>) attributes.get("rowFormat.after_comment");
}
public boolean hasBeforeComment() {
if (attributes == null) {
return false;
}
List<String> comments = (List<String>) attributes.get("rowFormat.before_comment");
if (comments == null) {
return false;
}
return !comments.isEmpty();
}
public boolean hasAfterComment() {
if (attributes == null) {
return false;
}
List<String> comments = (List<String>) attributes.get("rowFormat.after_comment");
if (comments == null) {
return false;
}
return !comments.isEmpty();
}
public SQLObject clone() {
throw new UnsupportedOperationException(this.getClass().getName());
}
public SQLDataType computeDataType() {
return null;
}
public int getSourceLine() {
return sourceLine;
}
public void setSourceLine(int sourceLine) {
this.sourceLine = sourceLine;
}
public int getSourceColumn() {
return sourceColumn;
}
public void setSourceColumn(int sourceColumn) {
this.sourceColumn = sourceColumn;
}
public SQLCommentHint getHint() {
return hint;
}
public void setHint(SQLCommentHint hint) {
this.hint = hint;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
public interface SQLObjectWithDataType extends SQLObject {
SQLDataType getDataType();
void setDataType(SQLDataType dataType);
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public final class SQLOrderBy extends SQLObjectImpl implements SQLReplaceable {
protected final List<SQLSelectOrderByItem> items = new ArrayList<SQLSelectOrderByItem>();
// for postgres
private boolean siblings;
public SQLOrderBy() {
}
public SQLOrderBy(SQLExpr expr) {
SQLSelectOrderByItem item = new SQLSelectOrderByItem(expr);
addItem(item);
}
public SQLOrderBy(SQLExpr expr, SQLOrderingSpecification type) {
SQLSelectOrderByItem item = new SQLSelectOrderByItem(expr, type);
addItem(item);
}
public void addItem(SQLSelectOrderByItem item) {
if (item != null) {
item.setParent(this);
}
this.items.add(item);
}
public void addItem(SQLExpr item) {
addItem(new SQLSelectOrderByItem(item));
}
public List<SQLSelectOrderByItem> getItems() {
return this.items;
}
public boolean isSiblings() {
return this.siblings;
}
public void setSiblings(boolean siblings) {
this.siblings = siblings;
}
protected void accept0(SQLASTVisitor v) {
if (v.visit(this)) {
for (int i = 0; i < this.items.size(); i++) {
final SQLSelectOrderByItem item = this.items.get(i);
item.accept(v);
}
}
v.endVisit(this);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SQLOrderBy order = (SQLOrderBy) o;
if (siblings != order.siblings) {
return false;
}
return items.equals(order.items);
}
@Override
public int hashCode() {
int result = items.hashCode();
result = 31 * result + (siblings ? 1 : 0);
return result;
}
public void addItem(SQLExpr expr, SQLOrderingSpecification type) {
SQLSelectOrderByItem item = createItem();
item.setExpr(expr);
item.setType(type);
addItem(item);
}
@Override
public boolean replace(SQLExpr expr, SQLExpr target) {
for (SQLSelectOrderByItem item : items) {
if (item.replace(expr, target)) {
return true;
}
}
return false;
}
protected SQLSelectOrderByItem createItem() {
return new SQLSelectOrderByItem();
}
public SQLOrderBy clone() {
SQLOrderBy x = new SQLOrderBy();
for (SQLSelectOrderByItem item : items) {
SQLSelectOrderByItem item1 = item.clone();
item1.setParent(x);
x.items.add(item1);
}
x.siblings = siblings;
return x;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
public enum SQLOrderingSpecification {
ASC("ASC"), DESC("DESC");
public final String name;
public final String nameLCase;
private SQLOrderingSpecification(String name) {
this.name = name;
this.nameLCase = name.toLowerCase();
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public final class SQLParameter extends SQLObjectImpl implements SQLObjectWithDataType {
private SQLName name;
private SQLDataType dataType;
private SQLExpr defaultValue;
private ParameterType paramType;
private boolean noCopy;
private boolean constant;
private SQLName cursorName;
private final List<SQLParameter> cursorParameters = new ArrayList<SQLParameter>();
private boolean order;
private boolean map;
private boolean member;
public SQLExpr getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(SQLExpr deaultValue) {
if (deaultValue != null) {
deaultValue.setParent(this);
}
this.defaultValue = deaultValue;
}
public SQLName getName() {
return name;
}
public void setName(SQLName name) {
if (name != null) {
name.setParent(this);
}
this.name = name;
}
public SQLDataType getDataType() {
return dataType;
}
public void setDataType(SQLDataType dataType) {
if (dataType != null) {
dataType.setParent(this);
}
this.dataType = dataType;
}
public ParameterType getParamType() {
return paramType;
}
public void setParamType(ParameterType paramType) {
this.paramType = paramType;
}
@Override
public void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
acceptChild(visitor, dataType);
acceptChild(visitor, defaultValue);
}
visitor.endVisit(this);
}
public static enum ParameterType {
DEFAULT,
IN, // in
OUT, // out
INOUT// inout
}
public boolean isNoCopy() {
return noCopy;
}
public void setNoCopy(boolean noCopy) {
this.noCopy = noCopy;
}
public boolean isConstant() {
return constant;
}
public void setConstant(boolean constant) {
this.constant = constant;
}
public List<SQLParameter> getCursorParameters() {
return cursorParameters;
}
public SQLName getCursorName() {
return cursorName;
}
public void setCursorName(SQLName cursorName) {
if (cursorName != null) {
cursorName.setParent(this);
}
this.cursorName = cursorName;
}
public SQLParameter clone() {
SQLParameter x = new SQLParameter();
if (name != null) {
x.setName(name.clone());
}
if (dataType != null) {
x.setDataType(dataType.clone());
}
if (defaultValue != null) {
x.setDefaultValue(defaultValue.clone());
}
x.paramType = paramType;
x.noCopy = noCopy;
x.constant = constant;
x.order = order;
x.map = map;
if (cursorName != null) {
x.setCursorName(cursorName.clone());
}
for (SQLParameter p : cursorParameters) {
SQLParameter p2 = p.clone();
p2.setParent(x);
x.cursorParameters.add(p2);
}
return x;
}
public boolean isOrder() {
return order;
}
public void setOrder(boolean order) {
this.order = order;
}
public boolean isMap() {
return map;
}
public void setMap(boolean map) {
this.map = map;
}
public boolean isMember() {
return member;
}
public void setMember(boolean member) {
this.member = member;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSegmentAttributes;
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSegmentAttributesImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLPartition extends OracleSegmentAttributesImpl implements OracleSegmentAttributes {
protected SQLName name;
protected SQLExpr subPartitionsCount;
protected List<SQLSubPartition> subPartitions = new ArrayList<SQLSubPartition>();
protected SQLPartitionValue values;
// for mysql
protected SQLExpr dataDirectory;
protected SQLExpr indexDirectory;
protected SQLExpr maxRows;
protected SQLExpr minRows;
protected SQLExpr engine;
protected SQLExpr comment;
// for oracle
protected boolean segmentCreationImmediate;
protected boolean segmentCreationDeferred;
private SQLObject lobStorage;
private SQLExpr locality;
public SQLExpr getLocality() {
return locality;
}
public void setLocality(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.locality = x;
}
public SQLName getName() {
return name;
}
public void setName(SQLName name) {
if (name != null) {
name.setParent(this);
}
this.name = name;
}
public SQLExpr getSubPartitionsCount() {
return subPartitionsCount;
}
public void setSubPartitionsCount(SQLExpr subPartitionsCount) {
if (subPartitionsCount != null) {
subPartitionsCount.setParent(this);
}
this.subPartitionsCount = subPartitionsCount;
}
public SQLPartitionValue getValues() {
return values;
}
public void setValues(SQLPartitionValue values) {
if (values != null) {
values.setParent(this);
}
this.values = values;
}
public List<SQLSubPartition> getSubPartitions() {
return subPartitions;
}
public void addSubPartition(SQLSubPartition partition) {
if (partition != null) {
partition.setParent(this);
}
this.subPartitions.add(partition);
}
public SQLExpr getIndexDirectory() {
return indexDirectory;
}
public void setIndexDirectory(SQLExpr indexDirectory) {
if (indexDirectory != null) {
indexDirectory.setParent(this);
}
this.indexDirectory = indexDirectory;
}
public SQLExpr getDataDirectory() {
return dataDirectory;
}
public void setDataDirectory(SQLExpr dataDirectory) {
if (dataDirectory != null) {
dataDirectory.setParent(this);
}
this.dataDirectory = dataDirectory;
}
public SQLExpr getMaxRows() {
return maxRows;
}
public void setMaxRows(SQLExpr maxRows) {
if (maxRows != null) {
maxRows.setParent(this);
}
this.maxRows = maxRows;
}
public SQLExpr getMinRows() {
return minRows;
}
public void setMinRows(SQLExpr minRows) {
if (minRows != null) {
minRows.setParent(this);
}
this.minRows = minRows;
}
public SQLExpr getEngine() {
return engine;
}
public void setEngine(SQLExpr engine) {
if (engine != null) {
engine.setParent(this);
}
this.engine = engine;
}
public SQLExpr getComment() {
return comment;
}
public void setComment(SQLExpr comment) {
if (comment != null) {
comment.setParent(this);
}
this.comment = comment;
}
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
acceptChild(visitor, values);
acceptChild(visitor, dataDirectory);
acceptChild(visitor, indexDirectory);
acceptChild(visitor, tablespace);
acceptChild(visitor, maxRows);
acceptChild(visitor, minRows);
acceptChild(visitor, engine);
acceptChild(visitor, comment);
acceptChild(visitor, subPartitionsCount);
acceptChild(visitor, storage);
acceptChild(visitor, subPartitions);
}
visitor.endVisit(this);
}
public SQLObject getLobStorage() {
return lobStorage;
}
public void setLobStorage(SQLObject lobStorage) {
if (lobStorage != null) {
lobStorage.setParent(this);
}
this.lobStorage = lobStorage;
}
public boolean isSegmentCreationImmediate() {
return segmentCreationImmediate;
}
public void setSegmentCreationImmediate(boolean segmentCreationImmediate) {
this.segmentCreationImmediate = segmentCreationImmediate;
}
public boolean isSegmentCreationDeferred() {
return segmentCreationDeferred;
}
public void setSegmentCreationDeferred(boolean segmentCreationDeferred) {
this.segmentCreationDeferred = segmentCreationDeferred;
}
public SQLPartition clone() {
SQLPartition x = new SQLPartition();
if (name != null) {
x.setName(name.clone());
}
if (subPartitionsCount != null) {
x.setSubPartitionsCount(subPartitionsCount.clone());
}
for (SQLSubPartition p : subPartitions) {
SQLSubPartition p2 = p.clone();
p2.setParent(x);
x.subPartitions.add(p2);
}
if (values != null) {
x.setValues(values.clone());
}
if (dataDirectory != null) {
x.setDataDirectory(dataDirectory.clone());
}
if (indexDirectory != null) {
x.setDataDirectory(indexDirectory.clone());
}
if (maxRows != null) {
x.setDataDirectory(maxRows.clone());
}
if (minRows != null) {
x.setDataDirectory(minRows.clone());
}
if (engine != null) {
x.setDataDirectory(engine.clone());
}
if (comment != null) {
x.setDataDirectory(comment.clone());
}
x.segmentCreationImmediate = segmentCreationImmediate;
x.segmentCreationDeferred = segmentCreationDeferred;
if (lobStorage != null) {
x.setLobStorage(lobStorage.clone());
}
return x;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
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>();
protected SQLIntegerExpr lifecycle;
public List<SQLPartition> getPartitions() {
return partitions;
}
public void addPartition(SQLPartition partition) {
if (partition != null) {
partition.setParent(this);
}
this.partitions.add(partition);
}
public SQLSubPartitionBy getSubPartitionBy() {
return subPartitionBy;
}
public void setSubPartitionBy(SQLSubPartitionBy subPartitionBy) {
if (subPartitionBy != null) {
subPartitionBy.setParent(this);
}
this.subPartitionBy = subPartitionBy;
}
public SQLExpr getPartitionsCount() {
return partitionsCount;
}
public void setPartitionsCount(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.partitionsCount = x;
}
public void setPartitionsCount(int partitionsCount) {
this.partitionsCount = new SQLIntegerExpr(partitionsCount);
}
public boolean isLinear() {
return linear;
}
public void setLinear(boolean linear) {
this.linear = linear;
}
public List<SQLName> getStoreIn() {
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());
}
if (partitionsCount != null) {
x.setPartitionsCount(partitionsCount.clone());
}
x.linear = linear;
for (SQLPartition p : partitions) {
SQLPartition p2 = p.clone();
p2.setParent(x);
x.partitions.add(p2);
}
for (SQLName name : storeIn) {
SQLName name2 = name.clone();
name2.setParent(x);
x.storeIn.add(name2);
}
x.lifecycle = lifecycle;
}
public boolean isPartitionByColumn(long columnNameHashCode64) {
for (SQLExpr column : columns) {
if (column instanceof SQLIdentifierExpr
&& ((SQLIdentifierExpr) column)
.nameHashCode64() == columnNameHashCode64) {
return true;
}
}
if (subPartitionBy != null) {
return subPartitionBy.isPartitionByColumn(columnNameHashCode64);
}
return false;
}
public SQLIntegerExpr getLifecycle() {
return lifecycle;
}
public void setLifecycle(SQLIntegerExpr lifecycle) {
this.lifecycle = lifecycle;
}
public abstract SQLPartitionBy clone();
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLPartitionByHash extends SQLPartitionBy {
// for aliyun ads
protected boolean key;
protected boolean unique;
public boolean isKey() {
return key;
}
public void setKey(boolean key) {
this.key = key;
}
public boolean isUnique() {
return unique;
}
public void setUnique(boolean unique) {
this.unique = unique;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, columns);
acceptChild(visitor, partitionsCount);
acceptChild(visitor, getPartitions());
acceptChild(visitor, subPartitionBy);
}
visitor.endVisit(this);
}
public SQLPartitionByHash clone() {
SQLPartitionByHash x = new SQLPartitionByHash();
cloneTo(x);
x.key = key;
x.unique = unique;
for (SQLExpr column : columns) {
SQLExpr c2 = column.clone();
c2.setParent(x);
x.columns.add(c2);
}
return x;
}
public void cloneTo(SQLPartitionByHash x) {
super.cloneTo(x);
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLPartitionByList extends SQLPartitionBy {
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, columns);
acceptChild(visitor, partitionsCount);
acceptChild(visitor, getPartitions());
acceptChild(visitor, subPartitionBy);
}
visitor.endVisit(this);
}
public SQLPartitionByList clone() {
SQLPartitionByList x = new SQLPartitionByList();
this.cloneTo(x);
for (SQLExpr column : columns) {
SQLExpr c2 = column.clone();
c2.setParent(x);
x.columns.add(c2);
}
return x;
}
public void cloneTo(SQLPartitionByList x) {
super.cloneTo(x);
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLPartitionByRange extends SQLPartitionBy {
protected SQLExpr interval;
protected boolean isColumns;
protected SQLExpr startWith;
protected SQLIntegerExpr expireAfter;
protected SQLIntegerExpr preAllocate;
protected SQLExpr pivotDateExpr;
protected boolean disableSchedule;
public SQLPartitionByRange() {
}
public SQLExpr getInterval() {
return interval;
}
public void setInterval(SQLExpr interval) {
if (interval != null) {
interval.setParent(this);
}
this.interval = interval;
}
public SQLExpr getStartWith() {
return this.startWith;
}
public void setStartWith(final SQLExpr startWith) {
if (startWith != null) {
startWith.setParent(this);
}
this.startWith = startWith;
}
public SQLIntegerExpr getExpireAfter() {
return this.expireAfter;
}
public void setExpireAfter(final SQLIntegerExpr expireAfter) {
if (expireAfter != null) {
expireAfter.setParent(this);
}
this.expireAfter = expireAfter;
}
public SQLIntegerExpr getPreAllocate() {
return this.preAllocate;
}
public void setPreAllocate(final SQLIntegerExpr preAllocate) {
if (preAllocate != null) {
preAllocate.setParent(this);
}
this.preAllocate = preAllocate;
}
public SQLExpr getPivotDateExpr() {
return this.pivotDateExpr;
}
public void setPivotDateExpr(final SQLExpr pivotDateExpr) {
if (pivotDateExpr != null) {
pivotDateExpr.setParent(this);
}
this.pivotDateExpr = pivotDateExpr;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, columns);
acceptChild(visitor, interval);
acceptChild(visitor, expireAfter);
acceptChild(visitor, preAllocate);
acceptChild(visitor, pivotDateExpr);
acceptChild(visitor, columns);
acceptChild(visitor, storeIn);
acceptChild(visitor, partitions);
acceptChild(visitor, subPartitionBy);
}
visitor.endVisit(this);
}
public SQLPartitionByRange clone() {
SQLPartitionByRange x = new SQLPartitionByRange();
this.cloneTo(x);
if (interval != null) {
x.setInterval(interval.clone());
}
if (startWith != null) {
x.setStartWith(startWith.clone());
}
if (expireAfter != null) {
x.setExpireAfter(expireAfter.clone());
}
for (SQLExpr column : columns) {
SQLExpr c2 = column.clone();
c2.setParent(x);
x.columns.add(c2);
}
x.setColumns(this.isColumns);
x.setDisableSchedule(this.disableSchedule);
return x;
}
public void cloneTo(SQLPartitionByRange x) {
super.cloneTo(x);
}
public boolean isColumns() {
return isColumns;
}
public void setColumns(boolean columns) {
isColumns = columns;
}
public boolean isDisableSchedule() {
return this.disableSchedule;
}
public void setDisableSchedule(final boolean disableSchedule) {
this.disableSchedule = disableSchedule;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLPartitionByValue extends SQLPartitionBy {
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, columns);
acceptChild(visitor, storeIn);
acceptChild(visitor, partitions);
acceptChild(visitor, subPartitionBy);
}
visitor.endVisit(this);
}
public SQLPartitionByValue clone() {
SQLPartitionByValue x = new SQLPartitionByValue();
cloneTo(x);
for (SQLExpr column : columns) {
SQLExpr c2 = column.clone();
c2.setParent(x);
x.columns.add(c2);
}
return x;
}
public void cloneTo(SQLPartitionByValue x) {
super.cloneTo(x);
}
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLPartitionSpec extends SQLObjectImpl implements Cloneable {
private List<Item> items = new ArrayList<Item>();
@Override
protected void accept0(SQLASTVisitor v) {
if (v.visit(this)) {
acceptChild(v, items);
}
v.endVisit(this);
}
public void addItem(Item item) {
item.setParent(this);
items.add(item);
}
public List<Item> getItems() {
return items;
}
public SQLPartitionSpec clone() {
SQLPartitionSpec x = new SQLPartitionSpec();
for (Item item : items) {
x.addItem(item.clone());
}
return x;
}
public static class Item extends SQLObjectImpl implements Cloneable {
private SQLName column;
private SQLExpr value;
@Override
protected void accept0(SQLASTVisitor v) {
if (v.visit(this)) {
acceptChild(v, column);
acceptChild(v, value);
}
v.endVisit(this);
}
public Item clone() {
Item x = new Item();
if (column != null) {
x.setColumn(column.clone());
}
if (value != null) {
x.setValue(value.clone());
}
return x;
}
public SQLName getColumn() {
return column;
}
public void setColumn(SQLName column) {
this.column = column;
}
public SQLExpr getValue() {
return value;
}
public void setValue(SQLExpr value) {
this.value = value;
}
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSegmentAttributesImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLPartitionValue extends OracleSegmentAttributesImpl {
protected Operator operator;
protected final List<SQLExpr> items = new ArrayList<SQLExpr>();
public SQLPartitionValue(Operator operator) {
super();
this.operator = operator;
}
public List<SQLExpr> getItems() {
return items;
}
public void addItem(SQLExpr item) {
if (item != null) {
item.setParent(this);
}
this.items.add(item);
}
public Operator getOperator() {
return operator;
}
public static enum Operator {
LessThan,
In,
List
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, getItems());
}
visitor.endVisit(this);
}
public SQLPartitionValue clone() {
SQLPartitionValue x = new SQLPartitionValue(operator);
for (SQLExpr item : items) {
SQLExpr item2 = item.clone();
item2.setParent(x);
x.items.add(item2);
}
return x;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLRecordDataType extends SQLDataTypeImpl implements SQLDataType {
private final List<SQLColumnDefinition> columns = new ArrayList<SQLColumnDefinition>();
public List<SQLColumnDefinition> getColumns() {
return columns;
}
public void addColumn(SQLColumnDefinition column) {
column.setParent(this);
this.columns.add(column);
}
public SQLRecordDataType clone() {
SQLRecordDataType x = new SQLRecordDataType();
cloneTo(x);
for (SQLColumnDefinition c : columns) {
SQLColumnDefinition c2 = c.clone();
c2.setParent(x);
x.columns.add(c2);
}
return x;
}
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, this.columns);
}
visitor.endVisit(this);
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
/**
* Created by wenshao on 06/06/2017.
*/
public interface SQLReplaceable {
boolean replace(SQLExpr expr, SQLExpr target);
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.ast.SQLStructDataType.Field;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.util.FnvHash;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SQLRowDataType extends SQLObjectImpl implements SQLDataType {
private DbType dbType;
private List<Field> fields = new ArrayList<Field>();
public SQLRowDataType() {
}
public SQLRowDataType(DbType dbType) {
this.dbType = dbType;
}
@Override
public String getName() {
return "ROW";
}
@Override
public long nameHashCode64() {
return FnvHash.Constants.ROW;
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException();
}
@Override
public List<SQLExpr> getArguments() {
return Collections.emptyList();
}
@Override
public Boolean getWithTimeZone() {
return null;
}
@Override
public void setWithTimeZone(Boolean value) {
throw new UnsupportedOperationException();
}
@Override
public boolean isWithLocalTimeZone() {
return false;
}
@Override
public void setWithLocalTimeZone(boolean value) {
throw new UnsupportedOperationException();
}
@Override
public void setDbType(DbType dbType) {
this.dbType = dbType;
}
@Override
public DbType getDbType() {
return dbType;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, fields);
}
visitor.endVisit(this);
}
public SQLRowDataType clone() {
SQLRowDataType x = new SQLRowDataType(dbType);
for (Field field : fields) {
x.addField(field.getName(), field.getDataType().clone());
}
return x;
}
public List<Field> getFields() {
return fields;
}
public Field addField(SQLName name, SQLDataType dataType) {
Field field = new Field(name, dataType);
field.setParent(this);
fields.add(field);
return field;
}
public int jdbcType() {
return Types.STRUCT;
}
@Override
public boolean isInt() {
return false;
}
@Override
public boolean isNumberic() {
return false;
}
@Override
public boolean isString() {
return false;
}
@Override
public boolean hasKeyLength() {
return false;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
public interface SQLSetQuantifier {
// SQL 92
public static final int ALL = 1;
public static final int DISTINCT = 2;
public static final int UNIQUE = 3;
public static final int DISTINCTROW = 4;
// <SetQuantifier>
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.visitor.VisitorFeature;
import java.util.List;
public interface SQLStatement extends SQLObject, SQLDbTypedObject {
DbType getDbType();
boolean isAfterSemi();
void setAfterSemi(boolean afterSemi);
SQLStatement clone();
List<SQLObject> getChildren();
List<SQLCommentHint> getHeadHintsDirect();
void setHeadHints(List<SQLCommentHint> headHints);
String toString();
String toString(VisitorFeature... features);
String toLowerCaseString();
String toParameterizedString();
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.sql.visitor.VisitorFeature;
import java.util.List;
public abstract class SQLStatementImpl extends SQLObjectImpl implements SQLStatement {
protected DbType dbType;
protected boolean afterSemi;
protected List<SQLCommentHint> headHints;
public SQLStatementImpl() {
}
public SQLStatementImpl(DbType dbType) {
this.dbType = dbType;
}
public DbType getDbType() {
return dbType;
}
public void setDbType(DbType dbType) {
this.dbType = dbType;
}
public String toString() {
return SQLUtils.toSQLString(this, dbType);
}
public String toString(VisitorFeature... features) {
return SQLUtils.toSQLString(this, dbType, null, features);
}
public String toLowerCaseString() {
return SQLUtils.toSQLString(this, dbType, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION);
}
public String toUnformattedString() {
return SQLUtils.toSQLString(this, dbType, new SQLUtils.FormatOption(true, false));
}
public String toParameterizedString() {
return ParameterizedOutputVisitorUtils.parameterize(this, dbType);
}
@Override
protected void accept0(SQLASTVisitor v) {
throw new UnsupportedOperationException(this.getClass().getName());
}
public List<SQLObject> getChildren() {
throw new UnsupportedOperationException(this.getClass().getName());
}
public boolean isAfterSemi() {
return afterSemi;
}
public void setAfterSemi(boolean afterSemi) {
this.afterSemi = afterSemi;
}
public SQLStatement clone() {
throw new UnsupportedOperationException(this.getClass().getName());
}
public List<SQLCommentHint> getHeadHintsDirect() {
return headHints;
}
public void setHeadHints(List<SQLCommentHint> headHints) {
this.headHints = headHints;
}
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.util.FnvHash;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SQLStructDataType extends SQLObjectImpl implements SQLDataType {
private DbType dbType;
private List<Field> fields = new ArrayList<Field>();
public SQLStructDataType() {
}
public SQLStructDataType(DbType dbType) {
this.dbType = dbType;
}
@Override
public String getName() {
return "STRUCT";
}
@Override
public long nameHashCode64() {
return FnvHash.Constants.STRUCT;
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException();
}
@Override
public List<SQLExpr> getArguments() {
return Collections.emptyList();
}
@Override
public Boolean getWithTimeZone() {
return null;
}
@Override
public void setWithTimeZone(Boolean value) {
throw new UnsupportedOperationException();
}
@Override
public boolean isWithLocalTimeZone() {
return false;
}
@Override
public void setWithLocalTimeZone(boolean value) {
throw new UnsupportedOperationException();
}
@Override
public void setDbType(DbType dbType) {
this.dbType = dbType;
}
@Override
public DbType getDbType() {
return dbType;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, fields);
}
visitor.endVisit(this);
}
public SQLStructDataType clone() {
SQLStructDataType x = new SQLStructDataType(dbType);
for (Field field : fields) {
x.addField(field.name, field.dataType.clone());
}
return x;
}
public List<Field> getFields() {
return fields;
}
public Field addField(SQLName name, SQLDataType dataType) {
Field field = new Field(name, dataType);
field.setParent(this);
fields.add(field);
return field;
}
public int jdbcType() {
return Types.STRUCT;
}
@Override
public boolean isInt() {
return false;
}
@Override
public boolean isNumberic() {
return false;
}
@Override
public boolean isString() {
return false;
}
@Override
public boolean hasKeyLength() {
return false;
}
public static class Field extends SQLObjectImpl {
private SQLName name;
private SQLDataType dataType;
private String comment;
public Field(SQLName name, SQLDataType dataType) {
setName(name);
setDataType(dataType);
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
acceptChild(visitor, dataType);
}
visitor.endVisit(this);
}
public SQLName getName() {
return name;
}
public void setName(SQLName x) {
if (x != null) {
x.setParent(this);
}
this.name = x;
}
public SQLDataType getDataType() {
return dataType;
}
public void setDataType(SQLDataType x) {
if (x != null) {
x.setParent(this);
}
this.dataType = x;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.dialect.oracle.ast.OracleSegmentAttributesImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLSubPartition extends OracleSegmentAttributesImpl {
protected SQLName name;
protected SQLPartitionValue values;
protected SQLName tableSpace;
// for mysql
protected SQLExpr dataDirectory;
protected SQLExpr indexDirectory;
protected SQLExpr maxRows;
protected SQLExpr minRows;
protected SQLExpr engine;
protected SQLExpr comment;
public SQLName getName() {
return name;
}
public void setName(SQLName name) {
if (name != null) {
name.setParent(this);
}
this.name = name;
}
public SQLPartitionValue getValues() {
return values;
}
public void setValues(SQLPartitionValue values) {
if (values != null) {
values.setParent(this);
}
this.values = values;
}
public SQLName getTableSpace() {
return tableSpace;
}
public void setTableSpace(SQLName tableSpace) {
if (tableSpace != null) {
tableSpace.setParent(this);
}
this.tableSpace = tableSpace;
}
public SQLExpr getDataDirectory() {
return dataDirectory;
}
public void setDataDirectory(SQLExpr dataDirectory) {
this.dataDirectory = dataDirectory;
}
public SQLExpr getIndexDirectory() {
return indexDirectory;
}
public void setIndexDirectory(SQLExpr indexDirectory) {
this.indexDirectory = indexDirectory;
}
public SQLExpr getMaxRows() {
return maxRows;
}
public void setMaxRows(SQLExpr maxRows) {
this.maxRows = maxRows;
}
public SQLExpr getMinRows() {
return minRows;
}
public void setMinRows(SQLExpr minRows) {
this.minRows = minRows;
}
public SQLExpr getEngine() {
return engine;
}
public void setEngine(SQLExpr engine) {
this.engine = engine;
}
public SQLExpr getComment() {
return comment;
}
public void setComment(SQLExpr comment) {
this.comment = comment;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
acceptChild(visitor, tableSpace);
acceptChild(visitor, values);
}
visitor.endVisit(this);
}
public SQLSubPartition clone() {
SQLSubPartition x = new SQLSubPartition();
if (name != null) {
x.setName(name.clone());
}
if (values != null) {
x.setValues(values.clone());
}
if (tableSpace != null) {
x.setTableSpace(tableSpace.clone());
}
return x;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
import java.util.ArrayList;
import java.util.List;
public abstract class SQLSubPartitionBy extends SQLObjectImpl {
protected SQLExpr subPartitionsCount;
protected boolean linear;
protected List<SQLAssignItem> options = new ArrayList<SQLAssignItem>();
protected List<SQLSubPartition> subPartitionTemplate = new ArrayList<SQLSubPartition>();
protected SQLIntegerExpr lifecycle;
public SQLExpr getSubPartitionsCount() {
return subPartitionsCount;
}
public void setSubPartitionsCount(SQLExpr x) {
if (x != null) {
x.setParent(this);
}
this.subPartitionsCount = x;
}
public boolean isLinear() {
return linear;
}
public void setLinear(boolean linear) {
this.linear = linear;
}
public List<SQLAssignItem> getOptions() {
return options;
}
public List<SQLSubPartition> getSubPartitionTemplate() {
return subPartitionTemplate;
}
public void cloneTo(SQLSubPartitionBy x) {
if (subPartitionsCount != null) {
x.setSubPartitionsCount(subPartitionsCount.clone());
}
x.linear = linear;
for (SQLAssignItem option : options) {
SQLAssignItem option2 = option.clone();
option2.setParent(x);
x.options.add(option2);
}
for (SQLSubPartition p : subPartitionTemplate) {
SQLSubPartition p2 = p.clone();
p2.setParent(x);
x.subPartitionTemplate.add(p2);
}
x.lifecycle = lifecycle;
}
public SQLIntegerExpr getLifecycle() {
return lifecycle;
}
public void setLifecycle(SQLIntegerExpr lifecycle) {
this.lifecycle = lifecycle;
}
public boolean isPartitionByColumn(long columnNameHashCode64) {
return false;
}
public abstract SQLSubPartitionBy clone();
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLSubPartitionByHash extends SQLSubPartitionBy {
protected SQLExpr expr;
// for aliyun ads
private boolean key;
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, expr);
acceptChild(visitor, subPartitionsCount);
}
visitor.endVisit(this);
}
public boolean isKey() {
return key;
}
public void setKey(boolean key) {
this.key = key;
}
public SQLSubPartitionByHash clone() {
SQLSubPartitionByHash x = new SQLSubPartitionByHash();
if (expr != null) {
x.setExpr(expr.clone());
}
x.key = key;
return x;
}
public boolean isPartitionByColumn(long columnNameHashCode64) {
return expr instanceof SQLName
&& ((SQLName) expr).nameHashCode64() == columnNameHashCode64;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLSubPartitionByList extends SQLSubPartitionBy {
protected SQLName column;
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, column);
acceptChild(visitor, subPartitionsCount);
}
visitor.endVisit(this);
}
public SQLName getColumn() {
return column;
}
public void setColumn(SQLName column) {
if (column != null) {
column.setParent(this);
}
this.column = column;
}
public SQLSubPartitionByList clone() {
SQLSubPartitionByList x = new SQLSubPartitionByList();
if (column != null) {
x.setColumn(column.clone());
}
return x;
}
public boolean isPartitionByColumn(long columnNameHashCode64) {
return column != null
&& column.nameHashCode64() == columnNameHashCode64;
}
}
/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLSubPartitionByRange extends SQLSubPartitionBy {
private List<SQLExpr> columns = new ArrayList<SQLExpr>();
public List<SQLExpr> getColumns() {
return columns;
}
@Override
protected void accept0(SQLASTVisitor v) {
if (v.visit(this)) {
acceptChild(v, columns);
acceptChild(v, subPartitionsCount);
}
v.endVisit(this);
}
public SQLSubPartitionByRange clone() {
SQLSubPartitionByRange x = new SQLSubPartitionByRange();
for (SQLExpr column : columns) {
SQLExpr c2 = column.clone();
c2.setParent(x);
x.columns.add(c2);
}
return x;
}
public boolean isPartitionByColumn(long columnNameHashCode64) {
for (SQLExpr column : columns) {
if (column instanceof SQLIdentifierExpr
&& ((SQLIdentifierExpr) column).nameHashCode64() == columnNameHashCode64) {
return true;
}
}
return false;
}
}
package com.alibaba.druid.sql.ast;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.util.FnvHash;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SQLTableDataType extends SQLObjectImpl implements SQLDataType {
private DbType dbType;
private List<SQLColumnDefinition> columns = new ArrayList<SQLColumnDefinition>();
public SQLTableDataType() {
}
public SQLTableDataType(DbType dbType) {
this.dbType = dbType;
}
@Override
public String getName() {
return "TABLE";
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException();
}
@Override
public long nameHashCode64() {
return FnvHash.Constants.TABLE;
}
@Override
public List<SQLExpr> getArguments() {
return Collections.emptyList();
}
@Override
public Boolean getWithTimeZone() {
return null;
}
@Override
public void setWithTimeZone(Boolean value) {
throw new UnsupportedOperationException();
}
@Override
public boolean isWithLocalTimeZone() {
return false;
}
@Override
public void setWithLocalTimeZone(boolean value) {
throw new UnsupportedOperationException();
}
@Override
public DbType getDbType() {
return dbType;
}
@Override
public void setDbType(DbType dbType) {
this.dbType = dbType;
}
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, columns);
}
visitor.endVisit(this);
}
public SQLTableDataType clone() {
SQLTableDataType x = new SQLTableDataType(dbType);
for (SQLColumnDefinition item : columns) {
SQLColumnDefinition item2 = item.clone();
item2.setParent(x);
x.columns.add(item2);
}
return x;
}
public List<SQLColumnDefinition> getColumns() {
return columns;
}
public int jdbcType() {
return Types.STRUCT;
}
@Override
public boolean isInt() {
return false;
}
@Override
public boolean isNumberic() {
return false;
}
@Override
public boolean isString() {
return false;
}
@Override
public boolean hasKeyLength() {
return false;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment