pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Aleksandr Parfenov <a.parfenov@postgrespro.ru>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: PostgreSQL crashes with SIGSEGV
Date: Wed, 07 Feb 2018 19:41:48 -0500
Message-ID: <10697.1518050508@sss.pgh.pa.us> (raw)
In-Reply-To: <CAH2-Wzm83typmXzf2vpJRHO4pd6zjUvBoaUBfNesS=aHUn1K3Q@mail.gmail.com>
References: <1512661638.9720.34.camel@oopsware.de>
	<CAH2-WzmxBVYUrqtmOyP9jB1j2ZO7xTpPx65ZKTO362Qg0MRgxA@mail.gmail.com>
	<151608914608.25640.2144132915573008595.pgcf@coridan.postgresql.org>
	<14267.1516216998@sss.pgh.pa.us>
	<CAH2-WzmAKo=KoBJrTB0M7UUnM-L=Gycs_=iT8+Z2YohmxEbFWg@mail.gmail.com>
	<4977.1516221082@sss.pgh.pa.us>
	<CAH2-WzkQzCaEkvdk2vyD1kNaKtTdYAM4r62krPFtytjxEu8A1A@mail.gmail.com>
	<6358.1516222816@sss.pgh.pa.us>
	<CAH2-WzmcLiz8GorHZ3USPNyR=LZS4S5VqXBOwcQWaMLF9Z0Lpg@mail.gmail.com>
	<CAH2-Wzm83typmXzf2vpJRHO4pd6zjUvBoaUBfNesS=aHUn1K3Q@mail.gmail.com>

Peter Geoghegan <pg@bowt.ie> writes:
> On Wed, Jan 17, 2018 at 2:23 PM, Peter Geoghegan <pg@bowt.ie> wrote:
>> A complicating factor for this fix of mine is that mode_final() seems
>> to have its own ideas about tuple memory lifetime, over and above what
>> tuplesort_getdatum() explicitly promises, as can be seen here:
>> /*
>> * Note: we *cannot* clean up the tuplesort object here, because the value
>> * to be returned is allocated inside its sortcontext.  We could use
>> * datumCopy to copy it out of there, but it doesn't seem worth the
>> * trouble, since the cleanup callback will clear the tuplesort later.
>> */

>> ISTM that either grouping sets or mode_final() must necessarily be
>> wrong, because each oversteps, and infers a different contract from
>> tuplesort tuple fetching routines (different assumptions about memory
>> contexts are made in each case). Only one can be right, unless it's
>> okay to have one rule for tuplesort_getdatum() and another for
>> tuplesort_gettupleslot() (which seems questionable to me). I still
>> think that grouping sets is right (and that mode_final() is wrong). Do
>> you?

> It would be nice to get an opinion on this mode_final() + tuplesort
> memory lifetime business from you, Tom.

I'm fairly sure that that bit in mode_final() was just a hack to make
it work.  If there's a better, more principled way, let's go for it.

> Note that you removed the quoted comment within be0ebb65, back in October.

There were multiple instances of basically that same comment before.
AFAICS I just consolidated them into one place, in the header comment for
ordered_set_shutdown.

			regards, tom lane




view thread (33+ messages)  latest in thread

Message-ID: <10697.1518050508@sss.pgh.pa.us>
Permalink:  ../10697.1518050508@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10697.1518050508@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pg@bowt.ie, a.parfenov@postgrespro.ru, pgsql-hackers@lists.postgresql.org
  Subject: Re: PostgreSQL crashes with SIGSEGV
  In-Reply-To: <10697.1518050508@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox