Re: Row pattern recognition

From: Henson Choi <assam258(at)gmail(dot)com>
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>, jian(dot)universality(at)gmail(dot)com
Cc: 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, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Row pattern recognition
Date: 2026-05-07 12:41:46
Message-ID: CAAAe_zAf-vCJvnTuiFF_85BHozgBC5aGLoNOUSuSonoXZhkEnA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tatsuo, hi Jian,

Attached are 10 incremental patches on top of v47, covering the
follow-up plan ([A]..[D]) I sketched on 2026-05-05, Jian's two
coding-style items (trailing commas, outer parentheses; gram.y
folded into 0007), one comment-only patch (0009), and one trivial
cleanup (0010). Packaging into the next version is at your
discretion.

Patch summary:

- 0001 Add DEFINE non-volatile baseline to rpr_integration B9
Adds a STABLE/IMMUTABLE baseline ahead of the volatile
case so the rejection in 0002 is visible against a working
reference.

- 0002 Unify RPR DEFINE walkers and reject volatile callees
[A]. Collapses the four DEFINE walkers (parser / planner
/ executor) into one phase-tagged traversal and, on that
base, rejects volatile / NextValueExpr at parse-analysis.
STABLE / IMMUTABLE accepted. The offset runtime-constant
check is folded in; B9 flips to error-case and its XXX is
dropped.

- 0003 Cover RPR empty-match path with EXPLAIN tests; fix
stale XXX comments
[B]. Adds rpr_explain coverage that surfaces "NFA: N
matched (len 0/0/0.0)" so the NFA-found-but-empty-frame
path is regression-visible; replaces stale rpr_nfa XXXs.

- 0004 Reclassify DEFINE qualifier check and reword
diagnostic to "expression"
[D]. Tri-classifies (pattern var / range var / fall-
through) so unknown qualifiers fall through to the
standard "column does not exist" diagnostic. Reworded to
"expression" since the quoted token may include
indirection on composite types (e.g. (A.items).amount).

- 0005 Sync stale comments on DEFINE/PATTERN handling
validateRPRPatternVarCount() rejects DEFINE names not in
PATTERN, but comments / SELECT doc described it as
"collection" / "filtered during planning". Wording
aligned; XXX note's "column references" bumped to
"expressions" to match 0004. Comment + doc only.

- 0006 Add trailing commas to RPR enum definitions
Per Jian. RPRNavKind, RPRNavOffsetKind, RPRPatternNodeType.

- 0007 Remove optional outer parentheses from ereport() calls
in RPR files
Per Jian + Tatsuo's gram.y patch. 19 sites in
parse_rpr.c / optimizer/plan/rpr.c plus the gram.y sites.

- 0008 Add high-water mark tracking to NFA visited bitmap
reset
[C]. Resets only the touched span (O(span_words) instead
of O(numElements/64)), at the cost of two int16 comparisons
per visit. Semantics unchanged; happy to drop if you
prefer the simpler bulk reset.

- 0009 Document DEFINE subquery rejection as intentional
over-rejection
Comment-only. Records that ISO/IEC 9075-2 §4.18.4 /
6.17.4 (R010 / R020) permits a non-RPR, non-pattern-var-
correlated subquery in DEFINE, and that our blanket
rejection is deliberate over-rejection. The case
distinction (walk subquery Query for nested RPR; match
ColumnRef qualifiers against ancestor p_rpr_pattern_vars)
is doable with existing infrastructure and left as future
work, not blocked on any other feature.

- 0010 Remove duplicate #include in nodeWindowAgg.c
"common/int.h" was included twice and the first occurrence
was misplaced between catalog/* headers. Drops the
misplaced first; the second sits at the correct
alphabetical position.

Still deferred:
- B7 Recursive CTE XXX: pending community input on the
§4.18.5 / 6.17.5 interpretation.

Please let me know if any of 0001-0010 looks misjudged or if you
would prefer a different slicing.

Best regards,
Henson

Attachment Content-Type Size
nocfbot-0001-DEFINE-non-volatile-baseline.txt text/plain 3.3 KB
nocfbot-0002-Unify-DEFINE-walkers-reject-volatile.txt text/plain 69.1 KB
nocfbot-0003-Empty-match-EXPLAIN-coverage.txt text/plain 19.0 KB
nocfbot-0004-Reclassify-DEFINE-qualifier-check.txt text/plain 11.9 KB
nocfbot-0005-Sync-DEFINE-PATTERN-comments.txt text/plain 4.4 KB
nocfbot-0006-Trailing-commas-RPR-enums.txt text/plain 1.8 KB
nocfbot-0007-ereport-outer-parens.txt text/plain 18.8 KB
nocfbot-0008-NFA-visited-high-water-mark.txt text/plain 5.0 KB
nocfbot-0009-Document-DEFINE-subquery-rejection.txt text/plain 2.7 KB
nocfbot-0010-Remove-duplicate-include-nodeWindowAgg.txt text/plain 1.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2026-05-07 12:42:37 Re: Broken build on macOS (Universal / Intel): cpuid instruction not available
Previous Message Andy Fan 2026-05-07 12:40:40 Re: Make printtup a bit faster