Skip to content

Commit 65fd913

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 d515365 commit 65fd913

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
@@ -3182,8 +3182,13 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows)
31823182
double numdistinct;
31833183
ListCell *l;
31843184

3185-
/* We should not be called unless query has GROUP BY (or DISTINCT) */
3186-
Assert(groupExprs != NIL);
3185+
/*
3186+
* If no grouping columns, there's exactly one group. (This can't happen
3187+
* for normal cases with GROUP BY or DISTINCT, but it is possible for
3188+
* corner cases with set operations.)
3189+
*/
3190+
if (groupExprs == NIL)
3191+
return 1.0;
31873192

31883193
/*
31893194
* Count groups derived from boolean grouping expressions. For other

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy