Re: MERGE Specification

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Petr Jelinek <pjmodos(at)pjmodos(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Subject: Re: MERGE Specification
Date: 2008-04-25 12:17:24
Message-ID: 1209125844.4238.7.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2008-04-25 at 11:07 +0200, Petr Jelinek wrote:

> Another thing is, the table on which we do SELECT (the one in USING) can
> be different from target table and we can use columns from that table in
> INSERT/UPDATE statement (probably one the reasons why spec says the
> "SELECT" query has to be executed before any changes). How you want to
> use the "INSERT first" implementation in this scenario ? IMHO you still
> need to have both implementations in the end. So we probably need to
> implement the standard one first and then implement our version and put
> some restrictions of what can be in USING or INSERT part when using it.

We do this:

1. Run using clause,

then for each row

2. NOT MATCHED rules
3. MATCHED

I'm now happy that we can get a spec-compliant end result by always
forcing NOT MATCHED rules to occur before MATCHED rules, when we have at
least one unique index.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Decibel! 2008-04-25 12:45:15 Re: MERGE Specification
Previous Message Simon Riggs 2008-04-25 09:30:49 Re: MERGE Specification