Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwbco-0002En-93 for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Jun 2021 02:31:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lwbcn-0006Fz-8A for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Jun 2021 02:31:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwbcm-0006Fr-PP for pgsql-hackers@lists.postgresql.org; Fri, 25 Jun 2021 02:31:21 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lwbch-0007Rb-1L for pgsql-hackers@lists.postgresql.org; Fri, 25 Jun 2021 02:31:19 +0000 Received: by mail-io1-xd2f.google.com with SMTP id o5so10882621iob.4 for ; Thu, 24 Jun 2021 19:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xV5wI9kozjB0CDIilTM8A1aJIZe1eRG8vgwRCf7qSzA=; b=LC3ZEs8BxOJgaPKrcrpK9qxJqFGDv2O6XP3dMdeOlAb5U01BR3uWUvPaLf3CKXBKHb jAS4FNxZulfH627tBpR/1kPJBex45sAHxy66VG5FdlYTB940KG5aNy4CsNaaNhoREWmG +E1bUSmnn5HT9n11WQMOBOqFNfxToNrg1m5dXMgr8sJxHGAYwsiGKGmWrqNZ9ACee7h3 36sRZTapJNceJXNDXJiGjLIP51rDmxFdwvK7iEtBpz+crLy5u+45pI/v9Wy97+/ERhcs 6nNqHBSWHAk3ljC6oGQCONlX/Ivs3QeVSCflKZEWD3dMKkSY1NO1HQ0xgEAI67cItvy6 8YKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xV5wI9kozjB0CDIilTM8A1aJIZe1eRG8vgwRCf7qSzA=; b=SExbOlOaFfOUw+JQONIaf6QAjVgJJEn9sAOIVIGy2IYTte3MAPPn6QSqhmwwiDuJuT 3HdnPWCcjp3WLEMwV51PBGr/fjjun9nA4udldWxyUgy8uiU2tIOJEIoc8fFp82hbk7k1 zFL6U9HQJY24Pe/n/HVPmDXA6ftQi0e7qeDd7Zren2L5/WmBv+Lgg6OCrJkRA1x3onN3 MX14GN4Kbh/E8s782+M6kKNBpOkXmaEDSxL6F2eFbfXL3BMmCosmOmsz2p5gp0kT9vYb CT5IMn8ybkshC0I/2KTc8xN006Vl/YDuJJOq1C+a3XyDgA8Ype1EQP+7El/QIorZe43v lnEQ== X-Gm-Message-State: AOAM533EUiZCh4H5A8ItWRJ/lAJF9CBNE9w6rBzSQEm++oKgR0WsMyov Gd/6NZrPiH+4nPHbWjLHCApGypTXdAyyaQ== X-Google-Smtp-Source: ABdhPJxJqXcF6F5Kqc2KrfLSABfjxC3PokA4RFauTZh/9G80/aAPxQ+Qa/nJUC+ZIjmGc9q5wcDgAw== X-Received: by 2002:a02:7126:: with SMTP id n38mr4554016jac.75.1624588273166; Thu, 24 Jun 2021 19:31:13 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id b23sm2273492ioh.53.2021.06.24.19.31.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jun 2021 19:31:12 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 48EE38007F8; Thu, 24 Jun 2021 21:31:11 -0500 (CDT) Date: Thu, 24 Jun 2021 21:31:11 -0500 From: Justin Pryzby To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: strange case of "if ((a & b))" Message-ID: <20210625023110.GI29179@telsasoft.com> References: <20210428182936.GE27406@telsasoft.com> <2896014.1619635209@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7AUc2qLy4jB3hD7Z" Content-Disposition: inline In-Reply-To: <2896014.1619635209@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --7AUc2qLy4jB3hD7Z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Apr 28, 2021 at 02:40:09PM -0400, Tom Lane wrote: > Justin Pryzby writes: > > These look strange to me - the inner parens don't do anything. > > I wouldn't write it with 2x parens for the same reason I wouldn't write it with > > 8x parens. > > Agreed, but shouldn't we just drop the excess parens rather than > doubling down on useless notation? I believe I got the impression from Michael that there was a style preference to write != 0. 0002 is a bonus patch I found in my typos branch. I will hold onto it for later if nobody wants to deal with it. --7AUc2qLy4jB3hD7Z Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Avoid-double-parens.patch" From 2534ff46830ab505a6a2079a1b6c0f8a1e9b2b8b Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Wed, 28 Apr 2021 14:12:49 -0500 Subject: [PATCH 1/2] Avoid double parens git grep -l '\tuphdr->t_hoff)); - else if ((infomask & HEAP_HASNULL)) + else if (infomask & HEAP_HASNULL) report_corruption(ctx, psprintf("tuple data should begin at byte %u, but actually begins at byte %u (%u attributes, has nulls)", expected_hoff, ctx->tuphdr->t_hoff, ctx->natts)); diff --git a/contrib/ltree/ltree_io.c b/contrib/ltree/ltree_io.c index 15115cb29f..b75f35d5b5 100644 --- a/contrib/ltree/ltree_io.c +++ b/contrib/ltree/ltree_io.c @@ -661,17 +661,17 @@ deparse_lquery(const lquery *in) } memcpy(ptr, curtlevel->name, curtlevel->len); ptr += curtlevel->len; - if ((curtlevel->flag & LVAR_SUBLEXEME)) + if (curtlevel->flag & LVAR_SUBLEXEME) { *ptr = '%'; ptr++; } - if ((curtlevel->flag & LVAR_INCASE)) + if (curtlevel->flag & LVAR_INCASE) { *ptr = '@'; ptr++; } - if ((curtlevel->flag & LVAR_ANYEND)) + if (curtlevel->flag & LVAR_ANYEND) { *ptr = '*'; ptr++; diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index da8a460722..9c13a7c589 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -2452,7 +2452,7 @@ PrepareTransaction(void) * cases, such as a temp table created and dropped all within the * transaction. That seems to require much more bookkeeping though. */ - if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPNAMESPACE)) + if (MyXactFlags & XACT_FLAGS_ACCESSEDTEMPNAMESPACE) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot PREPARE a transaction that has operated on temporary objects"))); @@ -5565,7 +5565,7 @@ XactLogCommitRecord(TimestampTz commit_time, xl_xinfo.xinfo |= XACT_COMPLETION_UPDATE_RELCACHE_FILE; if (forceSyncCommit) xl_xinfo.xinfo |= XACT_COMPLETION_FORCE_SYNC_COMMIT; - if ((xactflags & XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK)) + if (xactflags & XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK) xl_xinfo.xinfo |= XACT_XINFO_HAS_AE_LOCKS; /* @@ -5716,7 +5716,7 @@ XactLogAbortRecord(TimestampTz abort_time, xlrec.xact_time = abort_time; - if ((xactflags & XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK)) + if (xactflags & XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK) xl_xinfo.xinfo |= XACT_XINFO_HAS_AE_LOCKS; if (nsubxacts > 0) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 4e23c7fce5..39180999fd 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -16171,7 +16171,7 @@ PreCommit_on_commit_actions(void) * relations, we can skip truncating ON COMMIT DELETE ROWS * tables, as they must still be empty. */ - if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPNAMESPACE)) + if (MyXactFlags & XACT_FLAGS_ACCESSEDTEMPNAMESPACE) oids_to_truncate = lappend_oid(oids_to_truncate, oc->relid); break; case ONCOMMIT_DROP: diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index ff3dcc7b18..ae3364dfdc 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -2390,7 +2390,7 @@ query_tree_walker(Query *query, * don't contain actual expressions. However they do contain OIDs which * may be needed by dependency walkers etc. */ - if ((flags & QTW_EXAMINE_SORTGROUP)) + if (flags & QTW_EXAMINE_SORTGROUP) { if (walker((Node *) query->groupClause, context)) return true; @@ -3328,7 +3328,7 @@ query_tree_mutator(Query *query, * may be of interest to some mutators. */ - if ((flags & QTW_EXAMINE_SORTGROUP)) + if (flags & QTW_EXAMINE_SORTGROUP) { MUTATE(query->groupClause, query->groupClause, List *); MUTATE(query->windowClause, query->windowClause, List *); diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c index 453efc51e1..34a36b22f8 100644 --- a/src/backend/replication/logical/decode.c +++ b/src/backend/replication/logical/decode.c @@ -337,7 +337,7 @@ DecodeXactOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf) ReorderBufferXidSetCatalogChanges(ctx->reorder, xid, buf->origptr); } - else if ((!ctx->fast_forward)) + else if (!ctx->fast_forward) ReorderBufferImmediateInvalidation(ctx->reorder, invals->nmsgs, invals->msgs); -- 2.17.0 --7AUc2qLy4jB3hD7Z Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0002-tablefunc.c-Fix-comment.patch" From 16773708a7ab2c995fa3d7e1bba1b3626468a8d0 Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Sat, 8 May 2021 08:12:46 -0500 Subject: [PATCH 2/2] tablefunc.c: Fix comment Mentioned at: https://www.postgresql.org/message-id/CAJRYxuKmMkgHFKjuYPxThdT5Mjg%2Bg-nH5szYbS8UoVsQXzd95A%40mail.gmail.com --- contrib/tablefunc/tablefunc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 779bd4415e..52b272f298 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -1480,7 +1480,7 @@ validateConnectbyTupleDesc(TupleDesc td, bool show_branch, bool show_serial) "fifth column must be type %s", format_type_be(INT4OID)))); - /* check that the type of the fifth column is INT4 */ + /* check that the type of the fourth column is INT4 */ if (!show_branch && show_serial && TupleDescAttr(td, 3)->atttypid != INT4OID) ereport(ERROR, -- 2.17.0 --7AUc2qLy4jB3hD7Z--