Problem
Installing test_factory_pgtap inside a BEGIN/COMMIT transaction block causes COMMIT to fail. This breaks any install script that wraps multiple CREATE EXTENSION calls in a single transaction.
Root Cause
test_factory_pgtap creates a TEMP TABLE ... ON COMMIT DROP during extension installation. When PostgreSQL processes COMMIT, it auto-drops that temp table. However, the table is registered as owned by the extension, so PostgreSQL cannot drop it as part of the commit without removing the extension — causing the commit to fail with an error.
Minimal Reproduction
BEGIN;
CREATE EXTENSION test_factory_pgtap CASCADE;
COMMIT;
-- ERROR: cannot drop table <name> because extension test_factory_pgtap requires it
-- (or similar error preventing the commit)
Working workaround:
-- Install BEFORE the transaction block
CREATE EXTENSION test_factory_pgtap CASCADE;
BEGIN;
-- ... rest of install script ...
COMMIT;
Expected Behavior
CREATE EXTENSION test_factory_pgtap should be safe to run inside a transaction block, like any standard extension.
Fix
The extension should explicitly DROP TABLE the temp table at the end of installation rather than relying on ON COMMIT DROP. This removes the transaction-scoped lifetime dependency, making the extension safe to install inside a BEGIN/COMMIT block.
Problem
Installing
test_factory_pgtapinside aBEGIN/COMMITtransaction block causesCOMMITto fail. This breaks any install script that wraps multipleCREATE EXTENSIONcalls in a single transaction.Root Cause
test_factory_pgtapcreates aTEMP TABLE ... ON COMMIT DROPduring extension installation. When PostgreSQL processesCOMMIT, it auto-drops that temp table. However, the table is registered as owned by the extension, so PostgreSQL cannot drop it as part of the commit without removing the extension — causing the commit to fail with an error.Minimal Reproduction
Working workaround:
Expected Behavior
CREATE EXTENSION test_factory_pgtapshould be safe to run inside a transaction block, like any standard extension.Fix
The extension should explicitly
DROP TABLEthe temp table at the end of installation rather than relying onON COMMIT DROP. This removes the transaction-scoped lifetime dependency, making the extension safe to install inside aBEGIN/COMMITblock.