Skip to content

Fix wrong results for NOT (x IS DISTINCT FROM y) with recursive planning#8497

Open
bfa-dev wants to merge 4 commits intocitusdata:mainfrom
bfa-dev:fix/8468-recursive-planning-null-restriction-columns
Open

Fix wrong results for NOT (x IS DISTINCT FROM y) with recursive planning#8497
bfa-dev wants to merge 4 commits intocitusdata:mainfrom
bfa-dev:fix/8468-recursive-planning-null-restriction-columns

Conversation

@bfa-dev
Copy link
Copy Markdown

@bfa-dev bfa-dev commented Mar 8, 2026

DESCRIPTION: Fixes wrong query results when recursive planning projects restriction-referenced columns as NULL

When ReplaceRTERelationWithRteSubquery wraps a local table into a subquery, restrictions are pushed into the subplan but remain on the outer query. If restriction-referenced columns are not in requiredAttrNumbers, the outer subquery projects them as NULL, causing the outer WHERE to evaluate incorrectly (e.g., NOT (0 IS DISTINCT FROM NULL) is always FALSE).

Fix by including restriction-referenced column Vars in requiredAttrNumbers before building the subquery.

Fixes #8468

@bfa-dev
Copy link
Copy Markdown
Author

bfa-dev commented Mar 8, 2026

@microsoft-github-policy-service agree

When ReplaceRTERelationWithRteSubquery wraps a local table into a
subquery, restrictions are pushed into the subplan but remain on the
outer query. If restriction-referenced columns are not in
requiredAttrNumbers, the outer subquery projects them as NULL, causing
the outer WHERE to evaluate incorrectly (e.g., NOT (0 IS DISTINCT FROM
NULL) is always FALSE).

Fix by including restriction-referenced column Vars in
requiredAttrNumbers before building the subquery.

Fixes citusdata#8468
@bfa-dev bfa-dev force-pushed the fix/8468-recursive-planning-null-restriction-columns branch from 9a48df9 to 3dfbc9c Compare March 8, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TLP test fail on sqlancer due to num_nulls interpreted differently on workers

1 participant