Re: second DML operation fails with updatable cursor

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: second DML operation fails with updatable cursor
Дата
Msg-id 471F69FE.5000500@enterprisedb.com
обсуждение исходный текст
Ответ на Re: second DML operation fails with updatable cursor  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: second DML operation fails with updatable cursor  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:
> Heikki Linnakangas <heikki@enterprisedb.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: tomas@tuxteam.de
Дата:
Сообщение: Re: Feature Freeze date for 8.4
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Feature Freeze date for 8.4