Re: Update with subselect sometimes returns wrong result

From: Oliver Seemann <oseemann(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Update with subselect sometimes returns wrong result
Date: 2013-12-02 21:55:30
Message-ID: CANCipfqjL0hcz+3udLumjHinYgSMU7jK93upoZx-dqkYYSEJRw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

2013/12/1 Andres Freund <andres(at)2ndquadrant(dot)com>:
> To get rid of that ambiguity, I suggest rewriting the query to look
> like:
> WITH locked_row AS (
> SELECT id FROM t1 LIMIT 1 FOR UPDATE
> )
> UPDATE t1 SET id = t1.id
> FROM (SELECT * FROM locked_row) locked
> WHERE t1.id = locked.id
> RETURNING t1.id;

Thanks for looking into this and even providing a workaround!

The patch you posted previously is incomplete, right? Because I can
still trigger the problem with the patch applied on top of git master.
(I use autovacuum_naptime = 1s to reliably trigger within 1-5 seconds).

Oliver

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2013-12-02 22:41:10 Re: Update with subselect sometimes returns wrong result
Previous Message Peter Eisentraut 2013-12-02 21:52:12 Re: Fwd: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist