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.98.2) (envelope-from ) id 1xBFLa-0000000368e-08f5 for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Sep 2026 17:41:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xBFLZ-0000000Am0W-0NL4 for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Sep 2026 17:41:01 +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.98.2) (envelope-from ) id 1xBFLY-0000000Am0O-3JZ4 for pgsql-hackers@lists.postgresql.org; Mon, 28 Sep 2026 17:41:00 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xBFLX-00000001j56-0GbA for pgsql-hackers@postgresql.org; Mon, 28 Sep 2026 17:40:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 68SHeiR9506577; Mon, 28 Sep 2026 13:40:44 -0400 From: Tom Lane To: Robert Haas cc: Jeevan Chalke , Vik Fearing , PostgreSQL Hackers , Isaac Morland Subject: Re: ON EMPTY clause for aggregate and window functions In-reply-to: References: <636820.1789651904@sss.pgh.pa.us> <645015.1789660502@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Mon, 28 Sep 2026 13:36:47 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <506575.1790617244.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Mon, 28 Sep 2026 13:40:44 -0400 Message-ID: <506576.1790617244@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > On Thu, Sep 24, 2026 at 9:18 AM Jeevan Chalke < > jeevan.chalke@enterprisedb.com> wrote: >> It only accepts ON EMPTY on sum() and product(), the two aggregates the >> standard actually defines this for. At parse time, once we know the >> call is sum() or product(), it is just rewritten to >> COALESCE(sum(expr), default). Nothing else changes: > I can't get excited about supporting this syntax for just 2 aggregates and > nothing else. Yeah, that would be totally not in keeping with this project's usual attitudes about extensibility. "Rewrite at parse time" is an ugly hack anyway, because then view dumps and so forth expose the implementation. It'd need to be done later. regards, tom lane