Proposed new create command, CREATE OPERATOR CLASS

From: Bill Studenmund <wrstuden(at)netbsd(dot)org>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Proposed new create command, CREATE OPERATOR CLASS
Date: 2001-10-23 13:41:15
Message-ID: Pine.NEB.4.33.0110230400080.8537-100000@vespasia.home-net.internetconnect.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'd like to propose a new command, CREATE OPERATOR CLASS. Its purpose is
to create a named operator class, so that you can create new types of
index ops. Also, its inclusion would remove the section of the
documentation where we tell people how to manually manipulate the system
tables.

Since schema support is going to change some of the details of the system
tables in important ways, I think it's better to move away from manual
updates.

The command is basically an instrumentation of the documentation on how to
add new operator classes.

Here's the syntax I'd like to propose:

CREATE OPERATOR CLASS <name> [DEFAULT] FOR TYPE <typename> USING <access
method> WITH <list of operators> AND <list of support functions>

New keywords are "CLASS" (SQL99 reserved word) and "REPEATABLE" (SQL99
non-reserved word, see below for usage).

<name> is the class's name, and <typename> is the type to be indexed.
<access method> is the assosciated access method from pg_am (btree, rtree,
hash, gist).

The presence of [DEFAULT] indicates that this operator class shold be made
the default operator class for the type.

<list of operators> is a comma-delimited list of operator specs. An
operator spec is either an operator or an operator followed by the keyword
"REPEATABLE". The presence of "REPEATABLE" indicates that amopreqcheck
should be set to true for this operator. Each item in this list will
generate an entry in pg_amop.

<list of support functions> is a comma-seperated list of functions used to
assist the index method. Each item in this list will generate an item in
pg_amproc.

I agree that I think it is rare that anything will set "REPEATABLE", but
the point of this effort is to keep folks from mucking around with the
system tables manually, so we should support making any reasonable entry
in pg_amop.

Here's an example based on the programmer's guide. We've created the type
"complex", and have comparison functions complex_abs_lt, complex_abs_le,
complex_abs_eq, complex_abs_gt, complex_abs_ge. Then let us have created
operators "||<", "||<=", "||=", "||>", "||>=" based on them. We also have
the complex_abs_cmp helper function. To create the operator class, the
command would be:

CREATE OPERATOR CLASS complex_abs_ops DEFAULT FOR TYPE complex USING
btree with ||<, ||<=, ||=, ||>=, ||> and complex_abs_cmp;

Among other things, complex_abs_ops would be the default operator class
for the complex type after this command.

An example using REPEATABLE would be:

CREATE OPERATOR CLASS complex_abs_ops DEFAULT FOR TYPE complex USING btree
with ||< REPEATABLE, ||<=, ||=, ||>=, ||> REPEATABLE and complex_abs_cmp;

Note: I don't think the above command will create a correct operator
class, it just shows how to add REPEATABLE.

The alternative to "REPEATABLE" would be something like
"hit_needs_recheck" after the operator. Suggestions?

Thoughts?

Take care,

Bill

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2001-10-23 13:52:18 Re: [GENERAL] To Postgres Devs : Wouldn't changing the
Previous Message Marc Spitzer 2001-10-23 13:28:47 Re: Index of a table is not used (in any case)