From: | Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com> |
Cc: | Jaime Casanova <systemguards(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net> |
Subject: | Re: MERGE vs REPLACE |
Date: | 2005-11-11 23:23:56 |
Message-ID: | Pine.LNX.4.58.0511121022590.25926@linuxworld.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, 11 Nov 2005, Josh Berkus wrote:
> 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.
When it comes to predicate locking, I think we should defer to Peter's
comment at Open DB Con:
http://www.treehou.se/~swm/peter_merge.jpg
Gavin
From | Date | Subject | |
---|---|---|---|
Next Message | mark | 2005-11-11 23:36:57 | Re: MERGE vs REPLACE |
Previous Message | Tom Lane | 2005-11-11 23:17:58 | Re: MERGE vs REPLACE |