Обсуждение: plpgsql cursors : dynamic or static?

Поиск
Список
Период
Сортировка

plpgsql cursors : dynamic or static?

От
Ludwig Lim
Дата:
Hi:
 Are cursors in plpgsql dynamic or static?
 For example :
 ... /* some code */ FOR rec in   SELECT f1,f2               FROM table1 WHERE .... LOOP
   /* some codes that manipulate table1 */ END LOOP;
 Do the result set pointed to by the cursor remains
the same even if performed some data manipulation
inside the FOR..LOOP?

Thank you in advance,

ludwig.



__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com


Re: plpgsql cursors : dynamic or static?

От
Josh Berkus
Дата:
Ludwig,

>   Are cursors in plpgsql dynamic or static?
>
>   For example :
>
>   ... /* some code */
>   FOR rec in   SELECT f1,f2
>                FROM table1 WHERE .... LOOP
>
>     /* some codes that manipulate table1 */
>   END LOOP;

Technically speaking, that is not a cursor, even though it serves the same
purpose.

I'm pretty sure it's static, but it would be easy to test ... why don't you
give it a try?

--
-Josh BerkusAglio Database SolutionsSan Francisco



Re: plpgsql cursors : dynamic or static?

От
Tom Lane
Дата:
Josh Berkus <josh@agliodbs.com> writes:
>> Are cursors in plpgsql dynamic or static?
>> 
>> FOR rec in   SELECT f1,f2 
>> FROM table1 WHERE .... LOOP
>> 
>> /* some codes that manipulate table1 */
>> END LOOP;

> Technically speaking, that is not a cursor, even though it serves the same 
> purpose.

> I'm pretty sure it's static, but it would be easy to test ... why don't you 
> give it a try?

The result definitely will be static in 7.3.  I'm not entirely sure
about prior releases: we used to manipulate the current-command counter
in a different way.
        regards, tom lane