File tree Expand file tree Collapse file tree 4 files changed +27
-3
lines changed
jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/statement/select Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ public class PlainSelect extends ASTNodeAccessImpl implements SelectBody {
4949 private boolean sqlNoCacheFlag = false ;
5050 private String forXmlPath ;
5151 private KSQLWindow ksqlWindow = null ;
52+ private boolean noWait = false ;
5253
5354 public boolean isUseBrackets () {
5455 return useBrackets ;
@@ -396,6 +397,10 @@ public String toString() {
396397 // Wait's toString will do the formatting for us
397398 sql .append (wait );
398399 }
400+
401+ if (isNoWait ()) {
402+ sql .append (" NOWAIT" );
403+ }
399404 }
400405 if (optimizeFor != null ) {
401406 sql .append (optimizeFor );
@@ -506,4 +511,12 @@ public boolean getMySqlSqlCalcFoundRows() {
506511 public boolean getMySqlSqlNoCache () {
507512 return this .sqlNoCacheFlag ;
508513 }
514+
515+ public void setNoWait (boolean noWait ) {
516+ this .noWait = noWait ;
517+ }
518+
519+ public boolean isNoWait () {
520+ return this .noWait ;
521+ }
509522}
Original file line number Diff line number Diff line change @@ -165,6 +165,9 @@ public void visit(PlainSelect plainSelect) {
165165 // wait's toString will do the formatting for us
166166 buffer .append (plainSelect .getWait ());
167167 }
168+ if (plainSelect .isNoWait ()) {
169+ buffer .append (" NOWAIT" );
170+ }
168171 }
169172 if (plainSelect .getOptimizeFor () != null ) {
170173 deparseOptimizeFor (plainSelect .getOptimizeFor ());
Original file line number Diff line number Diff line change @@ -233,6 +233,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
233233| <K_NOVALIDATE : "NOVALIDATE">
234234| <K_NULL:"NULL">
235235| <K_NULLS: "NULLS">
236+ | <K_NOWAIT: "NOWAIT">
236237| <K_OF:"OF">
237238| <K_OFFSET:"OFFSET">
238239| <K_ON:"ON">
@@ -1276,7 +1277,8 @@ PlainSelect PlainSelect() #PlainSelect:
12761277 Wait wait = null;
12771278 boolean mySqlSqlCalcFoundRows = false;
12781279 Token token;
1279- KSQLWindow ksqlWindow=null;
1280+ KSQLWindow ksqlWindow = null;
1281+ boolean noWait = false;
12801282}
12811283{
12821284 <K_SELECT>
@@ -1332,9 +1334,10 @@ PlainSelect PlainSelect() #PlainSelect:
13321334
13331335 [LOOKAHEAD(<K_FETCH>) fetch = Fetch() { plainSelect.setFetch(fetch); } ]
13341336
1335- [ LOOKAHEAD(2) <K_FOR> <K_UPDATE> { plainSelect.setForUpdate(true); }
1337+ [LOOKAHEAD(2) <K_FOR> <K_UPDATE> { plainSelect.setForUpdate(true); }
13361338 [ <K_OF> updateTable = Table() { plainSelect.setForUpdateTable(updateTable); } ]
1337- [ LOOKAHEAD(<K_WAIT>) wait = Wait() { plainSelect.setWait(wait); } ] ]
1339+ [ LOOKAHEAD(<K_WAIT>) wait = Wait() { plainSelect.setWait(wait); } ]
1340+ [ <K_NOWAIT> { plainSelect.setNoWait(true); } ] ]
13381341
13391342 [LOOKAHEAD(<K_OPTIMIZE>) optimize = OptimizeFor() { plainSelect.setOptimizeFor(optimize); } ]
13401343
Original file line number Diff line number Diff line change @@ -3136,6 +3136,11 @@ public void testForUpdateWaitWithTimeout() throws JSQLParserException {
31363136 assertEquals ("wait time should be 60" , waitTime , 60L );
31373137 }
31383138
3139+ @ Test
3140+ public void testForUpdateNoWait () throws JSQLParserException {
3141+ assertSqlCanBeParsedAndDeparsed ("SELECT * FROM mytable FOR UPDATE NOWAIT" );
3142+ }
3143+
31393144// @Test public void testSubSelectFailsIssue394() throws JSQLParserException {
31403145// assertSqlCanBeParsedAndDeparsed("select aa.* , t.* from accenter.all aa, (select a.* from pacioli.emc_plan a) t");
31413146// }
You can’t perform that action at this time.
0 commit comments