Fix misuse of RelOptInfo.unique_for_rels cache by SJE
Alexander Korotkov <akorotkov@postgresql.org>
Fix misuse of RelOptInfo.unique_for_rels cache by SJE When SJE uses RelOptInfo.unique_for_rels cache, it passes filtered quals to innerrel_is_unique_ext(). That might lead to an invalid match to cache entries made by previous non self-join checking calls. Add UniqueRelInfo.self_join flag to prevent such cases. Also, fix that SJE should require a strict match of outerrelids to make sure UniqueRelInfo.extra_clauses are valid. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/4788f781-31bd-9796-d7d6-588a751c8787%40gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/plan/analyzejoins.c | modified | +21 −9 |
| src/include/nodes/pathnodes.h | modified | +6 −0 |
| src/test/regress/expected/join.out | modified | +23 −0 |
| src/test/regress/sql/join.sql | modified | +9 −0 |
Discussion
- Removing unneeded self joins 246 messages · 2018-05-16 → 2025-07-15