From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Ensure result of an aggregate's finalfunc is made read-only.
Date: Sun, 16 Apr 2023 18:16:51 +0000
Message-ID: <E1po6vi-003OUd-28@gemulon.postgresql.org> (raw)
Ensure result of an aggregate's finalfunc is made read-only.
The finalfunc might return a read-write expanded object. If we
de-duplicate multiple call sites for the aggregate, any function(s)
receiving the aggregate result earlier could alter or destroy the
value that reaches the ones called later. This is a brown-paper-bag
bug in commit 42b746d4c, because we actually considered the need
for read-only-ness but failed to realize that it applied to the case
with a finalfunc as well as the case without.
Per report from Justin Pryzby. New error in HEAD,
no need for back-patch.
Discussion: https://postgr.es/m/ZDm5TuKsh3tzoEjz@telsasoft.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/78d5952dd0e66afc4447eec07f770991fa406cce
Modified Files
--------------
src/backend/executor/nodeAgg.c | 18 +++++++++++----
src/backend/executor/nodeWindowAgg.c | 7 +++++-
src/test/regress/expected/aggregates.out | 37 ++++++++++++++++++++++++++++++
src/test/regress/sql/aggregates.sql | 39 ++++++++++++++++++++++++++++++++
4 files changed, 96 insertions(+), 5 deletions(-)
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: Ensure result of an aggregate's finalfunc is made read-only.
In-Reply-To: <E1po6vi-003OUd-28@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