Re: GIST code doesn't build on strict 64-bit machines

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: GIST code doesn't build on strict 64-bit machines
Date: 2004-03-29 16:10:05
Message-ID: 40684A5D.9060605@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>I suppose that a correct fix involves doing MAXALIGN(VARDATA(evec)),
>>>but I do not know what places need to change to support this.
>
>
>>Its only union and picksplit user-defined methods in contrib modules.
>
>
> If I recall correctly, we decided to go with the present hack because we
> found the problem just before a release date and there wasn't time to do
> it more cleanly. It seems to me that there is time to fix it right for
> 7.5 ...
Yes, you are right.

I suggest to replace bytea by struct
typedef struct {
int32 n; /* number of GISTENTRY */
GISTENTRY vector[1];
} GistEntryVector;

#define GEVHDRSZ (MAXALIGN(sizeof(int32))
so, allocation will be:
evec = palloc( GEVHDRSZ + sizeof(GISTENTRY)*n );
MAXALIGN guarantee that allocated memory will be no less than required (it may
be greater for 4 bytes).

And change interface to user defined structures from
Datum union(bytea *entryvec, int *size)
Datum picksplit(bytea *entryvec, GIST_SPLITVEC *v)
to
Datum union(GistEntryVector *entryvec, int *size)
Datum picksplit(GistEntryVector *entryvec, GIST_SPLITVEC *v)
In this function it's need to use entryvec->n and entryvec->vector

We can do even
Datum union(int32 n, GISTENTRY *entryvec, int *size)
Datum picksplit(int32 n, GISTENTRY *entryvec, GIST_SPLITVEC *v)

It seems to me that first case is clearer. Of course, I change all contrib
modules to new interface.
What do you think?

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-03-29 16:22:20 Re: GIST code doesn't build on strict 64-bit machines
Previous Message Tom Lane 2004-03-29 16:01:40 Re: pg_dump 7.4 bug