Re: Row pattern recognition

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: assam258(at)gmail(dot)com, zsolt(dot)parragi(at)percona(dot)com, sjjang112233(at)gmail(dot)com, vik(at)postgresfriends(dot)org, er(at)xs4all(dot)nl, jacob(dot)champion(at)enterprisedb(dot)com, david(dot)g(dot)johnston(at)gmail(dot)com, peter(at)eisentraut(dot)org, li(dot)evan(dot)chao(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Row pattern recognition
Date: 2026-08-16 02:53:06
Message-ID: CACJufxEb18fydJtNfjmFbDNP6iSg9jcVsd_DJQwcbHX0LxmCaQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 28, 2026 at 10:48 AM Tatsuo Ishii <ishii(at)postgresql(dot)org> wrote:
>
> Thanks to Jian He for an extensive review that helped surface several
> defects and substantially improved the readability and maintainability
> of the code; the review also prompted the redesign of the
> window-navigation functions.
>
> Discussion: https://postgr.es/m/20230625.210509.1276733411677577841.t-ishii%40sranhm.sra.co.jp
HI.

In src/backend/executor/nodeWindowAgg.c, we have:
```
if (rpr_is_defined(winstate))
{
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);
ensure_reduced_frame(winstate->nav_winobj,
winstate->currentpos);
}
```
and
ensure_reduced_frame(WindowObject winobj, int64 pos)

In the above ``winstate->currentpos`` clearly is more readable than "pos",
ensure_reduced_frame only used twice.
So I propose removing both ensure_reduced_frame and
clear_reduced_frame, and inlining their corresponding function
contents at the call sites.
given the whole code change in nodeWindowAgg.c is quite complicated,
these readability changes are necessary, IMHO.

--
jian
https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message sahil verma 2026-08-16 05:06:13 Request to expedite CommitFest account cool-off period
Previous Message Michael Paquier 2026-08-16 01:21:29 Re: Failing assertion while taking a restartpoint during crash recovery