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

From Eric
Subject Re: GiST consistent function, expected arguments; multi-dimensional indexes
Date
Msg-id 1183342808.898561.249600@j4g2000prf.googlegroups.com
Whole thread Raw
In response to Re: GiST consistent function, expected arguments; multi-dimensional indexes  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: GiST consistent function, expected arguments; multi-dimensional indexes  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-hackers
>
> 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...

Datum
gbt_int4_consistent(PG_FUNCTION_ARGS)
{
GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);int32        query = PG_GETARG_INT32(1);int32KEY   *kkk =
(int32KEY*) DatumGetPointer(entry->key);
 

>
> The usual approach to this is to define the index on a composite of
> the values. For example, if you have a table with two points that you
> want to index together, you do:
>
> CREATE INDEX foo ON bar((box(point1,point2)));
>
> i.e. a functional index on the result of combining the points. It does
> mean you need to use the same syntax when doing the queries, but it
> works with modifying any internal code at all...
>
> Given you can use rowtypes more easily these days, it's quite possible
> you use build an operator class on a row type...
>
> Have a nice day,
> --
> Martijn van Oosterhout   <klep...@svana.org>  http://svana.org/kleptog/
>
> > From each according to his ability. To each according to his ability to litigate.
>
>

Thanks Martijn.  I will consider that approach.




pgsql-hackers by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: what is difference between LOCAL and GLOBAL TEMP TABLES in PostgreSQL
Next
From: Hannu Krosing
Date:
Subject: Re: todo: Hash index creation