Re: mcvstats serialization code is still shy of a load - Mailing list pgsql-hackers

From Tom Lane
Subject Re: mcvstats serialization code is still shy of a load
Date
Msg-id 26130.1561556430@sss.pgh.pa.us
Whole thread Raw
In response to Re: mcvstats serialization code is still shy of a load  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
Tomas Vondra <tomas.vondra@2ndquadrant.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



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: "WIP: Data at rest encryption" patch and, PostgreSQL 11-beta3
Next
From: Tomas Vondra
Date:
Subject: Re: mcvstats serialization code is still shy of a load