Repository navigation
fix(parser): support OFFSET without LIMIT - #27021
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
aptend
left a comment
There was a problem hiding this comment.
Deep review completed on exact head dc1ae1af8c455a03b31c9cab5ef3c4817a9d412a.
Changes requested:
-
[P1] Preserve
OFFSETas an implicit alias. Giving the token precedence with%nonassoc OFFSETmakes the parser commit to the pagination clause before it knows the following context. This head rejects existing valid inputs such asselect 1 offset,select 1 offset from t, andselect * from t offset; the exact base052b2fdcebce6d8d093624773c03ef3f92afeaefaccepts them. This is a backward-compatibility regression whileOFFSETis still intentionally listed as an unreserved keyword. Please preserve projection/table alias behavior and add regression controls for both. -
[P1] Cover offset-only pagination after a parenthesized SELECT query expression. The two
select_no_parensalternatives beginning withselect_with_parensstill accept onlylimit_clause, so(select 1) offset 1andwith cte as (select 1) (select * from cte) offset 1fail on this head, while theirLIMITcounterparts pass. Please extend those grammar paths and add focused parser cases.
The new direct SELECT ... OFFSET parser test passes, generated parser output is reproducible, and the failures above come from focused counterexample probes.
aunjgr
left a comment
There was a problem hiding this comment.
P1: query_limit_opt is used for simple SELECTs, but the select_with_parens branches still take limit_clause (including the CTE counterpart). As a result, an existing accepted form such as (SELECT 1) LIMIT 1 has no OFFSET-only counterpart: (SELECT 1) OFFSET 1 fails to parse. Please use query_limit_opt in those branches and cover parenthesized SELECT (and CTE) forms.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed on exact head dc1ae1af8c455a03b31c9cab5ef3c4817a9d412a.
-
[P1] Preserve existing implicit aliases named
offset. MakingOFFSETnon-associative atpkg/sql/parsers/dialect/mysql/mysql_sql.y:347makes the parser commit to pagination before the following context is known. This head rejectsselect 1 offset,select 1 offset from t, andselect * from t offset; the exact base052b2fdcebce6d8d093624773c03ef3f92afeaefaccepts all three.OFFSETremains an unreserved keyword, so this is a backward-compatibility regression. Please preserve both projection and table implicit-alias paths and add base-vs-candidate regression controls. -
[P1] Close the parenthesized-query grammar paths. The
select_with_parensalternatives at lines 6388 and 6400 still consumelimit_clauseinstead ofquery_limit_opt, so(select 1) offset 1andwith cte as (select 1) (select * from cte) offset 1fail even though the corresponding LIMIT forms work. Please update both plain and WITH branches and add focused parser tests.
I reproduced both failures with isolated parser probes; the alias controls pass on the exact base. The existing parser package, new limit-binder tests, git diff --check, and vet pass, which confirms that current green tests do not cover these counterexamples.
|
@aptend @aunjgr @XuPeng-SH Thanks for the focused counterexamples. They are addressed on exact head
Fresh verification on this exact head:
Result: PASS ( |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review completed on exact head 7c46521f57aa8c61d3b132884ebaf22bb1d91865 against base bdbd613fdece966769eb68481a3e58bfbc36b30c.
Changes requested:
-
[P1] Finish preserving implicit aliases named
offsetacross every legal follower. The contextual lookahead inscanner.go:903-908has an ad-hoc terminator list that omits at leastBY,INTERVAL, andFULL. Exact-base controls demonstrate the regressions:SELECT 1 offset BY RANK WITH OPTION 'nprobe=1'parses on base asselect 1 as offset by rank ..., but this head returns a syntax error.SELECT * FROM t offset FULL JOIN u ON t.a = u.aparses on base with table aliasoffset, but this head returns a syntax error (same forFULL OUTER JOIN).SELECT 1 offset INTERVAL(ts, 1, day)hasLimit == niland a non-nil time window on base; this head silently changes it to a non-nilLimit.Offsetand no time window.
Please make the decision cover the grammar's complete alias follow set (rather than a partial token list) and add these base-compatibility controls.
-
[P1] Preserve the implicit derived-table alias column-list form with whitespace.
SELECT * FROM (SELECT 1) offset (c)is accepted on the exact base asselect * from (select 1) as offset(c)with no query limit. On this head it is silently reinterpreted as query pagination (Limit.Offset != nil) and formats asselect * from (select 1) offset (c). The new test coversAS offset(c), but that does not protect the existing optional-ASform. Please resolve this ambiguity without changing the pre-existing alias AST and add a focused regression.
The author's previously reported projection/table alias and parenthesized-query cases now pass. I also verified the full MySQL parser and plan packages, reproducible zero-conflict parser generation, build, vet, and git diff --check; the findings above are focused counterexamples not covered by the green suite.
|
@XuPeng-SH Addressed the current-head findings in
Fresh verification after the final edit:
|
Merge Queue Status
This pull request spent 44 minutes 36 seconds in the queue, with no time running CI. Waiting for any of
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks: HintYou may have to fix your CI before adding the pull request to the queue again. Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 3 hours 34 minutes 59 seconds in the queue, with no time running CI. Waiting for any of
All conditions
ReasonPull request #27021 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks: HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #26769
What this PR does / why we need it:
fix(parser): support OFFSET without LIMIT