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

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Peter Geoghegan <pg(at)heroku(dot)com>, 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 17:08:19
Message-ID: ce6f5ca3-1576-43dd-e02d-e23f344ee316@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 09/29/2016 07:04 PM, Peter Geoghegan wrote:
> 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?

The comments in those other routines explicitly say that "If it is not
set [*should_free], caller should not use tuple following next call
here". I also didn't notice that tuplesort_gettupleslot doesn't contain
say that, until now.

That's unfortunate. AFAICS, we have no choice but palloc(), when
tuplesort_gettupleslot() is used. For version 10, maybe we should
reconsider that API.

- Heikki

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2016-09-29 17:10:57 Re: vacuumdb parallel has a deadlock detected in 9.5.4
Previous Message Peter Geoghegan 2016-09-29 16:04:55 Re: BUG #14344: string_agg(DISTINCT ..) crash