10000 Fix an Assert that turns out to be reachable after all. · jandas/postgres@be9aad6 · GitHub
[go: up one dir, main page]

Skip to content

Commit be9aad6

Browse files
committed
Fix an Assert that turns out to be reachable after all.
estimate_num_groups() gets unhappy with create table empty(); select * from empty except select * from empty e2; I can't see any actual use-case for such a query (and the table is illegal per SQL spec), but it seems like a good idea that it not cause an assert failure.
1 parent 785d499 commit be9aad6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/backend/utils/adt/selfuncs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,8 +3051,13 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows)
30513051
double numdistinct;
30523052
ListCell *l;
30533053

3054-
/* We should not be called unless query has GROUP BY (or DISTINCT) */
3055-
Assert(groupExprs != NIL);
3054+
/*
3055+
* If no grouping columns, there's exactly one group. (This can't happen
3056+
* for normal cases with GROUP BY or DISTINCT, but it is possible for
3057+
* corner cases with set operations.)
3058+
*/
3059+
if (groupExprs == NIL)
3060+
return 1.0;
30563061

30573062
/*
30583063
* Count groups derived from boolean grouping expressions. For other

0 commit comments

Comments
 (0)
0