Re: Duplicate key insert question - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Duplicate key insert question
Date
Msg-id 20030702011602.GL27363@dcc.uchile.cl
Whole thread Raw
In response to Re: Duplicate key insert question  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
List pgsql-general
On Wed, Jul 02, 2003 at 09:58:28AM +0900, Jean-Christian Imbeault wrote:
> Alvaro Herrera wrote:
> >
> > No, only the "second" one will fail (though it's difficult which one is
> > the second)
>
> I couldn't get the link to work so I couldn't read why Tom shot it down.
> But if Tom shot down this idea down ... then it mustn't be correct.

The thread is here:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=3A4D6116.1A613402%40mascari.com&rnum=1&prev=/groups%3Fq%3DMike%2BMascari%2BINSERT%2BNOT%2BEXISTS%26ie%3D

The solution is not correct in that there _is_ a race condition.

> > You should check the returned value from the insertion
> > function to see if it succeeded or not.
>
> No, what I want if to have one query that will *always* insert if there
> is no record with this primary key and *always* do nothing (not fail,
> not generate an error) if there is already a record with this primary
> key. I don't want to check return values :)

No way.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"No es bueno caminar con un hombre muerto"

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: PSQL NEWBIE - RUNTIME ERROR
Next
From: "Reuben D. Budiardja"
Date:
Subject: Re: Duplicate key insert question