Re: cleanup in code - Mailing list pgsql-hackers

From David Rowley
Subject Re: cleanup in code
Date
Msg-id CAApHDvpCv8kb3S9guBmDjby5wfcMp-4WhZLxKtjK6vGqOK8h9A@mail.gmail.com
Whole thread Raw
In response to Re: cleanup in code  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: cleanup in code  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Tue, Jan 7, 2014 at 7:46 PM, Amit Kapila <amit.kapila16@gmail.com> wrote:
Having said above, I think there must be a reason to have elevel_ which I am
not aware.


I think it will be like Andres said up thread, to stop multiple evaluations of the expression passed to the macro.

If someone did:

elog(mylevel++, "Something bad just happened");

With assigning this to a variable the user will have the mylevel increase by 1, but if we didn't then it would get increase more times.

I didn't look at all the elog usages in core, but my guess is that we're probably not using any expressions like this in elog, but we can't really speak for any third party code which uses the macro. Likely to get rid of that variable something would have to go into the release notes to get users to check for volatile expressions being used in elog and fix them up.

The only other way to fix it that I can think of is the patch you posted above which is pretty much the same one as I posted on the other thread too.

Regards

David Rowley 

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: cleanup in code
Next
From: Amit Kapila
Date:
Subject: Re: Long paths for tablespace leads to uninterruptible hang in Windows