Here is the code:
testdb=# CREATE TABLE COMPANY7( testdb(# ID INT PRIMARY KEY NOT NULL, testdb(# NAME TEXT , testdb(# AGE INT , testdb(# ADDRESS CHAR(50), testdb(# SALARY REAL, testdb(# EXCLUDE USING gist testdb(# (NAME WITH =, testdb(# AGE WITH <>) testdb(# ); CREATE TABLE testdb=# INSERT INTO COMPANY7 VALUES(1, 'Paul', 32, 'California', 20000.00 ); INSERT 0 1 testdb=# INSERT INTO COMPANY7 VALUES(2, 'Paul', 32, 'Texas', 20000.00 ); INSERT 0 1 testdb=# INSERT INTO COMPANY7 VALUES(3, 'Allen', 42, 'California', 20000.00 ); INSERT 0 1 testdb=# table company7 testdb-# ; id | name | age | address | salary ----+-------+-----+----------------------------------------------------+-------- 1 | Paul | 32 | California | 20000 2 | Paul | 32 | Texas | 20000 3 | Allen | 42 | California | 20000 (3 rows) Clearly both constraints are violated, but there is no error, why?
PostgreSQL version 9.4.4
Tested on Ubuntu 15.04 and OS X 10.10