pg_query/
node_ref.rs

1use crate::*;
2
3#[derive(Debug, Copy, Clone)]
4pub enum NodeRef<'a> {
5    Alias(&'a protobuf::Alias),
6    RangeVar(&'a protobuf::RangeVar),
7    TableFunc(&'a protobuf::TableFunc),
8    Var(&'a protobuf::Var),
9    Param(&'a protobuf::Param),
10    Aggref(&'a protobuf::Aggref),
11    GroupingFunc(&'a protobuf::GroupingFunc),
12    WindowFunc(&'a protobuf::WindowFunc),
13    SubscriptingRef(&'a protobuf::SubscriptingRef),
14    FuncExpr(&'a protobuf::FuncExpr),
15    NamedArgExpr(&'a protobuf::NamedArgExpr),
16    OpExpr(&'a protobuf::OpExpr),
17    DistinctExpr(&'a protobuf::DistinctExpr),
18    NullIfExpr(&'a protobuf::NullIfExpr),
19    ScalarArrayOpExpr(&'a protobuf::ScalarArrayOpExpr),
20    BoolExpr(&'a protobuf::BoolExpr),
21    SubLink(&'a protobuf::SubLink),
22    SubPlan(&'a protobuf::SubPlan),
23    AlternativeSubPlan(&'a protobuf::AlternativeSubPlan),
24    FieldSelect(&'a protobuf::FieldSelect),
25    FieldStore(&'a protobuf::FieldStore),
26    RelabelType(&'a protobuf::RelabelType),
27    CoerceViaIo(&'a protobuf::CoerceViaIo),
28    ArrayCoerceExpr(&'a protobuf::ArrayCoerceExpr),
29    ConvertRowtypeExpr(&'a protobuf::ConvertRowtypeExpr),
30    CollateExpr(&'a protobuf::CollateExpr),
31    CaseExpr(&'a protobuf::CaseExpr),
32    CaseWhen(&'a protobuf::CaseWhen),
33    CaseTestExpr(&'a protobuf::CaseTestExpr),
34    ArrayExpr(&'a protobuf::ArrayExpr),
35    RowExpr(&'a protobuf::RowExpr),
36    RowCompareExpr(&'a protobuf::RowCompareExpr),
37    CoalesceExpr(&'a protobuf::CoalesceExpr),
38    MinMaxExpr(&'a protobuf::MinMaxExpr),
39    SqlvalueFunction(&'a protobuf::SqlValueFunction),
40    XmlExpr(&'a protobuf::XmlExpr),
41    NullTest(&'a protobuf::NullTest),
42    BooleanTest(&'a protobuf::BooleanTest),
43    CoerceToDomain(&'a protobuf::CoerceToDomain),
44    CoerceToDomainValue(&'a protobuf::CoerceToDomainValue),
45    SetToDefault(&'a protobuf::SetToDefault),
46    CurrentOfExpr(&'a protobuf::CurrentOfExpr),
47    NextValueExpr(&'a protobuf::NextValueExpr),
48    InferenceElem(&'a protobuf::InferenceElem),
49    TargetEntry(&'a protobuf::TargetEntry),
50    RangeTblRef(&'a protobuf::RangeTblRef),
51    JoinExpr(&'a protobuf::JoinExpr),
52    FromExpr(&'a protobuf::FromExpr),
53    OnConflictExpr(&'a protobuf::OnConflictExpr),
54    IntoClause(&'a protobuf::IntoClause),
55    RawStmt(&'a protobuf::RawStmt),
56    Query(&'a protobuf::Query),
57    InsertStmt(&'a protobuf::InsertStmt),
58    DeleteStmt(&'a protobuf::DeleteStmt),
59    UpdateStmt(&'a protobuf::UpdateStmt),
60    SelectStmt(&'a protobuf::SelectStmt),
61    AlterTableStmt(&'a protobuf::AlterTableStmt),
62    AlterTableCmd(&'a protobuf::AlterTableCmd),
63    AlterDomainStmt(&'a protobuf::AlterDomainStmt),
64    SetOperationStmt(&'a protobuf::SetOperationStmt),
65    GrantStmt(&'a protobuf::GrantStmt),
66    GrantRoleStmt(&'a protobuf::GrantRoleStmt),
67    AlterDefaultPrivilegesStmt(&'a protobuf::AlterDefaultPrivilegesStmt),
68    ClosePortalStmt(&'a protobuf::ClosePortalStmt),
69    ClusterStmt(&'a protobuf::ClusterStmt),
70    CopyStmt(&'a protobuf::CopyStmt),
71    CreateStmt(&'a protobuf::CreateStmt),
72    DefineStmt(&'a protobuf::DefineStmt),
73    DropStmt(&'a protobuf::DropStmt),
74    TruncateStmt(&'a protobuf::TruncateStmt),
75    CommentStmt(&'a protobuf::CommentStmt),
76    FetchStmt(&'a protobuf::FetchStmt),
77    IndexStmt(&'a protobuf::IndexStmt),
78    CreateFunctionStmt(&'a protobuf::CreateFunctionStmt),
79    AlterFunctionStmt(&'a protobuf::AlterFunctionStmt),
80    DoStmt(&'a protobuf::DoStmt),
81    RenameStmt(&'a protobuf::RenameStmt),
82    RuleStmt(&'a protobuf::RuleStmt),
83    NotifyStmt(&'a protobuf::NotifyStmt),
84    ListenStmt(&'a protobuf::ListenStmt),
85    UnlistenStmt(&'a protobuf::UnlistenStmt),
86    TransactionStmt(&'a protobuf::TransactionStmt),
87    ViewStmt(&'a protobuf::ViewStmt),
88    LoadStmt(&'a protobuf::LoadStmt),
89    CreateDomainStmt(&'a protobuf::CreateDomainStmt),
90    CreatedbStmt(&'a protobuf::CreatedbStmt),
91    DropdbStmt(&'a protobuf::DropdbStmt),
92    VacuumStmt(&'a protobuf::VacuumStmt),
93    ExplainStmt(&'a protobuf::ExplainStmt),
94    CreateTableAsStmt(&'a protobuf::CreateTableAsStmt),
95    CreateSeqStmt(&'a protobuf::CreateSeqStmt),
96    AlterSeqStmt(&'a protobuf::AlterSeqStmt),
97    VariableSetStmt(&'a protobuf::VariableSetStmt),
98    VariableShowStmt(&'a protobuf::VariableShowStmt),
99    DiscardStmt(&'a protobuf::DiscardStmt),
100    CreateTrigStmt(&'a protobuf::CreateTrigStmt),
101    CreatePlangStmt(&'a protobuf::CreatePLangStmt),
102    CreateRoleStmt(&'a protobuf::CreateRoleStmt),
103    AlterRoleStmt(&'a protobuf::AlterRoleStmt),
104    DropRoleStmt(&'a protobuf::DropRoleStmt),
105    LockStmt(&'a protobuf::LockStmt),
106    ConstraintsSetStmt(&'a protobuf::ConstraintsSetStmt),
107    ReindexStmt(&'a protobuf::ReindexStmt),
108    CheckPointStmt(&'a protobuf::CheckPointStmt),
109    CreateSchemaStmt(&'a protobuf::CreateSchemaStmt),
110    AlterDatabaseStmt(&'a protobuf::AlterDatabaseStmt),
111    AlterDatabaseSetStmt(&'a protobuf::AlterDatabaseSetStmt),
112    AlterRoleSetStmt(&'a protobuf::AlterRoleSetStmt),
113    CreateConversionStmt(&'a protobuf::CreateConversionStmt),
114    CreateCastStmt(&'a protobuf::CreateCastStmt),
115    CreateOpClassStmt(&'a protobuf::CreateOpClassStmt),
116    CreateOpFamilyStmt(&'a protobuf::CreateOpFamilyStmt),
117    AlterOpFamilyStmt(&'a protobuf::AlterOpFamilyStmt),
118    PrepareStmt(&'a protobuf::PrepareStmt),
119    ExecuteStmt(&'a protobuf::ExecuteStmt),
120    DeallocateStmt(&'a protobuf::DeallocateStmt),
121    DeclareCursorStmt(&'a protobuf::DeclareCursorStmt),
122    CreateTableSpaceStmt(&'a protobuf::CreateTableSpaceStmt),
123    DropTableSpaceStmt(&'a protobuf::DropTableSpaceStmt),
124    AlterObjectDependsStmt(&'a protobuf::AlterObjectDependsStmt),
125    AlterObjectSchemaStmt(&'a protobuf::AlterObjectSchemaStmt),
126    AlterOwnerStmt(&'a protobuf::AlterOwnerStmt),
127    AlterOperatorStmt(&'a protobuf::AlterOperatorStmt),
128    AlterTypeStmt(&'a protobuf::AlterTypeStmt),
129    DropOwnedStmt(&'a protobuf::DropOwnedStmt),
130    ReassignOwnedStmt(&'a protobuf::ReassignOwnedStmt),
131    CompositeTypeStmt(&'a protobuf::CompositeTypeStmt),
132    CreateEnumStmt(&'a protobuf::CreateEnumStmt),
133    CreateRangeStmt(&'a protobuf::CreateRangeStmt),
134    AlterEnumStmt(&'a protobuf::AlterEnumStmt),
135    AlterTsdictionaryStmt(&'a protobuf::AlterTsDictionaryStmt),
136    AlterTsconfigurationStmt(&'a protobuf::AlterTsConfigurationStmt),
137    CreateFdwStmt(&'a protobuf::CreateFdwStmt),
138    AlterFdwStmt(&'a protobuf::AlterFdwStmt),
139    CreateForeignServerStmt(&'a protobuf::CreateForeignServerStmt),
140    AlterForeignServerStmt(&'a protobuf::AlterForeignServerStmt),
141    CreateUserMappingStmt(&'a protobuf::CreateUserMappingStmt),
142    AlterUserMappingStmt(&'a protobuf::AlterUserMappingStmt),
143    DropUserMappingStmt(&'a protobuf::DropUserMappingStmt),
144    AlterTableSpaceOptionsStmt(&'a protobuf::AlterTableSpaceOptionsStmt),
145    AlterTableMoveAllStmt(&'a protobuf::AlterTableMoveAllStmt),
146    SecLabelStmt(&'a protobuf::SecLabelStmt),
147    CreateForeignTableStmt(&'a protobuf::CreateForeignTableStmt),
148    ImportForeignSchemaStmt(&'a protobuf::ImportForeignSchemaStmt),
149    CreateExtensionStmt(&'a protobuf::CreateExtensionStmt),
150    AlterExtensionStmt(&'a protobuf::AlterExtensionStmt),
151    AlterExtensionContentsStmt(&'a protobuf::AlterExtensionContentsStmt),
152    CreateEventTrigStmt(&'a protobuf::CreateEventTrigStmt),
153    AlterEventTrigStmt(&'a protobuf::AlterEventTrigStmt),
154    RefreshMatViewStmt(&'a protobuf::RefreshMatViewStmt),
155    ReplicaIdentityStmt(&'a protobuf::ReplicaIdentityStmt),
156    AlterSystemStmt(&'a protobuf::AlterSystemStmt),
157    CreatePolicyStmt(&'a protobuf::CreatePolicyStmt),
158    AlterPolicyStmt(&'a protobuf::AlterPolicyStmt),
159    CreateTransformStmt(&'a protobuf::CreateTransformStmt),
160    CreateAmStmt(&'a protobuf::CreateAmStmt),
161    CreatePublicationStmt(&'a protobuf::CreatePublicationStmt),
162    AlterPublicationStmt(&'a protobuf::AlterPublicationStmt),
163    CreateSubscriptionStmt(&'a protobuf::CreateSubscriptionStmt),
164    AlterSubscriptionStmt(&'a protobuf::AlterSubscriptionStmt),
165    DropSubscriptionStmt(&'a protobuf::DropSubscriptionStmt),
166    CreateStatsStmt(&'a protobuf::CreateStatsStmt),
167    AlterCollationStmt(&'a protobuf::AlterCollationStmt),
168    CallStmt(&'a protobuf::CallStmt),
169    AlterStatsStmt(&'a protobuf::AlterStatsStmt),
170    AExpr(&'a protobuf::AExpr),
171    ColumnRef(&'a protobuf::ColumnRef),
172    ParamRef(&'a protobuf::ParamRef),
173    AConst(&'a protobuf::AConst),
174    FuncCall(&'a protobuf::FuncCall),
175    AStar(&'a protobuf::AStar),
176    AIndices(&'a protobuf::AIndices),
177    AIndirection(&'a protobuf::AIndirection),
178    AArrayExpr(&'a protobuf::AArrayExpr),
179    ResTarget(&'a protobuf::ResTarget),
180    MultiAssignRef(&'a protobuf::MultiAssignRef),
181    TypeCast(&'a protobuf::TypeCast),
182    CollateClause(&'a protobuf::CollateClause),
183    SortBy(&'a protobuf::SortBy),
184    WindowDef(&'a protobuf::WindowDef),
185    RangeSubselect(&'a protobuf::RangeSubselect),
186    RangeFunction(&'a protobuf::RangeFunction),
187    RangeTableSample(&'a protobuf::RangeTableSample),
188    RangeTableFunc(&'a protobuf::RangeTableFunc),
189    RangeTableFuncCol(&'a protobuf::RangeTableFuncCol),
190    TypeName(&'a protobuf::TypeName),
191    ColumnDef(&'a protobuf::ColumnDef),
192    IndexElem(&'a protobuf::IndexElem),
193    Constraint(&'a protobuf::Constraint),
194    DefElem(&'a protobuf::DefElem),
195    RangeTblEntry(&'a protobuf::RangeTblEntry),
196    RangeTblFunction(&'a protobuf::RangeTblFunction),
197    TableSampleClause(&'a protobuf::TableSampleClause),
198    WithCheckOption(&'a protobuf::WithCheckOption),
199    SortGroupClause(&'a protobuf::SortGroupClause),
200    GroupingSet(&'a protobuf::GroupingSet),
201    WindowClause(&'a protobuf::WindowClause),
202    ObjectWithArgs(&'a protobuf::ObjectWithArgs),
203    AccessPriv(&'a protobuf::AccessPriv),
204    CreateOpClassItem(&'a protobuf::CreateOpClassItem),
205    TableLikeClause(&'a protobuf::TableLikeClause),
206    FunctionParameter(&'a protobuf::FunctionParameter),
207    LockingClause(&'a protobuf::LockingClause),
208    RowMarkClause(&'a protobuf::RowMarkClause),
209    XmlSerialize(&'a protobuf::XmlSerialize),
210    WithClause(&'a protobuf::WithClause),
211    InferClause(&'a protobuf::InferClause),
212    OnConflictClause(&'a protobuf::OnConflictClause),
213    CommonTableExpr(&'a protobuf::CommonTableExpr),
214    RoleSpec(&'a protobuf::RoleSpec),
215    TriggerTransition(&'a protobuf::TriggerTransition),
216    PartitionElem(&'a protobuf::PartitionElem),
217    PartitionSpec(&'a protobuf::PartitionSpec),
218    PartitionBoundSpec(&'a protobuf::PartitionBoundSpec),
219    PartitionRangeDatum(&'a protobuf::PartitionRangeDatum),
220    PartitionCmd(&'a protobuf::PartitionCmd),
221    VacuumRelation(&'a protobuf::VacuumRelation),
222    InlineCodeBlock(&'a protobuf::InlineCodeBlock),
223    CallContext(&'a protobuf::CallContext),
224    Integer(&'a protobuf::Integer),
225    Float(&'a protobuf::Float),
226    Boolean(&'a protobuf::Boolean),
227    String(&'a protobuf::String),
228    BitString(&'a protobuf::BitString),
229    List(&'a protobuf::List),
230    IntList(&'a protobuf::IntList),
231    OidList(&'a protobuf::OidList),
232    MergeStmt(&'a protobuf::MergeStmt),
233    MergeAction(&'a protobuf::MergeAction),
234    AlterDatabaseRefreshCollStmt(&'a protobuf::AlterDatabaseRefreshCollStmt),
235    ReturnStmt(&'a protobuf::ReturnStmt),
236    PlassignStmt(&'a protobuf::PlAssignStmt),
237    StatsElem(&'a protobuf::StatsElem),
238    CtesearchClause(&'a protobuf::CteSearchClause),
239    CtecycleClause(&'a protobuf::CteCycleClause),
240    MergeWhenClause(&'a protobuf::MergeWhenClause),
241    PublicationObjSpec(&'a protobuf::PublicationObjSpec),
242    PublicationTable(&'a protobuf::PublicationTable),
243    JsonFormat(&'a protobuf::JsonFormat),
244    JsonReturning(&'a protobuf::JsonReturning),
245    JsonValueExpr(&'a protobuf::JsonValueExpr),
246    JsonConstructorExpr(&'a protobuf::JsonConstructorExpr),
247    JsonIsPredicate(&'a protobuf::JsonIsPredicate),
248    JsonOutput(&'a protobuf::JsonOutput),
249    JsonKeyValue(&'a protobuf::JsonKeyValue),
250    JsonObjectConstructor(&'a protobuf::JsonObjectConstructor),
251    JsonArrayConstructor(&'a protobuf::JsonArrayConstructor),
252    JsonArrayQueryConstructor(&'a protobuf::JsonArrayQueryConstructor),
253    JsonAggConstructor(&'a protobuf::JsonAggConstructor),
254    JsonObjectAgg(&'a protobuf::JsonObjectAgg),
255    JsonArrayAgg(&'a protobuf::JsonArrayAgg),
256    RtepermissionInfo(&'a protobuf::RtePermissionInfo),
257    WindowFuncRunCondition(&'a protobuf::WindowFuncRunCondition),
258    MergeSupportFunc(&'a protobuf::MergeSupportFunc),
259    JsonBehavior(&'a protobuf::JsonBehavior),
260    JsonExpr(&'a protobuf::JsonExpr),
261    JsonTablePath(&'a protobuf::JsonTablePath),
262    JsonTablePathScan(&'a protobuf::JsonTablePathScan),
263    JsonTableSiblingJoin(&'a protobuf::JsonTableSiblingJoin),
264    SinglePartitionSpec(&'a protobuf::SinglePartitionSpec),
265    JsonArgument(&'a protobuf::JsonArgument),
266    JsonFuncExpr(&'a protobuf::JsonFuncExpr),
267    JsonTablePathSpec(&'a protobuf::JsonTablePathSpec),
268    JsonTable(&'a protobuf::JsonTable),
269    JsonTableColumn(&'a protobuf::JsonTableColumn),
270    JsonParseExpr(&'a protobuf::JsonParseExpr),
271    JsonScalarExpr(&'a protobuf::JsonScalarExpr),
272    JsonSerializeExpr(&'a protobuf::JsonSerializeExpr),
273}
274
275impl<'a> NodeRef<'a> {
276    // TODO: `deparseStmt` in pg_query_deparse.c panics on unexpected nodes. instead, return a Rust error
277    pub fn deparse(&self) -> Result<String> {
278        crate::deparse(&protobuf::ParseResult {
279            version: crate::bindings::PG_VERSION_NUM as i32,
280            stmts: vec![protobuf::RawStmt { stmt: Some(Box::new(Node { node: Some(self.to_enum()) })), stmt_location: 0, stmt_len: 0 }],
281        })
282    }
283
284    pub fn to_enum(&self) -> NodeEnum {
285        match self {
286            NodeRef::Alias(n) => NodeEnum::Alias((*n).clone()),
287            NodeRef::RangeVar(n) => NodeEnum::RangeVar((*n).clone()),
288            NodeRef::TableFunc(n) => NodeEnum::TableFunc(Box::new((*n).clone())),
289            NodeRef::Var(n) => NodeEnum::Var(Box::new((*n).clone())),
290            NodeRef::Param(n) => NodeEnum::Param(Box::new((*n).clone())),
291            NodeRef::Aggref(n) => NodeEnum::Aggref(Box::new((*n).clone())),
292            NodeRef::GroupingFunc(n) => NodeEnum::GroupingFunc(Box::new((*n).clone())),
293            NodeRef::WindowFunc(n) => NodeEnum::WindowFunc(Box::new((*n).clone())),
294            NodeRef::SubscriptingRef(n) => NodeEnum::SubscriptingRef(Box::new((*n).clone())),
295            NodeRef::FuncExpr(n) => NodeEnum::FuncExpr(Box::new((*n).clone())),
296            NodeRef::NamedArgExpr(n) => NodeEnum::NamedArgExpr(Box::new((*n).clone())),
297            NodeRef::OpExpr(n) => NodeEnum::OpExpr(Box::new((*n).clone())),
298            NodeRef::DistinctExpr(n) => NodeEnum::DistinctExpr(Box::new((*n).clone())),
299            NodeRef::NullIfExpr(n) => NodeEnum::NullIfExpr(Box::new((*n).clone())),
300            NodeRef::ScalarArrayOpExpr(n) => NodeEnum::ScalarArrayOpExpr(Box::new((*n).clone())),
301            NodeRef::BoolExpr(n) => NodeEnum::BoolExpr(Box::new((*n).clone())),
302            NodeRef::SubLink(n) => NodeEnum::SubLink(Box::new((*n).clone())),
303            NodeRef::SubPlan(n) => NodeEnum::SubPlan(Box::new((*n).clone())),
304            NodeRef::AlternativeSubPlan(n) => NodeEnum::AlternativeSubPlan(Box::new((*n).clone())),
305            NodeRef::FieldSelect(n) => NodeEnum::FieldSelect(Box::new((*n).clone())),
306            NodeRef::FieldStore(n) => NodeEnum::FieldStore(Box::new((*n).clone())),
307            NodeRef::RelabelType(n) => NodeEnum::RelabelType(Box::new((*n).clone())),
308            NodeRef::CoerceViaIo(n) => NodeEnum::CoerceViaIo(Box::new((*n).clone())),
309            NodeRef::ArrayCoerceExpr(n) => NodeEnum::ArrayCoerceExpr(Box::new((*n).clone())),
310            NodeRef::ConvertRowtypeExpr(n) => NodeEnum::ConvertRowtypeExpr(Box::new((*n).clone())),
311            NodeRef::CollateExpr(n) => NodeEnum::CollateExpr(Box::new((*n).clone())),
312            NodeRef::CaseExpr(n) => NodeEnum::CaseExpr(Box::new((*n).clone())),
313            NodeRef::CaseWhen(n) => NodeEnum::CaseWhen(Box::new((*n).clone())),
314            NodeRef::CaseTestExpr(n) => NodeEnum::CaseTestExpr(Box::new((*n).clone())),
315            NodeRef::ArrayExpr(n) => NodeEnum::ArrayExpr(Box::new((*n).clone())),
316            NodeRef::RowExpr(n) => NodeEnum::RowExpr(Box::new((*n).clone())),
317            NodeRef::RowCompareExpr(n) => NodeEnum::RowCompareExpr(Box::new((*n).clone())),
318            NodeRef::CoalesceExpr(n) => NodeEnum::CoalesceExpr(Box::new((*n).clone())),
319            NodeRef::MinMaxExpr(n) => NodeEnum::MinMaxExpr(Box::new((*n).clone())),
320            NodeRef::SqlvalueFunction(n) => NodeEnum::SqlvalueFunction(Box::new((*n).clone())),
321            NodeRef::XmlExpr(n) => NodeEnum::XmlExpr(Box::new((*n).clone())),
322            NodeRef::NullTest(n) => NodeEnum::NullTest(Box::new((*n).clone())),
323            NodeRef::BooleanTest(n) => NodeEnum::BooleanTest(Box::new((*n).clone())),
324            NodeRef::CoerceToDomain(n) => NodeEnum::CoerceToDomain(Box::new((*n).clone())),
325            NodeRef::CoerceToDomainValue(n) => NodeEnum::CoerceToDomainValue(Box::new((*n).clone())),
326            NodeRef::SetToDefault(n) => NodeEnum::SetToDefault(Box::new((*n).clone())),
327            NodeRef::CurrentOfExpr(n) => NodeEnum::CurrentOfExpr(Box::new((*n).clone())),
328            NodeRef::NextValueExpr(n) => NodeEnum::NextValueExpr(Box::new((*n).clone())),
329            NodeRef::InferenceElem(n) => NodeEnum::InferenceElem(Box::new((*n).clone())),
330            NodeRef::TargetEntry(n) => NodeEnum::TargetEntry(Box::new((*n).clone())),
331            NodeRef::RangeTblRef(n) => NodeEnum::RangeTblRef((*n).clone()),
332            NodeRef::JoinExpr(n) => NodeEnum::JoinExpr(Box::new((*n).clone())),
333            NodeRef::FromExpr(n) => NodeEnum::FromExpr(Box::new((*n).clone())),
334            NodeRef::OnConflictExpr(n) => NodeEnum::OnConflictExpr(Box::new((*n).clone())),
335            NodeRef::IntoClause(n) => NodeEnum::IntoClause(Box::new((*n).clone())),
336            NodeRef::RawStmt(n) => NodeEnum::RawStmt(Box::new((*n).clone())),
337            NodeRef::Query(n) => NodeEnum::Query(Box::new((*n).clone())),
338            NodeRef::InsertStmt(n) => NodeEnum::InsertStmt(Box::new((*n).clone())),
339            NodeRef::DeleteStmt(n) => NodeEnum::DeleteStmt(Box::new((*n).clone())),
340            NodeRef::UpdateStmt(n) => NodeEnum::UpdateStmt(Box::new((*n).clone())),
341            NodeRef::SelectStmt(n) => NodeEnum::SelectStmt(Box::new((*n).clone())),
342            NodeRef::AlterTableStmt(n) => NodeEnum::AlterTableStmt((*n).clone()),
343            NodeRef::AlterTableCmd(n) => NodeEnum::AlterTableCmd(Box::new((*n).clone())),
344            NodeRef::AlterDomainStmt(n) => NodeEnum::AlterDomainStmt(Box::new((*n).clone())),
345            NodeRef::SetOperationStmt(n) => NodeEnum::SetOperationStmt(Box::new((*n).clone())),
346            NodeRef::GrantStmt(n) => NodeEnum::GrantStmt((*n).clone()),
347            NodeRef::GrantRoleStmt(n) => NodeEnum::GrantRoleStmt((*n).clone()),
348            NodeRef::AlterDefaultPrivilegesStmt(n) => NodeEnum::AlterDefaultPrivilegesStmt((*n).clone()),
349            NodeRef::ClosePortalStmt(n) => NodeEnum::ClosePortalStmt((*n).clone()),
350            NodeRef::ClusterStmt(n) => NodeEnum::ClusterStmt((*n).clone()),
351            NodeRef::CopyStmt(n) => NodeEnum::CopyStmt(Box::new((*n).clone())),
352            NodeRef::CreateStmt(n) => NodeEnum::CreateStmt((*n).clone()),
353            NodeRef::DefineStmt(n) => NodeEnum::DefineStmt((*n).clone()),
354            NodeRef::DropStmt(n) => NodeEnum::DropStmt((*n).clone()),
355            NodeRef::TruncateStmt(n) => NodeEnum::TruncateStmt((*n).clone()),
356            NodeRef::CommentStmt(n) => NodeEnum::CommentStmt(Box::new((*n).clone())),
357            NodeRef::FetchStmt(n) => NodeEnum::FetchStmt((*n).clone()),
358            NodeRef::IndexStmt(n) => NodeEnum::IndexStmt(Box::new((*n).clone())),
359            NodeRef::CreateFunctionStmt(n) => NodeEnum::CreateFunctionStmt(Box::new((*n).clone())),
360            NodeRef::AlterFunctionStmt(n) => NodeEnum::AlterFunctionStmt((*n).clone()),
361            NodeRef::DoStmt(n) => NodeEnum::DoStmt((*n).clone()),
362            NodeRef::RenameStmt(n) => NodeEnum::RenameStmt(Box::new((*n).clone())),
363            NodeRef::RuleStmt(n) => NodeEnum::RuleStmt(Box::new((*n).clone())),
364            NodeRef::NotifyStmt(n) => NodeEnum::NotifyStmt((*n).clone()),
365            NodeRef::ListenStmt(n) => NodeEnum::ListenStmt((*n).clone()),
366            NodeRef::UnlistenStmt(n) => NodeEnum::UnlistenStmt((*n).clone()),
367            NodeRef::TransactionStmt(n) => NodeEnum::TransactionStmt((*n).clone()),
368            NodeRef::ViewStmt(n) => NodeEnum::ViewStmt(Box::new((*n).clone())),
369            NodeRef::LoadStmt(n) => NodeEnum::LoadStmt((*n).clone()),
370            NodeRef::CreateDomainStmt(n) => NodeEnum::CreateDomainStmt(Box::new((*n).clone())),
371            NodeRef::CreatedbStmt(n) => NodeEnum::CreatedbStmt((*n).clone()),
372            NodeRef::DropdbStmt(n) => NodeEnum::DropdbStmt((*n).clone()),
373            NodeRef::VacuumStmt(n) => NodeEnum::VacuumStmt((*n).clone()),
374            NodeRef::ExplainStmt(n) => NodeEnum::ExplainStmt(Box::new((*n).clone())),
375            NodeRef::CreateTableAsStmt(n) => NodeEnum::CreateTableAsStmt(Box::new((*n).clone())),
376            NodeRef::CreateSeqStmt(n) => NodeEnum::CreateSeqStmt((*n).clone()),
377            NodeRef::AlterSeqStmt(n) => NodeEnum::AlterSeqStmt((*n).clone()),
378            NodeRef::VariableSetStmt(n) => NodeEnum::VariableSetStmt((*n).clone()),
379            NodeRef::VariableShowStmt(n) => NodeEnum::VariableShowStmt((*n).clone()),
380            NodeRef::DiscardStmt(n) => NodeEnum::DiscardStmt((*n).clone()),
381            NodeRef::CreateTrigStmt(n) => NodeEnum::CreateTrigStmt(Box::new((*n).clone())),
382            NodeRef::CreatePlangStmt(n) => NodeEnum::CreatePlangStmt((*n).clone()),
383            NodeRef::CreateRoleStmt(n) => NodeEnum::CreateRoleStmt((*n).clone()),
384            NodeRef::AlterRoleStmt(n) => NodeEnum::AlterRoleStmt((*n).clone()),
385            NodeRef::DropRoleStmt(n) => NodeEnum::DropRoleStmt((*n).clone()),
386            NodeRef::LockStmt(n) => NodeEnum::LockStmt((*n).clone()),
387            NodeRef::ConstraintsSetStmt(n) => NodeEnum::ConstraintsSetStmt((*n).clone()),
388            NodeRef::ReindexStmt(n) => NodeEnum::ReindexStmt((*n).clone()),
389            NodeRef::CheckPointStmt(n) => NodeEnum::CheckPointStmt((*n).clone()),
390            NodeRef::CreateSchemaStmt(n) => NodeEnum::CreateSchemaStmt((*n).clone()),
391            NodeRef::AlterDatabaseStmt(n) => NodeEnum::AlterDatabaseStmt((*n).clone()),
392            NodeRef::AlterDatabaseSetStmt(n) => NodeEnum::AlterDatabaseSetStmt((*n).clone()),
393            NodeRef::AlterRoleSetStmt(n) => NodeEnum::AlterRoleSetStmt((*n).clone()),
394            NodeRef::CreateConversionStmt(n) => NodeEnum::CreateConversionStmt((*n).clone()),
395            NodeRef::CreateCastStmt(n) => NodeEnum::CreateCastStmt((*n).clone()),
396            NodeRef::CreateOpClassStmt(n) => NodeEnum::CreateOpClassStmt((*n).clone()),
397            NodeRef::CreateOpFamilyStmt(n) => NodeEnum::CreateOpFamilyStmt((*n).clone()),
398            NodeRef::AlterOpFamilyStmt(n) => NodeEnum::AlterOpFamilyStmt((*n).clone()),
399            NodeRef::PrepareStmt(n) => NodeEnum::PrepareStmt(Box::new((*n).clone())),
400            NodeRef::ExecuteStmt(n) => NodeEnum::ExecuteStmt((*n).clone()),
401            NodeRef::DeallocateStmt(n) => NodeEnum::DeallocateStmt((*n).clone()),
402            NodeRef::DeclareCursorStmt(n) => NodeEnum::DeclareCursorStmt(Box::new((*n).clone())),
403            NodeRef::CreateTableSpaceStmt(n) => NodeEnum::CreateTableSpaceStmt((*n).clone()),
404            NodeRef::DropTableSpaceStmt(n) => NodeEnum::DropTableSpaceStmt((*n).clone()),
405            NodeRef::AlterObjectDependsStmt(n) => NodeEnum::AlterObjectDependsStmt(Box::new((*n).clone())),
406            NodeRef::AlterObjectSchemaStmt(n) => NodeEnum::AlterObjectSchemaStmt(Box::new((*n).clone())),
407            NodeRef::AlterOwnerStmt(n) => NodeEnum::AlterOwnerStmt(Box::new((*n).clone())),
408            NodeRef::AlterOperatorStmt(n) => NodeEnum::AlterOperatorStmt((*n).clone()),
409            NodeRef::AlterTypeStmt(n) => NodeEnum::AlterTypeStmt((*n).clone()),
410            NodeRef::DropOwnedStmt(n) => NodeEnum::DropOwnedStmt((*n).clone()),
411            NodeRef::ReassignOwnedStmt(n) => NodeEnum::ReassignOwnedStmt((*n).clone()),
412            NodeRef::CompositeTypeStmt(n) => NodeEnum::CompositeTypeStmt((*n).clone()),
413            NodeRef::CreateEnumStmt(n) => NodeEnum::CreateEnumStmt((*n).clone()),
414            NodeRef::CreateRangeStmt(n) => NodeEnum::CreateRangeStmt((*n).clone()),
415            NodeRef::AlterEnumStmt(n) => NodeEnum::AlterEnumStmt((*n).clone()),
416            NodeRef::AlterTsdictionaryStmt(n) => NodeEnum::AlterTsdictionaryStmt((*n).clone()),
417            NodeRef::AlterTsconfigurationStmt(n) => NodeEnum::AlterTsconfigurationStmt((*n).clone()),
418            NodeRef::CreateFdwStmt(n) => NodeEnum::CreateFdwStmt((*n).clone()),
419            NodeRef::AlterFdwStmt(n) => NodeEnum::AlterFdwStmt((*n).clone()),
420            NodeRef::CreateForeignServerStmt(n) => NodeEnum::CreateForeignServerStmt((*n).clone()),
421            NodeRef::AlterForeignServerStmt(n) => NodeEnum::AlterForeignServerStmt((*n).clone()),
422            NodeRef::CreateUserMappingStmt(n) => NodeEnum::CreateUserMappingStmt((*n).clone()),
423            NodeRef::AlterUserMappingStmt(n) => NodeEnum::AlterUserMappingStmt((*n).clone()),
424            NodeRef::DropUserMappingStmt(n) => NodeEnum::DropUserMappingStmt((*n).clone()),
425            NodeRef::AlterTableSpaceOptionsStmt(n) => NodeEnum::AlterTableSpaceOptionsStmt((*n).clone()),
426            NodeRef::AlterTableMoveAllStmt(n) => NodeEnum::AlterTableMoveAllStmt((*n).clone()),
427            NodeRef::SecLabelStmt(n) => NodeEnum::SecLabelStmt(Box::new((*n).clone())),
428            NodeRef::CreateForeignTableStmt(n) => NodeEnum::CreateForeignTableStmt((*n).clone()),
429            NodeRef::ImportForeignSchemaStmt(n) => NodeEnum::ImportForeignSchemaStmt((*n).clone()),
430            NodeRef::CreateExtensionStmt(n) => NodeEnum::CreateExtensionStmt((*n).clone()),
431            NodeRef::AlterExtensionStmt(n) => NodeEnum::AlterExtensionStmt((*n).clone()),
432            NodeRef::AlterExtensionContentsStmt(n) => NodeEnum::AlterExtensionContentsStmt(Box::new((*n).clone())),
433            NodeRef::CreateEventTrigStmt(n) => NodeEnum::CreateEventTrigStmt((*n).clone()),
434            NodeRef::AlterEventTrigStmt(n) => NodeEnum::AlterEventTrigStmt((*n).clone()),
435            NodeRef::RefreshMatViewStmt(n) => NodeEnum::RefreshMatViewStmt((*n).clone()),
436            NodeRef::ReplicaIdentityStmt(n) => NodeEnum::ReplicaIdentityStmt((*n).clone()),
437            NodeRef::AlterSystemStmt(n) => NodeEnum::AlterSystemStmt((*n).clone()),
438            NodeRef::CreatePolicyStmt(n) => NodeEnum::CreatePolicyStmt(Box::new((*n).clone())),
439            NodeRef::AlterPolicyStmt(n) => NodeEnum::AlterPolicyStmt(Box::new((*n).clone())),
440            NodeRef::CreateTransformStmt(n) => NodeEnum::CreateTransformStmt((*n).clone()),
441            NodeRef::CreateAmStmt(n) => NodeEnum::CreateAmStmt((*n).clone()),
442            NodeRef::CreatePublicationStmt(n) => NodeEnum::CreatePublicationStmt((*n).clone()),
443            NodeRef::AlterPublicationStmt(n) => NodeEnum::AlterPublicationStmt((*n).clone()),
444            NodeRef::CreateSubscriptionStmt(n) => NodeEnum::CreateSubscriptionStmt((*n).clone()),
445            NodeRef::AlterSubscriptionStmt(n) => NodeEnum::AlterSubscriptionStmt((*n).clone()),
446            NodeRef::DropSubscriptionStmt(n) => NodeEnum::DropSubscriptionStmt((*n).clone()),
447            NodeRef::CreateStatsStmt(n) => NodeEnum::CreateStatsStmt((*n).clone()),
448            NodeRef::AlterCollationStmt(n) => NodeEnum::AlterCollationStmt((*n).clone()),
449            NodeRef::CallStmt(n) => NodeEnum::CallStmt(Box::new((*n).clone())),
450            NodeRef::AlterStatsStmt(n) => NodeEnum::AlterStatsStmt(Box::new((*n).clone())),
451            NodeRef::AExpr(n) => NodeEnum::AExpr(Box::new((*n).clone())),
452            NodeRef::ColumnRef(n) => NodeEnum::ColumnRef((*n).clone()),
453            NodeRef::ParamRef(n) => NodeEnum::ParamRef((*n).clone()),
454            NodeRef::AConst(n) => NodeEnum::AConst((*n).clone()),
455            NodeRef::FuncCall(n) => NodeEnum::FuncCall(Box::new((*n).clone())),
456            NodeRef::AStar(n) => NodeEnum::AStar((*n).clone()),
457            NodeRef::AIndices(n) => NodeEnum::AIndices(Box::new((*n).clone())),
458            NodeRef::AIndirection(n) => NodeEnum::AIndirection(Box::new((*n).clone())),
459            NodeRef::AArrayExpr(n) => NodeEnum::AArrayExpr((*n).clone()),
460            NodeRef::ResTarget(n) => NodeEnum::ResTarget(Box::new((*n).clone())),
461            NodeRef::MultiAssignRef(n) => NodeEnum::MultiAssignRef(Box::new((*n).clone())),
462            NodeRef::TypeCast(n) => NodeEnum::TypeCast(Box::new((*n).clone())),
463            NodeRef::CollateClause(n) => NodeEnum::CollateClause(Box::new((*n).clone())),
464            NodeRef::SortBy(n) => NodeEnum::SortBy(Box::new((*n).clone())),
465            NodeRef::WindowDef(n) => NodeEnum::WindowDef(Box::new((*n).clone())),
466            NodeRef::RangeSubselect(n) => NodeEnum::RangeSubselect(Box::new((*n).clone())),
467            NodeRef::RangeFunction(n) => NodeEnum::RangeFunction((*n).clone()),
468            NodeRef::RangeTableSample(n) => NodeEnum::RangeTableSample(Box::new((*n).clone())),
469            NodeRef::RangeTableFunc(n) => NodeEnum::RangeTableFunc(Box::new((*n).clone())),
470            NodeRef::RangeTableFuncCol(n) => NodeEnum::RangeTableFuncCol(Box::new((*n).clone())),
471            NodeRef::TypeName(n) => NodeEnum::TypeName((*n).clone()),
472            NodeRef::ColumnDef(n) => NodeEnum::ColumnDef(Box::new((*n).clone())),
473            NodeRef::IndexElem(n) => NodeEnum::IndexElem(Box::new((*n).clone())),
474            NodeRef::Constraint(n) => NodeEnum::Constraint(Box::new((*n).clone())),
475            NodeRef::DefElem(n) => NodeEnum::DefElem(Box::new((*n).clone())),
476            NodeRef::RangeTblEntry(n) => NodeEnum::RangeTblEntry(Box::new((*n).clone())),
477            NodeRef::RangeTblFunction(n) => NodeEnum::RangeTblFunction(Box::new((*n).clone())),
478            NodeRef::TableSampleClause(n) => NodeEnum::TableSampleClause(Box::new((*n).clone())),
479            NodeRef::WithCheckOption(n) => NodeEnum::WithCheckOption(Box::new((*n).clone())),
480            NodeRef::SortGroupClause(n) => NodeEnum::SortGroupClause((*n).clone()),
481            NodeRef::GroupingSet(n) => NodeEnum::GroupingSet((*n).clone()),
482            NodeRef::WindowClause(n) => NodeEnum::WindowClause(Box::new((*n).clone())),
483            NodeRef::ObjectWithArgs(n) => NodeEnum::ObjectWithArgs((*n).clone()),
484            NodeRef::AccessPriv(n) => NodeEnum::AccessPriv((*n).clone()),
485            NodeRef::CreateOpClassItem(n) => NodeEnum::CreateOpClassItem((*n).clone()),
486            NodeRef::TableLikeClause(n) => NodeEnum::TableLikeClause((*n).clone()),
487            NodeRef::FunctionParameter(n) => NodeEnum::FunctionParameter(Box::new((*n).clone())),
488            NodeRef::LockingClause(n) => NodeEnum::LockingClause((*n).clone()),
489            NodeRef::RowMarkClause(n) => NodeEnum::RowMarkClause((*n).clone()),
490            NodeRef::XmlSerialize(n) => NodeEnum::XmlSerialize(Box::new((*n).clone())),
491            NodeRef::WithClause(n) => NodeEnum::WithClause((*n).clone()),
492            NodeRef::InferClause(n) => NodeEnum::InferClause(Box::new((*n).clone())),
493            NodeRef::OnConflictClause(n) => NodeEnum::OnConflictClause(Box::new((*n).clone())),
494            NodeRef::CommonTableExpr(n) => NodeEnum::CommonTableExpr(Box::new((*n).clone())),
495            NodeRef::RoleSpec(n) => NodeEnum::RoleSpec((*n).clone()),
496            NodeRef::TriggerTransition(n) => NodeEnum::TriggerTransition((*n).clone()),
497            NodeRef::PartitionElem(n) => NodeEnum::PartitionElem(Box::new((*n).clone())),
498            NodeRef::PartitionSpec(n) => NodeEnum::PartitionSpec((*n).clone()),
499            NodeRef::PartitionBoundSpec(n) => NodeEnum::PartitionBoundSpec((*n).clone()),
500            NodeRef::PartitionRangeDatum(n) => NodeEnum::PartitionRangeDatum(Box::new((*n).clone())),
501            NodeRef::PartitionCmd(n) => NodeEnum::PartitionCmd((*n).clone()),
502            NodeRef::VacuumRelation(n) => NodeEnum::VacuumRelation((*n).clone()),
503            NodeRef::InlineCodeBlock(n) => NodeEnum::InlineCodeBlock((*n).clone()),
504            NodeRef::CallContext(n) => NodeEnum::CallContext((*n).clone()),
505            NodeRef::Integer(n) => NodeEnum::Integer((*n).clone()),
506            NodeRef::Float(n) => NodeEnum::Float((*n).clone()),
507            NodeRef::Boolean(n) => NodeEnum::Boolean((*n).clone()),
508            NodeRef::String(n) => NodeEnum::String((*n).clone()),
509            NodeRef::BitString(n) => NodeEnum::BitString((*n).clone()),
510            NodeRef::List(n) => NodeEnum::List((*n).clone()),
511            NodeRef::IntList(n) => NodeEnum::IntList((*n).clone()),
512            NodeRef::OidList(n) => NodeEnum::OidList((*n).clone()),
513            NodeRef::MergeStmt(n) => NodeEnum::MergeStmt(Box::new((*n).clone())),
514            NodeRef::MergeAction(n) => NodeEnum::MergeAction(Box::new((*n).clone())),
515            NodeRef::AlterDatabaseRefreshCollStmt(n) => NodeEnum::AlterDatabaseRefreshCollStmt((*n).clone()),
516            NodeRef::ReturnStmt(n) => NodeEnum::ReturnStmt(Box::new((*n).clone())),
517            NodeRef::PlassignStmt(n) => NodeEnum::PlassignStmt(Box::new((*n).clone())),
518            NodeRef::StatsElem(n) => NodeEnum::StatsElem(Box::new((*n).clone())),
519            NodeRef::CtesearchClause(n) => NodeEnum::CtesearchClause((*n).clone()),
520            NodeRef::CtecycleClause(n) => NodeEnum::CtecycleClause(Box::new((*n).clone())),
521            NodeRef::MergeWhenClause(n) => NodeEnum::MergeWhenClause(Box::new((*n).clone())),
522            NodeRef::PublicationObjSpec(n) => NodeEnum::PublicationObjSpec(Box::new((*n).clone())),
523            NodeRef::PublicationTable(n) => NodeEnum::PublicationTable(Box::new((*n).clone())),
524            NodeRef::JsonFormat(n) => NodeEnum::JsonFormat((*n).clone()),
525            NodeRef::JsonReturning(n) => NodeEnum::JsonReturning((*n).clone()),
526            NodeRef::JsonValueExpr(n) => NodeEnum::JsonValueExpr(Box::new((*n).clone())),
527            NodeRef::JsonConstructorExpr(n) => NodeEnum::JsonConstructorExpr(Box::new((*n).clone())),
528            NodeRef::JsonIsPredicate(n) => NodeEnum::JsonIsPredicate(Box::new((*n).clone())),
529            NodeRef::JsonOutput(n) => NodeEnum::JsonOutput((*n).clone()),
530            NodeRef::JsonKeyValue(n) => NodeEnum::JsonKeyValue(Box::new((*n).clone())),
531            NodeRef::JsonObjectConstructor(n) => NodeEnum::JsonObjectConstructor((*n).clone()),
532            NodeRef::JsonArrayConstructor(n) => NodeEnum::JsonArrayConstructor((*n).clone()),
533            NodeRef::JsonArrayQueryConstructor(n) => NodeEnum::JsonArrayQueryConstructor(Box::new((*n).clone())),
534            NodeRef::JsonAggConstructor(n) => NodeEnum::JsonAggConstructor(Box::new((*n).clone())),
535            NodeRef::JsonObjectAgg(n) => NodeEnum::JsonObjectAgg(Box::new((*n).clone())),
536            NodeRef::JsonArrayAgg(n) => NodeEnum::JsonArrayAgg(Box::new((*n).clone())),
537            NodeRef::RtepermissionInfo(n) => NodeEnum::RtepermissionInfo((*n).clone()),
538            NodeRef::WindowFuncRunCondition(n) => NodeEnum::WindowFuncRunCondition(Box::new((*n).clone())),
539            NodeRef::MergeSupportFunc(n) => NodeEnum::MergeSupportFunc(Box::new((*n).clone())),
540            NodeRef::JsonBehavior(n) => NodeEnum::JsonBehavior(Box::new((*n).clone())),
541            NodeRef::JsonExpr(n) => NodeEnum::JsonExpr(Box::new((*n).clone())),
542            NodeRef::JsonTablePath(n) => NodeEnum::JsonTablePath((*n).clone()),
543            NodeRef::JsonTablePathScan(n) => NodeEnum::JsonTablePathScan(Box::new((*n).clone())),
544            NodeRef::JsonTableSiblingJoin(n) => NodeEnum::JsonTableSiblingJoin(Box::new((*n).clone())),
545            NodeRef::SinglePartitionSpec(n) => NodeEnum::SinglePartitionSpec((*n).clone()),
546            NodeRef::JsonArgument(n) => NodeEnum::JsonArgument(Box::new((*n).clone())),
547            NodeRef::JsonFuncExpr(n) => NodeEnum::JsonFuncExpr(Box::new((*n).clone())),
548            NodeRef::JsonTablePathSpec(n) => NodeEnum::JsonTablePathSpec(Box::new((*n).clone())),
549            NodeRef::JsonTable(n) => NodeEnum::JsonTable(Box::new((*n).clone())),
550            NodeRef::JsonTableColumn(n) => NodeEnum::JsonTableColumn(Box::new((*n).clone())),
551            NodeRef::JsonParseExpr(n) => NodeEnum::JsonParseExpr(Box::new((*n).clone())),
552            NodeRef::JsonScalarExpr(n) => NodeEnum::JsonScalarExpr(Box::new((*n).clone())),
553            NodeRef::JsonSerializeExpr(n) => NodeEnum::JsonSerializeExpr(Box::new((*n).clone())),
554        }
555    }
556}