Re: Two division by 0 errors in optimizer/plan/planner.c and optimizer/path/costsize.c

From: Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Two division by 0 errors in optimizer/plan/planner.c and optimizer/path/costsize.c
Date: 2016-03-27 09:25:20
Message-ID: BLU437-SMTP67C2A4915E150388A48445F2850@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
estimate_hash_bucketsize-var.data-reltuples-backtrace.txt text/plain 3.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2016-03-27 09:38:25 Re: Move PinBuffer and UnpinBuffer to atomics
Previous Message Fabien COELHO 2016-03-27 09:01:01 Re: extend pgbench expressions with functions