Re: Row pattern recognition

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: assam258(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, jian(dot)universality(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Row pattern recognition
Date: 2026-05-10 02:54:37
Message-ID: 20260510.115437.1911555836676501912.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Henson,

> Still deferred:
> - B7 Recursive CTE XXX: pending community input on the
> ISO/IEC 19075-5 6.17.5 / 4.18.5 interpretation.

ISO/IEC 19075-5 6.17.5 stats that "Row pattern matching is prohibited
in recursive queries. For example, the following is a syntax error:

CREATE RECURSIVE VIEW Problem... SELECT Kolo, Xoro FROM Ticker... WINDOW W AS... MEASURES..."

ISO/IEC 19075-5 4.18.5 stats that "Row pattern matching is prohibited
in recursive queries. For example, the following is a syntax error:

CREATE RECURSIVE VIEW Problem... SELECT Kolo, Xoro FROM t... MATCH_REZOGNIZE..."

From these it is apparent that CREATE RECURSIVE VIEW cannot be used
with RPR in both R010 and R020.

Question is, what about CTE queries?

I looked into ISO/IEC 9075-2:2016 (I don't have access to 2023) and
found this in "7.17 <query expression>".

in "Syntax Rule"

3) If <with clause> WC is specified, then:

a) Let n be the number of <with list element>s.
:
:
3) If <with clause> WC is specified, then:
:
:
e) If WC immediately contains RECURSIVE, then WC, its <with list>, and
its <with list element>s are said to be potentially
recursive. Otherwise, they are said to be non-recursive.

f) A potentially recursive <with list element> shall not contain a
<row pattern measures> or <row pattern common syntax>.

So I think at least SQL:2016 explicitly prohibits using RPR within
recursive CTE. I would appreciate if anybody confirms this in
SQL:2023.

Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nisha Moond 2026-05-10 04:30:01 Re: pg_createsubscriber: Fix incorrect handling of cleanup flags
Previous Message Zhongpu Chen 2026-05-10 02:28:57 Re: Proposal: tighten validation for legacy EUC encodings or document that accepted byte sequences may be unconvertible to UTF8