mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
When removing a relation from the query, drop its RelOptInfo.
In commit b78f6264e
I opined that it was "too risky" to delete a
relation's RelOptInfo from the planner's data structures when we have
realized that we don't need to join to it; so instead we just marked
it as a dead relation. In hindsight that judgment seems flawed: any
subsequent access to such a dead relation is arguably a bug in
itself, so leaving the RelOptInfo present just helps to mask bugs.
Let's delete it instead, allowing removal of the whole notion of a
"dead relation". So far as the regression tests can find, this
requires no other code changes, except for one Assert in equivclass.c
that was very dubiously not complaining about access to a dead rel.
Discussion: https://postgr.es/m/229905.1676062220@sss.pgh.pa.us
This commit is contained in:
@ -2886,8 +2886,9 @@ match_foreign_keys_to_quals(PlannerInfo *root)
|
||||
|
||||
/*
|
||||
* Either relid might identify a rel that is in the query's rtable but
|
||||
* isn't referenced by the jointree so won't have a RelOptInfo. Hence
|
||||
* don't use find_base_rel() here. We can ignore such FKs.
|
||||
* isn't referenced by the jointree, or has been removed by join
|
||||
* removal, so that it won't have a RelOptInfo. Hence don't use
|
||||
* find_base_rel() here. We can ignore such FKs.
|
||||
*/
|
||||
if (fkinfo->con_relid >= root->simple_rel_array_size ||
|
||||
fkinfo->ref_relid >= root->simple_rel_array_size)
|
||||
@ -2901,8 +2902,7 @@ match_foreign_keys_to_quals(PlannerInfo *root)
|
||||
|
||||
/*
|
||||
* Ignore FK unless both rels are baserels. This gets rid of FKs that
|
||||
* link to inheritance child rels (otherrels) and those that link to
|
||||
* rels removed by join removal (dead rels).
|
||||
* link to inheritance child rels (otherrels).
|
||||
*/
|
||||
if (con_rel->reloptkind != RELOPT_BASEREL ||
|
||||
ref_rel->reloptkind != RELOPT_BASEREL)
|
||||
|
Reference in New Issue
Block a user