EXCLUDE constraint with not equals - Mailing list pgsql-general

From Kai Groner
Subject EXCLUDE constraint with not equals
Date
Msg-id CALiRux=zZatOsKKN3kHG0rnEHSatusz79_SHKBDsZ+1D4_2fpg@mail.gmail.com
Whole thread Raw
Responses Re: EXCLUDE constraint with not equals  (Thomas Kellerer <spam_eater@gmx.net>)
Re: EXCLUDE constraint with not equals  (Emre Hasegeli <emre@hasegeli.com>)
List pgsql-general
Hello,

Given the following table, I would like to ensure that all the rows for an email that have a user defined map to the same user.

CREATE TABLE person (
  id INTEGER PRIMARY KEY,
  user TEXT,
  email TEXT NOT NULL);

 
What I think I'm looking for is something like this:

CREATE TABLE person (
  id INTEGER PRIMARY KEY,
  user TEXT,
  email TEXT NOT NULL,
  EXCLUDE (email WITH =, user WITH <>)
    WHERE (user IS NOT NULL));

The not equals comparison isn't supported, but it would be useful here.

Is there another way to do this, short of creating a separate table that associates email and user?

pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Mult-standby streaming replication master failover
Next
From: Xavier Stevens
Date:
Subject: Logical Decoding Callbacks