pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: Improper const-evaluation of HAVING with grouping sets and subquery pullup
Date: Mon, 16 Oct 2017 04:50:15 +0100
Message-ID: <87efq3lq93.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <1197.1507820787@sss.pgh.pa.us>
References: <7dbdcf5c-b5a6-ef89-4958-da212fe10176@iki.fi>
	<1197.1507820787@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:

 >> I propose the attached patch to fix that. It forces the use of
 >> PlaceHolderVars in subquery pullup, if the parent query has grouping
 >> sets and HAVING. I'm not 100% sure that's the right approach or a
 >> misuse of the placeholder system, so comments welcome.

I've been testing Heikki's patch with the havingQual condition removed,
and I haven't found any issues yet.

 Tom> One thing I'm wondering is why only the HAVING clause would be
 Tom> subject to the problem. I'm a bit surprised that the "x" in the
 Tom> targetlist didn't become a constant as well. This may be pointing
 Tom> to some klugery in the GROUPING SETS patch that we could clean up
 Tom> if we use placeholders for this.

As far as I can tell, the "x" _does_ become a constant, but then in
setrefs, because it's still labelled with a sortgroupref, it gets
replaced by a Var again. I don't recall touching any of that in the GS
work, because it was already like that for plain GROUP BY.

-- 
Andrew (irc:RhodiumToad)


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (21+ messages)  latest in thread

Message-ID: <87efq3lq93.fsf@news-spur.riddles.org.uk>
Permalink:  ../87efq3lq93.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87efq3lq93.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, tgl@sss.pgh.pa.us, hlinnaka@iki.fi
  Subject: Re: Improper const-evaluation of HAVING with grouping sets and subquery pullup
  In-Reply-To: <87efq3lq93.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>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox