pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Suspicious strcmp() in src/backend/parser/parse_expr.c
Date: Thu, 11 Apr 2019 15:50:55 +0900
Message-ID: <20190411065055.GR2728@paquier.xyz> (raw )
In-Reply-To: <12975.1554958549@sss.pgh.pa.us >
References: <CADRDgG6fzA8A2oeygUw4=o7ywo4kvz26NxCSgpq22nMD73Bx4Q@mail.gmail.com >
<87pnptwl1a.fsf@news-spur.riddles.org.uk >
<1040.1554936212@sss.pgh.pa.us >
<20190411021946.GG2728@paquier.xyz >
<12975.1554958549@sss.pgh.pa.us >
On Thu, Apr 11, 2019 at 12:55:49AM -0400, Tom Lane wrote:
> I'd be +1 for that, just on the grounds of having consistent coding
> style. But I'm not sufficiently excited about it to do the work
> myself ...
Well, here you go as per the attached as we are on it. I am not
noticing any other spots.
--
Michael
Attachments:
strcmp-fixes.patch (text/x-diff, 2.6K) download
diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c
index f90f2bce0e..adf0490f85 100644
--- a/contrib/spi/refint.c
+++ b/contrib/spi/refint.c
@@ -473,9 +473,12 @@ check_foreign_key(PG_FUNCTION_ARGS)
nv = SPI_getvalue(newtuple, tupdesc, fn);
type = SPI_gettype(tupdesc, fn);
- if ((strcmp(type, "text") && strcmp(type, "varchar") &&
- strcmp(type, "char") && strcmp(type, "bpchar") &&
- strcmp(type, "date") && strcmp(type, "timestamp")) == 0)
+ if (strcmp(type, "text") == 0 ||
+ strcmp(type, "varchar") == 0 ||
+ strcmp(type, "char") == 0 ||
+ strcmp(type, "bpchar") == 0 ||
+ strcmp(type, "date") == 0 ||
+ strcmp(type, "timestamp") == 0)
is_char_type = 1;
#ifdef DEBUG_QUERY
elog(DEBUG4, "check_foreign_key Debug value %s type %s %d",
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index df681e3234..97cf0bc4ad 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -219,7 +219,8 @@ LockViewRecurse_walker(Node *node, LockViewRecurse_context *context)
* skipped.
*/
if (relid == context->viewoid &&
- (!strcmp(rte->eref->aliasname, "old") || !strcmp(rte->eref->aliasname, "new")))
+ (strcmp(rte->eref->aliasname, "old") == 0 ||
+ strcmp(rte->eref->aliasname, "new") == 0))
continue;
/* Currently, we only allow plain tables or views to be locked. */
diff --git a/src/test/modules/test_rls_hooks/test_rls_hooks.c b/src/test/modules/test_rls_hooks/test_rls_hooks.c
index 8bf8f764ac..10379bc59c 100644
--- a/src/test/modules/test_rls_hooks/test_rls_hooks.c
+++ b/src/test/modules/test_rls_hooks/test_rls_hooks.c
@@ -75,8 +75,8 @@ test_rls_hooks_permissive(CmdType cmdtype, Relation relation)
ParseState *qual_pstate;
RangeTblEntry *rte;
- if (strcmp(RelationGetRelationName(relation), "rls_test_permissive")
- && strcmp(RelationGetRelationName(relation), "rls_test_both"))
+ if (strcmp(RelationGetRelationName(relation), "rls_test_permissive") != 0 &&
+ strcmp(RelationGetRelationName(relation), "rls_test_both") != 0)
return NIL;
qual_pstate = make_parsestate(NULL);
@@ -140,8 +140,8 @@ test_rls_hooks_restrictive(CmdType cmdtype, Relation relation)
RangeTblEntry *rte;
- if (strcmp(RelationGetRelationName(relation), "rls_test_restrictive")
- && strcmp(RelationGetRelationName(relation), "rls_test_both"))
+ if (strcmp(RelationGetRelationName(relation), "rls_test_restrictive") != 0 &&
+ strcmp(RelationGetRelationName(relation), "rls_test_both") != 0)
return NIL;
qual_pstate = make_parsestate(NULL);
signature.asc (application/pgp-signature, 832B) download
view thread (13+ messages) latest in thread
Message-ID: <20190411065055.GR2728@paquier.xyz>
Permalink: ../20190411065055.GR2728@paquier.xyz/
Also on: postgresql.org/message-id/20190411065055.GR2728@paquier.xyz
copy link · copy postgr.es · copy git am
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: michael@paquier.xyz, tgl@sss.pgh.pa.us, andrew@tao11.riddles.org.uk, rikard.falkeborn@gmail.com
Subject: Re: Suspicious strcmp() in src/backend/parser/parse_expr.c
In-Reply-To: <20190411065055.GR2728@paquier.xyz>
References: <CADRDgG6fzA8A2oeygUw4=o7ywo4kvz26NxCSgpq22nMD73Bx4Q@mail.gmail.com> <87pnptwl1a.fsf@news-spur.riddles.org.uk> <1040.1554936212@sss.pgh.pa.us> <20190411021946.GG2728@paquier.xyz> <12975.1554958549@sss.pgh.pa.us> <20190411065055.GR2728@paquier.xyz>
* 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