Re: operator classes for index?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: weissig(at)rbg(dot)informatik(dot)tu-darmstadt(dot)de
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: operator classes for index?
Date: 2011-04-25 23:15:22
Message-ID: 22626.1303773322@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?ISO-8859-15?Q?Yves_Wei=DFig?= <weissig(at)rbg(dot)informatik(dot)tu-darmstadt(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2011-04-25 23:17:57 Re: branching for 9.2devel
Previous Message Tom Lane 2011-04-25 23:03:41 Re: wrong hint message for ALTER FOREIGN TABLE