File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
java/net/sf/jsqlparser/statement/select
jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/statement/select Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,11 @@ public enum ForMode {
2020
2121 NO_KEY_UPDATE ("NO KEY UPDATE" ),
2222
23- KEY_SHARE ("KEY SHARE" );
23+ KEY_SHARE ("KEY SHARE" ),
24+
25+ // https://www.ibm.com/docs/en/db2-for-zos/13.0.0?topic=statement-read-only-clause
26+ READ_ONLY ("READ ONLY" ),
27+ FETCH_ONLY ("FETCH ONLY" );
2428
2529 private final String value ;
2630
Original file line number Diff line number Diff line change @@ -4247,6 +4247,8 @@ PlainSelect PlainSelect() #PlainSelect:
42474247 | <K_SHARE> { plainSelect.setForMode(ForMode.SHARE); }
42484248 | (<K_NO> <K_KEY> <K_UPDATE> { plainSelect.setForMode(ForMode.NO_KEY_UPDATE); })
42494249 | (<K_KEY> <K_SHARE> { plainSelect.setForMode(ForMode.KEY_SHARE); })
4250+ | (<K_READ> <K_ONLY> { plainSelect.setForMode(ForMode.READ_ONLY); })
4251+ | (<K_FETCH> <K_ONLY> { plainSelect.setForMode(ForMode.FETCH_ONLY); })
42504252 )
42514253 [ LOOKAHEAD(2) <K_OF> updateTable = Table() { plainSelect.setForUpdateTable(updateTable); } ]
42524254 [ LOOKAHEAD(<K_WAIT>) wait = Wait() { plainSelect.setWait(wait); } ]
Original file line number Diff line number Diff line change 1212import net .sf .jsqlparser .JSQLParserException ;
1313import net .sf .jsqlparser .test .TestUtils ;
1414import org .junit .jupiter .api .Test ;
15+ import org .junit .jupiter .params .ParameterizedTest ;
16+ import org .junit .jupiter .params .provider .ValueSource ;
1517
1618public class DB2Test {
1719 @ Test
@@ -20,4 +22,16 @@ void testDB2SpecialRegister() throws JSQLParserException {
2022 "SELECT * FROM TABLE1 where COL_WITH_TIMESTAMP <= CURRENT TIMESTAMP - CURRENT TIMEZONE" ;
2123 TestUtils .assertSqlCanBeParsedAndDeparsed (sqlStr , true );
2224 }
25+
26+ @ ParameterizedTest
27+ @ ValueSource ( strings = {
28+ "SELECT * FROM table WITH UR" ,
29+ "SELECT * FROM table WITH UR FOR READ ONLY" ,
30+ "SELECT * FROM table FOR READ ONLY" ,
31+ "SELECT * FROM table FOR FETCH ONLY" ,
32+ "SELECT * FROM table FETCH FIRST 100 ROWS ONLY FOR READ ONLY"
33+ })
34+ void testWithIsolationLevelAndReadOnlyModes (String sqlStr ) throws JSQLParserException {
35+ TestUtils .assertSqlCanBeParsedAndDeparsed (sqlStr , true );
36+ }
2337}
You can’t perform that action at this time.
0 commit comments