pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Suspicious strcmp() in src/backend/parser/parse_expr.c
Date: Wed, 10 Apr 2019 23:33:35 +0100
Message-ID: <87pnptwl1a.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CADRDgG6fzA8A2oeygUw4=o7ywo4kvz26NxCSgpq22nMD73Bx4Q@mail.gmail.com>
References: <CADRDgG6fzA8A2oeygUw4=o7ywo4kvz26NxCSgpq22nMD73Bx4Q@mail.gmail.com>

>>>>> "Rikard" == Rikard Falkeborn <rikard.falkeborn@gmail.com> writes:

 Rikard> In src/backend/parser/parse_expr.c the following snippet of code is found
 Rikard> (lines 3238-3242, rev 765525c8c2c6e55abe):

 Rikard>     if (strcmp(*nodename, "+") == 0 ||
 Rikard>             strcmp(*nodename, "-")) // <-- notice the lack of comparisson
 Rikard> here
 Rikard>             group = 0;
 Rikard>     else
 Rikard>             group = PREC_GROUP_PREFIX_OP;

 Rikard> Should the second part of the || be strcmp(*nodename, "-") ==
 Rikard> 0?

Yes it should.

The effect of this bug is to produce a false operator precedence warning
when those are enabled, like so:

postgres=# set operator_precedence_warning = on;
SET
postgres=# select -random() is null;
WARNING:  operator precedence change: IS is now lower precedence than -

when in fact "-random() is null" always did parse as "(-random()) is null"
making the warning spurious.

-- 
Andrew (irc:RhodiumToad)





view thread (13+ messages)  latest in thread

Message-ID: <87pnptwl1a.fsf@news-spur.riddles.org.uk>
Permalink:  ../87pnptwl1a.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87pnptwl1a.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, rikard.falkeborn@gmail.com
  Subject: Re: Suspicious strcmp() in src/backend/parser/parse_expr.c
  In-Reply-To: <87pnptwl1a.fsf@news-spur.riddles.org.uk>
  References: <CADRDgG6fzA8A2oeygUw4=o7ywo4kvz26NxCSgpq22nMD73Bx4Q@mail.gmail.com> <87pnptwl1a.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox