mirror of
https://github.com/postgres/postgres.git
synced 2025-07-20 05:03:10 +03:00
Repair crash with unsortable grouping sets.
If there were multiple grouping sets, none of them empty, all of which were unsortable, then an oversight in consider_groupingsets_paths led to a null pointer dereference. Fix, and add a regression test for this case. Per report from Dang Minh Huong, though I didn't use their patch. Backpatch to 10.x where hashed grouping sets were added.
This commit is contained in:
@ -1018,6 +1018,18 @@ explain (costs off)
|
||||
-> Values Scan on "*VALUES*"
|
||||
(9 rows)
|
||||
|
||||
-- unsortable cases
|
||||
select unsortable_col, count(*)
|
||||
from gstest4 group by grouping sets ((unsortable_col),(unsortable_col))
|
||||
order by unsortable_col::text;
|
||||
unsortable_col | count
|
||||
----------------+-------
|
||||
1 | 4
|
||||
1 | 4
|
||||
2 | 4
|
||||
2 | 4
|
||||
(4 rows)
|
||||
|
||||
-- mixed hashable/sortable cases
|
||||
select unhashable_col, unsortable_col,
|
||||
grouping(unhashable_col, unsortable_col),
|
||||
|
@ -292,6 +292,11 @@ explain (costs off)
|
||||
select a, b, grouping(a,b), array_agg(v order by v)
|
||||
from gstest1 group by cube(a,b);
|
||||
|
||||
-- unsortable cases
|
||||
select unsortable_col, count(*)
|
||||
from gstest4 group by grouping sets ((unsortable_col),(unsortable_col))
|
||||
order by unsortable_col::text;
|
||||
|
||||
-- mixed hashable/sortable cases
|
||||
select unhashable_col, unsortable_col,
|
||||
grouping(unhashable_col, unsortable_col),
|
||||
|
Reference in New Issue
Block a user