Re: Expanding the use of FLEXIBLE_ARRAY_MEMBER for declarations like foo[1] - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Expanding the use of FLEXIBLE_ARRAY_MEMBER for declarations like foo[1]
Date
Msg-id 20150219095453.GF16383@alap3.anarazel.de
Whole thread Raw
In response to Re: Expanding the use of FLEXIBLE_ARRAY_MEMBER for declarations like foo[1]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2015-02-18 21:00:43 -0500, Tom Lane wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
> > 3) heapam.c in three places with HeapTupleHeaderData:
> >         struct
> >         {
> >                 HeapTupleHeaderData hdr;
> >                 char            data[MaxHeapTupleSize];
> >         }                       tbuf;
> 
> And this, though I'm not sure if we'd have to change the size of the
> padding data[] member.

I don't think so.
/** MaxHeapTupleSize is the maximum allowed size of a heap tuple, including* header and MAXALIGN alignment padding.
Basicallyit's BLCKSZ minus the* other stuff that has to be on a disk page.  Since heap pages use no* "special space",
there'sno deduction for that.
 
...
#define MaxHeapTupleSize  (BLCKSZ - MAXALIGN(SizeOfPageHeaderData + sizeof(ItemIdData)))

> > 5) reorderbuffer.h with its use of HeapTupleHeaderData:
> 
> Hmm.  Andres will have to answer for that one ;-)

That should be fairly uncomplicated to replace.
...       /* tuple, stored sequentially */HeapTupleData tuple;HeapTupleHeaderData header;char
data[MaxHeapTupleSize];

probably can just be replaced by a union of data and header part - as
quoted above MaxHeapTupleSize actually contains space for the
header. It's a bit annoying because potentially some output plugin might
reference .header - but they can just be changed to reference
tuple.t_data instead.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Expanding the use of FLEXIBLE_ARRAY_MEMBER for declarations like foo[1]
Next
From: Andres Freund
Date:
Subject: Re: INSERT ... ON CONFLICT UPDATE and logical decoding