aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-04-09 11:58:24 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-04-09 11:58:40 -0400
commit0e20abdb47e3499353ac4fd1b2d21e82ec6b1461 (patch)
tree64c0b3e3cb3f071ac0481c28f37a213df41071b7 /src/backend/utils/adt
parent88e071533fba70747aaf8d9b32fb927b7157ad16 (diff)
downloadpostgresql-0e20abdb47e3499353ac4fd1b2d21e82ec6b1461.tar.gz
postgresql-0e20abdb47e3499353ac4fd1b2d21e82ec6b1461.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/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/selfuncs.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 55e42025c6b..d700b86b934 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -3068,8 +3068,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