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

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>
Subject: Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Date: 2014-09-02 06:37:04
Message-ID: CAM3SWZR+daV92HH0FVSVz18V_JF8p2VcpcbsVpscvwF3TWriXw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 28, 2014 at 8:05 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
> I realized that I missed a few cases here. For one thing, the posted
> patch fails to arrange for the UPDATE post-parse-analysis tree
> representation to go through the rewriter stage (on the theory that
> user-defined rules shouldn't be able to separately affect the
> auxiliary UPDATE query tree), but rewriting is at least necessary so
> that rewriteTargetListIU() can expand a "SET val = DEFAULT"
> targetlist, as well as normalize the ordering of the UPDATE's tlist.
> Separately, the patch fails to defend against certain queries that
> ought to be disallowed, where a subselect is specified with a subquery
> expression in the auxiliary UPDATE's WHERE clause.

Attached revision fixes all of these issues. I've added regression
tests for each bug, too, although all changes are rebased into my
original commits.

I decided to explicitly rely on a simpler approach to VACUUM
interlocking. I no longer bother holding on to a buffer pin for a
period longer than the period that associated "value locks" are held,
which was something I talked about at the start of this thread. There
is a note on this added to the nbtree README, just after the master
branch's current remarks on B-Tree VACUUM interlocking.

I've also pushed the responsibility for supporting this new feature on
foreign tables onto FDWs themselves. The only writable FDW we
currently ship, postgres_fdw, lacks support for the new feature, but
this can be revisited in due course. My impression is that the task of
adding support is not quite a straightforward matter of adding a bit
more deparsing logic, but also isn't significantly more difficult than
that.

--
Peter Geoghegan

Attachment Content-Type Size
0001-Make-UPDATE-privileges-distinct-from-INSERT-privileg.patch.gz application/x-gzip 4.8 KB
0004-Internal-documentation-for-INSERT-.-ON-CONFLICT-UPDA.patch.gz application/x-gzip 6.9 KB
0003-Tests-for-INSERT-.-ON-CONFLICT-UPDATE-IGNORE.patch.gz application/x-gzip 7.0 KB
0002-Support-INSERT-.-ON-CONFLICT-UPDATE-IGNORE.patch.gz application/x-gzip 40.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2014-09-02 06:52:03 Re: [REVIEW] Re: Compression of full-page-writes
Previous Message Heikki Linnakangas 2014-09-02 06:26:36 Re: PL/pgSQL 2