Re: MERGE Specification
Simon Riggs <simon@2ndquadrant.com>
From: Simon Riggs <simon@2ndquadrant.com>
To: Petr Jelinek <pjmodos@pjmodos.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL-development <pgsql-hackers@postgresql.org>, Alvaro Herrera <alvherre@commandprompt.com>
Date: 2008-04-25T12:17:24Z
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