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, pgsql-hackers(at)postgresql(dot)org, 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
Subject: Re: Row pattern recognition
Date: 2026-07-03 03:55:43
Message-ID: CACJufxGdUQgx+ekZPkQTRqYrLe2fkWfWWww9yO9gKQPAq0183A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 3, 2026 at 8:36 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> Hi.
>
> ``The actual mark is set to: min(lookback_mark, lookahead_mark).``
> in README.rpr need update?
>
> The attached patch is still based on
> https://github.com/assam258-5892/postgres/commits/RPR.
>
> v50-0001-Refactor-visit_nav_plan.partial
> v50-0002-Refactor-visit_nav_exec.partial
> v50-0003-no-need-compile-and-evaluate-offset-in-expression-evaluation.partial
> v50-0004-misc.partial
> v50-0001-Evaluate-navigation-offset-once-at-one-place.nocfbot
>
> The ".partial" patch, when combined, contains the same content as the
> single patch (v50-0001-Evaluate-navigation-offset-once-at-one-place.nocfbot).
> (I first created separated patches, but then I felt the whole change
> focuses on one main topic, so merging them made sense to me).
>
> The commit message for the main patch
> (v50-0001-Evaluate-navigation-offset-once-at-one-place.nocfbot) is
> below:
> ------------------------------------------------
Hi.

While at it, I found nav_traversal_walker is a little bit of
complicated (overkill).
So the attached patch is removing nav_traversal_walker.

Two files are attached:
v50-0001-Evaluate-navigation-offset-once-at-one-place.nocfbot
v50-0002-Drop-the-shared-nav_traversal_walker-for-RPR-DEFINE.nocfbot

v50-0001 is the same as posted in [1].
v50-0002 is built on top of v50-0001. Even without v50-0001,
I think the changes in v50-0002 still make sense, as they improve readability.

The commit message for v50-0002 is below:
------------------------------------------------
Subject: [PATCH v50 2/2] Drop the shared nav_traversal_walker for RPR DEFINE

Both visit_nav_exec() and visit_nav_plan() assert:

Assert(nav->arg == NULL || !IsA(nav->arg, RPRNavExpr));
Assert(nav->offset_arg == NULL || !IsA(nav->offset_arg, RPRNavExpr));
Assert(nav->compound_offset_arg == NULL ||
!IsA(nav->compound_offset_arg, RPRNavExpr));

so an RPRNavExpr is never nested inside another RPRNavExpr, and the expressions
that contain RPRNavExpr nodes are not complicated. For that, the generic
nav_traversal_walker() -- a NavTraversal struct carrying a function pointer and
a void* context, shared between the planner and the executor is kind of
complicated.

Replace it with static RPRNavExpr_walker() in each site. RPRNavExpr_walker will
finds RPRNavExpr nodes, and acts on them the way it wants. Having a small
duplicated static walker in the two files is fine here, nodeWindowAgg.c no
longer need to include "optimizer/rpr.h".

rename visit_nav_plan to compute_matchStartDependent,
rename visit_nav_exec to compute_nav_offsets.
------------------------------------------------
[1]: https://www.postgresql.org/message-id/CACJufxFfMJAMc0R6g4f7Bwr47QDY%2BOBr2vzqqMRbCzjdD9vR2g%40mail.gmail.com

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

Attachment Content-Type Size
v50-0002-Drop-the-shared-nav_traversal_walker-for-RPR-DEFINE.nocfbot application/octet-stream 10.3 KB
v50-0001-Evaluate-navigation-offset-once-at-one-place.nocfbot application/octet-stream 45.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2026-07-03 04:08:51 Re: implement CAST(expr AS type FORMAT 'template')
Previous Message Xuneng Zhou 2026-07-03 03:54:31 Re: BUG: ReadStream look-ahead exhausts local buffers when effective_io_concurrency>=64