Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
984 views
in Technique[技术] by (71.8m points)

postgresql - Equivalent to exclusion constraint composed of integer and range

I need to have something equivalent to this exclusion constraint

drop table if exists t;
create table t (
    i int,
    tsr tstzrange,
    exclude using gist (i with =, tsr with &&)
);
ERROR:  data type integer 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 guess the problem is obvious from the error message. How to do it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to install the additional module btree_gist to make it work. The module installs the missing operator class.

Details in this related answer:
Exclusion constraint on a bitstring column with bitwise AND operator

More at this answer on dba.SE:
PostgreSQL EXCLUDE USING error: Data type integer has no default operator class


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.6k users

...