summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2024-09-29 15:54:25 -0700
committerNoah Misch <noah@leadboat.com>2024-09-29 15:54:30 -0700
commit5a33a39a8bb4540e760110202853aded611b1e7c (patch)
treed1e70d3e6d4b3e32d6b0a5fd5b5216db99843d75
parent91e5add02ba98ab3d46db6d3b457d6fd084f1ae3 (diff)
Remove NULL dereference from RenameRelationInternal().
Defect in last week's commit aac2c9b4fde889d13f859c233c2523345e72d32b, per Coverity. Reaching this would need catalog corruption. Back-patch to v12, like that commit.
-rw-r--r--src/backend/commands/tablecmds.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 346dc587d7c..ff2b36d6699 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -3640,9 +3640,9 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
relrelation = table_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheLockedCopy1(RELOID, ObjectIdGetDatum(myrelid));
- otid = reltup->t_self;
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", myrelid);
+ otid = reltup->t_self;
relform = (Form_pg_class) GETSTRUCT(reltup);
if (get_relname_relid(newrelname, namespaceId) != InvalidOid)