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

Rikard Falkeborn <rikard.falkeborn@gmail.com>

From: Rikard Falkeborn <rikard.falkeborn@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Date: 2019-04-10T21:40:53Z
Lists: pgsql-bugs
In src/backend/parser/parse_expr.c the following snippet of code is found
(lines 3238-3242, rev 765525c8c2c6e55abe):

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

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

Commits

  1. Fix more strcmp() calls using boolean-like comparisons for result checks

  2. Fix backwards test in operator_precedence_warning logic.