Skip to content

Commit

Permalink
false alarm unclosed cursors test
Browse files Browse the repository at this point in the history
  • Loading branch information
okbob committed Jan 12, 2024
1 parent 18886e8 commit 7068958
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
38 changes: 38 additions & 0 deletions expected/plpgsql_check_active.out
Original file line number Diff line number Diff line change
Expand Up @@ -9219,3 +9219,41 @@ select * from plpgsql_check_function('fx()');
(0 rows)

drop function fx();
-- should not to raise warning
do $$
declare
c cursor for select * from generate_series(1,10);
t int;
begin
for i in 1..2
loop
open c;
loop
fetch c into t;
exit when not found;
raise notice '%', t;
end loop;
close c;
end loop;
end;
$$;
NOTICE: 1
NOTICE: 2
NOTICE: 3
NOTICE: 4
NOTICE: 5
NOTICE: 6
NOTICE: 7
NOTICE: 8
NOTICE: 9
NOTICE: 10
NOTICE: 1
NOTICE: 2
NOTICE: 3
NOTICE: 4
NOTICE: 5
NOTICE: 6
NOTICE: 7
NOTICE: 8
NOTICE: 9
NOTICE: 10
38 changes: 38 additions & 0 deletions expected/plpgsql_check_active_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -9222,3 +9222,41 @@ select * from plpgsql_check_function('fx()');
(0 rows)

drop function fx();
-- should not to raise warning
do $$
declare
c cursor for select * from generate_series(1,10);
t int;
begin
for i in 1..2
loop
open c;
loop
fetch c into t;
exit when not found;
raise notice '%', t;
end loop;
close c;
end loop;
end;
$$;
NOTICE: 1
NOTICE: 2
NOTICE: 3
NOTICE: 4
NOTICE: 5
NOTICE: 6
NOTICE: 7
NOTICE: 8
NOTICE: 9
NOTICE: 10
NOTICE: 1
NOTICE: 2
NOTICE: 3
NOTICE: 4
NOTICE: 5
NOTICE: 6
NOTICE: 7
NOTICE: 8
NOTICE: 9
NOTICE: 10
19 changes: 19 additions & 0 deletions sql/plpgsql_check_active.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5469,3 +5469,22 @@ $$ language plpgsql;
select * from plpgsql_check_function('fx()');

drop function fx();

-- should not to raise warning
do $$
declare
c cursor for select * from generate_series(1,10);
t int;
begin
for i in 1..2
loop
open c;
loop
fetch c into t;
exit when not found;
raise notice '%', t;
end loop;
close c;
end loop;
end;
$$;

0 comments on commit 7068958

Please sign in to comment.