Skip to content

Fix returnless UNION EXISTS with VLE#2460

Closed
MuhammadTahaNaveed wants to merge 1 commit into
apache:masterfrom
MuhammadTahaNaveed:i2396
Closed

Fix returnless UNION EXISTS with VLE#2460
MuhammadTahaNaveed wants to merge 1 commit into
apache:masterfrom
MuhammadTahaNaveed:i2396

Conversation

@MuhammadTahaNaveed

Copy link
Copy Markdown
Member

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

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 UNION leaf queries to a single stable internal column to avoid branch-specific target width/type leakage during set-op planning.
  • Thread a returnless_union flag through transform_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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A WHERE EXISTS { ... } subquery may crash Apache AGE when it contains both:

3 participants