Re: xl_heap_header alignment? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: xl_heap_header alignment?
Date
Msg-id 1058724.1595356403@sss.pgh.pa.us
Whole thread Raw
In response to Re: xl_heap_header alignment?  (Andres Freund <andres@anarazel.de>)
Responses Re: xl_heap_header alignment?
List pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> On July 21, 2020 10:45:37 AM PDT, Antonin Houska <ah@cybertec.at> wrote:
>> I don't quite understand this part of the comment of the xl_heap_header
>> structure:
>> * NOTE: t_hoff could be recomputed, but we may as well store it because
>> * it will come for free due to alignment considerations.

> Unless you declare them as packed, structs will add padding to align members correctly (if, and only if, the whole
structis stored well aligned). 

I think that comment may be out of date, because what's there now is

 * NOTE: t_hoff could be recomputed, but we may as well store it because
 * it will come for free due to alignment considerations.
 */
typedef struct xl_heap_header
{
    uint16        t_infomask2;
    uint16        t_infomask;
    uint8        t_hoff;
} xl_heap_header;

I find it hard to see how tacking t_hoff onto what would have been a
4-byte struct is "free".  Maybe sometime in the dim past there was
another field in this struct?  (But I checked back as far as 7.4
without finding one.)

I don't particularly want to remove the field, but we ought to
change or remove the comment.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: xl_heap_header alignment?
Next
From: Justin Pryzby
Date:
Subject: v13 planner ERROR: could not determine which collation to use for string comparison