pub struct ForeignKeyTrigger {
pub is_check: bool,
pub deferred: bool,
pub trigger: Option<TriggerInfo>,
pub fault: Vec<u8>,
pub self_referencing: bool,
}Expand description
One trigger a foreign key implies, or the reason there is not one.
Fields§
§is_check: boolWhether it refuses a write rather than repairing one.
Only a check can be deferred. An action is what the constraint does, and doing it at commit time instead would leave the rows in between visible to the statements that come after.
deferred: boolWhether the key it enforces was declared INITIALLY DEFERRED.
trigger: Option<TriggerInfo>The trigger, or None when the key cannot be enforced at all.
fault: Vec<u8>Why it cannot be, when it cannot.
A key whose parent table is missing, or whose parent columns are not a key of the parent, is legal to declare: SQLite reports it when something writes, not when the schema is read, so that a schema can be loaded in any order. The message is kept here and reported then.
self_referencing: boolWhether the key’s child table and its parent table are the same table.
Read by DROP TABLE’s implicit delete (task-1979, F6). That delete
removes every row of one table, so a key whose child is that same table
cannot be violated once the statement has finished - the rows that would
be left pointing at nothing are themselves gone. SQLite reaches the same
answer a different way: its immediate foreign keys are a counter checked
at the end of the statement, so the violation deleting the first row
creates is cancelled by deleting the row that made it.