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 1wfZuS-005WUT-1d for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Jul 2026 09:10:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wfZuQ-006Rkx-0S for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Jul 2026 09:10:06 +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 1wfZuP-006Rkl-2s for pgsql-bugs@lists.postgresql.org; Fri, 03 Jul 2026 09:10:05 +0000 Received: from mail-qk2-x04.google.com ([2607:f8b0:4864:34::4]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wfZuO-00000001IEz-0cCM for pgsql-bugs@lists.postgresql.org; Fri, 03 Jul 2026 09:10:05 +0000 Received: by mail-qk2-x04.google.com with SMTP id af79cd13be357-92e862681easo14061685a.0 for ; Fri, 03 Jul 2026 02:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783069803; cv=none; d=google.com; s=arc-20260327; b=GTUTPelW7M9Sf34Y9rrtsird0np9K+NcpGExb6ueAFV3soCXwGwm9axdlVUh1w6ji1 1C1Xb8GvCiVNHgbhnQyPjl8/NfsO/o5UlK+GPqS489BviLxpHPmRJNwcEW/zrcNdQzZ5 GWS6j0jzvOsh2OgGpGcti3CF/DV6s1j0wRfWq09PfNPJ3XAZ0T3xOm91jZYlC/ByZiSc aVXCYr4s2U8oFw5N6xoHb2uI414iSUtGCVgwwwnKBiy2QmNCxHniAovZl7WIuEDBy6Dy SGjleaWwV9v1OHPFcpP+Z/N4YL4t3yBiOV91yPOC2tdHIyqYgs9aoKTMOfIPIUBElAdT 9ixA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rUmCH+Uk1RAL9P4hKHYcuSg4VfvWK+KcZC+pY4r3pHA=; fh=kIcebFTT8/FZZb/xEvhP2apE4zfKsZs+M3JI/GI2e8s=; b=j7XKTWjVQRbBnAjoQ3S4stXzRTjO4UY3wLDQc6sW/DMC6hqgtX6kHyU3zZzsaOe+kS 9Ca63Y+gCxyt5jTeEiU1ULmfzSS31V/HQ71xcvtIcQUmS0KIWHCQWrUr7740UO0H6KN0 InOWn6w2QajjFXP4EHKN7L9m6rKs5Vc7Jq+xNEiMbGaCag1yawDY6bs5cpGcM4Iownrj noipj3QBAWZR2vnn1egSRADfdwjLWb+K/pXpv3IRWPV3rbrme/ez2KwLpCb6GMIcsJ8g lYfKH9SQt26CAeQ5gCmbZ2l6Iw4J8Y6fL57iHG4czbodcrSvjzo/Ddwi5SsdKaRxwvVK EUpQ==; darn=lists.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=1783069803; x=1783674603; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=rUmCH+Uk1RAL9P4hKHYcuSg4VfvWK+KcZC+pY4r3pHA=; b=Xc75qXJzY19nLEQNDAWRn5oTy4BxrPb+nxtQPQ9V2odN9fd5d/G8FPd4HMGKTBodBN 2SuEHvQVZegoOp0rr+srpmiWYKSzqaNJJrLLSIyYA6fYVz6Rbpns57yNHCQnBEmywZin mFpwtcLEsNO7asPqlQqET4KcgweH2Kqi4gpAwF1p6R6C1IhWdaZfREbxDr698czqXw/S FtfOI9rZiT0QZUVIK7o+ptuPpX9B2Myz4klsIuuU8OKXfo9UMu3jM/0LTaZ6ih32J2xu o1Wgwx7nb6saCCztGhvh7cbMX4u6j2hFTeTtbclrKT654DPT5WlX5UNB3827aokEAsUy jtnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783069803; x=1783674603; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rUmCH+Uk1RAL9P4hKHYcuSg4VfvWK+KcZC+pY4r3pHA=; b=Zwv6lP6eZBrjzLiqlLEZ+DKCQtbvj5rY7V2sqSUQkfzLoYWC3XepSnIZQijRxw14Wq vInhp6Iu0kYr1vIrgBZ1XmZOGX0bu1Qn0sXsqzdWUiP1HcJvvPmh4EPPiB9TI4DrHdyY rQ6kRskFD2qa1Gcf5WX85WSGMRZ7GUzGpV7NE3o7dEiEGR9k50v6NKoacye9OdgcjbBF a3AVOvgfUjMO+6NMu8dQ2cndSjgyFrl9F76ui86VWRO36LZdgB1g/2U7hC0o3RoddKGL sXaql3VBujgZ9p9TYBNOQxOGHi40HrEWx5g0iU8UyUijnyM50KgCp49L4YA0tudh/Xf5 lQXA== X-Forwarded-Encrypted: i=1; AFNElJ9SQXf/G1Nxj4XRrufJeHbrJ7NpW/8fPy/pBOIMtY9LqwpYyQWdIoio9CxSn0Z4FwHSuHyd5wFJD69m@lists.postgresql.org X-Gm-Message-State: AOJu0YwTGFTNeXEus6XtlkXU991NLUSN4tEqKPL2WOyVnP/rs3f6A1h1 i6HQO91ufkSizrwv/j9vMMs+oEh4vx7Bq/o7r7h6qiuzgWo/oHDcNp0jM9qG2V8V6h0LtDz/aGN b8NoJR64n0o5JlRP5PPSsxDzyzQKLmV8= X-Gm-Gg: AfdE7cmlwnLTZy9xqCBQZDsVoWR0yM1NRZr3ZsY8Dd3caPlJ+f7ygZm5yjv+f2jGEk0 w+wgyRlG9eHifCyY/J7V53V6J7WePiWa4PWlkH2yNtkzfAJsmQmOg6oNNraitI4guTOYBESwciZ DRpV4qvJhHc+Ce4pE6zQA0kGiGVlmgiYCgMLLHaLbmnvJVrU9BOQnre6ZbdHWa8ncAEU9UTStaL btJ95VZQgGI39+8VFHmufXVpcZCplvsnGSUbHz//jkqgmJgb3BS9StX+1akJLlrRhv0p9RPM5H3 z63mHmZYG4XGriTcKWz3NtnnzEq7onXz5FhNOjVZ0agvCwyDTbNcF2ZMXkTv9RbCxhpCzvWm7hj zUVaCf77M9yFL4A== X-Received: by 2002:a05:620a:1707:b0:92e:5137:2830 with SMTP id af79cd13be357-92e7b4201b4mr1074130485a.72.1783069802974; Fri, 03 Jul 2026 02:10:02 -0700 (PDT) MIME-Version: 1.0 References: <19533-413a1014e5d0e766@postgresql.org> In-Reply-To: From: John Naylor Date: Fri, 3 Jul 2026 16:09:52 +0700 X-Gm-Features: AVVi8Cd01734ahOMDnemCEeOQgLHviklLYiuvc_uZOzpWvpMwR-PjN9ZzT4rgXM Message-ID: Subject: Re: BUG #19533: Wrong results from WindowAgg run-condition pushdown on count() with EXCLUDE CURRENT ROW To: David Rowley Cc: Richard Guo , Chengpeng Yan , "imchifan@163.com" , "pgsql-bugs@lists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jul 3, 2026 at 10:38=E2=80=AFAM David Rowley = wrote: > It's a little hard for me to know what to do here, as I really don't > know how commonly people use the EXCLUDE clause, and more so, how > often the Run Condition optimisation will apply when those are used. > It would be good to have an idea if the bug discovery was from a > real-world case, or if it was discovered from tooling, or from looking > at the code. If it was from tooling, it must have stopped with the first case it found, as is often the case. I just tried myself and found three more apparent bugs with EXCLUDE both with and without the v1 patch. Do you want to see the reproducers, or rethink the risk/reward ratio of what's handled? I'm also not sure how common that clause is. Separately, I also I believe I found a counterexample to the part starting with /* No ORDER BY clause then all rows are peers */ : CREATE TABLE t7 (x int); INSERT INTO t7 VALUES (7), (8), (9); =3D# SELECT * FROM (SELECT x, count(*) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) = c FROM t7) s WHERE c >=3D 2; x | c ---+--- (0 rows) =3D# SELECT * FROM (SELECT x, count(*) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) = c FROM t7) s WHERE c + 0 >=3D 2; -- baseline x | c ---+--- 2 | 2 2 | 3 (2 rows) -- John Naylor Amazon Web Services