Re: INSERT...ON DUPLICATE KEY LOCK FOR UPDATE

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: INSERT...ON DUPLICATE KEY LOCK FOR UPDATE
Date: 2014-01-16 07:02:20
Message-ID: CAM3SWZTU=3NRSepRRU6HhNA_OEvay6mB7c6HiSoKebLmf=zE+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 15, 2014 at 8:23 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
> I have an idea of what I could do to fix this, but I don't have time
> to make sure that my hunch is correct.

It might just be a matter of:

@@ -186,6 +186,13 @@ ExecLockHeapTupleForUpdateSpec(EState *estate,
switch (test)
{
case HeapTupleInvisible:
+ /*
+ * Tuple may have originated from this command, in which case it's
+ * already locked
+ */
+ if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple.t_data))
&&
+ HeapTupleHeaderGetCmin(tuple.t_data) == estate->es_output_cid)
+ return true;
/* Tuple became invisible; try again */
if (IsolationUsesXactSnapshot())
ereport(ERROR,

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2014-01-16 07:11:59 Re: [PATCH] Negative Transition Aggregate Functions (WIP)
Previous Message David Rowley 2014-01-16 06:39:07 Re: [PATCH] Negative Transition Aggregate Functions (WIP)