Re: Row pattern recognition

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Tatsuo Ishii <ishii@postgresql.org>
Cc: assam258@gmail.com, pgsql-hackers@postgresql.org, zsolt.parragi@percona.com, sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, li.evan.chao@gmail.com
Date: 2026-07-03T03:55:43Z
Lists: pgsql-hackers

Attachments

On Fri, Jul 3, 2026 at 8:36 AM jian he <jian.universality@gmail.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/

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Adjust cross-version upgrade tests for seg_out() fix

  2. Rationalize error comments in partition split/merge tests

  3. Add fast path for foreign key constraint checks

  4. Fix assorted pretty-trivial memory leaks in the backend.

  5. Add temporal FOREIGN KEY contraints

  6. Add trailing commas to enum definitions

  7. Remove obsolete executor cleanup code