Fix wrong results for WHERE on inherited column with LEFT JOIN ON FALSE#8591
Open
colm-mchugh wants to merge 1 commit into
Open
Fix wrong results for WHERE on inherited column with LEFT JOIN ON FALSE#8591colm-mchugh wants to merge 1 commit into
colm-mchugh wants to merge 1 commit into
Conversation
575fb64 to
100255d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8591 +/- ##
=======================================
Coverage 88.75% 88.76%
=======================================
Files 288 288
Lines 64263 64272 +9
Branches 8086 8086
=======================================
+ Hits 57036 57050 +14
+ Misses 4892 4885 -7
- Partials 2335 2337 +2 🚀 New features to boost your workflow:
|
…IN ON FALSE When a local inheritance parent table is cross-joined with a distributed table through LEFT JOIN ... ON FALSE, PostgreSQL's expand_single_inheritance_child() creates child RTEs via memcpy, duplicating Citus's identity marker (values_lists). This causes RelationRestrictionForRelation() to return the child's restriction instead of the parent's. Since Vars in plannerInfo->parse still reference the parent's original rtable position, RequiredAttrNumbersForRelationInternal() finds no matching Vars, causing all columns to be replaced with NULL. Fix by adding an originalRteIndex parameter to RequiredAttrNumbersForRelation() that also searches at the RTE's original position in the query's rtable when it differs from the restriction's index. Fixes: #8553
100255d to
d06e2c0
Compare
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.
DESCRIPTION: Fix wrong results for WHERE on inheritance parent column with LEFT JOIN ON FALSE
Problem: When a local inheritance parent table is cross-joined with a distributed table through
LEFT JOIN ... ON FALSE, PostgreSQL'sexpand_single_inheritance_child()creates child RTEs viamemcpy, duplicating Citus's identity marker (values_lists). This causesRelationRestrictionForRelation()to return the child's restriction instead of the parent's. Since Vars in plannerInfo->parse still reference the parent's original rtable position,RequiredAttrNumbersForRelationInternal()finds no matching Vars, causing all columns to be replaced with NULL, and ultimately producing wrong (empty) query results.Fix: Add an originalRteIndex parameter to RequiredAttrNumbersForRelation() that also searches at the RTE's original position in the query's rtable when it differs from the restriction's index. Fixes: #8553