From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: tibor@neszt.hu
Subject: BUG #15952: UNIQUE CONSTRAINT does not fulfill its' purpose
Date: Mon, 12 Aug 2019 20:22:58 +0000
Message-ID: <15952-d777d2ea6569227a@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15952
Logged by: Neszt Tibor
Email address: tibor@neszt.hu
PostgreSQL version: 9.6.14
Operating system: Debian 8.11
Description:
Schema:
=> \d cimek
Table "public.cimek"
Column | Type | Modifiers
----------------+-----------------------+-----------------------------------------------------
kod | bigint | not null default
nextval('cimek_kod_seq'::regclass)
irsz | character varying(16) | not null default ''::character
varying
telepules | character varying(64) | not null default ''::character
varying
telepulesresz | character varying(64) | not null default ''::character
varying
kozternev | character varying(64) | not null default ''::character
varying
kozterjelleg | character varying(32) | not null default ''::character
varying
hazszam | character varying(64) | not null default ''::character
varying
hazszambetujel | character varying(64) | not null default ''::character
varying
hazszamvege | character varying(64) | not null default ''::character
varying
lepcsohaz | character varying(32) | not null default ''::character
varying
em | character varying(32) | not null default ''::character
varying
ajto | character varying(64) | not null default ''::character
varying
ajtobetujel | character varying(64) | not null default ''::character
varying
longitude | character varying(32) | not null default ''::character
varying
latitude | character varying(32) | not null default ''::character
varying
Indexes:
"cimek_pkey" PRIMARY KEY, btree (kod)
"cimek_irsz_telepules_telepulesresz_kozternev_kozterjelleg_h_key" UNIQUE
CONSTRAINT, btree (irsz, telepules, telepulesresz, kozternev, kozterjelleg,
hazszam, hazszambetujel, hazszamvege, lepcsohaz, em, ajto, ajtobetujel)
Actual behavior:
=> select count(*), min(kod), max(kod), irsz, telepules, telepulesresz,
kozternev, kozterjelleg, hazszam, hazszambetujel, hazszamvege, lepcsohaz,
em, ajto, ajtobetujel from cimek group by irsz, telepules, telepulesresz,
kozternev, kozterjelleg, hazszam, hazszambetujel, hazszamvege, lepcsohaz,
em, ajto, ajtobetujel having count(*) > 1;
count | min | max | irsz | telepules | telepulesresz | kozternev |
kozterjelleg | hazszam | hazszambetujel | hazszamvege | lepcsohaz | em |
ajto | ajtobetujel
-------+-------+-------+------+-----------+---------------+-----------+--------------+---------+----------------+-------------+-----------+----+------+-------------
2 | 51611 | 55269 | 2092 | Budakeszi | | Foo | utca
| 46 | | | | | |
(1 row)
The main problem is that there are two records with the same data set.
The real street name was altered with 'Foo' in this bugreport.
I tried to reproduce the issue locally without success. I encountered this
bug in multiple databases with different table and data. I could upgrade the
database to version 11 with "pg_upgradecluster 11 main -m upgrade -k", and
the issue still remain. To make sure it's not a human error, I tried to dump
the data and restore it. I got duplicate key error as expected.
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-bugs@postgresql.org
Cc: noreply@postgresql.org, tibor@neszt.hu
Subject: Re: BUG #15952: UNIQUE CONSTRAINT does not fulfill its' purpose
In-Reply-To: <15952-d777d2ea6569227a@postgresql.org>
References: <15952-d777d2ea6569227a@postgresql.org>
* 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