I have my own enum data type (called
direction), which can be
OUT and I want to use
EXCLUDE USING gist constraint to prevent inserting row with the same direction (and two more columns) like this:
ALTER TABLE table_name ADD CONSTRAINT constraint_name EXCLUDE USING gist (id_group WITH =, direction WITH =, valid_range WITH &&)
There can't be more rows with the same id_group, same direction and overlapping valid_range , but I get this error:
ERROR: data type direction has no default operator class for access method "gist" HINT: You must specify an operator class for the index or define a default operator class for the data type.
I've found this http://www.postgresql.org/docs/9.2/static/sql-createopclass.html and tried
CREATE OPERATOR CLASS gist__direction_ops DEFAULT FOR TYPE scheman_name.direction USING gist AS OPERATOR 6 = (anyenum, anyenum);
but then I got
ERROR: missing support function 1 for attribute 2 of index "constraint_name"
and I don't know how to add function to compare two enums in gist or whatever should i do :)