sql: expand stars directly inside ROW expressions - #175302
Open
Alignyx wants to merge 2 commits into
Open
Conversation
|
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Cover the pg_get_keywords reproduction, tuple and relation stars, mixed fields, nested rows, NULL fields, and labeled tuple access. Keep explicit controls for non-star children and shorthand tuple nesting. Release note: None
|
Thank you for updating your pull request. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
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.
Summary
Expand stars that are direct children of an explicit
ROW(...)constructor into the enclosing row expression, matching PostgreSQL tuple semantics.Fixes #26619
Root cause
The expression visitor normally replaces one expression with one expression. For
ROW((pg_get_keywords()).*), the star expands to several columns, but the visitor cannot splice those columns into the parent tuple. The expanded value was therefore retained as a nested tuple-valued expression and later rendered as a single string-like field. PostgreSQL instead replaces the direct star with the expanded fields, producing one row with the expected columns.The syntax distinction matters: an explicit
ROW(...)constructor has different expansion semantics from shorthand tuple expressions. Applying the splice to every tuple would change existing behavior for shorthand tuples and regress the counterexample covered by the surrounding name-resolution logic.Change
Handle
tree.Tuplenodes before the ordinary child walk:AllColumnsSelectororTupleStarchildren.expandStarimplementation and append all resulting expressions to the enclosing row.Nested stars and shorthand tuples continue through the existing path. The change is limited to direct-star expansion inside
ROW(...), so it fixes the reported case without changing unrelated tuple construction.Validation
SELECT ROW((pg_get_keywords()).*)and verified that the expanded fields form the enclosing row instead of a nested string-like value.