Re: pgbench - doCustom cleanup - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: pgbench - doCustom cleanup
Date
Msg-id 20181121180840.qo2646ocipca4ggs@alvherre.pgsql
Whole thread Raw
In response to Re: pgbench - doCustom cleanup  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
On 2018-Nov-20, Fabien COELHO wrote:

> > On INSTR_TIME_SET_CURRENT_LAZY(), you cannot just put an "if" inside a
> > macro -- consider this:
> >     if (foo)
> >         INSTR_TIME_SET_CURRENT_LAZY(bar);
> >     else
> >         something_else();
> > Which "if" is the else now attached to?  Now maybe the C standard has an
> > answer for that (I don't know what it is), but it's hard to read and
> > likely the compiler will complain anyway.  I wrapped it in "do { }
> > while(0)" as is customary.
> 
> Indeed, good catch.

Actually, reviewing this bit again, I realized that it should be a
statement that evaluates to whether the change was made or not -- this
way, it can be used in one existing place.  Pushed that way.  (I
verified that InstrStartNode fails in the expected way if you call it
twice.)

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Speeding up INSERTs and UPDATEs to partitioned tables
Next
From: Stephen Frost
Date:
Subject: Re: pgsql: instr_time.h: add INSTR_TIME_SET_CURRENT_LAZY