From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: Improper const-evaluation of HAVING with grouping sets and subquery pullup |
Date: | 2017-10-15 12:42:52 |
Message-ID: | 87lgkclh7t.fsf@news-spur.riddles.org.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
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.
This shows that the problem can extend to the targetlist too:
select four, x || 'x'
from (select four, ten, 'foo'::text as x from tenk1 ) as t
group by grouping sets(four, x);
four | ?column?
------+----------
3 | foox
0 | foox
1 | foox
2 | foox
| foox
(5 rows)
What seems to happen in the original case is that the 'foo' constant
ends up in the projection of the input to the aggregate node, with a Var
in the output.
--
Andrew (irc:RhodiumToad)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-10-15 14:09:10 | Re: BUG #14855: index-only scans not used in simple cases |
Previous Message | andrew | 2017-10-15 12:20:53 | BUG #14855: index-only scans not used in simple cases |