From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | pgsql-hackers(at)postgresql(dot)org, Teodor Sigaev <teodor(at)sigaev(dot)ru> |
Subject: | Re: GinPageIs* don't actually return a boolean |
Date: | 2015-08-11 16:40:31 |
Message-ID: | 23420.1439311231@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Andres Freund <andres(at)anarazel(dot)de> writes:
> #define GinPageIsLeaf(page) ( GinPageGetOpaque(page)->flags & GIN_LEAF )
> #define GinPageIsData(page) ( GinPageGetOpaque(page)->flags & GIN_DATA )
> #define GinPageIsList(page) ( GinPageGetOpaque(page)->flags & GIN_LIST )
> These macros don't actually return a boolean that's comparable with our
> true/false. That doesn't strike me as a good idea.
Agreed, this is risky. For example, if the bit being tested is to the
left of the lowest byte of "flags", storing the result into a bool
variable would do the wrong thing.
> I think we should add a !! to these macros to make sure it's an actual
> boolean.
Please write it more like
#define GinPageIsLeaf(page) ((GinPageGetOpaque(page)->flags & GIN_LEAF) != 0)
We do not use !! elsewhere for this purpose, and I for one find it a
pretty ugly locution.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2015-08-11 16:43:03 | Re: GinPageIs* don't actually return a boolean |
Previous Message | Robert Haas | 2015-08-11 16:35:32 | Re: WIP: SCRAM authentication |