Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hELmq-0006VI-TD for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Apr 2019 22:33:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hELmp-00068Z-Bt for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Apr 2019 22:33:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hELmp-00068C-0b for pgsql-bugs@lists.postgresql.org; Wed, 10 Apr 2019 22:33:43 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hELml-000771-CU for pgsql-bugs@lists.postgresql.org; Wed, 10 Apr 2019 22:33:41 +0000 Received: from [192.168.127.1] (port=28904 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1hELmi-000Lz6-FB; Wed, 10 Apr 2019 22:33:36 +0000 Received: from [127.0.0.1] (port=12308 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1hELmh-0008j1-QP; Wed, 10 Apr 2019 22:33:35 +0000 From: Andrew Gierth To: Rikard Falkeborn Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Suspicious strcmp() in src/backend/parser/parse_expr.c In-Reply-To: (Rikard Falkeborn's message of "Wed, 10 Apr 2019 23:40:53 +0200") Message-ID: <87pnptwl1a.fsf@news-spur.riddles.org.uk> References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Wed, 10 Apr 2019 23:33:35 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Rikard" == Rikard Falkeborn 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)