0007-Run-pgindent-on-RPR-source-files.txt
text/plain
Filename: 0007-Run-pgindent-on-RPR-source-files.txt
Type: text/plain
Part: 5
Message:
Re: Row pattern recognition
From 74205caae63e95c8d237491a821ba07356ac18b2 Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Sat, 14 Feb 2026 22:34:39 +0900
Subject: [PATCH 1/1] Run pgindent on RPR source files
---
src/backend/executor/nodeWindowAgg.c | 32 +++++++++++++++-------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index b7b87f65b47..9b2c4b6a1d7 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -5108,9 +5108,9 @@ nfa_process_row(WindowAggState *winstate, int64 currentPos,
/*
* Phase 1 already handled frame boundary exceeded contexts by forcing
- * mismatch (nfa_match with NULL), which removes all states (all states
- * are at VAR positions after advance). So any surviving context here
- * must be within its frame boundary.
+ * mismatch (nfa_match with NULL), which removes all states (all
+ * states are at VAR positions after advance). So any surviving
+ * context here must be within its frame boundary.
*/
Assert(!hasLimitedFrame ||
currentPos < ctx->matchStartRow + frameOffset + 1);
@@ -5235,7 +5235,7 @@ nfa_states_equal(WindowAggState *winstate, RPRNFAState *s1, RPRNFAState *s2)
/* Compare counts up to current element's depth */
elem = &pattern->elements[s1->elemIdx];
- compareDepth = elem->depth + 1; /* depth 0 needs 1 count, etc. */
+ compareDepth = elem->depth + 1; /* depth 0 needs 1 count, etc. */
if (compareDepth > 0 &&
memcmp(s1->counts, s2->counts, sizeof(int32) * compareDepth) != 0)
@@ -5328,14 +5328,14 @@ nfa_add_matched_state(WindowAggState *winstate, RPRNFAContext *ctx,
state->next = NULL;
ctx->matchEndRow = matchEndRow;
- /*
+ /*----------
* SKIP PAST LAST ROW: eagerly prune contexts within match range.
*
* This function is called whenever a FIN state is reached, including
- * during greedy matching when intermediate (shorter) matches are found.
- * Each time we update matchEndRow (whether extending a greedy match or
- * finding a new match), we can prune pending contexts that started
- * within the current match range.
+ * during greedy matching when intermediate (shorter) matches are
+ * found. Each time we update matchEndRow (whether extending a greedy
+ * match or finding a new match), we can prune pending contexts that
+ * started within the current match range.
*
* SKIP PAST LAST ROW uses lexical order (matchStartRow). Therefore,
* any pending context that started at or before matchEndRow can never
@@ -5349,6 +5349,7 @@ nfa_add_matched_state(WindowAggState *winstate, RPRNFAContext *ctx,
* - Matches START UP (rows 1-2) → matchEndRow=2 → prune Context B(row 2)
* - Matches START UP UP (rows 1-3) → matchEndRow=3 → prune Context C(row 3)
* - Continues greedy extension while pruning incrementally
+ *----------
*/
if (winstate->rpSkipTo == ST_PAST_LAST_ROW)
{
@@ -5553,8 +5554,8 @@ nfa_get_head_context(WindowAggState *winstate, int64 pos)
RPRNFAContext *ctx = winstate->nfaContext;
/*
- * Contexts are sorted by matchStartRow ascending. If the head
- * context doesn't match pos, no context exists for this position.
+ * Contexts are sorted by matchStartRow ascending. If the head context
+ * doesn't match pos, no context exists for this position.
*/
if (ctx == NULL || ctx->matchStartRow != pos)
return NULL;
@@ -6075,9 +6076,9 @@ nfa_match(WindowAggState *winstate, RPRNFAContext *ctx, bool *varMatched)
/*
* END's max can never be exceeded here because
- * nfa_advance_end only loops when count < max,
- * so endCount entering inline advance is at most
- * max-1, and incrementing yields at most max.
+ * nfa_advance_end only loops when count < max, so
+ * endCount entering inline advance is at most max-1, and
+ * incrementing yields at most max.
*/
Assert(endElem->max == RPR_QUANTITY_INF ||
endCount <= endElem->max);
@@ -6251,7 +6252,7 @@ nfa_advance_end(WindowAggState *winstate, RPRNFAContext *ctx,
else if ((elem->max != RPR_QUANTITY_INF && count >= elem->max) ||
(count == 0 && elem->min == 0))
{
- /*
+ /*----------
* Must exit: either reached max iterations, or group matched empty.
*
* FIXME: The (count == 0 && min == 0) condition is insufficient for
@@ -6265,6 +6266,7 @@ nfa_advance_end(WindowAggState *winstate, RPRNFAContext *ctx,
* Currently, cycles are silently prevented by nfa_add_state_unique
* detecting duplicate states, but this is implicit and not guaranteed
* for all code paths. Explicit cycle detection is needed.
+ *----------
*/
RPRPatternElement *nextElem;
--
2.50.1 (Apple Git-155)