Details
-
New Feature
-
Status: Open (View Workflow)
-
Critical
-
Resolution: Unresolved
-
None
-
Q2/2025 Development
Description
Add support for autonomous blocks in stored routines.
This would allow a stored routine marked with autonomous_transaction to commit
and rollback it's own work, independent of the work of the caller.
Oracle defines this as "PRAGMA AUTONOMOUS_TRANSACTION":
https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/autonotransaction_pragma.htm
This pragma can be applied to:
- Top-level (not nested) anonymous PL/SQL blocks
- Local, standalone, and packaged functions and procedures
- Methods of a SQL object type
- Database triggers
For the moment a workaround is to use the Aria storage engine for tables that should be persistent against ROLLBACK. Aria tables are never rollbacked
(except if the server crashes in the middle of a query).
The suggested implementation is to run the autonomous routine with it's own THD (== user), like it would be a new independent connection.
An example of an Oracle stored function using AUTONOMOUS_TRANSACTION:
DROP TABLE employees; |
DROP FUNCTION raise_salary; |
CREATE TABLE employees ( |
employee_id INT NOT NULL PRIMARY KEY, |
salary INT NOT NULL |
);
|
INSERT INTO employees VALUES (1, 100); |
CREATE FUNCTION raise_salary |
(emp_id NUMBER,
|
sal_raise NUMBER) RETURN NUMBER |
IS
|
PRAGMA AUTONOMOUS_TRANSACTION;
|
new_sal NUMBER(8,2);
|
BEGIN
|
UPDATE employees |
SET salary= salary + sal_raise |
WHERE employee_id = emp_id; |
COMMIT; |
SELECT salary INTO new_sal FROM employees WHERE employee_id = emp_id; |
RETURN new_sal; |
END raise_salary; |
/
|
SELECT raise_salary(1, 10) FROM DUAL; |
RAISE_SALARY(1,10)
|
------------------
|
110
|
Attachments
Issue Links
- is duplicated by
-
MDEV-9917 autonomous transaction
-
- Closed
-
- is part of
-
MDEV-35973 Oracle Compatibility Project 1 for 2025
-
- In Progress
-
Activity
Field | Original Value | New Value |
---|---|---|
Epic Link | MDEV-10137 [ 56868 ] |
Summary | Autonomous blocks | Autonomous transactions |
Description |
Add support for autonomous blocks in stored procedures.
This would allow a stored procedure marked with autonomous_transaction to commit and rollback it's own work, independent of the work of the calling procedure. Here is a reference how Oracle defines this: https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/autonotransaction_pragma.htm For the moment a workaround is to use the Aria storage engine for tables that should be persistent against ROLLBACK. Aria tables are never rollbacked (except if the server crashes in the middle of a query). The suggested implementation is to run the autonomous procedure with it's own THD (== user), like it would be a new independent connection. |
Add support for autonomous blocks in stored procedures.
This would allow a stored procedure marked with autonomous_transaction to commit and rollback it's own work, independent of the work of the calling procedure. Here is a reference how Oracle defines this: https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/autonotransaction_pragma.htm This pragma can be applied to: - Top-level (not nested) anonymous PL/SQL blocks - Local, standalone, and packaged functions and procedures - Methods of a SQL object type - Database triggers For the moment a workaround is to use the Aria storage engine for tables that should be persistent against ROLLBACK. Aria tables are never rollbacked (except if the server crashes in the middle of a query). The suggested implementation is to run the autonomous procedure with it's own THD (== user), like it would be a new independent connection. |
Description |
Add support for autonomous blocks in stored procedures.
This would allow a stored procedure marked with autonomous_transaction to commit and rollback it's own work, independent of the work of the calling procedure. Here is a reference how Oracle defines this: https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/autonotransaction_pragma.htm This pragma can be applied to: - Top-level (not nested) anonymous PL/SQL blocks - Local, standalone, and packaged functions and procedures - Methods of a SQL object type - Database triggers For the moment a workaround is to use the Aria storage engine for tables that should be persistent against ROLLBACK. Aria tables are never rollbacked (except if the server crashes in the middle of a query). The suggested implementation is to run the autonomous procedure with it's own THD (== user), like it would be a new independent connection. |
Add support for autonomous blocks in stored procedures.
This would allow a stored procedure marked with autonomous_transaction to commit and rollback it's own work, independent of the work of the calling procedure. Oracle defines this as "PRAGMA AUTONOMOUS_TRANSACTION": https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/autonotransaction_pragma.htm This pragma can be applied to: - Top-level (not nested) anonymous PL/SQL blocks - Local, standalone, and packaged functions and procedures - Methods of a SQL object type - Database triggers For the moment a workaround is to use the Aria storage engine for tables that should be persistent against ROLLBACK. Aria tables are never rollbacked (except if the server crashes in the middle of a query). The suggested implementation is to run the autonomous procedure with it's own THD (== user), like it would be a new independent connection. An example of an Oracle stored procedure using AUTONOMOUS_TRANSACTION: {code:sql} DROP TABLE employees; DROP FUNCTION raise_salary; CREATE TABLE employees ( employee_id INT NOT NULL PRIMARY KEY, salary INT NOT NULL ); INSERT INTO employees VALUES (1, 100); CREATE FUNCTION raise_salary (emp_id NUMBER, sal_raise NUMBER) RETURN NUMBER IS PRAGMA AUTONOMOUS_TRANSACTION; new_sal NUMBER(8,2); BEGIN UPDATE employees SET salary= salary + sal_raise WHERE employee_id = emp_id; COMMIT; SELECT salary INTO new_sal FROM employees WHERE employee_id = emp_id; RETURN new_sal; END raise_salary; / SELECT raise_salary(1, 10) FROM DUAL; {code} {noformat} RAISE_SALARY(1,10) ------------------ 110 {noformat} |
Description |
Add support for autonomous blocks in stored procedures.
This would allow a stored procedure marked with autonomous_transaction to commit and rollback it's own work, independent of the work of the calling procedure. Oracle defines this as "PRAGMA AUTONOMOUS_TRANSACTION": https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/autonotransaction_pragma.htm This pragma can be applied to: - Top-level (not nested) anonymous PL/SQL blocks - Local, standalone, and packaged functions and procedures - Methods of a SQL object type - Database triggers For the moment a workaround is to use the Aria storage engine for tables that should be persistent against ROLLBACK. Aria tables are never rollbacked (except if the server crashes in the middle of a query). The suggested implementation is to run the autonomous procedure with it's own THD (== user), like it would be a new independent connection. An example of an Oracle stored procedure using AUTONOMOUS_TRANSACTION: {code:sql} DROP TABLE employees; DROP FUNCTION raise_salary; CREATE TABLE employees ( employee_id INT NOT NULL PRIMARY KEY, salary INT NOT NULL ); INSERT INTO employees VALUES (1, 100); CREATE FUNCTION raise_salary (emp_id NUMBER, sal_raise NUMBER) RETURN NUMBER IS PRAGMA AUTONOMOUS_TRANSACTION; new_sal NUMBER(8,2); BEGIN UPDATE employees SET salary= salary + sal_raise WHERE employee_id = emp_id; COMMIT; SELECT salary INTO new_sal FROM employees WHERE employee_id = emp_id; RETURN new_sal; END raise_salary; / SELECT raise_salary(1, 10) FROM DUAL; {code} {noformat} RAISE_SALARY(1,10) ------------------ 110 {noformat} |
Add support for autonomous blocks in stored routines.
This would allow a stored routine marked with autonomous_transaction to commit and rollback it's own work, independent of the work of the caller. Oracle defines this as "PRAGMA AUTONOMOUS_TRANSACTION": https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/autonotransaction_pragma.htm This pragma can be applied to: - Top-level (not nested) anonymous PL/SQL blocks - Local, standalone, and packaged functions and procedures - Methods of a SQL object type - Database triggers For the moment a workaround is to use the Aria storage engine for tables that should be persistent against ROLLBACK. Aria tables are never rollbacked (except if the server crashes in the middle of a query). The suggested implementation is to run the autonomous routine with it's own THD (== user), like it would be a new independent connection. An example of an Oracle stored function using AUTONOMOUS_TRANSACTION: {code:sql} DROP TABLE employees; DROP FUNCTION raise_salary; CREATE TABLE employees ( employee_id INT NOT NULL PRIMARY KEY, salary INT NOT NULL ); INSERT INTO employees VALUES (1, 100); CREATE FUNCTION raise_salary (emp_id NUMBER, sal_raise NUMBER) RETURN NUMBER IS PRAGMA AUTONOMOUS_TRANSACTION; new_sal NUMBER(8,2); BEGIN UPDATE employees SET salary= salary + sal_raise WHERE employee_id = emp_id; COMMIT; SELECT salary INTO new_sal FROM employees WHERE employee_id = emp_id; RETURN new_sal; END raise_salary; / SELECT raise_salary(1, 10) FROM DUAL; {code} {noformat} RAISE_SALARY(1,10) ------------------ 110 {noformat} |
Labels | procedures | Compatibility procedures |
Epic Link | MDEV-10137 [ 56868 ] | MDEV-10872 [ 58182 ] |
Link |
This issue blocks |
Fix Version/s | 10.3 [ 22126 ] | |
Fix Version/s | 10.2 [ 14601 ] |
Labels | Compatibility procedures | Compatibility NRE-307517 procedures |
NRE Projects | NRE-307517 |
Labels | Compatibility NRE-307517 procedures | Compatibility procedures |
Link |
This issue blocks |
Fix Version/s | 10.3 [ 22126 ] |
Support case ID | not-26307 |
NRE Projects | AC-2610/DEFERRED |
Workflow | MariaDB v3 [ 75840 ] | MariaDB v4 [ 130488 ] |
Link | This issue is part of MENT-2216 [ MENT-2216 ] |
Link | This issue is part of MDEV-35973 [ MDEV-35973 ] |
Link | This issue is part of MENT-2216 [ MENT-2216 ] |
Issue Type | Task [ 3 ] | New Feature [ 2 ] |
Labels | Compatibility procedures | Compatibility Oracle procedures |
Priority | Major [ 3 ] | Critical [ 2 ] |
Priority | Critical [ 2 ] | Major [ 3 ] |
Assignee | Michael Widenius [ monty ] |
Priority | Major [ 3 ] | Minor [ 4 ] |
Fix Version/s | 12.2 [ 30146 ] |
Priority | Minor [ 4 ] | Major [ 3 ] |
Sprint | Server 12.1 dev sprint [ 793 ] |
Rank | Ranked lower |
Fix Version/s | ROADMAP [ 30157 ] | |
Fix Version/s | 12.2 [ 30146 ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
When you plan to implement this feature? This will be a great thing in oracle compatibility and app design techniques.