diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index d5cba9a13c8d059eb618cb14b20e9893b9c20976..1d9844924138b001a76a974d5e697a4aaa6809ee 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -1951,9 +1951,13 @@ RelationClearRelation(Relation relation, bool rebuild) newrel = RelationBuildDesc(save_relid, false); if (newrel == NULL) { - /* Should only get here if relation was deleted */ - RelationCacheDelete(relation); - RelationDestroyRelation(relation); + /* + * This shouldn't happen as dropping a relation is intended to be + * impossible if still referenced (c.f. CheckTableNotInUse()). But + * if we get here anyway, we can't just delete the relcache entry, + * as it possibly could get accessed later (as e.g. the error + * might get trapped and handled via a subtransaction rollback). + */ elog(ERROR, "relation %u deleted while still in use", save_relid); }