Re: "Cannot insert a duplicate key..." -- but where?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: will trillich <will(at)serensoft(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: "Cannot insert a duplicate key..." -- but where?
Date: 2003-02-07 03:35:36
Message-ID: 23502.1044588936@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

will trillich <will(at)serensoft(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2003-02-07 03:43:32 Re: PGconn thread safety
Previous Message Tom Lane 2003-02-07 03:16:54 Re: plpgsql - fetching from returned cursors