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

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

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.

It seems that you are right.

#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

int main()
{
bool op1 = false;
bool op2 = true;
bool band;
bool cand;

band = op1 & op2;
printf("res=%d\n", band);

cand = op1 && op2;
printf("res=%d\n", cand);
}

#ifdef __cplusplus
}
#endif

results:
res=0
res=0

So, my assumption is incorrect.

regards,
Ranier Vilela

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2022-08-19 14:42:45 Re: Trivial doc patch
Previous Message Jonathan S. Katz 2022-08-19 14:11:01 Re: SQL/JSON features for v15