aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-05-05 12:44:32 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-05-05 12:44:32 -0400
commit62148c3520b562e518f17134b22120bab0cb113b (patch)
tree7c462dca7bba75bf8aaee02b4a99329704948835
parent84e4570da9230d45022ef77f98b560f26eaf6916 (diff)
downloadpostgresql-62148c3520b562e518f17134b22120bab0cb113b.tar.gz
postgresql-62148c3520b562e518f17134b22120bab0cb113b.zip
Add check for syscache lookup failure in update_relispartition().
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.
-rw-r--r--src/backend/commands/indexcmds.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index fabba3bacd1..26f3b2cd7a4 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -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);
}