Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bw46Z-0007LO-21 for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Oct 2016 09:21:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bw46Y-0002lq-L4 for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Oct 2016 09:21:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bw45u-00023l-6T for pgsql-bugs@postgresql.org; Mon, 17 Oct 2016 09:20:30 +0000 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bw45r-0004hX-Ft for pgsql-bugs@postgresql.org; Mon, 17 Oct 2016 09:20:29 +0000 Received: by mail-lf0-x22d.google.com with SMTP id x79so284480272lff.0 for ; Mon, 17 Oct 2016 02:20:27 -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=s9uUE/mcCGeUr4HiwHTuQ0zA51CLaq5w6T89Zu+5mME=; b=ICM3IOK9nUgQdxrCG3hj2WiDnPNJk/UEuPv/SCHTF9v26N9w4GXwfWA86yFqb43glF kyRs8kw03NB08NdU+BGr5+g8D33vr5VtbLS7zzCiEdqgGO1MpYfyPaG729LXYdCb6R8n 43xFfDgsbyVqKV5Lk14sFBgKSFJ3PzlC99thGsYR8qp3levV/mo1bMZE1CgX4XKgpv6y 5Nk7HdZBreQWFUEio5BupWuaQS1dfraPiACkMnsKyrRIDJaPJ2PxD41k9rS7J20O05uZ qBnmuNOnf6iDgtsMIJD68gn3+vP2n6qcd8bE7jtD1H5RWvnv/Jke4gMxPFQK/7MxqTnH SBcg== 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=s9uUE/mcCGeUr4HiwHTuQ0zA51CLaq5w6T89Zu+5mME=; b=BWW0evC9sGWdg35wO0WxcjxgrBuyQQt1hUgBcrdoeOSr7c0QDtsR2gtawP03knWs5f IzzweT84ikL4b2vy4GMnyKQGlMvZ8eQqXhiG3zdtoIws0Pa9enRJ7vBzzG/ZW64qj3Z/ DDSZK4KXji+KL4O1GSVjHJlmshjA3QgzecpDs1gAgFFVnshhwpEw2Da/OX4DUOh+Wsu+ mFrYLfxCMUCzx81RvoZzEMEw1o7EBBxPwclnVtobzq+uDHxvSlVs1qDEBGgiLiM6I8iT e/Kx1ue2mAn5S0EFrJuHgpRfc2+yiDd885StMo6VnJi6LzYHcgLOLnn90nDi4wUWIbxt ljJg== X-Gm-Message-State: AA6/9RnG6YBTqqVSL4FtMzXHicPUdMVOYoZ8/NyTFI94OLZTwIfWUo29l599rZ7bIMsKwg== X-Received: by 10.25.22.72 with SMTP id m69mr13430683lfi.179.1476696025900; Mon, 17 Oct 2016 02:20:25 -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 u10sm1015052lff.37.2016.10.17.02.20.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Oct 2016 02:20:25 -0700 (PDT) Subject: Re: BUG #14344: string_agg(DISTINCT ..) crash To: Peter Geoghegan References: <20160929035538.20224.39628@wrigleys.postgresql.org> <22270.1475163646@sss.pgh.pa.us> <5b2d9da9-d2a9-ee53-aab4-1112f8dcf072@iki.fi> Cc: Tom Lane , David Rowley , Michael Paquier , Robert Haas , Regina Obe , PostgreSQL mailing lists From: Heikki Linnakangas Message-ID: Date: Mon, 17 Oct 2016 12:20:24 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.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 10/13/2016 08:27 PM, Peter Geoghegan wrote: > On Thu, Oct 13, 2016 at 12:59 AM, Heikki Linnakangas 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs