On Mon, Apr 15, 2019 at 11:28 AM Masahiko Sawada <[email protected]> wrote:
> On Mon, Apr 15, 2019 at 11:57 AM Alexander Korotkov
> <[email protected]> wrote:
> >
> > Hi!
> >
> > On Sun, Apr 14, 2019 at 11:00 PM Piotr Stefaniak
> > <[email protected]> wrote:
> > > UB Sanitizer points out that prev_num_heap_tuples is sometimes 0,
> > > leading to division by 0 in
> > >                         (info->num_heap_tuples - prev_num_heap_tuples) /
> > >                         prev_num_heap_tuples >= cleanup_scale_factor)
> > > which are currently lines 839-840 in nbtree.c.
>
> Thank you pointing out it.
>
> > >
> > > Attaching my idea of a fix.
> >
> > Thank you for noticing.  BTW, I've more trivial idea for fixing this: 
> > replace
> > prev_num_heap_tuples < 0
> > with
> > prev_num_heap_tuples <= 0
> >
> > If prev_num_heap_tuples == 0, subsequent part of expression isn't
> > evaluated because result is known to be true.  And I think it's right
> > to don't skip cleanup when prev_num_heap_tuples == 0.
>
> +1. It looks good to me.

Thank you for the feedback!
Pushed.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company


Reply via email to