Re: mcvstats serialization code is still shy of a load

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: mcvstats serialization code is still shy of a load
Date: 2019-06-26 13:40:30
Message-ID: 26130.1561556430@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com> writes:
> On Tue, Jun 25, 2019 at 11:52:28PM -0400, Tom Lane wrote:
>> You can *not* cast something to an aligned pointer type if it's not
>> actually certain to be aligned suitably for that type.

> OK. So the solution is to ditch the casts altogether, and then do plain
> pointer arithmetics like this:

> #define ITEM_INDEXES(item) (item)
> #define ITEM_NULLS(item,ndims) (ITEM_INDEXES(item) + (ndims))
> #define ITEM_FREQUENCY(item,ndims) (ITEM_NULLS(item, ndims) + (ndims))
> #define ITEM_BASE_FREQUENCY(item,ndims) (ITEM_FREQUENCY(item, ndims) + sizeof(double))

> Or is that still relying on alignment, somehow?

No, constructs like a char* pointer plus n times sizeof(something) should
be safe.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2019-06-26 13:43:44 Re: mcvstats serialization code is still shy of a load
Previous Message Peter Eisentraut 2019-06-26 13:05:52 Re: "WIP: Data at rest encryption" patch and, PostgreSQL 11-beta3