Fix returnless UNION EXISTS with VLE#2460
Closed
MuhammadTahaNaveed wants to merge 1 commit into
Closed
Conversation
Project returnless UNION leaves to a stable internal column so postgres set-op planning does not see branch-specific target widths from injected RETURN * outputs. Add regression coverage for VLE branches, UNION ALL, and nested returnless UNION. Co-authored-by: OpenAI Codex 5.5 xhigh <codex@openai.com>
jrgemignani
approved these changes
Jul 3, 2026
There was a problem hiding this comment.
Pull request overview
Fixes a crash in predicate subqueries (EXISTS { ... }) that combine variable-length edges (VLE) with UNION by ensuring PostgreSQL set-operation planning sees a stable, branch-independent projection for returnless UNION leaves. Adds regression coverage for VLE + returnless UNION scenarios (including UNION ALL and nested UNION).
Changes:
- Project returnless
UNIONleaf queries to a single stable internal column to avoid branch-specific target width/type leakage during set-op planning. - Thread a
returnless_unionflag throughtransform_cypher_union_tree()so nested UNION trees consistently apply the returnless behavior. - Add regression tests and expected output for issue #2396 reproductions (VLE branches,
UNION ALL, nested returnless UNION).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/backend/parser/cypher_clause.c | Projects returnless UNION leaves to a stable column and propagates returnless-union context through UNION-tree transformation. |
| regress/sql/cypher_subquery.sql | Adds SQL regression queries covering returnless UNION in EXISTS with VLE, UNION ALL, and nesting. |
| regress/expected/cypher_subquery.out | Adds expected outputs for the new regression cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+995
to
+1004
| /* | ||
| * Returnless UNION branches use a parser-injected RETURN * only as a | ||
| * syntactic carrier. The branch output is unobservable, so expose one | ||
| * stable column to PostgreSQL's set-op planner instead of leaking the | ||
| * branch's current variable list into set-op metadata. | ||
| */ | ||
| if (returnless_union) | ||
| { | ||
| project_returnless_union_leaf(returnQuery); | ||
| } |
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.
Project returnless UNION leaves to a stable internal column so postgres set-op planning does not see branch-specific target widths from injected RETURN * outputs. Add regression coverage for VLE branches, UNION ALL, and nested returnless UNION
Fixes #2396