Re: BUG #14344: string_agg(DISTINCT ..) crash

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Regina Obe <lr(at)pcorp(dot)us>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14344: string_agg(DISTINCT ..) crash
Date: 2016-09-29 16:04:55
Message-ID: CAM3SWZTQcmnutjza3GdLLC-Y4WmF_FKAfAxLF4EMVK_dS3RsEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Sep 29, 2016 at 4:40 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> My immediate reaction to this is WTF. It seems like you have completely
> broken the expected contract of tuplesort_gettupleslot, which is that
> it copies the data into caller-owned memory. That cannot stand.

Other comparable routines, like tuplesort_getindextuple(), could be
argued to have always had a contract that allows for this kind of
thing (recycling batch memory) because they get to examine a
*should_free pointer -- do you accept that much?
tuplesort_gettupleslot() does that for callers that happen to want to
use a tuple slot, rather than a direct caller tuple. So, it doesn't
seem like there is a very hard distinction there; that could also have
broken something in an extension too, since the lifetime of memory
controlled by tuplesort (should_free = false cases, managed by
tuplesort memory context) was always a bit unclear.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2016-09-29 17:08:19 Re: BUG #14344: string_agg(DISTINCT ..) crash
Previous Message Tom Lane 2016-09-29 15:40:46 Re: BUG #14344: string_agg(DISTINCT ..) crash