From 24c4f39d838310760cf5f65f0ee9fede07b05c5b Mon Sep 17 00:00:00 2001 From: reshke Date: Mon, 22 Dec 2025 10:53:22 +0000 Subject: [PATCH] Beautify `UpdateCatalogForStandbyPromotion`. Some variable declaration to beginning of function to enforce C90 and long-standing coding practice of PostgreSQL. Also, be tidy, and release memory allocated in GetDatabasePath. This is not a real memory leak, as standby promotion happends only once (until next restart). Per coverity report 529246. --- src/backend/access/transam/xlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 034aeb6473b..cff69879aa1 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6528,6 +6528,7 @@ static void UpdateCatalogForStandbyPromotion(void) { GpRoleValue old_role; + char *fullpath; /* * NOTE: The following initialization logic was borrowed from ftsprobe. */ @@ -6599,8 +6600,6 @@ UpdateCatalogForStandbyPromotion(void) */ RelationCacheInitializePhase2(); - char *fullpath; - /* * In order to access the catalog, we need a database, and a * tablespace; our access to the heap is going to be slightly @@ -6620,6 +6619,7 @@ UpdateCatalogForStandbyPromotion(void) fullpath = GetDatabasePath(MyDatabaseId, MyDatabaseTableSpace); SetDatabasePath(fullpath); + pfree(fullpath); RelationCacheInitializePhase3();