]> granicus.if.org Git - postgresql/commitdiff
Fix access to just-closed relcache entry.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 11 Jun 2018 23:17:50 +0000 (19:17 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 11 Jun 2018 23:17:50 +0000 (19:17 -0400)
It might be impossible for this to cause a problem in non-debug builds,
since there'd be no opportunity for the relcache entry to get recycled
before the fetch.  It blows up nicely with -DRELCACHE_FORCE_RELEASE plus
valgrind, though.

Evidently introduced by careless refactoring in commit f0e44751d.
Back-patch accordingly.

Discussion: https://postgr.es/m/27543.1528758304@sss.pgh.pa.us

src/backend/commands/tablecmds.c

index cb7d8667103eec09b9a8c2566a684cab4136167d..215c2b47c8e019179f3f9d0afff2b27f75bb4d40 100644 (file)
@@ -11502,12 +11502,12 @@ ATExecDropInherit(Relation rel, RangeVar *parent, LOCKMODE lockmode)
        /* Off to RemoveInheritance() where most of the work happens */
        RemoveInheritance(rel, parent_rel);
 
-       /* keep our lock on the parent relation until commit */
-       heap_close(parent_rel, NoLock);
-
        ObjectAddressSet(address, RelationRelationId,
                                         RelationGetRelid(parent_rel));
 
+       /* keep our lock on the parent relation until commit */
+       heap_close(parent_rel, NoLock);
+
        return address;
 }