Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Andreas Karlsson <andreas@proxel.se>
From: Andreas Karlsson <andreas@proxel.se>
To: Peter Geoghegan <pg@heroku.com>, Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Craig Ringer <craig@2ndquadrant.com>
Date: 2014-08-28T14:29:18Z
Lists: 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
Commits
-
Change the way we mark tuples as frozen.
- 37484ad2aace 9.4.0 cited
-
Add documentation for data-modifying statements in WITH clauses.
- 0ef0b3020402 9.1.0 cited