postgres.git / summary / log / commit / refs
commit 159bf0f31b59f7ef7f4bc6c3f57a5187f6a96947
Author: Noah Misch <noah@leadboat.com>
Date: Sun Sep 29 22:54:25 2024 +0000
First released in: 18.0, 12.21, 13.17, 14.14, 15.9, 16.5, 17.1
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.
src/backend/commands/tablecmds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index f3050d8a1d2..e6c911fd9a4 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -3893,9 +3893,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)
[parent: 7f90b727422b]