diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2023-02-13 13:35:38 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2023-02-13 13:35:38 -0500 |
commit | e9a20e451f3aa0b64da807338012c65d8664d0ac (patch) | |
tree | ed030524aca96c5c13e3d3cd3bef3260dbf6310c /src/backend/optimizer/plan/initsplan.c | |
parent | c7468c73f7b6e842a53c12eaee5578a76a8fa7a6 (diff) |
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
Diffstat (limited to 'src/backend/optimizer/plan/initsplan.c')
-rw-r--r-- | src/backend/optimizer/plan/initsplan.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index 2b2c6af9ef8..fe4c8c63c95 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -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) |