Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1waY3V-001skL-0a for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jun 2026 12:10:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1waY1T-00FsJK-2U for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jun 2026 12:08:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1waY1T-00FsJC-16 for pgsql-hackers@lists.postgresql.org; Fri, 19 Jun 2026 12:08:35 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1waY1R-000000018Td-3W14 for pgsql-hackers@postgresql.org; Fri, 19 Jun 2026 12:08:34 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-c0115a3794bso397744566b.0 for ; Fri, 19 Jun 2026 05:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781870912; cv=none; d=google.com; s=arc-20240605; b=ayjKWu/SJcb3UNJJEwEr4dzR/fXb7ZpE+dTWY3+Q16EuIvYGQErI64WmcbPycPNI12 dvO1NGvRFbDaLXd0t8KbS5cjROXNgWNYpp0tCg9oo2iCh3SZBlV6HnB1khMr/6768Mhq 5myw048lCQpviJ5o8UpBDq6qsXGJ2AOfap7zs7HfWEExqYQjHre7B1wat/eZy6Xv7dvz LSEFIu5Er6kjTKjA+TjOrUJ5Ya1nZMQXcE0kGEpsNI0Na5RGHGDzqbTVfJp90I+Q4BJy g/z86yjEBhui4Z+eSGkDsTOiO7GHibl26gXuFLKL7HAd4a+obycINmlskuVSSFQpHOUb QDJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:dkim-signature; bh=xlaS1xESfuMaQP6wHzG0EYdAbbKYwZ+N/Xvbz232t8Q=; fh=+a7V0rF96Nd+ta9gHyXq02Vs6Dh482k1dpVeQDLG1R8=; b=PtIbBcPfOG4y5D3pH+lz7+rz79rPhvcZl4ryKn0Oco4bymMnJhcLLDfExrSyrwRJCQ z/NMzkuLDj2Ap3/jN8G5XtCoiRXyxwfKkJmdp8bwPMD+oJMat7+kpwtfnkiAFYeCvM/s gsdrgRTfxnepVaRvJMHNdEWBZcC8WGjOL4ipIngrxnt6XUDeVA8ne+5P7tuDK+LlHAk0 4pOr5ZYXSISto/8eSrYlMWR5GEj+UTRZYbb5B2if4tDG1b8fYrCxY4s7B1k01mirOe1H JX29opel10Y2SPER6sNkJEVl+llbZsS3nu29TZxESHqhHJayG8zdbVc1fSJ5DOzaW382 4zCw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781870912; x=1782475712; darn=postgresql.org; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=xlaS1xESfuMaQP6wHzG0EYdAbbKYwZ+N/Xvbz232t8Q=; b=OtRJeqFtrgpveRIMdz9fPjj+Xi1Mj7E8gkLy0zkFNuZVr+nksykN9dml+3+gHuzM5p E2qoPdqgWFhyaCe7j09Gq4f2KIcQBLarVghPKqMOGou8xOUV7iALxXD1g6LZVdlNtM5Z KjJEEAuMg2ypc4ztYc8NAqApilr15kPLLU2mVHaMKCxgzJUBZfSH/Xe/jhe715g1i+hO pN5yfXjbA40jVzA0ZC7UVNNOgbGPdHg68DuLKD4OYesO44iYnb5GDZtewfubOsTkEoM+ knopE5Rczu3zUuL4fAMHFSAp13L4HibI2SPsdCnLN1TzvdnaFY+NDLjgkpJPcVfuuTVp AXoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781870912; x=1782475712; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xlaS1xESfuMaQP6wHzG0EYdAbbKYwZ+N/Xvbz232t8Q=; b=MhLSDao9mU1jI8Fe0WNArNd6Hi6IJ63OaQGdynhj2JTgX9Kad1lRk6w9kbkqP6mmqX QGMWx11ZJr/GzWsziwhzVCv8/zHcgKyrjGWRraVUG+M2qfxps8Fht8K70YwaG9xwAR5O GOTErdOVj1afHiciD8gpLHbBX+MRmWdYxHuujHqAS7fwVk4/KO2eiQu7nBuJG3Ha38lg TafZk04x2tZVvVhNzHqJVuj2ZQqBPhp98FrR34z3OeVuSFA9L+6pSDQMTKlqYimHk8q9 YI30y/+1kZOVjKJDzFuqV58hAmdl3tHGXc+atdy4Iv0pNFtaOk0czJjWtOX4mC/4oMO8 /uWg== X-Forwarded-Encrypted: i=1; AFNElJ9ASdlwG+jtVKMIcv+/fhN9MVZpBRV8/qbi2wIo5sFFWr04hICJa79yMnEq2FC860phmlAH0mPt4cU5pisI@postgresql.org X-Gm-Message-State: AOJu0Yyd446VvHTaqVJRubgPflesD7y/5iHPYXNdhjWsHU9mQ0pTLzEj Ibw8gPA+8/wxLEf8Lb//vSEYqPas7TzfVw6LYNyeJyw6HFMkjWJ2ktNyDQ9fBwgOOBni7LoPNJ7 XXQkdwfKG4oamtYKh875EAkL+foQ2rBo= X-Gm-Gg: AfdE7cn59eklqNupIe4rcGin7U4uGneB8VhBo1PoDqqpglQ++P8CLArQIPI2MykY9WH 1ekBiGrOxGfZBt0HurXohx3i1ZPwxPbcOwd8xJYSeV4l6Plkq3FcCa68p+z0+viPajBP4D/Y0If e1TJToGbeY7jBrNk+RxsSgyMT+CEKEY41TMSKfWED/GQn8HDmAeWMSFZLW9QkwCqur/2sUzHtTM z9lh8PSAuaAGdPLpXS+gVX0nt3EdmU8Ppmv+L4X2QSjLiLc26ewQ8uz9VCh3TB2A87MDdkdeKxm vc/dUJe17/TQwsXbQ2XxwV+g29e18A12LU8vcBE7J6ANin8Znq7CRQjby1fowGWeqZRHjdS5IKe Lo06jd911oQg= X-Received: by 2002:a17:906:9fca:b0:bea:4a9b:27e6 with SMTP id a640c23a62f3a-c097ae06f21mr215870366b.3.1781870911579; Fri, 19 Jun 2026 05:08:31 -0700 (PDT) MIME-Version: 1.0 References: <20260604.132108.405136284364833955.ishii@postgresql.org> <20260609.171307.1883356507067957349.ishii@postgresql.org> In-Reply-To: Reply-To: assam258@gmail.com From: Henson Choi Date: Fri, 19 Jun 2026 21:08:19 +0900 X-Gm-Features: AVVi8CfrIlfJbA5--7GPo5slukNPm0xhkt35hWoCKJcING_DmqgOa1DqOrUZHKA Message-ID: Subject: Re: Row pattern recognition To: jian he Cc: Tatsuo Ishii , 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 Content-Type: multipart/alternative; boundary="000000000000b86e4606549a263d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b86e4606549a263d Content-Type: text/plain; charset="UTF-8" Hi Tatsuo, > From ISO/IEC 9075-2:2016 7.15 General Rules: > ... > a) If SL does not simply contain a , then the clause> is disregarded, and the result of TE is the result of the last > , , or 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 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 --000000000000b86e4606549a263d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Tatsuo,

