Skip to content

Fix JOIN motion type selection for join quals containing outer refs - #1897

Open
reshke wants to merge 2 commits into
REL_2_STABLEfrom
fix_laterla
Open

Fix JOIN motion type selection for join quals containing outer refs#1897
reshke wants to merge 2 commits into
REL_2_STABLEfrom
fix_laterla

Conversation

@reshke

@reshke reshke commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

same as #1895 but for back-branch

tglsfdc and others added 2 commits August 17, 2026 23:53
If the inner-side expressions contain PARAM_EXEC Params, we must
re-hash whenever the values of those Params change.  The executor
mechanism for that exists already, but we failed to invoke it because
finalize_plan() neglected to search the Hash.hashkeys field for
Params.  This allowed a previous scan's hash table to be re-used
when it should not be, leading to rows missing from the join's output.
(I believe incorrectly-included join rows are impossible however,
since checking the real hashclauses would reject false matches.)

This bug is very ancient, dating probably to d24d75f of 7.4.
Sadly, this simple fix depends on the plan representational changes
made by 2abd7ae, so it will only work back to v12.  I thought
about trying to make some kind of hack for v11, but I'm leery
of putting code significantly different from what is used in the
newer branches into a nearly-EOL branch.  Seeing that the bug
escaped detection for a full twenty years, problematic cases
must be rare; so I don't feel too awful about leaving v11 as-is.

Per bug #17985 from Zuming Jiang.  Back-patch to v12.

Discussion: https://postgr.es/m/17985-748b66607acd432e@postgresql.org
@reshke
reshke changed the base branch from main to REL_2_STABLE August 17, 2026 19:21
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.

2 participants