Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJ3kl-0002Ve-Uj for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Dec 2016 19:37:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cJ3kl-0000Rk-6i for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Dec 2016 19:37:43 +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 1cJ3kk-0000Rc-PH for pgsql-bugs@postgresql.org; Mon, 19 Dec 2016 19:37:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cJ3kc-0005AO-I9 for pgsql-bugs@postgresql.org; Mon, 19 Dec 2016 19:37:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id uBJJbKR3004847; Mon, 19 Dec 2016 14:37:20 -0500 From: Tom Lane To: Heikki Linnakangas cc: Pg Bugs , David Rowley Subject: Re: Crash with a CUBE query on 9.6 In-reply-to: References: Comments: In-reply-to Heikki Linnakangas message dated "Mon, 19 Dec 2016 14:59:42 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4845.1482176240.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 19 Dec 2016 14:37:20 -0500 Message-ID: <4846.1482176240@sss.pgh.pa.us> X-Pg-Spam-Score: -5.0 (-----) 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 Heikki Linnakangas writes: > The attached test case crashes on REL9_6_STABLE and master. On 9.5, it=20 > worked. As best I can tell, this is the fault of commit 804163bc2. The problem query can be simplified to SELECT STDDEV(DISTINCT floor(sale.cn)), AVG(DISTINCT floor(sale.cn)) FROM sale,vendor WHERE sale.vn=3Dvendor.vn GROUP BY CUBE((sale.cn,sale.dt,sale.dt),(sale.pn,sale.prc),(sale.qty,sale.v= n)),sale.qty order by 1,2 ; The two aggregates share a "pertrans" state, but finalize_aggregates does not account for that and calls process_ordered_aggregate_single() twice on the same pertrans state. The second time crashes because we already deleted the tuplesort object the first time. Probably, the loop in finalize_aggregates needs to be split into two, one over the pertrans states and then a second one over the peragg states. But this code has been hacked up enough since I last looked at it that I'm hesitant to try to fix it myself. regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs