nocfbot-0015-Remove-redundant-nfa_add_matched_state.txt
text/plain
Filename: nocfbot-0015-Remove-redundant-nfa_add_matched_state.txt
Type: text/plain
Part: 14
Message:
Re: Row pattern recognition
From a224ed18261a09d5b1e65aba3c97fc5741234589 Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Fri, 20 Mar 2026 22:11:30 +0900
Subject: [PATCH] Remove redundant list manipulation in nfa_add_matched_state
nfa_add_matched_state() manually unlinked pruned contexts before
calling ExecRPRFreeContext(), which internally calls nfa_unlink_context()
to perform the same list operations. Remove the manual forward-link
update and the post-loop tail fixup, letting nfa_unlink_context()
handle forward link, backward link, and tail update consistently.
---
src/backend/executor/execRPR.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/backend/executor/execRPR.c b/src/backend/executor/execRPR.c
index a0a462256ad..bab5257f68f 100644
--- a/src/backend/executor/execRPR.c
+++ b/src/backend/executor/execRPR.c
@@ -1808,14 +1808,12 @@ nfa_add_matched_state(WindowAggState *winstate, RPRNFAContext *ctx,
/* Prune contexts that started within this match's range */
if (winstate->rpSkipTo == ST_PAST_LAST_ROW)
{
- RPRNFAContext *nextCtx;
int64 skippedLen;
while (ctx->next != NULL &&
ctx->next->matchStartRow <= matchEndRow)
{
- nextCtx = ctx->next;
- ctx->next = ctx->next->next;
+ RPRNFAContext *nextCtx = ctx->next;
Assert(nextCtx->lastProcessedRow >= nextCtx->matchStartRow);
skippedLen = nextCtx->lastProcessedRow - nextCtx->matchStartRow + 1;
@@ -1823,8 +1821,6 @@ nfa_add_matched_state(WindowAggState *winstate, RPRNFAContext *ctx,
ExecRPRFreeContext(winstate, nextCtx);
}
- if (ctx->next == NULL)
- winstate->nfaContextTail = ctx;
}
}
--
2.50.1 (Apple Git-155)