Exclusion constraint with negated operator?

From: Torsten Förtsch <tfoertsch123(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Exclusion constraint with negated operator?
Date: 2023-06-13 18:11:01
Message-ID: CAKkG4_=4Wo43KfFNE1i_91p+xJnGry_WM8fngH8Tv=F5wBD=wA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I wanted to create an exclusion constraint like

EXCLUDE (c1 WITH =, c2 with <>)

This gives an error:

operator <>(integer,integer) is not a member of operator family
"integer_ops"

I can resolve that by using gist and the btree_gist extension.

My question is can I somehow express something like

EXCLUDE (c1 WITH =, c2 with NOT =)

It seems that's not possible at the moment. But is there any obstacle in
principle or is it just not implemented?

We have a ton of overlap operators (geometric, ranges, arrays) but none for
the opposite. Sometimes that's useful for exclusion constraints.

Thanks,
Torsten

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Patrick O'Toole 2023-06-13 19:24:51 Helping planner to chose sequential scan when it improves performance
Previous Message David G. Johnston 2023-06-13 18:07:50 Re: Reproducing incorrect order with order by in a subquery