parser: fold VALUES set-op inside parens + pin the whole VALUES/casing matrix - #58
Merged
Merged
Conversation
… matrix Proactive close-out of the recurring VALUES-as-set-op-operand regression class (each prior pass fixed one adjacent cell: RHS #53, parenthesized-RHS ORDER BY #56, bare top-level LEFT #57). An exhaustive enumeration of the neighborhood surfaced one still-broken cell: ( VALUES (1) UNION SELECT 2 ) -> parse returned NULL (whole query dropped) parse_parenthesized_query dispatched a leading VALUES to parse_values_stmt() WITHOUT folding a following set-op tail - unlike the SELECT branch (folds via parse_select_stmt) and the nested-'(' branch (fold_set_operations). So a set operation whose LEFT operand is a bare VALUES inside parens left the `UNION ...` unconsumed, failing the `)` check. Fold the tail here too. Guardrails: two table-driven matrix tests pin the ENTIRE neighborhood so a future change that drops any single cell fails loudly instead of surviving to the next audit: * ValuesSetOpOperandMatrix - 28 cells: VALUES standalone / LEFT / RIGHT / parenthesized / both-sides / chained / nested-in-parens / as INTERSECT arm / with trailing ORDER BY/LIMIT / as a derived table. * SetOpKeywordCasingMatrix - UNION/INTERSECT/EXCEPT x UPPER/lower/MiXeD (+ALL). Full suite 37/37 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FyKDAbMWGwiZq4iJx3imsg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The last four audit passes each fixed one adjacent cell of the "VALUES as a set-op operand" neighborhood — VALUES on the RHS (#53), parenthesized-RHS
ORDER BY(#56), bare top-level LEFT operand (#57) — a recurring fix-one-miss-the-neighbor pattern. Rather than wait for the next pass to surface the next cell, I exhaustively enumerated the whole neighborhood and found one still-broken cell.Bug found & fixed
parse_parenthesized_querydispatched a leadingVALUEStoparse_values_stmt()without folding a following set-op tail — unlike the SELECT branch (folds viaparse_select_stmt) and the nested-(branch (fold_set_operations). So a set operation whose LEFT operand is a bareVALUESinside parens left theUNION …unconsumed, failing the)check. Now it folds the tail there too, mirroring the sibling branches.Guardrails (the main ask)
Two table-driven matrix tests pin the entire neighborhood, so a future change that drops any single cell fails loudly here instead of surviving to the next audit:
ValuesSetOpOperandMatrix— 28 cells: VALUES standalone / LEFT / RIGHT / parenthesized / both-sides / chained / nested-in-parens / as an INTERSECT arm / with trailingORDER BY/LIMIT/ as a derived table.SetOpKeywordCasingMatrix—UNION/INTERSECT/EXCEPT×UPPER/lower/MiXeD(+ALL).Every cell asserts the root node type and that no operator/arm was dropped.
Full suite 37/37 green.