Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e477o-0005KJ-CE for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Oct 2017 15:16:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e477n-0004vp-VG for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Oct 2017 15:16:16 +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 1e4775-0003bK-AN for pgsql-bugs@postgresql.org; Mon, 16 Oct 2017 15:15:31 +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 1e4772-0001Xe-Hm for pgsql-bugs@postgresql.org; Mon, 16 Oct 2017 15:15:30 +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 v9GFFIJq002432; Mon, 16 Oct 2017 11:15:18 -0400 From: Tom Lane To: Andrew Gierth cc: Heikki Linnakangas , Pg Bugs Subject: Re: Improper const-evaluation of HAVING with grouping sets and subquery pullup In-reply-to: <8760bfku2u.fsf@news-spur.riddles.org.uk> References: <7dbdcf5c-b5a6-ef89-4958-da212fe10176@iki.fi> <1197.1507820787@sss.pgh.pa.us> <87efq3lq93.fsf@news-spur.riddles.org.uk> <87a80rli2w.fsf@news-spur.riddles.org.uk> <32319.1508163874@sss.pgh.pa.us> <8760bfku2u.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Mon, 16 Oct 2017 16:11:24 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2430.1508166918.1@sss.pgh.pa.us> Date: Mon, 16 Oct 2017 11:15:18 -0400 Message-ID: <2431.1508166918@sss.pgh.pa.us> 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 Andrew Gierth writes: > "Tom" == Tom Lane writes: > Tom> Uh ... but I thought the point here is that the outputs aren't > Tom> really constant in the presence of grouping sets. > select x, y, sum(z) from (select 1 as x, 2 as y, 3 as z) s > group by grouping sets (x,y); > x and y aren't constants, but z is. OK, but that just means we should put PHV wrapping around only the grouping-set columns. BTW, also need to think about GS expressions, eg select x+y, sum(z) from (select 1 as x, 2 as y, 3 as z) s group by grouping sets (x+y); Not real sure what needs to happen here. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs