Tom Lane wrote:
> Heikki Linnakangas <[EMAIL PROTECTED]> writes:
>> That would solve the problem with two updates of the same row, but not this:
>> UPDATE .. WHERE CURRENT OF...
>> FETCH RELATIVE 0
> 
>> At the moment, that returns the next row, not the one that was updated.
>> Same problem with FETCH NEXT + FETCH PRIOR after the UPDATE.
> 
> Hmm, what I'm seeing is that it returns the original (unmodified) row;
> is that what you meant to say?

No, that's not what I meant. Here's what I get:

postgres=# CREATE TABLE foo (id integer);
CREATE TABLE
postgres=# INSERT INTO foo SELECT a from generate_series(1,100) a;
INSERT 0 100
postgres=# BEGIN;
BEGIN
postgres=# DECLARE c CURSOR FOR SELECT id FROM foo FOR UPDATE;
DECLARE CURSOR
postgres=# FETCH 2 FROM c;
 id
----
  1
  2
(2 rows)

postgres=# UPDATE foo set ID=20 WHERE CURRENT OF c;
UPDATE 1
postgres=# FETCH RELATIVE 0 FROM c;
 id
----
  3
(1 row)

I was expecting to get 20.

I do get the original unmodified tuple (2) if I leave out the FOR UPDATE.

-- 
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to