REPLACE implementation (was: Re: MERGE vs REPLACE)

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, peter_e(at)gmx(dot)net
Subject: REPLACE implementation (was: Re: MERGE vs REPLACE)
Date: 2005-11-13 16:58:47
Message-ID: c2d9e70e0511130858j7f7f5007gcd7aa0dd702f1706@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/12/05, Matteo Beccati <php(at)beccati(dot)com> wrote:
> Tom Lane wrote:
> > Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> >> It seems to me that it has always been implicitly assumed around here
> >> that the MERGE command would be a substitute for a MySQL-like REPLACE
> >> functionality. After rereading the spec it seems that this is not the
> >> case. MERGE always operates on two different tables, which REPLACE
> >> doesn't do.
> >
> > Normally I'd plump for following the standard ... but AFAIR, we have had
> > bucketloads of requests for REPLACE functionality, and not one request
> > for spec-compatible MERGE. If, as it appears, full-spec MERGE is also a
> > whole lot harder and slower than REPLACE, it seems that we could do
> > worse than to concentrate on doing REPLACE for now. (We can always come
> > back to MERGE some other day.)
>
> I would also like to add that MySQL's REPLACE is not exactly an INSERT
> OR UPDATE, rather and INSERT OR (DELETE then INSERT): I mean that the
> fields not specified in the query are set to their defaults:
>

This sounds a lot like postgres implementation of UPDATE... delete
tuple (actually, mark it as dead and insert)...

Maybe we can use this? or maybe some kind of merge between ExecDelete
and ExecInsert?

Also, the MySQL implementation require DELETE and INSERT permission.
What about triggers? run before/after delete and insert?

--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2005-11-13 17:27:45 Re: MERGE vs REPLACE
Previous Message Tom Lane 2005-11-13 16:31:38 Re: Supporting NULL elements in arrays