Re: Row pattern recognition

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: assam258(at)gmail(dot)com
Cc: jian(dot)universality(at)gmail(dot)com, 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-06-04 04:21:08
Message-ID: 20260604.132108.405136284364833955.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Henson,

Just a trivial comment to 1.

> While going over the row pattern grammar I want to put on record why the
> empty pattern -- PATTERN (()) and the like -- is left unsupported, and why
> I think that is the right call for this series rather than an oversight.
>
> Today it is simply a syntax error. row_pattern_primary is either a
> variable (ColId) or a parenthesized group '(' row_pattern ')', and
> row_pattern has no empty production, so '()' never parses. The standard's
> pattern syntax does allow an empty row pattern -- it matches the empty
> sequence, i.e. it produces an empty match -- so the question is whether we
> should grow the grammar, plus an NFA "empty" element, to accept it.
>
> My claim is that we do not need to: every way an empty pattern can appear
> reduces to something we already handle, so a dedicated empty element in
> the executor would be dead weight. There are two cases.
>
>
> 1. The empty pattern is the whole pattern: PATTERN (())
>
> This pattern has zero pattern variables. But DEFINE is mandatory (per
> ISO/IEC 19075-5, Table 18), an empty DEFINE list is rejected, and every
> DEFINE variable must appear in PATTERN -- otherwise we already error with
> "DEFINE variable \"%s\" is not used in PATTERN". A pattern with no
> variables cannot satisfy any of that: there is nothing for DEFINE to
> define, yet DEFINE can be neither omitted nor left empty. So an all-empty
> pattern is rejected by the existing rules, with no new check needed.

I think current behavior is correct from the standard's point of
view. As you explained, there's no way to accept "PATTERN (())" or
"PATTERN ()" according to the R020 syntax rule.

Note, however, "PATTERN ()" is possible in R010 because it allows to
omit the DEFINE clause itself.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-06-04 04:47:32 Re: SERVICEFILE shows wrong file after servicefile fallback
Previous Message Michael Paquier 2026-06-04 04:07:00 Re: [PATCH] Fix recognizing 0x11A7 as a Hangul T syllable in Unicode normalization