nocfbot-0063-Tidy-up-formatting-in-row-pattern-recognition-cod.txt

text/plain

Filename: nocfbot-0063-Tidy-up-formatting-in-row-pattern-recognition-cod.txt
Type: text/plain
Part: 61
Message: Re: Row pattern recognition
From a4b58172b6f7f2f4a3e15c75dc2510b706fb6324 Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Mon, 8 Jun 2026 13:48:10 +0900
Subject: [PATCH 63/68] Tidy up formatting in row pattern recognition code

Reformat the first three row_pattern_quantifier_opt alternatives as
multiline blocks to match the rest of the rule, change the RF_* reduced
frame macros from a tab to a space after #define, add a trailing comma to
the last RPSkipTo enumerator, and move the RPRNav* entries to their correct
C-collation position in typedefs.list.  These are formatting and alignment
changes only, with no effect on behavior.
---
 src/backend/optimizer/plan/rpr.c |  2 +-
 src/backend/parser/gram.y        | 14 +++++++++++---
 src/include/nodes/execnodes.h    | 10 +++++-----
 src/include/nodes/parsenodes.h   |  2 +-
 src/tools/pgindent/typedefs.list |  6 +++---
 5 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/src/backend/optimizer/plan/rpr.c b/src/backend/optimizer/plan/rpr.c
index e7276c42ca6..143ea034fb3 100644
--- a/src/backend/optimizer/plan/rpr.c
+++ b/src/backend/optimizer/plan/rpr.c
@@ -484,7 +484,7 @@ mergeConsecutiveAlts(List *children)
  *
  * When a GROUP's children appear as a prefix before and/or suffix after
  * the GROUP in a SEQ, merge them by incrementing the GROUP's quantifier.
- * This runs iteratively: A B A B (A B)+ A B -> (A B){5,}.
+ * This runs iteratively: A B A B (A B)+ A B -> (A B){4,}.
  *
  * Algorithm:
  *   For each GROUP encountered in the sequence:
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 147b5f37293..e0799f35638 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -17740,9 +17740,17 @@ row_pattern_primary:
 row_pattern_quantifier_opt:
 			/* EMPTY - no quantifier means exactly once; @$ is unused since
 			 * min=max=1 never produces an error */
-			{ $$ = (Node *) makeRPRQuantifier(1, 1, -1, @$, yyscanner); }
-			| '*'					{ $$ = (Node *) makeRPRQuantifier(0, INT_MAX, -1, @1, yyscanner); }
-			| '+'					{ $$ = (Node *) makeRPRQuantifier(1, INT_MAX, -1, @1, yyscanner); }
+				{
+					$$ = (Node *) makeRPRQuantifier(1, 1, -1, @$, yyscanner);
+				}
+			| '*'
+				{
+					$$ = (Node *) makeRPRQuantifier(0, INT_MAX, -1, @1, yyscanner);
+				}
+			| '+'
+				{
+					$$ = (Node *) makeRPRQuantifier(1, INT_MAX, -1, @1, yyscanner);
+				}
 			| Op
 				{
 					/* Handle single Op: ? or reluctant quantifiers *?, +?, ?? */
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 141ab91caf5..771d095209f 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -2529,11 +2529,11 @@ typedef enum WindowAggStatus
 } WindowAggStatus;
 
 /* RPR reduced frame states returned by get_reduced_frame_status() */
-#define	RF_NOT_DETERMINED	0	/* not yet processed */
-#define	RF_FRAME_HEAD		1	/* start row of a match */
-#define	RF_SKIPPED			2	/* interior row of a match */
-#define	RF_UNMATCHED		3	/* no match at this row */
-#define	RF_EMPTY_MATCH		4	/* empty match (0 rows); treated as unmatched */
+#define RF_NOT_DETERMINED	0	/* not yet processed */
+#define RF_FRAME_HEAD		1	/* start row of a match */
+#define RF_SKIPPED			2	/* interior row of a match */
+#define RF_UNMATCHED		3	/* no match at this row */
+#define RF_EMPTY_MATCH		4	/* empty match (0 rows); treated as unmatched */
 
 /*
  * RPRNFAState - single NFA state for pattern matching
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index e371f04a403..9636a8efca1 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -589,7 +589,7 @@ typedef enum RPSkipTo
 	ST_NONE,					/* no AFTER MATCH clause; default for non-RPR
 								 * windows */
 	ST_NEXT_ROW,				/* SKIP TO NEXT ROW */
-	ST_PAST_LAST_ROW			/* SKIP TO PAST LAST ROW */
+	ST_PAST_LAST_ROW,			/* SKIP TO PAST LAST ROW */
 } RPSkipTo;
 
 /*
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 24cf2eb7860..06cd541be5b 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -2519,9 +2519,6 @@ QuerySource
 QueueBackendStatus
 QueuePosition
 QuitSignalReason
-RPRNavExpr
-RPRNavKind
-RPRNavOffsetKind
 RBTNode
 RBTOrderControl
 RBTree
@@ -2540,6 +2537,9 @@ RPRElemFlags
 RPRElemIdx
 RPRNFAContext
 RPRNFAState
+RPRNavExpr
+RPRNavKind
+RPRNavOffsetKind
 RPRPattern
 RPRPatternElement
 RPRPatternNode
-- 
2.50.1 (Apple Git-155)