Re: Row pattern recognition
Tatsuo Ishii <ishii@postgresql.org>
From: Tatsuo Ishii <ishii@postgresql.org>
To: assam258@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-27T02:37:33Z
Lists: pgsql-hackers
Attachments
- (unnamed) (text/plain)
Hi Henson,
> Hi Tatsuo,
>
> Here are ten incremental patches on top of v43.
Thanks.
BTW, I noticed that RPR accepts table name qualified variables in
DEFINE clause.
SELECT company, tdate, price, first_value(price) OVER w, last_value(price) OVER w,
nth_value(tdate, 2) OVER w AS nth_second
FROM stock
WINDOW w AS (
PARTITION BY company
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
INITIAL
PATTERN (START UP+ DOWN+)
DEFINE
START AS TRUE,
UP AS stock.price > PREV(price), <-- table name "stock" is uded
DOWN AS price < PREV(price)
);
The standard does not allow to use range variables, declared in the
FROM clause, in the DEFINE clause (19075-5 6.5). Attached patch raises
an error in this case.
psql:a.sql:13: ERROR: range var qualified name "stock.price" is not allowed in DEFINE clause
LINE 11: UP AS stock.price > PREV(price),
^
Also, currently we do not support pattern variable range vars in the
DEFINE caluse (e.g. UP.price). If used, we see a confusing error
message:
ERROR: missing FROM-clause entry for table "UP"
LINE 13: UP AS UP.price > PREV(price),
^
The attached patch errors out differently. I believe this is an
enhancement.
psql:a.sql:13: ERROR: range var qualified name "up.price" is not allowed in DEFINE clause
LINE 11: UP AS UP.price > PREV(price),
^
Thoughts?
--
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