mi_integer mi_key_opclass(MI_AM_KEY_DESC *keyDesc, mi_integer keyNum) mi_string * mi_key_opclass_name( MI_AM_KEY_DESC *keyDesc, mi_integer keyNum)
An operator class consists of the strategy and support functions with which the access method manages a particular data type. To determine which operator class to use for a particular key, identify the key as an argument to mi_key_opclass() or mi_key_opclass_name(). To obtain the operator class identifier number, call mi_key_opclass(). To obtain the operator class name, call mi_key_opclass_name().
The integer argument keyNum identifies the column number in the index entry. A one-column index contains only keyNum 0. A two-column key contains keyNum 0 and 1. To determine the number of columns in a key, call mi_key_nkeys().
The access method can execute mi_key_opclass() or mi_key_opclss_name() for each column in a multiple-column key because the columns do not necessarily all use the same operator class. A CREATE INDEX statement can assign different operator classes to individual columns in a multiple-column key. The following example defines an index with multiple operator classes:
CREATE OPCLASS str_ops FOR video_am
STRATEGIES (lessthan(char, char), lessthanorequal(char, char),
equal(char, char),
greaterthanorequal(char, char), greaterthan(char, char))
SUPPORT(compare)
CREATE OPCLASS int_ops FOR video_am
STRATEGIES (lessthan(int, int), lessthanorequal(int, int),
equal(int, int),
greaterthanorequal(int, int), greaterthan(int,int))
SUPPORT(compare)
CREATE TABLE videos (title char(50), year int, copies int)
CREATE INDEX vidx ON videos (title str_ops, year int_ops) USING video_am
As the access-method creator, you must assign a default operator class for the access method. To assign a default operator class, set the am_defopclass purpose value with the ALTER ACCESS_METHOD statement. If the CREATE INDEX statement does not specify the operator class to use, the mi_key_opclass() or mi_key_opclass_name() function specifies the default operator class.
For mi_key_opclass(), a positive return value identifies the operator class in the sysopclass system catalog table. A return value of -1 indicates that the function passed an invalid keyNum value.
For mi_key_opclass_name(), a non-NULL pointer identifies the name of the operator class. A return value of null indicates that the function passed an invalid keyNum value.
See the description of: