Re: GiST consistent function, expected arguments; multi-dimensional indexes - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: GiST consistent function, expected arguments; multi-dimensional indexes
Date
Msg-id 20070702105520.GB12254@svana.org
Whole thread Raw
In response to Re: GiST consistent function, expected arguments; multi-dimensional indexes  (Eric <fishware@comcast.net>)
Responses Re: GiST consistent function, expected arguments; multi-dimensional indexes  (Eric <fishware@comcast.net>)
List pgsql-hackers
On Sun, Jul 01, 2007 at 07:20:08PM -0700, Eric wrote:
>
> >
> > Everything is always passed as a Datum, so yes, it's is determined by
> > the storage clause in CREATE TYPE.
>
> Still not sure what to do in some scenarios.  One example is the gist
> example code for btree (btree_gist).  If you look at the int4 example
> consistent function, it gets an int32 value (param 1).  For other
> data  types, it would get a pointer to a value.  Is the rule anything
> <= 4 bytes it's a value, above that it's a pointer?  See the code
> below...

Why guess. You know the type ID of what you're manipulating, right.
Then the function:

get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);

Returns the byval flag (true if passed by value, false if passed by
reference) and the typlen field will be either a positive integer,
representing the number of bytes, or negative for variable length.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-hackers by date:

Previous
From: "Manera, Villiam"
Date:
Subject: R: R: [postgresql-it] no cascade triggers?
Next
From: "Jeroen T. Vermeulen"
Date:
Subject: ANALYZE and index/stats degradation