Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Anssi Kääriäinen <anssi(dot)kaariainen(at)thl(dot)fi>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Josh Berkus <josh(at)agliodbs(dot)com>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Craig Ringer <craig(at)2ndquadrant(dot)com>
Subject: Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Date: 2014-11-20 22:44:11
Message-ID: CAM3SWZR-CYxDzG9hw6uLXm263WGzL6sqJhPFxKNj-hfH+PK6Qg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 20, 2014 at 1:42 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
> Would you be happy to just know that certain
> rows were either inserted or updated in the context of an UPSERT (and
> not cancelled by a BEFORE ROW INSERT or UPDATE trigger returning
> NULL)

Of course, having the WHERE clause in the auxiliary UPDATE not pass
would also be cause to *not* return/project the not-processed row/slot
(in a world where we do something with RETURNING in respect of rows
actually processed by the auxiliary UPDATE). I mean, you're seeing the
final version of the row when RETURNING with an UPDATE, and if the
UPDATE is never evaluated, then the would-be final version (which is
generally based on the TARGET tuple and EXLCUDED tuple, as processed
by the UPDATE) never exists, and so clearly cannot be projected by
RETURNING.

This explanation a tiny bit misleading, because the rows/slots not
affected by the UPDATE (or INSERT) are still *locked*, even when the
UPDATE's WHERE clause does not pass - they have been processed to the
extent that they were locked. This is also true of postgres_fdw in
certain situations, but it seems like a very minor issue.
--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-11-20 23:03:25 Re: 9.5: Better memory accounting, towards memory-bounded HashAgg
Previous Message Andres Freund 2014-11-20 22:03:41 Re: superuser() shortcuts