Re: Hard problem with concurrency

From: CoL <col(at)mportal(dot)hu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hard problem with concurrency
Date: 2003-02-19 23:31:04
Message-ID: b313qb$2dmi$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Vincent van Leeuwen wrote, On 2/19/2003 10:08 PM:
> On 2003-02-18 20:02:29 +0100, Peter Eisentraut wrote:
>> Christopher Kings-Lynne writes:
>>
>> > REPLACE INTO anyone? ;)
>>
>> The upcoming SQL 200x standard includes a MERGE command that appears to
>> fulfill that purpose.
>>
>
> MySQL features a poor-mans aproach to this problem, their REPLACE command:
>
> http://www.mysql.com/doc/en/REPLACE.html
> REPLACE works exactly like INSERT, except that if an old record in the table
> has the same value as a new record on a UNIQUE index or PRIMARY KEY, the old
> record is deleted before the new record is inserted.
>
> I'd love to see this kind of functionality in PG, I've got a database that
> caches data which only gets conditional INSERT/UPDATEs, so that would save a
> lot of wasted SQL commands.

I think this replace function is stupid in mysql. It deletes the the
row, and what if that row is linked into another table? You loose your
connection, relation.
However you can easy write a procedure which can make a real replace,
cause it checks if same data (by keys) is in the table then makes an
update, if not, do an insert.

You can do everything, not like in mysql, just write it as you like.

C.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2003-02-20 01:17:01 Re: request for sql3 compliance for the update command
Previous Message mlw 2003-02-19 23:27:47 Re: The last configuration file patch (I hope!) This one