pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Cc: Vik Fearing <vik@postgresfriends.org>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Isaac Morland <isaac.morland@gmail.com>
Subject: Re: ON EMPTY clause for aggregate and window functions
Date: Mon, 28 Sep 2026 13:40:44 -0400
Message-ID: <506576.1790617244@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoY2feo+4pbB6C84WPWOgv1Cfk8Y5sWfb=pi3jm4dm2COA@mail.gmail.com>
References: <CAM2+6=VS=fSKxfimW6Th9iu_xjbxOEAKg4eYwaa=SMg3X8pHaQ@mail.gmail.com>
	<CAMsGm5fxS7+WbQ_mAziiTH8GxqurmVMKUFG5bm2pM7X+JCzpug@mail.gmail.com>
	<CAM2+6=Ws0Z2BmLv=NGe3B7ZZLT3y6RQxXwGKbQErYFmCFEd9Sw@mail.gmail.com>
	<CAM2+6=ULokLQY+-2FiY95Rp5CwV7nRF0a0dP9DzO6mb1_mKn6g@mail.gmail.com>
	<CA+TgmoYfZW9y_T8A1nykRUcvJ2FQtMpBjgkq=+TCdq0-odF4=w@mail.gmail.com>
	<636820.1789651904@sss.pgh.pa.us>
	<e9454ec0-6b35-49d6-aac3-7c5f1deeb309@postgresfriends.org>
	<645015.1789660502@sss.pgh.pa.us>
	<CAM2+6=VaUg4y5H2cpyKvuVgemL7gqdVYtv7hr1nhzJXMzX5HRQ@mail.gmail.com>
	<CA+TgmoY2feo+4pbB6C84WPWOgv1Cfk8Y5sWfb=pi3jm4dm2COA@mail.gmail.com>

Robert Haas <robertmhaas@gmail.com> 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





view thread (14+ messages)  latest in thread

Message-ID: <506576.1790617244@sss.pgh.pa.us>
Permalink:  ../506576.1790617244@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/506576.1790617244@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, jeevan.chalke@enterprisedb.com, vik@postgresfriends.org, isaac.morland@gmail.com
  Subject: Re: ON EMPTY clause for aggregate and window functions
  In-Reply-To: <506576.1790617244@sss.pgh.pa.us>
  References: <CAM2+6=VS=fSKxfimW6Th9iu_xjbxOEAKg4eYwaa=SMg3X8pHaQ@mail.gmail.com> <CAMsGm5fxS7+WbQ_mAziiTH8GxqurmVMKUFG5bm2pM7X+JCzpug@mail.gmail.com> <CAM2+6=Ws0Z2BmLv=NGe3B7ZZLT3y6RQxXwGKbQErYFmCFEd9Sw@mail.gmail.com> <CAM2+6=ULokLQY+-2FiY95Rp5CwV7nRF0a0dP9DzO6mb1_mKn6g@mail.gmail.com> <CA+TgmoYfZW9y_T8A1nykRUcvJ2FQtMpBjgkq=+TCdq0-odF4=w@mail.gmail.com> <636820.1789651904@sss.pgh.pa.us> <e9454ec0-6b35-49d6-aac3-7c5f1deeb309@postgresfriends.org> <645015.1789660502@sss.pgh.pa.us> <CAM2+6=VaUg4y5H2cpyKvuVgemL7gqdVYtv7hr1nhzJXMzX5HRQ@mail.gmail.com> <CA+TgmoY2feo+4pbB6C84WPWOgv1Cfk8Y5sWfb=pi3jm4dm2COA@mail.gmail.com> <506576.1790617244@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox