Re: MERGE vs REPLACE

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Rick Gigger <rick(at)alpinenetworking(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, josh(at)agliodbs(dot)com, pgsql-hackers(at)postgresql(dot)org, Jaime Casanova <systemguards(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: MERGE vs REPLACE
Date: 2005-11-16 17:59:36
Message-ID: 200511161759.jAGHxaT00877@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout wrote:
-- Start of PGP signed section.
> On Wed, Nov 16, 2005 at 11:37:46AM -0500, Bruce Momjian wrote:
> >
> > Interesting approach. Actually, we could tell the user they have to use
> > BEGIN;LOCK tab before doing MERGE, and throw an error if we don't
> > already have a table lock.
>
> The bit I'm still missing is why there needs to be a lock at all. The
> SQL standard doesn't say anywhere that concurrent MERGE operations
> can't conflict. It seems to me that standard visibility rules apply. If
> neither MERGE statement can see the results of the other, then they
> will both INSERT. If you don't have a UNIQUE constraint to prevent this
> then what's the problem?

I assume they want MERGE because they don't want duplicates. If they
don't care, they would have used INSERT.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-11-16 18:03:41 Re: [COMMITTERS] pgsql: make_restrictinfo() failed to attach the specified
Previous Message Tom Lane 2005-11-16 17:48:09 Some array semantics issues