Fix semijoin unique-ification for child relations
Richard Guo <rguo@postgresql.org>
Fix semijoin unique-ification for child relations For a child relation, we should not assume that its parent's unique-ified relation (or unique-ified path in v18) always exists. In cases where all RHS columns that need to be unique-ified are equated to constants, the unique-ified relation/path for the parent table is not built, as there are no columns left to unique-ify. Failing to account for this can result in a SIGSEGV crash during planning. This patch checks whether the parent's unique-ified relation or path exists and skips unique-ification of the child relation if it does not. Author: Richard Guo <guofenglinux@gmail.com> Discussion: https://postgr.es/m/CAMbWs49MOdLW2c+qbLHHBt8VBu=4ONpM91D19=AWeW93eFUF6A@mail.gmail.com Backpatch-through: 18
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/plan/planner.c | modified | +9 −0 |
| src/test/regress/expected/join.out | modified | +60 −0 |
| src/test/regress/sql/join.sql | modified | +37 −0 |
Discussion
- [BUG] Remove self joins causes 'variable not found in subplan target lists' error 20 messages · 2025-08-22 → 2025-08-29