Re: Replaceing records - Mailing list pgsql-general

From Greg Stark
Subject Re: Replaceing records
Date
Msg-id 878yp4blmi.fsf@stark.dyndns.tv
Whole thread Raw
In response to Re: Replaceing records  (Harald Fuchs <nospam@sap.com>)
Responses Re: Replaceing records  (Csaba Nagy <nagy@ecircle-ag.com>)
Re: Replaceing records  (Jonathan Bartlett <johnnyb@eskimo.com>)
List pgsql-general
Harald Fuchs <nospam@sap.com> writes:

> You can't.  The only thing MySQL has to offer is

Actually I found two things related to this:

http://www.mysql.com/doc/en/INSERT.html

http://www.mysql.com/doc/en/REPLACE.html

You can do
 INSERT INTO tab (...) VALUES (...) ON DUPLICATE KEY UPDATE col=val, ...

It seems to be newer than REPLACE.

In any case, both seem doable in postgres since in its MVCC every update is a
delete+insert anyways. It means doing the delete if necessary and doing the
insert unconditionally.

But I'm not sure how convinced the developers are of its usefulness beyond
satisfying mysql migrations. I've never used mysql and I have seen a few times
it might have been useful. Not a lot, but a few. And it seems to be a frequent
question on the mailing list.

--
greg

pgsql-general by date:

Previous
From: psql-mail@freeuk.com
Date:
Subject: Re: postmaster crashing
Next
From: "Jenny -"
Date:
Subject: tablelevel and rowlevel locks