Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpeox-00087E-DH for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Sep 2016 17:08:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bpeow-0007ie-W6 for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Sep 2016 17:08:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bpeov-0007g2-VC for pgsql-bugs@postgresql.org; Thu, 29 Sep 2016 17:08:30 +0000 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bpeop-0007kO-TP for pgsql-bugs@postgresql.org; Thu, 29 Sep 2016 17:08:28 +0000 Received: by mail-lf0-x22d.google.com with SMTP id t81so19068224lfe.0 for ; Thu, 29 Sep 2016 10:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=ol+XaV6kUf3JgkHrbl7r/h8OeTN1V1yNQiy3O5n+DE8=; b=kyIWD2Sc/xV5/O6Mt+4LgApQmicHF1/VzBOyqc/fvBQIQ5BkqrI30KgbWlYfv1ekoi VxSRjzDtEWeo0XCzjq3kbklWY/KXwucLsAYjAQ/rS6qKLX/5AixTQusQuwFCUlcsrsbR yw/y2DLgDpgQ+mf4QYZTmRoo1tXGW8EssUVGQVO2zvUs+NKFLanAhfLU3oFWhlIkZa9g 6pRS0n5mgqK9KFsBrFOFIVNGezVDq9OyqTInkeU3RGvWy3o4y4gzIuNbV+NlCw9wHwpm 16F/ogfYCgTVHd3WsGqmJ4jkEQcqoWqAFLzVq1Z2C2v7sOffFca7gqmgkVtU1G9dThl4 UsaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ol+XaV6kUf3JgkHrbl7r/h8OeTN1V1yNQiy3O5n+DE8=; b=VZ0T6LB0GeCzZdWSjOkLH2u96n4Daji5xIWL5c9HX+WOxatCrx4aaBMLdBeEWtmUEL 06CaMEXPE8EOmiI8fzxNT9zdpGOiBkRqjuHAEgD9kAH9+c6Tc2u6u9qT1sdfdfvVJsC8 lO7S+ONz6TTfUnfBQyw/TMEB9k5X8//BhM4BmKpUV2AKdVbww3DTdSBN30TX1Z93O8rU XcejxzYlf1lnrnkIfs9cjDyawEX0xFyTj+U1bRLM89rTd+mywHnxhY5HuUgFGocAMfZm +w+2Ohd18kPvLisiupSrqBoJp/7qetxsSgy6kFgem8vysZPf3rxYu9/jKz3DraOFXFDF 5wCQ== X-Gm-Message-State: AA6/9RlQkavdn15BpaH3W0A+DjaQhE1Mvmy5cLIyWWgaA22Q6tN0AGmZHiCD9Ivha2QGRg== X-Received: by 10.25.129.147 with SMTP id c141mr984409lfd.59.1475168901249; Thu, 29 Sep 2016 10:08:21 -0700 (PDT) Received: from [192.168.1.111] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id 23sm2295375lfr.5.2016.09.29.10.08.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Sep 2016 10:08:20 -0700 (PDT) Subject: Re: BUG #14344: string_agg(DISTINCT ..) crash To: Peter Geoghegan , Tom Lane References: <20160929035538.20224.39628@wrigleys.postgresql.org> <12479.1475122250@sss.pgh.pa.us> <000001d21a09$dd22a9f0$9767fdd0$@pcorp.us> <22270.1475163646@sss.pgh.pa.us> Cc: David Rowley , Michael Paquier , Robert Haas , Regina Obe , PostgreSQL mailing lists From: Heikki Linnakangas Message-ID: Date: Thu, 29 Sep 2016 20:08:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 09/29/2016 07:04 PM, Peter Geoghegan wrote: > On Thu, Sep 29, 2016 at 4:40 PM, Tom Lane 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs