diff --git a/src/jrd/exe.cpp b/src/jrd/exe.cpp index 7fef5d51b9..825b29aa41 100644 --- a/src/jrd/exe.cpp +++ b/src/jrd/exe.cpp @@ -1289,7 +1289,7 @@ void EXE_execute_triggers(thread_db* tdbb, * if any blow up. * **************************************/ - if (!*triggers) + if (!*triggers || (*triggers)->isEmpty()) return; SET_TDBB(tdbb); @@ -1297,7 +1297,7 @@ void EXE_execute_triggers(thread_db* tdbb, Request* const request = tdbb->getRequest(); jrd_tra* const transaction = request ? request->req_transaction : tdbb->getTransaction(); - TrigVector* vector = *triggers; + RefPtr vector(*triggers); Record* const old_rec = old_rpb ? old_rpb->rpb_record : NULL; Record* const new_rec = new_rpb ? new_rpb->rpb_record : NULL; @@ -1422,15 +1422,9 @@ void EXE_execute_triggers(thread_db* tdbb, trigger = NULL; } - - if (vector != *triggers) - MET_release_triggers(tdbb, &vector, true); } catch (const Exception& ex) { - if (vector != *triggers) - MET_release_triggers(tdbb, &vector, true); - if (trigger) { EXE_unwind(tdbb, trigger); diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 3a078907f9..6b81cbb5e2 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -9858,6 +9858,8 @@ void TrigVector::release() void TrigVector::release(thread_db* tdbb) { + fb_assert(useCount.value() > 0); + if (--useCount == 0) { decompile(tdbb); diff --git a/src/jrd/met.epp b/src/jrd/met.epp index 252775860a..0f3bae45b8 100644 --- a/src/jrd/met.epp +++ b/src/jrd/met.epp @@ -1883,6 +1883,7 @@ void MET_load_ddl_triggers(thread_db* tdbb) attachment->att_ddl_triggers = FB_NEW_POOL(*attachment->att_pool) TrigVector(*attachment->att_pool); + attachment->att_ddl_triggers->addRef(); AutoRequest trigger_request;