Re: Row pattern recognition

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: ssam258(at)gmail(dot)com
Cc: 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, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Row pattern recognition
Date: 2026-02-12 01:17:01
Message-ID: 20260212.101701.1434868071304923886.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Henson,

I found following in rpr_base.sql:

-- {0} is not allowed (min must be >= 1)
SELECT id, val, COUNT(*) OVER w as cnt
FROM rpr_quant
WINDOW w AS (
ORDER BY id
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
PATTERN (A{0} B)
DEFINE A AS val > 1000, B AS val > 0
)
ORDER BY id;

However in my uderstanding the SQL standard allows A{0}.

PATTERN (A{0} B)
is equivalant to:
PATTERN (B)

Another interesting PATTERN is:

A{,}

This is equivalant to A{0,}

BTW, after studied this more, I found that A{0,0} is not allowed. In
this form the right hand side number shall be greater than 0. From
ISO/IEC 9075-2 7.9 <row pattern syntax> "Syntax Rules 20)

"If <left brace> <unsigned integer> <comma> <unsigned integer> <right
brace> is specified, then let VUI1 and VUI2 be the values of the first
and second <unsigned integer>'s, respectively. VUI1 shall be less than
or equal to VUI2, and VUI2 shall be greater than 0 (zero)."

However according to the Google, Oracle and Snowflake allows A{0,0}:
they break the standard. So, what do you think PostgreSQL should do
here? My preference is "always follow the standard". But others might
think differently.

Best 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 Andres Freund 2026-02-12 01:26:00 Re: Odd usage of errmsg_internal in bufmgr.c
Previous Message Chao Li 2026-02-12 01:07:08 Re: Is it OK to perform logging while holding a LWLock?