Re: failures with tuplesort and ordered set aggregates (due to 5cefbf5a6c44)

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: failures with tuplesort and ordered set aggregates (due to 5cefbf5a6c44)
Date: 2015-03-04 00:14:20
Message-ID: CAM3SWZRHLaSBGUHLLV53nXDH2cSjLRgiMXZu_4iXK34t+DcY7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 3, 2015 at 3:53 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> I find your statement that this is a pre-existing issue in
> tuplesort_begin_datum() to be pretty misleading, unless what you mean
> by it is "pre-existing since November, when an earlier patch by Peter
> Geoghegan changed the comments without changing the code to match".
> Commit 5ea86e6e65dd2da3e9a3464484985d48328e7fe3, changed the comments
> for the sortKey field to say that it would be set in all cases except
> for the hash index case, but it did not make that statement true.

Agreed. I believe that is in fact what I meant. I'm not trying to
deflect blame - just to explain my understanding of the problem.

> Subsequently, another of your patches, which I committed as
> 5cefbf5a6c4466ac6b1cc2a4316b4eba9108c802, added a dependency on
> state->sortKeys always being set. Now you've got this patch here,
> which you claim makes sure that sortKeys is always set, but it
> actually doesn't, which is why the above still crashes. There are not
> so many tuplesort_begin_xxx routines that you couldn't audit them all
> before submitting your patches.

Sorry. I should have caught the hash index case too.

> Anyway, I propose the attached instead, which makes both Tomas's test
> case and the one above pass.

My patch actually matches Andrew Gierth's datumsort patch, in that it
also uses this convention, as I believe it should. For that reason,
I'd prefer to make the comment added in November true, rather than
changing the comment...I feel it ought to be true anyway (which is
what I meant about a pre-existing issue). You'll still need the
defenses you've added for the the hash case, of course. You might want
to also put a comment specifying why it's necessary, since the hash
tuple case is the oddball cases that doesn't always have "sortKeys"
set.

In other words, I suggest that you commit the union of our two
patches, less your changes to the comments around "sortKeys'.

Thanks
--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2015-03-04 00:17:23 Re: Providing catalog view to pg_hba.conf file - Patch submission
Previous Message Robert Haas 2015-03-04 00:00:16 Re: Combining Aggregates