Inside some of my triggers, I'm trying to detect if I'm at a top-level user- requested operation, or nested inside other triggers. (I've done this for some REDO triggers before, here I'm doing it for validation reasons -- there are things I don't want a user doing directly, but don't mind cascading from other tables.)
I'm using an autonomous transaction from inside my trigger to check mon$call_stack to see how deeply-nested my current statement is (active statement of current transaction). I can see my own trigger, and I can see other custom triggers if I'm nested in those, but it seems I can't see implied triggers that are part of FK- cascade rules. Not even if I remove the restriction on mon$object_type = 2 /* triggers only */ (I had hoped maybe they would show up as a 4, validation, instead?). Yet if I throw an exception inside that custom trigger, the stack-trace I get back (visible in flamerobin) DOES show the presence of CHECK_1234 around my trigger. It's not like the cascade-trigger ended, then caused my trigger to fire - - it's very much still active during the execution of my trigger. Am I crazy? Do the implied triggers that handle cascades not show up in mon$call_stack? Only user-defined triggers and procedures? (Firebird 2.5.2 stock, x64, on win64.) -Philip
