public inbox for [email protected]  
help / color / mirror / Atom feed
From: jian he <[email protected]>
To: Tatsuo Ishii <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Subject: Re: Row pattern recognition
Date: Fri, 3 Jul 2026 08:36:49 +0800
Message-ID: <CACJufxFfMJAMc0R6g4f7Bwr47QDY+OBr2vzqqMRbCzjdD9vR2g@mail.gmail.com> (raw)
In-Reply-To: <CACJufxEkjgPKeXiakXvb_9TEcz+nG+wiEtcTR3GS2Lx4ZTYssg@mail.gmail.com>
References: <[email protected]>
	<[email protected]>
	<CAAAe_zAwu0nuwXmEt-mnjV+J-BVLpJu64p-kRPyj8itbpriJhA@mail.gmail.com>
	<[email protected]>
	<CACJufxEkjgPKeXiakXvb_9TEcz+nG+wiEtcTR3GS2Lx4ZTYssg@mail.gmail.com>

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:
------------------------------------------------
Subject: [PATCH v51 1/1] Evaluate navigation offset once at one place

Row pattern navigation (PREV/NEXT/FIRST/LAST and their compounds) resolved
offsets (transform a expression to a int64 number) in ExecInitExprRec,
ExecEvalRPRNavSet, extract_const_offset, eval_define_offsets. Serval places
transform the same offset expression to a int64 number, that is too much!

With the attached, a single place (ExecInitWindowAgg->eval_define_offsets) to
handling this.

visit_nav_exec() now evaluates every offset expression at executor init and save
the result on the RPRNavExpr (offset / compound_offset); ExecEvalRPRNavSet()
simply reads those int64 values.  This removes:

  - the RPRNavOffsetKind enum and the offset/kind fields on the
    WindowAgg plan node.  The planner walk (visit_nav_plan /
    compute_define_metadata) now only classifies match_start
    dependency, which is all buildRPRPattern() needs to decide context
    absorption.

  - the per-invocation offset machinery in the executor: the Datum*
    offset arrays in the eval step, rpr_nav_get_compound_offset(), and
    the scattered NULL/negative checks, now centralized in
    eval_nav_offset.

The "retain all" case (backward reach overflows int64) is encoded as the
sentinel navMaxOffset < 0 rather than an enum value; advance_nav_mark() disables
tuplestore trim on it.  EXPLAIN reads the resolved offsets from the planstate
(ExecInitWindowAgg is reached for EXPLAIN without ANALYZE), so it now prints
concrete offsets instead of "runtime".

```
 We must still set nav_saved_outertuple (done above) so that
EEOP_RPR_NAV_RESTORE is a harmless no-op.
```
The above in ExecEvalRPRNavSet is wrong, EEOP_RPR_NAV_RESTORE will never be a
no-op. However we can make EEOP_RPR_NAV_RESTORE no-op, so the above comments
make sense.

Rename eval_nav_offset_helper to eval_nav_offset

Based on https://github.com/assam258-5892/postgres/commits/RPR
------------------------------------------------



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


Attachments:

  [application/octet-stream] v50-0001-Evaluate-navigation-offset-once-at-one-place.nocfbot (45.9K, ../CACJufxFfMJAMc0R6g4f7Bwr47QDY+OBr2vzqqMRbCzjdD9vR2g@mail.gmail.com/2-v50-0001-Evaluate-navigation-offset-once-at-one-place.nocfbot)
  download

  [application/octet-stream] v50-0001-Refactor-visit_nav_plan.partial (29.5K, ../CACJufxFfMJAMc0R6g4f7Bwr47QDY+OBr2vzqqMRbCzjdD9vR2g@mail.gmail.com/3-v50-0001-Refactor-visit_nav_plan.partial)
  download

  [application/octet-stream] v50-0004-misc.partial (5.4K, ../CACJufxFfMJAMc0R6g4f7Bwr47QDY+OBr2vzqqMRbCzjdD9vR2g@mail.gmail.com/4-v50-0004-misc.partial)
  download

  [application/octet-stream] v50-0003-no-need-compile-and-evaluate-offset-in-expression-evaluation.partial (9.5K, ../CACJufxFfMJAMc0R6g4f7Bwr47QDY+OBr2vzqqMRbCzjdD9vR2g@mail.gmail.com/5-v50-0003-no-need-compile-and-evaluate-offset-in-expression-evaluation.partial)
  download

  [application/octet-stream] v50-0002-Refactor-visit_nav_exec.partial (7.7K, ../CACJufxFfMJAMc0R6g4f7Bwr47QDY+OBr2vzqqMRbCzjdD9vR2g@mail.gmail.com/6-v50-0002-Refactor-visit_nav_exec.partial)
  download

view thread (181+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Row pattern recognition
  In-Reply-To: <CACJufxFfMJAMc0R6g4f7Bwr47QDY+OBr2vzqqMRbCzjdD9vR2g@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox