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 1i8qc0-0003fX-TB for pgsql-committers@arkaria.postgresql.org; Fri, 13 Sep 2019 18:48:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8qby-0004Du-9G for pgsql-committers@arkaria.postgresql.org; Fri, 13 Sep 2019 18:48:02 +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 1i8qbx-0004Dj-VX for pgsql-committers@lists.postgresql.org; Fri, 13 Sep 2019 18:48:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i8qbv-0003ul-MA for pgsql-committers@lists.postgresql.org; Fri, 13 Sep 2019 18:48:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x8DIluc1019796; Fri, 13 Sep 2019 14:47:56 -0400 From: Tom Lane To: Alvaro Herrera cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix progress reporting of CLUSTER / VACUUM FULL In-reply-to: References: Comments: In-reply-to Alvaro Herrera message dated "Fri, 13 Sep 2019 17:58:56 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19794.1568400476.1@sss.pgh.pa.us> Date: Fri, 13 Sep 2019 14:47:56 -0400 Message-ID: <19795.1568400476@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > Fix progress reporting of CLUSTER / VACUUM FULL Not a new problem of this patch, exactly, but: /* Reindex options */ #define REINDEXOPT_VERBOSE 1 << 0 /* print progress info */ +#define REINDEXOPT_REPORT_PROGRESS 1 << 1 /* report pgstat progress */ Surely these macro definitions are incredibly dangerous due to their lack of parentheses. I'd initially thought that we already had bugs in existing usages like if (options & REINDEXOPT_VERBOSE) After consulting a nearby C reference I see that we're accidentally saved by << having higher priority than &, but this is not safely- maintainable code. Expressions like "~REINDEXOPT_VERBOSE" would not do what one expects. regards, tom lane