Postgresql使用gist over text(varchar)数据类型排除约束

Postgresql使用gist over text(varchar)数据类型排除约束,sql,postgresql,constraints,exclude-constraint,Sql,Postgresql,Constraints,Exclude Constraint,我需要有一个约束来确保两个不同的行对于两个varchar列具有不同的值,并且组合范围不与另外两个列重叠 该表创建为: create table test(id varchar(255)不为空, 来自浮动8的金额, 金额_至浮点数8, 公司varchar(255)不为空, 货币varchar(255)不为空, 主键(id)); 此外,我还创建了一个自定义类型: 将类型floatrange创建为范围(subtype=float8,subtype_diff=float8mi); 现在,我可以创建一

我需要有一个约束来确保两个不同的行对于两个varchar列具有不同的值,并且组合范围不与另外两个列重叠

该表创建为:

create table test(id varchar(255)不为空,
来自浮动8的金额,
金额_至浮点数8,
公司varchar(255)不为空,
货币varchar(255)不为空,
主键(id));
此外,我还创建了一个自定义类型:

将类型floatrange创建为范围(subtype=float8,subtype_diff=float8mi);
现在,我可以创建一个EXCLUDE约束,以避免与base to amounts列(amount_from和amount_to)中的组合范围重叠

alter table test\u规则添加约束量\u范围\u重叠
使用gist(floatrange(amount_from,amount_to,“[]”)和&&)排除
但我不能把公司和货币列必须相等的限制条件包括在内。大概是这样的:

alter table test\u规则添加约束量\u范围\u重叠
排除将gist(浮动范围(金额从,金额到)与&、,
货币汇率=,
公司名称=)
这句话引起了以下错误:

SQL Error [42704]: ERROR: data type text 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.
Gist无法处理文本类型

如何包含这些列以完成预期的约束?是否存在允许文本比较的函数或类型转换

或者,有没有一种方法可以使用双重排除子句来使用gist和btree来获得我需要的东西?以这种方式:

alter table test\u规则添加约束量\u范围\u重叠
使用btree排除(货币为,公司为)
排除使用gist(floatrange(amount\u from,amount\u to)和&&)

创建扩展树此外,我认为对于金钱来说,现有的
numrange
更合适此外,我认为对于金钱而言,现有的
numrange
更合适。