Re: pgsql: Fix progress reporting of CLUSTER / VACUUM FULL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Fix progress reporting of CLUSTER / VACUUM FULL
Date: 2019-09-13 18:47:56
Message-ID: 19795.1568400476@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> 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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2019-09-13 18:52:41 Re: pgsql: Fix progress reporting of CLUSTER / VACUUM FULL
Previous Message Alvaro Herrera 2019-09-13 17:58:56 pgsql: Fix progress reporting of CLUSTER / VACUUM FULL