pub struct BoundTrigger {
pub name: Vec<u8>,
pub table: Vec<u8>,
pub time: TriggerTime,
pub when: Option<BoundExpr>,
pub body: Vec<BoundTriggerStatement>,
pub foreign_key: bool,
pub self_referencing: bool,
}Expand description
A trigger, bound against the write that fires it.
It is bound per statement rather than once per schema because the body’s FROM terms take statement-wide source numbers, and those only exist relative to the statement they are inlined into.
Fields§
§name: Vec<u8>The trigger’s name, for the diagnostic when its body fails.
table: Vec<u8>The folded name of the table it is attached to.
Read by the executor to decide whether a body statement is writing the
trigger’s own table, which is what PRAGMA recursive_triggers is
about: with it on, such a write fires this trigger again.
time: TriggerTimeWhether it fires before or after the row is written.
when: Option<BoundExpr>The WHEN guard, when one was written.
body: Vec<BoundTriggerStatement>The body statements, in written order.
foreign_key: boolWhether the binder synthesised this from a REFERENCES clause rather
than reading it from a CREATE TRIGGER.
Read by DROP TABLE (task-1979, F6). Dropping a table with foreign
keys on runs an implicit DELETE FROM first, so the keys that reference
it are enforced - and SQLite’s rule is that the implicit delete fires no
triggers of its own while still performing every foreign key action. A
delete bound for that purpose keeps the triggers this flag marks and
drops the rest.
self_referencing: boolWhether the foreign key this enforces has one table as both its child and its parent.
Also read by DROP TABLE (task-1979, F6). The implicit delete keeps
the foreign key triggers and drops this one, because emptying a table
cannot leave a row of that same table pointing at nothing - see
ForeignKeyTrigger::self_referencing, which is where the value comes
from. Always false on a trigger the schema wrote.