Re: "Cannot insert a duplicate key..." -- but where? - Mailing list pgsql-general

From Tom Lane
Subject Re: "Cannot insert a duplicate key..." -- but where?
Date
Msg-id 23502.1044588936@sss.pgh.pa.us
Whole thread Raw
In response to "Cannot insert a duplicate key..." -- but where?  (will trillich <will@serensoft.com>)
Responses Re: "Cannot insert a duplicate key..." -- SOLVED  (will trillich <will@serensoft.com>)
List pgsql-general
will trillich <will@serensoft.com> writes:
> in trying to UPDATE a linking-table record (the middle-man in a
> many-to-many relationship) i've encountered an "ERROR:  Cannot
> insert a duplicate key into unique index _relations_p_r_v_ix"

I tried to duplicate this, and got:

...
regression-# relation.relative   = r.id AND r.lname = 'b' and
regression-# relation.relation_v = t.id AND t.name  = 'Family';
UPDATE 1
regression=#

I think there's something you left out.

Given that you tested the WHERE clause by making an equivalent SELECT,
I don't believe that the UPDATE is trying to update more than one row.
It seems more likely that you overlooked a uniqueness conflict against
some other existing row.

            regards, tom lane

pgsql-general by date:

Previous
From: "kanchana"
Date:
Subject: Re: start error - pgsql
Next
From: Neil Conway
Date:
Subject: Re: PGconn thread safety