Re: Suspicious strcmp() in src/backend/parser/parse_expr.c

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Rikard Falkeborn <rikard(dot)falkeborn(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Suspicious strcmp() in src/backend/parser/parse_expr.c
Date: 2019-04-11 03:43:49
Message-ID: CAKJS1f8fvWe8MGsOrPgP5ThJ4QAn5K42a96E-gDffR_Let2tXA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, 11 Apr 2019 at 15:27, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
>
> On Thu, Apr 11, 2019 at 2:20 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> > On Wed, Apr 10, 2019 at 06:43:32PM -0400, Tom Lane wrote:
> > > Indeed. Considering how much I hate using strcmp's result as a boolean,
> > > you'd think I'd have got that right. Thanks for noticing!
> >
> > Just a note about those strcmp() calls using a boolean as return
> > result in the tree:
> > src/backend/commands/lockcmds.c: (!strcmp(rte->eref->aliasname, "old")
>
> Don't look at contrib/spi/refint.c if you value your sanity.

hmm, yeah. Take a non-bool expression, make it into a bool expression,
then compare that to 0 to make it look like a non-bool expression.
Weird.

If we're fixing some, we may as well do them all.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2019-04-11 03:46:00 Re: Suspicious strcmp() in src/backend/parser/parse_expr.c
Previous Message r.zharkov 2019-04-11 03:29:03 Re: BUG #15727: PANIC: cannot abort transaction 295144144, it was already committed