> From ISO/IEC 9075-2:2016 7.15 <w= indow clause> General Rules:
> ...
> a) If SL does not simpl= y 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 <havi= ng clause> of TE.

Thank you -- this is exactly the text I was mis= sing.=C2=A0 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.= =C2=A0 The General Rule you quote settles
it: disregarding an unused win= dow clause is required by the standard, and
since DEFINE is part of the = window clause, it is disregarded along with the
rest.=C2=A0 So evaluatin= g its DEFINE -- option (b) -- would mean running a clause
the standard t= ells us to ignore.

> But we already pass faulty window clauses. E= xample:
> ... ERROR: =C2=A0frame ending offset must not be negative .= ..
> I think if we detect faulty DEFINE in the last case, it's no= t only
> against the standard but against our existing behavior.
<= br>Agreed, and the parallel is convincing.=C2=A0 An unused window already e= scapes
the negative-frame-offset check, so singling out DEFINE as the on= e clause
that must fire regardless would be inconsistent with how the re= st of an
unused window already behaves.

This also matches the pla= nner: select_active_windows() drops any window with
no referencing Windo= wFunc, and its comment already cites the same <window
clause> Gene= ral Rules (General Rule 4) as its basis.

Either way, the disregard r= ule governs only execution.=C2=A0 A failure raised in
the parser, transf= orm, rewrite, or planner is a separate, static layer the
rule does not t= ouch.=C2=A0 And at execution there is nothing to evaluate: an
unused win= dow is never turned into a WindowAgg node, so its DEFINE is never
reache= d.

So I'm convinced -- let's keep (a), the current behavior,= and I'll treat
this open question as closed, with no patch change.= =C2=A0 For the record, the two
halves stay cleanly separated: the RPR DE= FINE 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
--000000000000b86e4606549a263d--