Skip to main content

syntaqlite_syntax/sqlite/
ast.rs

1// Copyright 2025 The syntaqlite Authors. All rights reserved.
2// Licensed under the Apache License, Version 2.0.
3//
4// @generated by syntaqlite-buildtools — DO NOT EDIT
5
6#![allow(
7    missing_docs,
8    clippy::upper_case_acronyms,
9    clippy::elidable_lifetime_names
10)]
11
12use crate::ast::{AnyNode, AnyNodeId, GrammarNodeType, TypedNodeId, TypedNodeList};
13use crate::parser::AnyParsedStatement;
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16#[repr(u32)]
17pub enum NodeTag {
18    Null = 0,
19    AggregateFunctionCall = 1,
20    OrderedSetFunctionCall = 2,
21    CastExpr = 3,
22    ColumnRef = 4,
23    CompoundSelect = 5,
24    SubqueryExpr = 6,
25    ExistsExpr = 7,
26    InExpr = 8,
27    IsExpr = 9,
28    BetweenExpr = 10,
29    LikeExpr = 11,
30    CaseExpr = 12,
31    CaseWhen = 13,
32    CaseWhenList = 14,
33    ForeignKeyClause = 15,
34    ColumnConstraint = 16,
35    ColumnConstraintList = 17,
36    ColumnDef = 18,
37    ColumnDefList = 19,
38    TableConstraint = 20,
39    TableConstraintList = 21,
40    CreateTableStmt = 22,
41    CteDefinition = 23,
42    CteList = 24,
43    WithClause = 25,
44    UpsertClause = 26,
45    UpsertClauseList = 27,
46    DeleteStmt = 28,
47    SetClause = 29,
48    SetClauseList = 30,
49    UpdateStmt = 31,
50    InsertStmt = 32,
51    BinaryExpr = 33,
52    UnaryExpr = 34,
53    Literal = 35,
54    IdentName = 36,
55    Error = 37,
56    ExprList = 38,
57    FunctionCall = 39,
58    Variable = 40,
59    CollateExpr = 41,
60    RaiseExpr = 42,
61    QualifiedName = 43,
62    DropStmt = 44,
63    AlterTableStmt = 45,
64    TransactionStmt = 46,
65    SavepointStmt = 47,
66    ResultColumn = 48,
67    ResultColumnList = 49,
68    SelectStmt = 50,
69    OrderingTerm = 51,
70    OrderByList = 52,
71    LimitClause = 53,
72    TableRef = 54,
73    SubqueryTableSource = 55,
74    JoinClause = 56,
75    JoinPrefix = 57,
76    TriggerEvent = 58,
77    TriggerCmdList = 59,
78    CreateTriggerStmt = 60,
79    CreateVirtualTableStmt = 61,
80    PragmaStmt = 62,
81    AnalyzeOrReindexStmt = 63,
82    AttachStmt = 64,
83    DetachStmt = 65,
84    VacuumStmt = 66,
85    ExplainStmt = 67,
86    CreateIndexStmt = 68,
87    CreateViewStmt = 69,
88    ValuesRowList = 70,
89    ValuesClause = 71,
90    FrameBound = 72,
91    FrameSpec = 73,
92    WindowDef = 74,
93    WindowDefList = 75,
94    NamedWindowDef = 76,
95    NamedWindowDefList = 77,
96    FilterOver = 78,
97}
98
99impl From<NodeTag> for crate::any::AnyNodeTag {
100    fn from(t: NodeTag) -> crate::any::AnyNodeTag {
101        crate::any::AnyNodeTag(t as u32)
102    }
103}
104
105impl NodeTag {
106    pub(crate) fn from_raw(raw: u32) -> Option<NodeTag> {
107        match raw {
108            0 => Some(NodeTag::Null),
109            1 => Some(NodeTag::AggregateFunctionCall),
110            2 => Some(NodeTag::OrderedSetFunctionCall),
111            3 => Some(NodeTag::CastExpr),
112            4 => Some(NodeTag::ColumnRef),
113            5 => Some(NodeTag::CompoundSelect),
114            6 => Some(NodeTag::SubqueryExpr),
115            7 => Some(NodeTag::ExistsExpr),
116            8 => Some(NodeTag::InExpr),
117            9 => Some(NodeTag::IsExpr),
118            10 => Some(NodeTag::BetweenExpr),
119            11 => Some(NodeTag::LikeExpr),
120            12 => Some(NodeTag::CaseExpr),
121            13 => Some(NodeTag::CaseWhen),
122            14 => Some(NodeTag::CaseWhenList),
123            15 => Some(NodeTag::ForeignKeyClause),
124            16 => Some(NodeTag::ColumnConstraint),
125            17 => Some(NodeTag::ColumnConstraintList),
126            18 => Some(NodeTag::ColumnDef),
127            19 => Some(NodeTag::ColumnDefList),
128            20 => Some(NodeTag::TableConstraint),
129            21 => Some(NodeTag::TableConstraintList),
130            22 => Some(NodeTag::CreateTableStmt),
131            23 => Some(NodeTag::CteDefinition),
132            24 => Some(NodeTag::CteList),
133            25 => Some(NodeTag::WithClause),
134            26 => Some(NodeTag::UpsertClause),
135            27 => Some(NodeTag::UpsertClauseList),
136            28 => Some(NodeTag::DeleteStmt),
137            29 => Some(NodeTag::SetClause),
138            30 => Some(NodeTag::SetClauseList),
139            31 => Some(NodeTag::UpdateStmt),
140            32 => Some(NodeTag::InsertStmt),
141            33 => Some(NodeTag::BinaryExpr),
142            34 => Some(NodeTag::UnaryExpr),
143            35 => Some(NodeTag::Literal),
144            36 => Some(NodeTag::IdentName),
145            37 => Some(NodeTag::Error),
146            38 => Some(NodeTag::ExprList),
147            39 => Some(NodeTag::FunctionCall),
148            40 => Some(NodeTag::Variable),
149            41 => Some(NodeTag::CollateExpr),
150            42 => Some(NodeTag::RaiseExpr),
151            43 => Some(NodeTag::QualifiedName),
152            44 => Some(NodeTag::DropStmt),
153            45 => Some(NodeTag::AlterTableStmt),
154            46 => Some(NodeTag::TransactionStmt),
155            47 => Some(NodeTag::SavepointStmt),
156            48 => Some(NodeTag::ResultColumn),
157            49 => Some(NodeTag::ResultColumnList),
158            50 => Some(NodeTag::SelectStmt),
159            51 => Some(NodeTag::OrderingTerm),
160            52 => Some(NodeTag::OrderByList),
161            53 => Some(NodeTag::LimitClause),
162            54 => Some(NodeTag::TableRef),
163            55 => Some(NodeTag::SubqueryTableSource),
164            56 => Some(NodeTag::JoinClause),
165            57 => Some(NodeTag::JoinPrefix),
166            58 => Some(NodeTag::TriggerEvent),
167            59 => Some(NodeTag::TriggerCmdList),
168            60 => Some(NodeTag::CreateTriggerStmt),
169            61 => Some(NodeTag::CreateVirtualTableStmt),
170            62 => Some(NodeTag::PragmaStmt),
171            63 => Some(NodeTag::AnalyzeOrReindexStmt),
172            64 => Some(NodeTag::AttachStmt),
173            65 => Some(NodeTag::DetachStmt),
174            66 => Some(NodeTag::VacuumStmt),
175            67 => Some(NodeTag::ExplainStmt),
176            68 => Some(NodeTag::CreateIndexStmt),
177            69 => Some(NodeTag::CreateViewStmt),
178            70 => Some(NodeTag::ValuesRowList),
179            71 => Some(NodeTag::ValuesClause),
180            72 => Some(NodeTag::FrameBound),
181            73 => Some(NodeTag::FrameSpec),
182            74 => Some(NodeTag::WindowDef),
183            75 => Some(NodeTag::WindowDefList),
184            76 => Some(NodeTag::NamedWindowDef),
185            77 => Some(NodeTag::NamedWindowDefList),
186            78 => Some(NodeTag::FilterOver),
187            _ => None,
188        }
189    }
190}
191
192#[derive(Debug, Clone, Copy, PartialEq, Eq)]
193#[repr(u32)]
194pub enum LiteralType {
195    Integer = 0,
196    Float = 1,
197    String = 2,
198    Blob = 3,
199    Null = 4,
200    Current = 5,
201    Qnumber = 6,
202}
203
204impl LiteralType {
205    pub fn as_str(&self) -> &'static str {
206        match self {
207            LiteralType::Integer => "INTEGER",
208            LiteralType::Float => "FLOAT",
209            LiteralType::String => "STRING",
210            LiteralType::Blob => "BLOB",
211            LiteralType::Null => "NULL",
212            LiteralType::Current => "CURRENT",
213            LiteralType::Qnumber => "QNUMBER",
214        }
215    }
216}
217
218#[derive(Debug, Clone, Copy, PartialEq, Eq)]
219#[repr(u32)]
220pub enum BinaryOp {
221    Plus = 0,
222    Minus = 1,
223    Star = 2,
224    Slash = 3,
225    Rem = 4,
226    Lt = 5,
227    Gt = 6,
228    Le = 7,
229    Ge = 8,
230    Eq = 9,
231    Ne = 10,
232    And = 11,
233    Or = 12,
234    BitAnd = 13,
235    BitOr = 14,
236    Lshift = 15,
237    Rshift = 16,
238    Concat = 17,
239    Ptr = 18,
240    Ptr2 = 19,
241}
242
243impl BinaryOp {
244    pub fn as_str(&self) -> &'static str {
245        match self {
246            BinaryOp::Plus => "PLUS",
247            BinaryOp::Minus => "MINUS",
248            BinaryOp::Star => "STAR",
249            BinaryOp::Slash => "SLASH",
250            BinaryOp::Rem => "REM",
251            BinaryOp::Lt => "LT",
252            BinaryOp::Gt => "GT",
253            BinaryOp::Le => "LE",
254            BinaryOp::Ge => "GE",
255            BinaryOp::Eq => "EQ",
256            BinaryOp::Ne => "NE",
257            BinaryOp::And => "AND",
258            BinaryOp::Or => "OR",
259            BinaryOp::BitAnd => "BIT_AND",
260            BinaryOp::BitOr => "BIT_OR",
261            BinaryOp::Lshift => "LSHIFT",
262            BinaryOp::Rshift => "RSHIFT",
263            BinaryOp::Concat => "CONCAT",
264            BinaryOp::Ptr => "PTR",
265            BinaryOp::Ptr2 => "PTR2",
266        }
267    }
268}
269
270#[derive(Debug, Clone, Copy, PartialEq, Eq)]
271#[repr(u32)]
272pub enum UnaryOp {
273    Minus = 0,
274    Plus = 1,
275    BitNot = 2,
276    Not = 3,
277}
278
279impl UnaryOp {
280    pub fn as_str(&self) -> &'static str {
281        match self {
282            UnaryOp::Minus => "MINUS",
283            UnaryOp::Plus => "PLUS",
284            UnaryOp::BitNot => "BIT_NOT",
285            UnaryOp::Not => "NOT",
286        }
287    }
288}
289
290#[derive(Debug, Clone, Copy, PartialEq, Eq)]
291#[repr(u32)]
292pub enum CompoundOp {
293    Union = 0,
294    UnionAll = 1,
295    Intersect = 2,
296    Except = 3,
297}
298
299impl CompoundOp {
300    pub fn as_str(&self) -> &'static str {
301        match self {
302            CompoundOp::Union => "UNION",
303            CompoundOp::UnionAll => "UNION_ALL",
304            CompoundOp::Intersect => "INTERSECT",
305            CompoundOp::Except => "EXCEPT",
306        }
307    }
308}
309
310#[derive(Debug, Clone, Copy, PartialEq, Eq)]
311#[repr(u32)]
312pub enum IsOp {
313    Is = 0,
314    IsNot = 1,
315    IsNull = 2,
316    NotNull = 3,
317    IsNotDistinct = 4,
318    IsDistinct = 5,
319}
320
321impl IsOp {
322    pub fn as_str(&self) -> &'static str {
323        match self {
324            IsOp::Is => "IS",
325            IsOp::IsNot => "IS_NOT",
326            IsOp::IsNull => "IS_NULL",
327            IsOp::NotNull => "NOT_NULL",
328            IsOp::IsNotDistinct => "IS_NOT_DISTINCT",
329            IsOp::IsDistinct => "IS_DISTINCT",
330        }
331    }
332}
333
334#[derive(Debug, Clone, Copy, PartialEq, Eq)]
335#[repr(u32)]
336pub enum LikeKeyword {
337    Like = 0,
338    Glob = 1,
339    Match = 2,
340    Regexp = 3,
341}
342
343impl LikeKeyword {
344    pub fn as_str(&self) -> &'static str {
345        match self {
346            LikeKeyword::Like => "LIKE",
347            LikeKeyword::Glob => "GLOB",
348            LikeKeyword::Match => "MATCH",
349            LikeKeyword::Regexp => "REGEXP",
350        }
351    }
352}
353
354#[derive(Debug, Clone, Copy, PartialEq, Eq)]
355#[repr(u32)]
356pub enum ForeignKeyAction {
357    NoAction = 0,
358    SetNull = 1,
359    SetDefault = 2,
360    Cascade = 3,
361    Restrict = 4,
362}
363
364impl ForeignKeyAction {
365    pub fn as_str(&self) -> &'static str {
366        match self {
367            ForeignKeyAction::NoAction => "NO_ACTION",
368            ForeignKeyAction::SetNull => "SET_NULL",
369            ForeignKeyAction::SetDefault => "SET_DEFAULT",
370            ForeignKeyAction::Cascade => "CASCADE",
371            ForeignKeyAction::Restrict => "RESTRICT",
372        }
373    }
374}
375
376#[derive(Debug, Clone, Copy, PartialEq, Eq)]
377#[repr(u32)]
378pub enum GeneratedColumnStorage {
379    Virtual = 0,
380    Stored = 1,
381}
382
383impl GeneratedColumnStorage {
384    pub fn as_str(&self) -> &'static str {
385        match self {
386            GeneratedColumnStorage::Virtual => "VIRTUAL",
387            GeneratedColumnStorage::Stored => "STORED",
388        }
389    }
390}
391
392#[derive(Debug, Clone, Copy, PartialEq, Eq)]
393#[repr(u32)]
394pub enum ColumnConstraintType {
395    Default = 0,
396    NotNull = 1,
397    PrimaryKey = 2,
398    Unique = 3,
399    Check = 4,
400    References = 5,
401    Collate = 6,
402    Generated = 7,
403    Null = 8,
404}
405
406impl ColumnConstraintType {
407    pub fn as_str(&self) -> &'static str {
408        match self {
409            ColumnConstraintType::Default => "DEFAULT",
410            ColumnConstraintType::NotNull => "NOT_NULL",
411            ColumnConstraintType::PrimaryKey => "PRIMARY_KEY",
412            ColumnConstraintType::Unique => "UNIQUE",
413            ColumnConstraintType::Check => "CHECK",
414            ColumnConstraintType::References => "REFERENCES",
415            ColumnConstraintType::Collate => "COLLATE",
416            ColumnConstraintType::Generated => "GENERATED",
417            ColumnConstraintType::Null => "NULL",
418        }
419    }
420}
421
422#[derive(Debug, Clone, Copy, PartialEq, Eq)]
423#[repr(u32)]
424pub enum TableConstraintType {
425    PrimaryKey = 0,
426    Unique = 1,
427    Check = 2,
428    ForeignKey = 3,
429}
430
431impl TableConstraintType {
432    pub fn as_str(&self) -> &'static str {
433        match self {
434            TableConstraintType::PrimaryKey => "PRIMARY_KEY",
435            TableConstraintType::Unique => "UNIQUE",
436            TableConstraintType::Check => "CHECK",
437            TableConstraintType::ForeignKey => "FOREIGN_KEY",
438        }
439    }
440}
441
442#[derive(Debug, Clone, Copy, PartialEq, Eq)]
443#[repr(u32)]
444pub enum Materialized {
445    Default = 0,
446    Materialized = 1,
447    NotMaterialized = 2,
448}
449
450impl Materialized {
451    pub fn as_str(&self) -> &'static str {
452        match self {
453            Materialized::Default => "DEFAULT",
454            Materialized::Materialized => "MATERIALIZED",
455            Materialized::NotMaterialized => "NOT_MATERIALIZED",
456        }
457    }
458}
459
460#[derive(Debug, Clone, Copy, PartialEq, Eq)]
461#[repr(u32)]
462pub enum ConflictAction {
463    Default = 0,
464    Rollback = 1,
465    Abort = 2,
466    Fail = 3,
467    Ignore = 4,
468    Replace = 5,
469}
470
471impl ConflictAction {
472    pub fn as_str(&self) -> &'static str {
473        match self {
474            ConflictAction::Default => "DEFAULT",
475            ConflictAction::Rollback => "ROLLBACK",
476            ConflictAction::Abort => "ABORT",
477            ConflictAction::Fail => "FAIL",
478            ConflictAction::Ignore => "IGNORE",
479            ConflictAction::Replace => "REPLACE",
480        }
481    }
482}
483
484#[derive(Debug, Clone, Copy, PartialEq, Eq)]
485#[repr(u32)]
486pub enum UpsertAction {
487    Nothing = 0,
488    Update = 1,
489}
490
491impl UpsertAction {
492    pub fn as_str(&self) -> &'static str {
493        match self {
494            UpsertAction::Nothing => "NOTHING",
495            UpsertAction::Update => "UPDATE",
496        }
497    }
498}
499
500#[derive(Debug, Clone, Copy, PartialEq, Eq)]
501#[repr(u32)]
502pub enum IndexHint {
503    Default = 0,
504    NotIndexed = 1,
505    Indexed = 2,
506}
507
508impl IndexHint {
509    pub fn as_str(&self) -> &'static str {
510        match self {
511            IndexHint::Default => "DEFAULT",
512            IndexHint::NotIndexed => "NOT_INDEXED",
513            IndexHint::Indexed => "INDEXED",
514        }
515    }
516}
517
518#[derive(Debug, Clone, Copy, PartialEq, Eq)]
519#[repr(u32)]
520pub enum RaiseType {
521    Ignore = 0,
522    Rollback = 1,
523    Abort = 2,
524    Fail = 3,
525}
526
527impl RaiseType {
528    pub fn as_str(&self) -> &'static str {
529        match self {
530            RaiseType::Ignore => "IGNORE",
531            RaiseType::Rollback => "ROLLBACK",
532            RaiseType::Abort => "ABORT",
533            RaiseType::Fail => "FAIL",
534        }
535    }
536}
537
538#[derive(Debug, Clone, Copy, PartialEq, Eq)]
539#[repr(u32)]
540pub enum DropObjectType {
541    Table = 0,
542    Index = 1,
543    View = 2,
544    Trigger = 3,
545}
546
547impl DropObjectType {
548    pub fn as_str(&self) -> &'static str {
549        match self {
550            DropObjectType::Table => "TABLE",
551            DropObjectType::Index => "INDEX",
552            DropObjectType::View => "VIEW",
553            DropObjectType::Trigger => "TRIGGER",
554        }
555    }
556}
557
558#[derive(Debug, Clone, Copy, PartialEq, Eq)]
559#[repr(u32)]
560pub enum AlterOp {
561    RenameTable = 0,
562    RenameColumn = 1,
563    DropColumn = 2,
564    AddColumn = 3,
565}
566
567impl AlterOp {
568    pub fn as_str(&self) -> &'static str {
569        match self {
570            AlterOp::RenameTable => "RENAME_TABLE",
571            AlterOp::RenameColumn => "RENAME_COLUMN",
572            AlterOp::DropColumn => "DROP_COLUMN",
573            AlterOp::AddColumn => "ADD_COLUMN",
574        }
575    }
576}
577
578#[derive(Debug, Clone, Copy, PartialEq, Eq)]
579#[repr(u32)]
580pub enum TransactionType {
581    Deferred = 0,
582    Immediate = 1,
583    Exclusive = 2,
584}
585
586impl TransactionType {
587    pub fn as_str(&self) -> &'static str {
588        match self {
589            TransactionType::Deferred => "DEFERRED",
590            TransactionType::Immediate => "IMMEDIATE",
591            TransactionType::Exclusive => "EXCLUSIVE",
592        }
593    }
594}
595
596#[derive(Debug, Clone, Copy, PartialEq, Eq)]
597#[repr(u32)]
598pub enum TransactionOp {
599    Begin = 0,
600    Commit = 1,
601    Rollback = 2,
602}
603
604impl TransactionOp {
605    pub fn as_str(&self) -> &'static str {
606        match self {
607            TransactionOp::Begin => "BEGIN",
608            TransactionOp::Commit => "COMMIT",
609            TransactionOp::Rollback => "ROLLBACK",
610        }
611    }
612}
613
614#[derive(Debug, Clone, Copy, PartialEq, Eq)]
615#[repr(u32)]
616pub enum SavepointOp {
617    Savepoint = 0,
618    Release = 1,
619    RollbackTo = 2,
620}
621
622impl SavepointOp {
623    pub fn as_str(&self) -> &'static str {
624        match self {
625            SavepointOp::Savepoint => "SAVEPOINT",
626            SavepointOp::Release => "RELEASE",
627            SavepointOp::RollbackTo => "ROLLBACK_TO",
628        }
629    }
630}
631
632#[derive(Debug, Clone, Copy, PartialEq, Eq)]
633#[repr(u32)]
634pub enum SortOrder {
635    Asc = 0,
636    Desc = 1,
637}
638
639impl SortOrder {
640    pub fn as_str(&self) -> &'static str {
641        match self {
642            SortOrder::Asc => "ASC",
643            SortOrder::Desc => "DESC",
644        }
645    }
646}
647
648#[derive(Debug, Clone, Copy, PartialEq, Eq)]
649#[repr(u32)]
650pub enum NullsOrder {
651    None = 0,
652    First = 1,
653    Last = 2,
654}
655
656impl NullsOrder {
657    pub fn as_str(&self) -> &'static str {
658        match self {
659            NullsOrder::None => "NONE",
660            NullsOrder::First => "FIRST",
661            NullsOrder::Last => "LAST",
662        }
663    }
664}
665
666#[derive(Debug, Clone, Copy, PartialEq, Eq)]
667#[repr(u32)]
668pub enum JoinType {
669    Comma = 0,
670    Inner = 1,
671    Left = 2,
672    Right = 3,
673    Full = 4,
674    Cross = 5,
675    NaturalInner = 6,
676    NaturalLeft = 7,
677    NaturalRight = 8,
678    NaturalFull = 9,
679}
680
681impl JoinType {
682    pub fn as_str(&self) -> &'static str {
683        match self {
684            JoinType::Comma => "COMMA",
685            JoinType::Inner => "INNER",
686            JoinType::Left => "LEFT",
687            JoinType::Right => "RIGHT",
688            JoinType::Full => "FULL",
689            JoinType::Cross => "CROSS",
690            JoinType::NaturalInner => "NATURAL_INNER",
691            JoinType::NaturalLeft => "NATURAL_LEFT",
692            JoinType::NaturalRight => "NATURAL_RIGHT",
693            JoinType::NaturalFull => "NATURAL_FULL",
694        }
695    }
696}
697
698#[derive(Debug, Clone, Copy, PartialEq, Eq)]
699#[repr(u32)]
700pub enum TriggerTiming {
701    Before = 0,
702    After = 1,
703    InsteadOf = 2,
704}
705
706impl TriggerTiming {
707    pub fn as_str(&self) -> &'static str {
708        match self {
709            TriggerTiming::Before => "BEFORE",
710            TriggerTiming::After => "AFTER",
711            TriggerTiming::InsteadOf => "INSTEAD_OF",
712        }
713    }
714}
715
716#[derive(Debug, Clone, Copy, PartialEq, Eq)]
717#[repr(u32)]
718pub enum TriggerEventType {
719    Delete = 0,
720    Insert = 1,
721    Update = 2,
722}
723
724impl TriggerEventType {
725    pub fn as_str(&self) -> &'static str {
726        match self {
727            TriggerEventType::Delete => "DELETE",
728            TriggerEventType::Insert => "INSERT",
729            TriggerEventType::Update => "UPDATE",
730        }
731    }
732}
733
734#[derive(Debug, Clone, Copy, PartialEq, Eq)]
735#[repr(u32)]
736pub enum ExplainMode {
737    Explain = 0,
738    QueryPlan = 1,
739}
740
741impl ExplainMode {
742    pub fn as_str(&self) -> &'static str {
743        match self {
744            ExplainMode::Explain => "EXPLAIN",
745            ExplainMode::QueryPlan => "QUERY_PLAN",
746        }
747    }
748}
749
750#[derive(Debug, Clone, Copy, PartialEq, Eq)]
751#[repr(u32)]
752pub enum PragmaForm {
753    Bare = 0,
754    Eq = 1,
755    Call = 2,
756}
757
758impl PragmaForm {
759    pub fn as_str(&self) -> &'static str {
760        match self {
761            PragmaForm::Bare => "BARE",
762            PragmaForm::Eq => "EQ",
763            PragmaForm::Call => "CALL",
764        }
765    }
766}
767
768#[derive(Debug, Clone, Copy, PartialEq, Eq)]
769#[repr(u32)]
770pub enum AnalyzeOrReindexOp {
771    Analyze = 0,
772    Reindex = 1,
773}
774
775impl AnalyzeOrReindexOp {
776    pub fn as_str(&self) -> &'static str {
777        match self {
778            AnalyzeOrReindexOp::Analyze => "ANALYZE",
779            AnalyzeOrReindexOp::Reindex => "REINDEX",
780        }
781    }
782}
783
784#[derive(Debug, Clone, Copy, PartialEq, Eq)]
785#[repr(u32)]
786pub enum FrameType {
787    None = 0,
788    Range = 1,
789    Rows = 2,
790    Groups = 3,
791}
792
793impl FrameType {
794    pub fn as_str(&self) -> &'static str {
795        match self {
796            FrameType::None => "NONE",
797            FrameType::Range => "RANGE",
798            FrameType::Rows => "ROWS",
799            FrameType::Groups => "GROUPS",
800        }
801    }
802}
803
804#[derive(Debug, Clone, Copy, PartialEq, Eq)]
805#[repr(u32)]
806pub enum FrameBoundType {
807    UnboundedPreceding = 0,
808    ExprPreceding = 1,
809    CurrentRow = 2,
810    ExprFollowing = 3,
811    UnboundedFollowing = 4,
812}
813
814impl FrameBoundType {
815    pub fn as_str(&self) -> &'static str {
816        match self {
817            FrameBoundType::UnboundedPreceding => "UNBOUNDED_PRECEDING",
818            FrameBoundType::ExprPreceding => "EXPR_PRECEDING",
819            FrameBoundType::CurrentRow => "CURRENT_ROW",
820            FrameBoundType::ExprFollowing => "EXPR_FOLLOWING",
821            FrameBoundType::UnboundedFollowing => "UNBOUNDED_FOLLOWING",
822        }
823    }
824}
825
826#[derive(Debug, Clone, Copy, PartialEq, Eq)]
827#[repr(u32)]
828pub enum FrameExclude {
829    None = 0,
830    NoOthers = 1,
831    CurrentRow = 2,
832    Group = 3,
833    Ties = 4,
834}
835
836impl FrameExclude {
837    pub fn as_str(&self) -> &'static str {
838        match self {
839            FrameExclude::None => "NONE",
840            FrameExclude::NoOthers => "NO_OTHERS",
841            FrameExclude::CurrentRow => "CURRENT_ROW",
842            FrameExclude::Group => "GROUP",
843            FrameExclude::Ties => "TIES",
844        }
845    }
846}
847
848#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
849#[repr(transparent)]
850pub struct AggregateFunctionCallFlags(u8);
851
852impl AggregateFunctionCallFlags {
853    pub fn bits(self) -> u8 {
854        self.0
855    }
856    pub fn distinct(&self) -> bool {
857        self.0 & 1 != 0
858    }
859}
860
861#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
862#[repr(transparent)]
863pub struct CreateTableStmtFlags(u8);
864
865impl CreateTableStmtFlags {
866    pub fn bits(self) -> u8 {
867        self.0
868    }
869    pub fn without_rowid(&self) -> bool {
870        self.0 & 1 != 0
871    }
872    pub fn strict(&self) -> bool {
873        self.0 & 2 != 0
874    }
875}
876
877#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
878#[repr(transparent)]
879pub struct FunctionCallFlags(u8);
880
881impl FunctionCallFlags {
882    pub fn bits(self) -> u8 {
883        self.0
884    }
885    pub fn distinct(&self) -> bool {
886        self.0 & 1 != 0
887    }
888    pub fn star(&self) -> bool {
889        self.0 & 2 != 0
890    }
891}
892
893#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
894#[repr(transparent)]
895pub struct ResultColumnFlags(u8);
896
897impl ResultColumnFlags {
898    pub fn bits(self) -> u8 {
899        self.0
900    }
901    pub fn star(&self) -> bool {
902        self.0 & 1 != 0
903    }
904}
905
906#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
907#[repr(transparent)]
908pub struct SelectStmtFlags(u8);
909
910impl SelectStmtFlags {
911    pub fn bits(self) -> u8 {
912        self.0
913    }
914    pub fn distinct(&self) -> bool {
915        self.0 & 1 != 0
916    }
917}
918
919/// Abstract `Select` — pattern-match to access the concrete type.
920#[derive(Debug, Clone, Copy)]
921pub enum Select<'a> {
922    SelectStmt(SelectStmt<'a>),
923    CompoundSelect(CompoundSelect<'a>),
924    WithClause(WithClause<'a>),
925    ValuesClause(ValuesClause<'a>),
926}
927
928impl<'a> Select<'a> {
929    /// The typed node ID of this node.
930    pub fn node_id(&self) -> SelectId {
931        match self {
932            Select::SelectStmt(n) => SelectId(n.node_id().into()),
933            Select::CompoundSelect(n) => SelectId(n.node_id().into()),
934            Select::WithClause(n) => SelectId(n.node_id().into()),
935            Select::ValuesClause(n) => SelectId(n.node_id().into()),
936        }
937    }
938}
939
940impl<'a> GrammarNodeType<'a> for Select<'a> {
941    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
942        let node = Node::resolve(stmt_result, id)?;
943        match node {
944            Node::SelectStmt(n) => Some(Select::SelectStmt(n)),
945            Node::CompoundSelect(n) => Some(Select::CompoundSelect(n)),
946            Node::WithClause(n) => Some(Select::WithClause(n)),
947            Node::ValuesClause(n) => Some(Select::ValuesClause(n)),
948            _ => None,
949        }
950    }
951}
952
953#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
954pub struct SelectId(AnyNodeId);
955
956impl SelectId {
957    pub fn into_inner(self) -> AnyNodeId {
958        self.0
959    }
960}
961
962impl<'a> From<Select<'a>> for SelectId {
963    fn from(n: Select<'a>) -> Self {
964        n.node_id()
965    }
966}
967
968impl From<SelectId> for AnyNodeId {
969    fn from(id: SelectId) -> AnyNodeId {
970        id.0
971    }
972}
973
974impl TypedNodeId for SelectId {
975    type Node<'a> = Select<'a>;
976}
977
978/// Abstract `InExprSource` — pattern-match to access the concrete type.
979#[derive(Debug, Clone, Copy)]
980pub enum InExprSource<'a> {
981    ExprList(ExprList<'a>),
982    SubqueryExpr(SubqueryExpr<'a>),
983    SelectStmt(SelectStmt<'a>),
984    CompoundSelect(CompoundSelect<'a>),
985    WithClause(WithClause<'a>),
986    ValuesClause(ValuesClause<'a>),
987}
988
989impl<'a> InExprSource<'a> {
990    /// The typed node ID of this node.
991    pub fn node_id(&self) -> InExprSourceId {
992        match self {
993            InExprSource::ExprList(n) => InExprSourceId(n.node_id().into()),
994            InExprSource::SubqueryExpr(n) => InExprSourceId(n.node_id().into()),
995            InExprSource::SelectStmt(n) => InExprSourceId(n.node_id().into()),
996            InExprSource::CompoundSelect(n) => InExprSourceId(n.node_id().into()),
997            InExprSource::WithClause(n) => InExprSourceId(n.node_id().into()),
998            InExprSource::ValuesClause(n) => InExprSourceId(n.node_id().into()),
999        }
1000    }
1001}
1002
1003impl<'a> GrammarNodeType<'a> for InExprSource<'a> {
1004    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1005        let node = Node::resolve(stmt_result, id)?;
1006        match node {
1007            Node::ExprList(n) => Some(InExprSource::ExprList(n)),
1008            Node::SubqueryExpr(n) => Some(InExprSource::SubqueryExpr(n)),
1009            Node::SelectStmt(n) => Some(InExprSource::SelectStmt(n)),
1010            Node::CompoundSelect(n) => Some(InExprSource::CompoundSelect(n)),
1011            Node::WithClause(n) => Some(InExprSource::WithClause(n)),
1012            Node::ValuesClause(n) => Some(InExprSource::ValuesClause(n)),
1013            _ => None,
1014        }
1015    }
1016}
1017
1018#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1019pub struct InExprSourceId(AnyNodeId);
1020
1021impl InExprSourceId {
1022    pub fn into_inner(self) -> AnyNodeId {
1023        self.0
1024    }
1025}
1026
1027impl<'a> From<InExprSource<'a>> for InExprSourceId {
1028    fn from(n: InExprSource<'a>) -> Self {
1029        n.node_id()
1030    }
1031}
1032
1033impl From<InExprSourceId> for AnyNodeId {
1034    fn from(id: InExprSourceId) -> AnyNodeId {
1035        id.0
1036    }
1037}
1038
1039impl TypedNodeId for InExprSourceId {
1040    type Node<'a> = InExprSource<'a>;
1041}
1042
1043/// Abstract `Name` — pattern-match to access the concrete type.
1044#[derive(Debug, Clone, Copy)]
1045pub enum Name<'a> {
1046    IdentName(IdentName<'a>),
1047    Error(Error<'a>),
1048}
1049
1050impl<'a> Name<'a> {
1051    /// The typed node ID of this node.
1052    pub fn node_id(&self) -> NameId {
1053        match self {
1054            Name::IdentName(n) => NameId(n.node_id().into()),
1055            Name::Error(n) => NameId(n.node_id().into()),
1056        }
1057    }
1058}
1059
1060impl<'a> GrammarNodeType<'a> for Name<'a> {
1061    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1062        let node = Node::resolve(stmt_result, id)?;
1063        match node {
1064            Node::IdentName(n) => Some(Name::IdentName(n)),
1065            Node::Error(n) => Some(Name::Error(n)),
1066            _ => None,
1067        }
1068    }
1069}
1070
1071#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1072pub struct NameId(AnyNodeId);
1073
1074impl NameId {
1075    pub fn into_inner(self) -> AnyNodeId {
1076        self.0
1077    }
1078}
1079
1080impl<'a> From<Name<'a>> for NameId {
1081    fn from(n: Name<'a>) -> Self {
1082        n.node_id()
1083    }
1084}
1085
1086impl From<NameId> for AnyNodeId {
1087    fn from(id: NameId) -> AnyNodeId {
1088        id.0
1089    }
1090}
1091
1092impl TypedNodeId for NameId {
1093    type Node<'a> = Name<'a>;
1094}
1095
1096/// Abstract `Expr` — pattern-match to access the concrete type.
1097#[derive(Debug, Clone, Copy)]
1098pub enum Expr<'a> {
1099    BinaryExpr(BinaryExpr<'a>),
1100    UnaryExpr(UnaryExpr<'a>),
1101    Literal(Literal<'a>),
1102    ColumnRef(ColumnRef<'a>),
1103    Variable(Variable<'a>),
1104    Error(Error<'a>),
1105    FunctionCall(FunctionCall<'a>),
1106    AggregateFunctionCall(AggregateFunctionCall<'a>),
1107    OrderedSetFunctionCall(OrderedSetFunctionCall<'a>),
1108    CastExpr(CastExpr<'a>),
1109    CollateExpr(CollateExpr<'a>),
1110    CaseExpr(CaseExpr<'a>),
1111    IsExpr(IsExpr<'a>),
1112    BetweenExpr(BetweenExpr<'a>),
1113    LikeExpr(LikeExpr<'a>),
1114    InExpr(InExpr<'a>),
1115    SubqueryExpr(SubqueryExpr<'a>),
1116    ExistsExpr(ExistsExpr<'a>),
1117    RaiseExpr(RaiseExpr<'a>),
1118}
1119
1120impl<'a> Expr<'a> {
1121    /// The typed node ID of this node.
1122    pub fn node_id(&self) -> ExprId {
1123        match self {
1124            Expr::BinaryExpr(n) => ExprId(n.node_id().into()),
1125            Expr::UnaryExpr(n) => ExprId(n.node_id().into()),
1126            Expr::Literal(n) => ExprId(n.node_id().into()),
1127            Expr::ColumnRef(n) => ExprId(n.node_id().into()),
1128            Expr::Variable(n) => ExprId(n.node_id().into()),
1129            Expr::Error(n) => ExprId(n.node_id().into()),
1130            Expr::FunctionCall(n) => ExprId(n.node_id().into()),
1131            Expr::AggregateFunctionCall(n) => ExprId(n.node_id().into()),
1132            Expr::OrderedSetFunctionCall(n) => ExprId(n.node_id().into()),
1133            Expr::CastExpr(n) => ExprId(n.node_id().into()),
1134            Expr::CollateExpr(n) => ExprId(n.node_id().into()),
1135            Expr::CaseExpr(n) => ExprId(n.node_id().into()),
1136            Expr::IsExpr(n) => ExprId(n.node_id().into()),
1137            Expr::BetweenExpr(n) => ExprId(n.node_id().into()),
1138            Expr::LikeExpr(n) => ExprId(n.node_id().into()),
1139            Expr::InExpr(n) => ExprId(n.node_id().into()),
1140            Expr::SubqueryExpr(n) => ExprId(n.node_id().into()),
1141            Expr::ExistsExpr(n) => ExprId(n.node_id().into()),
1142            Expr::RaiseExpr(n) => ExprId(n.node_id().into()),
1143        }
1144    }
1145}
1146
1147impl<'a> GrammarNodeType<'a> for Expr<'a> {
1148    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1149        let node = Node::resolve(stmt_result, id)?;
1150        match node {
1151            Node::BinaryExpr(n) => Some(Expr::BinaryExpr(n)),
1152            Node::UnaryExpr(n) => Some(Expr::UnaryExpr(n)),
1153            Node::Literal(n) => Some(Expr::Literal(n)),
1154            Node::ColumnRef(n) => Some(Expr::ColumnRef(n)),
1155            Node::Variable(n) => Some(Expr::Variable(n)),
1156            Node::Error(n) => Some(Expr::Error(n)),
1157            Node::FunctionCall(n) => Some(Expr::FunctionCall(n)),
1158            Node::AggregateFunctionCall(n) => Some(Expr::AggregateFunctionCall(n)),
1159            Node::OrderedSetFunctionCall(n) => Some(Expr::OrderedSetFunctionCall(n)),
1160            Node::CastExpr(n) => Some(Expr::CastExpr(n)),
1161            Node::CollateExpr(n) => Some(Expr::CollateExpr(n)),
1162            Node::CaseExpr(n) => Some(Expr::CaseExpr(n)),
1163            Node::IsExpr(n) => Some(Expr::IsExpr(n)),
1164            Node::BetweenExpr(n) => Some(Expr::BetweenExpr(n)),
1165            Node::LikeExpr(n) => Some(Expr::LikeExpr(n)),
1166            Node::InExpr(n) => Some(Expr::InExpr(n)),
1167            Node::SubqueryExpr(n) => Some(Expr::SubqueryExpr(n)),
1168            Node::ExistsExpr(n) => Some(Expr::ExistsExpr(n)),
1169            Node::RaiseExpr(n) => Some(Expr::RaiseExpr(n)),
1170            _ => None,
1171        }
1172    }
1173}
1174
1175#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1176pub struct ExprId(AnyNodeId);
1177
1178impl ExprId {
1179    pub fn into_inner(self) -> AnyNodeId {
1180        self.0
1181    }
1182}
1183
1184impl<'a> From<Expr<'a>> for ExprId {
1185    fn from(n: Expr<'a>) -> Self {
1186        n.node_id()
1187    }
1188}
1189
1190impl From<ExprId> for AnyNodeId {
1191    fn from(id: ExprId) -> AnyNodeId {
1192        id.0
1193    }
1194}
1195
1196impl TypedNodeId for ExprId {
1197    type Node<'a> = Expr<'a>;
1198}
1199
1200/// Abstract `Stmt` — pattern-match to access the concrete type.
1201#[derive(Debug, Clone, Copy)]
1202pub enum Stmt<'a> {
1203    SelectStmt(SelectStmt<'a>),
1204    CompoundSelect(CompoundSelect<'a>),
1205    ValuesClause(ValuesClause<'a>),
1206    WithClause(WithClause<'a>),
1207    InsertStmt(InsertStmt<'a>),
1208    UpdateStmt(UpdateStmt<'a>),
1209    DeleteStmt(DeleteStmt<'a>),
1210    CreateTableStmt(CreateTableStmt<'a>),
1211    CreateIndexStmt(CreateIndexStmt<'a>),
1212    CreateViewStmt(CreateViewStmt<'a>),
1213    CreateTriggerStmt(CreateTriggerStmt<'a>),
1214    CreateVirtualTableStmt(CreateVirtualTableStmt<'a>),
1215    DropStmt(DropStmt<'a>),
1216    AlterTableStmt(AlterTableStmt<'a>),
1217    TransactionStmt(TransactionStmt<'a>),
1218    SavepointStmt(SavepointStmt<'a>),
1219    PragmaStmt(PragmaStmt<'a>),
1220    AnalyzeOrReindexStmt(AnalyzeOrReindexStmt<'a>),
1221    AttachStmt(AttachStmt<'a>),
1222    DetachStmt(DetachStmt<'a>),
1223    VacuumStmt(VacuumStmt<'a>),
1224    ExplainStmt(ExplainStmt<'a>),
1225}
1226
1227impl<'a> Stmt<'a> {
1228    /// The typed node ID of this node.
1229    pub fn node_id(&self) -> StmtId {
1230        match self {
1231            Stmt::SelectStmt(n) => StmtId(n.node_id().into()),
1232            Stmt::CompoundSelect(n) => StmtId(n.node_id().into()),
1233            Stmt::ValuesClause(n) => StmtId(n.node_id().into()),
1234            Stmt::WithClause(n) => StmtId(n.node_id().into()),
1235            Stmt::InsertStmt(n) => StmtId(n.node_id().into()),
1236            Stmt::UpdateStmt(n) => StmtId(n.node_id().into()),
1237            Stmt::DeleteStmt(n) => StmtId(n.node_id().into()),
1238            Stmt::CreateTableStmt(n) => StmtId(n.node_id().into()),
1239            Stmt::CreateIndexStmt(n) => StmtId(n.node_id().into()),
1240            Stmt::CreateViewStmt(n) => StmtId(n.node_id().into()),
1241            Stmt::CreateTriggerStmt(n) => StmtId(n.node_id().into()),
1242            Stmt::CreateVirtualTableStmt(n) => StmtId(n.node_id().into()),
1243            Stmt::DropStmt(n) => StmtId(n.node_id().into()),
1244            Stmt::AlterTableStmt(n) => StmtId(n.node_id().into()),
1245            Stmt::TransactionStmt(n) => StmtId(n.node_id().into()),
1246            Stmt::SavepointStmt(n) => StmtId(n.node_id().into()),
1247            Stmt::PragmaStmt(n) => StmtId(n.node_id().into()),
1248            Stmt::AnalyzeOrReindexStmt(n) => StmtId(n.node_id().into()),
1249            Stmt::AttachStmt(n) => StmtId(n.node_id().into()),
1250            Stmt::DetachStmt(n) => StmtId(n.node_id().into()),
1251            Stmt::VacuumStmt(n) => StmtId(n.node_id().into()),
1252            Stmt::ExplainStmt(n) => StmtId(n.node_id().into()),
1253        }
1254    }
1255}
1256
1257impl<'a> GrammarNodeType<'a> for Stmt<'a> {
1258    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1259        let node = Node::resolve(stmt_result, id)?;
1260        match node {
1261            Node::SelectStmt(n) => Some(Stmt::SelectStmt(n)),
1262            Node::CompoundSelect(n) => Some(Stmt::CompoundSelect(n)),
1263            Node::ValuesClause(n) => Some(Stmt::ValuesClause(n)),
1264            Node::WithClause(n) => Some(Stmt::WithClause(n)),
1265            Node::InsertStmt(n) => Some(Stmt::InsertStmt(n)),
1266            Node::UpdateStmt(n) => Some(Stmt::UpdateStmt(n)),
1267            Node::DeleteStmt(n) => Some(Stmt::DeleteStmt(n)),
1268            Node::CreateTableStmt(n) => Some(Stmt::CreateTableStmt(n)),
1269            Node::CreateIndexStmt(n) => Some(Stmt::CreateIndexStmt(n)),
1270            Node::CreateViewStmt(n) => Some(Stmt::CreateViewStmt(n)),
1271            Node::CreateTriggerStmt(n) => Some(Stmt::CreateTriggerStmt(n)),
1272            Node::CreateVirtualTableStmt(n) => Some(Stmt::CreateVirtualTableStmt(n)),
1273            Node::DropStmt(n) => Some(Stmt::DropStmt(n)),
1274            Node::AlterTableStmt(n) => Some(Stmt::AlterTableStmt(n)),
1275            Node::TransactionStmt(n) => Some(Stmt::TransactionStmt(n)),
1276            Node::SavepointStmt(n) => Some(Stmt::SavepointStmt(n)),
1277            Node::PragmaStmt(n) => Some(Stmt::PragmaStmt(n)),
1278            Node::AnalyzeOrReindexStmt(n) => Some(Stmt::AnalyzeOrReindexStmt(n)),
1279            Node::AttachStmt(n) => Some(Stmt::AttachStmt(n)),
1280            Node::DetachStmt(n) => Some(Stmt::DetachStmt(n)),
1281            Node::VacuumStmt(n) => Some(Stmt::VacuumStmt(n)),
1282            Node::ExplainStmt(n) => Some(Stmt::ExplainStmt(n)),
1283            _ => None,
1284        }
1285    }
1286}
1287
1288#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1289pub struct StmtId(AnyNodeId);
1290
1291impl StmtId {
1292    pub fn into_inner(self) -> AnyNodeId {
1293        self.0
1294    }
1295}
1296
1297impl<'a> From<Stmt<'a>> for StmtId {
1298    fn from(n: Stmt<'a>) -> Self {
1299        n.node_id()
1300    }
1301}
1302
1303impl From<StmtId> for AnyNodeId {
1304    fn from(id: StmtId) -> AnyNodeId {
1305        id.0
1306    }
1307}
1308
1309impl TypedNodeId for StmtId {
1310    type Node<'a> = Stmt<'a>;
1311}
1312
1313/// Abstract `TableSource` — pattern-match to access the concrete type.
1314#[derive(Debug, Clone, Copy)]
1315pub enum TableSource<'a> {
1316    TableRef(TableRef<'a>),
1317    SubqueryTableSource(SubqueryTableSource<'a>),
1318    JoinClause(JoinClause<'a>),
1319    JoinPrefix(JoinPrefix<'a>),
1320}
1321
1322impl<'a> TableSource<'a> {
1323    /// The typed node ID of this node.
1324    pub fn node_id(&self) -> TableSourceId {
1325        match self {
1326            TableSource::TableRef(n) => TableSourceId(n.node_id().into()),
1327            TableSource::SubqueryTableSource(n) => TableSourceId(n.node_id().into()),
1328            TableSource::JoinClause(n) => TableSourceId(n.node_id().into()),
1329            TableSource::JoinPrefix(n) => TableSourceId(n.node_id().into()),
1330        }
1331    }
1332}
1333
1334impl<'a> GrammarNodeType<'a> for TableSource<'a> {
1335    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1336        let node = Node::resolve(stmt_result, id)?;
1337        match node {
1338            Node::TableRef(n) => Some(TableSource::TableRef(n)),
1339            Node::SubqueryTableSource(n) => Some(TableSource::SubqueryTableSource(n)),
1340            Node::JoinClause(n) => Some(TableSource::JoinClause(n)),
1341            Node::JoinPrefix(n) => Some(TableSource::JoinPrefix(n)),
1342            _ => None,
1343        }
1344    }
1345}
1346
1347#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1348pub struct TableSourceId(AnyNodeId);
1349
1350impl TableSourceId {
1351    pub fn into_inner(self) -> AnyNodeId {
1352        self.0
1353    }
1354}
1355
1356impl<'a> From<TableSource<'a>> for TableSourceId {
1357    fn from(n: TableSource<'a>) -> Self {
1358        n.node_id()
1359    }
1360}
1361
1362impl From<TableSourceId> for AnyNodeId {
1363    fn from(id: TableSourceId) -> AnyNodeId {
1364        id.0
1365    }
1366}
1367
1368impl TypedNodeId for TableSourceId {
1369    type Node<'a> = TableSource<'a>;
1370}
1371
1372#[derive(Clone, Copy)]
1373pub struct AggregateFunctionCall<'a> {
1374    raw: &'a super::ffi::AggregateFunctionCall,
1375    stmt_result: &'a AnyParsedStatement<'a>,
1376    id: AnyNodeId,
1377}
1378
1379impl std::fmt::Debug for AggregateFunctionCall<'_> {
1380    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1381        self.raw.fmt(f)
1382    }
1383}
1384
1385impl std::fmt::Display for AggregateFunctionCall<'_> {
1386    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1387        AnyNode {
1388            id: self.id,
1389            stmt_result: self.stmt_result,
1390        }
1391        .fmt(f)
1392    }
1393}
1394
1395impl<'a> AggregateFunctionCall<'a> {
1396    /// The typed node ID of this node.
1397    pub fn node_id(&self) -> AggregateFunctionCallId {
1398        AggregateFunctionCallId(self.id)
1399    }
1400    pub fn func_name(&self) -> &'a str {
1401        self.raw.func_name.as_str(self.stmt_result.source())
1402    }
1403    pub fn flags(&self) -> AggregateFunctionCallFlags {
1404        self.raw.flags
1405    }
1406    pub fn args(&self) -> Option<ExprList<'a>> {
1407        GrammarNodeType::from_result(self.stmt_result, self.raw.args)
1408    }
1409    pub fn orderby(&self) -> Option<OrderByList<'a>> {
1410        GrammarNodeType::from_result(self.stmt_result, self.raw.orderby)
1411    }
1412    pub fn filter_clause(&self) -> Option<Expr<'a>> {
1413        GrammarNodeType::from_result(self.stmt_result, self.raw.filter_clause)
1414    }
1415    pub fn over_clause(&self) -> Option<WindowDef<'a>> {
1416        GrammarNodeType::from_result(self.stmt_result, self.raw.over_clause)
1417    }
1418}
1419
1420impl<'a> GrammarNodeType<'a> for AggregateFunctionCall<'a> {
1421    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1422        let raw = stmt_result.resolve_as::<super::ffi::AggregateFunctionCall>(id)?;
1423        Some(AggregateFunctionCall {
1424            raw,
1425            stmt_result,
1426            id,
1427        })
1428    }
1429}
1430
1431#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1432pub struct AggregateFunctionCallId(AnyNodeId);
1433
1434impl AggregateFunctionCallId {
1435    pub fn into_inner(self) -> AnyNodeId {
1436        self.0
1437    }
1438}
1439
1440impl<'a> From<AggregateFunctionCall<'a>> for AggregateFunctionCallId {
1441    fn from(n: AggregateFunctionCall<'a>) -> Self {
1442        n.node_id()
1443    }
1444}
1445
1446impl From<AggregateFunctionCallId> for AnyNodeId {
1447    fn from(id: AggregateFunctionCallId) -> AnyNodeId {
1448        id.0
1449    }
1450}
1451
1452impl TypedNodeId for AggregateFunctionCallId {
1453    type Node<'a> = AggregateFunctionCall<'a>;
1454}
1455
1456#[derive(Clone, Copy)]
1457pub struct OrderedSetFunctionCall<'a> {
1458    raw: &'a super::ffi::OrderedSetFunctionCall,
1459    stmt_result: &'a AnyParsedStatement<'a>,
1460    id: AnyNodeId,
1461}
1462
1463impl std::fmt::Debug for OrderedSetFunctionCall<'_> {
1464    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1465        self.raw.fmt(f)
1466    }
1467}
1468
1469impl std::fmt::Display for OrderedSetFunctionCall<'_> {
1470    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1471        AnyNode {
1472            id: self.id,
1473            stmt_result: self.stmt_result,
1474        }
1475        .fmt(f)
1476    }
1477}
1478
1479impl<'a> OrderedSetFunctionCall<'a> {
1480    /// The typed node ID of this node.
1481    pub fn node_id(&self) -> OrderedSetFunctionCallId {
1482        OrderedSetFunctionCallId(self.id)
1483    }
1484    pub fn func_name(&self) -> &'a str {
1485        self.raw.func_name.as_str(self.stmt_result.source())
1486    }
1487    pub fn flags(&self) -> AggregateFunctionCallFlags {
1488        self.raw.flags
1489    }
1490    pub fn args(&self) -> Option<ExprList<'a>> {
1491        GrammarNodeType::from_result(self.stmt_result, self.raw.args)
1492    }
1493    pub fn orderby_expr(&self) -> Option<Expr<'a>> {
1494        GrammarNodeType::from_result(self.stmt_result, self.raw.orderby_expr)
1495    }
1496    pub fn filter_clause(&self) -> Option<Expr<'a>> {
1497        GrammarNodeType::from_result(self.stmt_result, self.raw.filter_clause)
1498    }
1499    pub fn over_clause(&self) -> Option<WindowDef<'a>> {
1500        GrammarNodeType::from_result(self.stmt_result, self.raw.over_clause)
1501    }
1502}
1503
1504impl<'a> GrammarNodeType<'a> for OrderedSetFunctionCall<'a> {
1505    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1506        let raw = stmt_result.resolve_as::<super::ffi::OrderedSetFunctionCall>(id)?;
1507        Some(OrderedSetFunctionCall {
1508            raw,
1509            stmt_result,
1510            id,
1511        })
1512    }
1513}
1514
1515#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1516pub struct OrderedSetFunctionCallId(AnyNodeId);
1517
1518impl OrderedSetFunctionCallId {
1519    pub fn into_inner(self) -> AnyNodeId {
1520        self.0
1521    }
1522}
1523
1524impl<'a> From<OrderedSetFunctionCall<'a>> for OrderedSetFunctionCallId {
1525    fn from(n: OrderedSetFunctionCall<'a>) -> Self {
1526        n.node_id()
1527    }
1528}
1529
1530impl From<OrderedSetFunctionCallId> for AnyNodeId {
1531    fn from(id: OrderedSetFunctionCallId) -> AnyNodeId {
1532        id.0
1533    }
1534}
1535
1536impl TypedNodeId for OrderedSetFunctionCallId {
1537    type Node<'a> = OrderedSetFunctionCall<'a>;
1538}
1539
1540#[derive(Clone, Copy)]
1541pub struct CastExpr<'a> {
1542    raw: &'a super::ffi::CastExpr,
1543    stmt_result: &'a AnyParsedStatement<'a>,
1544    id: AnyNodeId,
1545}
1546
1547impl std::fmt::Debug for CastExpr<'_> {
1548    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1549        self.raw.fmt(f)
1550    }
1551}
1552
1553impl std::fmt::Display for CastExpr<'_> {
1554    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1555        AnyNode {
1556            id: self.id,
1557            stmt_result: self.stmt_result,
1558        }
1559        .fmt(f)
1560    }
1561}
1562
1563impl<'a> CastExpr<'a> {
1564    /// The typed node ID of this node.
1565    pub fn node_id(&self) -> CastExprId {
1566        CastExprId(self.id)
1567    }
1568    pub fn expr(&self) -> Option<Expr<'a>> {
1569        GrammarNodeType::from_result(self.stmt_result, self.raw.expr)
1570    }
1571    pub fn type_name(&self) -> &'a str {
1572        self.raw.type_name.as_str(self.stmt_result.source())
1573    }
1574}
1575
1576impl<'a> GrammarNodeType<'a> for CastExpr<'a> {
1577    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1578        let raw = stmt_result.resolve_as::<super::ffi::CastExpr>(id)?;
1579        Some(CastExpr {
1580            raw,
1581            stmt_result,
1582            id,
1583        })
1584    }
1585}
1586
1587#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1588pub struct CastExprId(AnyNodeId);
1589
1590impl CastExprId {
1591    pub fn into_inner(self) -> AnyNodeId {
1592        self.0
1593    }
1594}
1595
1596impl<'a> From<CastExpr<'a>> for CastExprId {
1597    fn from(n: CastExpr<'a>) -> Self {
1598        n.node_id()
1599    }
1600}
1601
1602impl From<CastExprId> for AnyNodeId {
1603    fn from(id: CastExprId) -> AnyNodeId {
1604        id.0
1605    }
1606}
1607
1608impl TypedNodeId for CastExprId {
1609    type Node<'a> = CastExpr<'a>;
1610}
1611
1612#[derive(Clone, Copy)]
1613pub struct ColumnRef<'a> {
1614    raw: &'a super::ffi::ColumnRef,
1615    stmt_result: &'a AnyParsedStatement<'a>,
1616    id: AnyNodeId,
1617}
1618
1619impl std::fmt::Debug for ColumnRef<'_> {
1620    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1621        self.raw.fmt(f)
1622    }
1623}
1624
1625impl std::fmt::Display for ColumnRef<'_> {
1626    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1627        AnyNode {
1628            id: self.id,
1629            stmt_result: self.stmt_result,
1630        }
1631        .fmt(f)
1632    }
1633}
1634
1635impl<'a> ColumnRef<'a> {
1636    /// The typed node ID of this node.
1637    pub fn node_id(&self) -> ColumnRefId {
1638        ColumnRefId(self.id)
1639    }
1640    pub fn column(&self) -> &'a str {
1641        self.raw.column.as_str(self.stmt_result.source())
1642    }
1643    pub fn table(&self) -> &'a str {
1644        self.raw.table.as_str(self.stmt_result.source())
1645    }
1646    pub fn schema(&self) -> &'a str {
1647        self.raw.schema.as_str(self.stmt_result.source())
1648    }
1649}
1650
1651impl<'a> GrammarNodeType<'a> for ColumnRef<'a> {
1652    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1653        let raw = stmt_result.resolve_as::<super::ffi::ColumnRef>(id)?;
1654        Some(ColumnRef {
1655            raw,
1656            stmt_result,
1657            id,
1658        })
1659    }
1660}
1661
1662#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1663pub struct ColumnRefId(AnyNodeId);
1664
1665impl ColumnRefId {
1666    pub fn into_inner(self) -> AnyNodeId {
1667        self.0
1668    }
1669}
1670
1671impl<'a> From<ColumnRef<'a>> for ColumnRefId {
1672    fn from(n: ColumnRef<'a>) -> Self {
1673        n.node_id()
1674    }
1675}
1676
1677impl From<ColumnRefId> for AnyNodeId {
1678    fn from(id: ColumnRefId) -> AnyNodeId {
1679        id.0
1680    }
1681}
1682
1683impl TypedNodeId for ColumnRefId {
1684    type Node<'a> = ColumnRef<'a>;
1685}
1686
1687#[derive(Clone, Copy)]
1688pub struct CompoundSelect<'a> {
1689    raw: &'a super::ffi::CompoundSelect,
1690    stmt_result: &'a AnyParsedStatement<'a>,
1691    id: AnyNodeId,
1692}
1693
1694impl std::fmt::Debug for CompoundSelect<'_> {
1695    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1696        self.raw.fmt(f)
1697    }
1698}
1699
1700impl std::fmt::Display for CompoundSelect<'_> {
1701    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1702        AnyNode {
1703            id: self.id,
1704            stmt_result: self.stmt_result,
1705        }
1706        .fmt(f)
1707    }
1708}
1709
1710impl<'a> CompoundSelect<'a> {
1711    /// The typed node ID of this node.
1712    pub fn node_id(&self) -> CompoundSelectId {
1713        CompoundSelectId(self.id)
1714    }
1715    pub fn op(&self) -> CompoundOp {
1716        self.raw.op
1717    }
1718    pub fn left(&self) -> Option<Select<'a>> {
1719        GrammarNodeType::from_result(self.stmt_result, self.raw.left)
1720    }
1721    pub fn right(&self) -> Option<Select<'a>> {
1722        GrammarNodeType::from_result(self.stmt_result, self.raw.right)
1723    }
1724}
1725
1726impl<'a> GrammarNodeType<'a> for CompoundSelect<'a> {
1727    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1728        let raw = stmt_result.resolve_as::<super::ffi::CompoundSelect>(id)?;
1729        Some(CompoundSelect {
1730            raw,
1731            stmt_result,
1732            id,
1733        })
1734    }
1735}
1736
1737#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1738pub struct CompoundSelectId(AnyNodeId);
1739
1740impl CompoundSelectId {
1741    pub fn into_inner(self) -> AnyNodeId {
1742        self.0
1743    }
1744}
1745
1746impl<'a> From<CompoundSelect<'a>> for CompoundSelectId {
1747    fn from(n: CompoundSelect<'a>) -> Self {
1748        n.node_id()
1749    }
1750}
1751
1752impl From<CompoundSelectId> for AnyNodeId {
1753    fn from(id: CompoundSelectId) -> AnyNodeId {
1754        id.0
1755    }
1756}
1757
1758impl TypedNodeId for CompoundSelectId {
1759    type Node<'a> = CompoundSelect<'a>;
1760}
1761
1762#[derive(Clone, Copy)]
1763pub struct SubqueryExpr<'a> {
1764    raw: &'a super::ffi::SubqueryExpr,
1765    stmt_result: &'a AnyParsedStatement<'a>,
1766    id: AnyNodeId,
1767}
1768
1769impl std::fmt::Debug for SubqueryExpr<'_> {
1770    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1771        self.raw.fmt(f)
1772    }
1773}
1774
1775impl std::fmt::Display for SubqueryExpr<'_> {
1776    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1777        AnyNode {
1778            id: self.id,
1779            stmt_result: self.stmt_result,
1780        }
1781        .fmt(f)
1782    }
1783}
1784
1785impl<'a> SubqueryExpr<'a> {
1786    /// The typed node ID of this node.
1787    pub fn node_id(&self) -> SubqueryExprId {
1788        SubqueryExprId(self.id)
1789    }
1790    pub fn select(&self) -> Option<Select<'a>> {
1791        GrammarNodeType::from_result(self.stmt_result, self.raw.select)
1792    }
1793}
1794
1795impl<'a> GrammarNodeType<'a> for SubqueryExpr<'a> {
1796    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1797        let raw = stmt_result.resolve_as::<super::ffi::SubqueryExpr>(id)?;
1798        Some(SubqueryExpr {
1799            raw,
1800            stmt_result,
1801            id,
1802        })
1803    }
1804}
1805
1806#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1807pub struct SubqueryExprId(AnyNodeId);
1808
1809impl SubqueryExprId {
1810    pub fn into_inner(self) -> AnyNodeId {
1811        self.0
1812    }
1813}
1814
1815impl<'a> From<SubqueryExpr<'a>> for SubqueryExprId {
1816    fn from(n: SubqueryExpr<'a>) -> Self {
1817        n.node_id()
1818    }
1819}
1820
1821impl From<SubqueryExprId> for AnyNodeId {
1822    fn from(id: SubqueryExprId) -> AnyNodeId {
1823        id.0
1824    }
1825}
1826
1827impl TypedNodeId for SubqueryExprId {
1828    type Node<'a> = SubqueryExpr<'a>;
1829}
1830
1831#[derive(Clone, Copy)]
1832pub struct ExistsExpr<'a> {
1833    raw: &'a super::ffi::ExistsExpr,
1834    stmt_result: &'a AnyParsedStatement<'a>,
1835    id: AnyNodeId,
1836}
1837
1838impl std::fmt::Debug for ExistsExpr<'_> {
1839    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1840        self.raw.fmt(f)
1841    }
1842}
1843
1844impl std::fmt::Display for ExistsExpr<'_> {
1845    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1846        AnyNode {
1847            id: self.id,
1848            stmt_result: self.stmt_result,
1849        }
1850        .fmt(f)
1851    }
1852}
1853
1854impl<'a> ExistsExpr<'a> {
1855    /// The typed node ID of this node.
1856    pub fn node_id(&self) -> ExistsExprId {
1857        ExistsExprId(self.id)
1858    }
1859    pub fn select(&self) -> Option<Select<'a>> {
1860        GrammarNodeType::from_result(self.stmt_result, self.raw.select)
1861    }
1862}
1863
1864impl<'a> GrammarNodeType<'a> for ExistsExpr<'a> {
1865    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1866        let raw = stmt_result.resolve_as::<super::ffi::ExistsExpr>(id)?;
1867        Some(ExistsExpr {
1868            raw,
1869            stmt_result,
1870            id,
1871        })
1872    }
1873}
1874
1875#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1876pub struct ExistsExprId(AnyNodeId);
1877
1878impl ExistsExprId {
1879    pub fn into_inner(self) -> AnyNodeId {
1880        self.0
1881    }
1882}
1883
1884impl<'a> From<ExistsExpr<'a>> for ExistsExprId {
1885    fn from(n: ExistsExpr<'a>) -> Self {
1886        n.node_id()
1887    }
1888}
1889
1890impl From<ExistsExprId> for AnyNodeId {
1891    fn from(id: ExistsExprId) -> AnyNodeId {
1892        id.0
1893    }
1894}
1895
1896impl TypedNodeId for ExistsExprId {
1897    type Node<'a> = ExistsExpr<'a>;
1898}
1899
1900#[derive(Clone, Copy)]
1901pub struct InExpr<'a> {
1902    raw: &'a super::ffi::InExpr,
1903    stmt_result: &'a AnyParsedStatement<'a>,
1904    id: AnyNodeId,
1905}
1906
1907impl std::fmt::Debug for InExpr<'_> {
1908    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1909        self.raw.fmt(f)
1910    }
1911}
1912
1913impl std::fmt::Display for InExpr<'_> {
1914    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1915        AnyNode {
1916            id: self.id,
1917            stmt_result: self.stmt_result,
1918        }
1919        .fmt(f)
1920    }
1921}
1922
1923impl<'a> InExpr<'a> {
1924    /// The typed node ID of this node.
1925    pub fn node_id(&self) -> InExprId {
1926        InExprId(self.id)
1927    }
1928    pub fn negated(&self) -> bool {
1929        self.raw.negated == super::ffi::Bool::True
1930    }
1931    pub fn operand(&self) -> Option<Expr<'a>> {
1932        GrammarNodeType::from_result(self.stmt_result, self.raw.operand)
1933    }
1934    pub fn source(&self) -> Option<InExprSource<'a>> {
1935        GrammarNodeType::from_result(self.stmt_result, self.raw.source)
1936    }
1937}
1938
1939impl<'a> GrammarNodeType<'a> for InExpr<'a> {
1940    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
1941        let raw = stmt_result.resolve_as::<super::ffi::InExpr>(id)?;
1942        Some(InExpr {
1943            raw,
1944            stmt_result,
1945            id,
1946        })
1947    }
1948}
1949
1950#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1951pub struct InExprId(AnyNodeId);
1952
1953impl InExprId {
1954    pub fn into_inner(self) -> AnyNodeId {
1955        self.0
1956    }
1957}
1958
1959impl<'a> From<InExpr<'a>> for InExprId {
1960    fn from(n: InExpr<'a>) -> Self {
1961        n.node_id()
1962    }
1963}
1964
1965impl From<InExprId> for AnyNodeId {
1966    fn from(id: InExprId) -> AnyNodeId {
1967        id.0
1968    }
1969}
1970
1971impl TypedNodeId for InExprId {
1972    type Node<'a> = InExpr<'a>;
1973}
1974
1975#[derive(Clone, Copy)]
1976pub struct IsExpr<'a> {
1977    raw: &'a super::ffi::IsExpr,
1978    stmt_result: &'a AnyParsedStatement<'a>,
1979    id: AnyNodeId,
1980}
1981
1982impl std::fmt::Debug for IsExpr<'_> {
1983    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1984        self.raw.fmt(f)
1985    }
1986}
1987
1988impl std::fmt::Display for IsExpr<'_> {
1989    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1990        AnyNode {
1991            id: self.id,
1992            stmt_result: self.stmt_result,
1993        }
1994        .fmt(f)
1995    }
1996}
1997
1998impl<'a> IsExpr<'a> {
1999    /// The typed node ID of this node.
2000    pub fn node_id(&self) -> IsExprId {
2001        IsExprId(self.id)
2002    }
2003    pub fn op(&self) -> IsOp {
2004        self.raw.op
2005    }
2006    pub fn left(&self) -> Option<Expr<'a>> {
2007        GrammarNodeType::from_result(self.stmt_result, self.raw.left)
2008    }
2009    pub fn right(&self) -> Option<Expr<'a>> {
2010        GrammarNodeType::from_result(self.stmt_result, self.raw.right)
2011    }
2012}
2013
2014impl<'a> GrammarNodeType<'a> for IsExpr<'a> {
2015    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2016        let raw = stmt_result.resolve_as::<super::ffi::IsExpr>(id)?;
2017        Some(IsExpr {
2018            raw,
2019            stmt_result,
2020            id,
2021        })
2022    }
2023}
2024
2025#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2026pub struct IsExprId(AnyNodeId);
2027
2028impl IsExprId {
2029    pub fn into_inner(self) -> AnyNodeId {
2030        self.0
2031    }
2032}
2033
2034impl<'a> From<IsExpr<'a>> for IsExprId {
2035    fn from(n: IsExpr<'a>) -> Self {
2036        n.node_id()
2037    }
2038}
2039
2040impl From<IsExprId> for AnyNodeId {
2041    fn from(id: IsExprId) -> AnyNodeId {
2042        id.0
2043    }
2044}
2045
2046impl TypedNodeId for IsExprId {
2047    type Node<'a> = IsExpr<'a>;
2048}
2049
2050#[derive(Clone, Copy)]
2051pub struct BetweenExpr<'a> {
2052    raw: &'a super::ffi::BetweenExpr,
2053    stmt_result: &'a AnyParsedStatement<'a>,
2054    id: AnyNodeId,
2055}
2056
2057impl std::fmt::Debug for BetweenExpr<'_> {
2058    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2059        self.raw.fmt(f)
2060    }
2061}
2062
2063impl std::fmt::Display for BetweenExpr<'_> {
2064    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2065        AnyNode {
2066            id: self.id,
2067            stmt_result: self.stmt_result,
2068        }
2069        .fmt(f)
2070    }
2071}
2072
2073impl<'a> BetweenExpr<'a> {
2074    /// The typed node ID of this node.
2075    pub fn node_id(&self) -> BetweenExprId {
2076        BetweenExprId(self.id)
2077    }
2078    pub fn negated(&self) -> bool {
2079        self.raw.negated == super::ffi::Bool::True
2080    }
2081    pub fn operand(&self) -> Option<Expr<'a>> {
2082        GrammarNodeType::from_result(self.stmt_result, self.raw.operand)
2083    }
2084    pub fn low(&self) -> Option<Expr<'a>> {
2085        GrammarNodeType::from_result(self.stmt_result, self.raw.low)
2086    }
2087    pub fn high(&self) -> Option<Expr<'a>> {
2088        GrammarNodeType::from_result(self.stmt_result, self.raw.high)
2089    }
2090}
2091
2092impl<'a> GrammarNodeType<'a> for BetweenExpr<'a> {
2093    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2094        let raw = stmt_result.resolve_as::<super::ffi::BetweenExpr>(id)?;
2095        Some(BetweenExpr {
2096            raw,
2097            stmt_result,
2098            id,
2099        })
2100    }
2101}
2102
2103#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2104pub struct BetweenExprId(AnyNodeId);
2105
2106impl BetweenExprId {
2107    pub fn into_inner(self) -> AnyNodeId {
2108        self.0
2109    }
2110}
2111
2112impl<'a> From<BetweenExpr<'a>> for BetweenExprId {
2113    fn from(n: BetweenExpr<'a>) -> Self {
2114        n.node_id()
2115    }
2116}
2117
2118impl From<BetweenExprId> for AnyNodeId {
2119    fn from(id: BetweenExprId) -> AnyNodeId {
2120        id.0
2121    }
2122}
2123
2124impl TypedNodeId for BetweenExprId {
2125    type Node<'a> = BetweenExpr<'a>;
2126}
2127
2128#[derive(Clone, Copy)]
2129pub struct LikeExpr<'a> {
2130    raw: &'a super::ffi::LikeExpr,
2131    stmt_result: &'a AnyParsedStatement<'a>,
2132    id: AnyNodeId,
2133}
2134
2135impl std::fmt::Debug for LikeExpr<'_> {
2136    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2137        self.raw.fmt(f)
2138    }
2139}
2140
2141impl std::fmt::Display for LikeExpr<'_> {
2142    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2143        AnyNode {
2144            id: self.id,
2145            stmt_result: self.stmt_result,
2146        }
2147        .fmt(f)
2148    }
2149}
2150
2151impl<'a> LikeExpr<'a> {
2152    /// The typed node ID of this node.
2153    pub fn node_id(&self) -> LikeExprId {
2154        LikeExprId(self.id)
2155    }
2156    pub fn negated(&self) -> bool {
2157        self.raw.negated == super::ffi::Bool::True
2158    }
2159    pub fn keyword(&self) -> LikeKeyword {
2160        self.raw.keyword
2161    }
2162    pub fn operand(&self) -> Option<Expr<'a>> {
2163        GrammarNodeType::from_result(self.stmt_result, self.raw.operand)
2164    }
2165    pub fn pattern(&self) -> Option<Expr<'a>> {
2166        GrammarNodeType::from_result(self.stmt_result, self.raw.pattern)
2167    }
2168    pub fn escape(&self) -> Option<Expr<'a>> {
2169        GrammarNodeType::from_result(self.stmt_result, self.raw.escape)
2170    }
2171}
2172
2173impl<'a> GrammarNodeType<'a> for LikeExpr<'a> {
2174    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2175        let raw = stmt_result.resolve_as::<super::ffi::LikeExpr>(id)?;
2176        Some(LikeExpr {
2177            raw,
2178            stmt_result,
2179            id,
2180        })
2181    }
2182}
2183
2184#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2185pub struct LikeExprId(AnyNodeId);
2186
2187impl LikeExprId {
2188    pub fn into_inner(self) -> AnyNodeId {
2189        self.0
2190    }
2191}
2192
2193impl<'a> From<LikeExpr<'a>> for LikeExprId {
2194    fn from(n: LikeExpr<'a>) -> Self {
2195        n.node_id()
2196    }
2197}
2198
2199impl From<LikeExprId> for AnyNodeId {
2200    fn from(id: LikeExprId) -> AnyNodeId {
2201        id.0
2202    }
2203}
2204
2205impl TypedNodeId for LikeExprId {
2206    type Node<'a> = LikeExpr<'a>;
2207}
2208
2209#[derive(Clone, Copy)]
2210pub struct CaseExpr<'a> {
2211    raw: &'a super::ffi::CaseExpr,
2212    stmt_result: &'a AnyParsedStatement<'a>,
2213    id: AnyNodeId,
2214}
2215
2216impl std::fmt::Debug for CaseExpr<'_> {
2217    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2218        self.raw.fmt(f)
2219    }
2220}
2221
2222impl std::fmt::Display for CaseExpr<'_> {
2223    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2224        AnyNode {
2225            id: self.id,
2226            stmt_result: self.stmt_result,
2227        }
2228        .fmt(f)
2229    }
2230}
2231
2232impl<'a> CaseExpr<'a> {
2233    /// The typed node ID of this node.
2234    pub fn node_id(&self) -> CaseExprId {
2235        CaseExprId(self.id)
2236    }
2237    pub fn operand(&self) -> Option<Expr<'a>> {
2238        GrammarNodeType::from_result(self.stmt_result, self.raw.operand)
2239    }
2240    pub fn else_expr(&self) -> Option<Expr<'a>> {
2241        GrammarNodeType::from_result(self.stmt_result, self.raw.else_expr)
2242    }
2243    pub fn whens(&self) -> Option<CaseWhenList<'a>> {
2244        GrammarNodeType::from_result(self.stmt_result, self.raw.whens)
2245    }
2246}
2247
2248impl<'a> GrammarNodeType<'a> for CaseExpr<'a> {
2249    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2250        let raw = stmt_result.resolve_as::<super::ffi::CaseExpr>(id)?;
2251        Some(CaseExpr {
2252            raw,
2253            stmt_result,
2254            id,
2255        })
2256    }
2257}
2258
2259#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2260pub struct CaseExprId(AnyNodeId);
2261
2262impl CaseExprId {
2263    pub fn into_inner(self) -> AnyNodeId {
2264        self.0
2265    }
2266}
2267
2268impl<'a> From<CaseExpr<'a>> for CaseExprId {
2269    fn from(n: CaseExpr<'a>) -> Self {
2270        n.node_id()
2271    }
2272}
2273
2274impl From<CaseExprId> for AnyNodeId {
2275    fn from(id: CaseExprId) -> AnyNodeId {
2276        id.0
2277    }
2278}
2279
2280impl TypedNodeId for CaseExprId {
2281    type Node<'a> = CaseExpr<'a>;
2282}
2283
2284#[derive(Clone, Copy)]
2285pub struct CaseWhen<'a> {
2286    raw: &'a super::ffi::CaseWhen,
2287    stmt_result: &'a AnyParsedStatement<'a>,
2288    id: AnyNodeId,
2289}
2290
2291impl std::fmt::Debug for CaseWhen<'_> {
2292    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2293        self.raw.fmt(f)
2294    }
2295}
2296
2297impl std::fmt::Display for CaseWhen<'_> {
2298    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2299        AnyNode {
2300            id: self.id,
2301            stmt_result: self.stmt_result,
2302        }
2303        .fmt(f)
2304    }
2305}
2306
2307impl<'a> CaseWhen<'a> {
2308    /// The typed node ID of this node.
2309    pub fn node_id(&self) -> CaseWhenId {
2310        CaseWhenId(self.id)
2311    }
2312    pub fn when_expr(&self) -> Option<Expr<'a>> {
2313        GrammarNodeType::from_result(self.stmt_result, self.raw.when_expr)
2314    }
2315    pub fn then_expr(&self) -> Option<Expr<'a>> {
2316        GrammarNodeType::from_result(self.stmt_result, self.raw.then_expr)
2317    }
2318}
2319
2320impl<'a> GrammarNodeType<'a> for CaseWhen<'a> {
2321    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2322        let raw = stmt_result.resolve_as::<super::ffi::CaseWhen>(id)?;
2323        Some(CaseWhen {
2324            raw,
2325            stmt_result,
2326            id,
2327        })
2328    }
2329}
2330
2331#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2332pub struct CaseWhenId(AnyNodeId);
2333
2334impl CaseWhenId {
2335    pub fn into_inner(self) -> AnyNodeId {
2336        self.0
2337    }
2338}
2339
2340impl<'a> From<CaseWhen<'a>> for CaseWhenId {
2341    fn from(n: CaseWhen<'a>) -> Self {
2342        n.node_id()
2343    }
2344}
2345
2346impl From<CaseWhenId> for AnyNodeId {
2347    fn from(id: CaseWhenId) -> AnyNodeId {
2348        id.0
2349    }
2350}
2351
2352impl TypedNodeId for CaseWhenId {
2353    type Node<'a> = CaseWhen<'a>;
2354}
2355
2356#[derive(Clone, Copy)]
2357pub struct ForeignKeyClause<'a> {
2358    raw: &'a super::ffi::ForeignKeyClause,
2359    stmt_result: &'a AnyParsedStatement<'a>,
2360    id: AnyNodeId,
2361}
2362
2363impl std::fmt::Debug for ForeignKeyClause<'_> {
2364    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2365        self.raw.fmt(f)
2366    }
2367}
2368
2369impl std::fmt::Display for ForeignKeyClause<'_> {
2370    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2371        AnyNode {
2372            id: self.id,
2373            stmt_result: self.stmt_result,
2374        }
2375        .fmt(f)
2376    }
2377}
2378
2379impl<'a> ForeignKeyClause<'a> {
2380    /// The typed node ID of this node.
2381    pub fn node_id(&self) -> ForeignKeyClauseId {
2382        ForeignKeyClauseId(self.id)
2383    }
2384    pub fn ref_table(&self) -> &'a str {
2385        self.raw.ref_table.as_str(self.stmt_result.source())
2386    }
2387    pub fn ref_columns(&self) -> Option<ExprList<'a>> {
2388        GrammarNodeType::from_result(self.stmt_result, self.raw.ref_columns)
2389    }
2390    pub fn on_delete(&self) -> ForeignKeyAction {
2391        self.raw.on_delete
2392    }
2393    pub fn on_update(&self) -> ForeignKeyAction {
2394        self.raw.on_update
2395    }
2396    pub fn is_deferred(&self) -> bool {
2397        self.raw.is_deferred == super::ffi::Bool::True
2398    }
2399}
2400
2401impl<'a> GrammarNodeType<'a> for ForeignKeyClause<'a> {
2402    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2403        let raw = stmt_result.resolve_as::<super::ffi::ForeignKeyClause>(id)?;
2404        Some(ForeignKeyClause {
2405            raw,
2406            stmt_result,
2407            id,
2408        })
2409    }
2410}
2411
2412#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2413pub struct ForeignKeyClauseId(AnyNodeId);
2414
2415impl ForeignKeyClauseId {
2416    pub fn into_inner(self) -> AnyNodeId {
2417        self.0
2418    }
2419}
2420
2421impl<'a> From<ForeignKeyClause<'a>> for ForeignKeyClauseId {
2422    fn from(n: ForeignKeyClause<'a>) -> Self {
2423        n.node_id()
2424    }
2425}
2426
2427impl From<ForeignKeyClauseId> for AnyNodeId {
2428    fn from(id: ForeignKeyClauseId) -> AnyNodeId {
2429        id.0
2430    }
2431}
2432
2433impl TypedNodeId for ForeignKeyClauseId {
2434    type Node<'a> = ForeignKeyClause<'a>;
2435}
2436
2437#[derive(Clone, Copy)]
2438pub struct ColumnConstraint<'a> {
2439    raw: &'a super::ffi::ColumnConstraint,
2440    stmt_result: &'a AnyParsedStatement<'a>,
2441    id: AnyNodeId,
2442}
2443
2444impl std::fmt::Debug for ColumnConstraint<'_> {
2445    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2446        self.raw.fmt(f)
2447    }
2448}
2449
2450impl std::fmt::Display for ColumnConstraint<'_> {
2451    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2452        AnyNode {
2453            id: self.id,
2454            stmt_result: self.stmt_result,
2455        }
2456        .fmt(f)
2457    }
2458}
2459
2460impl<'a> ColumnConstraint<'a> {
2461    /// The typed node ID of this node.
2462    pub fn node_id(&self) -> ColumnConstraintId {
2463        ColumnConstraintId(self.id)
2464    }
2465    pub fn kind(&self) -> ColumnConstraintType {
2466        self.raw.kind
2467    }
2468    pub fn constraint_name(&self) -> &'a str {
2469        self.raw.constraint_name.as_str(self.stmt_result.source())
2470    }
2471    pub fn onconf(&self) -> ConflictAction {
2472        self.raw.onconf
2473    }
2474    pub fn sort_order(&self) -> SortOrder {
2475        self.raw.sort_order
2476    }
2477    pub fn is_autoincrement(&self) -> bool {
2478        self.raw.is_autoincrement == super::ffi::Bool::True
2479    }
2480    pub fn collation_name(&self) -> &'a str {
2481        self.raw.collation_name.as_str(self.stmt_result.source())
2482    }
2483    pub fn generated_storage(&self) -> GeneratedColumnStorage {
2484        self.raw.generated_storage
2485    }
2486    pub fn default_expr(&self) -> Option<Expr<'a>> {
2487        GrammarNodeType::from_result(self.stmt_result, self.raw.default_expr)
2488    }
2489    pub fn check_expr(&self) -> Option<Expr<'a>> {
2490        GrammarNodeType::from_result(self.stmt_result, self.raw.check_expr)
2491    }
2492    pub fn generated_expr(&self) -> Option<Expr<'a>> {
2493        GrammarNodeType::from_result(self.stmt_result, self.raw.generated_expr)
2494    }
2495    pub fn fk_clause(&self) -> Option<ForeignKeyClause<'a>> {
2496        GrammarNodeType::from_result(self.stmt_result, self.raw.fk_clause)
2497    }
2498}
2499
2500impl<'a> GrammarNodeType<'a> for ColumnConstraint<'a> {
2501    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2502        let raw = stmt_result.resolve_as::<super::ffi::ColumnConstraint>(id)?;
2503        Some(ColumnConstraint {
2504            raw,
2505            stmt_result,
2506            id,
2507        })
2508    }
2509}
2510
2511#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2512pub struct ColumnConstraintId(AnyNodeId);
2513
2514impl ColumnConstraintId {
2515    pub fn into_inner(self) -> AnyNodeId {
2516        self.0
2517    }
2518}
2519
2520impl<'a> From<ColumnConstraint<'a>> for ColumnConstraintId {
2521    fn from(n: ColumnConstraint<'a>) -> Self {
2522        n.node_id()
2523    }
2524}
2525
2526impl From<ColumnConstraintId> for AnyNodeId {
2527    fn from(id: ColumnConstraintId) -> AnyNodeId {
2528        id.0
2529    }
2530}
2531
2532impl TypedNodeId for ColumnConstraintId {
2533    type Node<'a> = ColumnConstraint<'a>;
2534}
2535
2536#[derive(Clone, Copy)]
2537pub struct ColumnDef<'a> {
2538    raw: &'a super::ffi::ColumnDef,
2539    stmt_result: &'a AnyParsedStatement<'a>,
2540    id: AnyNodeId,
2541}
2542
2543impl std::fmt::Debug for ColumnDef<'_> {
2544    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2545        self.raw.fmt(f)
2546    }
2547}
2548
2549impl std::fmt::Display for ColumnDef<'_> {
2550    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2551        AnyNode {
2552            id: self.id,
2553            stmt_result: self.stmt_result,
2554        }
2555        .fmt(f)
2556    }
2557}
2558
2559impl<'a> ColumnDef<'a> {
2560    /// The typed node ID of this node.
2561    pub fn node_id(&self) -> ColumnDefId {
2562        ColumnDefId(self.id)
2563    }
2564    pub fn column_name(&self) -> Option<Name<'a>> {
2565        GrammarNodeType::from_result(self.stmt_result, self.raw.column_name)
2566    }
2567    pub fn type_name(&self) -> &'a str {
2568        self.raw.type_name.as_str(self.stmt_result.source())
2569    }
2570    pub fn constraints(&self) -> Option<ColumnConstraintList<'a>> {
2571        GrammarNodeType::from_result(self.stmt_result, self.raw.constraints)
2572    }
2573}
2574
2575impl<'a> GrammarNodeType<'a> for ColumnDef<'a> {
2576    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2577        let raw = stmt_result.resolve_as::<super::ffi::ColumnDef>(id)?;
2578        Some(ColumnDef {
2579            raw,
2580            stmt_result,
2581            id,
2582        })
2583    }
2584}
2585
2586#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2587pub struct ColumnDefId(AnyNodeId);
2588
2589impl ColumnDefId {
2590    pub fn into_inner(self) -> AnyNodeId {
2591        self.0
2592    }
2593}
2594
2595impl<'a> From<ColumnDef<'a>> for ColumnDefId {
2596    fn from(n: ColumnDef<'a>) -> Self {
2597        n.node_id()
2598    }
2599}
2600
2601impl From<ColumnDefId> for AnyNodeId {
2602    fn from(id: ColumnDefId) -> AnyNodeId {
2603        id.0
2604    }
2605}
2606
2607impl TypedNodeId for ColumnDefId {
2608    type Node<'a> = ColumnDef<'a>;
2609}
2610
2611#[derive(Clone, Copy)]
2612pub struct TableConstraint<'a> {
2613    raw: &'a super::ffi::TableConstraint,
2614    stmt_result: &'a AnyParsedStatement<'a>,
2615    id: AnyNodeId,
2616}
2617
2618impl std::fmt::Debug for TableConstraint<'_> {
2619    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2620        self.raw.fmt(f)
2621    }
2622}
2623
2624impl std::fmt::Display for TableConstraint<'_> {
2625    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2626        AnyNode {
2627            id: self.id,
2628            stmt_result: self.stmt_result,
2629        }
2630        .fmt(f)
2631    }
2632}
2633
2634impl<'a> TableConstraint<'a> {
2635    /// The typed node ID of this node.
2636    pub fn node_id(&self) -> TableConstraintId {
2637        TableConstraintId(self.id)
2638    }
2639    pub fn kind(&self) -> TableConstraintType {
2640        self.raw.kind
2641    }
2642    pub fn constraint_name(&self) -> &'a str {
2643        self.raw.constraint_name.as_str(self.stmt_result.source())
2644    }
2645    pub fn onconf(&self) -> ConflictAction {
2646        self.raw.onconf
2647    }
2648    pub fn is_autoincrement(&self) -> bool {
2649        self.raw.is_autoincrement == super::ffi::Bool::True
2650    }
2651    pub fn pk_columns(&self) -> Option<OrderByList<'a>> {
2652        GrammarNodeType::from_result(self.stmt_result, self.raw.pk_columns)
2653    }
2654    pub fn fk_columns(&self) -> Option<ExprList<'a>> {
2655        GrammarNodeType::from_result(self.stmt_result, self.raw.fk_columns)
2656    }
2657    pub fn check_expr(&self) -> Option<Expr<'a>> {
2658        GrammarNodeType::from_result(self.stmt_result, self.raw.check_expr)
2659    }
2660    pub fn fk_clause(&self) -> Option<ForeignKeyClause<'a>> {
2661        GrammarNodeType::from_result(self.stmt_result, self.raw.fk_clause)
2662    }
2663}
2664
2665impl<'a> GrammarNodeType<'a> for TableConstraint<'a> {
2666    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2667        let raw = stmt_result.resolve_as::<super::ffi::TableConstraint>(id)?;
2668        Some(TableConstraint {
2669            raw,
2670            stmt_result,
2671            id,
2672        })
2673    }
2674}
2675
2676#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2677pub struct TableConstraintId(AnyNodeId);
2678
2679impl TableConstraintId {
2680    pub fn into_inner(self) -> AnyNodeId {
2681        self.0
2682    }
2683}
2684
2685impl<'a> From<TableConstraint<'a>> for TableConstraintId {
2686    fn from(n: TableConstraint<'a>) -> Self {
2687        n.node_id()
2688    }
2689}
2690
2691impl From<TableConstraintId> for AnyNodeId {
2692    fn from(id: TableConstraintId) -> AnyNodeId {
2693        id.0
2694    }
2695}
2696
2697impl TypedNodeId for TableConstraintId {
2698    type Node<'a> = TableConstraint<'a>;
2699}
2700
2701#[derive(Clone, Copy)]
2702pub struct CreateTableStmt<'a> {
2703    raw: &'a super::ffi::CreateTableStmt,
2704    stmt_result: &'a AnyParsedStatement<'a>,
2705    id: AnyNodeId,
2706}
2707
2708impl std::fmt::Debug for CreateTableStmt<'_> {
2709    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2710        self.raw.fmt(f)
2711    }
2712}
2713
2714impl std::fmt::Display for CreateTableStmt<'_> {
2715    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2716        AnyNode {
2717            id: self.id,
2718            stmt_result: self.stmt_result,
2719        }
2720        .fmt(f)
2721    }
2722}
2723
2724impl<'a> CreateTableStmt<'a> {
2725    /// The typed node ID of this node.
2726    pub fn node_id(&self) -> CreateTableStmtId {
2727        CreateTableStmtId(self.id)
2728    }
2729    pub fn table_name(&self) -> &'a str {
2730        self.raw.table_name.as_str(self.stmt_result.source())
2731    }
2732    pub fn schema(&self) -> &'a str {
2733        self.raw.schema.as_str(self.stmt_result.source())
2734    }
2735    pub fn is_temp(&self) -> bool {
2736        self.raw.is_temp == super::ffi::Bool::True
2737    }
2738    pub fn if_not_exists(&self) -> bool {
2739        self.raw.if_not_exists == super::ffi::Bool::True
2740    }
2741    pub fn flags(&self) -> CreateTableStmtFlags {
2742        self.raw.flags
2743    }
2744    pub fn columns(&self) -> Option<ColumnDefList<'a>> {
2745        GrammarNodeType::from_result(self.stmt_result, self.raw.columns)
2746    }
2747    pub fn table_constraints(&self) -> Option<TableConstraintList<'a>> {
2748        GrammarNodeType::from_result(self.stmt_result, self.raw.table_constraints)
2749    }
2750    pub fn as_select(&self) -> Option<Select<'a>> {
2751        GrammarNodeType::from_result(self.stmt_result, self.raw.as_select)
2752    }
2753}
2754
2755impl<'a> GrammarNodeType<'a> for CreateTableStmt<'a> {
2756    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2757        let raw = stmt_result.resolve_as::<super::ffi::CreateTableStmt>(id)?;
2758        Some(CreateTableStmt {
2759            raw,
2760            stmt_result,
2761            id,
2762        })
2763    }
2764}
2765
2766#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2767pub struct CreateTableStmtId(AnyNodeId);
2768
2769impl CreateTableStmtId {
2770    pub fn into_inner(self) -> AnyNodeId {
2771        self.0
2772    }
2773}
2774
2775impl<'a> From<CreateTableStmt<'a>> for CreateTableStmtId {
2776    fn from(n: CreateTableStmt<'a>) -> Self {
2777        n.node_id()
2778    }
2779}
2780
2781impl From<CreateTableStmtId> for AnyNodeId {
2782    fn from(id: CreateTableStmtId) -> AnyNodeId {
2783        id.0
2784    }
2785}
2786
2787impl TypedNodeId for CreateTableStmtId {
2788    type Node<'a> = CreateTableStmt<'a>;
2789}
2790
2791#[derive(Clone, Copy)]
2792pub struct CteDefinition<'a> {
2793    raw: &'a super::ffi::CteDefinition,
2794    stmt_result: &'a AnyParsedStatement<'a>,
2795    id: AnyNodeId,
2796}
2797
2798impl std::fmt::Debug for CteDefinition<'_> {
2799    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2800        self.raw.fmt(f)
2801    }
2802}
2803
2804impl std::fmt::Display for CteDefinition<'_> {
2805    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2806        AnyNode {
2807            id: self.id,
2808            stmt_result: self.stmt_result,
2809        }
2810        .fmt(f)
2811    }
2812}
2813
2814impl<'a> CteDefinition<'a> {
2815    /// The typed node ID of this node.
2816    pub fn node_id(&self) -> CteDefinitionId {
2817        CteDefinitionId(self.id)
2818    }
2819    pub fn cte_name(&self) -> &'a str {
2820        self.raw.cte_name.as_str(self.stmt_result.source())
2821    }
2822    pub fn materialized(&self) -> Materialized {
2823        self.raw.materialized
2824    }
2825    pub fn columns(&self) -> Option<ExprList<'a>> {
2826        GrammarNodeType::from_result(self.stmt_result, self.raw.columns)
2827    }
2828    pub fn select(&self) -> Option<Select<'a>> {
2829        GrammarNodeType::from_result(self.stmt_result, self.raw.select)
2830    }
2831}
2832
2833impl<'a> GrammarNodeType<'a> for CteDefinition<'a> {
2834    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2835        let raw = stmt_result.resolve_as::<super::ffi::CteDefinition>(id)?;
2836        Some(CteDefinition {
2837            raw,
2838            stmt_result,
2839            id,
2840        })
2841    }
2842}
2843
2844#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2845pub struct CteDefinitionId(AnyNodeId);
2846
2847impl CteDefinitionId {
2848    pub fn into_inner(self) -> AnyNodeId {
2849        self.0
2850    }
2851}
2852
2853impl<'a> From<CteDefinition<'a>> for CteDefinitionId {
2854    fn from(n: CteDefinition<'a>) -> Self {
2855        n.node_id()
2856    }
2857}
2858
2859impl From<CteDefinitionId> for AnyNodeId {
2860    fn from(id: CteDefinitionId) -> AnyNodeId {
2861        id.0
2862    }
2863}
2864
2865impl TypedNodeId for CteDefinitionId {
2866    type Node<'a> = CteDefinition<'a>;
2867}
2868
2869#[derive(Clone, Copy)]
2870pub struct WithClause<'a> {
2871    raw: &'a super::ffi::WithClause,
2872    stmt_result: &'a AnyParsedStatement<'a>,
2873    id: AnyNodeId,
2874}
2875
2876impl std::fmt::Debug for WithClause<'_> {
2877    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2878        self.raw.fmt(f)
2879    }
2880}
2881
2882impl std::fmt::Display for WithClause<'_> {
2883    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2884        AnyNode {
2885            id: self.id,
2886            stmt_result: self.stmt_result,
2887        }
2888        .fmt(f)
2889    }
2890}
2891
2892impl<'a> WithClause<'a> {
2893    /// The typed node ID of this node.
2894    pub fn node_id(&self) -> WithClauseId {
2895        WithClauseId(self.id)
2896    }
2897    pub fn recursive(&self) -> bool {
2898        self.raw.recursive == super::ffi::Bool::True
2899    }
2900    pub fn ctes(&self) -> Option<CteList<'a>> {
2901        GrammarNodeType::from_result(self.stmt_result, self.raw.ctes)
2902    }
2903    pub fn select(&self) -> Option<Select<'a>> {
2904        GrammarNodeType::from_result(self.stmt_result, self.raw.select)
2905    }
2906}
2907
2908impl<'a> GrammarNodeType<'a> for WithClause<'a> {
2909    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2910        let raw = stmt_result.resolve_as::<super::ffi::WithClause>(id)?;
2911        Some(WithClause {
2912            raw,
2913            stmt_result,
2914            id,
2915        })
2916    }
2917}
2918
2919#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
2920pub struct WithClauseId(AnyNodeId);
2921
2922impl WithClauseId {
2923    pub fn into_inner(self) -> AnyNodeId {
2924        self.0
2925    }
2926}
2927
2928impl<'a> From<WithClause<'a>> for WithClauseId {
2929    fn from(n: WithClause<'a>) -> Self {
2930        n.node_id()
2931    }
2932}
2933
2934impl From<WithClauseId> for AnyNodeId {
2935    fn from(id: WithClauseId) -> AnyNodeId {
2936        id.0
2937    }
2938}
2939
2940impl TypedNodeId for WithClauseId {
2941    type Node<'a> = WithClause<'a>;
2942}
2943
2944#[derive(Clone, Copy)]
2945pub struct UpsertClause<'a> {
2946    raw: &'a super::ffi::UpsertClause,
2947    stmt_result: &'a AnyParsedStatement<'a>,
2948    id: AnyNodeId,
2949}
2950
2951impl std::fmt::Debug for UpsertClause<'_> {
2952    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2953        self.raw.fmt(f)
2954    }
2955}
2956
2957impl std::fmt::Display for UpsertClause<'_> {
2958    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2959        AnyNode {
2960            id: self.id,
2961            stmt_result: self.stmt_result,
2962        }
2963        .fmt(f)
2964    }
2965}
2966
2967impl<'a> UpsertClause<'a> {
2968    /// The typed node ID of this node.
2969    pub fn node_id(&self) -> UpsertClauseId {
2970        UpsertClauseId(self.id)
2971    }
2972    pub fn columns(&self) -> Option<OrderByList<'a>> {
2973        GrammarNodeType::from_result(self.stmt_result, self.raw.columns)
2974    }
2975    pub fn target_where(&self) -> Option<Expr<'a>> {
2976        GrammarNodeType::from_result(self.stmt_result, self.raw.target_where)
2977    }
2978    pub fn action(&self) -> UpsertAction {
2979        self.raw.action
2980    }
2981    pub fn setlist(&self) -> Option<SetClauseList<'a>> {
2982        GrammarNodeType::from_result(self.stmt_result, self.raw.setlist)
2983    }
2984    pub fn update_where(&self) -> Option<Expr<'a>> {
2985        GrammarNodeType::from_result(self.stmt_result, self.raw.update_where)
2986    }
2987}
2988
2989impl<'a> GrammarNodeType<'a> for UpsertClause<'a> {
2990    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
2991        let raw = stmt_result.resolve_as::<super::ffi::UpsertClause>(id)?;
2992        Some(UpsertClause {
2993            raw,
2994            stmt_result,
2995            id,
2996        })
2997    }
2998}
2999
3000#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3001pub struct UpsertClauseId(AnyNodeId);
3002
3003impl UpsertClauseId {
3004    pub fn into_inner(self) -> AnyNodeId {
3005        self.0
3006    }
3007}
3008
3009impl<'a> From<UpsertClause<'a>> for UpsertClauseId {
3010    fn from(n: UpsertClause<'a>) -> Self {
3011        n.node_id()
3012    }
3013}
3014
3015impl From<UpsertClauseId> for AnyNodeId {
3016    fn from(id: UpsertClauseId) -> AnyNodeId {
3017        id.0
3018    }
3019}
3020
3021impl TypedNodeId for UpsertClauseId {
3022    type Node<'a> = UpsertClause<'a>;
3023}
3024
3025#[derive(Clone, Copy)]
3026pub struct DeleteStmt<'a> {
3027    raw: &'a super::ffi::DeleteStmt,
3028    stmt_result: &'a AnyParsedStatement<'a>,
3029    id: AnyNodeId,
3030}
3031
3032impl std::fmt::Debug for DeleteStmt<'_> {
3033    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3034        self.raw.fmt(f)
3035    }
3036}
3037
3038impl std::fmt::Display for DeleteStmt<'_> {
3039    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3040        AnyNode {
3041            id: self.id,
3042            stmt_result: self.stmt_result,
3043        }
3044        .fmt(f)
3045    }
3046}
3047
3048impl<'a> DeleteStmt<'a> {
3049    /// The typed node ID of this node.
3050    pub fn node_id(&self) -> DeleteStmtId {
3051        DeleteStmtId(self.id)
3052    }
3053    pub fn table(&self) -> Option<TableRef<'a>> {
3054        GrammarNodeType::from_result(self.stmt_result, self.raw.table)
3055    }
3056    pub fn index_hint(&self) -> IndexHint {
3057        self.raw.index_hint
3058    }
3059    pub fn index_name(&self) -> &'a str {
3060        self.raw.index_name.as_str(self.stmt_result.source())
3061    }
3062    pub fn where_clause(&self) -> Option<Expr<'a>> {
3063        GrammarNodeType::from_result(self.stmt_result, self.raw.where_clause)
3064    }
3065    pub fn orderby(&self) -> Option<OrderByList<'a>> {
3066        GrammarNodeType::from_result(self.stmt_result, self.raw.orderby)
3067    }
3068    pub fn limit_clause(&self) -> Option<LimitClause<'a>> {
3069        GrammarNodeType::from_result(self.stmt_result, self.raw.limit_clause)
3070    }
3071    pub fn returning(&self) -> Option<ResultColumnList<'a>> {
3072        GrammarNodeType::from_result(self.stmt_result, self.raw.returning)
3073    }
3074}
3075
3076impl<'a> GrammarNodeType<'a> for DeleteStmt<'a> {
3077    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3078        let raw = stmt_result.resolve_as::<super::ffi::DeleteStmt>(id)?;
3079        Some(DeleteStmt {
3080            raw,
3081            stmt_result,
3082            id,
3083        })
3084    }
3085}
3086
3087#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3088pub struct DeleteStmtId(AnyNodeId);
3089
3090impl DeleteStmtId {
3091    pub fn into_inner(self) -> AnyNodeId {
3092        self.0
3093    }
3094}
3095
3096impl<'a> From<DeleteStmt<'a>> for DeleteStmtId {
3097    fn from(n: DeleteStmt<'a>) -> Self {
3098        n.node_id()
3099    }
3100}
3101
3102impl From<DeleteStmtId> for AnyNodeId {
3103    fn from(id: DeleteStmtId) -> AnyNodeId {
3104        id.0
3105    }
3106}
3107
3108impl TypedNodeId for DeleteStmtId {
3109    type Node<'a> = DeleteStmt<'a>;
3110}
3111
3112#[derive(Clone, Copy)]
3113pub struct SetClause<'a> {
3114    raw: &'a super::ffi::SetClause,
3115    stmt_result: &'a AnyParsedStatement<'a>,
3116    id: AnyNodeId,
3117}
3118
3119impl std::fmt::Debug for SetClause<'_> {
3120    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3121        self.raw.fmt(f)
3122    }
3123}
3124
3125impl std::fmt::Display for SetClause<'_> {
3126    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3127        AnyNode {
3128            id: self.id,
3129            stmt_result: self.stmt_result,
3130        }
3131        .fmt(f)
3132    }
3133}
3134
3135impl<'a> SetClause<'a> {
3136    /// The typed node ID of this node.
3137    pub fn node_id(&self) -> SetClauseId {
3138        SetClauseId(self.id)
3139    }
3140    pub fn column(&self) -> &'a str {
3141        self.raw.column.as_str(self.stmt_result.source())
3142    }
3143    pub fn columns(&self) -> Option<ExprList<'a>> {
3144        GrammarNodeType::from_result(self.stmt_result, self.raw.columns)
3145    }
3146    pub fn value(&self) -> Option<Expr<'a>> {
3147        GrammarNodeType::from_result(self.stmt_result, self.raw.value)
3148    }
3149}
3150
3151impl<'a> GrammarNodeType<'a> for SetClause<'a> {
3152    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3153        let raw = stmt_result.resolve_as::<super::ffi::SetClause>(id)?;
3154        Some(SetClause {
3155            raw,
3156            stmt_result,
3157            id,
3158        })
3159    }
3160}
3161
3162#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3163pub struct SetClauseId(AnyNodeId);
3164
3165impl SetClauseId {
3166    pub fn into_inner(self) -> AnyNodeId {
3167        self.0
3168    }
3169}
3170
3171impl<'a> From<SetClause<'a>> for SetClauseId {
3172    fn from(n: SetClause<'a>) -> Self {
3173        n.node_id()
3174    }
3175}
3176
3177impl From<SetClauseId> for AnyNodeId {
3178    fn from(id: SetClauseId) -> AnyNodeId {
3179        id.0
3180    }
3181}
3182
3183impl TypedNodeId for SetClauseId {
3184    type Node<'a> = SetClause<'a>;
3185}
3186
3187#[derive(Clone, Copy)]
3188pub struct UpdateStmt<'a> {
3189    raw: &'a super::ffi::UpdateStmt,
3190    stmt_result: &'a AnyParsedStatement<'a>,
3191    id: AnyNodeId,
3192}
3193
3194impl std::fmt::Debug for UpdateStmt<'_> {
3195    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3196        self.raw.fmt(f)
3197    }
3198}
3199
3200impl std::fmt::Display for UpdateStmt<'_> {
3201    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3202        AnyNode {
3203            id: self.id,
3204            stmt_result: self.stmt_result,
3205        }
3206        .fmt(f)
3207    }
3208}
3209
3210impl<'a> UpdateStmt<'a> {
3211    /// The typed node ID of this node.
3212    pub fn node_id(&self) -> UpdateStmtId {
3213        UpdateStmtId(self.id)
3214    }
3215    pub fn conflict_action(&self) -> ConflictAction {
3216        self.raw.conflict_action
3217    }
3218    pub fn table(&self) -> Option<TableRef<'a>> {
3219        GrammarNodeType::from_result(self.stmt_result, self.raw.table)
3220    }
3221    pub fn index_hint(&self) -> IndexHint {
3222        self.raw.index_hint
3223    }
3224    pub fn index_name(&self) -> &'a str {
3225        self.raw.index_name.as_str(self.stmt_result.source())
3226    }
3227    pub fn setlist(&self) -> Option<SetClauseList<'a>> {
3228        GrammarNodeType::from_result(self.stmt_result, self.raw.setlist)
3229    }
3230    pub fn from_clause(&self) -> Option<TableSource<'a>> {
3231        GrammarNodeType::from_result(self.stmt_result, self.raw.from_clause)
3232    }
3233    pub fn where_clause(&self) -> Option<Expr<'a>> {
3234        GrammarNodeType::from_result(self.stmt_result, self.raw.where_clause)
3235    }
3236    pub fn orderby(&self) -> Option<OrderByList<'a>> {
3237        GrammarNodeType::from_result(self.stmt_result, self.raw.orderby)
3238    }
3239    pub fn limit_clause(&self) -> Option<LimitClause<'a>> {
3240        GrammarNodeType::from_result(self.stmt_result, self.raw.limit_clause)
3241    }
3242    pub fn returning(&self) -> Option<ResultColumnList<'a>> {
3243        GrammarNodeType::from_result(self.stmt_result, self.raw.returning)
3244    }
3245}
3246
3247impl<'a> GrammarNodeType<'a> for UpdateStmt<'a> {
3248    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3249        let raw = stmt_result.resolve_as::<super::ffi::UpdateStmt>(id)?;
3250        Some(UpdateStmt {
3251            raw,
3252            stmt_result,
3253            id,
3254        })
3255    }
3256}
3257
3258#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3259pub struct UpdateStmtId(AnyNodeId);
3260
3261impl UpdateStmtId {
3262    pub fn into_inner(self) -> AnyNodeId {
3263        self.0
3264    }
3265}
3266
3267impl<'a> From<UpdateStmt<'a>> for UpdateStmtId {
3268    fn from(n: UpdateStmt<'a>) -> Self {
3269        n.node_id()
3270    }
3271}
3272
3273impl From<UpdateStmtId> for AnyNodeId {
3274    fn from(id: UpdateStmtId) -> AnyNodeId {
3275        id.0
3276    }
3277}
3278
3279impl TypedNodeId for UpdateStmtId {
3280    type Node<'a> = UpdateStmt<'a>;
3281}
3282
3283#[derive(Clone, Copy)]
3284pub struct InsertStmt<'a> {
3285    raw: &'a super::ffi::InsertStmt,
3286    stmt_result: &'a AnyParsedStatement<'a>,
3287    id: AnyNodeId,
3288}
3289
3290impl std::fmt::Debug for InsertStmt<'_> {
3291    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3292        self.raw.fmt(f)
3293    }
3294}
3295
3296impl std::fmt::Display for InsertStmt<'_> {
3297    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3298        AnyNode {
3299            id: self.id,
3300            stmt_result: self.stmt_result,
3301        }
3302        .fmt(f)
3303    }
3304}
3305
3306impl<'a> InsertStmt<'a> {
3307    /// The typed node ID of this node.
3308    pub fn node_id(&self) -> InsertStmtId {
3309        InsertStmtId(self.id)
3310    }
3311    pub fn conflict_action(&self) -> ConflictAction {
3312        self.raw.conflict_action
3313    }
3314    pub fn table(&self) -> Option<TableRef<'a>> {
3315        GrammarNodeType::from_result(self.stmt_result, self.raw.table)
3316    }
3317    pub fn columns(&self) -> Option<ExprList<'a>> {
3318        GrammarNodeType::from_result(self.stmt_result, self.raw.columns)
3319    }
3320    pub fn source(&self) -> Option<Select<'a>> {
3321        GrammarNodeType::from_result(self.stmt_result, self.raw.source)
3322    }
3323    pub fn upsert(&self) -> Option<UpsertClauseList<'a>> {
3324        GrammarNodeType::from_result(self.stmt_result, self.raw.upsert)
3325    }
3326    pub fn returning(&self) -> Option<ResultColumnList<'a>> {
3327        GrammarNodeType::from_result(self.stmt_result, self.raw.returning)
3328    }
3329}
3330
3331impl<'a> GrammarNodeType<'a> for InsertStmt<'a> {
3332    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3333        let raw = stmt_result.resolve_as::<super::ffi::InsertStmt>(id)?;
3334        Some(InsertStmt {
3335            raw,
3336            stmt_result,
3337            id,
3338        })
3339    }
3340}
3341
3342#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3343pub struct InsertStmtId(AnyNodeId);
3344
3345impl InsertStmtId {
3346    pub fn into_inner(self) -> AnyNodeId {
3347        self.0
3348    }
3349}
3350
3351impl<'a> From<InsertStmt<'a>> for InsertStmtId {
3352    fn from(n: InsertStmt<'a>) -> Self {
3353        n.node_id()
3354    }
3355}
3356
3357impl From<InsertStmtId> for AnyNodeId {
3358    fn from(id: InsertStmtId) -> AnyNodeId {
3359        id.0
3360    }
3361}
3362
3363impl TypedNodeId for InsertStmtId {
3364    type Node<'a> = InsertStmt<'a>;
3365}
3366
3367#[derive(Clone, Copy)]
3368pub struct BinaryExpr<'a> {
3369    raw: &'a super::ffi::BinaryExpr,
3370    stmt_result: &'a AnyParsedStatement<'a>,
3371    id: AnyNodeId,
3372}
3373
3374impl std::fmt::Debug for BinaryExpr<'_> {
3375    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3376        self.raw.fmt(f)
3377    }
3378}
3379
3380impl std::fmt::Display for BinaryExpr<'_> {
3381    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3382        AnyNode {
3383            id: self.id,
3384            stmt_result: self.stmt_result,
3385        }
3386        .fmt(f)
3387    }
3388}
3389
3390impl<'a> BinaryExpr<'a> {
3391    /// The typed node ID of this node.
3392    pub fn node_id(&self) -> BinaryExprId {
3393        BinaryExprId(self.id)
3394    }
3395    pub fn op(&self) -> BinaryOp {
3396        self.raw.op
3397    }
3398    pub fn left(&self) -> Option<Expr<'a>> {
3399        GrammarNodeType::from_result(self.stmt_result, self.raw.left)
3400    }
3401    pub fn right(&self) -> Option<Expr<'a>> {
3402        GrammarNodeType::from_result(self.stmt_result, self.raw.right)
3403    }
3404}
3405
3406impl<'a> GrammarNodeType<'a> for BinaryExpr<'a> {
3407    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3408        let raw = stmt_result.resolve_as::<super::ffi::BinaryExpr>(id)?;
3409        Some(BinaryExpr {
3410            raw,
3411            stmt_result,
3412            id,
3413        })
3414    }
3415}
3416
3417#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3418pub struct BinaryExprId(AnyNodeId);
3419
3420impl BinaryExprId {
3421    pub fn into_inner(self) -> AnyNodeId {
3422        self.0
3423    }
3424}
3425
3426impl<'a> From<BinaryExpr<'a>> for BinaryExprId {
3427    fn from(n: BinaryExpr<'a>) -> Self {
3428        n.node_id()
3429    }
3430}
3431
3432impl From<BinaryExprId> for AnyNodeId {
3433    fn from(id: BinaryExprId) -> AnyNodeId {
3434        id.0
3435    }
3436}
3437
3438impl TypedNodeId for BinaryExprId {
3439    type Node<'a> = BinaryExpr<'a>;
3440}
3441
3442#[derive(Clone, Copy)]
3443pub struct UnaryExpr<'a> {
3444    raw: &'a super::ffi::UnaryExpr,
3445    stmt_result: &'a AnyParsedStatement<'a>,
3446    id: AnyNodeId,
3447}
3448
3449impl std::fmt::Debug for UnaryExpr<'_> {
3450    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3451        self.raw.fmt(f)
3452    }
3453}
3454
3455impl std::fmt::Display for UnaryExpr<'_> {
3456    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3457        AnyNode {
3458            id: self.id,
3459            stmt_result: self.stmt_result,
3460        }
3461        .fmt(f)
3462    }
3463}
3464
3465impl<'a> UnaryExpr<'a> {
3466    /// The typed node ID of this node.
3467    pub fn node_id(&self) -> UnaryExprId {
3468        UnaryExprId(self.id)
3469    }
3470    pub fn op(&self) -> UnaryOp {
3471        self.raw.op
3472    }
3473    pub fn operand(&self) -> Option<Expr<'a>> {
3474        GrammarNodeType::from_result(self.stmt_result, self.raw.operand)
3475    }
3476}
3477
3478impl<'a> GrammarNodeType<'a> for UnaryExpr<'a> {
3479    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3480        let raw = stmt_result.resolve_as::<super::ffi::UnaryExpr>(id)?;
3481        Some(UnaryExpr {
3482            raw,
3483            stmt_result,
3484            id,
3485        })
3486    }
3487}
3488
3489#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3490pub struct UnaryExprId(AnyNodeId);
3491
3492impl UnaryExprId {
3493    pub fn into_inner(self) -> AnyNodeId {
3494        self.0
3495    }
3496}
3497
3498impl<'a> From<UnaryExpr<'a>> for UnaryExprId {
3499    fn from(n: UnaryExpr<'a>) -> Self {
3500        n.node_id()
3501    }
3502}
3503
3504impl From<UnaryExprId> for AnyNodeId {
3505    fn from(id: UnaryExprId) -> AnyNodeId {
3506        id.0
3507    }
3508}
3509
3510impl TypedNodeId for UnaryExprId {
3511    type Node<'a> = UnaryExpr<'a>;
3512}
3513
3514#[derive(Clone, Copy)]
3515pub struct Literal<'a> {
3516    raw: &'a super::ffi::Literal,
3517    stmt_result: &'a AnyParsedStatement<'a>,
3518    id: AnyNodeId,
3519}
3520
3521impl std::fmt::Debug for Literal<'_> {
3522    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3523        self.raw.fmt(f)
3524    }
3525}
3526
3527impl std::fmt::Display for Literal<'_> {
3528    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3529        AnyNode {
3530            id: self.id,
3531            stmt_result: self.stmt_result,
3532        }
3533        .fmt(f)
3534    }
3535}
3536
3537impl<'a> Literal<'a> {
3538    /// The typed node ID of this node.
3539    pub fn node_id(&self) -> LiteralId {
3540        LiteralId(self.id)
3541    }
3542    pub fn literal_type(&self) -> LiteralType {
3543        self.raw.literal_type
3544    }
3545    pub fn source(&self) -> &'a str {
3546        self.raw.source.as_str(self.stmt_result.source())
3547    }
3548}
3549
3550impl<'a> GrammarNodeType<'a> for Literal<'a> {
3551    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3552        let raw = stmt_result.resolve_as::<super::ffi::Literal>(id)?;
3553        Some(Literal {
3554            raw,
3555            stmt_result,
3556            id,
3557        })
3558    }
3559}
3560
3561#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3562pub struct LiteralId(AnyNodeId);
3563
3564impl LiteralId {
3565    pub fn into_inner(self) -> AnyNodeId {
3566        self.0
3567    }
3568}
3569
3570impl<'a> From<Literal<'a>> for LiteralId {
3571    fn from(n: Literal<'a>) -> Self {
3572        n.node_id()
3573    }
3574}
3575
3576impl From<LiteralId> for AnyNodeId {
3577    fn from(id: LiteralId) -> AnyNodeId {
3578        id.0
3579    }
3580}
3581
3582impl TypedNodeId for LiteralId {
3583    type Node<'a> = Literal<'a>;
3584}
3585
3586#[derive(Clone, Copy)]
3587pub struct IdentName<'a> {
3588    raw: &'a super::ffi::IdentName,
3589    stmt_result: &'a AnyParsedStatement<'a>,
3590    id: AnyNodeId,
3591}
3592
3593impl std::fmt::Debug for IdentName<'_> {
3594    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3595        self.raw.fmt(f)
3596    }
3597}
3598
3599impl std::fmt::Display for IdentName<'_> {
3600    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3601        AnyNode {
3602            id: self.id,
3603            stmt_result: self.stmt_result,
3604        }
3605        .fmt(f)
3606    }
3607}
3608
3609impl<'a> IdentName<'a> {
3610    /// The typed node ID of this node.
3611    pub fn node_id(&self) -> IdentNameId {
3612        IdentNameId(self.id)
3613    }
3614    pub fn source(&self) -> &'a str {
3615        self.raw.source.as_str(self.stmt_result.source())
3616    }
3617}
3618
3619impl<'a> GrammarNodeType<'a> for IdentName<'a> {
3620    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3621        let raw = stmt_result.resolve_as::<super::ffi::IdentName>(id)?;
3622        Some(IdentName {
3623            raw,
3624            stmt_result,
3625            id,
3626        })
3627    }
3628}
3629
3630#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3631pub struct IdentNameId(AnyNodeId);
3632
3633impl IdentNameId {
3634    pub fn into_inner(self) -> AnyNodeId {
3635        self.0
3636    }
3637}
3638
3639impl<'a> From<IdentName<'a>> for IdentNameId {
3640    fn from(n: IdentName<'a>) -> Self {
3641        n.node_id()
3642    }
3643}
3644
3645impl From<IdentNameId> for AnyNodeId {
3646    fn from(id: IdentNameId) -> AnyNodeId {
3647        id.0
3648    }
3649}
3650
3651impl TypedNodeId for IdentNameId {
3652    type Node<'a> = IdentName<'a>;
3653}
3654
3655#[derive(Clone, Copy)]
3656pub struct Error<'a> {
3657    raw: &'a super::ffi::Error,
3658    stmt_result: &'a AnyParsedStatement<'a>,
3659    id: AnyNodeId,
3660}
3661
3662impl std::fmt::Debug for Error<'_> {
3663    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3664        self.raw.fmt(f)
3665    }
3666}
3667
3668impl std::fmt::Display for Error<'_> {
3669    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3670        AnyNode {
3671            id: self.id,
3672            stmt_result: self.stmt_result,
3673        }
3674        .fmt(f)
3675    }
3676}
3677
3678impl<'a> Error<'a> {
3679    /// The typed node ID of this node.
3680    pub fn node_id(&self) -> ErrorId {
3681        ErrorId(self.id)
3682    }
3683    pub fn source(&self) -> &'a str {
3684        self.raw.source.as_str(self.stmt_result.source())
3685    }
3686}
3687
3688impl<'a> GrammarNodeType<'a> for Error<'a> {
3689    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3690        let raw = stmt_result.resolve_as::<super::ffi::Error>(id)?;
3691        Some(Error {
3692            raw,
3693            stmt_result,
3694            id,
3695        })
3696    }
3697}
3698
3699#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3700pub struct ErrorId(AnyNodeId);
3701
3702impl ErrorId {
3703    pub fn into_inner(self) -> AnyNodeId {
3704        self.0
3705    }
3706}
3707
3708impl<'a> From<Error<'a>> for ErrorId {
3709    fn from(n: Error<'a>) -> Self {
3710        n.node_id()
3711    }
3712}
3713
3714impl From<ErrorId> for AnyNodeId {
3715    fn from(id: ErrorId) -> AnyNodeId {
3716        id.0
3717    }
3718}
3719
3720impl TypedNodeId for ErrorId {
3721    type Node<'a> = Error<'a>;
3722}
3723
3724#[derive(Clone, Copy)]
3725pub struct FunctionCall<'a> {
3726    raw: &'a super::ffi::FunctionCall,
3727    stmt_result: &'a AnyParsedStatement<'a>,
3728    id: AnyNodeId,
3729}
3730
3731impl std::fmt::Debug for FunctionCall<'_> {
3732    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3733        self.raw.fmt(f)
3734    }
3735}
3736
3737impl std::fmt::Display for FunctionCall<'_> {
3738    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3739        AnyNode {
3740            id: self.id,
3741            stmt_result: self.stmt_result,
3742        }
3743        .fmt(f)
3744    }
3745}
3746
3747impl<'a> FunctionCall<'a> {
3748    /// The typed node ID of this node.
3749    pub fn node_id(&self) -> FunctionCallId {
3750        FunctionCallId(self.id)
3751    }
3752    pub fn func_name(&self) -> &'a str {
3753        self.raw.func_name.as_str(self.stmt_result.source())
3754    }
3755    pub fn flags(&self) -> FunctionCallFlags {
3756        self.raw.flags
3757    }
3758    pub fn args(&self) -> Option<ExprList<'a>> {
3759        GrammarNodeType::from_result(self.stmt_result, self.raw.args)
3760    }
3761    pub fn filter_clause(&self) -> Option<Expr<'a>> {
3762        GrammarNodeType::from_result(self.stmt_result, self.raw.filter_clause)
3763    }
3764    pub fn over_clause(&self) -> Option<WindowDef<'a>> {
3765        GrammarNodeType::from_result(self.stmt_result, self.raw.over_clause)
3766    }
3767}
3768
3769impl<'a> GrammarNodeType<'a> for FunctionCall<'a> {
3770    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3771        let raw = stmt_result.resolve_as::<super::ffi::FunctionCall>(id)?;
3772        Some(FunctionCall {
3773            raw,
3774            stmt_result,
3775            id,
3776        })
3777    }
3778}
3779
3780#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3781pub struct FunctionCallId(AnyNodeId);
3782
3783impl FunctionCallId {
3784    pub fn into_inner(self) -> AnyNodeId {
3785        self.0
3786    }
3787}
3788
3789impl<'a> From<FunctionCall<'a>> for FunctionCallId {
3790    fn from(n: FunctionCall<'a>) -> Self {
3791        n.node_id()
3792    }
3793}
3794
3795impl From<FunctionCallId> for AnyNodeId {
3796    fn from(id: FunctionCallId) -> AnyNodeId {
3797        id.0
3798    }
3799}
3800
3801impl TypedNodeId for FunctionCallId {
3802    type Node<'a> = FunctionCall<'a>;
3803}
3804
3805#[derive(Clone, Copy)]
3806pub struct Variable<'a> {
3807    raw: &'a super::ffi::Variable,
3808    stmt_result: &'a AnyParsedStatement<'a>,
3809    id: AnyNodeId,
3810}
3811
3812impl std::fmt::Debug for Variable<'_> {
3813    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3814        self.raw.fmt(f)
3815    }
3816}
3817
3818impl std::fmt::Display for Variable<'_> {
3819    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3820        AnyNode {
3821            id: self.id,
3822            stmt_result: self.stmt_result,
3823        }
3824        .fmt(f)
3825    }
3826}
3827
3828impl<'a> Variable<'a> {
3829    /// The typed node ID of this node.
3830    pub fn node_id(&self) -> VariableId {
3831        VariableId(self.id)
3832    }
3833    pub fn source(&self) -> &'a str {
3834        self.raw.source.as_str(self.stmt_result.source())
3835    }
3836}
3837
3838impl<'a> GrammarNodeType<'a> for Variable<'a> {
3839    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3840        let raw = stmt_result.resolve_as::<super::ffi::Variable>(id)?;
3841        Some(Variable {
3842            raw,
3843            stmt_result,
3844            id,
3845        })
3846    }
3847}
3848
3849#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3850pub struct VariableId(AnyNodeId);
3851
3852impl VariableId {
3853    pub fn into_inner(self) -> AnyNodeId {
3854        self.0
3855    }
3856}
3857
3858impl<'a> From<Variable<'a>> for VariableId {
3859    fn from(n: Variable<'a>) -> Self {
3860        n.node_id()
3861    }
3862}
3863
3864impl From<VariableId> for AnyNodeId {
3865    fn from(id: VariableId) -> AnyNodeId {
3866        id.0
3867    }
3868}
3869
3870impl TypedNodeId for VariableId {
3871    type Node<'a> = Variable<'a>;
3872}
3873
3874#[derive(Clone, Copy)]
3875pub struct CollateExpr<'a> {
3876    raw: &'a super::ffi::CollateExpr,
3877    stmt_result: &'a AnyParsedStatement<'a>,
3878    id: AnyNodeId,
3879}
3880
3881impl std::fmt::Debug for CollateExpr<'_> {
3882    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3883        self.raw.fmt(f)
3884    }
3885}
3886
3887impl std::fmt::Display for CollateExpr<'_> {
3888    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3889        AnyNode {
3890            id: self.id,
3891            stmt_result: self.stmt_result,
3892        }
3893        .fmt(f)
3894    }
3895}
3896
3897impl<'a> CollateExpr<'a> {
3898    /// The typed node ID of this node.
3899    pub fn node_id(&self) -> CollateExprId {
3900        CollateExprId(self.id)
3901    }
3902    pub fn expr(&self) -> Option<Expr<'a>> {
3903        GrammarNodeType::from_result(self.stmt_result, self.raw.expr)
3904    }
3905    pub fn collation(&self) -> &'a str {
3906        self.raw.collation.as_str(self.stmt_result.source())
3907    }
3908}
3909
3910impl<'a> GrammarNodeType<'a> for CollateExpr<'a> {
3911    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3912        let raw = stmt_result.resolve_as::<super::ffi::CollateExpr>(id)?;
3913        Some(CollateExpr {
3914            raw,
3915            stmt_result,
3916            id,
3917        })
3918    }
3919}
3920
3921#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3922pub struct CollateExprId(AnyNodeId);
3923
3924impl CollateExprId {
3925    pub fn into_inner(self) -> AnyNodeId {
3926        self.0
3927    }
3928}
3929
3930impl<'a> From<CollateExpr<'a>> for CollateExprId {
3931    fn from(n: CollateExpr<'a>) -> Self {
3932        n.node_id()
3933    }
3934}
3935
3936impl From<CollateExprId> for AnyNodeId {
3937    fn from(id: CollateExprId) -> AnyNodeId {
3938        id.0
3939    }
3940}
3941
3942impl TypedNodeId for CollateExprId {
3943    type Node<'a> = CollateExpr<'a>;
3944}
3945
3946#[derive(Clone, Copy)]
3947pub struct RaiseExpr<'a> {
3948    raw: &'a super::ffi::RaiseExpr,
3949    stmt_result: &'a AnyParsedStatement<'a>,
3950    id: AnyNodeId,
3951}
3952
3953impl std::fmt::Debug for RaiseExpr<'_> {
3954    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3955        self.raw.fmt(f)
3956    }
3957}
3958
3959impl std::fmt::Display for RaiseExpr<'_> {
3960    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3961        AnyNode {
3962            id: self.id,
3963            stmt_result: self.stmt_result,
3964        }
3965        .fmt(f)
3966    }
3967}
3968
3969impl<'a> RaiseExpr<'a> {
3970    /// The typed node ID of this node.
3971    pub fn node_id(&self) -> RaiseExprId {
3972        RaiseExprId(self.id)
3973    }
3974    pub fn raise_type(&self) -> RaiseType {
3975        self.raw.raise_type
3976    }
3977    pub fn error_message(&self) -> Option<Expr<'a>> {
3978        GrammarNodeType::from_result(self.stmt_result, self.raw.error_message)
3979    }
3980}
3981
3982impl<'a> GrammarNodeType<'a> for RaiseExpr<'a> {
3983    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
3984        let raw = stmt_result.resolve_as::<super::ffi::RaiseExpr>(id)?;
3985        Some(RaiseExpr {
3986            raw,
3987            stmt_result,
3988            id,
3989        })
3990    }
3991}
3992
3993#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3994pub struct RaiseExprId(AnyNodeId);
3995
3996impl RaiseExprId {
3997    pub fn into_inner(self) -> AnyNodeId {
3998        self.0
3999    }
4000}
4001
4002impl<'a> From<RaiseExpr<'a>> for RaiseExprId {
4003    fn from(n: RaiseExpr<'a>) -> Self {
4004        n.node_id()
4005    }
4006}
4007
4008impl From<RaiseExprId> for AnyNodeId {
4009    fn from(id: RaiseExprId) -> AnyNodeId {
4010        id.0
4011    }
4012}
4013
4014impl TypedNodeId for RaiseExprId {
4015    type Node<'a> = RaiseExpr<'a>;
4016}
4017
4018#[derive(Clone, Copy)]
4019pub struct QualifiedName<'a> {
4020    raw: &'a super::ffi::QualifiedName,
4021    stmt_result: &'a AnyParsedStatement<'a>,
4022    id: AnyNodeId,
4023}
4024
4025impl std::fmt::Debug for QualifiedName<'_> {
4026    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4027        self.raw.fmt(f)
4028    }
4029}
4030
4031impl std::fmt::Display for QualifiedName<'_> {
4032    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4033        AnyNode {
4034            id: self.id,
4035            stmt_result: self.stmt_result,
4036        }
4037        .fmt(f)
4038    }
4039}
4040
4041impl<'a> QualifiedName<'a> {
4042    /// The typed node ID of this node.
4043    pub fn node_id(&self) -> QualifiedNameId {
4044        QualifiedNameId(self.id)
4045    }
4046    pub fn object_name(&self) -> Option<Name<'a>> {
4047        GrammarNodeType::from_result(self.stmt_result, self.raw.object_name)
4048    }
4049    pub fn schema(&self) -> Option<Name<'a>> {
4050        GrammarNodeType::from_result(self.stmt_result, self.raw.schema)
4051    }
4052}
4053
4054impl<'a> GrammarNodeType<'a> for QualifiedName<'a> {
4055    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4056        let raw = stmt_result.resolve_as::<super::ffi::QualifiedName>(id)?;
4057        Some(QualifiedName {
4058            raw,
4059            stmt_result,
4060            id,
4061        })
4062    }
4063}
4064
4065#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4066pub struct QualifiedNameId(AnyNodeId);
4067
4068impl QualifiedNameId {
4069    pub fn into_inner(self) -> AnyNodeId {
4070        self.0
4071    }
4072}
4073
4074impl<'a> From<QualifiedName<'a>> for QualifiedNameId {
4075    fn from(n: QualifiedName<'a>) -> Self {
4076        n.node_id()
4077    }
4078}
4079
4080impl From<QualifiedNameId> for AnyNodeId {
4081    fn from(id: QualifiedNameId) -> AnyNodeId {
4082        id.0
4083    }
4084}
4085
4086impl TypedNodeId for QualifiedNameId {
4087    type Node<'a> = QualifiedName<'a>;
4088}
4089
4090#[derive(Clone, Copy)]
4091pub struct DropStmt<'a> {
4092    raw: &'a super::ffi::DropStmt,
4093    stmt_result: &'a AnyParsedStatement<'a>,
4094    id: AnyNodeId,
4095}
4096
4097impl std::fmt::Debug for DropStmt<'_> {
4098    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4099        self.raw.fmt(f)
4100    }
4101}
4102
4103impl std::fmt::Display for DropStmt<'_> {
4104    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4105        AnyNode {
4106            id: self.id,
4107            stmt_result: self.stmt_result,
4108        }
4109        .fmt(f)
4110    }
4111}
4112
4113impl<'a> DropStmt<'a> {
4114    /// The typed node ID of this node.
4115    pub fn node_id(&self) -> DropStmtId {
4116        DropStmtId(self.id)
4117    }
4118    pub fn object_type(&self) -> DropObjectType {
4119        self.raw.object_type
4120    }
4121    pub fn if_exists(&self) -> bool {
4122        self.raw.if_exists == super::ffi::Bool::True
4123    }
4124    pub fn target(&self) -> Option<QualifiedName<'a>> {
4125        GrammarNodeType::from_result(self.stmt_result, self.raw.target)
4126    }
4127}
4128
4129impl<'a> GrammarNodeType<'a> for DropStmt<'a> {
4130    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4131        let raw = stmt_result.resolve_as::<super::ffi::DropStmt>(id)?;
4132        Some(DropStmt {
4133            raw,
4134            stmt_result,
4135            id,
4136        })
4137    }
4138}
4139
4140#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4141pub struct DropStmtId(AnyNodeId);
4142
4143impl DropStmtId {
4144    pub fn into_inner(self) -> AnyNodeId {
4145        self.0
4146    }
4147}
4148
4149impl<'a> From<DropStmt<'a>> for DropStmtId {
4150    fn from(n: DropStmt<'a>) -> Self {
4151        n.node_id()
4152    }
4153}
4154
4155impl From<DropStmtId> for AnyNodeId {
4156    fn from(id: DropStmtId) -> AnyNodeId {
4157        id.0
4158    }
4159}
4160
4161impl TypedNodeId for DropStmtId {
4162    type Node<'a> = DropStmt<'a>;
4163}
4164
4165#[derive(Clone, Copy)]
4166pub struct AlterTableStmt<'a> {
4167    raw: &'a super::ffi::AlterTableStmt,
4168    stmt_result: &'a AnyParsedStatement<'a>,
4169    id: AnyNodeId,
4170}
4171
4172impl std::fmt::Debug for AlterTableStmt<'_> {
4173    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4174        self.raw.fmt(f)
4175    }
4176}
4177
4178impl std::fmt::Display for AlterTableStmt<'_> {
4179    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4180        AnyNode {
4181            id: self.id,
4182            stmt_result: self.stmt_result,
4183        }
4184        .fmt(f)
4185    }
4186}
4187
4188impl<'a> AlterTableStmt<'a> {
4189    /// The typed node ID of this node.
4190    pub fn node_id(&self) -> AlterTableStmtId {
4191        AlterTableStmtId(self.id)
4192    }
4193    pub fn op(&self) -> AlterOp {
4194        self.raw.op
4195    }
4196    pub fn target(&self) -> Option<QualifiedName<'a>> {
4197        GrammarNodeType::from_result(self.stmt_result, self.raw.target)
4198    }
4199    pub fn new_name(&self) -> Option<Name<'a>> {
4200        GrammarNodeType::from_result(self.stmt_result, self.raw.new_name)
4201    }
4202    pub fn old_name(&self) -> Option<Name<'a>> {
4203        GrammarNodeType::from_result(self.stmt_result, self.raw.old_name)
4204    }
4205}
4206
4207impl<'a> GrammarNodeType<'a> for AlterTableStmt<'a> {
4208    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4209        let raw = stmt_result.resolve_as::<super::ffi::AlterTableStmt>(id)?;
4210        Some(AlterTableStmt {
4211            raw,
4212            stmt_result,
4213            id,
4214        })
4215    }
4216}
4217
4218#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4219pub struct AlterTableStmtId(AnyNodeId);
4220
4221impl AlterTableStmtId {
4222    pub fn into_inner(self) -> AnyNodeId {
4223        self.0
4224    }
4225}
4226
4227impl<'a> From<AlterTableStmt<'a>> for AlterTableStmtId {
4228    fn from(n: AlterTableStmt<'a>) -> Self {
4229        n.node_id()
4230    }
4231}
4232
4233impl From<AlterTableStmtId> for AnyNodeId {
4234    fn from(id: AlterTableStmtId) -> AnyNodeId {
4235        id.0
4236    }
4237}
4238
4239impl TypedNodeId for AlterTableStmtId {
4240    type Node<'a> = AlterTableStmt<'a>;
4241}
4242
4243#[derive(Clone, Copy)]
4244pub struct TransactionStmt<'a> {
4245    raw: &'a super::ffi::TransactionStmt,
4246    stmt_result: &'a AnyParsedStatement<'a>,
4247    id: AnyNodeId,
4248}
4249
4250impl std::fmt::Debug for TransactionStmt<'_> {
4251    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4252        self.raw.fmt(f)
4253    }
4254}
4255
4256impl std::fmt::Display for TransactionStmt<'_> {
4257    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4258        AnyNode {
4259            id: self.id,
4260            stmt_result: self.stmt_result,
4261        }
4262        .fmt(f)
4263    }
4264}
4265
4266impl<'a> TransactionStmt<'a> {
4267    /// The typed node ID of this node.
4268    pub fn node_id(&self) -> TransactionStmtId {
4269        TransactionStmtId(self.id)
4270    }
4271    pub fn op(&self) -> TransactionOp {
4272        self.raw.op
4273    }
4274    pub fn trans_type(&self) -> TransactionType {
4275        self.raw.trans_type
4276    }
4277}
4278
4279impl<'a> GrammarNodeType<'a> for TransactionStmt<'a> {
4280    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4281        let raw = stmt_result.resolve_as::<super::ffi::TransactionStmt>(id)?;
4282        Some(TransactionStmt {
4283            raw,
4284            stmt_result,
4285            id,
4286        })
4287    }
4288}
4289
4290#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4291pub struct TransactionStmtId(AnyNodeId);
4292
4293impl TransactionStmtId {
4294    pub fn into_inner(self) -> AnyNodeId {
4295        self.0
4296    }
4297}
4298
4299impl<'a> From<TransactionStmt<'a>> for TransactionStmtId {
4300    fn from(n: TransactionStmt<'a>) -> Self {
4301        n.node_id()
4302    }
4303}
4304
4305impl From<TransactionStmtId> for AnyNodeId {
4306    fn from(id: TransactionStmtId) -> AnyNodeId {
4307        id.0
4308    }
4309}
4310
4311impl TypedNodeId for TransactionStmtId {
4312    type Node<'a> = TransactionStmt<'a>;
4313}
4314
4315#[derive(Clone, Copy)]
4316pub struct SavepointStmt<'a> {
4317    raw: &'a super::ffi::SavepointStmt,
4318    stmt_result: &'a AnyParsedStatement<'a>,
4319    id: AnyNodeId,
4320}
4321
4322impl std::fmt::Debug for SavepointStmt<'_> {
4323    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4324        self.raw.fmt(f)
4325    }
4326}
4327
4328impl std::fmt::Display for SavepointStmt<'_> {
4329    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4330        AnyNode {
4331            id: self.id,
4332            stmt_result: self.stmt_result,
4333        }
4334        .fmt(f)
4335    }
4336}
4337
4338impl<'a> SavepointStmt<'a> {
4339    /// The typed node ID of this node.
4340    pub fn node_id(&self) -> SavepointStmtId {
4341        SavepointStmtId(self.id)
4342    }
4343    pub fn op(&self) -> SavepointOp {
4344        self.raw.op
4345    }
4346    pub fn savepoint_name(&self) -> Option<Name<'a>> {
4347        GrammarNodeType::from_result(self.stmt_result, self.raw.savepoint_name)
4348    }
4349}
4350
4351impl<'a> GrammarNodeType<'a> for SavepointStmt<'a> {
4352    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4353        let raw = stmt_result.resolve_as::<super::ffi::SavepointStmt>(id)?;
4354        Some(SavepointStmt {
4355            raw,
4356            stmt_result,
4357            id,
4358        })
4359    }
4360}
4361
4362#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4363pub struct SavepointStmtId(AnyNodeId);
4364
4365impl SavepointStmtId {
4366    pub fn into_inner(self) -> AnyNodeId {
4367        self.0
4368    }
4369}
4370
4371impl<'a> From<SavepointStmt<'a>> for SavepointStmtId {
4372    fn from(n: SavepointStmt<'a>) -> Self {
4373        n.node_id()
4374    }
4375}
4376
4377impl From<SavepointStmtId> for AnyNodeId {
4378    fn from(id: SavepointStmtId) -> AnyNodeId {
4379        id.0
4380    }
4381}
4382
4383impl TypedNodeId for SavepointStmtId {
4384    type Node<'a> = SavepointStmt<'a>;
4385}
4386
4387#[derive(Clone, Copy)]
4388pub struct ResultColumn<'a> {
4389    raw: &'a super::ffi::ResultColumn,
4390    stmt_result: &'a AnyParsedStatement<'a>,
4391    id: AnyNodeId,
4392}
4393
4394impl std::fmt::Debug for ResultColumn<'_> {
4395    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4396        self.raw.fmt(f)
4397    }
4398}
4399
4400impl std::fmt::Display for ResultColumn<'_> {
4401    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4402        AnyNode {
4403            id: self.id,
4404            stmt_result: self.stmt_result,
4405        }
4406        .fmt(f)
4407    }
4408}
4409
4410impl<'a> ResultColumn<'a> {
4411    /// The typed node ID of this node.
4412    pub fn node_id(&self) -> ResultColumnId {
4413        ResultColumnId(self.id)
4414    }
4415    pub fn flags(&self) -> ResultColumnFlags {
4416        self.raw.flags
4417    }
4418    pub fn alias(&self) -> Option<Name<'a>> {
4419        GrammarNodeType::from_result(self.stmt_result, self.raw.alias)
4420    }
4421    pub fn expr(&self) -> Option<Expr<'a>> {
4422        GrammarNodeType::from_result(self.stmt_result, self.raw.expr)
4423    }
4424}
4425
4426impl<'a> GrammarNodeType<'a> for ResultColumn<'a> {
4427    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4428        let raw = stmt_result.resolve_as::<super::ffi::ResultColumn>(id)?;
4429        Some(ResultColumn {
4430            raw,
4431            stmt_result,
4432            id,
4433        })
4434    }
4435}
4436
4437#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4438pub struct ResultColumnId(AnyNodeId);
4439
4440impl ResultColumnId {
4441    pub fn into_inner(self) -> AnyNodeId {
4442        self.0
4443    }
4444}
4445
4446impl<'a> From<ResultColumn<'a>> for ResultColumnId {
4447    fn from(n: ResultColumn<'a>) -> Self {
4448        n.node_id()
4449    }
4450}
4451
4452impl From<ResultColumnId> for AnyNodeId {
4453    fn from(id: ResultColumnId) -> AnyNodeId {
4454        id.0
4455    }
4456}
4457
4458impl TypedNodeId for ResultColumnId {
4459    type Node<'a> = ResultColumn<'a>;
4460}
4461
4462#[derive(Clone, Copy)]
4463pub struct SelectStmt<'a> {
4464    raw: &'a super::ffi::SelectStmt,
4465    stmt_result: &'a AnyParsedStatement<'a>,
4466    id: AnyNodeId,
4467}
4468
4469impl std::fmt::Debug for SelectStmt<'_> {
4470    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4471        self.raw.fmt(f)
4472    }
4473}
4474
4475impl std::fmt::Display for SelectStmt<'_> {
4476    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4477        AnyNode {
4478            id: self.id,
4479            stmt_result: self.stmt_result,
4480        }
4481        .fmt(f)
4482    }
4483}
4484
4485impl<'a> SelectStmt<'a> {
4486    /// The typed node ID of this node.
4487    pub fn node_id(&self) -> SelectStmtId {
4488        SelectStmtId(self.id)
4489    }
4490    pub fn flags(&self) -> SelectStmtFlags {
4491        self.raw.flags
4492    }
4493    pub fn columns(&self) -> Option<ResultColumnList<'a>> {
4494        GrammarNodeType::from_result(self.stmt_result, self.raw.columns)
4495    }
4496    pub fn from_clause(&self) -> Option<TableSource<'a>> {
4497        GrammarNodeType::from_result(self.stmt_result, self.raw.from_clause)
4498    }
4499    pub fn where_clause(&self) -> Option<Expr<'a>> {
4500        GrammarNodeType::from_result(self.stmt_result, self.raw.where_clause)
4501    }
4502    pub fn groupby(&self) -> Option<ExprList<'a>> {
4503        GrammarNodeType::from_result(self.stmt_result, self.raw.groupby)
4504    }
4505    pub fn having(&self) -> Option<Expr<'a>> {
4506        GrammarNodeType::from_result(self.stmt_result, self.raw.having)
4507    }
4508    pub fn orderby(&self) -> Option<OrderByList<'a>> {
4509        GrammarNodeType::from_result(self.stmt_result, self.raw.orderby)
4510    }
4511    pub fn limit_clause(&self) -> Option<LimitClause<'a>> {
4512        GrammarNodeType::from_result(self.stmt_result, self.raw.limit_clause)
4513    }
4514    pub fn window_clause(&self) -> Option<NamedWindowDefList<'a>> {
4515        GrammarNodeType::from_result(self.stmt_result, self.raw.window_clause)
4516    }
4517}
4518
4519impl<'a> GrammarNodeType<'a> for SelectStmt<'a> {
4520    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4521        let raw = stmt_result.resolve_as::<super::ffi::SelectStmt>(id)?;
4522        Some(SelectStmt {
4523            raw,
4524            stmt_result,
4525            id,
4526        })
4527    }
4528}
4529
4530#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4531pub struct SelectStmtId(AnyNodeId);
4532
4533impl SelectStmtId {
4534    pub fn into_inner(self) -> AnyNodeId {
4535        self.0
4536    }
4537}
4538
4539impl<'a> From<SelectStmt<'a>> for SelectStmtId {
4540    fn from(n: SelectStmt<'a>) -> Self {
4541        n.node_id()
4542    }
4543}
4544
4545impl From<SelectStmtId> for AnyNodeId {
4546    fn from(id: SelectStmtId) -> AnyNodeId {
4547        id.0
4548    }
4549}
4550
4551impl TypedNodeId for SelectStmtId {
4552    type Node<'a> = SelectStmt<'a>;
4553}
4554
4555#[derive(Clone, Copy)]
4556pub struct OrderingTerm<'a> {
4557    raw: &'a super::ffi::OrderingTerm,
4558    stmt_result: &'a AnyParsedStatement<'a>,
4559    id: AnyNodeId,
4560}
4561
4562impl std::fmt::Debug for OrderingTerm<'_> {
4563    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4564        self.raw.fmt(f)
4565    }
4566}
4567
4568impl std::fmt::Display for OrderingTerm<'_> {
4569    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4570        AnyNode {
4571            id: self.id,
4572            stmt_result: self.stmt_result,
4573        }
4574        .fmt(f)
4575    }
4576}
4577
4578impl<'a> OrderingTerm<'a> {
4579    /// The typed node ID of this node.
4580    pub fn node_id(&self) -> OrderingTermId {
4581        OrderingTermId(self.id)
4582    }
4583    pub fn expr(&self) -> Option<Expr<'a>> {
4584        GrammarNodeType::from_result(self.stmt_result, self.raw.expr)
4585    }
4586    pub fn sort_order(&self) -> SortOrder {
4587        self.raw.sort_order
4588    }
4589    pub fn nulls_order(&self) -> NullsOrder {
4590        self.raw.nulls_order
4591    }
4592}
4593
4594impl<'a> GrammarNodeType<'a> for OrderingTerm<'a> {
4595    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4596        let raw = stmt_result.resolve_as::<super::ffi::OrderingTerm>(id)?;
4597        Some(OrderingTerm {
4598            raw,
4599            stmt_result,
4600            id,
4601        })
4602    }
4603}
4604
4605#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4606pub struct OrderingTermId(AnyNodeId);
4607
4608impl OrderingTermId {
4609    pub fn into_inner(self) -> AnyNodeId {
4610        self.0
4611    }
4612}
4613
4614impl<'a> From<OrderingTerm<'a>> for OrderingTermId {
4615    fn from(n: OrderingTerm<'a>) -> Self {
4616        n.node_id()
4617    }
4618}
4619
4620impl From<OrderingTermId> for AnyNodeId {
4621    fn from(id: OrderingTermId) -> AnyNodeId {
4622        id.0
4623    }
4624}
4625
4626impl TypedNodeId for OrderingTermId {
4627    type Node<'a> = OrderingTerm<'a>;
4628}
4629
4630#[derive(Clone, Copy)]
4631pub struct LimitClause<'a> {
4632    raw: &'a super::ffi::LimitClause,
4633    stmt_result: &'a AnyParsedStatement<'a>,
4634    id: AnyNodeId,
4635}
4636
4637impl std::fmt::Debug for LimitClause<'_> {
4638    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4639        self.raw.fmt(f)
4640    }
4641}
4642
4643impl std::fmt::Display for LimitClause<'_> {
4644    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4645        AnyNode {
4646            id: self.id,
4647            stmt_result: self.stmt_result,
4648        }
4649        .fmt(f)
4650    }
4651}
4652
4653impl<'a> LimitClause<'a> {
4654    /// The typed node ID of this node.
4655    pub fn node_id(&self) -> LimitClauseId {
4656        LimitClauseId(self.id)
4657    }
4658    pub fn limit(&self) -> Option<Expr<'a>> {
4659        GrammarNodeType::from_result(self.stmt_result, self.raw.limit)
4660    }
4661    pub fn offset(&self) -> Option<Expr<'a>> {
4662        GrammarNodeType::from_result(self.stmt_result, self.raw.offset)
4663    }
4664}
4665
4666impl<'a> GrammarNodeType<'a> for LimitClause<'a> {
4667    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4668        let raw = stmt_result.resolve_as::<super::ffi::LimitClause>(id)?;
4669        Some(LimitClause {
4670            raw,
4671            stmt_result,
4672            id,
4673        })
4674    }
4675}
4676
4677#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4678pub struct LimitClauseId(AnyNodeId);
4679
4680impl LimitClauseId {
4681    pub fn into_inner(self) -> AnyNodeId {
4682        self.0
4683    }
4684}
4685
4686impl<'a> From<LimitClause<'a>> for LimitClauseId {
4687    fn from(n: LimitClause<'a>) -> Self {
4688        n.node_id()
4689    }
4690}
4691
4692impl From<LimitClauseId> for AnyNodeId {
4693    fn from(id: LimitClauseId) -> AnyNodeId {
4694        id.0
4695    }
4696}
4697
4698impl TypedNodeId for LimitClauseId {
4699    type Node<'a> = LimitClause<'a>;
4700}
4701
4702#[derive(Clone, Copy)]
4703pub struct TableRef<'a> {
4704    raw: &'a super::ffi::TableRef,
4705    stmt_result: &'a AnyParsedStatement<'a>,
4706    id: AnyNodeId,
4707}
4708
4709impl std::fmt::Debug for TableRef<'_> {
4710    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4711        self.raw.fmt(f)
4712    }
4713}
4714
4715impl std::fmt::Display for TableRef<'_> {
4716    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4717        AnyNode {
4718            id: self.id,
4719            stmt_result: self.stmt_result,
4720        }
4721        .fmt(f)
4722    }
4723}
4724
4725impl<'a> TableRef<'a> {
4726    /// The typed node ID of this node.
4727    pub fn node_id(&self) -> TableRefId {
4728        TableRefId(self.id)
4729    }
4730    pub fn table_name(&self) -> &'a str {
4731        self.raw.table_name.as_str(self.stmt_result.source())
4732    }
4733    pub fn schema(&self) -> &'a str {
4734        self.raw.schema.as_str(self.stmt_result.source())
4735    }
4736    pub fn alias(&self) -> Option<Name<'a>> {
4737        GrammarNodeType::from_result(self.stmt_result, self.raw.alias)
4738    }
4739    pub fn args(&self) -> Option<ExprList<'a>> {
4740        GrammarNodeType::from_result(self.stmt_result, self.raw.args)
4741    }
4742}
4743
4744impl<'a> GrammarNodeType<'a> for TableRef<'a> {
4745    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4746        let raw = stmt_result.resolve_as::<super::ffi::TableRef>(id)?;
4747        Some(TableRef {
4748            raw,
4749            stmt_result,
4750            id,
4751        })
4752    }
4753}
4754
4755#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4756pub struct TableRefId(AnyNodeId);
4757
4758impl TableRefId {
4759    pub fn into_inner(self) -> AnyNodeId {
4760        self.0
4761    }
4762}
4763
4764impl<'a> From<TableRef<'a>> for TableRefId {
4765    fn from(n: TableRef<'a>) -> Self {
4766        n.node_id()
4767    }
4768}
4769
4770impl From<TableRefId> for AnyNodeId {
4771    fn from(id: TableRefId) -> AnyNodeId {
4772        id.0
4773    }
4774}
4775
4776impl TypedNodeId for TableRefId {
4777    type Node<'a> = TableRef<'a>;
4778}
4779
4780#[derive(Clone, Copy)]
4781pub struct SubqueryTableSource<'a> {
4782    raw: &'a super::ffi::SubqueryTableSource,
4783    stmt_result: &'a AnyParsedStatement<'a>,
4784    id: AnyNodeId,
4785}
4786
4787impl std::fmt::Debug for SubqueryTableSource<'_> {
4788    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4789        self.raw.fmt(f)
4790    }
4791}
4792
4793impl std::fmt::Display for SubqueryTableSource<'_> {
4794    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4795        AnyNode {
4796            id: self.id,
4797            stmt_result: self.stmt_result,
4798        }
4799        .fmt(f)
4800    }
4801}
4802
4803impl<'a> SubqueryTableSource<'a> {
4804    /// The typed node ID of this node.
4805    pub fn node_id(&self) -> SubqueryTableSourceId {
4806        SubqueryTableSourceId(self.id)
4807    }
4808    pub fn select(&self) -> Option<Select<'a>> {
4809        GrammarNodeType::from_result(self.stmt_result, self.raw.select)
4810    }
4811    pub fn alias(&self) -> Option<Name<'a>> {
4812        GrammarNodeType::from_result(self.stmt_result, self.raw.alias)
4813    }
4814}
4815
4816impl<'a> GrammarNodeType<'a> for SubqueryTableSource<'a> {
4817    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4818        let raw = stmt_result.resolve_as::<super::ffi::SubqueryTableSource>(id)?;
4819        Some(SubqueryTableSource {
4820            raw,
4821            stmt_result,
4822            id,
4823        })
4824    }
4825}
4826
4827#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4828pub struct SubqueryTableSourceId(AnyNodeId);
4829
4830impl SubqueryTableSourceId {
4831    pub fn into_inner(self) -> AnyNodeId {
4832        self.0
4833    }
4834}
4835
4836impl<'a> From<SubqueryTableSource<'a>> for SubqueryTableSourceId {
4837    fn from(n: SubqueryTableSource<'a>) -> Self {
4838        n.node_id()
4839    }
4840}
4841
4842impl From<SubqueryTableSourceId> for AnyNodeId {
4843    fn from(id: SubqueryTableSourceId) -> AnyNodeId {
4844        id.0
4845    }
4846}
4847
4848impl TypedNodeId for SubqueryTableSourceId {
4849    type Node<'a> = SubqueryTableSource<'a>;
4850}
4851
4852#[derive(Clone, Copy)]
4853pub struct JoinClause<'a> {
4854    raw: &'a super::ffi::JoinClause,
4855    stmt_result: &'a AnyParsedStatement<'a>,
4856    id: AnyNodeId,
4857}
4858
4859impl std::fmt::Debug for JoinClause<'_> {
4860    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4861        self.raw.fmt(f)
4862    }
4863}
4864
4865impl std::fmt::Display for JoinClause<'_> {
4866    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4867        AnyNode {
4868            id: self.id,
4869            stmt_result: self.stmt_result,
4870        }
4871        .fmt(f)
4872    }
4873}
4874
4875impl<'a> JoinClause<'a> {
4876    /// The typed node ID of this node.
4877    pub fn node_id(&self) -> JoinClauseId {
4878        JoinClauseId(self.id)
4879    }
4880    pub fn join_type(&self) -> JoinType {
4881        self.raw.join_type
4882    }
4883    pub fn left(&self) -> Option<TableSource<'a>> {
4884        GrammarNodeType::from_result(self.stmt_result, self.raw.left)
4885    }
4886    pub fn right(&self) -> Option<TableSource<'a>> {
4887        GrammarNodeType::from_result(self.stmt_result, self.raw.right)
4888    }
4889    pub fn on_expr(&self) -> Option<Expr<'a>> {
4890        GrammarNodeType::from_result(self.stmt_result, self.raw.on_expr)
4891    }
4892    pub fn using_columns(&self) -> Option<ExprList<'a>> {
4893        GrammarNodeType::from_result(self.stmt_result, self.raw.using_columns)
4894    }
4895}
4896
4897impl<'a> GrammarNodeType<'a> for JoinClause<'a> {
4898    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4899        let raw = stmt_result.resolve_as::<super::ffi::JoinClause>(id)?;
4900        Some(JoinClause {
4901            raw,
4902            stmt_result,
4903            id,
4904        })
4905    }
4906}
4907
4908#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4909pub struct JoinClauseId(AnyNodeId);
4910
4911impl JoinClauseId {
4912    pub fn into_inner(self) -> AnyNodeId {
4913        self.0
4914    }
4915}
4916
4917impl<'a> From<JoinClause<'a>> for JoinClauseId {
4918    fn from(n: JoinClause<'a>) -> Self {
4919        n.node_id()
4920    }
4921}
4922
4923impl From<JoinClauseId> for AnyNodeId {
4924    fn from(id: JoinClauseId) -> AnyNodeId {
4925        id.0
4926    }
4927}
4928
4929impl TypedNodeId for JoinClauseId {
4930    type Node<'a> = JoinClause<'a>;
4931}
4932
4933#[derive(Clone, Copy)]
4934pub struct JoinPrefix<'a> {
4935    raw: &'a super::ffi::JoinPrefix,
4936    stmt_result: &'a AnyParsedStatement<'a>,
4937    id: AnyNodeId,
4938}
4939
4940impl std::fmt::Debug for JoinPrefix<'_> {
4941    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4942        self.raw.fmt(f)
4943    }
4944}
4945
4946impl std::fmt::Display for JoinPrefix<'_> {
4947    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4948        AnyNode {
4949            id: self.id,
4950            stmt_result: self.stmt_result,
4951        }
4952        .fmt(f)
4953    }
4954}
4955
4956impl<'a> JoinPrefix<'a> {
4957    /// The typed node ID of this node.
4958    pub fn node_id(&self) -> JoinPrefixId {
4959        JoinPrefixId(self.id)
4960    }
4961    pub fn source(&self) -> Option<TableSource<'a>> {
4962        GrammarNodeType::from_result(self.stmt_result, self.raw.source)
4963    }
4964    pub fn join_type(&self) -> JoinType {
4965        self.raw.join_type
4966    }
4967}
4968
4969impl<'a> GrammarNodeType<'a> for JoinPrefix<'a> {
4970    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
4971        let raw = stmt_result.resolve_as::<super::ffi::JoinPrefix>(id)?;
4972        Some(JoinPrefix {
4973            raw,
4974            stmt_result,
4975            id,
4976        })
4977    }
4978}
4979
4980#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4981pub struct JoinPrefixId(AnyNodeId);
4982
4983impl JoinPrefixId {
4984    pub fn into_inner(self) -> AnyNodeId {
4985        self.0
4986    }
4987}
4988
4989impl<'a> From<JoinPrefix<'a>> for JoinPrefixId {
4990    fn from(n: JoinPrefix<'a>) -> Self {
4991        n.node_id()
4992    }
4993}
4994
4995impl From<JoinPrefixId> for AnyNodeId {
4996    fn from(id: JoinPrefixId) -> AnyNodeId {
4997        id.0
4998    }
4999}
5000
5001impl TypedNodeId for JoinPrefixId {
5002    type Node<'a> = JoinPrefix<'a>;
5003}
5004
5005#[derive(Clone, Copy)]
5006pub struct TriggerEvent<'a> {
5007    raw: &'a super::ffi::TriggerEvent,
5008    stmt_result: &'a AnyParsedStatement<'a>,
5009    id: AnyNodeId,
5010}
5011
5012impl std::fmt::Debug for TriggerEvent<'_> {
5013    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5014        self.raw.fmt(f)
5015    }
5016}
5017
5018impl std::fmt::Display for TriggerEvent<'_> {
5019    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5020        AnyNode {
5021            id: self.id,
5022            stmt_result: self.stmt_result,
5023        }
5024        .fmt(f)
5025    }
5026}
5027
5028impl<'a> TriggerEvent<'a> {
5029    /// The typed node ID of this node.
5030    pub fn node_id(&self) -> TriggerEventId {
5031        TriggerEventId(self.id)
5032    }
5033    pub fn event_type(&self) -> TriggerEventType {
5034        self.raw.event_type
5035    }
5036    pub fn columns(&self) -> Option<ExprList<'a>> {
5037        GrammarNodeType::from_result(self.stmt_result, self.raw.columns)
5038    }
5039}
5040
5041impl<'a> GrammarNodeType<'a> for TriggerEvent<'a> {
5042    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5043        let raw = stmt_result.resolve_as::<super::ffi::TriggerEvent>(id)?;
5044        Some(TriggerEvent {
5045            raw,
5046            stmt_result,
5047            id,
5048        })
5049    }
5050}
5051
5052#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5053pub struct TriggerEventId(AnyNodeId);
5054
5055impl TriggerEventId {
5056    pub fn into_inner(self) -> AnyNodeId {
5057        self.0
5058    }
5059}
5060
5061impl<'a> From<TriggerEvent<'a>> for TriggerEventId {
5062    fn from(n: TriggerEvent<'a>) -> Self {
5063        n.node_id()
5064    }
5065}
5066
5067impl From<TriggerEventId> for AnyNodeId {
5068    fn from(id: TriggerEventId) -> AnyNodeId {
5069        id.0
5070    }
5071}
5072
5073impl TypedNodeId for TriggerEventId {
5074    type Node<'a> = TriggerEvent<'a>;
5075}
5076
5077#[derive(Clone, Copy)]
5078pub struct CreateTriggerStmt<'a> {
5079    raw: &'a super::ffi::CreateTriggerStmt,
5080    stmt_result: &'a AnyParsedStatement<'a>,
5081    id: AnyNodeId,
5082}
5083
5084impl std::fmt::Debug for CreateTriggerStmt<'_> {
5085    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5086        self.raw.fmt(f)
5087    }
5088}
5089
5090impl std::fmt::Display for CreateTriggerStmt<'_> {
5091    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5092        AnyNode {
5093            id: self.id,
5094            stmt_result: self.stmt_result,
5095        }
5096        .fmt(f)
5097    }
5098}
5099
5100impl<'a> CreateTriggerStmt<'a> {
5101    /// The typed node ID of this node.
5102    pub fn node_id(&self) -> CreateTriggerStmtId {
5103        CreateTriggerStmtId(self.id)
5104    }
5105    pub fn trigger_name(&self) -> &'a str {
5106        self.raw.trigger_name.as_str(self.stmt_result.source())
5107    }
5108    pub fn schema(&self) -> &'a str {
5109        self.raw.schema.as_str(self.stmt_result.source())
5110    }
5111    pub fn is_temp(&self) -> bool {
5112        self.raw.is_temp == super::ffi::Bool::True
5113    }
5114    pub fn if_not_exists(&self) -> bool {
5115        self.raw.if_not_exists == super::ffi::Bool::True
5116    }
5117    pub fn timing(&self) -> TriggerTiming {
5118        self.raw.timing
5119    }
5120    pub fn event(&self) -> Option<TriggerEvent<'a>> {
5121        GrammarNodeType::from_result(self.stmt_result, self.raw.event)
5122    }
5123    pub fn table(&self) -> Option<QualifiedName<'a>> {
5124        GrammarNodeType::from_result(self.stmt_result, self.raw.table)
5125    }
5126    pub fn when_expr(&self) -> Option<Expr<'a>> {
5127        GrammarNodeType::from_result(self.stmt_result, self.raw.when_expr)
5128    }
5129    pub fn body(&self) -> Option<TriggerCmdList<'a>> {
5130        GrammarNodeType::from_result(self.stmt_result, self.raw.body)
5131    }
5132}
5133
5134impl<'a> GrammarNodeType<'a> for CreateTriggerStmt<'a> {
5135    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5136        let raw = stmt_result.resolve_as::<super::ffi::CreateTriggerStmt>(id)?;
5137        Some(CreateTriggerStmt {
5138            raw,
5139            stmt_result,
5140            id,
5141        })
5142    }
5143}
5144
5145#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5146pub struct CreateTriggerStmtId(AnyNodeId);
5147
5148impl CreateTriggerStmtId {
5149    pub fn into_inner(self) -> AnyNodeId {
5150        self.0
5151    }
5152}
5153
5154impl<'a> From<CreateTriggerStmt<'a>> for CreateTriggerStmtId {
5155    fn from(n: CreateTriggerStmt<'a>) -> Self {
5156        n.node_id()
5157    }
5158}
5159
5160impl From<CreateTriggerStmtId> for AnyNodeId {
5161    fn from(id: CreateTriggerStmtId) -> AnyNodeId {
5162        id.0
5163    }
5164}
5165
5166impl TypedNodeId for CreateTriggerStmtId {
5167    type Node<'a> = CreateTriggerStmt<'a>;
5168}
5169
5170#[derive(Clone, Copy)]
5171pub struct CreateVirtualTableStmt<'a> {
5172    raw: &'a super::ffi::CreateVirtualTableStmt,
5173    stmt_result: &'a AnyParsedStatement<'a>,
5174    id: AnyNodeId,
5175}
5176
5177impl std::fmt::Debug for CreateVirtualTableStmt<'_> {
5178    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5179        self.raw.fmt(f)
5180    }
5181}
5182
5183impl std::fmt::Display for CreateVirtualTableStmt<'_> {
5184    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5185        AnyNode {
5186            id: self.id,
5187            stmt_result: self.stmt_result,
5188        }
5189        .fmt(f)
5190    }
5191}
5192
5193impl<'a> CreateVirtualTableStmt<'a> {
5194    /// The typed node ID of this node.
5195    pub fn node_id(&self) -> CreateVirtualTableStmtId {
5196        CreateVirtualTableStmtId(self.id)
5197    }
5198    pub fn table_name(&self) -> &'a str {
5199        self.raw.table_name.as_str(self.stmt_result.source())
5200    }
5201    pub fn schema(&self) -> &'a str {
5202        self.raw.schema.as_str(self.stmt_result.source())
5203    }
5204    pub fn module_name(&self) -> &'a str {
5205        self.raw.module_name.as_str(self.stmt_result.source())
5206    }
5207    pub fn if_not_exists(&self) -> bool {
5208        self.raw.if_not_exists == super::ffi::Bool::True
5209    }
5210    pub fn module_args(&self) -> &'a str {
5211        self.raw.module_args.as_str(self.stmt_result.source())
5212    }
5213}
5214
5215impl<'a> GrammarNodeType<'a> for CreateVirtualTableStmt<'a> {
5216    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5217        let raw = stmt_result.resolve_as::<super::ffi::CreateVirtualTableStmt>(id)?;
5218        Some(CreateVirtualTableStmt {
5219            raw,
5220            stmt_result,
5221            id,
5222        })
5223    }
5224}
5225
5226#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5227pub struct CreateVirtualTableStmtId(AnyNodeId);
5228
5229impl CreateVirtualTableStmtId {
5230    pub fn into_inner(self) -> AnyNodeId {
5231        self.0
5232    }
5233}
5234
5235impl<'a> From<CreateVirtualTableStmt<'a>> for CreateVirtualTableStmtId {
5236    fn from(n: CreateVirtualTableStmt<'a>) -> Self {
5237        n.node_id()
5238    }
5239}
5240
5241impl From<CreateVirtualTableStmtId> for AnyNodeId {
5242    fn from(id: CreateVirtualTableStmtId) -> AnyNodeId {
5243        id.0
5244    }
5245}
5246
5247impl TypedNodeId for CreateVirtualTableStmtId {
5248    type Node<'a> = CreateVirtualTableStmt<'a>;
5249}
5250
5251#[derive(Clone, Copy)]
5252pub struct PragmaStmt<'a> {
5253    raw: &'a super::ffi::PragmaStmt,
5254    stmt_result: &'a AnyParsedStatement<'a>,
5255    id: AnyNodeId,
5256}
5257
5258impl std::fmt::Debug for PragmaStmt<'_> {
5259    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5260        self.raw.fmt(f)
5261    }
5262}
5263
5264impl std::fmt::Display for PragmaStmt<'_> {
5265    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5266        AnyNode {
5267            id: self.id,
5268            stmt_result: self.stmt_result,
5269        }
5270        .fmt(f)
5271    }
5272}
5273
5274impl<'a> PragmaStmt<'a> {
5275    /// The typed node ID of this node.
5276    pub fn node_id(&self) -> PragmaStmtId {
5277        PragmaStmtId(self.id)
5278    }
5279    pub fn pragma_name(&self) -> &'a str {
5280        self.raw.pragma_name.as_str(self.stmt_result.source())
5281    }
5282    pub fn schema(&self) -> &'a str {
5283        self.raw.schema.as_str(self.stmt_result.source())
5284    }
5285    pub fn value(&self) -> &'a str {
5286        self.raw.value.as_str(self.stmt_result.source())
5287    }
5288    pub fn pragma_form(&self) -> PragmaForm {
5289        self.raw.pragma_form
5290    }
5291}
5292
5293impl<'a> GrammarNodeType<'a> for PragmaStmt<'a> {
5294    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5295        let raw = stmt_result.resolve_as::<super::ffi::PragmaStmt>(id)?;
5296        Some(PragmaStmt {
5297            raw,
5298            stmt_result,
5299            id,
5300        })
5301    }
5302}
5303
5304#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5305pub struct PragmaStmtId(AnyNodeId);
5306
5307impl PragmaStmtId {
5308    pub fn into_inner(self) -> AnyNodeId {
5309        self.0
5310    }
5311}
5312
5313impl<'a> From<PragmaStmt<'a>> for PragmaStmtId {
5314    fn from(n: PragmaStmt<'a>) -> Self {
5315        n.node_id()
5316    }
5317}
5318
5319impl From<PragmaStmtId> for AnyNodeId {
5320    fn from(id: PragmaStmtId) -> AnyNodeId {
5321        id.0
5322    }
5323}
5324
5325impl TypedNodeId for PragmaStmtId {
5326    type Node<'a> = PragmaStmt<'a>;
5327}
5328
5329#[derive(Clone, Copy)]
5330pub struct AnalyzeOrReindexStmt<'a> {
5331    raw: &'a super::ffi::AnalyzeOrReindexStmt,
5332    stmt_result: &'a AnyParsedStatement<'a>,
5333    id: AnyNodeId,
5334}
5335
5336impl std::fmt::Debug for AnalyzeOrReindexStmt<'_> {
5337    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5338        self.raw.fmt(f)
5339    }
5340}
5341
5342impl std::fmt::Display for AnalyzeOrReindexStmt<'_> {
5343    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5344        AnyNode {
5345            id: self.id,
5346            stmt_result: self.stmt_result,
5347        }
5348        .fmt(f)
5349    }
5350}
5351
5352impl<'a> AnalyzeOrReindexStmt<'a> {
5353    /// The typed node ID of this node.
5354    pub fn node_id(&self) -> AnalyzeOrReindexStmtId {
5355        AnalyzeOrReindexStmtId(self.id)
5356    }
5357    pub fn target_name(&self) -> &'a str {
5358        self.raw.target_name.as_str(self.stmt_result.source())
5359    }
5360    pub fn schema(&self) -> &'a str {
5361        self.raw.schema.as_str(self.stmt_result.source())
5362    }
5363    pub fn kind(&self) -> AnalyzeOrReindexOp {
5364        self.raw.kind
5365    }
5366}
5367
5368impl<'a> GrammarNodeType<'a> for AnalyzeOrReindexStmt<'a> {
5369    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5370        let raw = stmt_result.resolve_as::<super::ffi::AnalyzeOrReindexStmt>(id)?;
5371        Some(AnalyzeOrReindexStmt {
5372            raw,
5373            stmt_result,
5374            id,
5375        })
5376    }
5377}
5378
5379#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5380pub struct AnalyzeOrReindexStmtId(AnyNodeId);
5381
5382impl AnalyzeOrReindexStmtId {
5383    pub fn into_inner(self) -> AnyNodeId {
5384        self.0
5385    }
5386}
5387
5388impl<'a> From<AnalyzeOrReindexStmt<'a>> for AnalyzeOrReindexStmtId {
5389    fn from(n: AnalyzeOrReindexStmt<'a>) -> Self {
5390        n.node_id()
5391    }
5392}
5393
5394impl From<AnalyzeOrReindexStmtId> for AnyNodeId {
5395    fn from(id: AnalyzeOrReindexStmtId) -> AnyNodeId {
5396        id.0
5397    }
5398}
5399
5400impl TypedNodeId for AnalyzeOrReindexStmtId {
5401    type Node<'a> = AnalyzeOrReindexStmt<'a>;
5402}
5403
5404#[derive(Clone, Copy)]
5405pub struct AttachStmt<'a> {
5406    raw: &'a super::ffi::AttachStmt,
5407    stmt_result: &'a AnyParsedStatement<'a>,
5408    id: AnyNodeId,
5409}
5410
5411impl std::fmt::Debug for AttachStmt<'_> {
5412    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5413        self.raw.fmt(f)
5414    }
5415}
5416
5417impl std::fmt::Display for AttachStmt<'_> {
5418    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5419        AnyNode {
5420            id: self.id,
5421            stmt_result: self.stmt_result,
5422        }
5423        .fmt(f)
5424    }
5425}
5426
5427impl<'a> AttachStmt<'a> {
5428    /// The typed node ID of this node.
5429    pub fn node_id(&self) -> AttachStmtId {
5430        AttachStmtId(self.id)
5431    }
5432    pub fn filename(&self) -> Option<Expr<'a>> {
5433        GrammarNodeType::from_result(self.stmt_result, self.raw.filename)
5434    }
5435    pub fn db_name(&self) -> Option<Expr<'a>> {
5436        GrammarNodeType::from_result(self.stmt_result, self.raw.db_name)
5437    }
5438    pub fn key(&self) -> Option<Expr<'a>> {
5439        GrammarNodeType::from_result(self.stmt_result, self.raw.key)
5440    }
5441}
5442
5443impl<'a> GrammarNodeType<'a> for AttachStmt<'a> {
5444    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5445        let raw = stmt_result.resolve_as::<super::ffi::AttachStmt>(id)?;
5446        Some(AttachStmt {
5447            raw,
5448            stmt_result,
5449            id,
5450        })
5451    }
5452}
5453
5454#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5455pub struct AttachStmtId(AnyNodeId);
5456
5457impl AttachStmtId {
5458    pub fn into_inner(self) -> AnyNodeId {
5459        self.0
5460    }
5461}
5462
5463impl<'a> From<AttachStmt<'a>> for AttachStmtId {
5464    fn from(n: AttachStmt<'a>) -> Self {
5465        n.node_id()
5466    }
5467}
5468
5469impl From<AttachStmtId> for AnyNodeId {
5470    fn from(id: AttachStmtId) -> AnyNodeId {
5471        id.0
5472    }
5473}
5474
5475impl TypedNodeId for AttachStmtId {
5476    type Node<'a> = AttachStmt<'a>;
5477}
5478
5479#[derive(Clone, Copy)]
5480pub struct DetachStmt<'a> {
5481    raw: &'a super::ffi::DetachStmt,
5482    stmt_result: &'a AnyParsedStatement<'a>,
5483    id: AnyNodeId,
5484}
5485
5486impl std::fmt::Debug for DetachStmt<'_> {
5487    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5488        self.raw.fmt(f)
5489    }
5490}
5491
5492impl std::fmt::Display for DetachStmt<'_> {
5493    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5494        AnyNode {
5495            id: self.id,
5496            stmt_result: self.stmt_result,
5497        }
5498        .fmt(f)
5499    }
5500}
5501
5502impl<'a> DetachStmt<'a> {
5503    /// The typed node ID of this node.
5504    pub fn node_id(&self) -> DetachStmtId {
5505        DetachStmtId(self.id)
5506    }
5507    pub fn db_name(&self) -> Option<Expr<'a>> {
5508        GrammarNodeType::from_result(self.stmt_result, self.raw.db_name)
5509    }
5510}
5511
5512impl<'a> GrammarNodeType<'a> for DetachStmt<'a> {
5513    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5514        let raw = stmt_result.resolve_as::<super::ffi::DetachStmt>(id)?;
5515        Some(DetachStmt {
5516            raw,
5517            stmt_result,
5518            id,
5519        })
5520    }
5521}
5522
5523#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5524pub struct DetachStmtId(AnyNodeId);
5525
5526impl DetachStmtId {
5527    pub fn into_inner(self) -> AnyNodeId {
5528        self.0
5529    }
5530}
5531
5532impl<'a> From<DetachStmt<'a>> for DetachStmtId {
5533    fn from(n: DetachStmt<'a>) -> Self {
5534        n.node_id()
5535    }
5536}
5537
5538impl From<DetachStmtId> for AnyNodeId {
5539    fn from(id: DetachStmtId) -> AnyNodeId {
5540        id.0
5541    }
5542}
5543
5544impl TypedNodeId for DetachStmtId {
5545    type Node<'a> = DetachStmt<'a>;
5546}
5547
5548#[derive(Clone, Copy)]
5549pub struct VacuumStmt<'a> {
5550    raw: &'a super::ffi::VacuumStmt,
5551    stmt_result: &'a AnyParsedStatement<'a>,
5552    id: AnyNodeId,
5553}
5554
5555impl std::fmt::Debug for VacuumStmt<'_> {
5556    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5557        self.raw.fmt(f)
5558    }
5559}
5560
5561impl std::fmt::Display for VacuumStmt<'_> {
5562    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5563        AnyNode {
5564            id: self.id,
5565            stmt_result: self.stmt_result,
5566        }
5567        .fmt(f)
5568    }
5569}
5570
5571impl<'a> VacuumStmt<'a> {
5572    /// The typed node ID of this node.
5573    pub fn node_id(&self) -> VacuumStmtId {
5574        VacuumStmtId(self.id)
5575    }
5576    pub fn schema(&self) -> &'a str {
5577        self.raw.schema.as_str(self.stmt_result.source())
5578    }
5579    pub fn filename(&self) -> Option<Expr<'a>> {
5580        GrammarNodeType::from_result(self.stmt_result, self.raw.filename)
5581    }
5582}
5583
5584impl<'a> GrammarNodeType<'a> for VacuumStmt<'a> {
5585    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5586        let raw = stmt_result.resolve_as::<super::ffi::VacuumStmt>(id)?;
5587        Some(VacuumStmt {
5588            raw,
5589            stmt_result,
5590            id,
5591        })
5592    }
5593}
5594
5595#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5596pub struct VacuumStmtId(AnyNodeId);
5597
5598impl VacuumStmtId {
5599    pub fn into_inner(self) -> AnyNodeId {
5600        self.0
5601    }
5602}
5603
5604impl<'a> From<VacuumStmt<'a>> for VacuumStmtId {
5605    fn from(n: VacuumStmt<'a>) -> Self {
5606        n.node_id()
5607    }
5608}
5609
5610impl From<VacuumStmtId> for AnyNodeId {
5611    fn from(id: VacuumStmtId) -> AnyNodeId {
5612        id.0
5613    }
5614}
5615
5616impl TypedNodeId for VacuumStmtId {
5617    type Node<'a> = VacuumStmt<'a>;
5618}
5619
5620#[derive(Clone, Copy)]
5621pub struct ExplainStmt<'a> {
5622    raw: &'a super::ffi::ExplainStmt,
5623    stmt_result: &'a AnyParsedStatement<'a>,
5624    id: AnyNodeId,
5625}
5626
5627impl std::fmt::Debug for ExplainStmt<'_> {
5628    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5629        self.raw.fmt(f)
5630    }
5631}
5632
5633impl std::fmt::Display for ExplainStmt<'_> {
5634    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5635        AnyNode {
5636            id: self.id,
5637            stmt_result: self.stmt_result,
5638        }
5639        .fmt(f)
5640    }
5641}
5642
5643impl<'a> ExplainStmt<'a> {
5644    /// The typed node ID of this node.
5645    pub fn node_id(&self) -> ExplainStmtId {
5646        ExplainStmtId(self.id)
5647    }
5648    pub fn explain_mode(&self) -> ExplainMode {
5649        self.raw.explain_mode
5650    }
5651    pub fn stmt(&self) -> Option<Stmt<'a>> {
5652        GrammarNodeType::from_result(self.stmt_result, self.raw.stmt)
5653    }
5654}
5655
5656impl<'a> GrammarNodeType<'a> for ExplainStmt<'a> {
5657    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5658        let raw = stmt_result.resolve_as::<super::ffi::ExplainStmt>(id)?;
5659        Some(ExplainStmt {
5660            raw,
5661            stmt_result,
5662            id,
5663        })
5664    }
5665}
5666
5667#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5668pub struct ExplainStmtId(AnyNodeId);
5669
5670impl ExplainStmtId {
5671    pub fn into_inner(self) -> AnyNodeId {
5672        self.0
5673    }
5674}
5675
5676impl<'a> From<ExplainStmt<'a>> for ExplainStmtId {
5677    fn from(n: ExplainStmt<'a>) -> Self {
5678        n.node_id()
5679    }
5680}
5681
5682impl From<ExplainStmtId> for AnyNodeId {
5683    fn from(id: ExplainStmtId) -> AnyNodeId {
5684        id.0
5685    }
5686}
5687
5688impl TypedNodeId for ExplainStmtId {
5689    type Node<'a> = ExplainStmt<'a>;
5690}
5691
5692#[derive(Clone, Copy)]
5693pub struct CreateIndexStmt<'a> {
5694    raw: &'a super::ffi::CreateIndexStmt,
5695    stmt_result: &'a AnyParsedStatement<'a>,
5696    id: AnyNodeId,
5697}
5698
5699impl std::fmt::Debug for CreateIndexStmt<'_> {
5700    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5701        self.raw.fmt(f)
5702    }
5703}
5704
5705impl std::fmt::Display for CreateIndexStmt<'_> {
5706    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5707        AnyNode {
5708            id: self.id,
5709            stmt_result: self.stmt_result,
5710        }
5711        .fmt(f)
5712    }
5713}
5714
5715impl<'a> CreateIndexStmt<'a> {
5716    /// The typed node ID of this node.
5717    pub fn node_id(&self) -> CreateIndexStmtId {
5718        CreateIndexStmtId(self.id)
5719    }
5720    pub fn index_name(&self) -> &'a str {
5721        self.raw.index_name.as_str(self.stmt_result.source())
5722    }
5723    pub fn schema(&self) -> &'a str {
5724        self.raw.schema.as_str(self.stmt_result.source())
5725    }
5726    pub fn table_name(&self) -> &'a str {
5727        self.raw.table_name.as_str(self.stmt_result.source())
5728    }
5729    pub fn is_unique(&self) -> bool {
5730        self.raw.is_unique == super::ffi::Bool::True
5731    }
5732    pub fn if_not_exists(&self) -> bool {
5733        self.raw.if_not_exists == super::ffi::Bool::True
5734    }
5735    pub fn columns(&self) -> Option<OrderByList<'a>> {
5736        GrammarNodeType::from_result(self.stmt_result, self.raw.columns)
5737    }
5738    pub fn where_clause(&self) -> Option<Expr<'a>> {
5739        GrammarNodeType::from_result(self.stmt_result, self.raw.where_clause)
5740    }
5741}
5742
5743impl<'a> GrammarNodeType<'a> for CreateIndexStmt<'a> {
5744    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5745        let raw = stmt_result.resolve_as::<super::ffi::CreateIndexStmt>(id)?;
5746        Some(CreateIndexStmt {
5747            raw,
5748            stmt_result,
5749            id,
5750        })
5751    }
5752}
5753
5754#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5755pub struct CreateIndexStmtId(AnyNodeId);
5756
5757impl CreateIndexStmtId {
5758    pub fn into_inner(self) -> AnyNodeId {
5759        self.0
5760    }
5761}
5762
5763impl<'a> From<CreateIndexStmt<'a>> for CreateIndexStmtId {
5764    fn from(n: CreateIndexStmt<'a>) -> Self {
5765        n.node_id()
5766    }
5767}
5768
5769impl From<CreateIndexStmtId> for AnyNodeId {
5770    fn from(id: CreateIndexStmtId) -> AnyNodeId {
5771        id.0
5772    }
5773}
5774
5775impl TypedNodeId for CreateIndexStmtId {
5776    type Node<'a> = CreateIndexStmt<'a>;
5777}
5778
5779#[derive(Clone, Copy)]
5780pub struct CreateViewStmt<'a> {
5781    raw: &'a super::ffi::CreateViewStmt,
5782    stmt_result: &'a AnyParsedStatement<'a>,
5783    id: AnyNodeId,
5784}
5785
5786impl std::fmt::Debug for CreateViewStmt<'_> {
5787    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5788        self.raw.fmt(f)
5789    }
5790}
5791
5792impl std::fmt::Display for CreateViewStmt<'_> {
5793    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5794        AnyNode {
5795            id: self.id,
5796            stmt_result: self.stmt_result,
5797        }
5798        .fmt(f)
5799    }
5800}
5801
5802impl<'a> CreateViewStmt<'a> {
5803    /// The typed node ID of this node.
5804    pub fn node_id(&self) -> CreateViewStmtId {
5805        CreateViewStmtId(self.id)
5806    }
5807    pub fn view_name(&self) -> &'a str {
5808        self.raw.view_name.as_str(self.stmt_result.source())
5809    }
5810    pub fn schema(&self) -> &'a str {
5811        self.raw.schema.as_str(self.stmt_result.source())
5812    }
5813    pub fn is_temp(&self) -> bool {
5814        self.raw.is_temp == super::ffi::Bool::True
5815    }
5816    pub fn if_not_exists(&self) -> bool {
5817        self.raw.if_not_exists == super::ffi::Bool::True
5818    }
5819    pub fn column_names(&self) -> Option<ExprList<'a>> {
5820        GrammarNodeType::from_result(self.stmt_result, self.raw.column_names)
5821    }
5822    pub fn select(&self) -> Option<Select<'a>> {
5823        GrammarNodeType::from_result(self.stmt_result, self.raw.select)
5824    }
5825}
5826
5827impl<'a> GrammarNodeType<'a> for CreateViewStmt<'a> {
5828    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5829        let raw = stmt_result.resolve_as::<super::ffi::CreateViewStmt>(id)?;
5830        Some(CreateViewStmt {
5831            raw,
5832            stmt_result,
5833            id,
5834        })
5835    }
5836}
5837
5838#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5839pub struct CreateViewStmtId(AnyNodeId);
5840
5841impl CreateViewStmtId {
5842    pub fn into_inner(self) -> AnyNodeId {
5843        self.0
5844    }
5845}
5846
5847impl<'a> From<CreateViewStmt<'a>> for CreateViewStmtId {
5848    fn from(n: CreateViewStmt<'a>) -> Self {
5849        n.node_id()
5850    }
5851}
5852
5853impl From<CreateViewStmtId> for AnyNodeId {
5854    fn from(id: CreateViewStmtId) -> AnyNodeId {
5855        id.0
5856    }
5857}
5858
5859impl TypedNodeId for CreateViewStmtId {
5860    type Node<'a> = CreateViewStmt<'a>;
5861}
5862
5863#[derive(Clone, Copy)]
5864pub struct ValuesClause<'a> {
5865    raw: &'a super::ffi::ValuesClause,
5866    stmt_result: &'a AnyParsedStatement<'a>,
5867    id: AnyNodeId,
5868}
5869
5870impl std::fmt::Debug for ValuesClause<'_> {
5871    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5872        self.raw.fmt(f)
5873    }
5874}
5875
5876impl std::fmt::Display for ValuesClause<'_> {
5877    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5878        AnyNode {
5879            id: self.id,
5880            stmt_result: self.stmt_result,
5881        }
5882        .fmt(f)
5883    }
5884}
5885
5886impl<'a> ValuesClause<'a> {
5887    /// The typed node ID of this node.
5888    pub fn node_id(&self) -> ValuesClauseId {
5889        ValuesClauseId(self.id)
5890    }
5891    pub fn rows(&self) -> Option<ValuesRowList<'a>> {
5892        GrammarNodeType::from_result(self.stmt_result, self.raw.rows)
5893    }
5894}
5895
5896impl<'a> GrammarNodeType<'a> for ValuesClause<'a> {
5897    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5898        let raw = stmt_result.resolve_as::<super::ffi::ValuesClause>(id)?;
5899        Some(ValuesClause {
5900            raw,
5901            stmt_result,
5902            id,
5903        })
5904    }
5905}
5906
5907#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5908pub struct ValuesClauseId(AnyNodeId);
5909
5910impl ValuesClauseId {
5911    pub fn into_inner(self) -> AnyNodeId {
5912        self.0
5913    }
5914}
5915
5916impl<'a> From<ValuesClause<'a>> for ValuesClauseId {
5917    fn from(n: ValuesClause<'a>) -> Self {
5918        n.node_id()
5919    }
5920}
5921
5922impl From<ValuesClauseId> for AnyNodeId {
5923    fn from(id: ValuesClauseId) -> AnyNodeId {
5924        id.0
5925    }
5926}
5927
5928impl TypedNodeId for ValuesClauseId {
5929    type Node<'a> = ValuesClause<'a>;
5930}
5931
5932#[derive(Clone, Copy)]
5933pub struct FrameBound<'a> {
5934    raw: &'a super::ffi::FrameBound,
5935    stmt_result: &'a AnyParsedStatement<'a>,
5936    id: AnyNodeId,
5937}
5938
5939impl std::fmt::Debug for FrameBound<'_> {
5940    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5941        self.raw.fmt(f)
5942    }
5943}
5944
5945impl std::fmt::Display for FrameBound<'_> {
5946    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5947        AnyNode {
5948            id: self.id,
5949            stmt_result: self.stmt_result,
5950        }
5951        .fmt(f)
5952    }
5953}
5954
5955impl<'a> FrameBound<'a> {
5956    /// The typed node ID of this node.
5957    pub fn node_id(&self) -> FrameBoundId {
5958        FrameBoundId(self.id)
5959    }
5960    pub fn bound_type(&self) -> FrameBoundType {
5961        self.raw.bound_type
5962    }
5963    pub fn expr(&self) -> Option<Expr<'a>> {
5964        GrammarNodeType::from_result(self.stmt_result, self.raw.expr)
5965    }
5966}
5967
5968impl<'a> GrammarNodeType<'a> for FrameBound<'a> {
5969    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
5970        let raw = stmt_result.resolve_as::<super::ffi::FrameBound>(id)?;
5971        Some(FrameBound {
5972            raw,
5973            stmt_result,
5974            id,
5975        })
5976    }
5977}
5978
5979#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5980pub struct FrameBoundId(AnyNodeId);
5981
5982impl FrameBoundId {
5983    pub fn into_inner(self) -> AnyNodeId {
5984        self.0
5985    }
5986}
5987
5988impl<'a> From<FrameBound<'a>> for FrameBoundId {
5989    fn from(n: FrameBound<'a>) -> Self {
5990        n.node_id()
5991    }
5992}
5993
5994impl From<FrameBoundId> for AnyNodeId {
5995    fn from(id: FrameBoundId) -> AnyNodeId {
5996        id.0
5997    }
5998}
5999
6000impl TypedNodeId for FrameBoundId {
6001    type Node<'a> = FrameBound<'a>;
6002}
6003
6004#[derive(Clone, Copy)]
6005pub struct FrameSpec<'a> {
6006    raw: &'a super::ffi::FrameSpec,
6007    stmt_result: &'a AnyParsedStatement<'a>,
6008    id: AnyNodeId,
6009}
6010
6011impl std::fmt::Debug for FrameSpec<'_> {
6012    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6013        self.raw.fmt(f)
6014    }
6015}
6016
6017impl std::fmt::Display for FrameSpec<'_> {
6018    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6019        AnyNode {
6020            id: self.id,
6021            stmt_result: self.stmt_result,
6022        }
6023        .fmt(f)
6024    }
6025}
6026
6027impl<'a> FrameSpec<'a> {
6028    /// The typed node ID of this node.
6029    pub fn node_id(&self) -> FrameSpecId {
6030        FrameSpecId(self.id)
6031    }
6032    pub fn frame_type(&self) -> FrameType {
6033        self.raw.frame_type
6034    }
6035    pub fn exclude(&self) -> FrameExclude {
6036        self.raw.exclude
6037    }
6038    pub fn start_bound(&self) -> Option<FrameBound<'a>> {
6039        GrammarNodeType::from_result(self.stmt_result, self.raw.start_bound)
6040    }
6041    pub fn end_bound(&self) -> Option<FrameBound<'a>> {
6042        GrammarNodeType::from_result(self.stmt_result, self.raw.end_bound)
6043    }
6044}
6045
6046impl<'a> GrammarNodeType<'a> for FrameSpec<'a> {
6047    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
6048        let raw = stmt_result.resolve_as::<super::ffi::FrameSpec>(id)?;
6049        Some(FrameSpec {
6050            raw,
6051            stmt_result,
6052            id,
6053        })
6054    }
6055}
6056
6057#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6058pub struct FrameSpecId(AnyNodeId);
6059
6060impl FrameSpecId {
6061    pub fn into_inner(self) -> AnyNodeId {
6062        self.0
6063    }
6064}
6065
6066impl<'a> From<FrameSpec<'a>> for FrameSpecId {
6067    fn from(n: FrameSpec<'a>) -> Self {
6068        n.node_id()
6069    }
6070}
6071
6072impl From<FrameSpecId> for AnyNodeId {
6073    fn from(id: FrameSpecId) -> AnyNodeId {
6074        id.0
6075    }
6076}
6077
6078impl TypedNodeId for FrameSpecId {
6079    type Node<'a> = FrameSpec<'a>;
6080}
6081
6082#[derive(Clone, Copy)]
6083pub struct WindowDef<'a> {
6084    raw: &'a super::ffi::WindowDef,
6085    stmt_result: &'a AnyParsedStatement<'a>,
6086    id: AnyNodeId,
6087}
6088
6089impl std::fmt::Debug for WindowDef<'_> {
6090    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6091        self.raw.fmt(f)
6092    }
6093}
6094
6095impl std::fmt::Display for WindowDef<'_> {
6096    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6097        AnyNode {
6098            id: self.id,
6099            stmt_result: self.stmt_result,
6100        }
6101        .fmt(f)
6102    }
6103}
6104
6105impl<'a> WindowDef<'a> {
6106    /// The typed node ID of this node.
6107    pub fn node_id(&self) -> WindowDefId {
6108        WindowDefId(self.id)
6109    }
6110    pub fn base_window_name(&self) -> &'a str {
6111        self.raw.base_window_name.as_str(self.stmt_result.source())
6112    }
6113    pub fn partition_by(&self) -> Option<ExprList<'a>> {
6114        GrammarNodeType::from_result(self.stmt_result, self.raw.partition_by)
6115    }
6116    pub fn orderby(&self) -> Option<OrderByList<'a>> {
6117        GrammarNodeType::from_result(self.stmt_result, self.raw.orderby)
6118    }
6119    pub fn frame(&self) -> Option<FrameSpec<'a>> {
6120        GrammarNodeType::from_result(self.stmt_result, self.raw.frame)
6121    }
6122}
6123
6124impl<'a> GrammarNodeType<'a> for WindowDef<'a> {
6125    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
6126        let raw = stmt_result.resolve_as::<super::ffi::WindowDef>(id)?;
6127        Some(WindowDef {
6128            raw,
6129            stmt_result,
6130            id,
6131        })
6132    }
6133}
6134
6135#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6136pub struct WindowDefId(AnyNodeId);
6137
6138impl WindowDefId {
6139    pub fn into_inner(self) -> AnyNodeId {
6140        self.0
6141    }
6142}
6143
6144impl<'a> From<WindowDef<'a>> for WindowDefId {
6145    fn from(n: WindowDef<'a>) -> Self {
6146        n.node_id()
6147    }
6148}
6149
6150impl From<WindowDefId> for AnyNodeId {
6151    fn from(id: WindowDefId) -> AnyNodeId {
6152        id.0
6153    }
6154}
6155
6156impl TypedNodeId for WindowDefId {
6157    type Node<'a> = WindowDef<'a>;
6158}
6159
6160#[derive(Clone, Copy)]
6161pub struct NamedWindowDef<'a> {
6162    raw: &'a super::ffi::NamedWindowDef,
6163    stmt_result: &'a AnyParsedStatement<'a>,
6164    id: AnyNodeId,
6165}
6166
6167impl std::fmt::Debug for NamedWindowDef<'_> {
6168    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6169        self.raw.fmt(f)
6170    }
6171}
6172
6173impl std::fmt::Display for NamedWindowDef<'_> {
6174    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6175        AnyNode {
6176            id: self.id,
6177            stmt_result: self.stmt_result,
6178        }
6179        .fmt(f)
6180    }
6181}
6182
6183impl<'a> NamedWindowDef<'a> {
6184    /// The typed node ID of this node.
6185    pub fn node_id(&self) -> NamedWindowDefId {
6186        NamedWindowDefId(self.id)
6187    }
6188    pub fn window_name(&self) -> &'a str {
6189        self.raw.window_name.as_str(self.stmt_result.source())
6190    }
6191    pub fn window_def(&self) -> Option<WindowDef<'a>> {
6192        GrammarNodeType::from_result(self.stmt_result, self.raw.window_def)
6193    }
6194}
6195
6196impl<'a> GrammarNodeType<'a> for NamedWindowDef<'a> {
6197    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
6198        let raw = stmt_result.resolve_as::<super::ffi::NamedWindowDef>(id)?;
6199        Some(NamedWindowDef {
6200            raw,
6201            stmt_result,
6202            id,
6203        })
6204    }
6205}
6206
6207#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6208pub struct NamedWindowDefId(AnyNodeId);
6209
6210impl NamedWindowDefId {
6211    pub fn into_inner(self) -> AnyNodeId {
6212        self.0
6213    }
6214}
6215
6216impl<'a> From<NamedWindowDef<'a>> for NamedWindowDefId {
6217    fn from(n: NamedWindowDef<'a>) -> Self {
6218        n.node_id()
6219    }
6220}
6221
6222impl From<NamedWindowDefId> for AnyNodeId {
6223    fn from(id: NamedWindowDefId) -> AnyNodeId {
6224        id.0
6225    }
6226}
6227
6228impl TypedNodeId for NamedWindowDefId {
6229    type Node<'a> = NamedWindowDef<'a>;
6230}
6231
6232#[derive(Clone, Copy)]
6233pub struct FilterOver<'a> {
6234    raw: &'a super::ffi::FilterOver,
6235    stmt_result: &'a AnyParsedStatement<'a>,
6236    id: AnyNodeId,
6237}
6238
6239impl std::fmt::Debug for FilterOver<'_> {
6240    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6241        self.raw.fmt(f)
6242    }
6243}
6244
6245impl std::fmt::Display for FilterOver<'_> {
6246    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6247        AnyNode {
6248            id: self.id,
6249            stmt_result: self.stmt_result,
6250        }
6251        .fmt(f)
6252    }
6253}
6254
6255impl<'a> FilterOver<'a> {
6256    /// The typed node ID of this node.
6257    pub fn node_id(&self) -> FilterOverId {
6258        FilterOverId(self.id)
6259    }
6260    pub fn filter_expr(&self) -> Option<Expr<'a>> {
6261        GrammarNodeType::from_result(self.stmt_result, self.raw.filter_expr)
6262    }
6263    pub fn over_def(&self) -> Option<WindowDef<'a>> {
6264        GrammarNodeType::from_result(self.stmt_result, self.raw.over_def)
6265    }
6266    pub fn over_name(&self) -> &'a str {
6267        self.raw.over_name.as_str(self.stmt_result.source())
6268    }
6269}
6270
6271impl<'a> GrammarNodeType<'a> for FilterOver<'a> {
6272    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
6273        let raw = stmt_result.resolve_as::<super::ffi::FilterOver>(id)?;
6274        Some(FilterOver {
6275            raw,
6276            stmt_result,
6277            id,
6278        })
6279    }
6280}
6281
6282#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6283pub struct FilterOverId(AnyNodeId);
6284
6285impl FilterOverId {
6286    pub fn into_inner(self) -> AnyNodeId {
6287        self.0
6288    }
6289}
6290
6291impl<'a> From<FilterOver<'a>> for FilterOverId {
6292    fn from(n: FilterOver<'a>) -> Self {
6293        n.node_id()
6294    }
6295}
6296
6297impl From<FilterOverId> for AnyNodeId {
6298    fn from(id: FilterOverId) -> AnyNodeId {
6299        id.0
6300    }
6301}
6302
6303impl TypedNodeId for FilterOverId {
6304    type Node<'a> = FilterOver<'a>;
6305}
6306
6307/// Typed list of `CaseWhen`.
6308pub type CaseWhenList<'a> = TypedNodeList<'a, super::grammar::Grammar, CaseWhen<'a>>;
6309
6310#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6311pub struct CaseWhenListId(AnyNodeId);
6312
6313impl CaseWhenListId {
6314    pub fn into_inner(self) -> AnyNodeId {
6315        self.0
6316    }
6317}
6318
6319impl<'a> From<CaseWhenList<'a>> for CaseWhenListId {
6320    fn from(n: CaseWhenList<'a>) -> Self {
6321        CaseWhenListId(n.node_id().into())
6322    }
6323}
6324
6325impl From<CaseWhenListId> for AnyNodeId {
6326    fn from(id: CaseWhenListId) -> AnyNodeId {
6327        id.0
6328    }
6329}
6330
6331impl TypedNodeId for CaseWhenListId {
6332    type Node<'a> = CaseWhenList<'a>;
6333}
6334
6335/// Typed list of `ColumnConstraint`.
6336pub type ColumnConstraintList<'a> =
6337    TypedNodeList<'a, super::grammar::Grammar, ColumnConstraint<'a>>;
6338
6339#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6340pub struct ColumnConstraintListId(AnyNodeId);
6341
6342impl ColumnConstraintListId {
6343    pub fn into_inner(self) -> AnyNodeId {
6344        self.0
6345    }
6346}
6347
6348impl<'a> From<ColumnConstraintList<'a>> for ColumnConstraintListId {
6349    fn from(n: ColumnConstraintList<'a>) -> Self {
6350        ColumnConstraintListId(n.node_id().into())
6351    }
6352}
6353
6354impl From<ColumnConstraintListId> for AnyNodeId {
6355    fn from(id: ColumnConstraintListId) -> AnyNodeId {
6356        id.0
6357    }
6358}
6359
6360impl TypedNodeId for ColumnConstraintListId {
6361    type Node<'a> = ColumnConstraintList<'a>;
6362}
6363
6364/// Typed list of `ColumnDef`.
6365pub type ColumnDefList<'a> = TypedNodeList<'a, super::grammar::Grammar, ColumnDef<'a>>;
6366
6367#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6368pub struct ColumnDefListId(AnyNodeId);
6369
6370impl ColumnDefListId {
6371    pub fn into_inner(self) -> AnyNodeId {
6372        self.0
6373    }
6374}
6375
6376impl<'a> From<ColumnDefList<'a>> for ColumnDefListId {
6377    fn from(n: ColumnDefList<'a>) -> Self {
6378        ColumnDefListId(n.node_id().into())
6379    }
6380}
6381
6382impl From<ColumnDefListId> for AnyNodeId {
6383    fn from(id: ColumnDefListId) -> AnyNodeId {
6384        id.0
6385    }
6386}
6387
6388impl TypedNodeId for ColumnDefListId {
6389    type Node<'a> = ColumnDefList<'a>;
6390}
6391
6392/// Typed list of `TableConstraint`.
6393pub type TableConstraintList<'a> = TypedNodeList<'a, super::grammar::Grammar, TableConstraint<'a>>;
6394
6395#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6396pub struct TableConstraintListId(AnyNodeId);
6397
6398impl TableConstraintListId {
6399    pub fn into_inner(self) -> AnyNodeId {
6400        self.0
6401    }
6402}
6403
6404impl<'a> From<TableConstraintList<'a>> for TableConstraintListId {
6405    fn from(n: TableConstraintList<'a>) -> Self {
6406        TableConstraintListId(n.node_id().into())
6407    }
6408}
6409
6410impl From<TableConstraintListId> for AnyNodeId {
6411    fn from(id: TableConstraintListId) -> AnyNodeId {
6412        id.0
6413    }
6414}
6415
6416impl TypedNodeId for TableConstraintListId {
6417    type Node<'a> = TableConstraintList<'a>;
6418}
6419
6420/// Typed list of `CteDefinition`.
6421pub type CteList<'a> = TypedNodeList<'a, super::grammar::Grammar, CteDefinition<'a>>;
6422
6423#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6424pub struct CteListId(AnyNodeId);
6425
6426impl CteListId {
6427    pub fn into_inner(self) -> AnyNodeId {
6428        self.0
6429    }
6430}
6431
6432impl<'a> From<CteList<'a>> for CteListId {
6433    fn from(n: CteList<'a>) -> Self {
6434        CteListId(n.node_id().into())
6435    }
6436}
6437
6438impl From<CteListId> for AnyNodeId {
6439    fn from(id: CteListId) -> AnyNodeId {
6440        id.0
6441    }
6442}
6443
6444impl TypedNodeId for CteListId {
6445    type Node<'a> = CteList<'a>;
6446}
6447
6448/// Typed list of `UpsertClause`.
6449pub type UpsertClauseList<'a> = TypedNodeList<'a, super::grammar::Grammar, UpsertClause<'a>>;
6450
6451#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6452pub struct UpsertClauseListId(AnyNodeId);
6453
6454impl UpsertClauseListId {
6455    pub fn into_inner(self) -> AnyNodeId {
6456        self.0
6457    }
6458}
6459
6460impl<'a> From<UpsertClauseList<'a>> for UpsertClauseListId {
6461    fn from(n: UpsertClauseList<'a>) -> Self {
6462        UpsertClauseListId(n.node_id().into())
6463    }
6464}
6465
6466impl From<UpsertClauseListId> for AnyNodeId {
6467    fn from(id: UpsertClauseListId) -> AnyNodeId {
6468        id.0
6469    }
6470}
6471
6472impl TypedNodeId for UpsertClauseListId {
6473    type Node<'a> = UpsertClauseList<'a>;
6474}
6475
6476/// Typed list of `SetClause`.
6477pub type SetClauseList<'a> = TypedNodeList<'a, super::grammar::Grammar, SetClause<'a>>;
6478
6479#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6480pub struct SetClauseListId(AnyNodeId);
6481
6482impl SetClauseListId {
6483    pub fn into_inner(self) -> AnyNodeId {
6484        self.0
6485    }
6486}
6487
6488impl<'a> From<SetClauseList<'a>> for SetClauseListId {
6489    fn from(n: SetClauseList<'a>) -> Self {
6490        SetClauseListId(n.node_id().into())
6491    }
6492}
6493
6494impl From<SetClauseListId> for AnyNodeId {
6495    fn from(id: SetClauseListId) -> AnyNodeId {
6496        id.0
6497    }
6498}
6499
6500impl TypedNodeId for SetClauseListId {
6501    type Node<'a> = SetClauseList<'a>;
6502}
6503
6504/// Typed list of `Expr`.
6505pub type ExprList<'a> = TypedNodeList<'a, super::grammar::Grammar, Expr<'a>>;
6506
6507#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6508pub struct ExprListId(AnyNodeId);
6509
6510impl ExprListId {
6511    pub fn into_inner(self) -> AnyNodeId {
6512        self.0
6513    }
6514}
6515
6516impl<'a> From<ExprList<'a>> for ExprListId {
6517    fn from(n: ExprList<'a>) -> Self {
6518        ExprListId(n.node_id().into())
6519    }
6520}
6521
6522impl From<ExprListId> for AnyNodeId {
6523    fn from(id: ExprListId) -> AnyNodeId {
6524        id.0
6525    }
6526}
6527
6528impl TypedNodeId for ExprListId {
6529    type Node<'a> = ExprList<'a>;
6530}
6531
6532/// Typed list of `ResultColumn`.
6533pub type ResultColumnList<'a> = TypedNodeList<'a, super::grammar::Grammar, ResultColumn<'a>>;
6534
6535#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6536pub struct ResultColumnListId(AnyNodeId);
6537
6538impl ResultColumnListId {
6539    pub fn into_inner(self) -> AnyNodeId {
6540        self.0
6541    }
6542}
6543
6544impl<'a> From<ResultColumnList<'a>> for ResultColumnListId {
6545    fn from(n: ResultColumnList<'a>) -> Self {
6546        ResultColumnListId(n.node_id().into())
6547    }
6548}
6549
6550impl From<ResultColumnListId> for AnyNodeId {
6551    fn from(id: ResultColumnListId) -> AnyNodeId {
6552        id.0
6553    }
6554}
6555
6556impl TypedNodeId for ResultColumnListId {
6557    type Node<'a> = ResultColumnList<'a>;
6558}
6559
6560/// Typed list of `OrderingTerm`.
6561pub type OrderByList<'a> = TypedNodeList<'a, super::grammar::Grammar, OrderingTerm<'a>>;
6562
6563#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6564pub struct OrderByListId(AnyNodeId);
6565
6566impl OrderByListId {
6567    pub fn into_inner(self) -> AnyNodeId {
6568        self.0
6569    }
6570}
6571
6572impl<'a> From<OrderByList<'a>> for OrderByListId {
6573    fn from(n: OrderByList<'a>) -> Self {
6574        OrderByListId(n.node_id().into())
6575    }
6576}
6577
6578impl From<OrderByListId> for AnyNodeId {
6579    fn from(id: OrderByListId) -> AnyNodeId {
6580        id.0
6581    }
6582}
6583
6584impl TypedNodeId for OrderByListId {
6585    type Node<'a> = OrderByList<'a>;
6586}
6587
6588/// Typed list of `Stmt`.
6589pub type TriggerCmdList<'a> = TypedNodeList<'a, super::grammar::Grammar, Stmt<'a>>;
6590
6591#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6592pub struct TriggerCmdListId(AnyNodeId);
6593
6594impl TriggerCmdListId {
6595    pub fn into_inner(self) -> AnyNodeId {
6596        self.0
6597    }
6598}
6599
6600impl<'a> From<TriggerCmdList<'a>> for TriggerCmdListId {
6601    fn from(n: TriggerCmdList<'a>) -> Self {
6602        TriggerCmdListId(n.node_id().into())
6603    }
6604}
6605
6606impl From<TriggerCmdListId> for AnyNodeId {
6607    fn from(id: TriggerCmdListId) -> AnyNodeId {
6608        id.0
6609    }
6610}
6611
6612impl TypedNodeId for TriggerCmdListId {
6613    type Node<'a> = TriggerCmdList<'a>;
6614}
6615
6616/// Typed list of `ExprList`.
6617pub type ValuesRowList<'a> = TypedNodeList<'a, super::grammar::Grammar, ExprList<'a>>;
6618
6619#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6620pub struct ValuesRowListId(AnyNodeId);
6621
6622impl ValuesRowListId {
6623    pub fn into_inner(self) -> AnyNodeId {
6624        self.0
6625    }
6626}
6627
6628impl<'a> From<ValuesRowList<'a>> for ValuesRowListId {
6629    fn from(n: ValuesRowList<'a>) -> Self {
6630        ValuesRowListId(n.node_id().into())
6631    }
6632}
6633
6634impl From<ValuesRowListId> for AnyNodeId {
6635    fn from(id: ValuesRowListId) -> AnyNodeId {
6636        id.0
6637    }
6638}
6639
6640impl TypedNodeId for ValuesRowListId {
6641    type Node<'a> = ValuesRowList<'a>;
6642}
6643
6644/// Typed list of `WindowDef`.
6645pub type WindowDefList<'a> = TypedNodeList<'a, super::grammar::Grammar, WindowDef<'a>>;
6646
6647#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6648pub struct WindowDefListId(AnyNodeId);
6649
6650impl WindowDefListId {
6651    pub fn into_inner(self) -> AnyNodeId {
6652        self.0
6653    }
6654}
6655
6656impl<'a> From<WindowDefList<'a>> for WindowDefListId {
6657    fn from(n: WindowDefList<'a>) -> Self {
6658        WindowDefListId(n.node_id().into())
6659    }
6660}
6661
6662impl From<WindowDefListId> for AnyNodeId {
6663    fn from(id: WindowDefListId) -> AnyNodeId {
6664        id.0
6665    }
6666}
6667
6668impl TypedNodeId for WindowDefListId {
6669    type Node<'a> = WindowDefList<'a>;
6670}
6671
6672/// Typed list of `NamedWindowDef`.
6673pub type NamedWindowDefList<'a> = TypedNodeList<'a, super::grammar::Grammar, NamedWindowDef<'a>>;
6674
6675#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6676pub struct NamedWindowDefListId(AnyNodeId);
6677
6678impl NamedWindowDefListId {
6679    pub fn into_inner(self) -> AnyNodeId {
6680        self.0
6681    }
6682}
6683
6684impl<'a> From<NamedWindowDefList<'a>> for NamedWindowDefListId {
6685    fn from(n: NamedWindowDefList<'a>) -> Self {
6686        NamedWindowDefListId(n.node_id().into())
6687    }
6688}
6689
6690impl From<NamedWindowDefListId> for AnyNodeId {
6691    fn from(id: NamedWindowDefListId) -> AnyNodeId {
6692        id.0
6693    }
6694}
6695
6696impl TypedNodeId for NamedWindowDefListId {
6697    type Node<'a> = NamedWindowDefList<'a>;
6698}
6699
6700/// A typed AST node. Pattern-match to access the concrete type.
6701#[derive(Debug, Clone, Copy)]
6702pub enum Node<'a> {
6703    AggregateFunctionCall(AggregateFunctionCall<'a>),
6704    OrderedSetFunctionCall(OrderedSetFunctionCall<'a>),
6705    CastExpr(CastExpr<'a>),
6706    ColumnRef(ColumnRef<'a>),
6707    CompoundSelect(CompoundSelect<'a>),
6708    SubqueryExpr(SubqueryExpr<'a>),
6709    ExistsExpr(ExistsExpr<'a>),
6710    InExpr(InExpr<'a>),
6711    IsExpr(IsExpr<'a>),
6712    BetweenExpr(BetweenExpr<'a>),
6713    LikeExpr(LikeExpr<'a>),
6714    CaseExpr(CaseExpr<'a>),
6715    CaseWhen(CaseWhen<'a>),
6716    /// List of [`CaseWhen`].
6717    CaseWhenList(CaseWhenList<'a>),
6718    ForeignKeyClause(ForeignKeyClause<'a>),
6719    ColumnConstraint(ColumnConstraint<'a>),
6720    /// List of [`ColumnConstraint`].
6721    ColumnConstraintList(ColumnConstraintList<'a>),
6722    ColumnDef(ColumnDef<'a>),
6723    /// List of [`ColumnDef`].
6724    ColumnDefList(ColumnDefList<'a>),
6725    TableConstraint(TableConstraint<'a>),
6726    /// List of [`TableConstraint`].
6727    TableConstraintList(TableConstraintList<'a>),
6728    CreateTableStmt(CreateTableStmt<'a>),
6729    CteDefinition(CteDefinition<'a>),
6730    /// List of [`CteDefinition`].
6731    CteList(CteList<'a>),
6732    WithClause(WithClause<'a>),
6733    UpsertClause(UpsertClause<'a>),
6734    /// List of [`UpsertClause`].
6735    UpsertClauseList(UpsertClauseList<'a>),
6736    DeleteStmt(DeleteStmt<'a>),
6737    SetClause(SetClause<'a>),
6738    /// List of [`SetClause`].
6739    SetClauseList(SetClauseList<'a>),
6740    UpdateStmt(UpdateStmt<'a>),
6741    InsertStmt(InsertStmt<'a>),
6742    BinaryExpr(BinaryExpr<'a>),
6743    UnaryExpr(UnaryExpr<'a>),
6744    Literal(Literal<'a>),
6745    IdentName(IdentName<'a>),
6746    Error(Error<'a>),
6747    /// List of [`Expr`].
6748    ExprList(ExprList<'a>),
6749    FunctionCall(FunctionCall<'a>),
6750    Variable(Variable<'a>),
6751    CollateExpr(CollateExpr<'a>),
6752    RaiseExpr(RaiseExpr<'a>),
6753    QualifiedName(QualifiedName<'a>),
6754    DropStmt(DropStmt<'a>),
6755    AlterTableStmt(AlterTableStmt<'a>),
6756    TransactionStmt(TransactionStmt<'a>),
6757    SavepointStmt(SavepointStmt<'a>),
6758    ResultColumn(ResultColumn<'a>),
6759    /// List of [`ResultColumn`].
6760    ResultColumnList(ResultColumnList<'a>),
6761    SelectStmt(SelectStmt<'a>),
6762    OrderingTerm(OrderingTerm<'a>),
6763    /// List of [`OrderingTerm`].
6764    OrderByList(OrderByList<'a>),
6765    LimitClause(LimitClause<'a>),
6766    TableRef(TableRef<'a>),
6767    SubqueryTableSource(SubqueryTableSource<'a>),
6768    JoinClause(JoinClause<'a>),
6769    JoinPrefix(JoinPrefix<'a>),
6770    TriggerEvent(TriggerEvent<'a>),
6771    /// List of [`Stmt`].
6772    TriggerCmdList(TriggerCmdList<'a>),
6773    CreateTriggerStmt(CreateTriggerStmt<'a>),
6774    CreateVirtualTableStmt(CreateVirtualTableStmt<'a>),
6775    PragmaStmt(PragmaStmt<'a>),
6776    AnalyzeOrReindexStmt(AnalyzeOrReindexStmt<'a>),
6777    AttachStmt(AttachStmt<'a>),
6778    DetachStmt(DetachStmt<'a>),
6779    VacuumStmt(VacuumStmt<'a>),
6780    ExplainStmt(ExplainStmt<'a>),
6781    CreateIndexStmt(CreateIndexStmt<'a>),
6782    CreateViewStmt(CreateViewStmt<'a>),
6783    /// List of [`ExprList`].
6784    ValuesRowList(ValuesRowList<'a>),
6785    ValuesClause(ValuesClause<'a>),
6786    FrameBound(FrameBound<'a>),
6787    FrameSpec(FrameSpec<'a>),
6788    WindowDef(WindowDef<'a>),
6789    /// List of [`WindowDef`].
6790    WindowDefList(WindowDefList<'a>),
6791    NamedWindowDef(NamedWindowDef<'a>),
6792    /// List of [`NamedWindowDef`].
6793    NamedWindowDefList(NamedWindowDefList<'a>),
6794    FilterOver(FilterOver<'a>),
6795    /// A node with an unknown tag from a dialect extension.
6796    Other {
6797        id: AnyNodeId,
6798        tag: crate::any::AnyNodeTag,
6799    },
6800}
6801
6802impl<'a> Node<'a> {
6803    /// Construct a typed `Node` from a raw arena pointer.
6804    ///
6805    /// # Safety
6806    /// `ptr` must be non-null, well-aligned, and valid for `'a`.
6807    /// Its first `u32` must be a valid `NodeTag` discriminant.
6808    #[expect(clippy::too_many_lines, clippy::match_wildcard_for_single_variants)]
6809    pub(crate) unsafe fn from_raw(
6810        ptr: *const u32,
6811        stmt_result: &'a AnyParsedStatement<'a>,
6812        id: AnyNodeId,
6813    ) -> Node<'a> {
6814        // SAFETY: caller guarantees ptr is valid for 'a with a valid tag.
6815        unsafe {
6816            let tag = NodeTag::from_raw(*ptr).unwrap_or(NodeTag::Null);
6817            match tag {
6818                NodeTag::AggregateFunctionCall => {
6819                    Node::AggregateFunctionCall(AggregateFunctionCall {
6820                        raw: &*ptr.cast::<super::ffi::AggregateFunctionCall>(),
6821                        stmt_result,
6822                        id,
6823                    })
6824                }
6825                NodeTag::OrderedSetFunctionCall => {
6826                    Node::OrderedSetFunctionCall(OrderedSetFunctionCall {
6827                        raw: &*ptr.cast::<super::ffi::OrderedSetFunctionCall>(),
6828                        stmt_result,
6829                        id,
6830                    })
6831                }
6832                NodeTag::CastExpr => Node::CastExpr(CastExpr {
6833                    raw: &*ptr.cast::<super::ffi::CastExpr>(),
6834                    stmt_result,
6835                    id,
6836                }),
6837                NodeTag::ColumnRef => Node::ColumnRef(ColumnRef {
6838                    raw: &*ptr.cast::<super::ffi::ColumnRef>(),
6839                    stmt_result,
6840                    id,
6841                }),
6842                NodeTag::CompoundSelect => Node::CompoundSelect(CompoundSelect {
6843                    raw: &*ptr.cast::<super::ffi::CompoundSelect>(),
6844                    stmt_result,
6845                    id,
6846                }),
6847                NodeTag::SubqueryExpr => Node::SubqueryExpr(SubqueryExpr {
6848                    raw: &*ptr.cast::<super::ffi::SubqueryExpr>(),
6849                    stmt_result,
6850                    id,
6851                }),
6852                NodeTag::ExistsExpr => Node::ExistsExpr(ExistsExpr {
6853                    raw: &*ptr.cast::<super::ffi::ExistsExpr>(),
6854                    stmt_result,
6855                    id,
6856                }),
6857                NodeTag::InExpr => Node::InExpr(InExpr {
6858                    raw: &*ptr.cast::<super::ffi::InExpr>(),
6859                    stmt_result,
6860                    id,
6861                }),
6862                NodeTag::IsExpr => Node::IsExpr(IsExpr {
6863                    raw: &*ptr.cast::<super::ffi::IsExpr>(),
6864                    stmt_result,
6865                    id,
6866                }),
6867                NodeTag::BetweenExpr => Node::BetweenExpr(BetweenExpr {
6868                    raw: &*ptr.cast::<super::ffi::BetweenExpr>(),
6869                    stmt_result,
6870                    id,
6871                }),
6872                NodeTag::LikeExpr => Node::LikeExpr(LikeExpr {
6873                    raw: &*ptr.cast::<super::ffi::LikeExpr>(),
6874                    stmt_result,
6875                    id,
6876                }),
6877                NodeTag::CaseExpr => Node::CaseExpr(CaseExpr {
6878                    raw: &*ptr.cast::<super::ffi::CaseExpr>(),
6879                    stmt_result,
6880                    id,
6881                }),
6882                NodeTag::CaseWhen => Node::CaseWhen(CaseWhen {
6883                    raw: &*ptr.cast::<super::ffi::CaseWhen>(),
6884                    stmt_result,
6885                    id,
6886                }),
6887                NodeTag::CaseWhenList => Node::CaseWhenList(
6888                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
6889                ),
6890                NodeTag::ForeignKeyClause => Node::ForeignKeyClause(ForeignKeyClause {
6891                    raw: &*ptr.cast::<super::ffi::ForeignKeyClause>(),
6892                    stmt_result,
6893                    id,
6894                }),
6895                NodeTag::ColumnConstraint => Node::ColumnConstraint(ColumnConstraint {
6896                    raw: &*ptr.cast::<super::ffi::ColumnConstraint>(),
6897                    stmt_result,
6898                    id,
6899                }),
6900                NodeTag::ColumnConstraintList => Node::ColumnConstraintList(
6901                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
6902                ),
6903                NodeTag::ColumnDef => Node::ColumnDef(ColumnDef {
6904                    raw: &*ptr.cast::<super::ffi::ColumnDef>(),
6905                    stmt_result,
6906                    id,
6907                }),
6908                NodeTag::ColumnDefList => Node::ColumnDefList(
6909                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
6910                ),
6911                NodeTag::TableConstraint => Node::TableConstraint(TableConstraint {
6912                    raw: &*ptr.cast::<super::ffi::TableConstraint>(),
6913                    stmt_result,
6914                    id,
6915                }),
6916                NodeTag::TableConstraintList => Node::TableConstraintList(
6917                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
6918                ),
6919                NodeTag::CreateTableStmt => Node::CreateTableStmt(CreateTableStmt {
6920                    raw: &*ptr.cast::<super::ffi::CreateTableStmt>(),
6921                    stmt_result,
6922                    id,
6923                }),
6924                NodeTag::CteDefinition => Node::CteDefinition(CteDefinition {
6925                    raw: &*ptr.cast::<super::ffi::CteDefinition>(),
6926                    stmt_result,
6927                    id,
6928                }),
6929                NodeTag::CteList => Node::CteList(
6930                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
6931                ),
6932                NodeTag::WithClause => Node::WithClause(WithClause {
6933                    raw: &*ptr.cast::<super::ffi::WithClause>(),
6934                    stmt_result,
6935                    id,
6936                }),
6937                NodeTag::UpsertClause => Node::UpsertClause(UpsertClause {
6938                    raw: &*ptr.cast::<super::ffi::UpsertClause>(),
6939                    stmt_result,
6940                    id,
6941                }),
6942                NodeTag::UpsertClauseList => Node::UpsertClauseList(
6943                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
6944                ),
6945                NodeTag::DeleteStmt => Node::DeleteStmt(DeleteStmt {
6946                    raw: &*ptr.cast::<super::ffi::DeleteStmt>(),
6947                    stmt_result,
6948                    id,
6949                }),
6950                NodeTag::SetClause => Node::SetClause(SetClause {
6951                    raw: &*ptr.cast::<super::ffi::SetClause>(),
6952                    stmt_result,
6953                    id,
6954                }),
6955                NodeTag::SetClauseList => Node::SetClauseList(
6956                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
6957                ),
6958                NodeTag::UpdateStmt => Node::UpdateStmt(UpdateStmt {
6959                    raw: &*ptr.cast::<super::ffi::UpdateStmt>(),
6960                    stmt_result,
6961                    id,
6962                }),
6963                NodeTag::InsertStmt => Node::InsertStmt(InsertStmt {
6964                    raw: &*ptr.cast::<super::ffi::InsertStmt>(),
6965                    stmt_result,
6966                    id,
6967                }),
6968                NodeTag::BinaryExpr => Node::BinaryExpr(BinaryExpr {
6969                    raw: &*ptr.cast::<super::ffi::BinaryExpr>(),
6970                    stmt_result,
6971                    id,
6972                }),
6973                NodeTag::UnaryExpr => Node::UnaryExpr(UnaryExpr {
6974                    raw: &*ptr.cast::<super::ffi::UnaryExpr>(),
6975                    stmt_result,
6976                    id,
6977                }),
6978                NodeTag::Literal => Node::Literal(Literal {
6979                    raw: &*ptr.cast::<super::ffi::Literal>(),
6980                    stmt_result,
6981                    id,
6982                }),
6983                NodeTag::IdentName => Node::IdentName(IdentName {
6984                    raw: &*ptr.cast::<super::ffi::IdentName>(),
6985                    stmt_result,
6986                    id,
6987                }),
6988                NodeTag::Error => Node::Error(Error {
6989                    raw: &*ptr.cast::<super::ffi::Error>(),
6990                    stmt_result,
6991                    id,
6992                }),
6993                NodeTag::ExprList => Node::ExprList(
6994                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
6995                ),
6996                NodeTag::FunctionCall => Node::FunctionCall(FunctionCall {
6997                    raw: &*ptr.cast::<super::ffi::FunctionCall>(),
6998                    stmt_result,
6999                    id,
7000                }),
7001                NodeTag::Variable => Node::Variable(Variable {
7002                    raw: &*ptr.cast::<super::ffi::Variable>(),
7003                    stmt_result,
7004                    id,
7005                }),
7006                NodeTag::CollateExpr => Node::CollateExpr(CollateExpr {
7007                    raw: &*ptr.cast::<super::ffi::CollateExpr>(),
7008                    stmt_result,
7009                    id,
7010                }),
7011                NodeTag::RaiseExpr => Node::RaiseExpr(RaiseExpr {
7012                    raw: &*ptr.cast::<super::ffi::RaiseExpr>(),
7013                    stmt_result,
7014                    id,
7015                }),
7016                NodeTag::QualifiedName => Node::QualifiedName(QualifiedName {
7017                    raw: &*ptr.cast::<super::ffi::QualifiedName>(),
7018                    stmt_result,
7019                    id,
7020                }),
7021                NodeTag::DropStmt => Node::DropStmt(DropStmt {
7022                    raw: &*ptr.cast::<super::ffi::DropStmt>(),
7023                    stmt_result,
7024                    id,
7025                }),
7026                NodeTag::AlterTableStmt => Node::AlterTableStmt(AlterTableStmt {
7027                    raw: &*ptr.cast::<super::ffi::AlterTableStmt>(),
7028                    stmt_result,
7029                    id,
7030                }),
7031                NodeTag::TransactionStmt => Node::TransactionStmt(TransactionStmt {
7032                    raw: &*ptr.cast::<super::ffi::TransactionStmt>(),
7033                    stmt_result,
7034                    id,
7035                }),
7036                NodeTag::SavepointStmt => Node::SavepointStmt(SavepointStmt {
7037                    raw: &*ptr.cast::<super::ffi::SavepointStmt>(),
7038                    stmt_result,
7039                    id,
7040                }),
7041                NodeTag::ResultColumn => Node::ResultColumn(ResultColumn {
7042                    raw: &*ptr.cast::<super::ffi::ResultColumn>(),
7043                    stmt_result,
7044                    id,
7045                }),
7046                NodeTag::ResultColumnList => Node::ResultColumnList(
7047                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
7048                ),
7049                NodeTag::SelectStmt => Node::SelectStmt(SelectStmt {
7050                    raw: &*ptr.cast::<super::ffi::SelectStmt>(),
7051                    stmt_result,
7052                    id,
7053                }),
7054                NodeTag::OrderingTerm => Node::OrderingTerm(OrderingTerm {
7055                    raw: &*ptr.cast::<super::ffi::OrderingTerm>(),
7056                    stmt_result,
7057                    id,
7058                }),
7059                NodeTag::OrderByList => Node::OrderByList(
7060                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
7061                ),
7062                NodeTag::LimitClause => Node::LimitClause(LimitClause {
7063                    raw: &*ptr.cast::<super::ffi::LimitClause>(),
7064                    stmt_result,
7065                    id,
7066                }),
7067                NodeTag::TableRef => Node::TableRef(TableRef {
7068                    raw: &*ptr.cast::<super::ffi::TableRef>(),
7069                    stmt_result,
7070                    id,
7071                }),
7072                NodeTag::SubqueryTableSource => Node::SubqueryTableSource(SubqueryTableSource {
7073                    raw: &*ptr.cast::<super::ffi::SubqueryTableSource>(),
7074                    stmt_result,
7075                    id,
7076                }),
7077                NodeTag::JoinClause => Node::JoinClause(JoinClause {
7078                    raw: &*ptr.cast::<super::ffi::JoinClause>(),
7079                    stmt_result,
7080                    id,
7081                }),
7082                NodeTag::JoinPrefix => Node::JoinPrefix(JoinPrefix {
7083                    raw: &*ptr.cast::<super::ffi::JoinPrefix>(),
7084                    stmt_result,
7085                    id,
7086                }),
7087                NodeTag::TriggerEvent => Node::TriggerEvent(TriggerEvent {
7088                    raw: &*ptr.cast::<super::ffi::TriggerEvent>(),
7089                    stmt_result,
7090                    id,
7091                }),
7092                NodeTag::TriggerCmdList => Node::TriggerCmdList(
7093                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
7094                ),
7095                NodeTag::CreateTriggerStmt => Node::CreateTriggerStmt(CreateTriggerStmt {
7096                    raw: &*ptr.cast::<super::ffi::CreateTriggerStmt>(),
7097                    stmt_result,
7098                    id,
7099                }),
7100                NodeTag::CreateVirtualTableStmt => {
7101                    Node::CreateVirtualTableStmt(CreateVirtualTableStmt {
7102                        raw: &*ptr.cast::<super::ffi::CreateVirtualTableStmt>(),
7103                        stmt_result,
7104                        id,
7105                    })
7106                }
7107                NodeTag::PragmaStmt => Node::PragmaStmt(PragmaStmt {
7108                    raw: &*ptr.cast::<super::ffi::PragmaStmt>(),
7109                    stmt_result,
7110                    id,
7111                }),
7112                NodeTag::AnalyzeOrReindexStmt => Node::AnalyzeOrReindexStmt(AnalyzeOrReindexStmt {
7113                    raw: &*ptr.cast::<super::ffi::AnalyzeOrReindexStmt>(),
7114                    stmt_result,
7115                    id,
7116                }),
7117                NodeTag::AttachStmt => Node::AttachStmt(AttachStmt {
7118                    raw: &*ptr.cast::<super::ffi::AttachStmt>(),
7119                    stmt_result,
7120                    id,
7121                }),
7122                NodeTag::DetachStmt => Node::DetachStmt(DetachStmt {
7123                    raw: &*ptr.cast::<super::ffi::DetachStmt>(),
7124                    stmt_result,
7125                    id,
7126                }),
7127                NodeTag::VacuumStmt => Node::VacuumStmt(VacuumStmt {
7128                    raw: &*ptr.cast::<super::ffi::VacuumStmt>(),
7129                    stmt_result,
7130                    id,
7131                }),
7132                NodeTag::ExplainStmt => Node::ExplainStmt(ExplainStmt {
7133                    raw: &*ptr.cast::<super::ffi::ExplainStmt>(),
7134                    stmt_result,
7135                    id,
7136                }),
7137                NodeTag::CreateIndexStmt => Node::CreateIndexStmt(CreateIndexStmt {
7138                    raw: &*ptr.cast::<super::ffi::CreateIndexStmt>(),
7139                    stmt_result,
7140                    id,
7141                }),
7142                NodeTag::CreateViewStmt => Node::CreateViewStmt(CreateViewStmt {
7143                    raw: &*ptr.cast::<super::ffi::CreateViewStmt>(),
7144                    stmt_result,
7145                    id,
7146                }),
7147                NodeTag::ValuesRowList => Node::ValuesRowList(
7148                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
7149                ),
7150                NodeTag::ValuesClause => Node::ValuesClause(ValuesClause {
7151                    raw: &*ptr.cast::<super::ffi::ValuesClause>(),
7152                    stmt_result,
7153                    id,
7154                }),
7155                NodeTag::FrameBound => Node::FrameBound(FrameBound {
7156                    raw: &*ptr.cast::<super::ffi::FrameBound>(),
7157                    stmt_result,
7158                    id,
7159                }),
7160                NodeTag::FrameSpec => Node::FrameSpec(FrameSpec {
7161                    raw: &*ptr.cast::<super::ffi::FrameSpec>(),
7162                    stmt_result,
7163                    id,
7164                }),
7165                NodeTag::WindowDef => Node::WindowDef(WindowDef {
7166                    raw: &*ptr.cast::<super::ffi::WindowDef>(),
7167                    stmt_result,
7168                    id,
7169                }),
7170                NodeTag::WindowDefList => Node::WindowDefList(
7171                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
7172                ),
7173                NodeTag::NamedWindowDef => Node::NamedWindowDef(NamedWindowDef {
7174                    raw: &*ptr.cast::<super::ffi::NamedWindowDef>(),
7175                    stmt_result,
7176                    id,
7177                }),
7178                NodeTag::NamedWindowDefList => Node::NamedWindowDefList(
7179                    TypedNodeList::from_result(stmt_result, id).expect("list tag invariant"),
7180                ),
7181                NodeTag::FilterOver => Node::FilterOver(FilterOver {
7182                    raw: &*ptr.cast::<super::ffi::FilterOver>(),
7183                    stmt_result,
7184                    id,
7185                }),
7186                _ => Node::Other {
7187                    id,
7188                    tag: crate::any::AnyNodeTag(*ptr),
7189                },
7190            }
7191        } // unsafe
7192    }
7193
7194    /// Resolve a `NodeId` into a typed `Node`, or `None` if null/invalid.
7195    #[expect(clippy::cast_ptr_alignment)]
7196    pub(crate) fn resolve(
7197        stmt_result: &'a AnyParsedStatement<'a>,
7198        id: AnyNodeId,
7199    ) -> Option<Node<'a>> {
7200        let (ptr, _tag) = stmt_result.node_ptr(id)?;
7201        // SAFETY: node_ptr returns a valid arena pointer aligned to u32;
7202        // ptr is valid for 'a and its first u32 is a valid NodeTag.
7203        Some(unsafe { Node::from_raw(ptr.cast::<u32>(), stmt_result, id) })
7204    }
7205
7206    /// The node's tag.
7207    pub fn tag(&self) -> NodeTag {
7208        match self {
7209            Node::AggregateFunctionCall(..) => NodeTag::AggregateFunctionCall,
7210            Node::OrderedSetFunctionCall(..) => NodeTag::OrderedSetFunctionCall,
7211            Node::CastExpr(..) => NodeTag::CastExpr,
7212            Node::ColumnRef(..) => NodeTag::ColumnRef,
7213            Node::CompoundSelect(..) => NodeTag::CompoundSelect,
7214            Node::SubqueryExpr(..) => NodeTag::SubqueryExpr,
7215            Node::ExistsExpr(..) => NodeTag::ExistsExpr,
7216            Node::InExpr(..) => NodeTag::InExpr,
7217            Node::IsExpr(..) => NodeTag::IsExpr,
7218            Node::BetweenExpr(..) => NodeTag::BetweenExpr,
7219            Node::LikeExpr(..) => NodeTag::LikeExpr,
7220            Node::CaseExpr(..) => NodeTag::CaseExpr,
7221            Node::CaseWhen(..) => NodeTag::CaseWhen,
7222            Node::CaseWhenList(..) => NodeTag::CaseWhenList,
7223            Node::ForeignKeyClause(..) => NodeTag::ForeignKeyClause,
7224            Node::ColumnConstraint(..) => NodeTag::ColumnConstraint,
7225            Node::ColumnConstraintList(..) => NodeTag::ColumnConstraintList,
7226            Node::ColumnDef(..) => NodeTag::ColumnDef,
7227            Node::ColumnDefList(..) => NodeTag::ColumnDefList,
7228            Node::TableConstraint(..) => NodeTag::TableConstraint,
7229            Node::TableConstraintList(..) => NodeTag::TableConstraintList,
7230            Node::CreateTableStmt(..) => NodeTag::CreateTableStmt,
7231            Node::CteDefinition(..) => NodeTag::CteDefinition,
7232            Node::CteList(..) => NodeTag::CteList,
7233            Node::WithClause(..) => NodeTag::WithClause,
7234            Node::UpsertClause(..) => NodeTag::UpsertClause,
7235            Node::UpsertClauseList(..) => NodeTag::UpsertClauseList,
7236            Node::DeleteStmt(..) => NodeTag::DeleteStmt,
7237            Node::SetClause(..) => NodeTag::SetClause,
7238            Node::SetClauseList(..) => NodeTag::SetClauseList,
7239            Node::UpdateStmt(..) => NodeTag::UpdateStmt,
7240            Node::InsertStmt(..) => NodeTag::InsertStmt,
7241            Node::BinaryExpr(..) => NodeTag::BinaryExpr,
7242            Node::UnaryExpr(..) => NodeTag::UnaryExpr,
7243            Node::Literal(..) => NodeTag::Literal,
7244            Node::IdentName(..) => NodeTag::IdentName,
7245            Node::Error(..) => NodeTag::Error,
7246            Node::ExprList(..) => NodeTag::ExprList,
7247            Node::FunctionCall(..) => NodeTag::FunctionCall,
7248            Node::Variable(..) => NodeTag::Variable,
7249            Node::CollateExpr(..) => NodeTag::CollateExpr,
7250            Node::RaiseExpr(..) => NodeTag::RaiseExpr,
7251            Node::QualifiedName(..) => NodeTag::QualifiedName,
7252            Node::DropStmt(..) => NodeTag::DropStmt,
7253            Node::AlterTableStmt(..) => NodeTag::AlterTableStmt,
7254            Node::TransactionStmt(..) => NodeTag::TransactionStmt,
7255            Node::SavepointStmt(..) => NodeTag::SavepointStmt,
7256            Node::ResultColumn(..) => NodeTag::ResultColumn,
7257            Node::ResultColumnList(..) => NodeTag::ResultColumnList,
7258            Node::SelectStmt(..) => NodeTag::SelectStmt,
7259            Node::OrderingTerm(..) => NodeTag::OrderingTerm,
7260            Node::OrderByList(..) => NodeTag::OrderByList,
7261            Node::LimitClause(..) => NodeTag::LimitClause,
7262            Node::TableRef(..) => NodeTag::TableRef,
7263            Node::SubqueryTableSource(..) => NodeTag::SubqueryTableSource,
7264            Node::JoinClause(..) => NodeTag::JoinClause,
7265            Node::JoinPrefix(..) => NodeTag::JoinPrefix,
7266            Node::TriggerEvent(..) => NodeTag::TriggerEvent,
7267            Node::TriggerCmdList(..) => NodeTag::TriggerCmdList,
7268            Node::CreateTriggerStmt(..) => NodeTag::CreateTriggerStmt,
7269            Node::CreateVirtualTableStmt(..) => NodeTag::CreateVirtualTableStmt,
7270            Node::PragmaStmt(..) => NodeTag::PragmaStmt,
7271            Node::AnalyzeOrReindexStmt(..) => NodeTag::AnalyzeOrReindexStmt,
7272            Node::AttachStmt(..) => NodeTag::AttachStmt,
7273            Node::DetachStmt(..) => NodeTag::DetachStmt,
7274            Node::VacuumStmt(..) => NodeTag::VacuumStmt,
7275            Node::ExplainStmt(..) => NodeTag::ExplainStmt,
7276            Node::CreateIndexStmt(..) => NodeTag::CreateIndexStmt,
7277            Node::CreateViewStmt(..) => NodeTag::CreateViewStmt,
7278            Node::ValuesRowList(..) => NodeTag::ValuesRowList,
7279            Node::ValuesClause(..) => NodeTag::ValuesClause,
7280            Node::FrameBound(..) => NodeTag::FrameBound,
7281            Node::FrameSpec(..) => NodeTag::FrameSpec,
7282            Node::WindowDef(..) => NodeTag::WindowDef,
7283            Node::WindowDefList(..) => NodeTag::WindowDefList,
7284            Node::NamedWindowDef(..) => NodeTag::NamedWindowDef,
7285            Node::NamedWindowDefList(..) => NodeTag::NamedWindowDefList,
7286            Node::FilterOver(..) => NodeTag::FilterOver,
7287            Node::Other { .. } => NodeTag::Null,
7288        }
7289    }
7290
7291    /// The typed node ID of this node.
7292    pub fn node_id(&self) -> NodeId {
7293        match self {
7294            Node::AggregateFunctionCall(n) => NodeId(n.node_id().into()),
7295            Node::OrderedSetFunctionCall(n) => NodeId(n.node_id().into()),
7296            Node::CastExpr(n) => NodeId(n.node_id().into()),
7297            Node::ColumnRef(n) => NodeId(n.node_id().into()),
7298            Node::CompoundSelect(n) => NodeId(n.node_id().into()),
7299            Node::SubqueryExpr(n) => NodeId(n.node_id().into()),
7300            Node::ExistsExpr(n) => NodeId(n.node_id().into()),
7301            Node::InExpr(n) => NodeId(n.node_id().into()),
7302            Node::IsExpr(n) => NodeId(n.node_id().into()),
7303            Node::BetweenExpr(n) => NodeId(n.node_id().into()),
7304            Node::LikeExpr(n) => NodeId(n.node_id().into()),
7305            Node::CaseExpr(n) => NodeId(n.node_id().into()),
7306            Node::CaseWhen(n) => NodeId(n.node_id().into()),
7307            Node::CaseWhenList(n) => NodeId(n.node_id().into()),
7308            Node::ForeignKeyClause(n) => NodeId(n.node_id().into()),
7309            Node::ColumnConstraint(n) => NodeId(n.node_id().into()),
7310            Node::ColumnConstraintList(n) => NodeId(n.node_id().into()),
7311            Node::ColumnDef(n) => NodeId(n.node_id().into()),
7312            Node::ColumnDefList(n) => NodeId(n.node_id().into()),
7313            Node::TableConstraint(n) => NodeId(n.node_id().into()),
7314            Node::TableConstraintList(n) => NodeId(n.node_id().into()),
7315            Node::CreateTableStmt(n) => NodeId(n.node_id().into()),
7316            Node::CteDefinition(n) => NodeId(n.node_id().into()),
7317            Node::CteList(n) => NodeId(n.node_id().into()),
7318            Node::WithClause(n) => NodeId(n.node_id().into()),
7319            Node::UpsertClause(n) => NodeId(n.node_id().into()),
7320            Node::UpsertClauseList(n) => NodeId(n.node_id().into()),
7321            Node::DeleteStmt(n) => NodeId(n.node_id().into()),
7322            Node::SetClause(n) => NodeId(n.node_id().into()),
7323            Node::SetClauseList(n) => NodeId(n.node_id().into()),
7324            Node::UpdateStmt(n) => NodeId(n.node_id().into()),
7325            Node::InsertStmt(n) => NodeId(n.node_id().into()),
7326            Node::BinaryExpr(n) => NodeId(n.node_id().into()),
7327            Node::UnaryExpr(n) => NodeId(n.node_id().into()),
7328            Node::Literal(n) => NodeId(n.node_id().into()),
7329            Node::IdentName(n) => NodeId(n.node_id().into()),
7330            Node::Error(n) => NodeId(n.node_id().into()),
7331            Node::ExprList(n) => NodeId(n.node_id().into()),
7332            Node::FunctionCall(n) => NodeId(n.node_id().into()),
7333            Node::Variable(n) => NodeId(n.node_id().into()),
7334            Node::CollateExpr(n) => NodeId(n.node_id().into()),
7335            Node::RaiseExpr(n) => NodeId(n.node_id().into()),
7336            Node::QualifiedName(n) => NodeId(n.node_id().into()),
7337            Node::DropStmt(n) => NodeId(n.node_id().into()),
7338            Node::AlterTableStmt(n) => NodeId(n.node_id().into()),
7339            Node::TransactionStmt(n) => NodeId(n.node_id().into()),
7340            Node::SavepointStmt(n) => NodeId(n.node_id().into()),
7341            Node::ResultColumn(n) => NodeId(n.node_id().into()),
7342            Node::ResultColumnList(n) => NodeId(n.node_id().into()),
7343            Node::SelectStmt(n) => NodeId(n.node_id().into()),
7344            Node::OrderingTerm(n) => NodeId(n.node_id().into()),
7345            Node::OrderByList(n) => NodeId(n.node_id().into()),
7346            Node::LimitClause(n) => NodeId(n.node_id().into()),
7347            Node::TableRef(n) => NodeId(n.node_id().into()),
7348            Node::SubqueryTableSource(n) => NodeId(n.node_id().into()),
7349            Node::JoinClause(n) => NodeId(n.node_id().into()),
7350            Node::JoinPrefix(n) => NodeId(n.node_id().into()),
7351            Node::TriggerEvent(n) => NodeId(n.node_id().into()),
7352            Node::TriggerCmdList(n) => NodeId(n.node_id().into()),
7353            Node::CreateTriggerStmt(n) => NodeId(n.node_id().into()),
7354            Node::CreateVirtualTableStmt(n) => NodeId(n.node_id().into()),
7355            Node::PragmaStmt(n) => NodeId(n.node_id().into()),
7356            Node::AnalyzeOrReindexStmt(n) => NodeId(n.node_id().into()),
7357            Node::AttachStmt(n) => NodeId(n.node_id().into()),
7358            Node::DetachStmt(n) => NodeId(n.node_id().into()),
7359            Node::VacuumStmt(n) => NodeId(n.node_id().into()),
7360            Node::ExplainStmt(n) => NodeId(n.node_id().into()),
7361            Node::CreateIndexStmt(n) => NodeId(n.node_id().into()),
7362            Node::CreateViewStmt(n) => NodeId(n.node_id().into()),
7363            Node::ValuesRowList(n) => NodeId(n.node_id().into()),
7364            Node::ValuesClause(n) => NodeId(n.node_id().into()),
7365            Node::FrameBound(n) => NodeId(n.node_id().into()),
7366            Node::FrameSpec(n) => NodeId(n.node_id().into()),
7367            Node::WindowDef(n) => NodeId(n.node_id().into()),
7368            Node::WindowDefList(n) => NodeId(n.node_id().into()),
7369            Node::NamedWindowDef(n) => NodeId(n.node_id().into()),
7370            Node::NamedWindowDefList(n) => NodeId(n.node_id().into()),
7371            Node::FilterOver(n) => NodeId(n.node_id().into()),
7372            Node::Other { id, .. } => NodeId(*id),
7373        }
7374    }
7375}
7376
7377impl<'a> GrammarNodeType<'a> for Node<'a> {
7378    fn from_result(stmt_result: &'a AnyParsedStatement<'a>, id: AnyNodeId) -> Option<Self> {
7379        Node::resolve(stmt_result, id)
7380    }
7381}
7382
7383#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
7384pub struct NodeId(AnyNodeId);
7385
7386impl NodeId {
7387    pub fn into_inner(self) -> AnyNodeId {
7388        self.0
7389    }
7390}
7391
7392impl<'a> From<Node<'a>> for NodeId {
7393    fn from(n: Node<'a>) -> Self {
7394        n.node_id()
7395    }
7396}
7397
7398impl From<AnyNodeId> for NodeId {
7399    fn from(id: AnyNodeId) -> Self {
7400        NodeId(id)
7401    }
7402}
7403
7404impl From<NodeId> for AnyNodeId {
7405    fn from(id: NodeId) -> AnyNodeId {
7406        id.0
7407    }
7408}
7409
7410impl TypedNodeId for NodeId {
7411    type Node<'a> = Node<'a>;
7412}