pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@postgresql.org
Subject: pgsql: Fix sharing Agg transition state of DISTINCT or ordered aggs.
Date: Tue, 20 Dec 2016 07:23:42 +0000
Message-ID: <E1cJEly-0006Rt-3K@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Fix sharing Agg transition state of DISTINCT or ordered aggs.

If a query contained two aggregates that could share the transition value,
we would correctly collect the input into a tuplesort only once, but
incorrectly run the transition function over the accumulated input twice,
in finalize_aggregates(). That caused a crash, when we tried to call
tuplesort_performsort() on an already-freed NULL tuplestore.

Backport to 9.6, where sharing of transition state and this bug were
introduced.

Analysis by Tom Lane.

Discussion: https://www.postgresql.org/message-id/ac5b0b69-744c-9114-6218-8300ac920e61@iki.fi

Branch
------
REL9_6_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/ce92fc4e2540d0ce554e498adb27f0ef29199b94

Modified Files
--------------
src/backend/executor/nodeAgg.c           | 21 ++++++++++++++++++---
src/test/regress/expected/aggregates.out |  9 +++++++++
src/test/regress/sql/aggregates.sql      |  3 +++
3 files changed, 30 insertions(+), 3 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (2+ messages)

Message-ID: <E1cJEly-0006Rt-3K@gemulon.postgresql.org>
Permalink:  ../E1cJEly-0006Rt-3K@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1cJEly-0006Rt-3K@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 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-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Fix sharing Agg transition state of DISTINCT or ordered aggs.
  In-Reply-To: <E1cJEly-0006Rt-3K@gemulon.postgresql.org>
  References: <E1cJEly-0006Rt-3K@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