Re: [HACKERS] Per row status during INSERT .. ON CONFLICT UPDATE?

2015-05-19 Thread Peter Geoghegan
On Tue, May 19, 2015 at 1:20 PM, Peter Geoghegan wrote: > On Tue, May 19, 2015 at 1:07 PM, Robins Tharakan wrote: >> My use-case is to create an extra row for all UPDATEd rows (only), which is >> implemented in MSSQL by enveloping the MERGE with an INSERT (MERGE ... >> OUTPUT $action) WHERE $acti

Re: [HACKERS] Per row status during INSERT .. ON CONFLICT UPDATE?

2015-05-19 Thread Peter Geoghegan
On Tue, May 19, 2015 at 1:07 PM, Robins Tharakan wrote: > My use-case is to create an extra row for all UPDATEd rows (only), which is > implemented in MSSQL by enveloping the MERGE with an INSERT (MERGE ... > OUTPUT $action) WHERE $action = 'UPDATE'. That could make sense. You can achieve somethi

Re: [HACKERS] Per row status during INSERT .. ON CONFLICT UPDATE?

2015-05-19 Thread Robins Tharakan
On 19 May 2015 at 23:24, Peter Geoghegan wrote: > That's certainly something we talked about. It could probably be done > with some kind of magical expression. I have to wonder how many of the > people that are sure that they need this really do, though. Is it > really natural to care about this

Re: [HACKERS] Per row status during INSERT .. ON CONFLICT UPDATE?

2015-05-19 Thread Peter Geoghegan
On Tue, May 19, 2015 at 10:49 AM, Andres Freund wrote: >> The RETURNING clause just allows us to return columns, but am unable to >> find a way to know 'what' happened to a given row. > > There previously has been discussion about extending RETURNING to allow > to return the before/after row. But

Re: [HACKERS] Per row status during INSERT .. ON CONFLICT UPDATE?

2015-05-19 Thread Andres Freund
On 2015-05-19 17:53:09 +0530, Robins Tharakan wrote: > Is there a way to know which rows were INSERTed and UPDATEd when doing a > INSERT ... ON CONFLICT UPDATE? Probably via pseudo column indicating INSERT > / UPDATE ? No, not really. > The RETURNING clause just allows us to return columns, but a

Re: [HACKERS] Per row status during INSERT .. ON CONFLICT UPDATE?

2015-05-19 Thread Marko Tiikkaja
On 5/19/15 3:04 PM, Thom Brown wrote: If you want the delta, you'll have to resort to a CTE: e.g. # WITH newvals AS ( INSERT INTO test (name, age) VALUES ('James', 45) ON CONFLICT (name) DO UPDATE SET age = EXCLUDED.age RETURNING *) SELECT n.name, o.age as "old.age"

Re: [HACKERS] Per row status during INSERT .. ON CONFLICT UPDATE?

2015-05-19 Thread Thom Brown
On 19 May 2015 at 13:23, Robins Tharakan wrote: > Hi, > > Is there a way to know which rows were INSERTed and UPDATEd when doing a > INSERT ... ON CONFLICT UPDATE? Probably via pseudo column indicating INSERT > / UPDATE ? > > The RETURNING clause just allows us to return columns, but am unable to

[HACKERS] Per row status during INSERT .. ON CONFLICT UPDATE?

2015-05-19 Thread Robins Tharakan
Hi, Is there a way to know which rows were INSERTed and UPDATEd when doing a INSERT ... ON CONFLICT UPDATE? Probably via pseudo column indicating INSERT / UPDATE ? The RETURNING clause just allows us to return columns, but am unable to find a way to know 'what' happened to a given row. ​Any poin