Re: Expanding the use of FLEXIBLE_ARRAY_MEMBER for declarations like foo[1]

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Expanding the use of FLEXIBLE_ARRAY_MEMBER for declarations like foo[1]
Date: 2015-02-20 07:59:19
Message-ID: CAB7nPqTkYdVcgFEXwwPhX3atddqe5BRLp62Fwp=krHz5+_GDCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 20, 2015 at 2:21 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> On Fri, Feb 20, 2015 at 2:14 PM, Tom Lane wrote:
>> Michael Paquier writes:
>>> Thanks for the clarifications and the review. Attached is a new set.
>>
>> I've reviewed and pushed the 0001 patch (you missed a few things :-().
>
> My apologies. I completely forgot to check for any calls of offsetof
> with the structures changed...

Attached are 3 more patches to improve the coverage (being careful
this time with calls of offsetof and sizeof...):
- 0001 covers varlena in c.h
- 0002 covers HeapTupleHeaderData and MinimalTupleData, with things
changed in code paths of reorderbuffer and decoder
- 0003 changes RecordIOData, used in hstore, rowtypes and json functions

Even with this set applied, the following things remain in backend code:
$ git grep "VARIABLE LENGTH" | grep "[1]"
access/nbtree/nbtutils.c: BTOneVacInfo vacuums[1]; /* VARIABLE
LENGTH ARRAY */
access/transam/multixact.c: MultiXactId perBackendXactIds[1]; /*
VARIABLE LENGTH ARRAY */
access/transam/twophase.c: GlobalTransaction prepXacts[1];
/* VARIABLE LENGTH ARRAY */
commands/tablespace.c: Oid tblSpcs[1]; /*
VARIABLE LENGTH ARRAY */
commands/trigger.c: SetConstraintTriggerData trigstates[1];
/* VARIABLE LENGTH ARRAY */
executor/nodeAgg.c: AggStatePerGroupData pergroup[1]; /*
VARIABLE LENGTH ARRAY */
optimizer/plan/setrefs.c: tlist_vinfo vars[1]; /* VARIABLE
LENGTH ARRAY */
postmaster/checkpointer.c: CheckpointerRequest requests[1]; /*
VARIABLE LENGTH ARRAY */
storage/ipc/pmsignal.c: sig_atomic_t PMChildFlags[1]; /*
VARIABLE LENGTH ARRAY */
storage/ipc/procarray.c: int pgprocnos[1]; /*
VARIABLE LENGTH ARRAY */
utils/adt/rowtypes.c: ColumnCompareData columns[1]; /*
VARIABLE LENGTH ARRAY */
utils/cache/inval.c: SharedInvalidationMessage msgs[1]; /*
VARIABLE LENGTH ARRAY */
utils/cache/typcache.c: EnumItem enum_values[1]; /* VARIABLE
LENGTH ARRAY */

Regards,
--
Michael

Attachment Content-Type Size
0001-Switch-varlena-to-use-FLEXIBLE_ARRAY_MEMBER.patch application/x-patch 2.8 KB
0002-Switch-HeapTupleHeaderData-and-MinimalTupleData-to-u.patch application/x-patch 14.8 KB
0003-Switch-RecordIOData-to-use-FLEXIBLE_ARRAY_MEMBER.patch application/x-patch 8.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2015-02-20 08:29:14 Re: pg_basebackup may fail to send feedbacks.
Previous Message Pavel Stehule 2015-02-20 07:28:19 Re: POLA violation with \c service=