Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4MYI-0000Gq-Gm for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Oct 2017 07:44:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e4MYH-00014X-LU for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Oct 2017 07:44:37 +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 1e4MYF-00013o-Nl for pgsql-bugs@postgresql.org; Tue, 17 Oct 2017 07:44:35 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e4MYB-0002tg-Ql for pgsql-bugs@postgresql.org; Tue, 17 Oct 2017 07:44:34 +0000 Received: by mail-lf0-x242.google.com with SMTP id a132so887954lfa.7 for ; Tue, 17 Oct 2017 00:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=05fZxizAqnks0JUSONFBJAY8A1MtvGBO9+sg6oWCako=; b=gMhCSNRy7LqETTPK7mz0Z3edCd4UFu1xcDp0b8SLWFFZre81YZECistWpw6Xgcp+fO 0YVCm+EU15qzTBAvTwm8kgeXWr1YEha5eiIiBQ014AR4DIKY25AkAuAKjmBhMlyCcvpt ErNyvuDFb21i1QIAP/YRCnjEGrZvHG2KeNkXQjL6lNx9bKzFVVFyVtx7T1Lpuderou+k /m3HqDgmu4mOSzxrdv8T+NSKbF0zjcvf1Rkvx3w4ZxB0wVqdwVTpvzeyPiN5U/KS/rHI cc0S+9ysPhU6JoK15j6QROG0AP3A687y88AQpZmY8aeTZrDuMn/v7NB/IyrBi/q+NuCE YWwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=05fZxizAqnks0JUSONFBJAY8A1MtvGBO9+sg6oWCako=; b=iHSkLwFW1dGAz0stjhUcY+yp1kc6Cd05FSUY78vtouViNk742NYpnVtD4jbYRrWOsU DUZO/Jue33NkHmSR6Cz0VMcOBiez2uraUKE0+dBuj2n9QjMPYSdUqMDgZN+7FLvrhtyX Oc3LZ1COXNSqPqUeYDP5HR/lUCnr7DCxfTljF0uLsRpXs7wIupsRJBFEF4Gy9YPeOfkm RkeawfsKiZOqsor3iSHZDenT3SASJOdTN8jvme44rtiTAgI7a+O8HGJ7+Is44u54HrpO M7sEbq8N6ALGWXRk93XK6UPcZoroSczr2JQKNpU1vIMRy39tNdwzwtluAHQU7vwIpkVH 4jnA== X-Gm-Message-State: AMCzsaUDaL7BVkuOR5s/VnRZM9kkeTc6dbM5X5VuAODkPS1bZwJOTES2 t5atDwmmqvFSm04yoO4Iz0LoUQ== X-Google-Smtp-Source: ABhQp+Szw8vYsAyNDCmIEkVHLYl0c9oaEhrYrY4ucyEJ9NEokKAXEU5cpEpeiJJ4j7V0GlNGIaq9Iw== X-Received: by 10.25.142.141 with SMTP id a13mr4361596lfl.90.1508226268410; Tue, 17 Oct 2017 00:44:28 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibng32-54fb4e-103.dhcp.inet.fi. [84.251.78.103]) by smtp.gmail.com with ESMTPSA id g81sm2353240ljb.48.2017.10.17.00.44.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 00:44:27 -0700 (PDT) Subject: Re: Improper const-evaluation of HAVING with grouping sets and subquery pullup To: Andrew Gierth , Tom Lane Cc: Pg Bugs 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> <2431.1508166918@sss.pgh.pa.us> <871sm3ktl7.fsf@news-spur.riddles.org.uk> From: Heikki Linnakangas Message-ID: Date: Tue, 17 Oct 2017 10:44:23 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <871sm3ktl7.fsf@news-spur.riddles.org.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 Here's another interesting case, without any subqueries: postgres=# SELECT g as newalias1, g as newalias3 FROM generate_series(1,3) g GROUP BY newalias1, ROLLUP(newalias3); newalias1 | newalias3 -----------+----------- 1 | 1 3 | 3 2 | 2 2 | 2 3 | 3 1 | 1 (6 rows) Why are there no "summary" rows with NULLs, despite the ROLLUP? If you replace one of the g's with (g+0), you get the expected result: postgres=# SELECT g as newalias1, (g+0) as newalias3 FROM generate_series(1,3) g GROUP BY newalias1, ROLLUP(newalias3); newalias1 | newalias3 -----------+----------- 1 | 1 3 | 3 2 | 2 2 | 3 | 1 | (6 rows) - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs