From 923a8a9f40f4f6c1cc716e257d315d937403f358 Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Sun, 28 Jun 2026 15:08:45 +0900
Subject: [PATCH] Include row positions in WindowObject mark-position error

window_gettupleslot() raises a can't-happen error when asked for a row
before the WindowObject's mark position.  Include the requested position
and the mark position in the message, which makes the diagnostic directly
useful if it ever fires.
---
 src/backend/executor/nodeWindowAgg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index f1c524d00df..9514c684ab9 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -3271,7 +3271,8 @@ window_gettupleslot(WindowObject winobj, int64 pos, TupleTableSlot *slot)
 		return false;
 
 	if (pos < winobj->markpos)
-		elog(ERROR, "cannot fetch row before WindowObject's mark position");
+		elog(ERROR, "cannot fetch row: " INT64_FORMAT " before WindowObject's mark position: " INT64_FORMAT,
+			 pos, winobj->markpos);
 
 	oldcontext = MemoryContextSwitchTo(winstate->ss.ps.ps_ExprContext->ecxt_per_query_memory);
 
-- 
2.50.1 (Apple Git-155)

