| 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 00:36:49 |
| Message-ID: | CACJufxFfMJAMc0R6g4f7Bwr47QDY+OBr2vzqqMRbCzjdD9vR2g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
------------------------------------------------
| Attachment | Content-Type | Size |
|---|---|---|
| v50-0001-Evaluate-navigation-offset-once-at-one-place.nocfbot | application/octet-stream | 45.9 KB |
| v50-0001-Refactor-visit_nav_plan.partial | application/octet-stream | 29.5 KB |
| v50-0004-misc.partial | application/octet-stream | 5.4 KB |
| v50-0003-no-need-compile-and-evaluate-offset-in-expression-evaluation.partial | application/octet-stream | 9.5 KB |
| v50-0002-Refactor-visit_nav_exec.partial | application/octet-stream | 7.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayush Tiwari | 2026-07-03 00:52:12 | Re: GetBufferDescriptor() being called for local buffers from MarkBufferDirtyHint() |
| Previous Message | Tender Wang | 2026-07-03 00:26:51 | Re: satisfies_hash_partition crash |