Re: Two division by 0 errors in optimizer/plan/planner.c and optimizer/path/costsize.c - Mailing list pgsql-hackers

From Piotr Stefaniak
Subject Re: Two division by 0 errors in optimizer/plan/planner.c and optimizer/path/costsize.c
Date
Msg-id BLU437-SMTP67C2A4915E150388A48445F2850@phx.gbl
Whole thread Raw
In response to Re: Two division by 0 errors in optimizer/plan/planner.c and optimizer/path/costsize.c  (Piotr Stefaniak <postgres@piotr-stefaniak.me>)
Responses Re: Two division by 0 errors in optimizer/plan/planner.c and optimizer/path/costsize.c
Re: Two division by 0 errors in optimizer/plan/planner.c and optimizer/path/costsize.c
List pgsql-hackers
On 2016-03-26 19:29, Piotr Stefaniak wrote:
> I'm not saying this is necessarily a bug since the whole function deals
> with floats, but perhaps it's interesting to note that ndistinct can be
> 0 in src/backend/utils/adt/selfuncs.c:estimate_hash_bucketsize:

On the exact same note, something like this (again reduced from what
sqlsmith produced):

select 1
from unnest('{}'::boolean[]) a (x)
left join (
   select *
   from unnest('{}'::boolean[])
   where false
) b (x) on a.x = b.x;

leads to vardata.rel->tuples being zero here:
    if (vardata.rel)
        ndistinct *= vardata.rel->rows / vardata.rel->tuples;

Back-trace attached.


Attachment

pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: Re: extend pgbench expressions with functions
Next
From: Alexander Korotkov
Date:
Subject: Re: Move PinBuffer and UnpinBuffer to atomics