From: | Heikki Linnakangas <heikki(at)enterprisedb(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Dharmendra Goyal <dharmendra(dot)goyal(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: second DML operation fails with updatable cursor |
Date: | 2007-10-24 15:51:26 |
Message-ID: | 471F69FE.5000500@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane wrote:
> Heikki Linnakangas <heikki(at)enterprisedb(dot)com> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-10-24 15:57:40 | Re: Feature Freeze date for 8.4 |
Previous Message | tomas | 2007-10-24 15:50:01 | Re: Feature Freeze date for 8.4 |