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

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Joe Nelson <joe(at)begriffs(dot)com>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, Chapman Flack <chap(at)anastigmatix(dot)net>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays
Date: 2019-10-22 10:43:03
Message-ID: CAA4eK1+3r47qU63PSArFJEHkEME3ngS51WqE8h5jcoYeiOb0iw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 22, 2019 at 12:35 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Stephen Frost <sfrost(at)snowman(dot)net> writes:
> > * Joe Nelson (joe(at)begriffs(dot)com) wrote:
> >> If it's being put behind a macro then *stylistically* it shouldn't
> >> matter whether {} or {0} is chosen, right? In which case {0} would
> >> be a better choice because it's supported everywhere.
>
> > The problem with {0} in the first place is that it doesn't actually work
> > in all cases... Simple cases, yes, but not more complex ones. It's
> > unfortunate that there isn't a general solution here that works across
> > platforms (even if it involved macros..), but that seems to be the case.
>
> There is a general solution that works across platforms; it's called
> memset() and it's what we're using today. I'm beginning to think that
> we should just reject this patch.
>

Hmm, but then what is your suggestion for existing code that uses {0}.
If we reject this patch and leave the current code as it is, there is
always a risk of some people using {0} and others using memset which
will lead to further deviation in the code. Now, maybe if we change
the existing code to always use memset where we use {0}, then we can
kind of enforce such a rule for future patch authors.

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2019-10-22 11:06:20 Re: pgbench - refactor init functions with buffers
Previous Message Devrim Gündüz 2019-10-22 10:37:18 Re: v12 pg_basebackup fails against older servers (take two)