]> granicus.if.org Git - postgresql/commitdiff
Add check for syscache lookup failure in update_relispartition().
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 5 May 2019 16:44:32 +0000 (12:44 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 5 May 2019 16:44:32 +0000 (12:44 -0400)
Omitted in commit 05b38c7e6 (though it looks like the original blame
belongs to 9e9befac4).  A failure is admittedly unlikely, but if it
did happen, SIGSEGV is not the approved method of reporting it.

Per Coverity.  Back-patch to v11 where the broken code originated.

src/backend/commands/indexcmds.c

index fabba3bacd1d39bbb0ed1f5c62e2e7e5fbe3aea9..26f3b2cd7a43e3c6d9f4213b2c3a70ac4a3fa880 100644 (file)
@@ -3451,10 +3451,11 @@ update_relispartition(Oid relationId, bool newval)
 
        classRel = table_open(RelationRelationId, RowExclusiveLock);
        tup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
+       if (!HeapTupleIsValid(tup))
+               elog(ERROR, "cache lookup failed for relation %u", relationId);
        Assert(((Form_pg_class) GETSTRUCT(tup))->relispartition != newval);
        ((Form_pg_class) GETSTRUCT(tup))->relispartition = newval;
        CatalogTupleUpdate(classRel, &tup->t_self, tup);
        heap_freetuple(tup);
-
        table_close(classRel, RowExclusiveLock);
 }