Re: [HACKERS] taking stdbool.h into use - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: [HACKERS] taking stdbool.h into use
Date
Msg-id CAB7nPqT_Gx6zUhBjhJZAN2GVt6nBx2yqXr3TGWfcMkFuinUj1Q@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] taking stdbool.h into use  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: [HACKERS] taking stdbool.h into use
List pgsql-hackers
On Thu, Dec 21, 2017 at 1:02 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> On 11/15/17 15:13, Peter Eisentraut wrote:
>> I'm going to put this patch set as Returned With Feedback for now.  The
>> GinNullCategory issues look like they will need quite a bit of work.
>> But it will be worth picking this up some time.
>
> I think the issue with GinNullCategory is practically unfixable.  This
> is on-disk data that needs to be castable to an array of bool.  So
> tolerating a bool of size other than 1 would either require a disk
> format change or extensive code changes, neither of which seem
> worthwhile at this point.
>
> So here is a minimal patch set to perhaps wrap this up for the time
> being.  I have added static assertions that check the sizes of
> GinNullCategory and GinTernaryValue, which I think are the two critical
> places that require compatibility with bool.  And then we include
> <stdbool.h> only if its bool has size 1.

+   /*
+    * now we can use the nullFlags as category codes
+    */
+   StaticAssertStmt(sizeof(GinNullCategory) == sizeof(bool),
+                    "sizes of GinNullCategory and bool are not equal");
    *categories = (GinNullCategory *) nullFlags;

Hm. So on powerpc compilation is going to fail with this patch as
sizeof(char) is 1, no? Wouldn't it be better to just allocate an array
for GinNullCategory entries and then just fill in the values one by
one with GIN_CAT_NORM_KEY or GIN_CAT_NULL_KEY by scanning nullFlags?
-- 
Michael


pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table
Next
From: Konstantin Knizhnik
Date:
Subject: Re: AS OF queries