You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WARNING: resource was not closed: plancache reference 0x...
ERROR: plancache reference 0x... is not owned by resource owner PL/iSQL simple expressions
CONTEXT: SQL statement "CALL do_commit()"
PL/iSQL function main line 8 at CALL
The root cause is that PostgreSQL does not allow COMMIT/ROLLBACK inside subtransactions (which anonymous blocks create). Oracle PL/SQL allows this freely.
Logged: Step 1 - before work
Logged: Step 2 - after work
main_proc completed successfully
PL/SQL procedure successfully completed.
Step to reproduce
Test 1: Standalone procedures (clean error)
CREATE OR REPLACE PROCEDURE do_commit IS
BEGINCOMMIT;
END;
/
CREATE OR REPLACE PROCEDURE main_proc IS
BEGIN
do_commit();
END;
/-- This fails with "invalid transaction termination"BEGIN
main_proc();
END;
/
Test 2: Package procedures (plancache leak)
CREATE OR REPLACE PACKAGE pkg_commit_test IS
PROCEDURE do_commit;
PROCEDURE main;
END;
/
CREATE OR REPLACE PACKAGE BODY pkg_commit_test IS
PROCEDURE do_commit IS
BEGINCOMMIT;
END;
PROCEDURE main IS
BEGIN
do_commit();
END;
END;
/-- This fails with plancache resource leakBEGINpkg_commit_test.main();
END;
/
Additional context that can be helpful for identifying the problem
PostgreSQL limitation - PostgreSQL does not allow COMMIT/ROLLBACK inside subtransactions. Anonymous blocks (BEGIN...END;) create subtransactions, so any nested procedure call containing COMMIT fails.
Oracle compatibility gap - Oracle PL/SQL allows COMMIT inside nested calls freely. This is a common pattern for:
Autonomous logging procedures
Partial commits during long-running processes
Error handling with transaction control
Package vs standalone difference - Standalone procedures get a clean "invalid transaction termination" error, but package procedures cause a plancache resource leak which is a bug in error handling.
Related feature - The PRAGMA AUTONOMOUS_TRANSACTION (PR PRAGMA AUTONOMOUS_TRANSACTION Implementation #986) would provide a workaround by allowing procedures to run in independent transactions, similar to Oracle's autonomous transactions.
Inline COMMIT works - Placing COMMIT directly in the anonymous block (not via nested call) works without error, confirming the issue is specific to nested calls.
Bug Report
IvorySQL Version
master
OS Version (uname -a)
Linux 6.8.0-87-generic #88-Ubuntu SMP PREEMPT_DYNAMIC x86_64 GNU/Linux
Configuration options (config.status --config)
Current Behavior
There are two related issues when calling a procedure containing
COMMITfrom within a PL/iSQL anonymous block:Issue 1: Standalone procedures - "invalid transaction termination" error:
Issue 2: Package procedures - plancache resource leak (more severe):
The root cause is that PostgreSQL does not allow
COMMIT/ROLLBACKinside subtransactions (which anonymous blocks create). Oracle PL/SQL allows this freely.Expected behavior/code
Oracle 23c allows
COMMITinside nested procedure calls from anonymous blocks:Step to reproduce
Test 1: Standalone procedures (clean error)
Test 2: Package procedures (plancache leak)
Additional context that can be helpful for identifying the problem
PostgreSQL limitation - PostgreSQL does not allow
COMMIT/ROLLBACKinside subtransactions. Anonymous blocks (BEGIN...END;) create subtransactions, so any nested procedure call containingCOMMITfails.Oracle compatibility gap - Oracle PL/SQL allows
COMMITinside nested calls freely. This is a common pattern for:Package vs standalone difference - Standalone procedures get a clean "invalid transaction termination" error, but package procedures cause a plancache resource leak which is a bug in error handling.
Related feature - The
PRAGMA AUTONOMOUS_TRANSACTION(PR PRAGMA AUTONOMOUS_TRANSACTION Implementation #986) would provide a workaround by allowing procedures to run in independent transactions, similar to Oracle's autonomous transactions.Inline COMMIT works - Placing
COMMITdirectly in the anonymous block (not via nested call) works without error, confirming the issue is specific to nested calls.