[#5594] [#7171] Parser support for FETCH NEXT n PERCENT ROWS

This commit is contained in:
lukaseder 2018-02-22 16:13:36 +01:00
parent 1b393d5911
commit d1ccb52d89

View File

@ -760,8 +760,10 @@ final class ParserImpl implements Parser {
if (offsetPostgres) {
result.addLimit(limit);
if (parseKeywordIf(ctx, "PERCENT"))
result.setLimitPercent(true);
if (parseKeywordIf(ctx, "WITH TIES"))
result.setWithTies(true);
@ -770,8 +772,11 @@ final class ParserImpl implements Parser {
result.addLimit(limit, inline((int) (long) parseUnsignedInteger(ctx)));
}
else {
if (parseKeywordIf(ctx, "PERCENT"))
result.setLimitPercent(true);
if (parseKeywordIf(ctx, "WITH TIES"))
result.setWithTies(true);
@ -788,8 +793,10 @@ final class ParserImpl implements Parser {
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();
@ -913,14 +920,18 @@ final class ParserImpl implements Parser {
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);
@ -1074,8 +1085,10 @@ final class ParserImpl implements Parser {
else
result.addLimit((int) (long) limit);
if (percent)
result.setLimitPercent(percent);
if (withTies)
result.setWithTies(true);