pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <rhodiumtoad@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix array size allocation for HashAggregate hash keys.
Date: Thu, 23 May 2019 14:49:28 +0000
Message-ID: <E1hTp28-0002eA-C9@gemulon.postgresql.org> (raw)

Fix array size allocation for HashAggregate hash keys.

When there were duplicate columns in the hash key list, the array
sizes could be miscomputed, resulting in access off the end of the
array. Adjust the computation to ensure the array is always large
enough.

(I considered whether the duplicates could be removed in planning, but
I can't rule out the possibility that duplicate columns might have
different hash functions assigned. Simpler to just make sure it works
at execution time regardless.)

Bug apparently introduced in fc4b3dea2 as part of narrowing down the
tuples stored in the hashtable. Reported by Colm McHugh of Salesforce,
though I didn't use their patch. Backpatch back to version 10 where
the bug was introduced.

Discussion: https://postgr.es/m/CAFeeJoKKu0u+A_A9R9316djW-YW3-+Gtgvy3ju655qRHR3jtdA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/44e95b5728a4569c494fa4ea4317f8a2f50a206b

Modified Files
--------------
src/backend/executor/nodeAgg.c           | 29 ++++++++++++++++++++++-------
src/test/regress/expected/aggregates.out | 18 ++++++++++++++++++
src/test/regress/sql/aggregates.sql      |  7 +++++++
3 files changed, 47 insertions(+), 7 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1hTp28-0002eA-C9@gemulon.postgresql.org>
Permalink:  ../E1hTp28-0002eA-C9@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hTp28-0002eA-C9@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: rhodiumtoad@postgresql.org
  Subject: Re: pgsql: Fix array size allocation for HashAggregate hash keys.
  In-Reply-To: <E1hTp28-0002eA-C9@gemulon.postgresql.org>
  References: <E1hTp28-0002eA-C9@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