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 1we02D-004UFi-2e for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Jun 2026 00:39:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1we02B-0004bT-1c for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Jun 2026 00:39:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1we02B-0004bK-0X for pgsql-bugs@lists.postgresql.org; Mon, 29 Jun 2026 00:39:35 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1we029-00000000hwK-0aXA for pgsql-bugs@lists.postgresql.org; Mon, 29 Jun 2026 00:39:34 +0000 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-7e9beead38fso1203561a34.2 for ; Sun, 28 Jun 2026 17:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782693571; cv=none; d=google.com; s=arc-20260327; b=roKNuXyV/WyWFyNKJIut8TZhcS+yhacLhhOnRRD1KQUhFjX4uJYsm8JNGINi3I6X6U 31hcqeTc4k5w56KKQUr2+7XyegyH/3nWRry1Uf6hoKqSJQiKAKwATdal2K/WN3zPt+uR HJWddBrRgkJ3rheKFlhE43hhPvnsZuGs94Xf7GhvdGF/6cb4ClE01EPktO+jvOyWTQSj ZbVbzyElB3E9uqCFdUE11bT1AUy0md5rbKCfftIairT9tFlAYEOY4rb9IG5saXKmGws1 28zlFxyFsTFljvCWzrMCM/xSvDe5JCxiA09CsKA+eZE6N/gPEbkN0MfGc12rSRQ9ykz3 vJdw== 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=4V6osBjF+MejrOooAAnBmV54uyWTKB6/aoXdAfPeoGQ=; fh=3zGCgShpvx4AMjrEyk7BGfVbTnp/EmEOUKRc/Ae/CCY=; b=gznsbTWCDwve1dVWGze1GnQUo7eMU2FVttWM02VU6CTC1jeLO5z8BtpNq0H4TGXZtk CsMgR6s5bUwvs8+vr4Oo3e8s7thd0Uk2OXSiTeMzWMbh11vK/2KwOBgN0MGDi19Tz/dF JjVhS/QNctW2h2yUitz9yspyc1hCl0oAy7R+JudivG2NDwnlydU3chJhLtQpM2fpBY5c rv9m9NO10ZTSMpOj8Xp0GGfgW4SVIzFtx0OT+M/r21QbOP9necsF1FMSkeDSSPlRzANB s15koFkJYncyP9KZemNhD0ivClHktawk6xttRfQDTeQN32RAL6IgDZ+m1d/RxQCr7MCY fGXA==; 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=1782693571; x=1783298371; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4V6osBjF+MejrOooAAnBmV54uyWTKB6/aoXdAfPeoGQ=; b=lmCZ6s/VdHRNjhaTfkXrF3IfkZMvX2RCwoVih/OUUITXWCvu8b2iuaiYYkh9HCbTM1 H9ik/iQYD4hMx3qYFVXpTkyVQofGeO1KZdyR2q7+RrT1AHGEvMysdjdEsEzaWxrqeo9S MF6DwDDTKto29M1YLPM1JLdUlm6AmQwQF85ZbAde+zf8uj9bvCOZD4a2oiYQ9e2obk48 H1FO/CGgkH6zNvahXx6nu+de42gRGhF9giGiiun46VBourkKkjXd0iEQ35wgMhEN2p57 QGYewrD8E3+RU7LDW3VfStcwex1ybQ3Ti4ywIc6aERUThSJIj6clhBXY0ZmfZIiSswOn Zs4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782693571; x=1783298371; h=content-transfer-encoding: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; bh=4V6osBjF+MejrOooAAnBmV54uyWTKB6/aoXdAfPeoGQ=; b=crQ3DBbHuKoaSB4jqq0wyyty9CHGCU/NgTY1iObfzkHkC9CwHzH4+QEVWvfT4JYScJ ioNOASPGsbQyW+e+TVuXc5OEF8mRjVvgDdDOZl7Dtew8ep/+jAX3FaIVds58DixcnknC aQr3HwOtwNfmx2FmnIzRiibiZ5HZbbuik3eSCm0exWjrb62fLfLPqlqQCSMPhHYpDNb9 oMHBOqY3CPdycYguZ1Ud5A2GtrcDxSj922XdS7eFJqbfQ/fdObskyPgI82rIULf+MvIj v/LYQBSnYpzigkR94ZCCvqYAAlNJ0hrlMO7r1K42+9jPuP6UnT2jt67HtveL6QVcwAX4 KqKg== X-Forwarded-Encrypted: i=1; AFNElJ+9wvoris1RlIyQryLLxe8N5hQ5pSekLveEYKRsmOAmh0JUj0q73zpSuR8tTf/QJDlYudI+IPo4dnbv@lists.postgresql.org X-Gm-Message-State: AOJu0Yw1Zg7qxxja6PbgSkv8CfilTrWapIsLRuZy01xnFHbTAUEbLTHj mkI2wDY1Xasq9gmXR2bzJWINJ9NPKZGDZwU5iiznnw/62J5jRGSf6o9q/mQrXdc1LSMJfZ5tsvr Pv8jIV1syGnQSsXeBKozXQMqUSNvXaXA= X-Gm-Gg: AfdE7ckE83UUstRM1Zu48w3NRuE68D8fYz0DjU4u2F4Z44WnXV+OwTLEnEJVdkFGjik ETEMZJBSFH+2s2H8PsneHv2MmbUWCjxlAh9YRA6GXXbbJa5MVAaCamiwpIM/mgwl/TUDjP3Lzj0 PXBcWxlNJPfLzsfF8M+9fFsD7FzS7tbr3pCH04G1UAa7omxopjU7X3pHlYLsZO+L2yCgQrotD1t hBNv3vzjSZrz4eS3PQCGk6USASUaw1AZvauN/BD+w1Liy0vm1GiiMkiRm+KLovvJMCdq9Oen8A= X-Received: by 2002:a05:6820:1614:b0:6a1:4e1d:5398 with SMTP id 006d021491bc7-6a14e1d5453mr6627938eaf.4.1782693570939; Sun, 28 Jun 2026 17:39:30 -0700 (PDT) MIME-Version: 1.0 References: <19533-413a1014e5d0e766@postgresql.org> In-Reply-To: From: Richard Guo Date: Mon, 29 Jun 2026 09:39:20 +0900 X-Gm-Features: AVVi8Cfbxm5aElCUb0p3Y_cJAaJNfKO1EvoIzpnheGKJrxPgKDzmT0UWM4zpM_U Message-ID: Subject: Re: BUG #19533: Wrong results from WindowAgg run-condition pushdown on count() with EXCLUDE CURRENT ROW To: Chengpeng Yan Cc: "imchifan@163.com" , "pgsql-bugs@lists.postgresql.org" , David Rowley 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 Sun, Jun 28, 2026 at 1:53=E2=80=AFAM Chengpeng Yan wrote: > The attached patch takes the conservative route: int8inc_support() no > longer reports count() as monotonic when the window frame has > FRAMEOPTION_EXCLUSION. The added regression tests cover the reported > case, related EXCLUDE variants, and a count(*) case. They also check > that the excluded-frame query keeps a normal Filter instead of a > WindowAgg Run Condition. I think the fix is on the right track. One nit is that it might be better to use if/else if structure here. The other nit is that the test case is over-heavy; it should be kept as minimal as possible. > Thoughts welcome on whether this is the right boundary, or whether some > narrower excluded-frame cases should still prove monotonicity > separately. I wonder if we should still support count(*) with EXCLUDE CURRENT ROW, as that always removes exactly one row, so it is still monotonic. + if ((frameOptions & FRAMEOPTION_EXCLUSION) && + ((frameOptions & FRAMEOPTION_EXCLUSION) !=3D FRAMEOPTION_EXCLUDE_CURRENT_ROW || + req->window_func->winfnoid !=3D F_COUNT_)) + monotonic =3D MONOTONICFUNC_NONE; - Richard