Hi,

> Some details from postmaster.log:
> ==2296443== Conditional jump or move depends on uninitialised value(s)
> ==2296443==    at 0x434D3E6: cost_material (costsize.c:2593)
> ==2296443==    by 0x436E869: materialize_finished_plan (createplan.c:6531)
> [...]
> **2296443** Valgrind detected 1 error(s) during execution of "explain
> (costs off) declare c1 scroll cursor for select (select 42) as x;"
> **2296443** Valgrind detected 1 error(s) during execution of "declare
> c1 scroll cursor for select (select 42) as x;"
>
> So it looks like this is missing some initialization, causing valgrind
> to complain.

I tested an alternative solution based on memset() and it makes
Valgrind happy (tested on Linux x64), while all the tests pass.


--
Best regards,
Aleksander Alekseev
From 14eb37ffae650bf3b33f4274bcd84984c89db607 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <[email protected]>
Date: Thu, 29 Jan 2026 16:11:50 +0300
Subject: [PATCH v1] Initialize mathpath variable in
 materialize_finished_plan()

---
 src/backend/optimizer/plan/createplan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index c26e841f537..41df7d488bb 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -6526,8 +6526,7 @@ materialize_finished_plan(Plan *subplan)
 	subplan->startup_cost -= initplan_cost;
 	subplan->total_cost -= initplan_cost;
 
-	/* Set cost data */
-	matpath.parent = NULL;
+	memset(&matpath, 0, sizeof(matpath));
 	cost_material(&matpath,
 				  enable_material,
 				  subplan->disabled_nodes,
-- 
2.43.0

Reply via email to