From: | Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Division by zero in selfuncs.c:estimate_hash_bucketsize() |
Date: | 2015-07-30 05:28:24 |
Message-ID: | BLU436-SMTP6793A5675100602B2012D6F28B0@phx.gbl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
the two asserts below will fail with this query (ran against the
regression db):
SELECT 1
FROM (SELECT age FROM public.person LIMIT 1) s
INNER JOIN public.person USING (age);
diff --git a/src/backend/utils/adt/selfuncs.c
b/src/backend/utils/adt/selfuncs.c
index 64b6ae4..56c65b3 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -3482,6 +3482,7 @@ estimate_hash_bucketsize(PlannerInfo *root, Node
*hashkey, double nbuckets)
stanullfrac = 0.0;
/* Compute avg freq of all distinct data values in raw relation */
+ Assert(ndistinct != 0);
avgfreq = (1.0 - stanullfrac) / ndistinct;
/*
@@ -3502,8 +3503,10 @@ estimate_hash_bucketsize(PlannerInfo *root, Node
*hashkey, double nbuckets)
*/
if (ndistinct > nbuckets)
estfract = 1.0 / nbuckets;
- else
+ else {
+ Assert(ndistinct != 0);
estfract = 1.0 / ndistinct;
+ }
/*
* Look up the frequency of the most common value, if available.
From | Date | Subject | |
---|---|---|---|
Next Message | Corey Huinker | 2015-07-30 05:39:25 | Re: dblink: add polymorphic functions. |
Previous Message | Beena Emerson | 2015-07-30 05:16:51 | Re: Support for N synchronous standby servers - take 2 |