Thread: GiST Comparing IndexTuples/Datums

GiST Comparing IndexTuples/Datums

From
"Matthew Campbell"
Date:
Hey folks:

    I've been working with a group trying to implement UNIQUE index functionality in GiST (we started with hash, and have branched out to try and understand some of the other indexing structures as well).  We installed the btree-gist contrib module and have gist indexes working fine and understanding when it's supposed to be unique (regardless of which contrib module is installed).  We currently can walk over all the IndexTuples in a page and we were hoping to compare the IndexTuple passed into the gistdoinsert() function (the new itup being added to the index) to each of the IndexTuples in said page.  The idea we've been playing with right now is using 'datum = index_getattr(itup, 1, RelationGetDescr(r), &isnull);' as its used in hashinsert.c, but we can't figure out how to compare the two datums then.  The actual data type of the value being inserted would be different depending on the type of column you created the index on.  Since you provide an opclass when creating a gist index, are we supposed to use one of the user defined functions to compare items?  (One of them is 'same', so in btree-gist, the function is gbt_text_same() for indexes on char and text columns)  Is there a general way to access these functions without knowing specifically what contrib module is specified, something like OpClassFunction7()?  Thanks so much for humoring me, and I apologize as I get myself familiar with PostgreSQL and database concepts in general.


-Matt

Re: GiST Comparing IndexTuples/Datums

From
Tom Lane
Date:
"Matthew Campbell" <mtthw.cmpbll@gmail.com> writes:
>     I've been working with a group trying to implement UNIQUE index
> functionality in GiST (we started with hash, and have branched out to try
> and understand some of the other indexing structures as well).

This is hardly -novice material, suggest you repost in -hackers.

            regards, tom lane