Re: Row pattern recognition - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: Row pattern recognition
Date
Msg-id 20260701.211805.2273383346456030984.ishii@postgresql.org
Whole thread
In response to Re: Row pattern recognition  (Tatsuo Ishii <ishii@postgresql.org>)
Responses Re: Row pattern recognition
Re: Row pattern recognition
List pgsql-hackers
> Will continue reviewes tomorrow.

Sorry for delay. Here is the review for
v50-0005-match-once-per-row.patch.

--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -239,6 +239,10 @@ static int64 row_is_in_reduced_frame(WindowObject winobj, int64 pos);
 
 static void clear_reduced_frame(WindowAggState *winstate);
 static int    get_reduced_frame_status(WindowAggState *winstate, int64 pos);
+static void advance_nav_mark(WindowAggState *winstate, int64 currentPos);
+static void advance_reduced_frame_nfa(WindowObject winobj,
+                                      RPRNFAContext *targetCtx, int64 pos,
+                                      bool hasLimitedFrame, int64 frameOffset);
 static void update_reduced_frame(WindowObject winobj, int64 pos);
 
 /* Forward declarations - NFA row evaluation */
@@ -2521,6 +2525,16 @@ ExecWindowAgg(PlanState *pstate)
             {
                 if (winstate->rpSkipTo == ST_NEXT_ROW)
                     clear_reduced_frame(winstate);
+
+                /*
+                 * Drive the row pattern match every row, so it tracks the row
+                 * scan rather than frame access: a window function that skips
+                 * the frame (e.g. nth_value() with a NULL offset) must not
+                 * leave the match state behind currentpos.
+                 */
+                Assert(winstate->nav_winobj != NULL);
+                (void) row_is_in_reduced_frame(winstate->nav_winobj,
+                                               winstate->currentpos);

Is there any reason that we call row_is_in_reduced_frame() here,
instead of something like:

   update_frameheadpos(winstate);
   update_reduced_frame(winobj, pos);

row_is_in_reduced_frame() returns row status. Ignoring it using (void)
looks a little bit confusing to me.

Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: md5_password_warnings for password auth with MD5-encrypted passwords
Next
From: Jacob Champion
Date:
Subject: Re: Coverage (lcov) failing with inconsistent error in versions 2.x