diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-04-09 11:58:24 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-04-09 11:58:24 -0400 |
commit | 65fd91333e45114c5d9a07d3d4f6a4786df48768 (patch) | |
tree | a4d811b27eabfb84a1939ba6cc5590822a611919 /src | |
parent | d515365a611a58241019c59a62b0cb79584aa725 (diff) | |
download | postgresql-65fd91333e45114c5d9a07d3d4f6a4786df48768.tar.gz postgresql-65fd91333e45114c5d9a07d3d4f6a4786df48768.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index ced40484c4a..83e43a99972 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -3182,8 +3182,13 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows) double numdistinct; ListCell *l; - /* We should not be called unless query has GROUP BY (or DISTINCT) */ - Assert(groupExprs != NIL); + /* + * If no grouping columns, there's exactly one group. (This can't happen + * for normal cases with GROUP BY or DISTINCT, but it is possible for + * corner cases with set operations.) + */ + if (groupExprs == NIL) + return 1.0; /* * Count groups derived from boolean grouping expressions. For other |