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-03T00:36:49Z
Lists: pgsql-hackers
Attachments
- v50-0001-Evaluate-navigation-offset-once-at-one-place.nocfbot (application/octet-stream)
- v50-0001-Refactor-visit_nav_plan.partial (application/octet-stream)
- v50-0004-misc.partial (application/octet-stream)
- v50-0003-no-need-compile-and-evaluate-offset-in-expression-evaluation.partial (application/octet-stream)
- v50-0002-Refactor-visit_nav_exec.partial (application/octet-stream)
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/
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Adjust cross-version upgrade tests for seg_out() fix
- 3e3d7875e956 19 (unreleased) cited
-
Rationalize error comments in partition split/merge tests
- ecb2508aaf9b 19 (unreleased) cited
-
Add fast path for foreign key constraint checks
- 2da86c1ef9b5 19 (unreleased) cited
-
Fix assorted pretty-trivial memory leaks in the backend.
- e78d1d6d47dc 19 (unreleased) cited
-
Add temporal FOREIGN KEY contraints
- 89f908a6d0ac 18.0 cited
-
Add trailing commas to enum definitions
- 611806cd726f 17.0 cited
-
Remove obsolete executor cleanup code
- d060e921ea5a 17.0 cited