BUG #2069: Cursors are not close outside of a function - Mailing list pgsql-bugs

From Hubert FONGARNAND
Subject BUG #2069: Cursors are not close outside of a function
Date
Msg-id 20051124143836.CFCB0F0BC3@svr2.postgresql.org
Whole thread Raw
Responses Re: BUG #2069: Cursors are not close outside of a function  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: BUG #2069: Cursors are not close outside of a function  (Jaime Casanova <systemguards@gmail.com>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      2069
Logged by:          Hubert FONGARNAND
Email address:      h.fongarnand@fiducial.fr
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!

pgsql-bugs by date:

Previous
From: mattias
Date:
Subject: Re: BUG #2042: Installation failed
Next
From: "Jan Jockusch"
Date:
Subject: BUG #2070: Encoding dependent error in comparison operators