Re: Making joins involving ctid work for the benefit of UPSERT - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Making joins involving ctid work for the benefit of UPSERT
Date
Msg-id 20140730211755.GA12435@momjian.us
Whole thread Raw
In response to Re: Making joins involving ctid work for the benefit of UPSERT  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Mon, Jul 28, 2014 at 11:37:07AM -0400, Robert Haas wrote:
> > Yes, but what if you don't see a conflict because it isn't visible to
> > your snapshot, and then you insert, and only then (step 5), presumably
> > with a dirty snapshot, you find a conflict? How does the loop
> > terminate if that brings you back to step 1 with the same MVCC
> > snapshot feeding the update?
> 
> Good point.  Maybe the syntax should be something like:
> 
> UPSERT table (keycol [, keycol] ...) { VALUES (val [, val] ...) [,
> ...] | select_query }

One idea would be to allow UPSERT with constants (single row), and use
CTEs with a SELECT or INSERT/RETURNING for multi-row upserts.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + Everyone has their own god. +



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Making joins involving ctid work for the benefit of UPSERT
Next
From: Tom Lane
Date:
Subject: Re: Allow GRANT TRIGGER privilege to DROP TRIGGER (Re: Bug ##7716)