Re: Row pattern recognition
Henson Choi <assam258@gmail.com>
From: Henson Choi <assam258@gmail.com>
To: jian he <jian.universality@gmail.com>
Cc: Tatsuo Ishii <ishii@postgresql.org>, zsolt.parragi@percona.com,
sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, li.evan.chao@gmail.com, pgsql-hackers@postgresql.org
Date: 2026-06-19T12:08:19Z
Lists: pgsql-hackers
Hi Tatsuo, > From ISO/IEC 9075-2:2016 7.15 <window clause> General Rules: > ... > a) If SL does not simply contain a <window function>, then the <window > clause> is disregarded, and the result of TE is the result of the last > <from clause>, <where clause>, <group by clause> or <having clause> of TE. Thank you -- this is exactly the text I was missing. I only have ISO/IEC 19075-5 (the guidance / technical report), which describes what a window definition does but says nothing about a window clause being disregarded when no window function references it. The General Rule you quote settles it: disregarding an unused window clause is required by the standard, and since DEFINE is part of the window clause, it is disregarded along with the rest. So evaluating its DEFINE -- option (b) -- would mean running a clause the standard tells us to ignore. > But we already pass faulty window clauses. Example: > ... ERROR: frame ending offset must not be negative ... > I think if we detect faulty DEFINE in the last case, it's not only > against the standard but against our existing behavior. Agreed, and the parallel is convincing. An unused window already escapes the negative-frame-offset check, so singling out DEFINE as the one clause that must fire regardless would be inconsistent with how the rest of an unused window already behaves. This also matches the planner: select_active_windows() drops any window with no referencing WindowFunc, and its comment already cites the same <window clause> General Rules (General Rule 4) as its basis. Either way, the disregard rule governs only execution. A failure raised in the parser, transform, rewrite, or planner is a separate, static layer the rule does not touch. And at execution there is nothing to evaluate: an unused window is never turned into a WindowAgg node, so its DEFINE is never reached. So I'm convinced -- let's keep (a), the current behavior, and I'll treat this open question as closed, with no patch change. For the record, the two halves stay cleanly separated: the RPR DEFINE volatility check still visits every window clause at preprocessing (independent of select_active_windows), while run-time DEFINE evaluation happens only for windows that survive it. Thanks for digging up the standard text. Best regards, Henson
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