Re: Row pattern recognition
Tatsuo Ishii <ishii@postgresql.org>
From: Tatsuo Ishii <ishii@postgresql.org>
To: assam258@gmail.com
Cc: jacob.champion@enterprisedb.com, david.g.johnston@gmail.com,
vik@postgresfriends.org, er@xs4all.nl, peter@eisentraut.org,
pgsql-hackers@postgresql.org
Date: 2026-01-16T04:44:22Z
Lists: pgsql-hackers
Attachments
- v39-0001-Row-pattern-recognition-patch-for-raw-parser.patch (application/octet-stream) patch v39-0001
- v39-0002-Row-pattern-recognition-patch-parse-analysis.patch (application/octet-stream) patch v39-0002
- v39-0003-Row-pattern-recognition-patch-rewriter.patch (application/octet-stream) patch v39-0003
- v39-0004-Row-pattern-recognition-patch-planner.patch (application/octet-stream) patch v39-0004
- v39-0005-Row-pattern-recognition-patch-executor-and-comma.patch (application/octet-stream) patch v39-0005
- v39-0006-Row-pattern-recognition-patch-docs.patch (application/octet-stream) patch v39-0006
- v39-0007-Row-pattern-recognition-patch-tests.patch (application/octet-stream) patch v39-0007
- v39-0008-Row-pattern-recognition-patch-typedefs.list.patch (application/octet-stream) patch v39-0008
Hi Henson, > Hi Ishii-san, > > Thank you for raising the frame boundary concern. You're right that > different contexts have different frame boundaries. Ok. > Your suggestion was to use row_is_in_frame() to check frame boundaries > for each row. However, I took a simpler approach: just disable context > absorption entirely when the frame is limited. > > The root cause is that context absorption assumes all contexts see > the same rows. With limited frames, each context starting at a different > row has a different visible range, so we cannot absorb one context into > another. > > As I mentioned before, I think we should use absorption conservatively > for now - only in cases where it's clearly safe (e.g., A* at the > beginning of the pattern). We can extend it later through more in-depth > research. Agreed. > The fix: > > if (winstate->rpSkipTo == ST_PAST_LAST_ROW && !hasLimitedFrame) > nfa_absorb_contexts(winstate, targetCtx, currentPos); > > I added a test case to verify this: [snip] > I'm attaching three related commits: > > 1. Row pattern recognition: Improve NFA state memory management > > This commit refactors NFA state management for better readability > and maintainability. > > 2. Row pattern recognition: Disable context absorption for limited frame > > This commit further restricts absorption: even with SKIP PAST LAST ROW, > absorption is disabled when the frame is limited. With limited frames, > different contexts have different frame boundaries, making absorption > unsafe. I have applied the patches on top of v38 to create v39 patches. In addition to these patches, I have made following changes: - Add check for frame option "EXCLUDE". With RPR, using EXCLUDE is not permitted by the SQL standard. A test case added. - Remove unused typedef from windowfuncs.c (which causes removal of the typedef from typedes.list). The typedef was accidentally left by me while developing RPR. - Update the Copyright year to 2026 in some newly added files. 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