Skip to content

Commit 4de1707

Browse files
author
mjh
committed
feat: with no log
1 parent f1676dd commit 4de1707

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

src/main/java/net/sf/jsqlparser/statement/select/PlainSelect.java

+36
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public class PlainSelect extends Select {
6767

6868
private boolean isUsingOnly = false;
6969

70+
private boolean useWithNoLog = false;
71+
72+
private Table intoTempTable = null;
73+
7074
@Deprecated
7175
public boolean isUseBrackets() {
7276
return false;
@@ -228,6 +232,32 @@ public PlainSelect withUsingOnly(boolean usingOnly) {
228232
return this;
229233
}
230234

235+
public boolean isUseWithNoLog() {
236+
return useWithNoLog;
237+
}
238+
239+
public void setUseWithNoLog(boolean useWithNoLog) {
240+
this.useWithNoLog = useWithNoLog;
241+
}
242+
243+
public PlainSelect withUseWithNoLog(boolean useWithNoLog) {
244+
this.setUseWithNoLog(useWithNoLog);
245+
return this;
246+
}
247+
248+
public Table getIntoTempTable() {
249+
return intoTempTable;
250+
}
251+
252+
public void setIntoTempTable(Table intoTempTable) {
253+
this.intoTempTable = intoTempTable;
254+
}
255+
256+
public PlainSelect withIntoTempTable(Table intoTempTable) {
257+
this.setIntoTempTable(intoTempTable);
258+
return this;
259+
}
260+
231261
@Override
232262
public void accept(SelectVisitor selectVisitor) {
233263
selectVisitor.visit(this);
@@ -529,6 +559,12 @@ public StringBuilder appendSelectBodyTo(StringBuilder builder) {
529559
builder.append(" WHERE ").append(where);
530560
}
531561
}
562+
if (intoTempTable != null) {
563+
builder.append(" INTO TEMP ").append(intoTempTable);
564+
}
565+
if (useWithNoLog) {
566+
builder.append(" WITH NO LOG");
567+
}
532568
return builder;
533569
}
534570

src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java

+6
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ public void visit(PlainSelect plainSelect) {
320320
if (plainSelect.getForXmlPath() != null) {
321321
buffer.append(" FOR XML PATH(").append(plainSelect.getForXmlPath()).append(")");
322322
}
323+
if (plainSelect.getIntoTempTable() != null) {
324+
buffer.append(" INTO TEMP ").append(plainSelect.getIntoTempTable());
325+
}
326+
if (plainSelect.isUseWithNoLog()) {
327+
buffer.append(" WITH NO LOG");
328+
}
323329

324330
}
325331

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

+3
Original file line numberDiff line numberDiff line change
@@ -2237,6 +2237,7 @@ PlainSelect PlainSelect() #PlainSelect:
22372237
boolean noWait = false;
22382238
String windowName = null;
22392239
WindowDefinition winDef;
2240+
Table intoTempTable = null;
22402241
}
22412242
{
22422243
<K_SELECT>
@@ -2322,6 +2323,8 @@ PlainSelect PlainSelect() #PlainSelect:
23222323
| <K_SKIP> <K_LOCKED> { plainSelect.setSkipLocked(true); }) ]
23232324
]
23242325
[ LOOKAHEAD(<K_OPTIMIZE>) optimize = OptimizeFor() { plainSelect.setOptimizeFor(optimize); } ]
2326+
[ LOOKAHEAD(3) <K_INTO> <K_TEMP> intoTempTable = Table() { plainSelect.setIntoTempTable(intoTempTable);} ]
2327+
[ LOOKAHEAD(3)<K_WITH> <K_NO> <K_LOG> { plainSelect.setUseWithNoLog(true); } ]
23252328
{
23262329
plainSelect.setSelectItems(selectItems);
23272330
plainSelect.setFromItem(fromItem);

src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -5813,4 +5813,10 @@ public void testIssue1908() throws JSQLParserException {
58135813
String stmt = "SELECT * FROM ONLY sys_business_rule";
58145814
assertSqlCanBeParsedAndDeparsed(stmt);
58155815
}
5816+
5817+
@Test
5818+
public void testIssue1833() throws JSQLParserException {
5819+
String stmt = "SELECT age, name, gender FROM user_info INTO TEMP user_temp WITH NO LOG";
5820+
assertSqlCanBeParsedAndDeparsed(stmt);
5821+
}
58165822
}

0 commit comments

Comments
 (0)