The following bug has been logged online:

Bug reference:      2069
Logged by:          Hubert FONGARNAND
Email address:      [EMAIL PROTECTED]
PostgreSQL version: 8.1
Operating system:   Linux
Description:        Cursors are not close outside of a function
Details: 

I've written a little test function :

CREATE OR REPLACE FUNCTION test()
  RETURNS void AS
$BODY$declare 
        c1 cursor for select * from essai;
        c1_rec record;
begin
open c1;
fetch c1 into c1_rec;
end;$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

Note that i don't close c1 after returning...
(c1 should be close automatically because it is declared inside my
function);

If i execute : 
select test();
select test();

the second select fails with :
ERROR:  cursor "c1" already in use
CONTEXTE : PL/pgSQL function "test" line 5 at open

not that if I use to distinct connection it doesn't fails... It seems that a
cursor is a "global" variable inside a "postgres" process (1 connection).

It should be a bug!

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to