clazz) {
- SimpleNode parent = (SimpleNode) node.jjtGetParent();
+ Node parent = (Node) node.jjtGetParent();
while (parent.jjtGetValue() == null || !clazz.isInstance(parent.jjtGetValue())) {
- parent = (SimpleNode) parent.jjtGetParent();
+ parent = (Node) parent.jjtGetParent();
}
return clazz.cast(parent.jjtGetValue());
diff --git a/src/main/java/net/sf/jsqlparser/parser/AbstractJSqlParser.java b/src/main/java/net/sf/jsqlparser/parser/AbstractJSqlParser.java
index a39ac7e32..45580cb5e 100644
--- a/src/main/java/net/sf/jsqlparser/parser/AbstractJSqlParser.java
+++ b/src/main/java/net/sf/jsqlparser/parser/AbstractJSqlParser.java
@@ -21,6 +21,10 @@ public abstract class AbstractJSqlParser {
protected boolean errorRecovery = false;
protected List parseErrors = new ArrayList<>();
+ public enum Dialect {
+ ORACLE, EXASOL
+ }
+
public P withSquareBracketQuotation() {
return withFeature(Feature.allowSquareBracketQuotation, true);
}
@@ -57,6 +61,14 @@ public P withTimeOut(long timeOutMillSeconds) {
return withFeature(Feature.timeOut, timeOutMillSeconds);
}
+ public P withDialect(Dialect dialect) {
+ return withFeature(Feature.dialect, dialect.name());
+ }
+
+ public P withAllowedNestingDepth(int allowedNestingDepth) {
+ return withFeature(Feature.allowedNestingDepth, allowedNestingDepth);
+ }
+
public P withBackslashEscapeCharacter() {
return withFeature(Feature.allowBackslashEscapeCharacter, true);
}
@@ -83,8 +95,21 @@ public P withFeature(Feature f, long value) {
return me();
}
+ public P withFeature(Feature f, String value) {
+ getConfiguration().setValue(f, value);
+ return me();
+ }
+
public abstract FeatureConfiguration getConfiguration();
+ public FeatureConfiguration setValue(Feature feature, Object value) {
+ return getConfiguration().setValue(feature, value);
+ }
+
+ public Object getValue(Feature feature) {
+ return getConfiguration().getValue(feature);
+ }
+
public abstract P me();
public boolean getAsBoolean(Feature f) {
@@ -95,6 +120,18 @@ public Long getAsLong(Feature f) {
return getConfiguration().getAsLong(f);
}
+ public int getAsInt(Feature f) {
+ return getConfiguration().getAsInt(f);
+ }
+
+ public Integer getAsInteger(Feature f) {
+ return getConfiguration().getAsInteger(f);
+ }
+
+ public String getAsString(Feature f) {
+ return getConfiguration().getAsString(f);
+ }
+
public void setErrorRecovery(boolean errorRecovery) {
this.errorRecovery = errorRecovery;
}
diff --git a/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserUtil.java b/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserUtil.java
index 50d583194..bdb25eeb4 100644
--- a/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserUtil.java
+++ b/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserUtil.java
@@ -40,7 +40,6 @@
@SuppressWarnings("PMD.CyclomaticComplexity")
public final class CCJSqlParserUtil {
public final static Logger LOGGER = Logger.getLogger(CCJSqlParserUtil.class.getName());
- public final static int ALLOWED_NESTING_DEPTH = 10;
static {
LOGGER.setLevel(Level.OFF);
@@ -50,7 +49,7 @@ private CCJSqlParserUtil() {}
public static Statement parse(Reader statementReader) throws JSQLParserException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
- Statement statement = null;
+ Statement statement;
CCJSqlParser parser = new CCJSqlParser(new StreamProvider(statementReader));
try {
statement = parseStatement(parser, executorService);
@@ -86,7 +85,7 @@ public static Statement parse(String sql, Consumer consumer)
}
ExecutorService executorService = Executors.newSingleThreadExecutor();
- Statement statement = null;
+ Statement statement;
try {
statement = parse(sql, executorService, consumer);
} finally {
@@ -102,20 +101,22 @@ public static Statement parse(String sql, ExecutorService executorService,
return null;
}
- Statement statement = null;
+ Statement statement;
// first, try to parse fast and simple
CCJSqlParser parser = newParser(sql);
if (consumer != null) {
consumer.accept(parser);
}
- boolean allowComplex = parser.getConfiguration().getAsBoolean(Feature.allowComplexParsing);
+ boolean allowComplex = parser.getAsBoolean(Feature.allowComplexParsing);
+ int allowedNestingDepth = parser.getAsInt(Feature.allowedNestingDepth);
LOGGER.info("Allowed Complex Parsing: " + allowComplex);
try {
LOGGER.info("Trying SIMPLE parsing " + (allowComplex ? "first" : "only"));
statement = parseStatement(parser.withAllowComplexParsing(false), executorService);
} catch (JSQLParserException ex) {
LOGGER.info("Nesting Depth" + getNestingDepth(sql));
- if (allowComplex && getNestingDepth(sql) <= ALLOWED_NESTING_DEPTH) {
+ if (allowComplex
+ && (allowedNestingDepth < 0 || getNestingDepth(sql) <= allowedNestingDepth)) {
LOGGER.info("Trying COMPLEX parsing when SIMPLE parsing failed");
// beware: the parser must not be reused, but needs to be re-initiated
parser = newParser(sql);
@@ -222,23 +223,21 @@ public static Expression parseExpression(String expressionStr, boolean allowPart
} catch (JSQLParserException ex1) {
// when fast simple parsing fails, try complex parsing but only if it has a chance to
// succeed
- if (getNestingDepth(expressionStr) <= ALLOWED_NESTING_DEPTH) {
- CCJSqlParser parser = newParser(expressionStr).withAllowComplexParsing(true);
- if (consumer != null) {
- consumer.accept(parser);
- }
- try {
- expression = parser.Expression();
- if (!allowPartialParse
- && parser.getNextToken().kind != CCJSqlParserTokenManager.EOF) {
- throw new JSQLParserException(
- "could only parse partial expression " + expression.toString());
- }
- } catch (JSQLParserException ex) {
- throw ex;
- } catch (ParseException ex) {
- throw new JSQLParserException(ex);
+ CCJSqlParser parser = newParser(expressionStr).withAllowComplexParsing(true);
+ if (consumer != null) {
+ consumer.accept(parser);
+ }
+ try {
+ expression = parser.Expression();
+ if (!allowPartialParse
+ && parser.getNextToken().kind != CCJSqlParserTokenManager.EOF) {
+ throw new JSQLParserException(
+ "could only parse partial expression " + expression.toString());
}
+ } catch (JSQLParserException ex) {
+ throw ex;
+ } catch (ParseException ex) {
+ throw new JSQLParserException(ex);
}
}
return expression;
@@ -301,24 +300,22 @@ public static Expression parseCondExpression(String conditionalExpressionStr,
throw new JSQLParserException(ex);
}
} catch (JSQLParserException ex1) {
- if (getNestingDepth(conditionalExpressionStr) <= ALLOWED_NESTING_DEPTH) {
- CCJSqlParser parser =
- newParser(conditionalExpressionStr).withAllowComplexParsing(true);
- if (consumer != null) {
- consumer.accept(parser);
- }
- try {
- expression = parser.Expression();
- if (!allowPartialParse
- && parser.getNextToken().kind != CCJSqlParserTokenManager.EOF) {
- throw new JSQLParserException(
- "could only parse partial expression " + expression.toString());
- }
- } catch (JSQLParserException ex) {
- throw ex;
- } catch (ParseException ex) {
- throw new JSQLParserException(ex);
+ CCJSqlParser parser =
+ newParser(conditionalExpressionStr).withAllowComplexParsing(true);
+ if (consumer != null) {
+ consumer.accept(parser);
+ }
+ try {
+ expression = parser.Expression();
+ if (!allowPartialParse
+ && parser.getNextToken().kind != CCJSqlParserTokenManager.EOF) {
+ throw new JSQLParserException(
+ "could only parse partial expression " + expression.toString());
}
+ } catch (JSQLParserException ex) {
+ throw ex;
+ } catch (ParseException ex) {
+ throw new JSQLParserException(ex);
}
}
return expression;
@@ -334,7 +331,7 @@ public static Expression parseCondExpression(String conditionalExpressionStr,
public static Statement parseStatement(CCJSqlParser parser, ExecutorService executorService)
throws JSQLParserException {
- Statement statement = null;
+ Statement statement;
Future future = executorService.submit(new Callable() {
@Override
public Statement call() throws ParseException {
@@ -342,7 +339,7 @@ public Statement call() throws ParseException {
}
});
try {
- statement = future.get(parser.getConfiguration().getAsLong(Feature.timeOut),
+ statement = future.get(parser.getAsLong(Feature.timeOut),
TimeUnit.MILLISECONDS);
} catch (TimeoutException ex) {
parser.interrupted = true;
@@ -397,7 +394,8 @@ public static Statements parseStatements(String sqls, ExecutorService executorSe
if (consumer != null) {
consumer.accept(parser);
}
- boolean allowComplex = parser.getConfiguration().getAsBoolean(Feature.allowComplexParsing);
+ boolean allowComplex = parser.getAsBoolean(Feature.allowComplexParsing);
+ int allowedNestingDepth = parser.getAsInt(Feature.allowedNestingDepth);
// first, try to parse fast and simple
try {
@@ -405,7 +403,8 @@ public static Statements parseStatements(String sqls, ExecutorService executorSe
} catch (JSQLParserException ex) {
// when fast simple parsing fails, try complex parsing but only if it has a chance to
// succeed
- if (allowComplex && getNestingDepth(sqls) <= ALLOWED_NESTING_DEPTH) {
+ if (allowComplex
+ && (allowedNestingDepth < 0 || getNestingDepth(sqls) <= allowedNestingDepth)) {
// beware: parser must not be re-used but needs to be re-initiated
parser = newParser(sqls);
if (consumer != null) {
@@ -434,7 +433,7 @@ public Statements call() throws ParseException {
}
});
try {
- statements = future.get(parser.getConfiguration().getAsLong(Feature.timeOut),
+ statements = future.get(parser.getAsLong(Feature.timeOut),
TimeUnit.MILLISECONDS);
} catch (TimeoutException ex) {
parser.interrupted = true;
@@ -450,17 +449,14 @@ public static void streamStatements(StatementListener listener, InputStream is,
throws JSQLParserException {
try {
CCJSqlParser parser = newParser(is, encoding);
- while (true) {
+ do {
Statement stmt = parser.SingleStatement();
listener.accept(stmt);
if (parser.getToken(1).kind == CCJSqlParserTokenManager.ST_SEMICOLON) {
parser.getNextToken();
}
- if (parser.getToken(1).kind == CCJSqlParserTokenManager.EOF) {
- break;
- }
- }
+ } while (parser.getToken(1).kind != CCJSqlParserTokenManager.EOF);
} catch (Exception ex) {
throw new JSQLParserException(ex);
}
diff --git a/src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java b/src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java
index 6e6019a64..bfaa4a647 100644
--- a/src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java
+++ b/src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java
@@ -56,6 +56,7 @@ public class ParserKeywordsUtils {
{"CHECK", RESTRICTED_SQL2016},
{"CONNECT", RESTRICTED_ALIAS},
{"CONNECT_BY_ROOT", RESTRICTED_JSQLPARSER},
+ {"CSV", RESTRICTED_JSQLPARSER},
{"PRIOR", RESTRICTED_JSQLPARSER},
{"CONSTRAINT", RESTRICTED_SQL2016},
{"CREATE", RESTRICTED_ALIAS},
@@ -63,14 +64,18 @@ public class ParserKeywordsUtils {
{"CURRENT", RESTRICTED_JSQLPARSER},
{"DEFAULT", RESTRICTED_ALIAS},
{"DISTINCT", RESTRICTED_SQL2016},
+ {"DISTINCTROW", RESTRICTED_SQL2016},
{"DOUBLE", RESTRICTED_ALIAS},
{"ELSE", RESTRICTED_JSQLPARSER},
+ {"ERRORS", RESTRICTED_JSQLPARSER},
{"EXCEPT", RESTRICTED_SQL2016},
{"EXCLUDES", RESTRICTED_JSQLPARSER},
{"EXISTS", RESTRICTED_SQL2016},
{"EXTEND", RESTRICTED_JSQLPARSER},
{"FALSE", RESTRICTED_SQL2016},
+ {"FBV", RESTRICTED_JSQLPARSER},
{"FETCH", RESTRICTED_SQL2016},
+ {"FILE", RESTRICTED_JSQLPARSER},
{"FINAL", RESTRICTED_JSQLPARSER},
{"FOR", RESTRICTED_SQL2016},
{"FORCE", RESTRICTED_SQL2016},
@@ -86,6 +91,7 @@ public class ParserKeywordsUtils {
{"IIF", RESTRICTED_ALIAS},
{"IGNORE", RESTRICTED_ALIAS},
{"ILIKE", RESTRICTED_SQL2016},
+ {"IMPORT", RESTRICTED_JSQLPARSER},
{"IN", RESTRICTED_SQL2016},
{"INCLUDES", RESTRICTED_JSQLPARSER},
{"INNER", RESTRICTED_SQL2016},
@@ -121,12 +127,14 @@ public class ParserKeywordsUtils {
{"RETURNING", RESTRICTED_JSQLPARSER},
{"RIGHT", RESTRICTED_SQL2016},
{"SAMPLE", RESTRICTED_ALIAS},
+ {"SCRIPT", RESTRICTED_JSQLPARSER},
{"SEL", RESTRICTED_ALIAS},
{"SELECT", RESTRICTED_ALIAS},
{"SEMI", RESTRICTED_JSQLPARSER},
{"SET", RESTRICTED_JSQLPARSER},
{"SOME", RESTRICTED_JSQLPARSER},
{"START", RESTRICTED_JSQLPARSER},
+ {"STATEMENT", RESTRICTED_JSQLPARSER},
{"TABLES", RESTRICTED_ALIAS},
{"TOP", RESTRICTED_SQL2016},
{"TRAILING", RESTRICTED_SQL2016},
@@ -146,6 +154,7 @@ public class ParserKeywordsUtils {
{"VALUE", RESTRICTED_JSQLPARSER},
{"VALUES", RESTRICTED_SQL2016},
{"VARYING", RESTRICTED_JSQLPARSER},
+ {"VERIFY", RESTRICTED_JSQLPARSER},
{"WHEN", RESTRICTED_SQL2016},
{"WHERE", RESTRICTED_SQL2016},
{"WINDOW", RESTRICTED_SQL2016},
diff --git a/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java b/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java
index b96578e01..c10c568a6 100644
--- a/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java
+++ b/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java
@@ -2,29 +2,30 @@
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2019 JSQLParser
+ * Copyright (C) 2004 - 2025 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
+/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 8.0.0 */
package net.sf.jsqlparser.parser;
-import java.io.IOException;
+/**
+ * An implementation of interface CharStream, where the stream is assumed to contain only ASCII
+ * characters (without unicode processing).
+ */
-@SuppressWarnings({"PMD.MethodNamingConventions", "PMD.CyclomaticComplexity"})
public class SimpleCharStream {
-
/**
* Whether parser is static.
*/
- @SuppressWarnings("checkstyle:constantname")
public static final boolean staticFlag = false;
/**
* Position in buffer.
*/
public int bufpos = -1;
- protected int bufline[];
- protected int bufcolumn[];
+ protected int[] bufline;
+ protected int[] bufcolumn;
protected int column = 0;
protected int line = 1;
protected boolean prevCharIsCR = false;
@@ -40,52 +41,30 @@ public class SimpleCharStream {
int bufsize;
int available;
int tokenBegin;
- private boolean isStringProvider;
/**
- * Constructor
- *
- * @param dstream
- * @param startline
- * @param startcolumn
- * @param buffersize
+ * Constructor.
*/
- public SimpleCharStream(Provider dstream, int startline,
- int startcolumn, int buffersize) {
+ public SimpleCharStream(Provider dstream, int startline, int startcolumn, int buffersize) {
inputStream = dstream;
- isStringProvider = dstream instanceof StringProvider;
line = startline;
column = startcolumn - 1;
- if (isStringProvider) {
- int bs = ((StringProvider) inputStream)._string.length();
- available = bufsize = bs;
- bufline = new int[bs];
- bufcolumn = new int[bs];
- } else {
- available = bufsize = buffersize;
- buffer = new char[buffersize];
- bufline = new int[buffersize];
- bufcolumn = new int[buffersize];
- }
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
}
/**
- * Constructor
- *
- * @param dstream
- * @param startline
- * @param startcolumn
+ * Constructor.
*/
- public SimpleCharStream(Provider dstream, int startline,
- int startcolumn) {
+ public SimpleCharStream(Provider dstream, int startline, int startcolumn) {
this(dstream, startline, startcolumn, 4096);
}
/**
- * Constructor
- *
- * @param dstream
+ * Constructor.
*/
public SimpleCharStream(Provider dstream) {
this(dstream, 1, 1, 4096);
@@ -103,10 +82,10 @@ public final int getAbsoluteTokenBegin() {
return absoluteTokenBegin;
}
- protected void ExpandBuff(boolean wrapAround) throws IOException {
+ protected void ExpandBuff(boolean wrapAround) {
char[] newbuffer = new char[bufsize + 2048];
- int newbufline[] = new int[bufsize + 2048];
- int newbufcolumn[] = new int[bufsize + 2048];
+ int[] newbufline = new int[bufsize + 2048];
+ int[] newbufcolumn = new int[bufsize + 2048];
try {
if (wrapAround) {
@@ -136,16 +115,17 @@ protected void ExpandBuff(boolean wrapAround) throws IOException {
maxNextCharInd = bufpos -= tokenBegin;
}
} catch (Throwable t) {
- throw new IOException("Errow expanding the buffer.", t);
+ throw new Error(t.getMessage());
}
+
bufsize += 2048;
available = bufsize;
tokenBegin = 0;
}
- protected void FillBuff() throws IOException {
- if (!isStringProvider && maxNextCharInd == available) {
+ protected void FillBuff() throws java.io.IOException {
+ if (maxNextCharInd == available) {
if (available == bufsize) {
if (tokenBegin > 2048) {
bufpos = maxNextCharInd = 0;
@@ -166,23 +146,13 @@ protected void FillBuff() throws IOException {
int i;
try {
- if (inputStream instanceof StringProvider) {
- i = ((StringProvider) inputStream)._string.length();
- if (maxNextCharInd == i) {
- throw new IOException();
- }
- maxNextCharInd = i;
+ if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) {
+ inputStream.close();
+ throw new java.io.IOException();
} else {
- if ((i = inputStream.read(buffer, maxNextCharInd,
- available - maxNextCharInd)) == -1) {
- inputStream.close();
- throw new IOException();
- } else {
- maxNextCharInd += i;
- }
+ maxNextCharInd += i;
}
- return;
- } catch (IOException e) {
+ } catch (java.io.IOException e) {
--bufpos;
backup(0);
if (tokenBegin == -1) {
@@ -194,15 +164,14 @@ protected void FillBuff() throws IOException {
/**
* Start.
- *
- * @return the character read
- * @throws IOException
*/
- public char BeginToken() throws IOException {
+ public char BeginToken() throws java.io.IOException {
tokenBegin = -1;
char c = readChar();
tokenBegin = bufpos;
+
absoluteTokenBegin = totalCharsRead;
+
return c;
}
@@ -230,7 +199,7 @@ protected void UpdateLineColumn(char c) {
break;
case '\t':
column--;
- column += tabSize - (column % tabSize);
+ column += tabSize - column % tabSize;
break;
default:
break;
@@ -240,21 +209,10 @@ protected void UpdateLineColumn(char c) {
bufcolumn[bufpos] = column;
}
- private char readChar(int pos) {
- if (this.inputStream instanceof StringProvider) {
- return ((StringProvider) inputStream)._string.charAt(pos);
- } else {
- return buffer[pos];
- }
- }
-
/**
* Read a character.
- *
- * @return the character read
- * @throws IOException
*/
- public char readChar() throws IOException {
+ public char readChar() throws java.io.IOException {
if (inBuf > 0) {
--inBuf;
@@ -263,7 +221,8 @@ public char readChar() throws IOException {
}
totalCharsRead++;
- return readChar(bufpos);
+
+ return buffer[bufpos];
}
if (++bufpos >= maxNextCharInd) {
@@ -272,53 +231,55 @@ public char readChar() throws IOException {
totalCharsRead++;
- char c = readChar(bufpos);
+ char c = buffer[bufpos];
UpdateLineColumn(c);
return c;
}
+ @Deprecated
/**
- * @return the column
- * @deprecated @see #getEndColumn
+ * @deprecated
+ * @see #getEndColumn
*/
- @Deprecated
+
public int getColumn() {
return bufcolumn[bufpos];
}
+ @Deprecated
/**
- * @return the line
- * @deprecated @see #getEndLine
+ * @deprecated
+ * @see #getEndLine
*/
- @Deprecated
+
public int getLine() {
return bufline[bufpos];
}
/**
- * @return get token end column number.
+ * Get token end column number.
*/
public int getEndColumn() {
return bufcolumn[bufpos];
}
/**
- * @return get token end line number.
+ * Get token end line number.
*/
public int getEndLine() {
return bufline[bufpos];
}
/**
- * @return get token beginning column number.
+ * Get token beginning column number.
*/
public int getBeginColumn() {
return bufcolumn[tokenBegin];
}
/**
- * @return get token beginning line number.
+ * Get token beginning line number.
*/
public int getBeginLine() {
return bufline[tokenBegin];
@@ -326,8 +287,6 @@ public int getBeginLine() {
/**
* Backup a number of characters.
- *
- * @param amount
*/
public void backup(int amount) {
@@ -340,30 +299,17 @@ public void backup(int amount) {
/**
* Reinitialise.
- *
- * @param dstream
- * @param startline
- * @param startcolumn
- * @param buffersize
*/
- public void ReInit(Provider dstream, int startline,
- int startcolumn, int buffersize) {
+ public void ReInit(Provider dstream, int startline, int startcolumn, int buffersize) {
inputStream = dstream;
- isStringProvider = dstream instanceof StringProvider;
line = startline;
column = startcolumn - 1;
- if (isStringProvider) {
- int bs = ((StringProvider) inputStream)._string.length();
- available = bufsize = bs;
- bufline = new int[bs];
- bufcolumn = new int[bs];
- } else {
- if (buffer == null || buffersize != buffer.length) {
- available = bufsize = buffersize;
- buffer = new char[buffersize];
- bufline = new int[buffersize];
- bufcolumn = new int[buffersize];
- }
+
+ if (buffer == null || buffersize != buffer.length) {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
}
prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0;
@@ -372,72 +318,42 @@ public void ReInit(Provider dstream, int startline,
/**
* Reinitialise.
- *
- * @param dstream
- * @param startline
- * @param startcolumn
*/
- public void ReInit(Provider dstream, int startline,
- int startcolumn) {
+ public void ReInit(Provider dstream, int startline, int startcolumn) {
ReInit(dstream, startline, startcolumn, 4096);
}
/**
* Reinitialise.
- *
- * @param dstream
*/
public void ReInit(Provider dstream) {
ReInit(dstream, 1, 1, 4096);
}
+
/**
- * @return get token literal value.
+ * Get token literal value.
*/
public String GetImage() {
- if (isStringProvider) {
- String data = ((StringProvider) inputStream)._string;
- if (bufpos >= tokenBegin) {
- return data.substring(tokenBegin, bufpos + 1);
- } else {
- return data.substring(tokenBegin, bufsize)
- + data.substring(0, bufpos + 1);
- }
+ if (bufpos >= tokenBegin) {
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
} else {
- if (bufpos >= tokenBegin) {
- return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
- } else {
- return new String(buffer, tokenBegin, bufsize - tokenBegin)
- + new String(buffer, 0, bufpos + 1);
- }
+ return new String(buffer, tokenBegin, bufsize - tokenBegin)
+ + new String(buffer, 0, bufpos + 1);
}
}
/**
- * @param len
- * @return get the suffix.
+ * Get the suffix.
*/
public char[] GetSuffix(int len) {
-
char[] ret = new char[len];
- if (isStringProvider) {
- String str = ((StringProvider) inputStream)._string;
- if ((bufpos + 1) >= len) {
- str.getChars(bufpos - len + 1, bufpos - len + 1 + len, ret, 0);
- } else {
- str.getChars(bufsize - (len - bufpos - 1),
- bufsize - (len - bufpos - 1) + len - bufpos - 1, ret, 0);
- str.getChars(0, bufpos + 1, ret, len - bufpos - 1);
- }
+ if ((bufpos + 1) >= len) {
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
} else {
- if ((bufpos + 1) >= len) {
- System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
- } else {
- System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
- len - bufpos - 1);
- System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
- }
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
}
return ret;
@@ -454,12 +370,8 @@ public void Done() {
/**
* Method to adjust line and column numbers for the start of a token.
- *
- * @param newLine
- * @param newCol
*/
public void adjustBeginLineColumn(int newLine, int newCol) {
- int nl = newLine;
int start = tokenBegin;
int len;
@@ -471,12 +383,12 @@ public void adjustBeginLineColumn(int newLine, int newCol) {
int i = 0;
int j = 0;
- int k = 0;
- int nextColDiff = 0;
+ int k;
+ int nextColDiff;
int columnDiff = 0;
while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) {
- bufline[j] = nl;
+ bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
@@ -484,14 +396,14 @@ public void adjustBeginLineColumn(int newLine, int newCol) {
}
if (i < len) {
- bufline[j] = nl++;
+ bufline[j] = newLine++;
bufcolumn[j] = newCol + columnDiff;
while (i++ < len) {
if (bufline[j = start % bufsize] != bufline[++start % bufsize]) {
- bufline[j] = nl++;
+ bufline[j] = newLine++;
} else {
- bufline[j] = nl;
+ bufline[j] = newLine;
}
}
}
@@ -508,4 +420,4 @@ void setTrackLineColumn(boolean tlc) {
trackLineColumn = tlc;
}
}
-/* JavaCC - OriginalChecksum=47e65cd0a1ed785f7a51c9e0c60893c9 (do not edit this line) */
+/* JavaCC - OriginalChecksum=0cd74e5ad7a4ccb9188541ab8f8b35eb (do not edit this line) */
diff --git a/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java b/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java
index 75b5c78a5..7f4cf2af0 100644
--- a/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java
+++ b/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java
@@ -792,6 +792,23 @@ public enum Feature {
* allows sub selects without parentheses, e.g. `select * from dual where 1 = select 1`
*/
allowUnparenthesizedSubSelects(false),
+
+ /**
+ * maximum nesting depth for trying complex parsing, can bet set to -1 to ignore
+ */
+ allowedNestingDepth(10),
+
+ dialect(null),
+
+ /**
+ * "IMPORT"
+ */
+ imprt,
+
+ /**
+ * "EXPORT"
+ */
+ export,
;
private final Object value;
diff --git a/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java b/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java
index da5ddd2b0..0106431cc 100644
--- a/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java
+++ b/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java
@@ -19,7 +19,7 @@ public class FeatureConfiguration {
private static final Logger LOG = Logger.getLogger(FeatureConfiguration.class.getName());
- private Map featureEnabled = new EnumMap<>(Feature.class);
+ private final Map featureEnabled = new EnumMap<>(Feature.class);
public FeatureConfiguration() {
// set default-value for all switchable features
@@ -64,6 +64,14 @@ public Long getAsLong(Feature f) {
return Long.valueOf(String.valueOf(getValue(f)));
}
+ public int getAsInt(Feature f) {
+ return Integer.parseInt(String.valueOf(getValue(f)));
+ }
+
+ public Integer getAsInteger(Feature f) {
+ return Integer.parseInt(String.valueOf(getValue(f)));
+ }
+
public String getAsString(Feature f) {
Object value = getValue(f);
return value == null ? null : String.valueOf(value);
diff --git a/src/main/java/net/sf/jsqlparser/schema/Column.java b/src/main/java/net/sf/jsqlparser/schema/Column.java
index 2aa0994cd..400d34c3a 100644
--- a/src/main/java/net/sf/jsqlparser/schema/Column.java
+++ b/src/main/java/net/sf/jsqlparser/schema/Column.java
@@ -29,6 +29,9 @@ public class Column extends ASTNodeAccessImpl implements Expression, MultiPartNa
private ArrayConstructor arrayConstructor;
private String tableDelimiter = ".";
+ // holds the physical table when resolved against an actual schema information
+ private Table resolvedTable = null;
+
public Column() {}
public Column(Table table, String columnName) {
@@ -223,4 +226,26 @@ public String getCommentText() {
public void setCommentText(String commentText) {
this.commentText = commentText;
}
+
+ /**
+ * Gets the actual table when resolved against a physical schema information.
+ *
+ * @return the actual table when resolved against a physical schema information
+ */
+ public Table getResolvedTable() {
+ return resolvedTable;
+ }
+
+ /**
+ * Sets resolved table.
+ *
+ * @param resolvedTable the resolved table
+ * @return this column
+ */
+ public Column setResolvedTable(Table resolvedTable) {
+ // clone, not reference
+ this.resolvedTable =
+ resolvedTable != null ? new Table(resolvedTable.getFullyQualifiedName()) : null;
+ return this;
+ }
}
diff --git a/src/main/java/net/sf/jsqlparser/schema/Table.java b/src/main/java/net/sf/jsqlparser/schema/Table.java
index 066326a88..cd0aa679d 100644
--- a/src/main/java/net/sf/jsqlparser/schema/Table.java
+++ b/src/main/java/net/sf/jsqlparser/schema/Table.java
@@ -10,6 +10,7 @@
package net.sf.jsqlparser.schema;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -17,6 +18,7 @@
import net.sf.jsqlparser.expression.MySQLIndexHint;
import net.sf.jsqlparser.expression.SQLServerHints;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
+import net.sf.jsqlparser.statement.ErrorDestination;
import net.sf.jsqlparser.statement.select.FromItem;
import net.sf.jsqlparser.statement.select.FromItemVisitor;
import net.sf.jsqlparser.statement.select.IntoTableVisitor;
@@ -27,11 +29,9 @@
/**
* A table. It can have an alias and the schema name it belongs to.
*/
-public class Table extends ASTNodeAccessImpl implements FromItem, MultiPartName {
+public class Table extends ASTNodeAccessImpl
+ implements ErrorDestination, FromItem, MultiPartName, Cloneable {
- // private Database database;
- // private String schemaName;
- // private String name;
private static final int NAME_IDX = 0;
private static final int SCHEMA_IDX = 1;
@@ -44,8 +44,14 @@ public class Table extends ASTNodeAccessImpl implements FromItem, MultiPartName
private List partDelimiters = new ArrayList<>();
+ // holds the various `time travel` syntax for BigQuery, RedShift, Snowflake or RedShift
+ private String timeTravelStr = null;
+
private Alias alias;
+ // thank you, Google!
+ private String timeTravelStrAfterAlias = null;
+
private SampleClause sampleClause;
private Pivot pivot;
@@ -56,6 +62,9 @@ public class Table extends ASTNodeAccessImpl implements FromItem, MultiPartName
private SQLServerHints sqlServerHints;
+ // holds the physical table when resolved against an actual schema information
+ private Table resolvedTable = null;
+
public Table() {}
/**
@@ -70,6 +79,10 @@ public Table(String name) {
setName(name);
}
+ public Table(String name, boolean splitNamesOnDelimiter) {
+ setName(name, splitNamesOnDelimiter);
+ }
+
public Table(String schemaName, String name) {
setSchemaName(schemaName);
setName(name);
@@ -193,12 +206,20 @@ public void setName(String name) {
.of("0", "N", "n", "FALSE", "false", "OFF", "off")
.contains(System.getProperty("SPLIT_NAMES_ON_DELIMITER"));
+ setName(name, splitNamesOnDelimiter);
+ }
+
+ public void setName(String name, boolean splitNamesOnDelimiter) {
if (MultiPartName.isQuoted(name) && name.contains(".") && splitNamesOnDelimiter) {
partItems.clear();
for (String unquotedIdentifier : MultiPartName.unquote(name).split("\\.")) {
partItems.add("\"" + unquotedIdentifier + "\"");
}
Collections.reverse(partItems);
+ } else if (name.contains(".") && splitNamesOnDelimiter) {
+ partItems.clear();
+ partItems.addAll(Arrays.asList(MultiPartName.unquote(name).split("\\.")));
+ Collections.reverse(partItems);
} else {
setIndex(NAME_IDX, name);
}
@@ -230,6 +251,15 @@ public void setAlias(Alias alias) {
this.alias = alias;
}
+ public String getTimeTravelStrAfterAlias() {
+ return timeTravelStrAfterAlias;
+ }
+
+ public Table setTimeTravelStrAfterAlias(String timeTravelStrAfterAlias) {
+ this.timeTravelStrAfterAlias = timeTravelStrAfterAlias;
+ return this;
+ }
+
private void setIndex(int idx, String value) {
int size = partItems.size();
for (int i = 0; i < idx - size + 1; i++) {
@@ -290,6 +320,15 @@ public T accept(IntoTableVisitor intoTableVisitor, S context) {
return intoTableVisitor.visit(this, context);
}
+ public String getTimeTravel() {
+ return timeTravelStr;
+ }
+
+ public Table setTimeTravel(String timeTravelStr) {
+ this.timeTravelStr = timeTravelStr;
+ return this;
+ }
+
@Override
public Pivot getPivot() {
return pivot;
@@ -342,10 +381,19 @@ public Table setSampleClause(SampleClause sampleClause) {
public StringBuilder appendTo(StringBuilder builder) {
builder.append(getFullyQualifiedName());
+
+ if (timeTravelStr != null) {
+ builder.append(" ").append(timeTravelStr);
+ }
+
if (alias != null) {
builder.append(alias);
}
+ if (timeTravelStrAfterAlias != null) {
+ builder.append(" ").append(timeTravelStrAfterAlias);
+ }
+
if (sampleClause != null) {
sampleClause.appendTo(builder);
}
@@ -400,4 +448,74 @@ public List getNameParts() {
public List getNamePartDelimiters() {
return partDelimiters;
}
+
+ /**
+ * Gets the actual table when resolved against a physical schema information.
+ *
+ * @return the actual table when resolved against a physical schema information
+ */
+ public Table getResolvedTable() {
+ return resolvedTable;
+ }
+
+ /**
+ * Sets resolved table.
+ *
+ * @param resolvedTable the resolved table
+ * @return this table
+ */
+ public Table setResolvedTable(Table resolvedTable) {
+ // clone, not reference
+ if (resolvedTable != null) {
+ this.resolvedTable = new Table(resolvedTable.getFullyQualifiedName());
+ }
+ return this;
+ }
+
+ /**
+ * Sets a table's catalog and schema only when not set. Useful for setting CURRENT_SCHEMA() and
+ * CURRENT_DATABASE()
+ *
+ * @param currentCatalogName the catalog name
+ * @param currentSchemaName the schema name
+ * @return the provided table
+ */
+ public Table setUnsetCatalogAndSchema(String currentCatalogName, String currentSchemaName) {
+ String databaseName = getDatabaseName();
+ if (databaseName == null || databaseName.isEmpty()) {
+ setDatabaseName(currentCatalogName);
+ }
+
+ String schemaName = getSchemaName();
+ if (schemaName == null || schemaName.isEmpty()) {
+ setSchemaName(currentSchemaName);
+ }
+ return this;
+ }
+
+ /**
+ * Sets a tables' catalog and schema only when not set. Useful for setting CURRENT_SCHEMA() and
+ * CURRENT_DATABASE()
+ *
+ * @param currentCatalogName the current catalog name
+ * @param currentSchemaName the current schema name
+ * @param tables the tables
+ * @return the tables
+ */
+ public static Table[] setUnsetCatalogAndSchema(String currentCatalogName,
+ String currentSchemaName, Table... tables) {
+ for (Table t : tables) {
+ if (t != null) {
+ t.setUnsetCatalogAndSchema(currentCatalogName, currentSchemaName);
+ }
+ }
+ return tables;
+ }
+
+ @Override
+ public Table clone() {
+ Table clone = new Table(this.getFullyQualifiedName());
+ clone.setResolvedTable(this.resolvedTable != null ? this.resolvedTable.clone() : null);
+ return clone;
+ }
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/CSVColumn.java b/src/main/java/net/sf/jsqlparser/statement/CSVColumn.java
new file mode 100644
index 000000000..08c7f4d1d
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/CSVColumn.java
@@ -0,0 +1,91 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.StringValue;
+
+public class CSVColumn {
+ private Long startIndex;
+ private Long endIndex;
+ private StringValue format;
+ private String delimit;
+
+ public CSVColumn(Long startIndex, Long endIndex) {
+ this.startIndex = startIndex;
+ this.endIndex = endIndex;
+ }
+
+ public CSVColumn(Long index) {
+ this(index, null);
+ }
+
+ public Long getStartIndex() {
+ return startIndex;
+ }
+
+ public void setStartIndex(Long startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ public Long getIndex() {
+ return getStartIndex();
+ }
+
+ public void setIndex(Long index) {
+ setStartIndex(index);
+ }
+
+ public Long getEndIndex() {
+ return endIndex;
+ }
+
+ public void setEndIndex(Long endIndex) {
+ this.endIndex = endIndex;
+ }
+
+ public StringValue getFormat() {
+ return format;
+ }
+
+ public void setFormat(StringValue format) {
+ this.format = format;
+ }
+
+ public String getDelimit() {
+ return delimit;
+ }
+
+ public void setDelimit(String delimit) {
+ this.delimit = delimit;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append(startIndex);
+ if (endIndex != null) {
+ sql.append(" .. ");
+ sql.append(endIndex);
+ } else if (format != null || delimit != null) {
+ if (format != null) {
+ sql.append(" FORMAT = ");
+ sql.append(format);
+ }
+
+ if (delimit != null) {
+ sql.append(" DELIMIT = ");
+ sql.append(delimit);
+ }
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/CSVFileDestination.java b/src/main/java/net/sf/jsqlparser/statement/CSVFileDestination.java
new file mode 100644
index 000000000..697368f83
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/CSVFileDestination.java
@@ -0,0 +1,75 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.StringValue;
+
+public class CSVFileDestination implements ErrorDestination {
+ private ConnectionDefinition connectionDefinition;
+ private boolean local;
+ private boolean secure;
+ private StringValue file;
+
+ public ConnectionDefinition getConnectionDefinition() {
+ return connectionDefinition;
+ }
+
+ public void setConnectionDefinition(ConnectionDefinition connectionDefinition) {
+ this.connectionDefinition = connectionDefinition;
+ }
+
+ public boolean isLocal() {
+ return local;
+ }
+
+ public void setLocal(boolean local) {
+ this.local = local;
+ }
+
+ public boolean isSecure() {
+ return secure;
+ }
+
+ public void setSecure(boolean secure) {
+ this.secure = secure;
+ }
+
+ public StringValue getFile() {
+ return file;
+ }
+
+ public void setFile(StringValue file) {
+ this.file = file;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ if (local) {
+ sql.append("LOCAL ");
+ if (secure) {
+ sql.append("SECURE ");
+ }
+ }
+
+ sql.append("CSV");
+
+ if (connectionDefinition != null) {
+ sql.append(" ");
+ sql.append(connectionDefinition);
+ }
+
+ sql.append(" FILE ");
+ sql.append(file);
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/CertificateVerification.java b/src/main/java/net/sf/jsqlparser/statement/CertificateVerification.java
new file mode 100644
index 000000000..7aabbb060
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/CertificateVerification.java
@@ -0,0 +1,67 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2025 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.StringValue;
+
+import java.io.Serializable;
+
+public class CertificateVerification implements Serializable {
+ private Boolean ignoreCertificate;
+ private StringValue publicKey;
+
+ public StringValue getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(StringValue publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public Boolean getIgnoreCertificate() {
+ return ignoreCertificate;
+ }
+
+ public void setIgnoreCertificate(Boolean ignoreCertificate) {
+ this.ignoreCertificate = ignoreCertificate;
+ }
+
+ public Boolean getVerifyCertificate() {
+ return !ignoreCertificate;
+ }
+
+ public void setVerifyCertificate(Boolean verifyCertificate) {
+ this.ignoreCertificate = !verifyCertificate;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ if (ignoreCertificate != null) {
+ if (ignoreCertificate) {
+ sql.append("IGNORE ");
+ } else {
+ sql.append("VERIFY ");
+ }
+ sql.append("CERTIFICATE");
+ }
+
+ if (publicKey != null) {
+ if (ignoreCertificate != null) {
+ sql.append(" ");
+ }
+ sql.append("PUBLIC KEY ");
+ sql.append(publicKey);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/CloudConnectionDefinition.java b/src/main/java/net/sf/jsqlparser/statement/CloudConnectionDefinition.java
new file mode 100644
index 000000000..82b65fbd7
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/CloudConnectionDefinition.java
@@ -0,0 +1,37 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+public class CloudConnectionDefinition extends ConnectionDefinition {
+ private String storage;
+
+ public String getStorage() {
+ return storage;
+ }
+
+ public void setStorage(String storage) {
+ this.storage = storage;
+ }
+
+ @Override
+ public void setCertificateVerification(CertificateVerification certificateVerification) {}
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append("AT CLOUD ");
+ sql.append(storage);
+ sql.append(" ");
+ appendConnectionDefinition(sql);
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ConnectionDefinition.java b/src/main/java/net/sf/jsqlparser/statement/ConnectionDefinition.java
new file mode 100644
index 000000000..f2887cf82
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/ConnectionDefinition.java
@@ -0,0 +1,91 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.StringValue;
+
+import java.io.Serializable;
+
+public class ConnectionDefinition implements Serializable {
+ private String connectionObjectName;
+ private StringValue connectionDefinition;
+ private UserIdentification userIdentification;
+ private CertificateVerification certificateVerification;
+
+ public String getConnectionObjectName() {
+ return connectionObjectName;
+ }
+
+ public void setConnectionObjectName(String connectionObjectName) {
+ this.connectionObjectName = connectionObjectName;
+ }
+
+ public StringValue getConnectionDefinition() {
+ return connectionDefinition;
+ }
+
+ public void setConnectionDefinition(StringValue connectionDefinition) {
+ this.connectionDefinition = connectionDefinition;
+ }
+
+ public void setConnection(String connectionObjectName) {
+ this.connectionObjectName = connectionObjectName;
+ }
+
+ public void setConnection(StringValue connectionDefinition) {
+ this.connectionDefinition = connectionDefinition;
+ }
+
+ public UserIdentification getUserIdentification() {
+ return userIdentification;
+ }
+
+ public void setUserIdentification(UserIdentification userIdentification) {
+ this.userIdentification = userIdentification;
+ }
+
+ public CertificateVerification getCertificateVerification() {
+ return certificateVerification;
+ }
+
+ public void setCertificateVerification(CertificateVerification certificateVerification) {
+ this.certificateVerification = certificateVerification;
+ }
+
+ protected StringBuilder appendConnectionDefinition(StringBuilder sql) {
+ if (connectionObjectName != null) {
+ sql.append(connectionObjectName);
+ } else if (connectionDefinition != null) {
+ sql.append(connectionDefinition);
+ }
+
+ if (userIdentification != null) {
+ sql.append(" ");
+ sql.append(userIdentification);
+ }
+
+ if (certificateVerification != null) {
+ sql.append(" ");
+ sql.append(certificateVerification);
+ }
+
+ return sql;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append("AT ");
+ appendConnectionDefinition(sql);
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ConnectionFileDefinition.java b/src/main/java/net/sf/jsqlparser/statement/ConnectionFileDefinition.java
new file mode 100644
index 000000000..f0e0d0cf1
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/ConnectionFileDefinition.java
@@ -0,0 +1,60 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.StringValue;
+
+import java.util.List;
+
+public class ConnectionFileDefinition {
+ private ConnectionDefinition connectionDefinition;
+ private List filePaths;
+
+ public ConnectionFileDefinition(List filePaths) {
+ this(null, filePaths);
+ }
+
+ public ConnectionFileDefinition(ConnectionDefinition connectionDefinition,
+ List filePaths) {
+ this.connectionDefinition = connectionDefinition;
+ this.filePaths = filePaths;
+ }
+
+ public ConnectionDefinition getConnectionDefinition() {
+ return connectionDefinition;
+ }
+
+ public void setConnectionDefinition(ConnectionDefinition connectionDefinition) {
+ this.connectionDefinition = connectionDefinition;
+ }
+
+ public List getFilePaths() {
+ return filePaths;
+ }
+
+ public void setFilePaths(List filePaths) {
+ this.filePaths = filePaths;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ if (connectionDefinition != null) {
+ sql.append(connectionDefinition);
+ }
+
+ for (StringValue filePath : filePaths) {
+ sql.append(" FILE ").append(filePath);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/DBMSType.java b/src/main/java/net/sf/jsqlparser/statement/DBMSType.java
new file mode 100644
index 000000000..4b3d667da
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/DBMSType.java
@@ -0,0 +1,52 @@
+/*-
+ * #%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.expression.StringValue;
+
+public class DBMSType implements SourceDestinationType {
+ private final Kind dbmsType;
+ private StringValue jdbcDriverDefinition;
+
+ public DBMSType(String dbmsType) {
+ this(dbmsType, null);
+ }
+
+ public DBMSType(String dbmsType, String jdbcDriverDefinition) {
+ this.dbmsType = Kind.valueOf(dbmsType.toUpperCase());
+ if (jdbcDriverDefinition != null) {
+ this.jdbcDriverDefinition = new StringValue(jdbcDriverDefinition);
+ }
+ }
+
+ private enum Kind {
+ EXA, ORA, JDBC
+ }
+
+ public StringValue getJDBCDriverDefinition() {
+ return jdbcDriverDefinition;
+ }
+
+ public void setJDBCDriverDefinition(StringValue jdbcDriverDefinition) {
+ this.jdbcDriverDefinition = jdbcDriverDefinition;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append(dbmsType);
+ if (jdbcDriverDefinition != null) {
+ sql.append(" DRIVER = ").append(jdbcDriverDefinition);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ErrorClause.java b/src/main/java/net/sf/jsqlparser/statement/ErrorClause.java
new file mode 100644
index 000000000..92db1a3dc
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/ErrorClause.java
@@ -0,0 +1,90 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.Expression;
+
+import java.io.Serializable;
+
+public class ErrorClause implements Serializable {
+ private ErrorDestination errorDestination;
+ private Expression expression;
+ private RejectClause rejectClause;
+ private boolean replace;
+ private boolean truncate;
+
+ public ErrorDestination getErrorDestination() {
+ return errorDestination;
+ }
+
+ public void setErrorDestination(ErrorDestination errorDestination) {
+ this.errorDestination = errorDestination;
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+ public RejectClause getRejectClause() {
+ return rejectClause;
+ }
+
+ public void setRejectClause(RejectClause rejectClause) {
+ this.rejectClause = rejectClause;
+ }
+
+ public boolean isReplace() {
+ return replace;
+ }
+
+ public void setReplace(boolean replace) {
+ this.replace = replace;
+ }
+
+ public boolean isTruncate() {
+ return truncate;
+ }
+
+ public void setTruncate(boolean truncate) {
+ this.truncate = truncate;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ if (errorDestination != null) {
+ sql.append("ERRORS INTO ");
+ sql.append(errorDestination);
+ if (expression != null) {
+ sql.append(" (");
+ sql.append(expression);
+ sql.append(")");
+ }
+
+ if (replace) {
+ sql.append(" REPLACE");
+ } else if (truncate) {
+ sql.append(" TRUNCATE");
+ }
+ }
+
+ if (rejectClause != null) {
+ sql.append(" ");
+ sql.append(rejectClause);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ErrorDestination.java b/src/main/java/net/sf/jsqlparser/statement/ErrorDestination.java
new file mode 100644
index 000000000..258a39ebb
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/ErrorDestination.java
@@ -0,0 +1,13 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+public interface ErrorDestination {
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/FBVColumn.java b/src/main/java/net/sf/jsqlparser/statement/FBVColumn.java
new file mode 100644
index 000000000..a1846efd9
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/FBVColumn.java
@@ -0,0 +1,98 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.LongValue;
+import net.sf.jsqlparser.expression.StringValue;
+
+public class FBVColumn {
+ private boolean precedesComma;
+ private String key;
+ private Expression value;
+ private String stringValue;
+
+ private FBVColumn(String key, Expression value) {
+ this.key = key;
+ this.value = value;
+ this.stringValue = null;
+ }
+
+ public FBVColumn(String key, String value) {
+ this.key = key;
+ this.value = null;
+ this.stringValue = value;
+ }
+
+ public FBVColumn(String key, StringValue value) {
+ this(key, (Expression) value);
+ }
+
+ public FBVColumn(String key, LongValue value) {
+ this(key, (Expression) value);
+ }
+
+ public boolean precedesComma() {
+ return precedesComma;
+ }
+
+ public void setPrecedesComma(boolean precedesComma) {
+ this.precedesComma = precedesComma;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public Expression getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.stringValue = value;
+ this.value = null;
+ }
+
+ private void setValue(Expression value) {
+ this.value = value;
+ this.stringValue = null;
+ }
+
+ public void setValue(StringValue value) {
+ setValue((Expression) value);
+ }
+
+ public void setValue(LongValue value) {
+ setValue((Expression) value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ if (precedesComma) {
+ sql.append(", ");
+ }
+
+ sql.append(key);
+ sql.append(" = ");
+ if (stringValue != null) {
+ sql.append(stringValue);
+ } else {
+ sql.append(value);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/FileOption.java b/src/main/java/net/sf/jsqlparser/statement/FileOption.java
new file mode 100644
index 000000000..ff91f571b
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/FileOption.java
@@ -0,0 +1,85 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.LongValue;
+import net.sf.jsqlparser.expression.StringValue;
+
+public class FileOption {
+ private String key;
+ private Expression value;
+ private String stringValue;
+
+ private FileOption(String key, Expression value) {
+ this.key = key;
+ this.value = value;
+ this.stringValue = null;
+ }
+
+ public FileOption(String key, String value) {
+ this.key = key;
+ this.value = null;
+ this.stringValue = value;
+ }
+
+ public FileOption(String key) {
+ this(key, (Expression) null);
+ }
+
+ public FileOption(String key, StringValue value) {
+ this(key, (Expression) value);
+ }
+
+ public FileOption(String key, LongValue value) {
+ this(key, (Expression) value);
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public Expression getValue() {
+ return value;
+ }
+
+ public void setValue(StringValue value) {
+ this.value = value;
+ }
+
+ public void setValue(LongValue value) {
+ this.value = value;
+ }
+
+ public void setValue(String value) {
+ this.stringValue = value;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append(key);
+ if (value != null || stringValue != null) {
+ sql.append(" = ");
+ if (stringValue != null) {
+ sql.append(stringValue);
+ } else {
+ sql.append(value);
+ }
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/FileSourceDestination.java b/src/main/java/net/sf/jsqlparser/statement/FileSourceDestination.java
new file mode 100644
index 000000000..d5a79ed8f
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/FileSourceDestination.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;
+
+import net.sf.jsqlparser.statement.select.PlainSelect;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+public abstract class FileSourceDestination implements Serializable {
+ private SourceDestinationType type;
+ private List connectionFileDefinitions;
+ private Boolean local;
+ private Boolean secure;
+ private List csvColumns;
+ private List fbvColumns;
+ private List fileOptions;
+ private CertificateVerification certificateVerification;
+
+ protected SourceDestinationType getType() {
+ return type;
+ }
+
+ protected void setType(SourceDestinationType type) {
+ this.type = type;
+ }
+
+ public List getConnectionFileDefinitions() {
+ return connectionFileDefinitions;
+ }
+
+ public void setConnectionFileDefinitions(
+ List connectionFileDefinitions) {
+ this.connectionFileDefinitions = connectionFileDefinitions;
+ }
+
+ public Boolean isLocal() {
+ return local;
+ }
+
+ public void setLocal(Boolean local) {
+ this.local = local;
+ }
+
+ public Boolean isSecure() {
+ return secure;
+ }
+
+ public void setSecure(Boolean secure) {
+ this.secure = secure;
+ }
+
+ public List getCSVColumns() {
+ return csvColumns;
+ }
+
+ public void setCSVColumns(List csvColumns) {
+ this.csvColumns = csvColumns;
+ }
+
+ public List getFBVColumns() {
+ return fbvColumns;
+ }
+
+ public void setFBVColumns(List fbvColumns) {
+ this.fbvColumns = fbvColumns;
+ }
+
+ public List getFileOptions() {
+ return fileOptions;
+ }
+
+ public void setFileOptions(List fileOptions) {
+ this.fileOptions = fileOptions;
+ }
+
+ public CertificateVerification getCertificateVerification() {
+ return certificateVerification;
+ }
+
+ public void setCertificateVerification(CertificateVerification certificateVerification) {
+ this.certificateVerification = certificateVerification;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ if (local != null) {
+ if (local) {
+ sql.append("LOCAL ");
+ }
+
+ if (Objects.requireNonNullElse(secure, false)) {
+ sql.append("SECURE ");
+ }
+ }
+
+ sql.append(type);
+ if (connectionFileDefinitions != null) {
+ sql.append(" ");
+ PlainSelect.appendStringListTo(sql, connectionFileDefinitions, false, false);
+ }
+
+ if (csvColumns != null) {
+ sql.append(" ");
+ PlainSelect.appendStringListTo(sql, csvColumns, true, true);
+ } else if (fbvColumns != null) {
+ sql.append(" ");
+ PlainSelect.appendStringListTo(sql, fbvColumns, false, true);
+ }
+
+ if (fileOptions != null) {
+ sql.append(" ");
+ PlainSelect.appendStringListTo(sql, fileOptions, false, false);
+ }
+
+ if (certificateVerification != null) {
+ sql.append(" ");
+ sql.append(certificateVerification);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/FileType.java b/src/main/java/net/sf/jsqlparser/statement/FileType.java
new file mode 100644
index 000000000..7ea1535f9
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/FileType.java
@@ -0,0 +1,27 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2025 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+public class FileType implements SourceDestinationType {
+ private final Kind fileType;
+
+ public FileType(String fileType) {
+ this.fileType = Kind.valueOf(fileType.toUpperCase());
+ }
+
+ private enum Kind {
+ CSV, FBV
+ }
+
+ @Override
+ public String toString() {
+ return fileType.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/LikeClause.java b/src/main/java/net/sf/jsqlparser/statement/LikeClause.java
new file mode 100644
index 000000000..448b4de72
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/LikeClause.java
@@ -0,0 +1,142 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.schema.Column;
+import net.sf.jsqlparser.schema.Table;
+import net.sf.jsqlparser.statement.imprt.ImportColumn;
+import net.sf.jsqlparser.statement.select.PlainSelect;
+import net.sf.jsqlparser.statement.select.SelectItem;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Exasol Like Clause
+ *
+ * @see Like Clause in CREATE
+ * TABLE
+ * @see Like Clause in IMPORT
+ */
+public class LikeClause implements ImportColumn, Serializable {
+ private Table table;
+ private List> columnsList;
+
+ private Boolean includingDefaults;
+ private Boolean includingIdentity;
+ private Boolean includingComments;
+
+ public Table getTable() {
+ return table;
+ }
+
+ public void setTable(Table table) {
+ this.table = table;
+ }
+
+ public List> getColumnsList() {
+ return columnsList;
+ }
+
+ public void setColumnsList(List> columnsList) {
+ this.columnsList = columnsList;
+ }
+
+ public Boolean isIncludingDefaults() {
+ return includingDefaults;
+ }
+
+ public void setIncludingDefaults(Boolean includingDefaults) {
+ this.includingDefaults = includingDefaults;
+ }
+
+ public Boolean isExcludingDefaults() {
+ return includingDefaults == null ? null : !includingDefaults;
+ }
+
+ public void setExcludingDefaults(Boolean excludingDefaults) {
+ this.includingDefaults = !excludingDefaults;
+ }
+
+ public Boolean isIncludingIdentity() {
+ return includingIdentity;
+ }
+
+ public void setIncludingIdentity(Boolean includingIdentity) {
+ this.includingIdentity = includingIdentity;
+ }
+
+ public Boolean isExcludingIdentity() {
+ return includingIdentity == null ? null : !includingIdentity;
+ }
+
+ public void setExcludingIdentity(Boolean excludingIdentity) {
+ this.includingIdentity = !excludingIdentity;
+ }
+
+ public Boolean isIncludingComments() {
+ return includingComments;
+ }
+
+ public void setIncludingComments(Boolean includingComments) {
+ this.includingComments = includingComments;
+ }
+
+ public Boolean isExcludingComments() {
+ return includingComments == null ? null : !includingComments;
+ }
+
+ public void setExcludingComments(Boolean excludingComments) {
+ this.includingComments = !excludingComments;
+ }
+
+ public StringBuilder appendTo(StringBuilder builder) {
+ builder.append(" LIKE ");
+ builder.append(table);
+ if (columnsList != null) {
+ builder.append(" ");
+ PlainSelect.appendStringListTo(builder, columnsList, true, true);
+ }
+
+ if (includingDefaults != null) {
+ if (includingDefaults) {
+ builder.append(" INCLUDING ");
+ } else {
+ builder.append(" EXCLUDING ");
+ }
+ builder.append(" DEFAULTS ");
+ }
+
+ if (includingIdentity != null) {
+ if (includingIdentity) {
+ builder.append(" INCLUDING ");
+ } else {
+ builder.append(" EXCLUDING ");
+ }
+ builder.append(" IDENTITY ");
+ }
+
+ if (includingComments != null) {
+ if (includingComments) {
+ builder.append(" INCLUDING ");
+ } else {
+ builder.append(" EXCLUDING ");
+ }
+ builder.append(" COMMENTS ");
+ }
+
+ return builder;
+ }
+
+ @Override
+ public String toString() {
+ return appendTo(new StringBuilder()).toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/RejectClause.java b/src/main/java/net/sf/jsqlparser/statement/RejectClause.java
new file mode 100644
index 000000000..5ca9f9714
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/RejectClause.java
@@ -0,0 +1,53 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.LongValue;
+
+import java.io.Serializable;
+
+public class RejectClause implements Serializable {
+ private LongValue limit;
+ private boolean errors;
+
+ public LongValue getLimit() {
+ return limit;
+ }
+
+ public void setLimit(LongValue limit) {
+ this.limit = limit;
+ }
+
+ public boolean isErrors() {
+ return errors;
+ }
+
+ public void setErrors(boolean errors) {
+ this.errors = errors;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append("REJECT LIMIT ");
+ if (limit != null) {
+ sql.append(limit);
+ } else {
+ sql.append("UNLIMITED");
+ }
+
+ if (errors) {
+ sql.append(" ERRORS");
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ScriptSourceDestination.java b/src/main/java/net/sf/jsqlparser/statement/ScriptSourceDestination.java
new file mode 100644
index 000000000..c1193b037
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/ScriptSourceDestination.java
@@ -0,0 +1,99 @@
+/*-
+ * #%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.expression.StringValue;
+import net.sf.jsqlparser.schema.Table;
+import net.sf.jsqlparser.statement.export.ExportIntoItem;
+import net.sf.jsqlparser.statement.imprt.ImportFromItem;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class ScriptSourceDestination implements ImportFromItem, ExportIntoItem, Serializable {
+ private Table script;
+ private ConnectionDefinition connectionDefinition;
+ private List properties;
+ private List values;
+ private ErrorClause errorClause;
+
+ public Table getScript() {
+ return script;
+ }
+
+ public void setScript(Table script) {
+ this.script = script;
+ }
+
+ public ConnectionDefinition getConnectionDefinition() {
+ return connectionDefinition;
+ }
+
+ public void setConnectionDefinition(ConnectionDefinition connectionDefinition) {
+ this.connectionDefinition = connectionDefinition;
+ }
+
+ public List getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List properties) {
+ this.properties = properties;
+ }
+
+ public List getValues() {
+ return values;
+ }
+
+ public void setValues(List values) {
+ this.values = values;
+ }
+
+ @Override
+ public ErrorClause getErrorClause() {
+ return errorClause;
+ }
+
+ @Override
+ public void setErrorClause(ErrorClause errorClause) {
+ this.errorClause = errorClause;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append("SCRIPT ");
+ sql.append(script);
+
+ if (connectionDefinition != null) {
+ sql.append(" ");
+ sql.append(connectionDefinition);
+ }
+
+ if (properties != null && values != null) {
+ sql.append(" WITH");
+
+ int max = Math.min(properties.size(), values.size());
+ for (int i = 0; i < max; i++) {
+ sql.append(" ");
+ sql.append(properties.get(i));
+ sql.append(" = ");
+ sql.append(values.get(i));
+ }
+ }
+
+ if (errorClause != null) {
+ sql.append(errorClause);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/SessionStatement.java b/src/main/java/net/sf/jsqlparser/statement/SessionStatement.java
new file mode 100644
index 000000000..873c18245
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/SessionStatement.java
@@ -0,0 +1,60 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2025 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+public class SessionStatement implements Statement {
+ public enum Action {
+ START, APPLY, DROP, SHOW, DESCRIBE;
+
+ public static Action from(String flag) {
+ return Enum.valueOf(Action.class, flag.toUpperCase());
+ }
+ }
+
+ final private Action action;
+ final private String id;
+
+ public SessionStatement(Action action, String id) {
+ this.action = action;
+ this.id = id;
+ }
+
+ public SessionStatement(String action, String id) {
+ this(Action.from(action), id);
+ }
+
+ public SessionStatement(String action) {
+ this(action, null);
+ }
+
+
+ public Action getAction() {
+ return action;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public T accept(StatementVisitor statementVisitor, S context) {
+ return statementVisitor.visit(this, context);
+ }
+
+ @Override
+ public void accept(StatementVisitor> statementVisitor) {
+ Statement.super.accept(statementVisitor);
+ }
+
+ @Override
+ public String toString() {
+ return "SESSION " + action + " " + (id != null ? id : "") + ";";
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/SourceDestinationType.java b/src/main/java/net/sf/jsqlparser/statement/SourceDestinationType.java
new file mode 100644
index 000000000..743d21378
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/SourceDestinationType.java
@@ -0,0 +1,13 @@
+/*-
+ * #%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 interface SourceDestinationType {
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/StatementVisitor.java b/src/main/java/net/sf/jsqlparser/statement/StatementVisitor.java
index e8be0a5cb..0068e0cf6 100644
--- a/src/main/java/net/sf/jsqlparser/statement/StatementVisitor.java
+++ b/src/main/java/net/sf/jsqlparser/statement/StatementVisitor.java
@@ -27,7 +27,9 @@
import net.sf.jsqlparser.statement.delete.ParenthesedDelete;
import net.sf.jsqlparser.statement.drop.Drop;
import net.sf.jsqlparser.statement.execute.Execute;
+import net.sf.jsqlparser.statement.export.Export;
import net.sf.jsqlparser.statement.grant.Grant;
+import net.sf.jsqlparser.statement.imprt.Import;
import net.sf.jsqlparser.statement.insert.Insert;
import net.sf.jsqlparser.statement.insert.ParenthesedInsert;
import net.sf.jsqlparser.statement.merge.Merge;
@@ -323,4 +325,22 @@ default void visit(ParenthesedUpdate parenthesedUpdate) {
default void visit(ParenthesedDelete parenthesedDelete) {
this.visit(parenthesedDelete, null);
}
+
+ T visit(SessionStatement sessionStatement, S context);
+
+ default void visit(SessionStatement sessionStatement) {
+ this.visit(sessionStatement, null);
+ }
+
+ T visit(Import imprt, S context);
+
+ default void visit(Import imprt) {
+ this.visit(imprt, null);
+ }
+
+ T visit(Export export, S context);
+
+ default void visit(Export export) {
+ this.visit(export, null);
+ }
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/StatementVisitorAdapter.java b/src/main/java/net/sf/jsqlparser/statement/StatementVisitorAdapter.java
index 0e6ab8698..012abff28 100644
--- a/src/main/java/net/sf/jsqlparser/statement/StatementVisitorAdapter.java
+++ b/src/main/java/net/sf/jsqlparser/statement/StatementVisitorAdapter.java
@@ -9,6 +9,10 @@
*/
package net.sf.jsqlparser.statement;
+import net.sf.jsqlparser.expression.ExpressionVisitor;
+import net.sf.jsqlparser.expression.ExpressionVisitorAdapter;
+import net.sf.jsqlparser.schema.Column;
+import net.sf.jsqlparser.schema.Partition;
import net.sf.jsqlparser.statement.alter.Alter;
import net.sf.jsqlparser.statement.alter.AlterSession;
import net.sf.jsqlparser.statement.alter.AlterSystemStatement;
@@ -27,12 +31,26 @@
import net.sf.jsqlparser.statement.delete.ParenthesedDelete;
import net.sf.jsqlparser.statement.drop.Drop;
import net.sf.jsqlparser.statement.execute.Execute;
+import net.sf.jsqlparser.statement.export.Export;
import net.sf.jsqlparser.statement.grant.Grant;
+import net.sf.jsqlparser.statement.imprt.Import;
import net.sf.jsqlparser.statement.insert.Insert;
+import net.sf.jsqlparser.statement.insert.InsertConflictAction;
import net.sf.jsqlparser.statement.insert.ParenthesedInsert;
import net.sf.jsqlparser.statement.merge.Merge;
+import net.sf.jsqlparser.statement.merge.MergeOperationVisitor;
+import net.sf.jsqlparser.statement.merge.MergeOperationVisitorAdapter;
import net.sf.jsqlparser.statement.refresh.RefreshMaterializedViewStatement;
+import net.sf.jsqlparser.statement.select.FromItemVisitor;
+import net.sf.jsqlparser.statement.select.FromItemVisitorAdapter;
+import net.sf.jsqlparser.statement.select.PivotVisitor;
+import net.sf.jsqlparser.statement.select.PivotVisitorAdapter;
import net.sf.jsqlparser.statement.select.Select;
+import net.sf.jsqlparser.statement.select.SelectItemVisitor;
+import net.sf.jsqlparser.statement.select.SelectItemVisitorAdapter;
+import net.sf.jsqlparser.statement.select.SelectVisitor;
+import net.sf.jsqlparser.statement.select.SelectVisitorAdapter;
+import net.sf.jsqlparser.statement.select.WithItem;
import net.sf.jsqlparser.statement.show.ShowIndexStatement;
import net.sf.jsqlparser.statement.show.ShowTablesStatement;
import net.sf.jsqlparser.statement.truncate.Truncate;
@@ -40,8 +58,48 @@
import net.sf.jsqlparser.statement.update.Update;
import net.sf.jsqlparser.statement.upsert.Upsert;
+import java.util.List;
+
@SuppressWarnings({"PMD.UncommentedEmptyMethodBody"})
public class StatementVisitorAdapter implements StatementVisitor {
+ private final ExpressionVisitor expressionVisitor;
+ private final PivotVisitor pivotVisitor;
+ private final SelectItemVisitor selectItemVisitor;
+ private final FromItemVisitor fromItemVisitor;
+ private final SelectVisitor selectVisitor;
+ private final MergeOperationVisitor mergeOperationVisitor;
+
+ public StatementVisitorAdapter() {
+ this.expressionVisitor = new ExpressionVisitorAdapter<>();
+ this.pivotVisitor = new PivotVisitorAdapter<>(this.expressionVisitor);
+ this.selectItemVisitor = new SelectItemVisitorAdapter<>(this.expressionVisitor);
+ this.fromItemVisitor = new FromItemVisitorAdapter<>();
+
+ this.selectVisitor = new SelectVisitorAdapter<>(this.expressionVisitor, this.pivotVisitor,
+ this.selectItemVisitor, this.fromItemVisitor);
+ this.mergeOperationVisitor = new MergeOperationVisitorAdapter<>();
+ }
+
+ public StatementVisitorAdapter(ExpressionVisitor expressionVisitor,
+ PivotVisitor pivotVisitor, SelectItemVisitor selectItemVisitor,
+ FromItemVisitor fromItemVisitor, SelectVisitor selectVisitor,
+ MergeOperationVisitor mergeOperationVisitor) {
+ this.expressionVisitor = expressionVisitor;
+ this.pivotVisitor = pivotVisitor;
+ this.selectItemVisitor = selectItemVisitor;
+ this.fromItemVisitor = fromItemVisitor;
+ this.selectVisitor = selectVisitor;
+ this.mergeOperationVisitor = mergeOperationVisitor;
+ }
+
+ public StatementVisitorAdapter(SelectVisitorAdapter selectVisitor) {
+ this.selectVisitor = selectVisitor;
+ this.expressionVisitor = selectVisitor.getExpressionVisitor();
+ this.pivotVisitor = selectVisitor.getPivotVisitor();
+ this.selectItemVisitor = selectVisitor.getSelectItemVisitor();
+ this.fromItemVisitor = selectVisitor.getFromItemVisitor();
+ this.mergeOperationVisitor = new MergeOperationVisitorAdapter<>();
+ }
@Override
public T visit(Comment comment, S context) {
@@ -57,56 +115,138 @@ public T visit(Commit commit, S context) {
@Override
public T visit(Select select, S context) {
-
- return null;
+ return select.accept(selectVisitor, context);
}
@Override
public T visit(Delete delete, S context) {
+ visitWithItems(delete.getWithItemsList(), context);
+ fromItemVisitor.visitTables(delete.getTables(), context);
+ selectVisitor.visitOutputClause(delete.getOutputClause(), context);
+ fromItemVisitor.visitFromItem(delete.getTable(), context);
+ fromItemVisitor.visitTables(delete.getUsingList(), context);
+ fromItemVisitor.visitJoins(delete.getJoins(), context);
+ expressionVisitor.visitExpression(delete.getWhere(), context);
+
+ expressionVisitor.visitPreferringClause(delete.getPreferringClause(), context);
+
+ expressionVisitor.visitOrderBy(delete.getOrderByElements(), context);
+
+ expressionVisitor.visitLimit(delete.getLimit(), context);
return null;
}
+ private void visitWithItems(List> withItemsList, S context) {
+ if (withItemsList != null) {
+ for (WithItem> item : withItemsList) {
+ item.accept(this, context);
+ }
+ }
+ }
+
@Override
public T visit(ParenthesedDelete delete, S context) {
+ delete.getDelete().accept(this, context);
+ return null;
+ }
+ @Override
+ public T visit(SessionStatement sessionStatement, S context) {
return null;
}
@Override
public T visit(Update update, S context) {
-
+ visitWithItems(update.getWithItemsList(), context);
+ fromItemVisitor.visitFromItem(update.getTable(), context);
+ fromItemVisitor.visitJoins(update.getStartJoins(), context);
+ expressionVisitor.visitUpdateSets(update.getUpdateSets(), context);
+ selectVisitor.visitOutputClause(update.getOutputClause(), context);
+ fromItemVisitor.visitFromItem(update.getFromItem(), context);
+ fromItemVisitor.visitJoins(update.getJoins(), context);
+ expressionVisitor.visitExpression(update.getWhere(), context);
+ expressionVisitor.visitPreferringClause(update.getPreferringClause(), context);
+ expressionVisitor.visitOrderBy(update.getOrderByElements(), context);
+ expressionVisitor.visitLimit(update.getLimit(), context);
+ visitReturningClause(update.getReturningClause(), context);
return null;
}
@Override
public T visit(ParenthesedUpdate update, S context) {
-
- return null;
+ return update.getUpdate().accept(this, context);
}
@Override
public T visit(Insert insert, S context) {
+ visitWithItems(insert.getWithItemsList(), context);
+
+ insert.getTable().accept(fromItemVisitor, context);
+ fromItemVisitor.visitFromItem(insert.getTable(), context);
+
+ if (insert.getColumns() != null) {
+ for (Column column : insert.getColumns()) {
+ column.accept(expressionVisitor, context);
+ }
+ }
+
+ if (insert.getPartitions() != null) {
+ for (Partition partition : insert.getPartitions()) {
+ partition.getColumn().accept(expressionVisitor, context);
+ if (partition.getValue() != null) {
+ partition.getValue().accept(expressionVisitor, context);
+ }
+ }
+ }
+
+ selectVisitor.visitOutputClause(insert.getOutputClause(), context);
+
+ if (insert.getSelect() != null) {
+ insert.getSelect().accept(selectVisitor, null);
+ }
+ expressionVisitor.visitUpdateSets(insert.getSetUpdateSets(), context);
+
+ expressionVisitor.visitUpdateSets(insert.getDuplicateUpdateSets(), context);
+
+ final InsertConflictAction conflictAction = insert.getConflictAction();
+ if (conflictAction != null) {
+ expressionVisitor.visitExpression(conflictAction.getWhereExpression(), context);
+ expressionVisitor.visitUpdateSets(conflictAction.getUpdateSets(), context);
+ }
+
+ visitReturningClause(insert.getReturningClause(), context);
+ return null;
+ }
+
+ private T visitReturningClause(ReturningClause returningClause, S context) {
+ if (returningClause!=null) {
+ returningClause.forEach(selectItem -> selectItem.accept(selectItemVisitor, context));
+ // @todo: verify why this is a list of strings and not columns
+ }
return null;
}
@Override
public T visit(ParenthesedInsert insert, S context) {
-
+ insert.getInsert().accept(this, context);
return null;
}
@Override
public T visit(Drop drop, S context) {
+ if (drop.getType().equalsIgnoreCase("table")) {
+ fromItemVisitor.visitFromItem(drop.getName(), context);
+ }
+ // @todo: handle schemas
return null;
}
@Override
public T visit(Truncate truncate, S context) {
-
- return null;
+ return truncate.getTable().accept(fromItemVisitor, context);
}
@Override
@@ -122,13 +262,11 @@ public T visit(CreateSchema createSchema, S context) {
@Override
public T visit(CreateTable createTable, S context) {
-
- return null;
+ return createTable.getTable().accept(fromItemVisitor, context);
}
@Override
public T visit(CreateView createView, S context) {
-
return null;
}
@@ -166,7 +304,12 @@ public T visit(ResetStatement reset, S context) {
@Override
public T visit(Merge merge, S context) {
-
+ visitWithItems(merge.getWithItemsList(), context);
+ fromItemVisitor.visitFromItem(merge.getTable(), context);
+ fromItemVisitor.visitFromItem(merge.getFromItem(), context);
+ expressionVisitor.visitExpression(merge.getOnCondition(), context);
+ mergeOperationVisitor.visit(merge.getOperations(), context);
+ selectVisitor.visitOutputClause(merge.getOutputClause(), context);
return null;
}
@@ -308,4 +451,14 @@ public T visit(UnsupportedStatement unsupportedStatement, S context) {
public T visit(RefreshMaterializedViewStatement materializedView, S context) {
return null;
}
+
+ @Override
+ public T visit(Import imprt, S context) {
+ return null;
+ }
+
+ @Override
+ public T visit(Export export, S context) {
+ return null;
+ }
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/UserIdentification.java b/src/main/java/net/sf/jsqlparser/statement/UserIdentification.java
new file mode 100644
index 000000000..d951931d9
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/UserIdentification.java
@@ -0,0 +1,48 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.expression.StringValue;
+
+import java.io.Serializable;
+
+public class UserIdentification implements Serializable {
+ private StringValue user;
+ private StringValue password;
+
+ public StringValue getUser() {
+ return user;
+ }
+
+ public void setUser(StringValue user) {
+ this.user = user;
+ }
+
+ public StringValue getPassword() {
+ return password;
+ }
+
+ public void setPassword(StringValue password) {
+ this.password = password;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append("USER ");
+ sql.append(user);
+
+ sql.append(" IDENTIFIED BY ");
+ sql.append(password);
+
+ return sql.toString();
+ }
+}
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 90a0e0e40..a7f47104c 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
@@ -9,6 +9,7 @@
*/
package net.sf.jsqlparser.statement.create.table;
+import net.sf.jsqlparser.statement.imprt.ImportColumn;
import net.sf.jsqlparser.statement.select.PlainSelect;
import java.io.Serializable;
@@ -21,7 +22,7 @@
/**
* Globally used definition class for columns.
*/
-public class ColumnDefinition implements Serializable {
+public class ColumnDefinition implements ImportColumn, Serializable {
private String columnName;
private ColDataType colDataType;
diff --git a/src/main/java/net/sf/jsqlparser/statement/export/DBMSDestination.java b/src/main/java/net/sf/jsqlparser/statement/export/DBMSDestination.java
new file mode 100644
index 000000000..38774023a
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/export/DBMSDestination.java
@@ -0,0 +1,118 @@
+/*-
+ * #%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.export;
+
+import net.sf.jsqlparser.expression.StringValue;
+import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
+import net.sf.jsqlparser.schema.Column;
+import net.sf.jsqlparser.schema.Table;
+import net.sf.jsqlparser.statement.ConnectionDefinition;
+import net.sf.jsqlparser.statement.ErrorClause;
+import net.sf.jsqlparser.statement.SourceDestinationType;
+import net.sf.jsqlparser.statement.select.PlainSelect;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class DBMSDestination implements ExportIntoItem, Serializable {
+ private SourceDestinationType destinationType;
+ private ConnectionDefinition connectionDefinition;
+ private Table table;
+ private ExpressionList columns;
+ private List dbmsTableDestinationOptions;
+ private StringValue statement;
+ private ErrorClause errorClause;
+
+ public SourceDestinationType getDestinationType() {
+ return destinationType;
+ }
+
+ public void setDestinationType(SourceDestinationType destinationType) {
+ this.destinationType = destinationType;
+ }
+
+ public ConnectionDefinition getConnectionDefinition() {
+ return connectionDefinition;
+ }
+
+ public void setConnectionDefinition(ConnectionDefinition connectionDefinition) {
+ this.connectionDefinition = connectionDefinition;
+ }
+
+ public Table getTable() {
+ return table;
+ }
+
+ public void setTable(Table table) {
+ this.table = table;
+ }
+
+ public ExpressionList getColumns() {
+ return columns;
+ }
+
+ public void setColumns(ExpressionList columns) {
+ this.columns = columns;
+ }
+
+ public List getDBMSTableDestinationOptions() {
+ return dbmsTableDestinationOptions;
+ }
+
+ public void setDBMSTableDestinationOptions(
+ List dbmsTableDestinationOptions) {
+ this.dbmsTableDestinationOptions = dbmsTableDestinationOptions;
+ }
+
+ public StringValue getStatement() {
+ return statement;
+ }
+
+ public void setStatement(StringValue statement) {
+ this.statement = statement;
+ }
+
+ @Override
+ public ErrorClause getErrorClause() {
+ return errorClause;
+ }
+
+ @Override
+ public void setErrorClause(ErrorClause errorClause) {
+ this.errorClause = errorClause;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append(destinationType);
+
+ sql.append(" ");
+ sql.append(connectionDefinition);
+
+ if (table != null) {
+ sql.append(" TABLE ").append(table);
+ PlainSelect.appendStringListTo(sql, columns, true, true);
+ if (dbmsTableDestinationOptions != null) {
+ sql.append(" ");
+ PlainSelect.appendStringListTo(sql, dbmsTableDestinationOptions, false, false);
+ }
+ } else if (statement != null) {
+ sql.append(" STATEMENT ").append(statement);
+ }
+
+ if (errorClause != null) {
+ sql.append(errorClause);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/export/DBMSTableDestinationOption.java b/src/main/java/net/sf/jsqlparser/statement/export/DBMSTableDestinationOption.java
new file mode 100644
index 000000000..904acea95
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/export/DBMSTableDestinationOption.java
@@ -0,0 +1,67 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2022 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement.export;
+
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.LongValue;
+import net.sf.jsqlparser.expression.StringValue;
+
+import java.io.Serializable;
+
+public class DBMSTableDestinationOption implements Serializable {
+ private String key;
+ private Expression value;
+
+ private DBMSTableDestinationOption(String key, Expression value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public DBMSTableDestinationOption(String key) {
+ this(key, (Expression) null);
+ }
+
+ public DBMSTableDestinationOption(String key, StringValue value) {
+ this(key, (Expression) value);
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public Expression getValue() {
+ return value;
+ }
+
+ public void setValue(StringValue value) {
+ this.value = value;
+ }
+
+ public void setValue(LongValue value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append(key);
+ if (value != null) {
+ sql.append(" ");
+ sql.append(value);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/export/Export.java b/src/main/java/net/sf/jsqlparser/statement/export/Export.java
new file mode 100644
index 000000000..dd6628a20
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/export/Export.java
@@ -0,0 +1,81 @@
+/*-
+ * #%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.export;
+
+import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
+import net.sf.jsqlparser.schema.Column;
+import net.sf.jsqlparser.schema.Table;
+import net.sf.jsqlparser.statement.Statement;
+import net.sf.jsqlparser.statement.StatementVisitor;
+import net.sf.jsqlparser.statement.select.*;
+
+public class Export implements Statement {
+ private Table table;
+ private ExpressionList columns;
+ private Select select;
+ private ExportIntoItem exportIntoItem;
+
+ public Table getTable() {
+ return table;
+ }
+
+ public void setTable(Table table) {
+ this.table = table;
+ }
+
+ public ExpressionList getColumns() {
+ return columns;
+ }
+
+ public void setColumns(ExpressionList columns) {
+ this.columns = columns;
+ }
+
+ public Select getSelect() {
+ return select;
+ }
+
+ public void setSelect(Select select) {
+ this.select = select;
+ }
+
+ public ExportIntoItem getExportIntoItem() {
+ return exportIntoItem;
+ }
+
+ public void setExportIntoItem(ExportIntoItem exportIntoItem) {
+ this.exportIntoItem = exportIntoItem;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+ sql.append("EXPORT ");
+ if (table != null || select != null) {
+ if (table != null) {
+ sql.append(table);
+ PlainSelect.appendStringListTo(sql, columns, true, true);
+ } else {
+ sql.append(select);
+ }
+ sql.append(" ");
+ }
+
+ sql.append("INTO ");
+ sql.append(exportIntoItem);
+
+ return sql.toString();
+ }
+
+ @Override
+ public T accept(StatementVisitor statementVisitor, S context) {
+ return statementVisitor.visit(this, context);
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/export/ExportIntoItem.java b/src/main/java/net/sf/jsqlparser/statement/export/ExportIntoItem.java
new file mode 100644
index 000000000..4558b67e9
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/export/ExportIntoItem.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.export;
+
+import net.sf.jsqlparser.statement.ErrorClause;
+
+public interface ExportIntoItem {
+ ErrorClause getErrorClause();
+
+ void setErrorClause(ErrorClause errorClause);
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/export/FileDestination.java b/src/main/java/net/sf/jsqlparser/statement/export/FileDestination.java
new file mode 100644
index 000000000..6ff364075
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/export/FileDestination.java
@@ -0,0 +1,50 @@
+/*-
+ * #%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.export;
+
+import net.sf.jsqlparser.statement.*;
+
+import java.io.Serializable;
+
+public class FileDestination extends FileSourceDestination implements ExportIntoItem, Serializable {
+ private ErrorClause errorClause;
+
+ public SourceDestinationType getDestinationType() {
+ return getType();
+ }
+
+ public void setDestinationType(SourceDestinationType destinationType) {
+ setType(destinationType);
+ }
+
+ @Override
+ public ErrorClause getErrorClause() {
+ return errorClause;
+ }
+
+ @Override
+ public void setErrorClause(ErrorClause errorClause) {
+ this.errorClause = errorClause;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append(super.toString());
+
+ if (errorClause != null) {
+ sql.append(" ");
+ sql.append(errorClause);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/imprt/DBMSSource.java b/src/main/java/net/sf/jsqlparser/statement/imprt/DBMSSource.java
new file mode 100644
index 000000000..0845af338
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/imprt/DBMSSource.java
@@ -0,0 +1,106 @@
+/*-
+ * #%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.imprt;
+
+import net.sf.jsqlparser.expression.StringValue;
+import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
+import net.sf.jsqlparser.schema.Column;
+import net.sf.jsqlparser.schema.Table;
+import net.sf.jsqlparser.statement.ConnectionDefinition;
+import net.sf.jsqlparser.statement.ErrorClause;
+import net.sf.jsqlparser.statement.SourceDestinationType;
+import net.sf.jsqlparser.statement.select.PlainSelect;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class DBMSSource implements ImportFromItem, Serializable {
+ private SourceDestinationType sourceType;
+ private ConnectionDefinition connectionDefinition;
+ private Table table;
+ private ExpressionList columns;
+ private List statements;
+ private ErrorClause errorClause;
+
+ public SourceDestinationType getSourceType() {
+ return sourceType;
+ }
+
+ public void setSourceType(SourceDestinationType sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ public ConnectionDefinition getConnectionDefinition() {
+ return connectionDefinition;
+ }
+
+ public void setConnectionDefinition(ConnectionDefinition connectionDefinition) {
+ this.connectionDefinition = connectionDefinition;
+ }
+
+ public Table getTable() {
+ return table;
+ }
+
+ public void setTable(Table table) {
+ this.table = table;
+ }
+
+ public ExpressionList getColumns() {
+ return columns;
+ }
+
+ public void setColumns(ExpressionList columns) {
+ this.columns = columns;
+ }
+
+ public List getStatements() {
+ return statements;
+ }
+
+ public void setStatements(List statements) {
+ this.statements = statements;
+ }
+
+ @Override
+ public ErrorClause getErrorClause() {
+ return errorClause;
+ }
+
+ @Override
+ public void setErrorClause(ErrorClause errorClause) {
+ this.errorClause = errorClause;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append(sourceType);
+
+ sql.append(" ");
+ sql.append(connectionDefinition);
+
+ if (table != null) {
+ sql.append(" TABLE ").append(table);
+ PlainSelect.appendStringListTo(sql, columns, true, true);
+ } else if (statements != null) {
+ for (StringValue statement : statements) {
+ sql.append(" STATEMENT ").append(statement);
+ }
+ }
+
+ if (errorClause != null) {
+ sql.append(errorClause);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/imprt/FileSource.java b/src/main/java/net/sf/jsqlparser/statement/imprt/FileSource.java
new file mode 100644
index 000000000..0be5bbab6
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/imprt/FileSource.java
@@ -0,0 +1,50 @@
+/*-
+ * #%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.imprt;
+
+import net.sf.jsqlparser.statement.*;
+
+import java.io.Serializable;
+
+public class FileSource extends FileSourceDestination implements ImportFromItem, Serializable {
+ private ErrorClause errorClause;
+
+ public SourceDestinationType getSourceType() {
+ return getType();
+ }
+
+ public void setSourceType(SourceDestinationType sourceType) {
+ setType(sourceType);
+ }
+
+ @Override
+ public ErrorClause getErrorClause() {
+ return errorClause;
+ }
+
+ @Override
+ public void setErrorClause(ErrorClause errorClause) {
+ this.errorClause = errorClause;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+
+ sql.append(super.toString());
+
+ if (errorClause != null) {
+ sql.append(" ");
+ sql.append(errorClause);
+ }
+
+ return sql.toString();
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/imprt/Import.java b/src/main/java/net/sf/jsqlparser/statement/imprt/Import.java
new file mode 100644
index 000000000..e71799a3d
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/imprt/Import.java
@@ -0,0 +1,128 @@
+/*-
+ * #%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.imprt;
+
+import net.sf.jsqlparser.expression.Alias;
+import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
+import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
+import net.sf.jsqlparser.schema.Column;
+import net.sf.jsqlparser.schema.Table;
+import net.sf.jsqlparser.statement.Statement;
+import net.sf.jsqlparser.statement.StatementVisitor;
+import net.sf.jsqlparser.statement.select.*;
+
+import java.util.List;
+
+public class Import extends ASTNodeAccessImpl implements FromItem, Statement {
+ private Table table;
+ private ExpressionList columns;
+ private List importColumns;
+ private ImportFromItem fromItem;
+ private Alias alias;
+
+ public Table getTable() {
+ return table;
+ }
+
+ public void setTable(Table table) {
+ this.table = table;
+ }
+
+ public ExpressionList getColumns() {
+ return columns;
+ }
+
+ public void setColumns(ExpressionList columns) {
+ this.columns = columns;
+ }
+
+ public List getImportColumns() {
+ return importColumns;
+ }
+
+ public void setImportColumns(List importColumns) {
+ this.importColumns = importColumns;
+ }
+
+ public ImportFromItem getFromItem() {
+ return fromItem;
+ }
+
+ public void setFromItem(ImportFromItem fromItem) {
+ this.fromItem = fromItem;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sql = new StringBuilder();
+ sql.append("IMPORT ");
+ if (table != null || importColumns != null) {
+ sql.append("INTO ");
+ if (table != null) {
+ sql.append(table);
+ PlainSelect.appendStringListTo(sql, columns, true, true);
+ } else {
+ PlainSelect.appendStringListTo(sql, importColumns, true, true);
+ }
+ sql.append(" ");
+ }
+
+ sql.append("FROM ");
+ sql.append(fromItem);
+
+ return sql.toString();
+ }
+
+ @Override
+ public T accept(StatementVisitor statementVisitor, S context) {
+ return statementVisitor.visit(this, context);
+ }
+
+ @Override
+ public T accept(FromItemVisitor fromItemVisitor, S context) {
+ return fromItemVisitor.visit(this, context);
+ }
+
+ @Override
+ public Alias getAlias() {
+ return alias;
+ }
+
+ @Override
+ public void setAlias(Alias alias) {
+ this.alias = alias;
+ }
+
+ @Override
+ public Pivot getPivot() {
+ return null;
+ }
+
+ @Override
+ public void setPivot(Pivot pivot) {}
+
+ @Override
+ public UnPivot getUnPivot() {
+ return null;
+ }
+
+ @Override
+ public void setUnPivot(UnPivot unpivot) {}
+
+ @Override
+ public SampleClause getSampleClause() {
+ return null;
+ }
+
+ @Override
+ public FromItem setSampleClause(SampleClause sampleClause) {
+ return null;
+ }
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/imprt/ImportColumn.java b/src/main/java/net/sf/jsqlparser/statement/imprt/ImportColumn.java
new file mode 100644
index 000000000..7d3f719dd
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/imprt/ImportColumn.java
@@ -0,0 +1,13 @@
+/*-
+ * #%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.imprt;
+
+public interface ImportColumn {
+}
diff --git a/src/main/java/net/sf/jsqlparser/statement/imprt/ImportFromItem.java b/src/main/java/net/sf/jsqlparser/statement/imprt/ImportFromItem.java
new file mode 100644
index 000000000..86e736cca
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/imprt/ImportFromItem.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.imprt;
+
+import net.sf.jsqlparser.statement.ErrorClause;
+
+public interface ImportFromItem {
+ ErrorClause getErrorClause();
+
+ void setErrorClause(ErrorClause errorClause);
+}
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 be0d4bb2f..7e33db8b0 100644
--- a/src/main/java/net/sf/jsqlparser/statement/merge/MergeInsert.java
+++ b/src/main/java/net/sf/jsqlparser/statement/merge/MergeInsert.java
@@ -67,15 +67,15 @@ public String toString() {
StringBuilder b = new StringBuilder();
b.append(" WHEN NOT MATCHED");
if (andPredicate != null) {
- b.append(" AND ").append(andPredicate.toString());
+ b.append(" AND ").append(andPredicate);
}
b.append(" THEN INSERT ");
if (columns != null) {
- b.append(columns.toString());
+ b.append(columns);
}
b.append(" VALUES ").append(values.toString());
if (whereCondition != null) {
- b.append(" WHERE ").append(whereCondition.toString());
+ b.append(" WHERE ").append(whereCondition);
}
return b.toString();
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/merge/MergeOperationVisitor.java b/src/main/java/net/sf/jsqlparser/statement/merge/MergeOperationVisitor.java
index fef9682fe..d2439fbd8 100644
--- a/src/main/java/net/sf/jsqlparser/statement/merge/MergeOperationVisitor.java
+++ b/src/main/java/net/sf/jsqlparser/statement/merge/MergeOperationVisitor.java
@@ -9,6 +9,8 @@
*/
package net.sf.jsqlparser.statement.merge;
+import java.util.Collection;
+
public interface MergeOperationVisitor {
T visit(MergeDelete mergeDelete, S context);
@@ -16,4 +18,11 @@ public interface MergeOperationVisitor {
T visit(MergeUpdate mergeUpdate, S context);
T visit(MergeInsert mergeInsert, S context);
+
+ default T visit(Collection mergeOperations, S context) {
+ if (mergeOperations != null) {
+ mergeOperations.forEach(operation -> operation.accept(this, context));
+ }
+ return null;
+ }
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/merge/MergeOperationVisitorAdapter.java b/src/main/java/net/sf/jsqlparser/statement/merge/MergeOperationVisitorAdapter.java
index 546b44604..61ff7a45a 100644
--- a/src/main/java/net/sf/jsqlparser/statement/merge/MergeOperationVisitorAdapter.java
+++ b/src/main/java/net/sf/jsqlparser/statement/merge/MergeOperationVisitorAdapter.java
@@ -9,20 +9,47 @@
*/
package net.sf.jsqlparser.statement.merge;
+import net.sf.jsqlparser.expression.ExpressionVisitor;
+import net.sf.jsqlparser.expression.ExpressionVisitorAdapter;
+import net.sf.jsqlparser.statement.select.SelectVisitorAdapter;
+
@SuppressWarnings({"PMD.UncommentedEmptyMethodBody"})
public class MergeOperationVisitorAdapter implements MergeOperationVisitor {
+ private ExpressionVisitor expressionVisitor;
+
+ public MergeOperationVisitorAdapter() {
+ this.expressionVisitor = new ExpressionVisitorAdapter<>();
+ }
+
+ public MergeOperationVisitorAdapter(ExpressionVisitor expressionVisitor) {
+ this.expressionVisitor = expressionVisitor;
+ }
+
+ public MergeOperationVisitorAdapter(SelectVisitorAdapter selectVisitorAdapter) {
+ this.expressionVisitor = selectVisitorAdapter.getExpressionVisitor();
+ }
+
@Override
public T visit(MergeDelete mergeDelete, S context) {
+ expressionVisitor.visitExpression(mergeDelete.getAndPredicate(), context);
return null;
}
@Override
public T visit(MergeUpdate mergeUpdate, S context) {
+ expressionVisitor.visitExpression(mergeUpdate.getAndPredicate(), context);
+ expressionVisitor.visitUpdateSets(mergeUpdate.getUpdateSets(), context);
+ expressionVisitor.visitExpression(mergeUpdate.getWhereCondition(), context);
+ expressionVisitor.visitExpression(mergeUpdate.getDeleteWhereCondition(), context);
return null;
}
@Override
public T visit(MergeInsert mergeInsert, S context) {
+ expressionVisitor.visitExpression(mergeInsert.getAndPredicate(), context);
+ expressionVisitor.visitExpressions(mergeInsert.getColumns(), context);
+ expressionVisitor.visitExpressions(mergeInsert.getValues(), context);
+ expressionVisitor.visitExpression(mergeInsert.getWhereCondition(), context);
return null;
}
}
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 37f64ad81..c0312384a 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/Distinct.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/Distinct.java
@@ -20,6 +20,7 @@ public class Distinct implements Serializable {
private List> onSelectItems;
private boolean useUnique = false;
+ private boolean useDistinctRow = false;
public Distinct() {}
@@ -43,9 +44,18 @@ public void setUseUnique(boolean useUnique) {
this.useUnique = useUnique;
}
+ public boolean isUseDistinctRow() {
+ return useDistinctRow;
+ }
+
+ public void setUseDistinctRow(boolean useDistinctRow) {
+ this.useDistinctRow = useDistinctRow;
+ }
+
@Override
public String toString() {
- String sql = useUnique ? "UNIQUE" : "DISTINCT";
+ String distinctIdentifier = useDistinctRow ? "DISTINCTROW" : "DISTINCT";
+ String sql = useUnique ? "UNIQUE" : distinctIdentifier;
if (onSelectItems != null && !onSelectItems.isEmpty()) {
sql += " ON (" + PlainSelect.getStringList(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 a16320822..c38dd140b 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/ExceptOp.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/ExceptOp.java
@@ -13,38 +13,13 @@
public class ExceptOp extends SetOperation {
- private boolean distinct;
- private boolean all;
-
public ExceptOp() {
- super(SetOperationType.EXCEPT);
- }
-
- public boolean isAll() {
- return all;
- }
-
- public void setAll(boolean all) {
- this.all = all;
- }
-
- public boolean isDistinct() {
- return distinct;
- }
-
- public void setDistinct(boolean distinct) {
- this.distinct = distinct;
+ this("");
}
- @Override
- public String toString() {
- String allDistinct = "";
- if (isAll()) {
- allDistinct = " ALL";
- } else if (isDistinct()) {
- allDistinct = " DISTINCT";
- }
- return super.toString() + allDistinct;
+ public ExceptOp(String modifier) {
+ super(SetOperationType.EXCEPT);
+ this.modifier = modifier;
}
public ExceptOp withDistinct(boolean distinct) {
@@ -56,4 +31,9 @@ public ExceptOp withAll(boolean all) {
this.setAll(all);
return this;
}
+
+ public ExceptOp withModifier(String modifier) {
+ this.modifier = modifier;
+ return this;
+ }
}
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 0d97c4e4b..ed4432003 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java
@@ -10,10 +10,39 @@
package net.sf.jsqlparser.statement.select;
import net.sf.jsqlparser.schema.Table;
+import net.sf.jsqlparser.statement.imprt.Import;
import net.sf.jsqlparser.statement.piped.FromQuery;
+import java.util.Collection;
+import java.util.List;
+
public interface FromItemVisitor {
+ default T visitFromItem(FromItem fromItem, S context) {
+ if (fromItem != null) {
+ fromItem.accept(this, context);
+ }
+ return null;
+ }
+
+ default T visitTables(List tables, S context) {
+ if (tables != null) {
+ for (Table table : tables) {
+ table.accept(this, context);
+ }
+ }
+ return null;
+ }
+
+ default T visitJoins(Collection joins, S context) {
+ if (joins != null) {
+ for (Join join : joins) {
+ join.getFromItem().accept(this, context);
+ }
+ }
+ return null;
+ }
+
T visit(Table tableName, S context);
default void visit(Table tableName) {
@@ -68,5 +97,11 @@ default void visit(TableStatement tableStatement) {
this.visit(tableStatement, null);
}
+ T visit(Import imprt, S context);
+
+ default void visit(Import imprt) {
+ this.visit(imprt, null);
+ }
+
T visit(FromQuery fromQuery, S context);
}
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 1ea920707..783b614f2 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java
@@ -9,28 +9,96 @@
*/
package net.sf.jsqlparser.statement.select;
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.ExpressionVisitor;
+import net.sf.jsqlparser.expression.ExpressionVisitorAdapter;
+import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.schema.Table;
+import net.sf.jsqlparser.statement.imprt.Import;
import net.sf.jsqlparser.statement.piped.FromQuery;
+import java.util.ArrayList;
+import java.util.Collection;
+
@SuppressWarnings({"PMD.UncommentedEmptyMethodBody"})
public class FromItemVisitorAdapter implements FromItemVisitor {
+ private SelectVisitor selectVisitor;
+ private ExpressionVisitor expressionVisitor;
+
+ public FromItemVisitorAdapter(SelectVisitor selectVisitor,
+ ExpressionVisitor expressionVisitor) {
+ this.selectVisitor = selectVisitor;
+ this.expressionVisitor = expressionVisitor;
+ }
+
+ public FromItemVisitorAdapter(ExpressionVisitor expressionVisitor) {
+ this.selectVisitor = new SelectVisitorAdapter<>(expressionVisitor);
+ this.expressionVisitor = expressionVisitor;
+ }
+
+ public FromItemVisitorAdapter() {
+ this.selectVisitor = new SelectVisitorAdapter<>();
+ this.expressionVisitor = new ExpressionVisitorAdapter<>(this.selectVisitor);
+ }
+
+
+ public SelectVisitor getSelectVisitor() {
+ return selectVisitor;
+ }
+
+ public FromItemVisitorAdapter setSelectVisitor(SelectVisitor selectVisitor) {
+ this.selectVisitor = selectVisitor;
+ return this;
+ }
+
+ public FromItemVisitorAdapter setSelectVisitor(SelectVisitorAdapter selectVisitor) {
+ this.selectVisitor = selectVisitor;
+ this.expressionVisitor = selectVisitor.getExpressionVisitor();
+ return this;
+ }
+
+ public ExpressionVisitor getExpressionVisitor() {
+ return expressionVisitor;
+ }
+
+ public FromItemVisitorAdapter setExpressionVisitor(ExpressionVisitor expressionVisitor) {
+ this.expressionVisitor = expressionVisitor;
+ return this;
+ }
@Override
- public T visit(Table table, S context) {
+ public T visitJoins(Collection joins, S context) {
+ if (joins != null) {
+ for (Join join : joins) {
+ join.getFromItem().accept(this, context);
+ if (join.getUsingColumns() != null) {
+ for (Column column : join.getUsingColumns()) {
+ column.accept(expressionVisitor, context);
+ }
+ }
+ if (join.getOnExpressions() != null) {
+ for (Expression expression : join.getOnExpressions()) {
+ expression.accept(expressionVisitor, context);
+ }
+ }
+ }
+ }
+ return null;
+ }
+ @Override
+ public T visit(Table table, S context) {
return null;
}
@Override
public T visit(ParenthesedSelect select, S context) {
-
- return null;
+ return select.getPlainSelect().accept(selectVisitor, context);
}
@Override
public T visit(LateralSubSelect lateralSubSelect, S context) {
-
- return null;
+ return lateralSubSelect.getPlainSelect().accept(selectVisitor, context);
}
@Override
@@ -41,36 +109,43 @@ public T visit(TableFunction tableFunction, S context) {
@Override
public T visit(ParenthesedFromItem fromItem, S context) {
-
- return null;
+ return fromItem.getFromItem().accept(this, context);
}
@Override
public T visit(Values values, S context) {
-
+ for (Expression expression : values.getExpressions()) {
+ expression.accept(expressionVisitor, context);
+ }
return null;
}
@Override
public T visit(PlainSelect plainSelect, S context) {
-
- return null;
+ return plainSelect.accept(selectVisitor, context);
}
@Override
public T visit(SetOperationList setOperationList, S context) {
+ ArrayList results = new ArrayList<>();
+ for (Select select : setOperationList.getSelects()) {
+ results.add(select.accept(selectVisitor, context));
+ }
+ return results.isEmpty() ? null : results.get(0);
+ }
+ @Override
+ public T visit(TableStatement tableStatement, S context) {
return null;
}
@Override
- public T visit(TableStatement tableStatement, S context) {
+ public T visit(Import imprt, S context) {
return null;
}
- @Override
public T visit(FromQuery fromQuery, S context) {
- return null;
+ return fromQuery.accept(selectVisitor, context);
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/select/GroupByElement.java b/src/main/java/net/sf/jsqlparser/statement/select/GroupByElement.java
index a708fe720..63b6b479d 100644
--- a/src/main/java/net/sf/jsqlparser/statement/select/GroupByElement.java
+++ b/src/main/java/net/sf/jsqlparser/statement/select/GroupByElement.java
@@ -35,23 +35,23 @@ public T accept(GroupByVisitor groupByVisitor, S context) {
return groupByVisitor.visit(this, context);
}
- public ExpressionList getGroupByExpressionList() {
+ public ExpressionList getGroupByExpressionList() {
return groupByExpressions;
}
@Deprecated
- public ExpressionList getGroupByExpressions() {
+ public ExpressionList