Re: operator classes for index? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: operator classes for index?
Date
Msg-id 22626.1303773322@sss.pgh.pa.us
Whole thread Raw
In response to Re: operator classes for index?  (Yves Weißig <weissig@rbg.informatik.tu-darmstadt.de>)
Responses Re: operator classes for index?
List pgsql-hackers
Yves Weißig <weissig@rbg.informatik.tu-darmstadt.de> writes:
> But anyway I am having trouble creating an operator class:

> CREATE OPERATOR CLASS abstime_ops
>  DEFAULT FOR TYPE abstime USING ebi FAMILY abstime_ops AS
>  OPERATOR 1 = ,
>  FUNCTION 1 abstimeeq(abstime,abstime);

> yields: ERROR: invalid procedure number 1, must be between 1 and 0

Apparently you've got zero in pg_am.amsupport for your new index AM.
You need to set that to the number of support-procedure types your AM
defines.  Have you been through
http://developer.postgresql.org/pgdocs/postgres/indexam.html
and the docs and source code for the pg_am, pg_amop, pg_amproc catalogs?
See
http://developer.postgresql.org/pgdocs/postgres/catalogs.html
as well as the src/include/catalog/ files for those catalogs.

> Additional, I don't know yet how to create index method support
> routines. I want to re-use the hash functions from hashfunc.c (because I
> do kind of a mapping). Is this possible?

Just list them in your CREATE OPERATOR CLASS commands.

> How does index_getprocinfo();
> now which support routine belongs to my index?

It looks in pg_amproc to find the routines that are entered for the
opclass associated with the index.  This is a pretty direct
representation of the FUNCTION entries from your previous CREATE
OPERATOR CLASS (or if you prefer, CREATE OPERATOR CLASS is designed to
provide the information needed to populate pg_amop and pg_amproc).
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: wrong hint message for ALTER FOREIGN TABLE
Next
From: Andrew Dunstan
Date:
Subject: Re: branching for 9.2devel