nocfbot-0039-Apply-pgindent-RPR-comment-blocks.txt

text/plain

Filename: nocfbot-0039-Apply-pgindent-RPR-comment-blocks.txt
Type: text/plain
Part: 38
Message: Re: Row pattern recognition
From 441039aba513d6ff0f4de79c8e3a8765f0fbaa73 Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Sat, 2 May 2026 01:17:16 +0900
Subject: [PATCH 39/40] Apply pgindent canonicalization to RPR comment blocks

Two RPR source files carried comment blocks that pre-dated their
last pgindent pass: execRPR.c (in nfa_match and nfa_advance_end)
and rpr.c (in tryMultiplyQuantifiers).  Run pgindent to bring the
prose paragraphs into line with the project-wide 78-column style.

For two of those blocks the structure is meaningful (numbered list
in nfa_advance_end, "Case 2 / Case 3 / Unsafe example" labels in
tryMultiplyQuantifiers), so the labeled items are wrapped in
/*---------- ... *---------- ... */ to disable pgindent reflow on
the hanging indents while leaving plain prose paragraphs inside
the same block at the canonical 78-column wrap.

These adjustments were deferred from earlier delta patches in this
series (Use Max()/Min() macros, Replace non-ASCII characters) so
those patches could remain focused on their stated logical changes.
With the design notes now extracted into README.rpr, this is a
natural moment to clear the remaining formatting debt.

Whitespace-only change; no functional or test impact.
---
 src/backend/executor/execRPR.c   | 30 +++++++++++++++---------------
 src/backend/optimizer/plan/rpr.c |  9 +++++----
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/src/backend/executor/execRPR.c b/src/backend/executor/execRPR.c
index 96cfbfbc0a2..242ae9c6dcf 100644
--- a/src/backend/executor/execRPR.c
+++ b/src/backend/executor/execRPR.c
@@ -810,10 +810,10 @@ nfa_match(WindowAggState *winstate, RPRNFAContext *ctx, bool *varMatched)
 				 * to the next outer END.  The loop below walks this chain.
 				 *
 				 * ABSORBABLE_BRANCH marks elements inside the absorbable
-				 * region; ABSORBABLE marks the outermost judgment point
-				 * where count-dominance is evaluated.  We chain through
-				 * BRANCH elements until reaching the ABSORBABLE point or
-				 * an element that can still loop (count < max).
+				 * region; ABSORBABLE marks the outermost judgment point where
+				 * count-dominance is evaluated.  We chain through BRANCH
+				 * elements until reaching the ABSORBABLE point or an element
+				 * that can still loop (count < max).
 				 */
 				if (RPRElemIsAbsorbableBranch(elem) &&
 					!RPRElemIsAbsorbable(elem) &&
@@ -1035,9 +1035,9 @@ nfa_advance_end(WindowAggState *winstate, RPRNFAContext *ctx,
 		RPRPatternElement *jumpElem;
 		RPRNFAState *ffState = NULL;
 
-		/*
-		 * Two paths are explored in parallel when the group body is
-		 * nullable (RPR_ELEM_EMPTY_LOOP):
+		/*----------
+		 * Two paths are explored in parallel when the group body is nullable
+		 * (RPR_ELEM_EMPTY_LOOP):
 		 *
 		 * 1. Primary path: loop back and attempt real matches in the
 		 *    next iteration (state, modified below).
@@ -1046,8 +1046,9 @@ nfa_advance_end(WindowAggState *winstate, RPRNFAContext *ctx,
 		 *    treating all remaining required iterations as empty
 		 *    matches (ffState, handled after the primary path).
 		 *
-		 * The snapshot must be taken BEFORE modifying state for the
-		 * loop-back, since both paths diverge from the same point.
+		 * The snapshot must be taken BEFORE modifying state for the loop-back,
+		 * since both paths diverge from the same point.
+		 *----------
 		 */
 		if (RPRElemCanEmptyLoop(elem))
 			ffState = nfa_state_create(winstate, state->elemIdx,
@@ -1062,12 +1063,11 @@ nfa_advance_end(WindowAggState *winstate, RPRNFAContext *ctx,
 						  currentPos);
 
 		/*
-		 * Fast-forward path for nullable bodies.  E.g. (A?){2,3} when
-		 * A doesn't match: the primary loop-back produces empty
-		 * iterations that cycle detection would kill.  Instead, exit
-		 * directly with count satisfied.  Route to elem->next (not
-		 * nfa_advance_end) to avoid creating competing greedy/reluctant
-		 * loop states.
+		 * Fast-forward path for nullable bodies.  E.g. (A?){2,3} when A
+		 * doesn't match: the primary loop-back produces empty iterations that
+		 * cycle detection would kill.  Instead, exit directly with count
+		 * satisfied.  Route to elem->next (not nfa_advance_end) to avoid
+		 * creating competing greedy/reluctant loop states.
 		 */
 		if (ffState != NULL)
 		{
diff --git a/src/backend/optimizer/plan/rpr.c b/src/backend/optimizer/plan/rpr.c
index 754fcd53099..2543170c374 100644
--- a/src/backend/optimizer/plan/rpr.c
+++ b/src/backend/optimizer/plan/rpr.c
@@ -825,7 +825,7 @@ tryMultiplyQuantifiers(RPRPatternNode *pattern)
 		return child;
 	}
 
-	/*
+	/*----------
 	 * Case 2: Outer exact (min == max): (A{2,3}){4} -> A{8,12}.
 	 *         Safe because every iteration produces the same range.
 	 *
@@ -833,9 +833,10 @@ tryMultiplyQuantifiers(RPRPatternNode *pattern)
 	 *         Safe because the child contributes exactly one per
 	 *         iteration, so the outer range maps directly.
 	 *
-	 * Unsafe example: (A{2}){2,3} produces counts 4 or 6 only, not
-	 * the full range 4..6, so we cannot flatten when child has a
-	 * non-trivial range AND outer is also a range.
+	 * Unsafe example: (A{2}){2,3} produces counts 4 or 6 only, not the full
+	 * range 4..6, so we cannot flatten when child has a non-trivial range AND
+	 * outer is also a range.
+	 *----------
 	 */
 	if (child->max != RPR_QUANTITY_INF &&
 		(pattern->min == pattern->max ||
-- 
2.50.1 (Apple Git-155)