Re: Quick pointer required re indexing geometry

From: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
To: Paul Matthews <plm(at)netspace(dot)net(dot)au>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Quick pointer required re indexing geometry
Date: 2009-08-11 13:54:55
Message-ID: 87vdkuh2vk.fsf@hi-media-techno.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Paul Matthews <plm(at)netspace(dot)net(dot)au> writes:
> Witting a box@>point function easy. Having a spot of trouble trying to
> figure out where and how to graft this into the GiST stuff. Could
> someone please point me in the general direction?

You want index support for it, I suppose?

Without index support (but needed anyway), you implement your code in a
C module then make it visible from SQL. I'm not sure you're asking help
for the C part so don't expand, please ask more if needed:

CREATE OR REPLACE FUNCTION box_contains_point(box, point)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;

CREATE OPERATOR @> (
LEFTARG = box,
RIGHTARG = point,
PROCEDURE = box_contains_point,
COMMUTATOR = '<@',
RESTRICT = contsel,
JOIN = contjoinsel
);
COMMENT ON OPERATOR @>(box, point) IS 'box contains point?';

Now for adding support for index lookups, you have to see documentation
about OPERATOR CLASS and OPERATOR FAMILY. I guess you need to make a
family out of point and box if none already exists, add the @> operator
there and point to your function.

I'm unclear if you need to add it to an OPERATOR CLASS too and which, so
I won't risk into writing the commands. Cross datatype indexing support,
as far as I've understood, is tied together with operator families.

Hope this helps, regards,
--
dim

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2009-08-11 13:56:38 Re: "Hot standby"?
Previous Message Tom Lane 2009-08-11 13:41:46 Re: HEAD docs