Red Hat Database: Administrator and User's Guide | ||
---|---|---|
Prev | Chapter 15. Interfacing Extensions To Indexes | Next |
The next table of interest is pg_opclass. This table defines operator class names and input data types for each of the operator classes supported by a given index access method. The same class name can be used for several different access methods (for example, both B-tree and hash access methods have operator classes named oid_ops), but a separate pg_opclass row must appear for each access method. The OID of the pg_opclass row is used as a foreign key in other tables to associate specific operators and support routines with the operator class.
You need to add a row with your operator class name (for example, complex_abs_ops) to pg_opclass:
INSERT INTO pg_opclass (opcamid,opcname,opcintype,opcdefault,opckeytype) VALUES ( (SELECT oid FROM pg_am WHERE amname = 'btree'), 'complex_abs_ops', (SELECT oid FROM pg_type WHERE typname = 'complex'), true, 0); SELECT oid, * FROM pg_opclass WHERE opcname = 'complex_abs_ops'; oid |opcamid| opcname | opcintype | opcdefault | opckeytype -------+-------+-----------------+-----------+------------+----------- 277975| 403| complex_abs_ops | 277946 | t | 0 (1 row) |
The above example assumes that you want to make this new operator class the default B-tree operator class for the complex data type. If you do not, just set opcdefault to false instead. opckeytype is not described here; it should always be zero for B-tree operator classes.