Re: Update with subselect sometimes returns wrong result - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: Update with subselect sometimes returns wrong result
Date
Msg-id 20131219005808.GI11006@eldon.alvh.no-ip.org
Whole thread Raw
In response to Re: Update with subselect sometimes returns wrong result  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Update with subselect sometimes returns wrong result  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-bugs
Andres Freund escribió:
> On 2013-12-18 19:13:43 -0300, Alvaro Herrera wrote:
> > I'm not sure about the added assert that the tuple cannot possibly be
> > locked.  I fear cursors provide strange ways to access at tuples.
>
> I don't see how, the EPQ machinery should have ensured we're looking at
> the most recent version. Also, pretty fundamentally, we have to be the
> only locker, otherwise the optimization wouldn't be applicable in this
> way.

EPQ works funny with cursors in the WHERE CURRENT OF stuff; the fact
that it behaves differently in FOR UPDATE case than when there's no
locking clause makes this whole thing pretty misterious.

Anyway I think this whole optimization can be formulated more clearly if
we separate the case into its own block by checking
XidIsCurrentTransaction instead of cramming it into the XidIsInProgress
case as the original is doing; see attached.

Any ideas on possible tests for this stuff?  Nothing comes to mind that
doesn't involve pageinspect ...

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-bugs by date:

Previous
From: Andres Freund
Date:
Subject: Re: Update with subselect sometimes returns wrong result
Next
From: katsumata.tomonari@po.ntts.co.jp
Date:
Subject: BUG #8686: Standby could not restart.