Remove redundant initialization of smgr pointer for relcache

Started by Jingtang Zhang2 months ago1 messages
#1Jingtang Zhang
mrdrivingduck@gmail.com
1 attachment(s)

Hi~

We seem to have a reduntant initialization of rd_smgr for a newly created
relcache entry. Commonly, the pointer is assigned as NULL after a relcache
is palloc'ed. But this one seems unnecessary because the rd_smgr has already
been initialized by earlier AllocateRelationDesc. Propose a patch for it.

--
Regards, Jingtang

Attachments:

0001-Remove-redundant-initialization-of-smgr-pointer-for-.patchapplication/octet-stream; name=0001-Remove-redundant-initialization-of-smgr-pointer-for-.patch; x-unix-mode=0644Download
From 117de27919ca51a849cb2812a4bfef135e3666b1 Mon Sep 17 00:00:00 2001
From: Jingtang Zhang <mrdrivingduck@gmail.com>
Date: Tue, 11 Nov 2025 00:04:24 +0800
Subject: [PATCH] Remove redundant initialization of smgr pointer for relcache

The smgr object pointer of a relcache is commonly initialized after the
RelationData is palloc'ed. This commit removes a redundant assign.
---
 src/backend/utils/cache/relcache.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 915d0bc9084..1ed08687e08 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -1275,9 +1275,6 @@ retry:
 	 */
 	RelationInitPhysicalAddr(relation);
 
-	/* make sure relation is marked as having no open file yet */
-	relation->rd_smgr = NULL;
-
 	/*
 	 * now we can free the memory allocated for pg_class_tuple
 	 */
-- 
2.50.1 (Apple Git-155)