pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix unnecessary use of moving-aggregate mode with non-moving fra
Date: Wed, 27 Mar 2024 17:39:52 +0000
Message-ID: <E1rpXFg-005xTI-Bs@gemulon.postgresql.org> (raw)

Fix unnecessary use of moving-aggregate mode with non-moving frame.

When a plain aggregate is used as a window function, and the window
frame start is specified as UNBOUNDED PRECEDING, the frame's head
cannot move so we do not need to use moving-aggregate mode.  The check
for that was put into initialize_peragg(), failing to notice that
ExecInitWindowAgg() calls that function before it's filled in
winstate->frameOptions.  Since makeNode() would have zeroed the field,
this didn't provoke uninitialized-value complaints, nor would the
erroneous decision have resulted in more than a little inefficiency.
Still, it's wrong, so move the initialization of
winstate->frameOptions earlier to make it work properly.

While here, also fix a thinko in a comment.  Both errors crept in in
commit a9d9acbf2 which introduced the moving-aggregate mode.

Spotted by Vallimaharajan G.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/18e7f2a5167.fe36253866818.977923893562469143@zohocorp.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/de3c5b18729a234df0b9203e195a2a5c168ef1cd

Modified Files
--------------
src/backend/executor/nodeWindowAgg.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1rpXFg-005xTI-Bs@gemulon.postgresql.org>
Permalink:  ../E1rpXFg-005xTI-Bs@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rpXFg-005xTI-Bs@gemulon.postgresql.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix unnecessary use of moving-aggregate mode with non-moving fra
  In-Reply-To: <E1rpXFg-005xTI-Bs@gemulon.postgresql.org>

* 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