Re: Fix typo with logical connector (src/backend/commands/vacuumparallel.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix typo with logical connector (src/backend/commands/vacuumparallel.c)
Date: 2022-08-20 14:07:59
Message-ID: CAEudQAoFXZX11=xoLxqQBabqcRWNUO85GjOghxMQHBVnZDyzbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em sáb., 20 de ago. de 2022 às 01:03, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
escreveu:

> On Fri, Aug 19, 2022 at 7:45 PM Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
> >
> > Em sex., 19 de ago. de 2022 às 10:28, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> escreveu:
> >>
> >> Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> writes:
> >> > At function parallel_vacuum_process_all_indexes there is
> >> > a typo with a logical connector.
> >> > I think that correct is &&, because both of the operators are
> >> > bool types [1].
> >> > As a result, parallel vacuum workers can be incorrectly enabled.
> >>
> >> Since they're bools, the C spec requires them to promote to integer
> >> 0 or 1, therefore the & operator will yield the desired result.
> >> So there's not going to be any incorrect behavior.
> >
> >
> > So, my assumption is incorrect.
> >
>
> Right, but as Tom pointed it is still better to change this.

Sorry, I expressed myself badly.
As Tom pointed out, It's not a bug, as I stated in the first post.
But even if it wasn't a small performance improvement, by avoiding the
function call.
The correct thing is to use logical connectors (&& ||) with boolean
operands.

> However,
> I am not sure if we should backpatch this to PG15 as this won't lead
> to any incorrect behavior.
>
+1 for backpath to PG15, too.
It's certainly a safe change.

regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2022-08-20 14:26:53 Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
Previous Message Erik Rijkers 2022-08-20 13:55:07 Re: Schema variables - new implementation for Postgres 15