Why isn't DECLARE CURSOR ... FOR UPDATE supported?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Why isn't DECLARE CURSOR ... FOR UPDATE supported?
Дата
Msg-id 19754.1071760814@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: Why isn't DECLARE CURSOR ... FOR UPDATE supported?  (Rod Taylor <pg@rbt.ca>)
Re: Why isn't DECLARE CURSOR ... FOR UPDATE supported?  ("Hiroshi Inoue" <inoue@tpf.co.jp>)
Список pgsql-hackers
Is there any good reason for this restriction?

regression=# begin;
BEGIN
regression=# declare c cursor for select * from tenk1 for update;
ERROR:  DECLARE CURSOR ... FOR UPDATE is not supported
DETAIL:  Cursors must be READ ONLY.

While I have not tried it, I think that simply removing this error check
in PerformCursorOpen() would allow the system to behave in a reasonable
way, ie, locking each row the first time it is fetched through the
cursor.

A recent conversation on pgsql-bugs led me to think of this as an easy
way to get the effect of "LIMIT after FOR UPDATE" --- that is, you
declare the cursor as above and then FETCH just one row, or however many
you need.  With the current implementation in which LIMIT acts before
FOR UPDATE, it's possible the "SELECT ... LIMIT 1 FOR UPDATE" will
return no row, even though lockable rows exist in the table.
        regards, tom lane


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

Предыдущее
От: david@fetter.org (David Fetter)
Дата:
Сообщение: Re: Dates BC.
Следующее
От: Doug McNaught
Дата:
Сообщение: Re: plpgsql Integer Concat To String