diff --git a/doc/sql.extensions/README.db_triggers.txt b/doc/sql.extensions/README.db_triggers.txt index e2336dae4d..79bfeb512a 100644 --- a/doc/sql.extensions/README.db_triggers.txt +++ b/doc/sql.extensions/README.db_triggers.txt @@ -59,7 +59,9 @@ exceptions are returned to the client and the transaction is rolled-back. - TRANSACTION COMMIT Triggers are fired in the committing transaction - uncaught exceptions rollback the triggers savepoint, the commit command is aborted and the -exception is returned to the client +exception is returned to the client. + Note: for two-phase transactions the triggers are fired in "prepare" +and not in commit. - TRANSACTION ROLLBACK Triggers are fired in the rolling-back transaction - changes done will diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index c7948409d8..e391ceac31 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -5993,7 +5993,7 @@ static ISC_STATUS prepare(thread_db* tdbb, if (!(transaction->tra_flags & TRA_prepared)) { // run ON TRANSACTION COMMIT triggers - EXE_execute_db_triggers(tdbb, transaction, jrd_req::req_trigger_trans_commit); + run_commit_triggers(tdbb, transaction); } for (; transaction; transaction = transaction->tra_sibling) { @@ -6986,6 +6986,9 @@ static void run_commit_triggers(thread_db* tdbb, jrd_tra* transaction) **************************************/ SET_TDBB(tdbb); + if (transaction == tdbb->tdbb_database->dbb_sys_trans) + return; + // start a savepoint to rollback changes of all triggers VIO_start_save_point(tdbb, transaction); @@ -6993,6 +6996,7 @@ static void run_commit_triggers(thread_db* tdbb, jrd_tra* transaction) { // run ON TRANSACTION COMMIT triggers EXE_execute_db_triggers(tdbb, transaction, jrd_req::req_trigger_trans_commit); + VIO_verb_cleanup(tdbb, transaction); } catch (const Firebird::Exception&) {