Skip to content

Commit

Permalink
regress test - fix crash after commit/rollback inside procesure when …
Browse files Browse the repository at this point in the history
…cursor leak detection is active
  • Loading branch information
okbob committed Mar 29, 2024
1 parent ad1eced commit 75e8d5e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
11 changes: 11 additions & 0 deletions expected/plpgsql_check_active.out
Original file line number Diff line number Diff line change
Expand Up @@ -9287,3 +9287,14 @@ select * from plpgsql_check_function('fx()');
(0 rows)

drop function fx();
-- should not crash
create or replace procedure p1()
as $$
begin
commit;
end;
$$ language plpgsql;
set plpgsql_check.cursors_leaks to on;
do $$ declare c cursor for select 1; begin open c; call p1(); end $$;
set plpgsql_check.cursors_leaks to default;
drop procedure p1;
11 changes: 11 additions & 0 deletions expected/plpgsql_check_active_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -9289,3 +9289,14 @@ select * from plpgsql_check_function('fx()');
(0 rows)

drop function fx();
-- should not crash
create or replace procedure p1()
as $$
begin
commit;
end;
$$ language plpgsql;
set plpgsql_check.cursors_leaks to on;
do $$ declare c cursor for select 1; begin open c; call p1(); end $$;
set plpgsql_check.cursors_leaks to default;
drop procedure p1;
11 changes: 11 additions & 0 deletions expected/plpgsql_check_active_2.out
Original file line number Diff line number Diff line change
Expand Up @@ -9286,3 +9286,14 @@ select * from plpgsql_check_function('fx()');
(0 rows)

drop function fx();
-- should not crash
create or replace procedure p1()
as $$
begin
commit;
end;
$$ language plpgsql;
set plpgsql_check.cursors_leaks to on;
do $$ declare c cursor for select 1; begin open c; call p1(); end $$;
set plpgsql_check.cursors_leaks to default;
drop procedure p1;
16 changes: 16 additions & 0 deletions sql/plpgsql_check_active.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5515,3 +5515,19 @@ $$ language plpgsql;
select * from plpgsql_check_function('fx()');

drop function fx();

-- should not crash
create or replace procedure p1()
as $$
begin
commit;
end;
$$ language plpgsql;

set plpgsql_check.cursors_leaks to on;

do $$ declare c cursor for select 1; begin open c; call p1(); end $$;

set plpgsql_check.cursors_leaks to default;

drop procedure p1;

0 comments on commit 75e8d5e

Please sign in to comment.