Re: Row pattern recognition

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: assam258(at)gmail(dot)com
Cc: jacob(dot)champion(at)enterprisedb(dot)com, david(dot)g(dot)johnston(at)gmail(dot)com, vik(at)postgresfriends(dot)org, er(at)xs4all(dot)nl, peter(at)eisentraut(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Row pattern recognition
Date: 2026-02-02 07:20:00
Message-ID: 20260202.162000.2139438609347688347.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The series of patches are to implement the row pattern recognition
(SQL/RPR) feature. Currently the implementation is a subset of SQL/RPR
(ISO/IEC 19075-2:2016). Namely, implementation of some features of
R020 (WINDOW clause). R010 (MATCH_RECOGNIZE) is out of the scope of
the patches.

Attached are the v42 patches.
The difference from v41 include:

- Add Peter as a reviewer to commit message. He gave a good valuable
suggestions to the gram.y patch. I accidentally forgot to credit his
name.

- Tons of enhancements from Henson.

-- Fully rewrite absorption logic (optimizer/plan/rpr.c).
Example: (a+ b* c?){2,} -> (a+" b* c?){2,}

-- Add safety check to tryMultiplyQuantifiers (optimizer/plan/rpr.c)
Example: (A{2}){2,3} cannot be rewritten to A{4,6} because it allows
5 times reputation which is not correct. Perform multiplication
optimization only in safe case.

-- Fix infinite loop/segfault when unlimited quantifiers (e.g. (A*)*,
(A+)+) are used.

-- Optimize unlimited quantifiers if possible (e.g. (A*)* -> A*, (A+)+ -> A+)

-- Fix segfault case (SELECT id, flag ...WINDOW w AS (... DEFINE T AS flag)

-- More accurate error position report

-- Some code refactoring in parser/planner patches

-- Split regression test file into rpr.sql and rpr_base.sql

-- Fix outfuncs.c and readfuncs.c

-- Fix some corner cases bug of regular expression optimization

-- Remove unused PATTERN variable to enhance performance

-- Change treatment of undefined DEFINE variables. Previously if
variable "A" is used in PATTERN but not defined in DEFINE, A is
automatically defined as "A AS TRUE". Now A is evaluated as TRUE in
executor and the generated entry for A is removed. This improves
memory usage.

-- EXPLAIN now shows the absorbable points (a+")

- Bug fix from me.

-- Assertion failure when two or more window clauses are used.
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

Attachment Content-Type Size
v42-0001-Row-pattern-recognition-patch-for-raw-parser.patch application/octet-stream 32.1 KB
v42-0002-Row-pattern-recognition-patch-parse-analysis.patch application/octet-stream 26.9 KB
v42-0003-Row-pattern-recognition-patch-rewriter.patch application/octet-stream 5.7 KB
v42-0004-Row-pattern-recognition-patch-planner.patch application/octet-stream 61.6 KB
v42-0005-Row-pattern-recognition-patch-executor-and-comma.patch application/octet-stream 93.5 KB
v42-0006-Row-pattern-recognition-patch-docs.patch application/octet-stream 11.1 KB
v42-0007-Row-pattern-recognition-patch-tests.patch application/octet-stream 684.7 KB
v42-0008-Row-pattern-recognition-patch-typedefs.list.patch application/octet-stream 1.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2026-02-02 07:25:48 Re: Adding REPACK [concurrently]
Previous Message Chao Li 2026-02-02 07:15:52 Re: walsender: Assert MyReplicationSlot is set before use