Re: Improper const-evaluation of HAVING with grouping sets and subquery pullup
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Date: 2017-10-17T07:44:23Z
Lists: pgsql-bugs
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
Commits
-
Fix incorrect handling of subquery pullup in the presence of grouping sets.
- ff99d7761aa4 9.5.11 landed
- d3ca1a6c3721 10.2 landed
- 90947674fc98 11.0 landed
- 6520d4a96928 9.6.7 landed
-
Make setrefs.c match by ressortgroupref even for plain Vars.
- 6a81ba1d4d26 10.1 landed
- 37b4e0fe9964 9.6.6 landed
- 08f1e1f0a47b 11.0 landed
-
Make the upper part of the planner work by generating and comparing Paths.
- 3fc6e2d7f5b6 9.6.0 cited