Skip to content

Commit

Permalink
[#5594] [#7171] Parser support for FETCH NEXT n PERCENT ROWS
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed Feb 22, 2018
1 parent 1b393d5 commit d1ccb52
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions jOOQ/src/main/java/org/jooq/impl/ParserImpl.java
Expand Up @@ -760,8 +760,10 @@ else if (peekKeyword(ctx, "FETCH"))
if (offsetPostgres) {
result.addLimit(limit);

if (parseKeywordIf(ctx, "PERCENT"))
result.setLimitPercent(true);





if (parseKeywordIf(ctx, "WITH TIES"))
result.setWithTies(true);
Expand All @@ -770,8 +772,11 @@ else if (parseIf(ctx, ',')) {
result.addLimit(limit, inline((int) (long) parseUnsignedInteger(ctx)));
}
else {
if (parseKeywordIf(ctx, "PERCENT"))
result.setLimitPercent(true);






if (parseKeywordIf(ctx, "WITH TIES"))
result.setWithTies(true);
Expand All @@ -788,8 +793,10 @@ else if (!offsetPostgres && parseKeywordIf(ctx, "FETCH")) {

result.addLimit(inline((int) (long) defaultIfNull(parseUnsignedIntegerIf(ctx), 1L)));

if (parseKeywordIf(ctx, "PERCENT"))
result.setLimitPercent(true);





if (!parseKeywordIf(ctx, "ROW") && !parseKeywordIf(ctx, "ROWS"))
throw ctx.unexpectedToken();
Expand Down Expand Up @@ -913,14 +920,18 @@ private static final SelectQueryImpl<Record> parseQueryPrimary(ParserContext ctx

Long limit = null;
Long offset = null;
boolean percent = false;



boolean withTies = false;

// T-SQL style TOP .. START AT
if (parseKeywordIf(ctx, "TOP")) {
limit = parseUnsignedInteger(ctx);

percent = parseKeywordIf(ctx, "PERCENT");




if (parseKeywordIf(ctx, "START AT"))
offset = parseUnsignedInteger(ctx);
Expand Down Expand Up @@ -1074,8 +1085,10 @@ else if (parseKeywordIf(ctx, "GROUPING SETS")) {
else
result.addLimit((int) (long) limit);

if (percent)
result.setLimitPercent(percent);





if (withTies)
result.setWithTies(true);
Expand Down

0 comments on commit d1ccb52

Please sign in to comment.