use crate::{ast::*, common::symbol::Symbol};
#[derive(Debug, Clone, PartialEq)]
pub struct CreateTriggerStmt {
pub name: Symbol,
pub if_not_exists: bool,
pub or_replace: bool,
pub constraint: bool,
pub timing: TriggerTiming,
pub events: Vec<TriggerEvent>,
pub table: ObjectName,
pub from_table: Option<ObjectName>,
pub deferrable: Option<bool>,
pub initially: Option<TriggerInitially>,
pub referencing: Vec<TriggerReferencing>,
pub level: TriggerLevel,
pub condition: Option<Expr>,
pub function: TriggerFunction,
pub priority: Option<i64>,
pub tags: Vec<Symbol>,
pub enabled: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub enum TriggerTiming {
Before,
After,
InsteadOf,
}
#[derive(Debug, Clone, PartialEq)]
pub enum TriggerEvent {
Insert,
Update(Vec<Symbol>), Delete,
Truncate,
}
#[derive(Debug, Clone, PartialEq)]
pub enum TriggerLevel {
Row,
Statement,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TriggerFunction {
pub name: ObjectName,
pub args: Vec<Symbol>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TriggerReferencing {
pub kind: TransitionKind,
pub alias: Symbol,
}
#[derive(Debug, Clone, PartialEq)]
pub enum TransitionKind {
OldTable,
NewTable,
}
#[derive(Debug, Clone, PartialEq)]
pub enum TriggerInitially {
Deferred,
Immediate,
}