nocfbot-0023-Explain-the-completed-head-context-branch-in-upda.txt

text/plain

Filename: nocfbot-0023-Explain-the-completed-head-context-branch-in-upda.txt
Type: text/plain
Part: 23
Message: Re: Row pattern recognition
From 3a64a070fc113d9c90f8ec5b17121203b32658a3 Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Fri, 29 May 2026 17:56:02 +0900
Subject: [PATCH 23/26] Explain the completed-head-context branch in
 update_reduced_frame per Jian He's review

ExecRPRGetHeadContext() can return a context whose state list is already
drained, and the branch handling it looked unreachable.  It fires under
SKIP TO NEXT ROW: overlapping contexts let one reach FIN, and record its
result, during an earlier call -- before the call asking about its own
start row arrives.  Comment only; no behavior change.
---
 src/backend/executor/nodeWindowAgg.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 4cf1a9ac67b..f16d01e9743 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -4434,7 +4434,12 @@ update_reduced_frame(WindowObject winobj, int64 pos)
 	}
 	else if (targetCtx->states == NULL)
 	{
-		/* Context already completed - skip to result registration */
+		/*
+		 * The head context already completed in an earlier call.  Reachable
+		 * under SKIP TO NEXT ROW, where overlapping contexts let one reach
+		 * FIN -- recording its result -- before the call for its own start
+		 * row arrives.  Register that result.
+		 */
 		goto register_result;
 	}
 
-- 
2.50.1 (Apple Git-155)