Re: INSERT ... ON CONFLICT UPDATE/IGNORE 4.0

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, hlinnaka <hlinnaka(at)iki(dot)fi>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: INSERT ... ON CONFLICT UPDATE/IGNORE 4.0
Date: 2015-05-05 02:13:27
Message-ID: CAM3SWZRdVttc-_a=XH0pisej_830FLmhM_eEcOC2-Q2TahkZ+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-hackers

On Fri, May 1, 2015 at 7:49 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
>> seems weird for both the BEFORE INSERT and BEFORE UPDATE triggers to
>> get a crack at the same tuple, so your way might be better after all.
>> But on the other hand, the BEFORE INSERT trigger might have had side
>> effects, so we can't just pretend it didn't happen.
>
> Well, I think it's pretty unavoidable to fire both. On that part I think
> were pretty lengthy discussions a year or so back.
>
>> One idea is to decide that an INSERT with an ON CONFLICT UPDATE
>> handler is still an INSERT. Period. So the INSERT triggers run, the
>> UPDATE triggers don't, and that's it.
>
> I think that'd be much worse.

A question has come up about RTEs, column-level privileges and BEFORE
triggers. This commit message gives a summary:

https://github.com/petergeoghegan/postgres/commit/87b9f27055e81d1396db3d10a5e9d01c52603783

I'm pretty sure that I'll have to require SELECT privileges of the
EXCLUDED.* RTE too (i.e. revert that commit, and probably document the
new behavior of requiring that). I think it's worth getting feedback
on this point, though, since it is a somewhat subtle issue.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Andres Freund 2015-05-05 04:00:09 Re: INSERT ... ON CONFLICT UPDATE/IGNORE 4.0
Previous Message Igor Neyman 2015-05-04 18:25:53 Re: pg_dump and pg_restore with multiple streams does Not seem to improve overall times

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2015-05-05 02:24:33 Re: BRIN range operator class
Previous Message Stefan Keller 2015-05-05 01:40:11 Re: BRIN range operator class