v50-0013-doc-nav-offset.patch

application/octet-stream

Filename: v50-0013-doc-nav-offset.patch
Type: application/octet-stream
Part: 21
Message: Re: Row pattern recognition

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v50-0013
Subject: Document eval_nav_offset_helper's NULL/negative offset handling
File+
src/backend/executor/nodeWindowAgg.c 9 4
From 4abf15f9354b4857a704772d9e1edf167bc0586e Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Fri, 19 Jun 2026 14:17:19 +0900
Subject: [PATCH v50 22/29] Document eval_nav_offset_helper's NULL/negative
 offset handling

eval_nav_offset_helper pre-evaluates a navigation offset at executor init
to size the frame trim, returning 0 for a NULL or negative offset rather
than rejecting it.  The comment did not say why, leaving the purpose of the
function and of those branches unclear.

Explain that a NULL or negative offset is caught per row on the navigation
path that consumes it, which errors out before navigation produces any
result, so the trim value computed here is never used.  The branches are
reachable -- a navigation offset can be a run-time constant such as a Param
-- and are already covered by the PREV(price, $1) tests in rpr.sql, so they
need neither a new test nor an assertion.
---
 src/backend/executor/nodeWindowAgg.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 819ad814bf5..eb1d616b49a 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -3985,10 +3985,15 @@ put_notnull_info(WindowObject winobj, int64 pos, int argno, bool isnull)
 
 /*
  * eval_nav_offset_helper
- *		Evaluate an offset expression at executor init time for trim
- *		optimization.  Returns the offset value, or 0 for NULL/negative
- *		(these will cause a runtime error during actual navigation, so the
- *		trim value is irrelevant).
+ *		Pre-evaluate a navigation offset expression at executor init time, to
+ *		bound how far navigation can reach (which sizes the frame trim).
+ *		Returns the offset value, or 0 for a NULL or negative offset.
+ *
+ * The offset is not validated here.  A NULL or negative value is caught later,
+ * per row, on the navigation path that consumes it (see EEOP_RPR_NAV_SET in
+ * execExprInterp.c), which errors out before navigation produces any result;
+ * the trim sizing computed from such an offset is therefore never used, and 0
+ * is returned as a harmless placeholder.
  */
 static int64
 eval_nav_offset_helper(WindowAggState *winstate, Expr *offset_expr,
-- 
2.50.1 (Apple Git-155)