Division by zero in selfuncs.c:estimate_hash_bucketsize()
От | Piotr Stefaniak |
---|---|
Тема | Division by zero in selfuncs.c:estimate_hash_bucketsize() |
Дата | |
Msg-id | BLU436-SMTP6793A5675100602B2012D6F28B0@phx.gbl обсуждение исходный текст |
Ответы |
Re: Division by zero in selfuncs.c:estimate_hash_bucketsize()
|
Список | 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.
В списке pgsql-hackers по дате отправления: