Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Smith, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Joe Nelson <joe(at)begriffs(dot)com>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays
Date: 2019-10-04 04:08:08
Message-ID: 13800.1570162088@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Smith, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com> writes:
> From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> Sent: Friday, 4 October 2019 1:32 PM
>>   Also, if we want to pursue, do we want to use INIT_ALL_ZEROES for bool arrays as well?

> FYI - In case it went unnoticed - my last patch addresses this by defining 2 macros:

> #define INIT_ALL_ELEMS_ZERO {0}
> #define INIT_ALL_ELEMS_FALSE {false}

I would say that's 100% wrong. The entire point here is that it's
memset-equivalent, and therefore writes zeroes, regardless of what
the datatype is. As a counterexample, the coding you have above
looks a lot like it would work to add

#define INIT_ALL_ELEMS_TRUE {true}

which as previously noted will *not* work. So I think the
one-size-fits-all approach is what to use.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2019-10-04 04:12:41 Re: [HACKERS] proposal: schema variables
Previous Message Smith, Peter 2019-10-04 03:51:48 RE: Proposal: Make use of C99 designated initialisers for nulls/values arrays