Re: Row pattern recognition
Tatsuo Ishii <ishii@postgresql.org>
From: Tatsuo Ishii <ishii@postgresql.org>
To: assam258@gmail.com
Cc: sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl,
jacob.champion@enterprisedb.com, david.g.johnston@gmail.com,
peter@eisentraut.org, pgsql-hackers@postgresql.org
Date: 2026-03-18T11:41:39Z
Lists: pgsql-hackers
Attachments
- v45-0001-Row-pattern-recognition-patch-for-raw-parser.patch (application/octet-stream) patch v45-0001
- v45-0002-Row-pattern-recognition-patch-parse-analysis.patch (application/octet-stream) patch v45-0002
- v45-0003-Row-pattern-recognition-patch-rewriter.patch (application/octet-stream) patch v45-0003
- v45-0004-Row-pattern-recognition-patch-planner.patch (application/octet-stream) patch v45-0004
- v45-0005-Row-pattern-recognition-patch-executor-and-comma.patch (application/octet-stream) patch v45-0005
- v45-0006-Row-pattern-recognition-patch-docs.patch (application/octet-stream) patch v45-0006
- v45-0007-Row-pattern-recognition-patch-tests.patch (application/octet-stream) patch v45-0007
- v45-0008-Row-pattern-recognition-patch-typedefs.list.patch (application/octet-stream) patch v45-0008
Hi Henson,
Attached is the v45 patches. These are basically your patches
(0001-0013) on top of v44, plus rebase. Major changes/fixes since v44
include:
- Rebase. Due to commits (SQL/PG) rebase was required.
I had to resolve shift/reduce conflicts while rebasing gram.y. In
the end, I removed follwing in the v44 patch.
---------------------------------------------------------------------------
qual_Op: Op
{ $$ = list_make1(makeString($1)); }
| OPERATOR '(' any_operator ')'
{ $$ = $3; }
+ | '|'
+ { $$ = list_make1(makeString("|")); }
;
---------------------------------------------------------------------------
Also, we don't need the patch to scan.l anymore since the necessary
changes are already there, thanks to SQL/PGQ commit.
- Fix elog message to use lowercase per PostgreSQL convention
Minor style fix: lowercase the elog error message in
nodeWindowAgg.c to follow PostgreSQL coding convention.
- Fix RPR reluctant quantifier flag lost during VIEW serialization
The reluctant flag on quantifiers was lost when a VIEW containing
RPR was serialized and restored via ruleutils.c. This patch fixes
gram.y, rpr.c, ruleutils.c, and parsenodes.h so the flag survives
the round-trip.
- Expand RPR test coverage and improve test comments
Reorganizes test cases across rpr.sql, rpr_base.sql, rpr_explain.sql,
and rpr_nfa.sql. Moves base functionality tests from rpr.sql to
rpr_base.sql and NFA-specific tests to rpr_nfa.sql. Adds better
section comments throughout. Duplicate tests in rpr.sql were
removed. No reduction in test coverage.
- Keep RPR test objects for pg_upgrade/pg_dump testing
Adjusts rpr_base.sql and rpr_explain.sql so that test tables and
views are not dropped at the end of the test. This allows
pg_upgrade and pg_dump regression testing to cover RPR objects.
- Disable run condition pushdown for RPR windows
Revised version of Tatsuo's run condition fix [1]. Existing test
expected output updated accordingly.
- Disable frame optimization for RPR windows
Prevents the planner from optimizing the window frame for RPR
windows. The frame clause in RPR has different semantics (it
bounds the pattern search space), so standard frame optimizations
must be disabled. Adds EXPLAIN tests to verify. Please review
this one -- it's a newly discovered issue.
- Add stock scenario tests for RPR pattern matching
Adds stock trading scenario tests using realistic synthetic data
(stock.data with 1632 rows). Tests V-shape recovery, W-shape,
consecutive rises, and other common pattern matching use cases.
- Fix zero-min reluctant quantifier to produce zero-length match
Fixes the bug reported by SungJun [2]: reluctant quantifiers with
min=0 (A*?, A??) were incorrectly consuming at least one row instead
of producing a zero-length match. The NFA can now internally
distinguish between a zero-length match and no match, so it will
be ready when additional infrastructure (e.g. MATCH_NUMBER) is
added. Now matches Oracle behavior.
- Fix coerce_to_boolean result not applied in DEFINE clause
[1]
https://www.postgresql.org/message-id/20260304.153822.445473532741409674.ishii@postgresql.org
[2]
https://www.postgresql.org/message-id/CAE+cgNiUbKeH1A0PoxV2QjpsoxJLe+pJcGz_gdxwOwu_9zqchw@mail.gmail.com
Best regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
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