Re: mcvstats serialization code is still shy of a load

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2019-06-26T13:40:30Z
Lists: 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



Commits

  1. Simplify pg_mcv_list (de)serialization

  2. Sync our Snowball stemmer dictionaries with current upstream