From: | "Smith, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com> |
---|---|
To: | Isaac Morland <isaac(dot)morland(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | RE: Proposal: Make use of C99 designated initialisers for nulls/values arrays |
Date: | 2019-10-01 23:23:00 |
Message-ID: | 201DD0641B056142AC8C6645EC1B5F62014B91B2E8@SYD1217 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
From: Isaac Morland <isaac(dot)morland(at)gmail(dot)com> Sent: Tuesday, 1 October 2019 11:32 PM
>Typical Example:
>Before:
> Datum values[Natts_pg_attribute];
> bool nulls[Natts_pg_attribute];
> ...
> memset(values, 0, sizeof(values));
> memset(nulls, false, sizeof(nulls));
>After:
> Datum values[Natts_pg_attribute] = {0};
> bool nulls[Natts_pg_attribute] = {0};
>
>I hope you'll forgive a noob question. Why does the "After" initialization for the boolean array have {0} rather than {false}?
It is a valid question.
I found that the original memsets that this patch replaces were already using 0 and false interchangeably. So I just picked one.
Reasons I chose {0} over {false} are: (a) laziness, and (b) consistency with the values[] initialiser.
But it is no problem to change the bool initialisers to {false} if that becomes a committer review issue.
Kind Regards
--
Peter Smith
Fujitsu Australia
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2019-10-01 23:23:40 | Re: pgbench - allow to create partitioned tables |
Previous Message | Amit Kapila | 2019-10-01 22:57:30 | Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions |