From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Pól Ua Laoínecháin <linehanp@tcd.ie>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: Using a TRIGGER with window functions.
Date: Mon, 16 Aug 2021 17:25:50 -0400
Message-ID: <1025332.1629149150@sss.pgh.pa.us> (raw)
In-Reply-To: <987976.1629145486@sss.pgh.pa.us>
References: <CAF4RT5TFeFkpVYTp70ko8m50J5RtpZxs_hLLbZjKpamoadEkqQ@mail.gmail.com>
<CAKFQuwZY5C+3i5BT_B-zV4azNy4bVfvfvA=rbs7nfz5gZ+wbqw@mail.gmail.com>
<987976.1629145486@sss.pgh.pa.us>
I wrote:
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
>> On Sun, Aug 15, 2021 at 1:24 AM Pól Ua Laoínecháin <linehanp@tcd.ie> wrote:
>>> Why are window functions now allowed in UPDATEs
> I suspect the error check was just copied from the aggregate-function
> case. It's clear why we can't put aggregates in UPDATE: there'd no
> longer be a one-to-one correspondence with original rows. But that
> argument doesn't hold for window functions, so at least in principle
> it seems like we could allow it. The utility doesn't seem very high
> though, so if it takes more work than "delete the error check" I'm
> not sure anyone will care to bother.
Out of curiosity, I did spend a few minutes poking at this, and as
I feared it's not all that trivial. I think that the planner and
executor might mostly Just Work, but there are various gaps in the
parser. One interesting point is that the UPDATE syntax has no
provision for a WINDOW clause, so there'd be no way to share window
definitions across different window functions. While that's not exactly
a deal-breaker, it'd be weird compared to how things work in SELECT.
Would we be willing to go to the trouble of adding such a clause to the
syntax? I dunno; it'd certainly enlarge the footprint of a patch for
this by a lot.
regards, tom lane
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-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, linehanp@tcd.ie
Subject: Re: Using a TRIGGER with window functions.
In-Reply-To: <1025332.1629149150@sss.pgh.pa.us>
References: <CAF4RT5TFeFkpVYTp70ko8m50J5RtpZxs_hLLbZjKpamoadEkqQ@mail.gmail.com> <CAKFQuwZY5C+3i5BT_B-zV4azNy4bVfvfvA=rbs7nfz5gZ+wbqw@mail.gmail.com> <987976.1629145486@sss.pgh.pa.us> <1025332.1629149150@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