nocfbot-0027-Fix-comment-typos-grammar.txt
text/plain
Filename: nocfbot-0027-Fix-comment-typos-grammar.txt
Type: text/plain
Part: 26
Message:
Re: Row pattern recognition
From 809e8b5c9f79e40ee114bef963e2a902800608ed Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Tue, 7 Apr 2026 10:09:41 +0900
Subject: [PATCH 27/40] Fix comment typos, grammar, and inaccuracies in RPR
code
---
src/backend/executor/execRPR.c | 7 +++----
src/backend/executor/nodeWindowAgg.c | 20 ++++++++++----------
src/backend/optimizer/plan/createplan.c | 3 ++-
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/backend/executor/execRPR.c b/src/backend/executor/execRPR.c
index 94f1b2941a2..baee45ce54e 100644
--- a/src/backend/executor/execRPR.c
+++ b/src/backend/executor/execRPR.c
@@ -416,7 +416,6 @@
* the normal loop-back (which cycle detection will eventually kill) and
* a fast-forward exit clone that bypasses the loop entirely.
* (See IX-4(c) for detailed runtime behavior.)
- * - Empty match is impossible since body is not nullable
*
* IV-5. Absorbability Analysis (RPR_ELEM_ABSORBABLE)
*
@@ -645,8 +644,8 @@
* When processing a context whose matchStartRow differs from the shared
* value, nfa_reevaluate_dependent_vars() temporarily sets nav_match_start
* to that context's matchStartRow and re-evaluates only the dependent
- * variables. No restore is needed because contexts are ordered by
- * matchStartRow (ascending), so no later context shares the head's value.
+ * variables. The original nav_match_start and currentpos are saved and
+ * restored after re-evaluation.
*
* VI-5. Tuplestore Mark and Trim (nodeWindowAgg.c)
*
@@ -2715,7 +2714,7 @@ nfa_advance_var(WindowAggState *winstate, RPRNFAContext *ctx,
bool reluctant = RPRElemIsReluctant(elem);
/*
- * Clone state for the second-priority path. For greedy, clone is the
+ * Clone state for the first-priority path. For greedy, clone is the
* loop state; for reluctant, clone is the exit state.
*/
if (reluctant)
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index cdbe356abd7..849ebf8abb0 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -3705,8 +3705,8 @@ ignorenulls_getfuncarginframe(WindowObject winobj, int argno,
{
/*
* Early check if row could be out of reduced frame. When RPR is
- * enabled, EXCUDE clause cannot be specified and the frame is always
- * contiguous. So we can do the check followings safely. Note,
+ * enabled, EXCLUDE clause cannot be specified and the frame is always
+ * contiguous. So we can safely perform the following checks. Note,
* however, it is possible that a row is out of reduced frame if
* there's a NULL in the middle. So we need to check it in the
* following do loop.
@@ -4168,7 +4168,7 @@ eval_nav_first_offset(WindowAggState *winstate, List *defineClause)
/*
* rpr_is_defined
- * return true if Row pattern recognition is defined.
+ * Return true if row pattern recognition is defined.
*/
static bool
rpr_is_defined(WindowAggState *winstate)
@@ -4182,14 +4182,14 @@ rpr_is_defined(WindowAggState *winstate)
* Determine whether a row is in the current row's reduced window frame
* according to row pattern matching
*
- * The row must has been already determined that it is in a full window frame
- * and fetched it into slot.
+ * The row must have already been determined to be in a full window frame
+ * and fetched into the slot.
*
* Returns:
* = 0, RPR is not defined.
* >0, if the row is the first in the reduced frame. Return the number of rows
* in the reduced frame.
- * -1, if the row is unmatched row
+ * -1, if the row is an unmatched row
* -2, if the row is in the reduced frame but needed to be skipped because of
* AFTER MATCH SKIP PAST LAST ROW
* -----------------
@@ -4204,8 +4204,8 @@ row_is_in_reduced_frame(WindowObject winobj, int64 pos)
if (!rpr_is_defined(winstate))
{
/*
- * RPR is not defined. Assume that we are always in the the reduced
- * window frame.
+ * RPR is not defined. Assume that we are always in the reduced window
+ * frame.
*/
rtn = 0;
return rtn;
@@ -4938,8 +4938,8 @@ WinGetFuncArgInFrame(WindowObject winobj, int argno,
* isout: output argument, set to indicate whether target row position
* is out of frame (can pass NULL if caller doesn't care about this)
*
- * Returns 0 if we successfully got the slot. false if out of frame.
- * (also isout is set)
+ * Returns 0 if we successfully got the slot, or nonzero if out of frame.
+ * (isout is also set in the latter case.)
*/
static int
WinGetSlotInFrame(WindowObject winobj, TupleTableSlot *slot,
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 02d511269ab..50668f3b7ab 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -2475,7 +2475,8 @@ typedef struct NavOffsetContext
int64 maxOffset; /* max PREV/LAST backward offset (>= 0) */
bool maxNeedsEval; /* non-constant PREV/LAST offset found */
bool maxOverflow; /* constant offset overflow detected */
- int64 firstOffset; /* min FIRST offset (>= 0), or -1 if none */
+ int64 firstOffset; /* min FIRST offset (may be negative for
+ * PREV_FIRST) */
bool hasFirst; /* any FIRST node found */
bool firstNeedsEval; /* non-constant FIRST offset found */
} NavOffsetContext;
--
2.50.1 (Apple Git-155)