Hi,

While discussing [1], I was reading execUtils.c, then I noticed this redundant local variable assignment in CreateWorkExprContext(). The attached patch fixed that.

[1]: https://www.postgresql.org/message-id/caa4ek1+seus_6vqay9tf_r4ow+e-q7lynlfsd78haoslsgp...@mail.gmail.com

Best regards,

--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
From 5b5462398117acd0203e760b7bf18c4ff616cf81 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <[email protected]>
Date: Thu, 21 Aug 2025 11:35:18 +0800
Subject: [PATCH v1] Remove redundant assignemnt in CreateWorkExprContext

In CreateWorkExprContext(), maxBlockSize is initialized to
ALLOCSET_DEFAULT_MAXSIZE, and it then immediately reassigned,
thus the initialization is a redundant.

Author: Chao Li <[email protected]>
---
 src/backend/executor/execUtils.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index fdc65c2b42b..07b67d65b40 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -321,9 +321,7 @@ CreateExprContext(EState *estate)
 ExprContext *
 CreateWorkExprContext(EState *estate)
 {
-       Size            maxBlockSize = ALLOCSET_DEFAULT_MAXSIZE;
-
-       maxBlockSize = pg_prevpower2_size_t(work_mem * (Size) 1024 / 16);
+       Size            maxBlockSize = pg_prevpower2_size_t(work_mem * (Size) 
1024 / 16);
 
        /* But no bigger than ALLOCSET_DEFAULT_MAXSIZE */
        maxBlockSize = Min(maxBlockSize, ALLOCSET_DEFAULT_MAXSIZE);
-- 
2.39.5 (Apple Git-154)

Reply via email to