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 1hETZG-0003Kg-Ta for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Apr 2019 06:52:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hETYF-0005aa-CY for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Apr 2019 06:51:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hETYD-0005aS-On for pgsql-bugs@lists.postgresql.org; Thu, 11 Apr 2019 06:51:11 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hETY9-0004cN-Id for pgsql-bugs@lists.postgresql.org; Thu, 11 Apr 2019 06:51:09 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id B4FDD51A; Thu, 11 Apr 2019 02:51:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Apr 2019 02:51:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=Wy15hpdedFH+E10Kx9Sff4DDPsX RgzWG7e3E0tPq/C4=; b=CCVTTHV5dSx57ao14o09R7W8ESVVTZScRoXN+9biYX3 rDT5kZpr5vTC6C1KtJbJOjAMYmUxRkmLIpb+NYa5rzgu+zisHKVH4SQEgYB0ZTXI JzIcM/gqV975gB/2q8yzBqvLtwnwH7mQM3WGVyasON7VN2AD08ZjGnq56HDuftmu jpulTdQBaKWpRz5KhRd471/t5I7FiklJOXRNyQVGeeb7MaCaf7rBl0UK2WJzJTxQ jm+F+cpKIVfqdQf+4+v+saQHAAaAq1V2kjSuTbIrZUzbfw4dmVzD+D4xlGATwlMP J9zpN2IlLLeljTHdbe/EnXz2NZoUjRRXDexHaHMxTTQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Wy15hp dedFH+E10Kx9Sff4DDPsXRgzWG7e3E0tPq/C4=; b=8BRvMOpfMovDIndmkT0Sbr FoPugjVOcM5WgDP89RujPljFkr44NddXiFt4wikvY5yyD9YxOeKd3TDVgw38R2bP q5Q2tB0hy2HWyCnHFM/wG8G0dD0DksO8r1dD/6secbNGbTL2BPOT+5Kyh2lB4tK5 yj+C6qgkm+g/rsm8gUcGehtC24tptrJ5bC1Hvb4XDbQeD493BzQ/RGnyVsOZoB9E qd9WI0AdmAfqC1xCCFt9iAfjHOP4a8Jpyl9sPFY2HqHlOUrl7pfKutV5MR+lN/gA XBEIeXWzBYNobaNGfuZx3gGk2Na+BGTa/QMMZgWMRuk+GuQoOo2SldA1mVx5n07g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudekgddutdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucfkphepudduuddruddtvddrudektddrudekheenucfrrghr rghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiienucevlh hushhtvghrufhiiigvpedt X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 7DBA5E446F; Thu, 11 Apr 2019 02:50:59 -0400 (EDT) Date: Thu, 11 Apr 2019 15:50:55 +0900 From: Michael Paquier To: Tom Lane Cc: Andrew Gierth , Rikard Falkeborn , pgsql-bugs@lists.postgresql.org Subject: Re: Suspicious strcmp() in src/backend/parser/parse_expr.c Message-ID: <20190411065055.GR2728@paquier.xyz> References: <87pnptwl1a.fsf@news-spur.riddles.org.uk> <1040.1554936212@sss.pgh.pa.us> <20190411021946.GG2728@paquier.xyz> <12975.1554958549@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="mmR5Tf+WJGm+vTLg" Content-Disposition: inline In-Reply-To: <12975.1554958549@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --mmR5Tf+WJGm+vTLg Content-Type: multipart/mixed; boundary="ZjLa2K+dB9SFbrgo" Content-Disposition: inline --ZjLa2K+dB9SFbrgo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --ZjLa2K+dB9SFbrgo Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="strcmp-fixes.patch" Content-Transfer-Encoding: quoted-printable 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 =3D SPI_getvalue(newtuple, tupdesc, fn); type =3D SPI_gettype(tupdesc, fn); =20 - if ((strcmp(type, "text") && strcmp(type, "varchar") && - strcmp(type, "char") && strcmp(type, "bpchar") && - strcmp(type, "date") && strcmp(type, "timestamp")) =3D=3D 0) + if (strcmp(type, "text") =3D=3D 0 || + strcmp(type, "varchar") =3D=3D 0 || + strcmp(type, "char") =3D=3D 0 || + strcmp(type, "bpchar") =3D=3D 0 || + strcmp(type, "date") =3D=3D 0 || + strcmp(type, "timestamp") =3D=3D 0) is_char_type =3D 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/lockcmd= s.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_cont= ext *context) * skipped. */ if (relid =3D=3D context->viewoid && - (!strcmp(rte->eref->aliasname, "old") || !strcmp(rte->eref->aliasname,= "new"))) + (strcmp(rte->eref->aliasname, "old") =3D=3D 0 || + strcmp(rte->eref->aliasname, "new") =3D=3D 0)) continue; =20 /* 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/mo= dules/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 relat= ion) ParseState *qual_pstate; RangeTblEntry *rte; =20 - if (strcmp(RelationGetRelationName(relation), "rls_test_permissive") - && strcmp(RelationGetRelationName(relation), "rls_test_both")) + if (strcmp(RelationGetRelationName(relation), "rls_test_permissive") !=3D= 0 && + strcmp(RelationGetRelationName(relation), "rls_test_both") !=3D 0) return NIL; =20 qual_pstate =3D make_parsestate(NULL); @@ -140,8 +140,8 @@ test_rls_hooks_restrictive(CmdType cmdtype, Relation re= lation) RangeTblEntry *rte; =20 =20 - if (strcmp(RelationGetRelationName(relation), "rls_test_restrictive") - && strcmp(RelationGetRelationName(relation), "rls_test_both")) + if (strcmp(RelationGetRelationName(relation), "rls_test_restrictive") != =3D 0 && + strcmp(RelationGetRelationName(relation), "rls_test_both") !=3D 0) return NIL; =20 qual_pstate =3D make_parsestate(NULL); --ZjLa2K+dB9SFbrgo-- --mmR5Tf+WJGm+vTLg Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlyu488ACgkQnvQgOdby QH3I9xAAnf3EKtZTtj+b5HMOHQacY7VjbSDtodCu8JxfwD33rAdbn4lBbZFTACug vw0JYSFcISehZhw3o5knnHuZK2q3NHaxNSv3+R+IpVWaXHjpVG/fxSh3bV/EHCtk pDtq40LJ+x2hKH93WD3J8jwf1WMixakmEi9jRJ6Ue01Lnj7IayHCUeWjc8BEkJX+ EtX4zIhFqC/x2DAH7rYxdVBDVmlB1Pcev6IxKJc0qwxtNHzrpX1qFJCdwBTXjCI7 IQxFplC6hh3Pyha4Oa0oLv2I0BPHtCyIFtyhbYo6EHFK6vg5KDeHRWktlOcSVtMd wgdi9XVRI/U/YIaXXNkX8ID59IIyJ8bQBQo4QvQEKMu0rbyuwb2t84fGmu8Bs3vz hIhxFq1DcRyVWM4Qg5u+ZtyPfaAHT6LujPsQNV6TdmeENL0mkZODG65Elcr+0CEs 6raqNzEWwFNFBca79qJClQDHnUnTWTyEHwLwvAfLjEIHSQOCnGToJHqwi2zzxOW2 6zi/AEGIxLLZFWNuE+GbGtqtjF+OuXXfpIko2gcpqXhLn441at2xRXcgbKqRNnxt tj4G+Zd0nQ7G0DuNXHPyC/EJOeXlz7blKz/qIrx00AcaLSMgAfGLGeOuh6XqmqcJ ym8L2rCV3HpnaQWE44/6Js7FQhdV4uXrOoc+mW++OmPiv9HzRDs= =uX6v -----END PGP SIGNATURE----- --mmR5Tf+WJGm+vTLg--