From: Bernhard Beroun <bernhard@beroun.io>
To: pgsql-general@postgresql.org
Subject: Vanishing unique constraint
Date: Mon, 01 Jun 2020 10:02:12 +0200
Message-ID: <5301-5ed4b600-3-d1dc0d0@127402255> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: bernhard@beroun.io
Subject: Re: Vanishing unique constraint
In-Reply-To: <5301-5ed4b600-3-d1dc0d0@127402255>
References: <5301-5ed4b600-3-d1dc0d0@127402255>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox