Minor refactor of the code in ExecScanExtended()

Started by cca55072 months ago1 messages
#1cca5507
cca5507@qq.com
1 attachment(s)

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

Attachments:

v1-0001-Minor-refactor-of-the-code-in-ExecScanExtended.patchapplication/octet-stream; charset=utf-8; name=v1-0001-Minor-refactor-of-the-code-in-ExecScanExtended.patchDownload
From b7a5362fccb82820c6e1b05d4e3d44d64acc2844 Mon Sep 17 00:00:00 2001
From: ChangAo Chen <cca5507@qq.com>
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