Re: Row pattern recognition
Tatsuo Ishii <ishii@postgresql.org>
From: Tatsuo Ishii <ishii@postgresql.org>
To: ssam258@gmail.com
Cc: vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com,
david.g.johnston@gmail.com, peter@eisentraut.org,
pgsql-hackers@postgresql.org
Date: 2026-02-12T01:17:01Z
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
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