Vanishing unique constraint

From: "Bernhard Beroun" <bernhard(at)beroun(dot)io>
To: pgsql-general(at)postgresql(dot)org
Subject: Vanishing unique constraint
Date: 2020-06-01 08:02:12
Message-ID: 5301-5ed4b600-3-d1dc0d0@127402255
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello,

I am experiencing a strange thing on my production database server, which I can't explain.

On my production database server, there is a table called "label_suggestion" which has a unique constraint on the "name" column. If I do a "\d+ label_suggestion" I can see, that the unique constraint shows up with

"label_suggestion_name_unique" UNIQUE CONSTRAINT, btree (name)

in the output. But when I execute the following query

SELECT name FROM label_suggestion GROUP BY name HAVING COUNT(name) > 1

I can see that there are actually entries with a duplicate name in the database, which makes me believe that the unique constraint isn't there at all. (or at least it's not enforced)

Next, I dumped the complete production database (via pg_dumpall) and applied the dump on my local machine. I did again a "\d+ label_suggestion" and now the unique constraint doesn't show up anymore.

Anyone an idea what's going on here?

(Both the production database server and my local database server are running at version 9.6.18)

Any help is really appreciated.

Thanks,
Bernhard

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gabriele Bulfon 2020-06-01 08:07:29 Re: problem with self built postgres 9.0.9
Previous Message Thomas Kellerer 2020-06-01 07:53:32 Re: Oracle vs. PostgreSQL - a comment