Re: BUG #14344: string_agg(DISTINCT ..) crash - Mailing list pgsql-bugs

From Peter Geoghegan
Subject Re: BUG #14344: string_agg(DISTINCT ..) crash
Date
Msg-id CAM3SWZTQcmnutjza3GdLLC-Y4WmF_FKAfAxLF4EMVK_dS3RsEQ@mail.gmail.com
Whole thread Raw
In response to Re: BUG #14344: string_agg(DISTINCT ..) crash  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #14344: string_agg(DISTINCT ..) crash  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-bugs
On Thu, Sep 29, 2016 at 4:40 PM, Tom Lane <tgl@sss.pgh.pa.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #14344: string_agg(DISTINCT ..) crash
Next
From: Heikki Linnakangas
Date:
Subject: Re: BUG #14344: string_agg(DISTINCT ..) crash