Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: add package test and meson.build entry for autonomous transactions
- Add Test 21: autonomous transaction in package procedure
- Add pl_autonomous.c to meson.build for Meson build support
  • Loading branch information
rophy committed Dec 5, 2025
commit 48c46fcba84be2e3399500abc4384894de04e17b
27 changes: 27 additions & 0 deletions src/pl/plisql/src/expected/plisql_autonomous.out
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,31 @@ SELECT id, msg FROM autonomous_test WHERE id = 55 ORDER BY id;
55 | boolean: false
(2 rows)

--
-- Test 21: Autonomous transaction in package procedure
-- Tests that PRAGMA AUTONOMOUS_TRANSACTION works inside package bodies
--
CREATE OR REPLACE PACKAGE test_pkg AUTHID DEFINER AS
PROCEDURE pkg_test_with_params(p_id INT, p_msg TEXT);
END;
/
CREATE OR REPLACE PACKAGE BODY test_pkg AS
PROCEDURE pkg_test_with_params(p_id INT, p_msg TEXT) AS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO autonomous_test VALUES (p_id, p_msg, 'committed');
END pkg_test_with_params;
END test_pkg;
/
COMMIT;
WARNING: there is no transaction in progress
CALL test_pkg.pkg_test_with_params(76, 'package procedure test');
SELECT id, msg FROM autonomous_test WHERE id = 76;
id | msg
----+------------------------
76 | package procedure test
(1 row)

--
-- Summary: Show all test results
--
Expand Down Expand Up @@ -536,4 +561,6 @@ DROP FUNCTION outer_function(INT);
DROP FUNCTION test_function_numeric(NUMERIC);
DROP FUNCTION test_function_date(DATE, INT);
DROP FUNCTION test_function_boolean(INT);
DROP PACKAGE BODY test_pkg;
DROP PACKAGE test_pkg;
DROP TABLE autonomous_test;
1 change: 1 addition & 0 deletions src/pl/plisql/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plisql_sources = files(
'pl_subproc_function.c',
'pl_package.c',
'pl_exception_type.c',
'pl_autonomous.c',
)

pl_gram = custom_target('gram',
Expand Down
25 changes: 25 additions & 0 deletions src/pl/plisql/src/sql/plisql_autonomous.sql
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,29 @@ SELECT test_function_boolean(75) AS bool_true_result;
SELECT test_function_boolean(25) AS bool_false_result;
SELECT id, msg FROM autonomous_test WHERE id = 55 ORDER BY id;

Comment thread
rophy marked this conversation as resolved.
--
-- Test 21: Autonomous transaction in package procedure
-- Tests that PRAGMA AUTONOMOUS_TRANSACTION works inside package bodies
--
CREATE OR REPLACE PACKAGE test_pkg AUTHID DEFINER AS
PROCEDURE pkg_test_with_params(p_id INT, p_msg TEXT);
END;
/

CREATE OR REPLACE PACKAGE BODY test_pkg AS
PROCEDURE pkg_test_with_params(p_id INT, p_msg TEXT) AS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO autonomous_test VALUES (p_id, p_msg, 'committed');
END pkg_test_with_params;
END test_pkg;
/

COMMIT;

CALL test_pkg.pkg_test_with_params(76, 'package procedure test');
SELECT id, msg FROM autonomous_test WHERE id = 76;

--
-- Summary: Show all test results
--
Expand All @@ -451,4 +474,6 @@ DROP FUNCTION outer_function(INT);
DROP FUNCTION test_function_numeric(NUMERIC);
DROP FUNCTION test_function_date(DATE, INT);
DROP FUNCTION test_function_boolean(INT);
DROP PACKAGE BODY test_pkg;
DROP PACKAGE test_pkg;
DROP TABLE autonomous_test;