Re: [HACKERS] taking stdbool.h into use

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Subject: Re: [HACKERS] taking stdbool.h into use
Date: 2017-12-25 05:32:28
Message-ID: CAB7nPqT_Gx6zUhBjhJZAN2GVt6nBx2yqXr3TGWfcMkFuinUj1Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 21, 2017 at 1:02 AM, Peter Eisentraut
<peter(dot)eisentraut(at)2ndquadrant(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Konstantin Knizhnik 2017-12-25 07:59:57 Re: AS OF queries
Previous Message Amit Langote 2017-12-25 04:52:32 Re: [HACKERS] Proposal: Local indexes for partitioned table