Re: xl_heap_header alignment?

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org,Antonin Houska <ah(at)cybertec(dot)at>,pgsql-hackers(at)postgresql(dot)org
Subject: Re: xl_heap_header alignment?
Date: 2020-07-21 18:02:11
Message-ID: 5A0F3128-D990-4431-9E97-793CD99FF11E@anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On July 21, 2020 10:45:37 AM PDT, Antonin Houska <ah(at)cybertec(dot)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.
>
>What are the alignment considerations? The WAL code does not appear to
>assume
>any alignment, and therefore it uses memcpy() to copy the structure
>into a
>local variable before accessing its fields. For example,
>heap_xlog_insert().

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

Regards,

Andres
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-07-21 18:33:23 Re: xl_heap_header alignment?
Previous Message Antonin Houska 2020-07-21 17:45:37 xl_heap_header alignment?