Re: MERGE vs REPLACE

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Jaime Casanova <systemguards(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: MERGE vs REPLACE
Date: 2005-11-11 22:40:54
Message-ID: 200511111440.54848.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jaime,

> why? seems that REPLACE only work if there are at least one row
> matching...

Scenario:

session1: REPLACE .... 1
session2: REPLACE ..... 1
session1: check to see that "1" exists .... no
session2: check to see that "1" exists .... no
session1: INSERT 1
session2: INSERT 1 .... ERROR

Get the picture? The only way to avoid a race condition is to be able to
do "predicate locking", that is to lock the table against any data write
matching that predicate.

--
--Josh

Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2005-11-11 23:00:32 Re: MERGE vs REPLACE
Previous Message Jaime Casanova 2005-11-11 22:04:25 Re: MERGE vs REPLACE