public inbox for [email protected]  
help / color / mirror / Atom feed
Minor refactor of the code in ExecScanExtended()
3+ messages / 3 participants
[nested] [flat]

* Minor refactor of the code in ExecScanExtended()
@ 2025-11-07 14:00  =?utf-8?B?Y2NhNTUwNw==?= <[email protected]>
  0 siblings, 2 replies; 3+ messages in thread

From: =?utf-8?B?Y2NhNTUwNw==?= @ 2025-11-07 14:00 UTC (permalink / raw)
  To: =?utf-8?B?cGdzcWwtaGFja2Vycw==?= <[email protected]>

Hi,


The current code:


      if (!qual &amp;&amp; !projInfo)
      {
            ResetExprContext(econtext);
            return ExecScanFetch(node, epqstate, accessMtd, recheckMtd);
      }


      ResetExprContext(econtext);


The following format might be simpler:


      ResetExprContext(econtext);


      if (!qual &amp;&amp; !projInfo)
            return ExecScanFetch(node, epqstate, accessMtd, recheckMtd);


Attach a patch to do this.


--
Regards,
ChangAo Chen

Attachments:

  [application/octet-stream] v1-0001-Minor-refactor-of-the-code-in-ExecScanExtended.patch (1.3K, 3-v1-0001-Minor-refactor-of-the-code-in-ExecScanExtended.patch)
  download | inline diff:
From b7a5362fccb82820c6e1b05d4e3d44d64acc2844 Mon Sep 17 00:00:00 2001
From: ChangAo Chen <[email protected]>
Date: Fri, 7 Nov 2025 21:55:38 +0800
Subject: [PATCH v1] Minor refactor of the code in ExecScanExtended()

---
 src/include/executor/execScan.h | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/include/executor/execScan.h b/src/include/executor/execScan.h
index 2003cbc7ed5..53a896439ca 100644
--- a/src/include/executor/execScan.h
+++ b/src/include/executor/execScan.h
@@ -168,21 +168,18 @@ ExecScanExtended(ScanState *node,
 
 	/* interrupt checks are in ExecScanFetch */
 
+	/*
+	 * Reset per-tuple memory context to free any expression evaluation
+	 * storage allocated in the previous tuple cycle.
+	 */
+	ResetExprContext(econtext);
+
 	/*
 	 * If we have neither a qual to check nor a projection to do, just skip
 	 * all the overhead and return the raw scan tuple.
 	 */
 	if (!qual && !projInfo)
-	{
-		ResetExprContext(econtext);
 		return ExecScanFetch(node, epqstate, accessMtd, recheckMtd);
-	}
-
-	/*
-	 * Reset per-tuple memory context to free any expression evaluation
-	 * storage allocated in the previous tuple cycle.
-	 */
-	ResetExprContext(econtext);
 
 	/*
 	 * get a tuple from the access method.  Loop until we obtain a tuple that
-- 
2.51.2



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Minor refactor of the code in ExecScanExtended()
@ 2026-03-25 01:53  Henson Choi <[email protected]>
  parent: =?utf-8?B?Y2NhNTUwNw==?= <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: Henson Choi @ 2026-03-25 01:53 UTC (permalink / raw)
  To: Aditya Gollamudi <[email protected]>; cca5507 <[email protected]>; +Cc: pgsql-hackers <[email protected]>

Hi hackers,

2026년 1월 19일 (월) PM 1:51, Aditya Gollamudi <[email protected]>님이 작성:

> On Sun, Jan 18, 2026 at 7:31 PM cca5507 <[email protected]> wrote:
>
>> Hi,
>>
>> The current code:
>>
>> if (!qual && !projInfo)
>> {
>> ResetExprContext(econtext);
>> return ExecScanFetch(node, epqstate, accessMtd, recheckMtd);
>> }
>>
>> ResetExprContext(econtext);
>>
>> The following format might be simpler:
>>
>> ResetExprContext(econtext);
>>
>> if (!qual && !projInfo)
>> return ExecScanFetch(node, epqstate, accessMtd, recheckMtd);
>>
>> Attach a patch to do this.
>>
>> --
>> Regards,
>> ChangAo Chen
>>
>> Hi,
>
> +1, seems like a simple refactor.
> Tests are passing locally for me!
>
> - Adi Gollamudi
>

+1, agreed.

The refactored version is cleaner and easier to read by moving
ResetExprContext() before the early return,
eliminating the duplicated logic.

Best regards,
Henson


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Minor refactor of the code in ExecScanExtended()
@ 2026-03-25 01:58  Michael Paquier <[email protected]>
  parent: =?utf-8?B?Y2NhNTUwNw==?= <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: Michael Paquier @ 2026-03-25 01:58 UTC (permalink / raw)
  To: cca5507 <[email protected]>; +Cc: pgsql-hackers <[email protected]>

On Fri, Nov 07, 2025 at 10:00:15PM +0800, cca5507 wrote:
> Attach a patch to do this.

There is no benefit in this change: the current code is fine.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, 2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-03-25 01:58 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-11-07 14:00 Minor refactor of the code in ExecScanExtended() =?utf-8?B?Y2NhNTUwNw==?= <[email protected]>
2026-03-25 01:53 ` Henson Choi <[email protected]>
2026-03-25 01:58 ` Michael Paquier <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox