Re: INSERT ... ON CONFLICT {UPDATE | IGNORE} - Mailing list pgsql-hackers

From Andreas Karlsson
Subject Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Date
Msg-id 53FF3CBE.3060904@proxel.se
Whole thread Raw
In response to INSERT ... ON CONFLICT {UPDATE | IGNORE}  (Peter Geoghegan <pg@heroku.com>)
Responses Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
List pgsql-hackers
On 08/28/2014 04:43 AM, Peter Geoghegan wrote:
> -- Nesting within wCTE:
> WITH t AS (
>      INSERT INTO z SELECT i, 'insert'
>      FROM generate_series(0, 16) i
>      ON CONFLICT UPDATE SET v = v || 'update' -- use of
> operators/functions in targetlist
>      RETURNING * -- only projects inserted tuples, never updated tuples
> )
> SELECT * FROM t JOIN y ON t.k = y.a ORDER BY a, k;

Personally I would find it surprising if RETURNING did not also return 
the updated tuples. In many use cases for upsert the user does not care 
if the row was new or not.

What I think would be useful is if all tuples were returned but there 
was some way to filter out only the inserted ones.

-- 
Andreas Karlsson



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Audit of logout
Next
From: Andres Freund
Date:
Subject: Re: re-reading SSL certificates during server reload