cursors FOR UPDATE don't return most recent row - Mailing list pgsql-hackers

From Alvaro Herrera
Subject cursors FOR UPDATE don't return most recent row
Date
Msg-id 1327536411-sup-7848@alvh.no-ip.org
Whole thread Raw
Responses Re: cursors FOR UPDATE don't return most recent row  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
This is my test case (all in one session):

CREATE TABLE foo (     key             int PRIMARY KEY,     value   int
);

INSERT INTO foo VALUES (1, 1);
BEGIN;DECLARE foo CURSOR FOR SELECT * FROM foo FOR UPDATE;UPDATE foo SET value = 2 WHERE key = 1;UPDATE foo SET value =
3WHERE key = 1;FETCH 1 FROM foo;COMMIT; 


I expected the FETCH to return one row, with the latest data, i.e.
(1, 3), but instead it's returning empty.

If instead I run both UPDATEs in another session, then I do get

alvherre=#  FETCH 1 FROM foo; key | value
-----+-------  1 |     3
(1 fila)


Is this intended?

--
Álvaro Herrera <alvherre@alvh.no-ip.org>


pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Avoid FK validations for no-rewrite ALTER TABLE ALTER TYPE
Next
From: Fujii Masao
Date:
Subject: Re: WAL Restore process during recovery