Skip to content

feat: support Informix keywords "with no log" #1953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/main/java/net/sf/jsqlparser/statement/select/PlainSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public class PlainSelect extends Select {

private boolean isUsingOnly = false;

private boolean useWithNoLog = false;

private Table intoTempTable = null;

@Deprecated
public boolean isUseBrackets() {
return false;
Expand Down Expand Up @@ -228,6 +232,32 @@ public PlainSelect withUsingOnly(boolean usingOnly) {
return this;
}

public boolean isUseWithNoLog() {
return useWithNoLog;
}

public void setUseWithNoLog(boolean useWithNoLog) {
this.useWithNoLog = useWithNoLog;
}

public PlainSelect withUseWithNoLog(boolean useWithNoLog) {
this.setUseWithNoLog(useWithNoLog);
return this;
}

public Table getIntoTempTable() {
return intoTempTable;
}

public void setIntoTempTable(Table intoTempTable) {
this.intoTempTable = intoTempTable;
}

public PlainSelect withIntoTempTable(Table intoTempTable) {
this.setIntoTempTable(intoTempTable);
return this;
}

@Override
public void accept(SelectVisitor selectVisitor) {
selectVisitor.visit(this);
Expand Down Expand Up @@ -529,6 +559,12 @@ public StringBuilder appendSelectBodyTo(StringBuilder builder) {
builder.append(" WHERE ").append(where);
}
}
if (intoTempTable != null) {
builder.append(" INTO TEMP ").append(intoTempTable);
}
if (useWithNoLog) {
builder.append(" WITH NO LOG");
}
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ public void visit(PlainSelect plainSelect) {
if (plainSelect.getForXmlPath() != null) {
buffer.append(" FOR XML PATH(").append(plainSelect.getForXmlPath()).append(")");
}
if (plainSelect.getIntoTempTable() != null) {
buffer.append(" INTO TEMP ").append(plainSelect.getIntoTempTable());
}
if (plainSelect.isUseWithNoLog()) {
buffer.append(" WITH NO LOG");
}

}

Expand Down
3 changes: 3 additions & 0 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -2237,6 +2237,7 @@ PlainSelect PlainSelect() #PlainSelect:
boolean noWait = false;
String windowName = null;
WindowDefinition winDef;
Table intoTempTable = null;
}
{
<K_SELECT>
Expand Down Expand Up @@ -2322,6 +2323,8 @@ PlainSelect PlainSelect() #PlainSelect:
| <K_SKIP> <K_LOCKED> { plainSelect.setSkipLocked(true); }) ]
]
[ LOOKAHEAD(<K_OPTIMIZE>) optimize = OptimizeFor() { plainSelect.setOptimizeFor(optimize); } ]
[ LOOKAHEAD(3) <K_INTO> <K_TEMP> intoTempTable = Table() { plainSelect.setIntoTempTable(intoTempTable);} ]
[ LOOKAHEAD(3)<K_WITH> <K_NO> <K_LOG> { plainSelect.setUseWithNoLog(true); } ]
{
plainSelect.setSelectItems(selectItems);
plainSelect.setFromItem(fromItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5813,4 +5813,10 @@ public void testIssue1908() throws JSQLParserException {
String stmt = "SELECT * FROM ONLY sys_business_rule";
assertSqlCanBeParsedAndDeparsed(stmt);
}

@Test
public void testIssue1833() throws JSQLParserException {
String stmt = "SELECT age, name, gender FROM user_info INTO TEMP user_temp WITH NO LOG";
assertSqlCanBeParsedAndDeparsed(stmt);
}
}