From: | klimych(at)tut(dot)by |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #14275: cursor's variable in pgsql doesn't respect scope |
Date: | 2016-08-03 09:53:01 |
Message-ID: | 20160803095301.1420.50016@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 14275
Logged by: Oleg Klimovich
Email address: klimych(at)tut(dot)by
PostgreSQL version: 9.5.3
Operating system: Windows 7, Windows 8, Ubuntu 14.04
Description:
DO $$
DECLARE
cur cursor for select 1; -- (1)
BEGIN
open cur; -- (2)
DECLARE
cur cursor for select 2; -- (3)
BEGIN
open cur; -- (4)
close cur; -- (5)
END;
close cur; -- (6)
end $$;
Executing of the code gives error "cursor "cur" already in use". Evedently,
PG in statement (4) refers to the variable, defined in statement (1). (and I
expect it should be variable, defined in statement (3)).
Futhermore, same error exists even across different functions:
create function func1() returns void as $$
declare
cur cursor for select 1;
BEGIN
open cur;
close cur;
end
$$
LANGUAGE 'plpgsql';
create function func2() returns void as $$
declare
cur cursor for select 1;
BEGIN
open cur;
PERFORM func1();
close cur;
end
$$
LANGUAGE 'plpgsql';
select func2();
So, cursor's variable is kind of global. I just hope it's a bug and not
"feature" (at least I haven't found mention of such behaviour in
documentation)
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2016-08-03 13:03:22 | Re: BUG #14275: cursor's variable in pgsql doesn't respect scope |
Previous Message | Kishor Hargude | 2016-08-03 07:00:20 | Re: BUG #14273: Tuple concurently updated error while creating function using async call from node js with postgresq |