Skip to main content

sqlparser/ast/
trigger.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//! SQL Abstract Syntax Tree (AST) for triggers.
19use super::*;
20
21/// This specifies whether the trigger function should be fired once for every row affected by the trigger event, or just once per SQL statement.
22#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TriggerObject {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                TriggerObject::Row => "Row",
                TriggerObject::Statement => "Statement",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TriggerObject {
    #[inline]
    fn clone(&self) -> TriggerObject { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TriggerObject { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for TriggerObject {
    #[inline]
    fn eq(&self, other: &TriggerObject) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for TriggerObject {
    #[inline]
    fn partial_cmp(&self, other: &TriggerObject)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for TriggerObject {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::Ord for TriggerObject {
    #[inline]
    fn cmp(&self, other: &TriggerObject) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for TriggerObject {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash)]
23#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
24#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for TriggerObject {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self { Self::Row => {} Self::Statement => {} }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for TriggerObject {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self { Self::Row => {} Self::Statement => {} }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
25pub enum TriggerObject {
26    /// The trigger fires once for each row affected by the triggering event
27    Row,
28    /// The trigger fires once for the triggering SQL statement
29    Statement,
30}
31
32impl fmt::Display for TriggerObject {
33    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
34        match self {
35            TriggerObject::Row => f.write_fmt(format_args!("ROW"))write!(f, "ROW"),
36            TriggerObject::Statement => f.write_fmt(format_args!("STATEMENT"))write!(f, "STATEMENT"),
37        }
38    }
39}
40
41#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TriggerReferencingType {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                TriggerReferencingType::OldTable => "OldTable",
                TriggerReferencingType::NewTable => "NewTable",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TriggerReferencingType {
    #[inline]
    fn clone(&self) -> TriggerReferencingType { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TriggerReferencingType { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for TriggerReferencingType {
    #[inline]
    fn eq(&self, other: &TriggerReferencingType) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for TriggerReferencingType {
    #[inline]
    fn partial_cmp(&self, other: &TriggerReferencingType)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for TriggerReferencingType {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::Ord for TriggerReferencingType {
    #[inline]
    fn cmp(&self, other: &TriggerReferencingType) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for TriggerReferencingType {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash)]
42#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
43#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for TriggerReferencingType {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self { Self::OldTable => {} Self::NewTable => {} }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for TriggerReferencingType {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self { Self::OldTable => {} Self::NewTable => {} }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
44/// This clause indicates whether the following relation name is for the before-image transition relation or the after-image transition relation
45pub enum TriggerReferencingType {
46    /// The transition relation containing the old rows affected by the triggering statement
47    OldTable,
48    /// The transition relation containing the new rows affected by the triggering statement
49    NewTable,
50}
51
52impl fmt::Display for TriggerReferencingType {
53    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54        match self {
55            TriggerReferencingType::OldTable => f.write_fmt(format_args!("OLD TABLE"))write!(f, "OLD TABLE"),
56            TriggerReferencingType::NewTable => f.write_fmt(format_args!("NEW TABLE"))write!(f, "NEW TABLE"),
57        }
58    }
59}
60
61/// This keyword immediately precedes the declaration of one or two relation names that provide access to the transition relations of the triggering statement
62#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TriggerReferencing {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "TriggerReferencing", "refer_type", &self.refer_type, "is_as",
            &self.is_as, "transition_relation_name",
            &&self.transition_relation_name)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TriggerReferencing {
    #[inline]
    fn clone(&self) -> TriggerReferencing {
        TriggerReferencing {
            refer_type: ::core::clone::Clone::clone(&self.refer_type),
            is_as: ::core::clone::Clone::clone(&self.is_as),
            transition_relation_name: ::core::clone::Clone::clone(&self.transition_relation_name),
        }
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for TriggerReferencing {
    #[inline]
    fn eq(&self, other: &TriggerReferencing) -> bool {
        self.is_as == other.is_as && self.refer_type == other.refer_type &&
            self.transition_relation_name == other.transition_relation_name
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for TriggerReferencing {
    #[inline]
    fn partial_cmp(&self, other: &TriggerReferencing)
        -> ::core::option::Option<::core::cmp::Ordering> {
        match ::core::cmp::PartialOrd::partial_cmp(&self.refer_type,
                &other.refer_type) {
            ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
                match ::core::cmp::PartialOrd::partial_cmp(&self.is_as,
                        &other.is_as) {
                    ::core::option::Option::Some(::core::cmp::Ordering::Equal)
                        =>
                        ::core::cmp::PartialOrd::partial_cmp(&self.transition_relation_name,
                            &other.transition_relation_name),
                    cmp => cmp,
                },
            cmp => cmp,
        }
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for TriggerReferencing {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<TriggerReferencingType>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
        let _: ::core::cmp::AssertParamIsEq<ObjectName>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::Ord for TriggerReferencing {
    #[inline]
    fn cmp(&self, other: &TriggerReferencing) -> ::core::cmp::Ordering {
        match ::core::cmp::Ord::cmp(&self.refer_type, &other.refer_type) {
            ::core::cmp::Ordering::Equal =>
                match ::core::cmp::Ord::cmp(&self.is_as, &other.is_as) {
                    ::core::cmp::Ordering::Equal =>
                        ::core::cmp::Ord::cmp(&self.transition_relation_name,
                            &other.transition_relation_name),
                    cmp => cmp,
                },
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for TriggerReferencing {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.refer_type, state);
        ::core::hash::Hash::hash(&self.is_as, state);
        ::core::hash::Hash::hash(&self.transition_relation_name, state)
    }
}Hash)]
63#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
64#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for TriggerReferencing {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        sqlparser::ast::Visit::visit(&self.refer_type, visitor)?;
                        sqlparser::ast::Visit::visit(&self.is_as, visitor)?;
                        sqlparser::ast::Visit::visit(&self.transition_relation_name,
                                visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for TriggerReferencing {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        sqlparser::ast::VisitMut::visit(&mut self.refer_type,
                                visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.is_as, visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.transition_relation_name,
                                visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
65pub struct TriggerReferencing {
66    /// The referencing type (`OLD TABLE` or `NEW TABLE`).
67    pub refer_type: TriggerReferencingType,
68    /// True if the `AS` keyword is present in the referencing clause.
69    pub is_as: bool,
70    /// The transition relation name provided by the referencing clause.
71    pub transition_relation_name: ObjectName,
72}
73
74impl fmt::Display for TriggerReferencing {
75    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
76        f.write_fmt(format_args!("{0}{1} {2}", self.refer_type,
        if self.is_as { " AS" } else { "" }, self.transition_relation_name))write!(
77            f,
78            "{refer_type}{is_as} {relation_name}",
79            refer_type = self.refer_type,
80            is_as = if self.is_as { " AS" } else { "" },
81            relation_name = self.transition_relation_name
82        )
83    }
84}
85
86/// Used to describe trigger events
87#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TriggerEvent {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TriggerEvent::Insert =>
                ::core::fmt::Formatter::write_str(f, "Insert"),
            TriggerEvent::Update(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Update",
                    &__self_0),
            TriggerEvent::Delete =>
                ::core::fmt::Formatter::write_str(f, "Delete"),
            TriggerEvent::Truncate =>
                ::core::fmt::Formatter::write_str(f, "Truncate"),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TriggerEvent {
    #[inline]
    fn clone(&self) -> TriggerEvent {
        match self {
            TriggerEvent::Insert => TriggerEvent::Insert,
            TriggerEvent::Update(__self_0) =>
                TriggerEvent::Update(::core::clone::Clone::clone(__self_0)),
            TriggerEvent::Delete => TriggerEvent::Delete,
            TriggerEvent::Truncate => TriggerEvent::Truncate,
        }
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for TriggerEvent {
    #[inline]
    fn eq(&self, other: &TriggerEvent) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (TriggerEvent::Update(__self_0),
                    TriggerEvent::Update(__arg1_0)) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for TriggerEvent {
    #[inline]
    fn partial_cmp(&self, other: &TriggerEvent)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        match (self, other) {
            (TriggerEvent::Update(__self_0), TriggerEvent::Update(__arg1_0))
                => ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
            _ =>
                ::core::cmp::PartialOrd::partial_cmp(&__self_discr,
                    &__arg1_discr),
        }
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for TriggerEvent {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Vec<Ident>>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::Ord for TriggerEvent {
    #[inline]
    fn cmp(&self, other: &TriggerEvent) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
            ::core::cmp::Ordering::Equal =>
                match (self, other) {
                    (TriggerEvent::Update(__self_0),
                        TriggerEvent::Update(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    _ => ::core::cmp::Ordering::Equal,
                },
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for TriggerEvent {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state);
        match self {
            TriggerEvent::Update(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash)]
88#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
89#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for TriggerEvent {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self {
                            Self::Insert => {}
                            Self::Update(_0) => {
                                sqlparser::ast::Visit::visit(_0, visitor)?;
                            }
                            Self::Delete => {}
                            Self::Truncate => {}
                        }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for TriggerEvent {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self {
                            Self::Insert => {}
                            Self::Update(_0) => {
                                sqlparser::ast::VisitMut::visit(_0, visitor)?;
                            }
                            Self::Delete => {}
                            Self::Truncate => {}
                        }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
90pub enum TriggerEvent {
91    /// Trigger on INSERT event
92    Insert,
93    /// Trigger on UPDATE event, with optional list of columns
94    Update(Vec<Ident>),
95    /// Trigger on DELETE event
96    Delete,
97    /// Trigger on TRUNCATE event
98    Truncate,
99}
100
101impl fmt::Display for TriggerEvent {
102    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
103        match self {
104            TriggerEvent::Insert => f.write_fmt(format_args!("INSERT"))write!(f, "INSERT"),
105            TriggerEvent::Update(columns) => {
106                f.write_fmt(format_args!("UPDATE"))write!(f, "UPDATE")?;
107                if !columns.is_empty() {
108                    f.write_fmt(format_args!(" OF"))write!(f, " OF")?;
109                    f.write_fmt(format_args!(" {0}", display_comma_separated(columns)))write!(f, " {}", display_comma_separated(columns))?;
110                }
111                Ok(())
112            }
113            TriggerEvent::Delete => f.write_fmt(format_args!("DELETE"))write!(f, "DELETE"),
114            TriggerEvent::Truncate => f.write_fmt(format_args!("TRUNCATE"))write!(f, "TRUNCATE"),
115        }
116    }
117}
118
119/// Trigger period
120#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TriggerPeriod {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                TriggerPeriod::For => "For",
                TriggerPeriod::After => "After",
                TriggerPeriod::Before => "Before",
                TriggerPeriod::InsteadOf => "InsteadOf",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TriggerPeriod {
    #[inline]
    fn clone(&self) -> TriggerPeriod { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TriggerPeriod { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for TriggerPeriod {
    #[inline]
    fn eq(&self, other: &TriggerPeriod) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for TriggerPeriod {
    #[inline]
    fn partial_cmp(&self, other: &TriggerPeriod)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for TriggerPeriod {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::Ord for TriggerPeriod {
    #[inline]
    fn cmp(&self, other: &TriggerPeriod) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for TriggerPeriod {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash)]
121#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
122#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for TriggerPeriod {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self {
                            Self::For => {}
                            Self::After => {}
                            Self::Before => {}
                            Self::InsteadOf => {}
                        }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for TriggerPeriod {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self {
                            Self::For => {}
                            Self::After => {}
                            Self::Before => {}
                            Self::InsteadOf => {}
                        }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
123pub enum TriggerPeriod {
124    /// The trigger fires once for each row affected by the triggering event
125    For,
126    /// The trigger fires once for the triggering SQL statement
127    After,
128    /// The trigger fires before the triggering event
129    Before,
130    /// The trigger fires instead of the triggering event
131    InsteadOf,
132}
133
134impl fmt::Display for TriggerPeriod {
135    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
136        match self {
137            TriggerPeriod::For => f.write_fmt(format_args!("FOR"))write!(f, "FOR"),
138            TriggerPeriod::After => f.write_fmt(format_args!("AFTER"))write!(f, "AFTER"),
139            TriggerPeriod::Before => f.write_fmt(format_args!("BEFORE"))write!(f, "BEFORE"),
140            TriggerPeriod::InsteadOf => f.write_fmt(format_args!("INSTEAD OF"))write!(f, "INSTEAD OF"),
141        }
142    }
143}
144
145/// Types of trigger body execution body.
146#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TriggerExecBodyType {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                TriggerExecBodyType::Function => "Function",
                TriggerExecBodyType::Procedure => "Procedure",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TriggerExecBodyType {
    #[inline]
    fn clone(&self) -> TriggerExecBodyType { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TriggerExecBodyType { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for TriggerExecBodyType {
    #[inline]
    fn eq(&self, other: &TriggerExecBodyType) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for TriggerExecBodyType {
    #[inline]
    fn partial_cmp(&self, other: &TriggerExecBodyType)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for TriggerExecBodyType {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::Ord for TriggerExecBodyType {
    #[inline]
    fn cmp(&self, other: &TriggerExecBodyType) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for TriggerExecBodyType {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash)]
147#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
148#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for TriggerExecBodyType {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self { Self::Function => {} Self::Procedure => {} }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for TriggerExecBodyType {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self { Self::Function => {} Self::Procedure => {} }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
149pub enum TriggerExecBodyType {
150    /// Execute a function
151    Function,
152    /// Execute a procedure
153    Procedure,
154}
155
156impl fmt::Display for TriggerExecBodyType {
157    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
158        match self {
159            TriggerExecBodyType::Function => f.write_fmt(format_args!("FUNCTION"))write!(f, "FUNCTION"),
160            TriggerExecBodyType::Procedure => f.write_fmt(format_args!("PROCEDURE"))write!(f, "PROCEDURE"),
161        }
162    }
163}
164/// This keyword immediately precedes the declaration of one or two relation names that provide access to the transition relations of the triggering statement
165#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TriggerExecBody {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "TriggerExecBody", "exec_type", &self.exec_type, "func_desc",
            &&self.func_desc)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TriggerExecBody {
    #[inline]
    fn clone(&self) -> TriggerExecBody {
        TriggerExecBody {
            exec_type: ::core::clone::Clone::clone(&self.exec_type),
            func_desc: ::core::clone::Clone::clone(&self.func_desc),
        }
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for TriggerExecBody {
    #[inline]
    fn eq(&self, other: &TriggerExecBody) -> bool {
        self.exec_type == other.exec_type && self.func_desc == other.func_desc
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for TriggerExecBody {
    #[inline]
    fn partial_cmp(&self, other: &TriggerExecBody)
        -> ::core::option::Option<::core::cmp::Ordering> {
        match ::core::cmp::PartialOrd::partial_cmp(&self.exec_type,
                &other.exec_type) {
            ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
                ::core::cmp::PartialOrd::partial_cmp(&self.func_desc,
                    &other.func_desc),
            cmp => cmp,
        }
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for TriggerExecBody {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<TriggerExecBodyType>;
        let _: ::core::cmp::AssertParamIsEq<FunctionDesc>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::Ord for TriggerExecBody {
    #[inline]
    fn cmp(&self, other: &TriggerExecBody) -> ::core::cmp::Ordering {
        match ::core::cmp::Ord::cmp(&self.exec_type, &other.exec_type) {
            ::core::cmp::Ordering::Equal =>
                ::core::cmp::Ord::cmp(&self.func_desc, &other.func_desc),
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for TriggerExecBody {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.exec_type, state);
        ::core::hash::Hash::hash(&self.func_desc, state)
    }
}Hash)]
166#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
167#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for TriggerExecBody {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        sqlparser::ast::Visit::visit(&self.exec_type, visitor)?;
                        sqlparser::ast::Visit::visit(&self.func_desc, visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for TriggerExecBody {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        sqlparser::ast::VisitMut::visit(&mut self.exec_type,
                                visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.func_desc,
                                visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
168pub struct TriggerExecBody {
169    /// Whether the body is a `FUNCTION` or `PROCEDURE` invocation.
170    pub exec_type: TriggerExecBodyType,
171    /// Description of the function/procedure to execute.
172    pub func_desc: FunctionDesc,
173}
174
175impl fmt::Display for TriggerExecBody {
176    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
177        f.write_fmt(format_args!("{0} {1}", self.exec_type, self.func_desc))write!(
178            f,
179            "{exec_type} {func_desc}",
180            exec_type = self.exec_type,
181            func_desc = self.func_desc
182        )
183    }
184}