Skip site navigation (1) Skip section navigation (2)

Re: Duplicate key value error

From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Duplicate key value error
Date: 2009-04-03 07:23:10
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru> wrote:

> Is it possible to print which key value is duplicated when 'Duplicate 
> key value violates unique constraint' occurs? Foreign key violation 
> error reports such kind of information.

I think it is not difficult from a technical standpoint.
The attached patch adds DETAIL messages to duplicate key value error:

    postgres=# INSERT INTO tbl(pk1, pk2) VALUES ('A', 1);
    ERROR:  duplicate key value violates unique constraint "tbl_pkey"
    DETAIL:  Key (pk1,pk2)=(A,1) already exists.

If no objection, I'd like to submit the patch to the next commit-fest (8.5).

ITAGAKI Takahiro
NTT Open Source Software Center

Attachment: report_dupkey.patch
Description: application/octet-stream (2.5 KB)

In response to


pgsql-hackers by date

Next:From: Martin PihlakDate: 2009-04-03 07:46:00
Subject: Re: psql \d commands and information_schema
Previous:From: Tena SakaiDate: 2009-04-03 05:52:09
Subject: Re: [HACKERS] How would I get rid of trailing blank line?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group