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

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-10-17 09:20:24
Message-ID: d99ea540-80cc-fc1b-e1b8-3d4fd205e31f@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 10/13/2016 08:27 PM, Peter Geoghegan wrote:
> On Thu, Oct 13, 2016 at 12:59 AM, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>> Hmm. That also adds a copy to the sorted-in-mem case. That's safe, but
>> should we be worried about performance. Or is the extra copy so cheap that
>> it doesn't matter?
>
> I think that simply reading random locations in memory is the dominant
> cost, but the exact overhead should be investigated before proceeding.

Ok. In quick testing, the extra palloc() indeed didn't seem to cost much.

> The point I'm making is that we might be better off worrying about the
> general problem, by adding a tuplestore_gettupleslot()-style "copy"
> boolean argument at the same time, and having some callers pass
> "false" to avoid copying (when they determine no risk of
> use-after-free, by not keeping the contents of a slot active across
> calls to tuplesort_gettupleslot()). You indicated that you don't
> really want to go there for 9.6, but maybe it's worth reconsidering
> that. For example, maybe ABI breakage is avoided by making
> tuplesort_gettupleslot() into a shim. Or, maybe it's okay to put it in
> the release notes of 9.6.1 -- I'm not sure how manageable that is.

Pushed this isolated fix for now.

- Heikki

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-10-17 13:42:13 Re: BUG #14344: string_agg(DISTINCT ..) crash
Previous Message Tom Lane 2016-10-16 17:50:55 Re: Issue in pg_update