From 75e8d5ec27ee9f366992f25d13ab75620d95d741 Mon Sep 17 00:00:00 2001 From: "okbob@github.com" Date: Fri, 29 Mar 2024 21:55:40 +0100 Subject: [PATCH] regress test - fix crash after commit/rollback inside procesure when cursor leak detection is active --- expected/plpgsql_check_active.out | 11 +++++++++++ expected/plpgsql_check_active_1.out | 11 +++++++++++ expected/plpgsql_check_active_2.out | 11 +++++++++++ sql/plpgsql_check_active.sql | 16 ++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/expected/plpgsql_check_active.out b/expected/plpgsql_check_active.out index 53e8351..449808c 100644 --- a/expected/plpgsql_check_active.out +++ b/expected/plpgsql_check_active.out @@ -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; diff --git a/expected/plpgsql_check_active_1.out b/expected/plpgsql_check_active_1.out index de678a1..c62b4db 100644 --- a/expected/plpgsql_check_active_1.out +++ b/expected/plpgsql_check_active_1.out @@ -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; diff --git a/expected/plpgsql_check_active_2.out b/expected/plpgsql_check_active_2.out index 7d4c724..3407825 100644 --- a/expected/plpgsql_check_active_2.out +++ b/expected/plpgsql_check_active_2.out @@ -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; diff --git a/sql/plpgsql_check_active.sql b/sql/plpgsql_check_active.sql index 563e9ef..92d06b3 100644 --- a/sql/plpgsql_check_active.sql +++ b/sql/plpgsql_check_active.sql @@ -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;