nameParts) {
+ this(nameParts.size() > 1
+ ? new Table(nameParts.subList(0, nameParts.size() - 1)) : null,
+ nameParts.get(nameParts.size() - 1));
+ }
+
public Column(String columnName) {
this(null, columnName);
}
+ /**
+ * Retrieve the information regarding the {@code Table} this {@code Column} does
+ * belong to, if any can be inferred.
+ *
+ * The inference is based only on local information, and not on the whole SQL command.
+ * For example, consider the following query:
+ *
+ * SELECT x FROM Foo
+ *
+ * Given the {@code Column} called {@code x}, this method would return {@code null},
+ * and not the info about the table {@code Foo}.
+ * On the other hand, consider:
+ *
+ * SELECT t.x FROM Foo t
+ *
+ * Here, we will get a {@code Table} object for a table called {@code t}.
+ * But because the inference is local, such object will not know that {@code t} is
+ * just an alias for {@code Foo}.
+ *
+ * @return an instance of {@link net.sf.jsqlparser.schema.Table} representing the
+ * table this column does belong to, if it can be inferred. Can be {@code null}.
+ */
public Table getTable() {
return table;
}
@@ -65,12 +82,6 @@ public String getFullyQualifiedName() {
return getName(false);
}
- /**
- * Get name with out without using aliases.
- *
- * @param aliases
- * @return
- */
public String getName(boolean aliases) {
StringBuilder fqn = new StringBuilder();
diff --git a/src/main/java/net/sf/jsqlparser/schema/Database.java b/src/main/java/net/sf/jsqlparser/schema/Database.java
index 5035b4fd..9ec4b539 100644
--- a/src/main/java/net/sf/jsqlparser/schema/Database.java
+++ b/src/main/java/net/sf/jsqlparser/schema/Database.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.schema;
diff --git a/src/main/java/net/sf/jsqlparser/schema/MultiPartName.java b/src/main/java/net/sf/jsqlparser/schema/MultiPartName.java
index b238c755..57960855 100644
--- a/src/main/java/net/sf/jsqlparser/schema/MultiPartName.java
+++ b/src/main/java/net/sf/jsqlparser/schema/MultiPartName.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.schema;
diff --git a/src/main/java/net/sf/jsqlparser/schema/Server.java b/src/main/java/net/sf/jsqlparser/schema/Server.java
index 7b83ab67..ea983b60 100644
--- a/src/main/java/net/sf/jsqlparser/schema/Server.java
+++ b/src/main/java/net/sf/jsqlparser/schema/Server.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.schema;
diff --git a/src/main/java/net/sf/jsqlparser/schema/Table.java b/src/main/java/net/sf/jsqlparser/schema/Table.java
index 97b82098..93c30f5e 100644
--- a/src/main/java/net/sf/jsqlparser/schema/Table.java
+++ b/src/main/java/net/sf/jsqlparser/schema/Table.java
@@ -1,26 +1,17 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.schema;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import net.sf.jsqlparser.expression.*;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.statement.select.*;
@@ -30,54 +21,69 @@
*/
public class Table extends ASTNodeAccessImpl implements FromItem, MultiPartName {
- private Database database;
- private String schemaName;
- private String name;
+// private Database database;
+// private String schemaName;
+// private String name;
+ private static final int NAME_IDX = 0;
+ private static final int SCHEMA_IDX = 1;
+ private static final int DATABASE_IDX = 2;
+ private static final int SERVER_IDX = 3;
+
+ private List partItems = new ArrayList<>();
private Alias alias;
private Pivot pivot;
+ private UnPivot unpivot;
private MySQLIndexHint hint;
public Table() {
}
public Table(String name) {
- this.name = name;
+ setName(name);
}
public Table(String schemaName, String name) {
- this.schemaName = schemaName;
- this.name = name;
+ setName(name);
+ setSchemaName(schemaName);
}
public Table(Database database, String schemaName, String name) {
- this.database = database;
- this.schemaName = schemaName;
- this.name = name;
+ setName(name);
+ setSchemaName(schemaName);
+ setDatabase(database);
+ }
+
+ public Table(List partItems) {
+ this.partItems = new ArrayList<>(partItems);
+ Collections.reverse(this.partItems);
}
public Database getDatabase() {
- return database;
+ return new Database(getIndex(DATABASE_IDX));
}
public void setDatabase(Database database) {
- this.database = database;
+ setIndex(DATABASE_IDX, database.getDatabaseName());
+ if (database.getServer() != null) {
+ setIndex(SERVER_IDX, database.getServer().getFullyQualifiedName());
+ }
}
public String getSchemaName() {
- return schemaName;
+ return getIndex(SCHEMA_IDX);
}
public void setSchemaName(String string) {
- schemaName = string;
+ setIndex(SCHEMA_IDX, string);
}
public String getName() {
- return name;
+ return getIndex(NAME_IDX);
}
public void setName(String string) {
- name = string;
+ setIndex(NAME_IDX, string);
}
@Override
@@ -90,29 +96,38 @@ public void setAlias(Alias alias) {
this.alias = alias;
}
- @Override
- public String getFullyQualifiedName() {
- String fqn = "";
-
- if (database != null) {
- fqn += database.getFullyQualifiedName();
- }
- if (!fqn.isEmpty()) {
- fqn += ".";
+ private void setIndex(int idx, String value) {
+ int size = partItems.size();
+ for (int i = 0; i < idx - size + 1; i++) {
+ partItems.add(null);
}
+ partItems.set(idx, value);
+ }
- if (schemaName != null) {
- fqn += schemaName;
- }
- if (!fqn.isEmpty()) {
- fqn += ".";
+ private String getIndex(int idx) {
+ if (idx < partItems.size()) {
+ return partItems.get(idx);
+ } else {
+ return null;
}
+ }
- if (name != null) {
- fqn += name;
+ @Override
+ public String getFullyQualifiedName() {
+ StringBuilder fqn = new StringBuilder();
+
+ for (int i = partItems.size() - 1; i >= 0; i--) {
+ String part = partItems.get(i);
+ if (part == null) {
+ part = "";
+ }
+ fqn.append(part);
+ if (i != 0) {
+ fqn.append(".");
+ }
}
- return fqn;
+ return fqn.toString();
}
@Override
@@ -134,6 +149,16 @@ public void setPivot(Pivot pivot) {
this.pivot = pivot;
}
+ @Override
+ public UnPivot getUnPivot() {
+ return this.unpivot;
+ }
+
+ @Override
+ public void setUnPivot(UnPivot unpivot) {
+ this.unpivot = unpivot;
+ }
+
public MySQLIndexHint getIndexHint() {
return hint;
}
@@ -145,8 +170,9 @@ public void setHint(MySQLIndexHint hint) {
@Override
public String toString() {
return getFullyQualifiedName()
- + ((pivot != null) ? " " + pivot : "")
+ ((alias != null) ? alias.toString() : "")
+ + ((pivot != null) ? " " + pivot : "")
+ + ((unpivot != null) ? " " + unpivot : "")
+ ((hint != null) ? hint.toString() : "");
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/Block.java b/src/main/java/net/sf/jsqlparser/statement/Block.java
new file mode 100644
index 00000000..8d41cc74
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/Block.java
@@ -0,0 +1,33 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+public class Block implements Statement {
+
+ private Statements statements;
+
+ public Statements getStatements() {
+ return statements;
+ }
+
+ public void setStatements(Statements statements) {
+ this.statements = statements;
+ }
+
+ @Override
+ public void accept(StatementVisitor statementVisitor) {
+ statementVisitor.visit(this);
+ }
+
+ @Override
+ public String toString() {
+ return "BEGIN\n" + (statements != null ? statements.toString() : "") + "END";
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/Commit.java b/src/main/java/net/sf/jsqlparser/statement/Commit.java
index 66116a4b..f33a36ae 100644
--- a/src/main/java/net/sf/jsqlparser/statement/Commit.java
+++ b/src/main/java/net/sf/jsqlparser/statement/Commit.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2017 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;
diff --git a/src/main/java/net/sf/jsqlparser/statement/DeclareStatement.java b/src/main/java/net/sf/jsqlparser/statement/DeclareStatement.java
new file mode 100644
index 00000000..da84c419
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/DeclareStatement.java
@@ -0,0 +1,132 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import java.util.ArrayList;
+import java.util.List;
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.UserVariable;
+import net.sf.jsqlparser.statement.create.table.ColDataType;
+import net.sf.jsqlparser.statement.create.table.ColumnDefinition;
+
+public final class DeclareStatement implements Statement {
+
+ private UserVariable userVariable = null;
+ private DeclareType type = DeclareType.TYPE;
+ private String typeName;
+ private List typeDefExprList = new ArrayList<>();
+ private List colDefs = new ArrayList<>();
+
+ public DeclareStatement() {
+ }
+
+ public void setUserVariable(UserVariable userVariable) {
+ this.userVariable = userVariable;
+ }
+
+ public UserVariable getUserVariable() {
+ return userVariable;
+ }
+
+ public DeclareType getType() {
+ return type;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setDeclareType(DeclareType type) {
+ this.type = type;
+ }
+
+ public void addType(ColDataType colDataType, Expression defaultExpr) {
+ typeDefExprList.add(new TypeDefExpr(colDataType, defaultExpr));
+ }
+
+ public void addType(UserVariable userVariable, ColDataType colDataType, Expression defaultExpr) {
+ typeDefExprList.add(new TypeDefExpr(userVariable, colDataType, defaultExpr));
+ }
+
+ public void addColumnDefinition(ColumnDefinition colDef) {
+ colDefs.add(colDef);
+ }
+
+ public List getColumnDefinitions() {
+ return colDefs;
+ }
+
+ public List getTypeDefinitions() {
+ return typeDefExprList;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b = new StringBuilder("DECLARE ");
+ if (type == DeclareType.AS) {
+ b.append(userVariable.toString());
+ b.append(" AS ").append(typeName);
+ } else {
+ if (type == DeclareType.TABLE) {
+ b.append(userVariable.toString());
+ b.append(" TABLE (");
+ for (int i = 0; i < colDefs.size(); i++) {
+ if (i > 0) {
+ b.append(", ");
+ }
+ b.append(colDefs.get(i).toString());
+ }
+ b.append(")");
+ } else {
+ for (int i = 0; i < typeDefExprList.size(); i++) {
+ if (i > 0) {
+ b.append(", ");
+ }
+ final TypeDefExpr type = typeDefExprList.get(i);
+ if (type.userVariable != null) {
+ b.append(type.userVariable.toString()).append(" ");
+ }
+ b.append(type.colDataType.toString());
+ if (type.defaultExpr != null) {
+ b.append(" = ").append(type.defaultExpr.toString());
+ }
+ }
+ }
+ }
+ return b.toString();
+ }
+
+ @Override
+ public void accept(StatementVisitor statementVisitor
+ ) {
+ statementVisitor.visit(this);
+ }
+
+ public static class TypeDefExpr {
+
+ public final UserVariable userVariable;
+ public final ColDataType colDataType;
+ public final Expression defaultExpr;
+
+ public TypeDefExpr(ColDataType colDataType, Expression defaultExpr) {
+ this(null, colDataType, defaultExpr);
+ }
+
+ public TypeDefExpr(UserVariable userVariable, ColDataType colDataType, Expression defaultExpr) {
+ this.userVariable = userVariable;
+ this.colDataType = colDataType;
+ this.defaultExpr = defaultExpr;
+ }
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/DeclareType.java b/src/main/java/net/sf/jsqlparser/statement/DeclareType.java
new file mode 100644
index 00000000..8e0d7119
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/DeclareType.java
@@ -0,0 +1,18 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+/**
+ *
+ * @author tobens
+ */
+public enum DeclareType {
+ TABLE, AS, TYPE
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/DescribeStatement.java b/src/main/java/net/sf/jsqlparser/statement/DescribeStatement.java
new file mode 100644
index 00000000..26bf26dc
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/DescribeStatement.java
@@ -0,0 +1,39 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.schema.Table;
+
+public class DescribeStatement implements Statement {
+
+ private Table table;
+
+ public DescribeStatement(Table table) {
+ this.table = table;
+ }
+
+ public Table getTable() {
+ return table;
+ }
+
+ public void setTable(Table table) {
+ this.table = table;
+ }
+
+ @Override
+ public String toString() {
+ return "DESCRIBE " + table.getFullyQualifiedName();
+ }
+
+ @Override
+ public void accept(StatementVisitor statementVisitor) {
+ statementVisitor.visit(this);
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java b/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java
new file mode 100644
index 00000000..35c8c377
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java
@@ -0,0 +1,39 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.statement.select.Select;
+
+public class ExplainStatement implements Statement {
+
+ private Select select;
+
+ public ExplainStatement(Select select) {
+ this.select = select;
+ }
+
+ public Select getStatement() {
+ return select;
+ }
+
+ public void setStatement(Select select) {
+ this.select = select;
+ }
+
+ @Override
+ public String toString() {
+ return "EXPLAIN " + select.toString();
+ }
+
+ @Override
+ public void accept(StatementVisitor statementVisitor) {
+ statementVisitor.visit(this);
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/SetStatement.java b/src/main/java/net/sf/jsqlparser/statement/SetStatement.java
index 8794bd1b..8350f007 100644
--- a/src/main/java/net/sf/jsqlparser/statement/SetStatement.java
+++ b/src/main/java/net/sf/jsqlparser/statement/SetStatement.java
@@ -1,93 +1,120 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2015 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
- /*
- * Copyright (C) 2015 JSQLParser.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
package net.sf.jsqlparser.statement;
+import java.util.ArrayList;
+import java.util.List;
import net.sf.jsqlparser.expression.Expression;
-/**
- *
- * @author toben
- */
-public class SetStatement implements Statement {
+public final class SetStatement implements Statement {
- private String name;
- private Expression expression;
- private boolean useEqual;
+ private final List values = new ArrayList<>();
public SetStatement(String name, Expression expression) {
- this.name = name;
- this.expression = expression;
+ add(name, expression, true);
+ }
+
+ public void add(String name, Expression expression, boolean useEqual) {
+ values.add(new NameExpr(name, expression, useEqual));
+ }
+
+ public void remove(int idx) {
+ values.remove(idx);
+ }
+
+ public int getCount() {
+ return values.size();
+ }
+
+ public boolean isUseEqual(int idx) {
+ return values.get(idx).useEqual;
}
public boolean isUseEqual() {
- return useEqual;
+ return isUseEqual(0);
}
- public SetStatement setUseEqual(boolean useEqual) {
- this.useEqual = useEqual;
+ public SetStatement setUseEqual(int idx, boolean useEqual) {
+ values.get(idx).useEqual = useEqual;
return this;
}
+ public SetStatement setUseEqual(boolean useEqual) {
+ return setUseEqual(0, useEqual);
+ }
+
public String getName() {
- return name;
+ return getName(0);
+ }
+
+ public String getName(int idx) {
+ return values.get(idx).name;
}
public void setName(String name) {
- this.name = name;
+ setName(0, name);
+ }
+
+ public void setName(int idx, String name) {
+ values.get(idx).name = name;
+ }
+
+ public Expression getExpression(int idx) {
+ return values.get(idx).expression;
}
public Expression getExpression() {
- return expression;
+ return getExpression(0);
+ }
+
+ public void setExpression(int idx, Expression expression) {
+ values.get(idx).expression = expression;
}
public void setExpression(Expression expression) {
- this.expression = expression;
+ setExpression(0, expression);
+ }
+
+ private String toString(NameExpr ne) {
+ return ne.name + (ne.useEqual ? " = " : " ") + ne.expression.toString();
}
@Override
public String toString() {
- return "SET " + name + (useEqual ? " = " : " ") + expression.toString();
+ StringBuilder b = new StringBuilder("SET ");
+
+ for (NameExpr ne : values) {
+ if (b.length() != 4) {
+ b.append(", ");
+ }
+ b.append(toString(ne));
+ }
+
+ return b.toString();
}
@Override
public void accept(StatementVisitor statementVisitor) {
statementVisitor.visit(this);
}
+
+ static class NameExpr {
+
+ private String name;
+ private Expression expression;
+ private boolean useEqual;
+
+ public NameExpr(String name, Expression expr, boolean useEqual) {
+ this.name = name;
+ this.expression = expr;
+ this.useEqual = useEqual;
+ }
+ }
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ShowColumnsStatement.java b/src/main/java/net/sf/jsqlparser/statement/ShowColumnsStatement.java
new file mode 100644
index 00000000..71f9822e
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/ShowColumnsStatement.java
@@ -0,0 +1,37 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+public class ShowColumnsStatement implements Statement {
+
+ private String tableName;
+
+ public ShowColumnsStatement(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ @Override
+ public String toString() {
+ return "SHOW COLUMNS FROM " + tableName;
+ }
+
+ @Override
+ public void accept(StatementVisitor statementVisitor) {
+ statementVisitor.visit(this);
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ShowStatement.java b/src/main/java/net/sf/jsqlparser/statement/ShowStatement.java
new file mode 100644
index 00000000..9e3bd62a
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/ShowStatement.java
@@ -0,0 +1,37 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+public class ShowStatement implements Statement {
+
+ private String name;
+
+ public ShowStatement(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "SHOW " + name;
+ }
+
+ @Override
+ public void accept(StatementVisitor statementVisitor) {
+ statementVisitor.visit(this);
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/Statement.java b/src/main/java/net/sf/jsqlparser/statement/Statement.java
index bf45b83c..e90f8746 100644
--- a/src/main/java/net/sf/jsqlparser/statement/Statement.java
+++ b/src/main/java/net/sf/jsqlparser/statement/Statement.java
@@ -1,29 +1,14 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;
-/**
- * An operation on the db (SELECT, UPDATE ecc.)
- */
public interface Statement {
void accept(StatementVisitor statementVisitor);
diff --git a/src/main/java/net/sf/jsqlparser/statement/StatementVisitor.java b/src/main/java/net/sf/jsqlparser/statement/StatementVisitor.java
index 9a9a05ee..531921ba 100644
--- a/src/main/java/net/sf/jsqlparser/statement/StatementVisitor.java
+++ b/src/main/java/net/sf/jsqlparser/statement/StatementVisitor.java
@@ -1,27 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;
import net.sf.jsqlparser.statement.alter.Alter;
+import net.sf.jsqlparser.statement.comment.Comment;
import net.sf.jsqlparser.statement.create.index.CreateIndex;
import net.sf.jsqlparser.statement.create.table.CreateTable;
import net.sf.jsqlparser.statement.create.view.AlterView;
@@ -36,9 +25,12 @@
import net.sf.jsqlparser.statement.truncate.Truncate;
import net.sf.jsqlparser.statement.update.Update;
import net.sf.jsqlparser.statement.upsert.Upsert;
+import net.sf.jsqlparser.statement.values.ValuesStatement;
public interface StatementVisitor {
+ void visit(Comment comment);
+
void visit(Commit commit);
void visit(Delete delete);
@@ -69,10 +61,25 @@ public interface StatementVisitor {
void visit(SetStatement set);
+ void visit(ShowColumnsStatement set);
+
void visit(Merge merge);
void visit(Select select);
void visit(Upsert upsert);
+ void visit(UseStatement use);
+
+ void visit(Block block);
+
+ void visit(ValuesStatement values);
+
+ void visit(DescribeStatement describe);
+
+ public void visit(ExplainStatement aThis);
+
+ public void visit(ShowStatement aThis);
+
+ public void visit(DeclareStatement aThis);
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/StatementVisitorAdapter.java b/src/main/java/net/sf/jsqlparser/statement/StatementVisitorAdapter.java
index b2a364c8..df46cc2f 100644
--- a/src/main/java/net/sf/jsqlparser/statement/StatementVisitorAdapter.java
+++ b/src/main/java/net/sf/jsqlparser/statement/StatementVisitorAdapter.java
@@ -1,27 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;
import net.sf.jsqlparser.statement.alter.Alter;
+import net.sf.jsqlparser.statement.comment.Comment;
import net.sf.jsqlparser.statement.create.index.CreateIndex;
import net.sf.jsqlparser.statement.create.table.CreateTable;
import net.sf.jsqlparser.statement.create.view.AlterView;
@@ -36,11 +25,18 @@
import net.sf.jsqlparser.statement.truncate.Truncate;
import net.sf.jsqlparser.statement.update.Update;
import net.sf.jsqlparser.statement.upsert.Upsert;
+import net.sf.jsqlparser.statement.values.ValuesStatement;
public class StatementVisitorAdapter implements StatementVisitor {
+
+ @Override
+ public void visit(Comment comment) {
+
+ }
+
@Override
public void visit(Commit commit) {
-
+
}
@Override
@@ -115,6 +111,10 @@ public void visit(SetStatement set) {
}
+ @Override
+ public void visit(ShowColumnsStatement set) {
+ }
+
@Override
public void visit(Merge merge) {
@@ -126,6 +126,33 @@ public void visit(AlterView alterView) {
@Override
public void visit(Upsert upsert) {
-
+ }
+
+ @Override
+ public void visit(UseStatement use) {
+ }
+
+ @Override
+ public void visit(Block block) {
+ }
+
+ @Override
+ public void visit(ValuesStatement values) {
+ }
+
+ @Override
+ public void visit(DescribeStatement describe) {
+ }
+
+ @Override
+ public void visit(ExplainStatement aThis) {
+ }
+
+ @Override
+ public void visit(ShowStatement aThis) {
+ }
+
+ @Override
+ public void visit(DeclareStatement aThis) {
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/Statements.java b/src/main/java/net/sf/jsqlparser/statement/Statements.java
index 1d9f38eb..a0f7989c 100644
--- a/src/main/java/net/sf/jsqlparser/statement/Statements.java
+++ b/src/main/java/net/sf/jsqlparser/statement/Statements.java
@@ -1,32 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2014 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;
import java.util.List;
-/**
- *
- * @author toben
- */
public class Statements {
private List statements;
diff --git a/src/main/java/net/sf/jsqlparser/statement/UseStatement.java b/src/main/java/net/sf/jsqlparser/statement/UseStatement.java
new file mode 100644
index 00000000..37d5e150
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/UseStatement.java
@@ -0,0 +1,37 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+public class UseStatement implements Statement {
+
+ private String name;
+
+ public UseStatement(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "USE " + name;
+ }
+
+ @Override
+ public void accept(StatementVisitor statementVisitor) {
+ statementVisitor.visit(this);
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/alter/Alter.java b/src/main/java/net/sf/jsqlparser/statement/alter/Alter.java
index b0ea9342..944284f6 100644
--- a/src/main/java/net/sf/jsqlparser/statement/alter/Alter.java
+++ b/src/main/java/net/sf/jsqlparser/statement/alter/Alter.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.alter;
@@ -29,10 +17,6 @@
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.StatementVisitor;
-/**
- *
- * @author toben & wrobstory
- */
public class Alter implements Statement {
private Table table;
diff --git a/src/main/java/net/sf/jsqlparser/statement/alter/AlterExpression.java b/src/main/java/net/sf/jsqlparser/statement/alter/AlterExpression.java
index 62b31b66..fb1ee97d 100644
--- a/src/main/java/net/sf/jsqlparser/statement/alter/AlterExpression.java
+++ b/src/main/java/net/sf/jsqlparser/statement/alter/AlterExpression.java
@@ -1,42 +1,28 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2016 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.alter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-
import net.sf.jsqlparser.statement.create.table.ColDataType;
import net.sf.jsqlparser.statement.create.table.Index;
import net.sf.jsqlparser.statement.select.PlainSelect;
-/**
- *
- * @author toben & wrobstory
- */
public class AlterExpression {
private AlterOperation operation;
+ private String optionalSpecifier;
private String columnName;
+ private String columnOldName;
//private ColDataType dataType;
private List colDataTypeList;
@@ -46,14 +32,18 @@ public class AlterExpression {
private String ukName;
private Index index = null;
private String constraintName;
+ private boolean constraintIfExists;
private boolean onDeleteRestrict;
private boolean onDeleteSetNull;
private boolean onDeleteCascade;
private List fkColumns;
private String fkSourceTable;
private List fkSourceColumns;
+ private boolean uk;
+ private boolean useEqual;
private List constraints;
+ private List parameters;
public AlterOperation getOperation() {
return operation;
@@ -63,6 +53,14 @@ public void setOperation(AlterOperation operation) {
this.operation = operation;
}
+ public String getOptionalSpecifier() {
+ return optionalSpecifier;
+ }
+
+ public void setOptionalSpecifier(String optionalSpecifier) {
+ this.optionalSpecifier = optionalSpecifier;
+ }
+
public boolean isOnDeleteCascade() {
return onDeleteCascade;
}
@@ -108,7 +106,7 @@ public List getColDataTypeList() {
}
public void addColDataType(String columnName, ColDataType colDataType) {
- addColDataType(new ColumnDataType(columnName, colDataType, null));
+ addColDataType(new ColumnDataType(columnName, false, colDataType, null));
}
public void addColDataType(ColumnDataType columnDataType) {
@@ -134,6 +132,14 @@ public void setColumnName(String columnName) {
this.columnName = columnName;
}
+ public String getColOldName() {
+ return columnOldName;
+ }
+
+ public void setColOldName(String columnOldName) {
+ this.columnOldName = columnOldName;
+ }
+
public String getConstraintName() {
return this.constraintName;
}
@@ -142,6 +148,14 @@ public void setConstraintName(final String constraintName) {
this.constraintName = constraintName;
}
+ public boolean isConstraintIfExists() {
+ return constraintIfExists;
+ }
+
+ public void setConstraintIfExists(boolean constraintIfExists) {
+ this.constraintIfExists = constraintIfExists;
+ }
+
public List getPkColumns() {
return pkColumns;
}
@@ -182,6 +196,33 @@ public void setConstraints(List constraints) {
this.constraints = constraints;
}
+ public void addParameters(String... params) {
+ if (parameters == null) {
+ parameters = new ArrayList();
+ }
+ parameters.addAll(Arrays.asList(params));
+ }
+
+ public List getParameters() {
+ return parameters;
+ }
+
+ public boolean getUseEqual() {
+ return useEqual;
+ }
+
+ public void setUseEqual(boolean useEqual) {
+ this.useEqual = useEqual;
+ }
+
+ public boolean getUk() {
+ return uk;
+ }
+
+ public void setUk(boolean uk) {
+ this.uk = uk;
+ }
+
@Override
public String toString() {
@@ -192,7 +233,12 @@ public String toString() {
if (columnName != null) {
b.append("COLUMN ").append(columnName);
} else if (getColDataTypeList() != null) {
- if (colDataTypeList.size() > 1) {
+ if (operation == AlterOperation.CHANGE) {
+ if (optionalSpecifier != null) {
+ b.append(optionalSpecifier).append(" ");
+ }
+ b.append(columnOldName).append(" ");
+ } else if (colDataTypeList.size() > 1) {
b.append("(");
} else {
b.append("COLUMN ");
@@ -202,12 +248,24 @@ public String toString() {
b.append(")");
}
} else if (constraintName != null) {
- b.append("CONSTRAINT ").append(constraintName);
+ b.append("CONSTRAINT ");
+ if (constraintIfExists) {
+ b.append("IF EXISTS ");
+ }
+ b.append(constraintName);
} else if (pkColumns != null) {
b.append("PRIMARY KEY (").append(PlainSelect.getStringList(pkColumns)).append(')');
} else if (ukColumns != null) {
- b.append("UNIQUE KEY ").append(ukName).append(" (").append(PlainSelect.
- getStringList(ukColumns)).append(")");
+ b.append("UNIQUE");
+ if (ukName != null) {
+ if (getUk()) {
+ b.append(" KEY ");
+ } else {
+ b.append(" INDEX ");
+ }
+ b.append(ukName);
+ }
+ b.append(" (").append(PlainSelect.getStringList(ukColumns)).append(")");
} else if (fkColumns != null) {
b.append("FOREIGN KEY (").append(PlainSelect.getStringList(fkColumns)).
append(") REFERENCES ").append(fkSourceTable).append(" (").append(
@@ -225,6 +283,12 @@ public String toString() {
if (getConstraints() != null && !getConstraints().isEmpty()) {
b.append(' ').append(PlainSelect.getStringList(constraints, false, false));
}
+ if (getUseEqual()) {
+ b.append('=');
+ }
+ if (parameters != null && !parameters.isEmpty()) {
+ b.append(' ').append(PlainSelect.getStringList(parameters, false, false));
+ }
return b.toString();
}
@@ -232,11 +296,13 @@ public String toString() {
public static class ColumnDataType {
private final String columnName;
+ private final boolean withType;
private final ColDataType colDataType;
private final List columnSpecs;
- public ColumnDataType(String columnName, ColDataType colDataType, List columnSpecs) {
+ public ColumnDataType(String columnName, boolean withType, ColDataType colDataType, List columnSpecs) {
this.columnName = columnName;
+ this.withType = withType;
this.colDataType = colDataType;
this.columnSpecs = columnSpecs;
}
@@ -258,7 +324,7 @@ public List getColumnSpecs() {
@Override
public String toString() {
- return columnName + " " + colDataType + parametersToString();
+ return columnName + (withType ? " TYPE " : " ") + colDataType + parametersToString();
}
private String parametersToString() {
diff --git a/src/main/java/net/sf/jsqlparser/statement/alter/AlterOperation.java b/src/main/java/net/sf/jsqlparser/statement/alter/AlterOperation.java
index ea37d08c..53b27893 100644
--- a/src/main/java/net/sf/jsqlparser/statement/alter/AlterOperation.java
+++ b/src/main/java/net/sf/jsqlparser/statement/alter/AlterOperation.java
@@ -1,30 +1,14 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2016 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.alter;
-/**
- *
- * @author toben
- */
public enum AlterOperation {
- ADD, DROP, MODIFY, CHANGE;
+ ADD, ALTER, DROP, MODIFY, CHANGE, ALGORITHM;
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/alter/ConstraintState.java b/src/main/java/net/sf/jsqlparser/statement/alter/ConstraintState.java
index 878566b1..432173a8 100644
--- a/src/main/java/net/sf/jsqlparser/statement/alter/ConstraintState.java
+++ b/src/main/java/net/sf/jsqlparser/statement/alter/ConstraintState.java
@@ -1,30 +1,13 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2017 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.alter;
-/**
- * Based on https://docs.oracle.com/cd/B28359_01/server.111/b28286/clauses002.htm#i1002273
- *
- * @author Christophe Moine
- */
public interface ConstraintState {
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/alter/DeferrableConstraint.java b/src/main/java/net/sf/jsqlparser/statement/alter/DeferrableConstraint.java
index c249b7d8..15bba4a1 100644
--- a/src/main/java/net/sf/jsqlparser/statement/alter/DeferrableConstraint.java
+++ b/src/main/java/net/sf/jsqlparser/statement/alter/DeferrableConstraint.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2017 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.alter;
diff --git a/src/main/java/net/sf/jsqlparser/statement/alter/EnableConstraint.java b/src/main/java/net/sf/jsqlparser/statement/alter/EnableConstraint.java
index 1bdcd7ec..9573a1b6 100644
--- a/src/main/java/net/sf/jsqlparser/statement/alter/EnableConstraint.java
+++ b/src/main/java/net/sf/jsqlparser/statement/alter/EnableConstraint.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2017 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.alter;
diff --git a/src/main/java/net/sf/jsqlparser/statement/alter/ValidateConstraint.java b/src/main/java/net/sf/jsqlparser/statement/alter/ValidateConstraint.java
index c4241fa4..36d000a9 100644
--- a/src/main/java/net/sf/jsqlparser/statement/alter/ValidateConstraint.java
+++ b/src/main/java/net/sf/jsqlparser/statement/alter/ValidateConstraint.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2017 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.alter;
diff --git a/src/main/java/net/sf/jsqlparser/statement/comment/Comment.java b/src/main/java/net/sf/jsqlparser/statement/comment/Comment.java
new file mode 100755
index 00000000..b44fbf12
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/comment/Comment.java
@@ -0,0 +1,64 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.comment;
+
+import net.sf.jsqlparser.expression.StringValue;
+import net.sf.jsqlparser.schema.Column;
+import net.sf.jsqlparser.schema.Table;
+import net.sf.jsqlparser.statement.Statement;
+import net.sf.jsqlparser.statement.StatementVisitor;
+
+public class Comment implements Statement {
+
+ private Table table;
+ private Column column;
+ private StringValue comment;
+
+ @Override
+ public void accept(StatementVisitor statementVisitor) {
+ statementVisitor.visit(this);
+ }
+
+ public Table getTable() {
+ return table;
+ }
+
+ public void setTable(Table table) {
+ this.table = table;
+ }
+
+ public Column getColumn() {
+ return column;
+ }
+
+ public void setColumn(Column column) {
+ this.column = column;
+ }
+
+ public StringValue getComment() {
+ return comment;
+ }
+
+ public void setComment(StringValue comment) {
+ this.comment = comment;
+ }
+
+ @Override
+ public String toString() {
+ String sql = "COMMENT ON ";
+ if (table != null) {
+ sql += "TABLE " + table + " ";
+ } else if (column != null) {
+ sql += "COLUMN " + column + " ";
+ }
+ sql += "IS " + comment;
+ return sql;
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/index/CreateIndex.java b/src/main/java/net/sf/jsqlparser/statement/create/index/CreateIndex.java
index 5b590ea4..92c602d5 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/index/CreateIndex.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/index/CreateIndex.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.index;
@@ -27,11 +15,6 @@
import java.util.*;
-/**
- * A "CREATE INDEX" statement
- *
- * @author Raymond Augé
- */
public class CreateIndex implements Statement {
private Table table;
@@ -42,9 +25,6 @@ public void accept(StatementVisitor statementVisitor) {
statementVisitor.visit(this);
}
- /**
- * The index to be created
- */
public Index getIndex() {
return index;
}
@@ -53,9 +33,6 @@ public void setIndex(Index index) {
this.index = index;
}
- /**
- * The table on which the index is to be created
- */
public Table getTable() {
return table;
}
@@ -80,6 +57,11 @@ public String toString() {
buffer.append(" ON ");
buffer.append(table.getFullyQualifiedName());
+ if (index.getUsing() != null){
+ buffer.append(" USING ");
+ buffer.append(index.getUsing());
+ }
+
if (index.getColumnsNames() != null) {
buffer.append(" (");
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/table/CheckConstraint.java b/src/main/java/net/sf/jsqlparser/statement/create/table/CheckConstraint.java
index 8d2c14cf..30dfbc42 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/table/CheckConstraint.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/table/CheckConstraint.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.table;
@@ -24,12 +12,6 @@
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.schema.Table;
-/**
- * Table Check Constraint Eg. ' CONSTRAINT less_than_ten CHECK (count < 10) ' @au
- *
- *
- * thor mw
- */
public class CheckConstraint extends NamedConstraint {
private Table table;
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/table/ColDataType.java b/src/main/java/net/sf/jsqlparser/statement/create/table/ColDataType.java
index fafb4f06..de414896 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/table/ColDataType.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/table/ColDataType.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.table;
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/table/ColumnDefinition.java b/src/main/java/net/sf/jsqlparser/statement/create/table/ColumnDefinition.java
index c43adcbf..91e6640b 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/table/ColumnDefinition.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/table/ColumnDefinition.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.table;
@@ -25,20 +13,12 @@
import net.sf.jsqlparser.statement.select.PlainSelect;
-/**
- * A column definition in a CREATE TABLE statement.
- * Example: mycol VARCHAR(30) NOT NULL
- */
public class ColumnDefinition {
private String columnName;
private ColDataType colDataType;
private List columnSpecStrings;
- /**
- * A list of strings of every word after the datatype of the column.
- * Example ("NOT", "NULL")
- */
public List getColumnSpecStrings() {
return columnSpecStrings;
}
@@ -47,9 +27,6 @@ public void setColumnSpecStrings(List list) {
columnSpecStrings = list;
}
- /**
- * The {@link ColDataType} of this column definition
- */
public ColDataType getColDataType() {
return colDataType;
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/table/CreateTable.java b/src/main/java/net/sf/jsqlparser/statement/create/table/CreateTable.java
index 0cc64f61..3f7e58ee 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/table/CreateTable.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/table/CreateTable.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.table;
@@ -29,9 +17,6 @@
import net.sf.jsqlparser.statement.select.PlainSelect;
import net.sf.jsqlparser.statement.select.Select;
-/**
- * A "CREATE TABLE" statement
- */
public class CreateTable implements Statement {
private Table table;
@@ -49,9 +34,6 @@ public void accept(StatementVisitor statementVisitor) {
statementVisitor.visit(this);
}
- /**
- * The name of the table to be created
- */
public Table getTable() {
return table;
}
@@ -60,11 +42,6 @@ public void setTable(Table table) {
this.table = table;
}
- /**
- * Whether the table is unlogged or not (PostgreSQL 9.1+ feature)
- *
- * @return
- */
public boolean isUnlogged() {
return unlogged;
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/table/ExcludeConstraint.java b/src/main/java/net/sf/jsqlparser/statement/create/table/ExcludeConstraint.java
index 63fee20f..0cc4c9d7 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/table/ExcludeConstraint.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/table/ExcludeConstraint.java
@@ -1,33 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2016 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.table;
import net.sf.jsqlparser.expression.Expression;
-/**
- * Table Exclusion Constraint Eg. 'EXCLUDE WHERE (col1 > 100)'
- *
- * @author wrobstory
- */
public class ExcludeConstraint extends Index {
private Expression expression;
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/table/ForeignKeyIndex.java b/src/main/java/net/sf/jsqlparser/statement/create/table/ForeignKeyIndex.java
index 0c371751..3d8a23b6 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/table/ForeignKeyIndex.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/table/ForeignKeyIndex.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.table;
@@ -25,11 +13,6 @@
import net.sf.jsqlparser.schema.Table;
import net.sf.jsqlparser.statement.select.PlainSelect;
-/**
- * Foreign Key Index
- *
- * @author toben
- */
public class ForeignKeyIndex extends NamedConstraint {
private Table table;
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/table/Index.java b/src/main/java/net/sf/jsqlparser/statement/create/table/Index.java
index 30beff48..4136d563 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/table/Index.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/table/Index.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.table;
@@ -25,19 +13,14 @@
import net.sf.jsqlparser.statement.select.PlainSelect;
-/**
- * An index (unique, primary etc.) in a CREATE TABLE statement
- */
public class Index {
private String type;
+ private String using;
private List columnsNames;
private String name;
private List idxSpec;
- /**
- * A list of strings of all the columns regarding this index
- */
public List getColumnsNames() {
return columnsNames;
}
@@ -46,13 +29,21 @@ public String getName() {
return name;
}
- /**
- * The type of this index: "PRIMARY KEY", "UNIQUE", "INDEX"
- */
public String getType() {
return type;
}
+ /**
+ * In postgresql, the index type (Btree, GIST, etc.) is indicated
+ * with a USING clause.
+ * Please note that:
+ * Oracle - the type might be BITMAP, indicating a bitmap kind of index
+ * MySQL - the type might be FULLTEXT or SPATIAL
+ */
+ public void setUsing(String string) {
+ using = string;
+ }
+
public void setColumnsNames(List list) {
columnsNames = list;
}
@@ -65,6 +56,10 @@ public void setType(String string) {
type = string;
}
+ public String getUsing() {
+ return using;
+ }
+
public List getIndexSpec() {
return idxSpec;
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/table/NamedConstraint.java b/src/main/java/net/sf/jsqlparser/statement/create/table/NamedConstraint.java
index 454c8b03..55cb4a21 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/table/NamedConstraint.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/table/NamedConstraint.java
@@ -1,50 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2014 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
- /*
- * Copyright (C) 2014 JSQLParser.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
package net.sf.jsqlparser.statement.create.table;
import net.sf.jsqlparser.statement.select.PlainSelect;
-/**
- *
- * @author toben
- */
public class NamedConstraint extends Index {
@Override
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/view/AlterView.java b/src/main/java/net/sf/jsqlparser/statement/create/view/AlterView.java
index fb87502a..2e9af610 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/view/AlterView.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/view/AlterView.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.view;
@@ -28,13 +16,11 @@
import net.sf.jsqlparser.statement.select.PlainSelect;
import net.sf.jsqlparser.statement.select.SelectBody;
-/**
- * A "CREATE VIEW" statement
- */
public class AlterView implements Statement {
private Table view;
private SelectBody selectBody;
+ private boolean useReplace = false;
private List columnNames = null;
@Override
@@ -42,11 +28,6 @@ public void accept(StatementVisitor statementVisitor) {
statementVisitor.visit(this);
}
- /**
- * In the syntax tree, a view looks and acts just like a Table.
- *
- * @return The name of the view to be created.
- */
public Table getView() {
return view;
}
@@ -55,9 +36,6 @@ public void setView(Table view) {
this.view = view;
}
- /**
- * @return the SelectBody
- */
public SelectBody getSelectBody() {
return selectBody;
}
@@ -74,9 +52,22 @@ public void setColumnNames(List columnNames) {
this.columnNames = columnNames;
}
+ public boolean isUseReplace() {
+ return useReplace;
+ }
+
+ public void setUseReplace(boolean useReplace) {
+ this.useReplace = useReplace;
+ }
+
@Override
public String toString() {
- StringBuilder sql = new StringBuilder("ALTER ");
+ StringBuilder sql;
+ if (useReplace) {
+ sql = new StringBuilder("REPLACE ");
+ } else {
+ sql = new StringBuilder("ALTER ");
+ }
sql.append("VIEW ");
sql.append(view);
if (columnNames != null) {
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/view/CreateView.java b/src/main/java/net/sf/jsqlparser/statement/create/view/CreateView.java
index e3d51451..f4143fff 100644
--- a/src/main/java/net/sf/jsqlparser/statement/create/view/CreateView.java
+++ b/src/main/java/net/sf/jsqlparser/statement/create/view/CreateView.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.create.view;
@@ -26,29 +14,24 @@
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.StatementVisitor;
import net.sf.jsqlparser.statement.select.PlainSelect;
-import net.sf.jsqlparser.statement.select.SelectBody;
+import net.sf.jsqlparser.statement.select.Select;
-/**
- * A "CREATE VIEW" statement
- */
public class CreateView implements Statement {
private Table view;
- private SelectBody selectBody;
+ private Select select;
private boolean orReplace = false;
private List columnNames = null;
private boolean materialized = false;
+ private ForceOption force = ForceOption.NONE;
+ private TemporaryOption temp = TemporaryOption.NONE;
+ private boolean withReadOnly = false;
@Override
public void accept(StatementVisitor statementVisitor) {
statementVisitor.visit(this);
}
- /**
- * In the syntax tree, a view looks and acts just like a Table.
- *
- * @return The name of the view to be created.
- */
public Table getView() {
return view;
}
@@ -57,9 +40,6 @@ public void setView(Table view) {
this.view = view;
}
- /**
- * @return was "OR REPLACE" specified?
- */
public boolean isOrReplace() {
return orReplace;
}
@@ -71,15 +51,12 @@ public void setOrReplace(boolean orReplace) {
this.orReplace = orReplace;
}
- /**
- * @return the SelectBody
- */
- public SelectBody getSelectBody() {
- return selectBody;
+ public Select getSelect() {
+ return select;
}
- public void setSelectBody(SelectBody selectBody) {
- this.selectBody = selectBody;
+ public void setSelect(Select select) {
+ this.select = select;
}
public List getColumnNames() {
@@ -98,12 +75,49 @@ public void setMaterialized(boolean materialized) {
this.materialized = materialized;
}
+ public ForceOption getForce() {
+ return force;
+ }
+
+ public void setForce(ForceOption force) {
+ this.force = force;
+ }
+
+ public TemporaryOption getTemporary() {
+ return temp;
+ }
+
+ public void setTemporary(TemporaryOption temp) {
+ this.temp = temp;
+ }
+
+ public boolean isWithReadOnly() {
+ return withReadOnly;
+ }
+
+ public void setWithReadOnly(boolean withReadOnly) {
+ this.withReadOnly = withReadOnly;
+ }
+
@Override
public String toString() {
StringBuilder sql = new StringBuilder("CREATE ");
if (isOrReplace()) {
sql.append("OR REPLACE ");
}
+ switch (force) {
+ case FORCE:
+ sql.append("FORCE ");
+ break;
+ case NO_FORCE:
+ sql.append("NO FORCE ");
+ break;
+ }
+
+ if (temp != TemporaryOption.NONE) {
+ sql.append(temp.name()).append(" ");
+ }
+
if (isMaterialized()) {
sql.append("MATERIALIZED ");
}
@@ -112,7 +126,10 @@ public String toString() {
if (columnNames != null) {
sql.append(PlainSelect.getStringList(columnNames, true, true));
}
- sql.append(" AS ").append(selectBody);
+ sql.append(" AS ").append(select);
+ if (isWithReadOnly()) {
+ sql.append(" WITH READ ONLY");
+ }
return sql.toString();
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/view/ForceOption.java b/src/main/java/net/sf/jsqlparser/statement/create/view/ForceOption.java
new file mode 100644
index 00000000..66d3a962
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/create/view/ForceOption.java
@@ -0,0 +1,18 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.create.view;
+
+public enum ForceOption {
+ NONE,
+
+ FORCE,
+
+ NO_FORCE
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/create/view/TemporaryOption.java b/src/main/java/net/sf/jsqlparser/statement/create/view/TemporaryOption.java
new file mode 100644
index 00000000..31b1721f
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/create/view/TemporaryOption.java
@@ -0,0 +1,18 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.create.view;
+
+public enum TemporaryOption {
+ NONE,
+
+ TEMP,
+
+ TEMPORARY
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/delete/Delete.java b/src/main/java/net/sf/jsqlparser/statement/delete/Delete.java
index 75e6e06c..3e59b2e7 100644
--- a/src/main/java/net/sf/jsqlparser/statement/delete/Delete.java
+++ b/src/main/java/net/sf/jsqlparser/statement/delete/Delete.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.delete;
@@ -31,6 +19,7 @@
import net.sf.jsqlparser.statement.select.PlainSelect;
import java.util.List;
+import static java.util.stream.Collectors.joining;
public class Delete implements Statement {
@@ -100,9 +89,9 @@ public String toString() {
if (tables != null && tables.size() > 0) {
b.append(" ");
- for (Table t : tables) {
- b.append(t.toString());
- }
+ b.append(tables.stream()
+ .map(t -> t.toString())
+ .collect(joining(", ")));
}
b.append(" FROM ");
diff --git a/src/main/java/net/sf/jsqlparser/statement/drop/Drop.java b/src/main/java/net/sf/jsqlparser/statement/drop/Drop.java
index 69dceb18..177f6398 100644
--- a/src/main/java/net/sf/jsqlparser/statement/drop/Drop.java
+++ b/src/main/java/net/sf/jsqlparser/statement/drop/Drop.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.drop;
diff --git a/src/main/java/net/sf/jsqlparser/statement/execute/Execute.java b/src/main/java/net/sf/jsqlparser/statement/execute/Execute.java
index 4a26bd61..75422b0c 100644
--- a/src/main/java/net/sf/jsqlparser/statement/execute/Execute.java
+++ b/src/main/java/net/sf/jsqlparser/statement/execute/Execute.java
@@ -1,39 +1,26 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2014 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.execute;
+import java.util.List;
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.StatementVisitor;
import net.sf.jsqlparser.statement.select.PlainSelect;
-/**
- *
- * @author toben
- */
public class Execute implements Statement {
+ private EXEC_TYPE execType = EXEC_TYPE.EXECUTE;
private String name;
private ExpressionList exprList;
+ private boolean parenthesis = false;
public String getName() {
return name;
@@ -43,6 +30,16 @@ public void setName(String name) {
this.name = name;
}
+ public void setName(List names) {
+ for (String item : names) {
+ if (this.name != null) {
+ this.name = this.name + "." + item;
+ } else {
+ this.name = item;
+ }
+ }
+ }
+
public ExpressionList getExprList() {
return exprList;
}
@@ -51,6 +48,22 @@ public void setExprList(ExpressionList exprList) {
this.exprList = exprList;
}
+ public EXEC_TYPE getExecType() {
+ return execType;
+ }
+
+ public void setExecType(EXEC_TYPE execType) {
+ this.execType = execType;
+ }
+
+ public boolean isParenthesis() {
+ return parenthesis;
+ }
+
+ public void setParenthesis(boolean parenthesis) {
+ this.parenthesis = parenthesis;
+ }
+
@Override
public void accept(StatementVisitor statementVisitor) {
statementVisitor.visit(this);
@@ -58,8 +71,15 @@ public void accept(StatementVisitor statementVisitor) {
@Override
public String toString() {
- return "EXECUTE " + name + " " + PlainSelect.
- getStringList(exprList.getExpressions(), true, false);
+ return execType.name() + " " + name
+ + (exprList != null && exprList.getExpressions() != null ? " "
+ + PlainSelect.getStringList(exprList.getExpressions(), true, parenthesis) : "");
+ }
+
+ public static enum EXEC_TYPE {
+ EXECUTE,
+ EXEC,
+ CALL
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/insert/Insert.java b/src/main/java/net/sf/jsqlparser/statement/insert/Insert.java
index 31541aaa..14db1219 100644
--- a/src/main/java/net/sf/jsqlparser/statement/insert/Insert.java
+++ b/src/main/java/net/sf/jsqlparser/statement/insert/Insert.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.insert;
@@ -33,10 +21,6 @@
import net.sf.jsqlparser.statement.select.Select;
import net.sf.jsqlparser.statement.select.SelectExpressionItem;
-/**
- * The insert statement. Every column name in columnNames matches an item in
- * itemsList
- */
public class Insert implements Statement {
private Table table;
@@ -54,6 +38,10 @@ public class Insert implements Statement {
private boolean returningAllColumns = false;
private List returningExpressionList = null;
+
+ private boolean useSet = false;
+ private List setColumns;
+ private List setExpressionList;
@Override
public void accept(StatementVisitor statementVisitor) {
@@ -68,11 +56,6 @@ public void setTable(Table name) {
table = name;
}
- /**
- * Get the columns (found in "INSERT INTO (col1,col2..) [...]" )
- *
- * @return a list of {@link net.sf.jsqlparser.schema.Column}
- */
public List getColumns() {
return columns;
}
@@ -173,6 +156,30 @@ public boolean isModifierIgnore() {
public void setModifierIgnore(boolean modifierIgnore) {
this.modifierIgnore = modifierIgnore;
}
+
+ public void setUseSet(boolean useSet) {
+ this.useSet = useSet;
+ }
+
+ public boolean isUseSet() {
+ return useSet;
+ }
+
+ public void setSetColumns(List setColumns) {
+ this.setColumns = setColumns;
+ }
+
+ public List getSetColumns() {
+ return setColumns;
+ }
+
+ public void setSetExpressionList(List setExpressionList) {
+ this.setExpressionList = setExpressionList;
+ }
+
+ public List getSetExpressionList() {
+ return setExpressionList;
+ }
@Override
public String toString() {
@@ -208,6 +215,17 @@ public String toString() {
sql.append(")");
}
}
+
+ if (useSet) {
+ sql.append("SET ");
+ for (int i = 0; i < getSetColumns().size(); i++) {
+ if (i != 0) {
+ sql.append(", ");
+ }
+ sql.append(setColumns.get(i)).append(" = ");
+ sql.append(setExpressionList.get(i));
+ }
+ }
if (useDuplicate) {
sql.append(" ON DUPLICATE KEY UPDATE ");
@@ -229,4 +247,5 @@ public String toString() {
return sql.toString();
}
+
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/insert/InsertModifierPriority.java b/src/main/java/net/sf/jsqlparser/statement/insert/InsertModifierPriority.java
index c5296a99..534281e8 100644
--- a/src/main/java/net/sf/jsqlparser/statement/insert/InsertModifierPriority.java
+++ b/src/main/java/net/sf/jsqlparser/statement/insert/InsertModifierPriority.java
@@ -1,30 +1,14 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2015 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.insert;
-/**
- *
- * @author tw
- */
public enum InsertModifierPriority {
LOW_PRIORITY, DELAYED, HIGH_PRIORITY, IGNORE
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/merge/Merge.java b/src/main/java/net/sf/jsqlparser/statement/merge/Merge.java
index 5bb95e1d..f9c7bced 100644
--- a/src/main/java/net/sf/jsqlparser/statement/merge/Merge.java
+++ b/src/main/java/net/sf/jsqlparser/statement/merge/Merge.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2015 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.merge;
@@ -28,11 +16,6 @@
import net.sf.jsqlparser.statement.StatementVisitor;
import net.sf.jsqlparser.statement.select.SubSelect;
-/**
- * Merge - statement
- *
- * @author tw
- */
public class Merge implements Statement {
private Table table;
diff --git a/src/main/java/net/sf/jsqlparser/statement/merge/MergeInsert.java b/src/main/java/net/sf/jsqlparser/statement/merge/MergeInsert.java
index cfc679c1..6f46a357 100644
--- a/src/main/java/net/sf/jsqlparser/statement/merge/MergeInsert.java
+++ b/src/main/java/net/sf/jsqlparser/statement/merge/MergeInsert.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2015 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.merge;
@@ -26,10 +14,6 @@
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.statement.select.PlainSelect;
-/**
- *
- * @author toben
- */
public class MergeInsert {
private List columns = null;
@@ -53,7 +37,8 @@ public void setValues(List values) {
@Override
public String toString() {
- return " WHEN NOT MATCHED THEN INSERT " + PlainSelect.getStringList(columns, true, true)
+ return " WHEN NOT MATCHED THEN INSERT "
+ + (columns.isEmpty() ? "" : PlainSelect.getStringList(columns, true, true))
+ " VALUES " + PlainSelect.getStringList(values, true, true);
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/merge/MergeUpdate.java b/src/main/java/net/sf/jsqlparser/statement/merge/MergeUpdate.java
index bdd1a404..b81b446d 100644
--- a/src/main/java/net/sf/jsqlparser/statement/merge/MergeUpdate.java
+++ b/src/main/java/net/sf/jsqlparser/statement/merge/MergeUpdate.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2015 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.merge;
@@ -25,10 +13,6 @@
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.schema.Column;
-/**
- *
- * @author toben
- */
public class MergeUpdate {
private List columns = null;
diff --git a/src/main/java/net/sf/jsqlparser/statement/replace/Replace.java b/src/main/java/net/sf/jsqlparser/statement/replace/Replace.java
index 936d1665..51252d3e 100644
--- a/src/main/java/net/sf/jsqlparser/statement/replace/Replace.java
+++ b/src/main/java/net/sf/jsqlparser/statement/replace/Replace.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.replace;
@@ -31,9 +19,6 @@
import net.sf.jsqlparser.statement.StatementVisitor;
import net.sf.jsqlparser.statement.select.PlainSelect;
-/**
- * The replace statement.
- */
public class Replace implements Statement {
private Table table;
@@ -64,20 +49,10 @@ public void setUseIntoTables(boolean useIntoTables) {
this.useIntoTables = useIntoTables;
}
- /**
- * A list of {@link net.sf.jsqlparser.schema.Column}s either from a "REPLACE mytab (col1, col2)
- * [...]" or a "REPLACE mytab SET col1=exp1, col2=exp2".
- *
- * @return a list of {@link net.sf.jsqlparser.schema.Column}s
- */
public List getColumns() {
return columns;
}
- /**
- * An {@link ItemsList} (either from a "REPLACE mytab VALUES (exp1,exp2)" or a "REPLACE mytab
- * SELECT * FROM mytab2") it is null in case of a "REPLACE mytab SET col1=exp1, col2=exp2"
- */
public ItemsList getItemsList() {
return itemsList;
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/AllColumns.java b/src/main/java/net/sf/jsqlparser/statement/select/AllColumns.java
index 36949093..b01828b3 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/AllColumns.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/AllColumns.java
@@ -1,30 +1,17 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
-/**
- * All the columns (as in "SELECT * FROM ...")
- */
-public class AllColumns implements SelectItem {
+import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
+
+public class AllColumns extends ASTNodeAccessImpl implements SelectItem {
public AllColumns() {
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/AllTableColumns.java b/src/main/java/net/sf/jsqlparser/statement/select/AllTableColumns.java
index 35c8acb5..e1b7d3d5 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/AllTableColumns.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/AllTableColumns.java
@@ -1,32 +1,18 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
-/**
- * All the columns of a table (as in "SELECT TableName.* FROM ...")
- */
+import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.schema.*;
-public class AllTableColumns implements SelectItem {
+public class AllTableColumns extends ASTNodeAccessImpl implements SelectItem {
private Table table;
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/Distinct.java b/src/main/java/net/sf/jsqlparser/statement/select/Distinct.java
index e9d62ab0..9b2f6c83 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/Distinct.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/Distinct.java
@@ -1,31 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import java.util.List;
-/**
- * A DISTINCT [ON (expression, ...)] clause
- */
public class Distinct {
private List onSelectItems;
@@ -38,11 +23,6 @@ public Distinct(boolean useUnique) {
this.useUnique = useUnique;
}
- /**
- * A list of {@link SelectItem}s expressions, as in "select DISTINCT ON (a,b,c) a,b FROM..."
- *
- * @return a list of {@link SelectItem}s expressions
- */
public List getOnSelectItems() {
return onSelectItems;
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/ExceptOp.java b/src/main/java/net/sf/jsqlparser/statement/select/ExceptOp.java
index d0db50bb..f6b11a70 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/ExceptOp.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/ExceptOp.java
@@ -1,32 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.statement.select.SetOperationList.SetOperationType;
-/**
- *
- * @author tw
- */
public class ExceptOp extends SetOperation {
public ExceptOp() {
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/ExpressionListItem.java b/src/main/java/net/sf/jsqlparser/statement/select/ExpressionListItem.java
index 35e026a9..7ae1d1a9 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/ExpressionListItem.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/ExpressionListItem.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/Fetch.java b/src/main/java/net/sf/jsqlparser/statement/select/Fetch.java
index 4918ce75..3a7f34a5 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/Fetch.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/Fetch.java
@@ -1,33 +1,20 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
-/**
- * A fetch clause in the form FETCH (FIRST | NEXT) row_count (ROW | ROWS) ONLY
- */
+import net.sf.jsqlparser.expression.JdbcParameter;
+
public class Fetch {
private long rowCount;
- private boolean fetchJdbcParameter = false;
+ private JdbcParameter fetchJdbcParameter = null;
private boolean isFetchParamFirst = false;
private String fetchParam = "ROW";
@@ -39,7 +26,7 @@ public void setRowCount(long l) {
rowCount = l;
}
- public boolean isFetchJdbcParameter() {
+ public JdbcParameter getFetchJdbcParameter() {
return fetchJdbcParameter;
}
@@ -51,8 +38,8 @@ public boolean isFetchParamFirst() {
return isFetchParamFirst;
}
- public void setFetchJdbcParameter(boolean b) {
- fetchJdbcParameter = b;
+ public void setFetchJdbcParameter(JdbcParameter jdbc) {
+ fetchJdbcParameter = jdbc;
}
public void setFetchParam(String s) {
@@ -65,7 +52,8 @@ public void setFetchParamFirst(boolean b) {
@Override
public String toString() {
- return " FETCH " + (isFetchParamFirst ? "FIRST" : "NEXT") + " " + (fetchJdbcParameter ? "?" : Long.
- toString(rowCount)) + " " + fetchParam + " ONLY";
+ return " FETCH " + (isFetchParamFirst ? "FIRST" : "NEXT") + " "
+ + (fetchJdbcParameter!=null ? fetchJdbcParameter.toString() :
+ Long.toString(rowCount)) + " " + fetchParam + " ONLY";
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/First.java b/src/main/java/net/sf/jsqlparser/statement/select/First.java
index a476f025..dfac655b 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/First.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/First.java
@@ -1,35 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2015 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.expression.JdbcParameter;
-/**
- * A FIRST clause in the form [FIRST row_count] the alternative form [LIMIT row_count] is also
- * supported.
- *
- * Initial implementation was done for informix special syntax:
- * http://www-01.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ibm.sqls.doc/ids_sqs_0156.htm
- */
public class First {
public enum Keyword {
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/FromItem.java b/src/main/java/net/sf/jsqlparser/statement/select/FromItem.java
index f3781e28..b191750b 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/FromItem.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/FromItem.java
@@ -1,31 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.expression.Alias;
-/**
- * An item in a "SELECT [...] FROM item1" statement. (for example a table or a sub-select)
- */
public interface FromItem {
void accept(FromItemVisitor fromItemVisitor);
@@ -38,4 +23,8 @@ public interface FromItem {
void setPivot(Pivot pivot);
+ UnPivot getUnPivot();
+
+ void setUnPivot(UnPivot unpivot);
+
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java
index 8ec50c1b..c1c1d077 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
@@ -36,4 +24,6 @@ public interface FromItemVisitor {
void visit(ValuesList valuesList);
void visit(TableFunction tableFunction);
+
+ public void visit(ParenthesisFromItem aThis);
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java
index c2af2a11..3cdcb9c5 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
@@ -54,4 +42,9 @@ public void visit(ValuesList valuesList) {
public void visit(TableFunction valuesList) {
}
+
+ @Override
+ public void visit(ParenthesisFromItem aThis) {
+
+ }
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/FunctionItem.java b/src/main/java/net/sf/jsqlparser/statement/select/FunctionItem.java
index 292cb6d8..50c920f7 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/FunctionItem.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/FunctionItem.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/GroupByElement.java b/src/main/java/net/sf/jsqlparser/statement/select/GroupByElement.java
new file mode 100644
index 00000000..f57a06ed
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/select/GroupByElement.java
@@ -0,0 +1,82 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.select;
+
+import java.util.ArrayList;
+import java.util.List;
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
+
+public class GroupByElement {
+
+ private List groupByExpressions = new ArrayList<>();
+ private List groupingSets = new ArrayList();
+
+ public void accept(GroupByVisitor groupByVisitor) {
+ groupByVisitor.visit(this);
+ }
+
+ public List getGroupByExpressions() {
+ return groupByExpressions;
+ }
+
+ public void setGroupByExpressions(List groupByExpressions) {
+ this.groupByExpressions = groupByExpressions;
+ }
+
+ public void addGroupByExpression(Expression groupByExpression) {
+ groupByExpressions.add(groupByExpression);
+ }
+
+ public List getGroupingSets() {
+ return groupingSets;
+ }
+
+ public void setGroupingSets(List groupingSets) {
+ this.groupingSets = groupingSets;
+ }
+
+ public void addGroupingSet(Expression expr) {
+ this.groupingSets.add(expr);
+ }
+
+ public void addGroupingSet(ExpressionList list) {
+ this.groupingSets.add(list);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b = new StringBuilder();
+ b.append("GROUP BY ");
+
+ if (groupByExpressions.size() > 0) {
+ b.append(PlainSelect.getStringList(groupByExpressions));
+ } else if (groupingSets.size() > 0) {
+ b.append("GROUPING SETS (");
+ boolean first = true;
+ for (Object o : groupingSets) {
+ if (first) {
+ first = false;
+ } else {
+ b.append(", ");
+ }
+ if (o instanceof Expression) {
+ b.append(o.toString());
+ } else if (o instanceof ExpressionList) {
+ ExpressionList list = (ExpressionList) o;
+ b.append(list.getExpressions() == null ? "()" : list.toString());
+ }
+ }
+ b.append(")");
+ }
+
+ return b.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/GroupByVisitor.java b/src/main/java/net/sf/jsqlparser/statement/select/GroupByVisitor.java
new file mode 100644
index 00000000..21bfc578
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/select/GroupByVisitor.java
@@ -0,0 +1,15 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.select;
+
+public interface GroupByVisitor {
+
+ void visit(GroupByElement groupBy);
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/IntersectOp.java b/src/main/java/net/sf/jsqlparser/statement/select/IntersectOp.java
index e6976134..f2248ca1 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/IntersectOp.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/IntersectOp.java
@@ -1,32 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.statement.select.SetOperationList.SetOperationType;
-/**
- *
- * @author tw
- */
public class IntersectOp extends SetOperation {
public IntersectOp() {
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/IntoTableVisitor.java b/src/main/java/net/sf/jsqlparser/statement/select/IntoTableVisitor.java
index 9b0746d4..64a85ca9 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/IntoTableVisitor.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/IntoTableVisitor.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/IntoTableVisitorAdapter.java b/src/main/java/net/sf/jsqlparser/statement/select/IntoTableVisitorAdapter.java
index 32f960e7..5875cc6f 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/IntoTableVisitorAdapter.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/IntoTableVisitorAdapter.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/Join.java b/src/main/java/net/sf/jsqlparser/statement/select/Join.java
index a2c87fb4..98e4a89b 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/Join.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/Join.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
@@ -24,12 +12,10 @@
import java.util.List;
import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.schema.Column;
-/**
- * A join clause
- */
-public class Join {
+public class Join extends ASTNodeAccessImpl {
private boolean outer = false;
private boolean right = false;
@@ -40,15 +26,13 @@ public class Join {
private boolean simple = false;
private boolean cross = false;
private boolean semi = false;
+ private boolean straight = false;
+ private boolean apply = false;
private FromItem rightItem;
private Expression onExpression;
private List usingColumns;
+ private KSQLJoinWindow joinWindow;
- /**
- * Whether is a tab1,tab2 join
- *
- * @return true if is a "tab1,tab2" join
- */
public boolean isSimple() {
return simple;
}
@@ -57,11 +41,6 @@ public void setSimple(boolean b) {
simple = b;
}
- /**
- * Whether is a "INNER" join
- *
- * @return true if is a "INNER" join
- */
public boolean isInner() {
return inner;
}
@@ -70,6 +49,14 @@ public void setInner(boolean b) {
inner = b;
}
+ public boolean isStraight() {
+ return straight;
+ }
+
+ public void setStraight(boolean b) {
+ straight = b;
+ }
+
/**
* Whether is a "OUTER" join
*
@@ -83,6 +70,14 @@ public void setOuter(boolean b) {
outer = b;
}
+ public boolean isApply() {
+ return apply;
+ }
+
+ public void setApply(boolean apply) {
+ this.apply = apply;
+ }
+
/**
* Whether is a "SEMI" join
*
@@ -189,9 +184,26 @@ public void setUsingColumns(List list) {
usingColumns = list;
}
+ public boolean isWindowJoin() {
+ return joinWindow != null;
+ }
+
+ /**
+ * Return the "WITHIN" join window (if any)
+ */
+ public KSQLJoinWindow getJoinWindow() {
+ return joinWindow;
+ }
+
+ public void setJoinWindow(KSQLJoinWindow joinWindow) {
+ this.joinWindow = joinWindow;
+ }
+
@Override
public String toString() {
- if (isSimple()) {
+ if (isSimple() && isOuter()) {
+ return "OUTER " + rightItem;
+ } else if (isSimple()) {
return "" + rightItem;
} else {
String type = "";
@@ -216,7 +228,16 @@ public String toString() {
type += "SEMI ";
}
- return type + "JOIN " + rightItem + ((onExpression != null) ? " ON " + onExpression + "" : "")
+ if (isStraight()) {
+ type = "STRAIGHT_JOIN ";
+ } else if (isApply()) {
+ type += "APPLY ";
+ } else {
+ type += "JOIN ";
+ }
+
+ return type + rightItem + ((joinWindow != null) ? " WITHIN " + joinWindow : "")
+ + ((onExpression != null) ? " ON " + onExpression + "" : "")
+ PlainSelect.getFormatedList(usingColumns, "USING", true, true);
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/KSQLJoinWindow.java b/src/main/java/net/sf/jsqlparser/statement/select/KSQLJoinWindow.java
new file mode 100644
index 00000000..871dc028
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/select/KSQLJoinWindow.java
@@ -0,0 +1,113 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.select;
+
+import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
+
+public class KSQLJoinWindow extends ASTNodeAccessImpl {
+
+ public enum TimeUnit {
+ DAY ("DAY"),
+ HOUR ("HOUR"),
+ MINUTE ("MINUTE"),
+ SECOND ("SECOND"),
+ MILLISECOND ("MILLISECOND"),
+ DAYS ("DAYS"),
+ HOURS ("HOURS"),
+ MINUTES ("MINUTES"),
+ SECONDS ("SECONDS"),
+ MILLISECONDS ("MILLISECONDS");
+
+ private String timeUnit;
+
+ TimeUnit(String timeUnit) {
+ this.timeUnit = timeUnit;
+ }
+
+ public String getTimeUnit() {
+ return timeUnit;
+ }
+ }
+
+ private boolean beforeAfter;
+ private long duration;
+ private TimeUnit timeUnit;
+ private long beforeDuration;
+ private TimeUnit beforeTimeUnit;
+ private long afterDuration;
+ private TimeUnit afterTimeUnit;
+
+ public KSQLJoinWindow() {
+ }
+
+ public boolean isBeforeAfterWindow() {
+ return beforeAfter;
+ }
+
+ public void setBeforeAfterWindow(boolean beforeAfter) {
+ this.beforeAfter = beforeAfter;
+ }
+
+ public long getDuration() {
+ return duration;
+ }
+
+ public void setDuration(long duration) {
+ this.duration = duration;
+ }
+
+ public TimeUnit getTimeUnit() {
+ return timeUnit;
+ }
+
+ public void setTimeUnit(TimeUnit timeUnit) {
+ this.timeUnit = timeUnit;
+ }
+
+ public long getBeforeDuration() {
+ return beforeDuration;
+ }
+
+ public void setBeforeDuration(long beforeDuration) {
+ this.beforeDuration = beforeDuration;
+ }
+
+ public TimeUnit getBeforeTimeUnit() {
+ return beforeTimeUnit;
+ }
+
+ public void setBeforeTimeUnit(TimeUnit beforeTimeUnit) {
+ this.beforeTimeUnit = beforeTimeUnit;
+ }
+
+ public long getAfterDuration() {
+ return afterDuration;
+ }
+
+ public void setAfterDuration(long afterDuration) {
+ this.afterDuration = afterDuration;
+ }
+
+ public TimeUnit getAfterTimeUnit() {
+ return afterTimeUnit;
+ }
+
+ public void setAfterTimeUnit(TimeUnit afterTimeUnit) {
+ this.afterTimeUnit = afterTimeUnit;
+ }
+
+ @Override
+ public String toString() {
+ if (isBeforeAfterWindow()) {
+ return "(" + beforeDuration + " " + beforeTimeUnit + ", " + afterDuration + " " + afterTimeUnit + ")";
+ }
+ return "(" + duration + " " + timeUnit + ")";
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/KSQLWindow.java b/src/main/java/net/sf/jsqlparser/statement/select/KSQLWindow.java
new file mode 100644
index 00000000..620cb142
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/select/KSQLWindow.java
@@ -0,0 +1,133 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.select;
+
+import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
+
+public class KSQLWindow extends ASTNodeAccessImpl {
+
+ public enum TimeUnit {
+ DAY ("DAY"),
+ HOUR ("HOUR"),
+ MINUTE ("MINUTE"),
+ SECOND ("SECOND"),
+ MILLISECOND ("MILLISECOND"),
+ DAYS ("DAYS"),
+ HOURS ("HOURS"),
+ MINUTES ("MINUTES"),
+ SECONDS ("SECONDS"),
+ MILLISECONDS ("MILLISECONDS");
+
+ private String timeUnit;
+
+ TimeUnit(String timeUnit) {
+ this.timeUnit = timeUnit;
+ }
+
+ public String getTimeUnit() {
+ return timeUnit;
+ }
+ }
+
+ public enum WindowType {
+ HOPPING ("HOPPING"),
+ SESSION ("SESSION"),
+ TUMBLING ("TUMBLING");
+
+ private String windowType;
+
+ WindowType(String windowType) {
+ this.windowType = windowType;
+ }
+
+ public String getWindowType() {
+ return windowType;
+ }
+ }
+
+ private boolean hopping;
+ private boolean tumbling;
+ private boolean session;
+ private long sizeDuration;
+ private TimeUnit sizeTimeUnit;
+ private long advanceDuration;
+ private TimeUnit advanceTimeUnit;
+
+ public boolean isHoppingWindow() {
+ return hopping;
+ }
+
+ public void setHoppingWindow(boolean hopping) {
+ this.hopping = hopping;
+ }
+
+ public boolean isTumblingWindow() {
+ return tumbling;
+ }
+
+ public void setTumblingWindow(boolean tumbling) {
+ this.tumbling = tumbling;
+ }
+
+ public boolean isSessionWindow() {
+ return session;
+ }
+
+ public void setSessionWindow(boolean session) {
+ this.session = session;
+ }
+
+ public long getSizeDuration() {
+ return sizeDuration;
+ }
+
+ public void setSizeDuration(long sizeDuration) {
+ this.sizeDuration = sizeDuration;
+ }
+
+ public TimeUnit getSizeTimeUnit() {
+ return sizeTimeUnit;
+ }
+
+ public void setSizeTimeUnit(TimeUnit sizeTimeUnit) {
+ this.sizeTimeUnit = sizeTimeUnit;
+ }
+
+ public long getAdvanceDuration() {
+ return advanceDuration;
+ }
+
+ public void setAdvanceDuration(long advanceDuration) {
+ this.advanceDuration = advanceDuration;
+ }
+
+ public TimeUnit getAdvanceTimeUnit() {
+ return advanceTimeUnit;
+ }
+
+ public void setAdvanceTimeUnit(TimeUnit advanceTimeUnit) {
+ this.advanceTimeUnit = advanceTimeUnit;
+ }
+
+ public KSQLWindow() {
+ }
+
+ @Override
+ public String toString() {
+ if (isHoppingWindow()) {
+ return "HOPPING (" + "SIZE " + sizeDuration + " " + sizeTimeUnit + ", " +
+ "ADVANCE BY " + advanceDuration + " " + advanceTimeUnit + ")";
+ } else if (isSessionWindow()) {
+ return "SESSION (" + sizeDuration + " " + sizeTimeUnit + ")";
+ } else {
+ return "TUMBLING (" + "SIZE " + sizeDuration + " " + sizeTimeUnit + ")";
+ }
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/LateralSubSelect.java b/src/main/java/net/sf/jsqlparser/statement/select/LateralSubSelect.java
index 52b094f7..fb9bde26 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/LateralSubSelect.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/LateralSubSelect.java
@@ -1,76 +1,26 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
-import net.sf.jsqlparser.expression.Alias;
-
/**
- * A lateral subselect followed by an alias.
- *
- * @author Tobias Warneke
+ * lateral sub select
+ * @author tobens
*/
-public class LateralSubSelect implements FromItem {
-
- private SubSelect subSelect;
- private Alias alias;
- private Pivot pivot;
-
- public void setSubSelect(SubSelect subSelect) {
- this.subSelect = subSelect;
+public class LateralSubSelect extends SpecialSubSelect {
+
+ public LateralSubSelect() {
+ super("LATERAL");
}
-
- public SubSelect getSubSelect() {
- return subSelect;
- }
-
+
@Override
public void accept(FromItemVisitor fromItemVisitor) {
fromItemVisitor.visit(this);
}
-
- @Override
- public Alias getAlias() {
- return alias;
- }
-
- @Override
- public void setAlias(Alias alias) {
- this.alias = alias;
- }
-
- @Override
- public Pivot getPivot() {
- return pivot;
- }
-
- @Override
- public void setPivot(Pivot pivot) {
- this.pivot = pivot;
- }
-
- @Override
- public String toString() {
- return "LATERAL" + subSelect.toString()
- + ((pivot != null) ? " " + pivot : "")
- + ((alias != null) ? alias.toString() : "");
- }
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/Limit.java b/src/main/java/net/sf/jsqlparser/statement/select/Limit.java
index 981ba5d5..3ddd975b 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/Limit.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/Limit.java
@@ -1,32 +1,18 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
-/**
- * A limit clause in the form [LIMIT {[offset,] row_count) | (row_count | ALL) OFFSET offset}]
- */
-public class Limit {
+public class Limit extends ASTNodeAccessImpl {
private Expression rowCount;
private Expression offset;
@@ -49,9 +35,6 @@ public void setRowCount(Expression l) {
rowCount = l;
}
- /**
- * @return true if the limit is "LIMIT ALL [OFFSET ...])
- */
public boolean isLimitAll() {
return limitAll;
}
@@ -60,9 +43,6 @@ public void setLimitAll(boolean b) {
limitAll = b;
}
- /**
- * @return true if the limit is "LIMIT NULL [OFFSET ...])
- */
public boolean isLimitNull() {
return limitNull;
}
@@ -77,11 +57,15 @@ public String toString() {
if (limitNull) {
retVal += "NULL";
} else {
- if (null != offset) {
- retVal += offset + ", ";
- }
- if (null != rowCount) {
- retVal += rowCount;
+ if (limitAll) {
+ retVal += "ALL";
+ } else {
+ if (null != offset) {
+ retVal += offset + ", ";
+ }
+ if (null != rowCount) {
+ retVal += rowCount;
+ }
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/MinusOp.java b/src/main/java/net/sf/jsqlparser/statement/select/MinusOp.java
index d63a04bc..ab779978 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/MinusOp.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/MinusOp.java
@@ -1,32 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.statement.select.SetOperationList.SetOperationType;
-/**
- *
- * @author tw
- */
public class MinusOp extends SetOperation {
public MinusOp() {
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/Offset.java b/src/main/java/net/sf/jsqlparser/statement/select/Offset.java
index a8bb81fa..310226c0 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/Offset.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/Offset.java
@@ -1,33 +1,22 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
-/**
- * An offset clause in the form OFFSET offset or in the form OFFSET offset (ROW | ROWS)
- */
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.JdbcNamedParameter;
+import net.sf.jsqlparser.expression.JdbcParameter;
+
public class Offset {
private long offset;
- private boolean offsetJdbcParameter = false;
+ private Expression offsetJdbcParameter = null;
private String offsetParam = null;
public long getOffset() {
@@ -46,16 +35,20 @@ public void setOffsetParam(String s) {
offsetParam = s;
}
- public boolean isOffsetJdbcParameter() {
+ public Expression getOffsetJdbcParameter() {
return offsetJdbcParameter;
}
- public void setOffsetJdbcParameter(boolean b) {
- offsetJdbcParameter = b;
+ public void setOffsetJdbcParameter(JdbcParameter jdbc) {
+ offsetJdbcParameter = jdbc;
+ }
+
+ public void setOffsetJdbcParameter(JdbcNamedParameter jdbc) {
+ offsetJdbcParameter = jdbc;
}
@Override
public String toString() {
- return " OFFSET " + (offsetJdbcParameter ? "?" : offset) + (offsetParam != null ? " " + offsetParam : "");
+ return " OFFSET " + (offsetJdbcParameter!=null ? offsetJdbcParameter.toString() : offset) + (offsetParam != null ? " " + offsetParam : "");
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/OptimizeFor.java b/src/main/java/net/sf/jsqlparser/statement/select/OptimizeFor.java
new file mode 100644
index 00000000..d10d1161
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/select/OptimizeFor.java
@@ -0,0 +1,35 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.select;
+
+/**
+ * A optimize for clause.
+ */
+public class OptimizeFor {
+
+ private long rowCount;
+
+ public OptimizeFor(long rowCount) {
+ this.rowCount = rowCount;
+ }
+
+ public long getRowCount() {
+ return rowCount;
+ }
+
+ public void setRowCount(long l) {
+ rowCount = l;
+ }
+
+ @Override
+ public String toString() {
+ return " OPTIMIZE FOR " + rowCount + " ROWS";
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/OrderByElement.java b/src/main/java/net/sf/jsqlparser/statement/select/OrderByElement.java
index 1a1a3fe6..60a953a8 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/OrderByElement.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/OrderByElement.java
@@ -1,31 +1,16 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.expression.Expression;
-/**
- * An element (column reference) in an "ORDER BY" clause.
- */
public class OrderByElement {
public enum NullOrdering {
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/OrderByVisitor.java b/src/main/java/net/sf/jsqlparser/statement/select/OrderByVisitor.java
index cd82b688..e54b8fc0 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/OrderByVisitor.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/OrderByVisitor.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/OrderByVisitorAdapter.java b/src/main/java/net/sf/jsqlparser/statement/select/OrderByVisitorAdapter.java
index ba5bee90..95d9f189 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/OrderByVisitorAdapter.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/OrderByVisitorAdapter.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/ParenthesisFromItem.java b/src/main/java/net/sf/jsqlparser/statement/select/ParenthesisFromItem.java
new file mode 100644
index 00000000..8ed4eeab
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/select/ParenthesisFromItem.java
@@ -0,0 +1,74 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2019 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.select;
+
+import net.sf.jsqlparser.expression.*;
+
+public class ParenthesisFromItem implements FromItem {
+
+ private FromItem fromItem;
+
+ private Alias alias;
+
+ public ParenthesisFromItem() {
+ }
+
+ public ParenthesisFromItem(FromItem fromItem) {
+ setFromItem(fromItem);
+ }
+
+ public FromItem getFromItem() {
+ return fromItem;
+ }
+
+ public final void setFromItem(FromItem fromItem) {
+ this.fromItem = fromItem;
+ }
+
+ @Override
+ public void accept(FromItemVisitor fromItemVisitor) {
+ fromItemVisitor.visit(this);
+ }
+
+ @Override
+ public String toString() {
+ return "(" + fromItem + ")" + (alias!=null?alias.toString():"");
+ }
+
+ @Override
+ public Alias getAlias() {
+ return alias;
+ }
+
+ @Override
+ public void setAlias(Alias alias) {
+ this.alias = alias;
+ }
+
+ @Override
+ public Pivot getPivot() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setPivot(Pivot pivot) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public UnPivot getUnPivot() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setUnPivot(UnPivot unpivot) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/Pivot.java b/src/main/java/net/sf/jsqlparser/statement/select/Pivot.java
index 0c472971..191ca0b1 100755
--- a/src/main/java/net/sf/jsqlparser/statement/select/Pivot.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/Pivot.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * .
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement.select;
@@ -24,16 +12,15 @@
import net.sf.jsqlparser.schema.Column;
import java.util.List;
+import net.sf.jsqlparser.expression.Alias;
public class Pivot {
private List functionItems;
-
private List forColumns;
-
private List singleInItems;
-
private List multiInItems;
+ private Alias alias;
public void accept(PivotVisitor pivotVisitor) {
pivotVisitor.visit(this);
@@ -75,12 +62,21 @@ public List> getInItems() {
return singleInItems == null ? multiInItems : singleInItems;
}
+ public Alias getAlias() {
+ return alias;
+ }
+
+ public void setAlias(Alias alias) {
+ this.alias = alias;
+ }
+
@Override
public String toString() {
return "PIVOT ("
+ PlainSelect.getStringList(functionItems)
+ " FOR " + PlainSelect.
getStringList(forColumns, true, forColumns != null && forColumns.size() > 1)
- + " IN " + PlainSelect.getStringList(getInItems(), true, true) + ")";
+ + " IN " + PlainSelect.getStringList(getInItems(), true, true) + ")"
+ + (alias!=null?alias.toString():"");
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/PivotVisitor.java b/src/main/java/net/sf/jsqlparser/statement/select/PivotVisitor.java
index 656a50e3..e348aa9d 100755
--- a/src/main/java/net/sf/jsqlparser/statement/select/PivotVisitor.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/PivotVisitor.java
@@ -1,22 +1,10 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2013 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- *