diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index d500d0fb37..b9689e8eef 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -959,7 +959,15 @@ void Trigger::release(thread_db* tdbb) extTrigger = NULL; } - if (sysTrigger || !statement || statement->isActive() || releaseInProgress) + // dimitr: We should never release triggers created by MET_parse_sys_trigger(). + // System triggers do have BLR, but it's not stored inside the trigger object. + // However, triggers backing RI constraints are also marked as system, + // but they are loaded in a regular way and their BLR is present here. + // This is why we cannot simply check for sysTrigger, sigh. + + const bool sysTableTrigger = (blr.isEmpty() && engine.isEmpty()); + + if (sysTableTrigger || !statement || statement->isActive() || releaseInProgress) return; AutoSetRestore autoProgressFlag(&releaseInProgress, true);