From 84d4683096f24483a37dc4c6de33934d9ece7494 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Fri, 28 Jul 2023 16:16:13 +0200
Subject: [PATCH 01/23] feat: initial commit for parser sourcegen

---
 .DS_Store                                     |  Bin 6148 -> 0 bytes
 .gitignore                                    |    2 +
 Cargo.toml                                    |    2 +
 crates/parser/Cargo.toml                      |    3 +
 crates/parser/proto/source.proto              | 3673 +++++++++++++++++
 crates/parser/src/bin/generate.rs             |  148 +
 crates/parser/src/pg_query_utils.rs           |  274 +-
 crates/parser/src/statement.rs                |   50 +-
 crates/parser/src/syntax_kind.rs              |  709 +++-
 crates/parser/src/syntax_kind_generated.rs    |  762 ++++
 crates/parser/test_data/source/valid/0001.sql |   11 +
 .../test_data/statements/valid/0001.sql       |    3 +
 .../test_data/statements/valid/0002.sql       |    1 +
 .../test_data/statements/valid/0003.sql       |    7 +
 .../test_data/statements/valid/0004.sql       |    4 +
 .../test_data/statements/valid/0005.sql       |    1 +
 .../test_data/statements/valid/0006.sql       |    1 +
 .../test_data/statements/valid/0007.sql       |    6 +
 .../test_data/statements/valid/0008.sql       |    2 +
 .../test_data/statements/valid/0009.sql       |    4 +
 .../test_data/statements/valid/0010.sql       |    1 +
 .../test_data/statements/valid/0011.sql       |    3 +
 .../test_data/statements/valid/0012.sql       |    4 +
 .../test_data/statements/valid/0013.sql       |    3 +
 .../test_data/statements/valid/0014.sql       |    3 +
 .../test_data/statements/valid/0015.sql       |    4 +
 .../test_data/statements/valid/0016.sql       |    1 +
 .../test_data/statements/valid/0017.sql       |    2 +
 .../test_data/statements/valid/0018.sql       |    1 +
 .../test_data/statements/valid/0019.sql       |    4 +
 .../test_data/statements/valid/0020.sql       |   10 +
 .../test_data/statements/valid/0021.sql       |    1 +
 .../test_data/statements/valid/0022.sql       |    5 +
 .../test_data/statements/valid/0023.sql       |    7 +
 .../test_data/statements/valid/0024.sql       |    6 +
 .../test_data/statements/valid/0025.sql       |    1 +
 .../test_data/statements/valid/0026.sql       |    1 +
 .../test_data/statements/valid/0027.sql       |    1 +
 .../test_data/statements/valid/0028.sql       |    1 +
 .../test_data/statements/valid/0029.sql       |    1 +
 .../test_data/statements/valid/0030.sql       |    2 +
 .../test_data/statements/valid/0031.sql       |    6 +
 .../test_data/statements/valid/0032.sql       |    1 +
 .../test_data/statements/valid/0033.sql       |    6 +
 .../test_data/statements/valid/0034.sql       |    1 +
 .../test_data/statements/valid/0035.sql       |    1 +
 .../test_data/statements/valid/0036.sql       |    3 +
 crates/pg_query_proto_parser/Cargo.toml       |   11 +
 crates/pg_query_proto_parser/src/lib.rs       |    9 +
 .../pg_query_proto_parser/src/proto_file.rs   |   57 +
 .../pg_query_proto_parser/src/proto_parser.rs |  110 +
 crates/postgres_lsp/Cargo.toml                |    2 +-
 crates/sourcegen/Cargo.toml                   |    9 +
 crates/sourcegen/src/attribute.rs             |   76 +
 crates/sourcegen/src/builder.rs               |   10 +
 crates/sourcegen/src/comment.rs               |   58 +
 crates/sourcegen/src/enum_.rs                 |  100 +
 crates/sourcegen/src/function.rs              |   96 +
 crates/sourcegen/src/implementation.rs        |   54 +
 crates/sourcegen/src/imports.rs               |   64 +
 crates/sourcegen/src/lib.rs                   |   60 +
 crates/sourcegen/src/match_.rs                |   65 +
 crates/sourcegen/src/source_file.rs           |   60 +
 63 files changed, 6571 insertions(+), 13 deletions(-)
 delete mode 100644 .DS_Store
 create mode 100644 crates/parser/proto/source.proto
 create mode 100644 crates/parser/src/bin/generate.rs
 create mode 100644 crates/parser/src/syntax_kind_generated.rs
 create mode 100644 crates/parser/test_data/source/valid/0001.sql
 create mode 100644 crates/parser/test_data/statements/valid/0001.sql
 create mode 100644 crates/parser/test_data/statements/valid/0002.sql
 create mode 100644 crates/parser/test_data/statements/valid/0003.sql
 create mode 100644 crates/parser/test_data/statements/valid/0004.sql
 create mode 100644 crates/parser/test_data/statements/valid/0005.sql
 create mode 100644 crates/parser/test_data/statements/valid/0006.sql
 create mode 100644 crates/parser/test_data/statements/valid/0007.sql
 create mode 100644 crates/parser/test_data/statements/valid/0008.sql
 create mode 100644 crates/parser/test_data/statements/valid/0009.sql
 create mode 100644 crates/parser/test_data/statements/valid/0010.sql
 create mode 100644 crates/parser/test_data/statements/valid/0011.sql
 create mode 100644 crates/parser/test_data/statements/valid/0012.sql
 create mode 100644 crates/parser/test_data/statements/valid/0013.sql
 create mode 100644 crates/parser/test_data/statements/valid/0014.sql
 create mode 100644 crates/parser/test_data/statements/valid/0015.sql
 create mode 100644 crates/parser/test_data/statements/valid/0016.sql
 create mode 100644 crates/parser/test_data/statements/valid/0017.sql
 create mode 100644 crates/parser/test_data/statements/valid/0018.sql
 create mode 100644 crates/parser/test_data/statements/valid/0019.sql
 create mode 100644 crates/parser/test_data/statements/valid/0020.sql
 create mode 100644 crates/parser/test_data/statements/valid/0021.sql
 create mode 100644 crates/parser/test_data/statements/valid/0022.sql
 create mode 100644 crates/parser/test_data/statements/valid/0023.sql
 create mode 100644 crates/parser/test_data/statements/valid/0024.sql
 create mode 100644 crates/parser/test_data/statements/valid/0025.sql
 create mode 100644 crates/parser/test_data/statements/valid/0026.sql
 create mode 100644 crates/parser/test_data/statements/valid/0027.sql
 create mode 100644 crates/parser/test_data/statements/valid/0028.sql
 create mode 100644 crates/parser/test_data/statements/valid/0029.sql
 create mode 100644 crates/parser/test_data/statements/valid/0030.sql
 create mode 100644 crates/parser/test_data/statements/valid/0031.sql
 create mode 100644 crates/parser/test_data/statements/valid/0032.sql
 create mode 100644 crates/parser/test_data/statements/valid/0033.sql
 create mode 100644 crates/parser/test_data/statements/valid/0034.sql
 create mode 100644 crates/parser/test_data/statements/valid/0035.sql
 create mode 100644 crates/parser/test_data/statements/valid/0036.sql
 create mode 100644 crates/pg_query_proto_parser/Cargo.toml
 create mode 100644 crates/pg_query_proto_parser/src/lib.rs
 create mode 100644 crates/pg_query_proto_parser/src/proto_file.rs
 create mode 100644 crates/pg_query_proto_parser/src/proto_parser.rs
 create mode 100644 crates/sourcegen/Cargo.toml
 create mode 100644 crates/sourcegen/src/attribute.rs
 create mode 100644 crates/sourcegen/src/builder.rs
 create mode 100644 crates/sourcegen/src/comment.rs
 create mode 100644 crates/sourcegen/src/enum_.rs
 create mode 100644 crates/sourcegen/src/function.rs
 create mode 100644 crates/sourcegen/src/implementation.rs
 create mode 100644 crates/sourcegen/src/imports.rs
 create mode 100644 crates/sourcegen/src/lib.rs
 create mode 100644 crates/sourcegen/src/match_.rs
 create mode 100644 crates/sourcegen/src/source_file.rs

diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index 0c737d4c73405d6e90e5f4eaf867fd8ada145890..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 6148
zcmeHK&2G~`82mN~jok_<2P*Ya$x^RTNCS$5xVUL@s018p1P4IDj;&(V@kX&jkfKOF
zx9`wb;L4NmE}ZD>PY`zC2%=~|>DyWF&Un3JdDlxsY_JHAiCRQtAq6&eQT!rAzsRkq
z=@uKv<UKfbC?QT0y4+%$2IGKn;9qk<e7n1JN<Pi$0$=Wr@AoX>lOW*%`o-dKg6w>k
zfm&6QLpi0SqWN6WG%2D_7->o~tP)X~%?`KN&*%(KHli2g(Wt_{uCQ%72lIr6^c>j1
z7-2>6t)i$?hB;5ltlC9|wL`h~CZfE|m7d)E<VlGeEVG&R?@KUC;w<lWzp`4rac`$-
zHLX4Co%ew+z1+_i*}$K_5mzrcPl8R|4_?L5a@=}w%G2DB(`YUQaTtN}_H~?wd^zBY
zG|Z&dQyrFV+2hv1YIWT2x1C<EzivCLC%taldHkrqUfb6G(Zi?b<I7~4@+-_0!LWAA
zxUX>o!sF7MK6>*s;i>RwquFo`-aQBOJGA!h-lLl*HVzmE{;&gLeQ=NhU5$l8xpbhA
zM*v_0%`#9IzY9X+Xmm9e3ekgLN(xj`rjHm*$<gj;o~yA?sN}@-;e+XsnLeQ~IXdp|
zNIEfBp(%|6#(}Z}b#>Vi`~T?o=l`<ETp0(91OJr+tTFV4158Qpty_~5d#!_fj}#$z
ng+eJop|@jM5nJ&AQU>}QQ31Ld3x#Mwm>&UYgDH#yf7O9oF*2gh

diff --git a/.gitignore b/.gitignore
index 196e176d..21912aef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,5 @@ Cargo.lock
 # Added by cargo
 
 /target
+
+**/.DS_Store
diff --git a/Cargo.toml b/Cargo.toml
index 925ff684..4e6bb4f1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,8 @@ members = [
 
 [workspace.dependencies]
 parser = { path = "./crates/parser", version = "0.0.0" }
+sourcegen = { path = "./crates/sourcegen", version = "0.0.0" }
+pg_query_proto_parser = { path = "./crates/pg_query_proto_parser", version = "0.0.0" }
 triomphe = { version = "0.1.8", default-features = false, features = ["std"] }
 
 
diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml
index c5bb8591..171be408 100644
--- a/crates/parser/Cargo.toml
+++ b/crates/parser/Cargo.toml
@@ -12,3 +12,6 @@ logos = "0.13.0"
 serde_json = "1.0"
 regex = "1.9.1"
 serde = { version = "1.0", features = ["derive"] }
+
+sourcegen.workspace = true
+pg_query_proto_parser.workspace = true
diff --git a/crates/parser/proto/source.proto b/crates/parser/proto/source.proto
new file mode 100644
index 00000000..e34f5869
--- /dev/null
+++ b/crates/parser/proto/source.proto
@@ -0,0 +1,3673 @@
+// This file is copied from https://github.com/pganalyze/libpg_query/blob/fc5775e0622955f9e5d887dfaf0b7bbf7f9046f9/protobuf/pg_query.proto
+// This file is autogenerated by ./scripts/generate_protobuf_and_funcs.rb
+
+syntax = "proto3";
+
+package pg_query;
+
+message ParseResult {
+  int32 version = 1;
+  repeated RawStmt stmts = 2;
+}
+
+message ScanResult {
+  int32 version = 1;
+  repeated ScanToken tokens = 2;
+}
+
+message Node {
+  oneof node {
+		Alias alias = 1 [json_name="Alias"];
+    RangeVar range_var = 2 [json_name="RangeVar"];
+    TableFunc table_func = 3 [json_name="TableFunc"];
+    Var var = 4 [json_name="Var"];
+    Param param = 5 [json_name="Param"];
+    Aggref aggref = 6 [json_name="Aggref"];
+    GroupingFunc grouping_func = 7 [json_name="GroupingFunc"];
+    WindowFunc window_func = 8 [json_name="WindowFunc"];
+    SubscriptingRef subscripting_ref = 9 [json_name="SubscriptingRef"];
+    FuncExpr func_expr = 10 [json_name="FuncExpr"];
+    NamedArgExpr named_arg_expr = 11 [json_name="NamedArgExpr"];
+    OpExpr op_expr = 12 [json_name="OpExpr"];
+    DistinctExpr distinct_expr = 13 [json_name="DistinctExpr"];
+    NullIfExpr null_if_expr = 14 [json_name="NullIfExpr"];
+    ScalarArrayOpExpr scalar_array_op_expr = 15 [json_name="ScalarArrayOpExpr"];
+    BoolExpr bool_expr = 16 [json_name="BoolExpr"];
+    SubLink sub_link = 17 [json_name="SubLink"];
+    SubPlan sub_plan = 18 [json_name="SubPlan"];
+    AlternativeSubPlan alternative_sub_plan = 19 [json_name="AlternativeSubPlan"];
+    FieldSelect field_select = 20 [json_name="FieldSelect"];
+    FieldStore field_store = 21 [json_name="FieldStore"];
+    RelabelType relabel_type = 22 [json_name="RelabelType"];
+    CoerceViaIO coerce_via_io = 23 [json_name="CoerceViaIO"];
+    ArrayCoerceExpr array_coerce_expr = 24 [json_name="ArrayCoerceExpr"];
+    ConvertRowtypeExpr convert_rowtype_expr = 25 [json_name="ConvertRowtypeExpr"];
+    CollateExpr collate_expr = 26 [json_name="CollateExpr"];
+    CaseExpr case_expr = 27 [json_name="CaseExpr"];
+    CaseWhen case_when = 28 [json_name="CaseWhen"];
+    CaseTestExpr case_test_expr = 29 [json_name="CaseTestExpr"];
+    ArrayExpr array_expr = 30 [json_name="ArrayExpr"];
+    RowExpr row_expr = 31 [json_name="RowExpr"];
+    RowCompareExpr row_compare_expr = 32 [json_name="RowCompareExpr"];
+    CoalesceExpr coalesce_expr = 33 [json_name="CoalesceExpr"];
+    MinMaxExpr min_max_expr = 34 [json_name="MinMaxExpr"];
+    SQLValueFunction sqlvalue_function = 35 [json_name="SQLValueFunction"];
+    XmlExpr xml_expr = 36 [json_name="XmlExpr"];
+    NullTest null_test = 37 [json_name="NullTest"];
+    BooleanTest boolean_test = 38 [json_name="BooleanTest"];
+    CoerceToDomain coerce_to_domain = 39 [json_name="CoerceToDomain"];
+    CoerceToDomainValue coerce_to_domain_value = 40 [json_name="CoerceToDomainValue"];
+    SetToDefault set_to_default = 41 [json_name="SetToDefault"];
+    CurrentOfExpr current_of_expr = 42 [json_name="CurrentOfExpr"];
+    NextValueExpr next_value_expr = 43 [json_name="NextValueExpr"];
+    InferenceElem inference_elem = 44 [json_name="InferenceElem"];
+    TargetEntry target_entry = 45 [json_name="TargetEntry"];
+    RangeTblRef range_tbl_ref = 46 [json_name="RangeTblRef"];
+    JoinExpr join_expr = 47 [json_name="JoinExpr"];
+    FromExpr from_expr = 48 [json_name="FromExpr"];
+    OnConflictExpr on_conflict_expr = 49 [json_name="OnConflictExpr"];
+    IntoClause into_clause = 50 [json_name="IntoClause"];
+    MergeAction merge_action = 51 [json_name="MergeAction"];
+    RawStmt raw_stmt = 52 [json_name="RawStmt"];
+    Query query = 53 [json_name="Query"];
+    InsertStmt insert_stmt = 54 [json_name="InsertStmt"];
+    DeleteStmt delete_stmt = 55 [json_name="DeleteStmt"];
+    UpdateStmt update_stmt = 56 [json_name="UpdateStmt"];
+    MergeStmt merge_stmt = 57 [json_name="MergeStmt"];
+    SelectStmt select_stmt = 58 [json_name="SelectStmt"];
+    ReturnStmt return_stmt = 59 [json_name="ReturnStmt"];
+    PLAssignStmt plassign_stmt = 60 [json_name="PLAssignStmt"];
+    AlterTableStmt alter_table_stmt = 61 [json_name="AlterTableStmt"];
+    AlterTableCmd alter_table_cmd = 62 [json_name="AlterTableCmd"];
+    AlterDomainStmt alter_domain_stmt = 63 [json_name="AlterDomainStmt"];
+    SetOperationStmt set_operation_stmt = 64 [json_name="SetOperationStmt"];
+    GrantStmt grant_stmt = 65 [json_name="GrantStmt"];
+    GrantRoleStmt grant_role_stmt = 66 [json_name="GrantRoleStmt"];
+    AlterDefaultPrivilegesStmt alter_default_privileges_stmt = 67 [json_name="AlterDefaultPrivilegesStmt"];
+    ClosePortalStmt close_portal_stmt = 68 [json_name="ClosePortalStmt"];
+    ClusterStmt cluster_stmt = 69 [json_name="ClusterStmt"];
+    CopyStmt copy_stmt = 70 [json_name="CopyStmt"];
+    CreateStmt create_stmt = 71 [json_name="CreateStmt"];
+    DefineStmt define_stmt = 72 [json_name="DefineStmt"];
+    DropStmt drop_stmt = 73 [json_name="DropStmt"];
+    TruncateStmt truncate_stmt = 74 [json_name="TruncateStmt"];
+    CommentStmt comment_stmt = 75 [json_name="CommentStmt"];
+    FetchStmt fetch_stmt = 76 [json_name="FetchStmt"];
+    IndexStmt index_stmt = 77 [json_name="IndexStmt"];
+    CreateFunctionStmt create_function_stmt = 78 [json_name="CreateFunctionStmt"];
+    AlterFunctionStmt alter_function_stmt = 79 [json_name="AlterFunctionStmt"];
+    DoStmt do_stmt = 80 [json_name="DoStmt"];
+    RenameStmt rename_stmt = 81 [json_name="RenameStmt"];
+    RuleStmt rule_stmt = 82 [json_name="RuleStmt"];
+    NotifyStmt notify_stmt = 83 [json_name="NotifyStmt"];
+    ListenStmt listen_stmt = 84 [json_name="ListenStmt"];
+    UnlistenStmt unlisten_stmt = 85 [json_name="UnlistenStmt"];
+    TransactionStmt transaction_stmt = 86 [json_name="TransactionStmt"];
+    ViewStmt view_stmt = 87 [json_name="ViewStmt"];
+    LoadStmt load_stmt = 88 [json_name="LoadStmt"];
+    CreateDomainStmt create_domain_stmt = 89 [json_name="CreateDomainStmt"];
+    CreatedbStmt createdb_stmt = 90 [json_name="CreatedbStmt"];
+    DropdbStmt dropdb_stmt = 91 [json_name="DropdbStmt"];
+    VacuumStmt vacuum_stmt = 92 [json_name="VacuumStmt"];
+    ExplainStmt explain_stmt = 93 [json_name="ExplainStmt"];
+    CreateTableAsStmt create_table_as_stmt = 94 [json_name="CreateTableAsStmt"];
+    CreateSeqStmt create_seq_stmt = 95 [json_name="CreateSeqStmt"];
+    AlterSeqStmt alter_seq_stmt = 96 [json_name="AlterSeqStmt"];
+    VariableSetStmt variable_set_stmt = 97 [json_name="VariableSetStmt"];
+    VariableShowStmt variable_show_stmt = 98 [json_name="VariableShowStmt"];
+    DiscardStmt discard_stmt = 99 [json_name="DiscardStmt"];
+    CreateTrigStmt create_trig_stmt = 100 [json_name="CreateTrigStmt"];
+    CreatePLangStmt create_plang_stmt = 101 [json_name="CreatePLangStmt"];
+    CreateRoleStmt create_role_stmt = 102 [json_name="CreateRoleStmt"];
+    AlterRoleStmt alter_role_stmt = 103 [json_name="AlterRoleStmt"];
+    DropRoleStmt drop_role_stmt = 104 [json_name="DropRoleStmt"];
+    LockStmt lock_stmt = 105 [json_name="LockStmt"];
+    ConstraintsSetStmt constraints_set_stmt = 106 [json_name="ConstraintsSetStmt"];
+    ReindexStmt reindex_stmt = 107 [json_name="ReindexStmt"];
+    CheckPointStmt check_point_stmt = 108 [json_name="CheckPointStmt"];
+    CreateSchemaStmt create_schema_stmt = 109 [json_name="CreateSchemaStmt"];
+    AlterDatabaseStmt alter_database_stmt = 110 [json_name="AlterDatabaseStmt"];
+    AlterDatabaseRefreshCollStmt alter_database_refresh_coll_stmt = 111 [json_name="AlterDatabaseRefreshCollStmt"];
+    AlterDatabaseSetStmt alter_database_set_stmt = 112 [json_name="AlterDatabaseSetStmt"];
+    AlterRoleSetStmt alter_role_set_stmt = 113 [json_name="AlterRoleSetStmt"];
+    CreateConversionStmt create_conversion_stmt = 114 [json_name="CreateConversionStmt"];
+    CreateCastStmt create_cast_stmt = 115 [json_name="CreateCastStmt"];
+    CreateOpClassStmt create_op_class_stmt = 116 [json_name="CreateOpClassStmt"];
+    CreateOpFamilyStmt create_op_family_stmt = 117 [json_name="CreateOpFamilyStmt"];
+    AlterOpFamilyStmt alter_op_family_stmt = 118 [json_name="AlterOpFamilyStmt"];
+    PrepareStmt prepare_stmt = 119 [json_name="PrepareStmt"];
+    ExecuteStmt execute_stmt = 120 [json_name="ExecuteStmt"];
+    DeallocateStmt deallocate_stmt = 121 [json_name="DeallocateStmt"];
+    DeclareCursorStmt declare_cursor_stmt = 122 [json_name="DeclareCursorStmt"];
+    CreateTableSpaceStmt create_table_space_stmt = 123 [json_name="CreateTableSpaceStmt"];
+    DropTableSpaceStmt drop_table_space_stmt = 124 [json_name="DropTableSpaceStmt"];
+    AlterObjectDependsStmt alter_object_depends_stmt = 125 [json_name="AlterObjectDependsStmt"];
+    AlterObjectSchemaStmt alter_object_schema_stmt = 126 [json_name="AlterObjectSchemaStmt"];
+    AlterOwnerStmt alter_owner_stmt = 127 [json_name="AlterOwnerStmt"];
+    AlterOperatorStmt alter_operator_stmt = 128 [json_name="AlterOperatorStmt"];
+    AlterTypeStmt alter_type_stmt = 129 [json_name="AlterTypeStmt"];
+    DropOwnedStmt drop_owned_stmt = 130 [json_name="DropOwnedStmt"];
+    ReassignOwnedStmt reassign_owned_stmt = 131 [json_name="ReassignOwnedStmt"];
+    CompositeTypeStmt composite_type_stmt = 132 [json_name="CompositeTypeStmt"];
+    CreateEnumStmt create_enum_stmt = 133 [json_name="CreateEnumStmt"];
+    CreateRangeStmt create_range_stmt = 134 [json_name="CreateRangeStmt"];
+    AlterEnumStmt alter_enum_stmt = 135 [json_name="AlterEnumStmt"];
+    AlterTSDictionaryStmt alter_tsdictionary_stmt = 136 [json_name="AlterTSDictionaryStmt"];
+    AlterTSConfigurationStmt alter_tsconfiguration_stmt = 137 [json_name="AlterTSConfigurationStmt"];
+    CreateFdwStmt create_fdw_stmt = 138 [json_name="CreateFdwStmt"];
+    AlterFdwStmt alter_fdw_stmt = 139 [json_name="AlterFdwStmt"];
+    CreateForeignServerStmt create_foreign_server_stmt = 140 [json_name="CreateForeignServerStmt"];
+    AlterForeignServerStmt alter_foreign_server_stmt = 141 [json_name="AlterForeignServerStmt"];
+    CreateUserMappingStmt create_user_mapping_stmt = 142 [json_name="CreateUserMappingStmt"];
+    AlterUserMappingStmt alter_user_mapping_stmt = 143 [json_name="AlterUserMappingStmt"];
+    DropUserMappingStmt drop_user_mapping_stmt = 144 [json_name="DropUserMappingStmt"];
+    AlterTableSpaceOptionsStmt alter_table_space_options_stmt = 145 [json_name="AlterTableSpaceOptionsStmt"];
+    AlterTableMoveAllStmt alter_table_move_all_stmt = 146 [json_name="AlterTableMoveAllStmt"];
+    SecLabelStmt sec_label_stmt = 147 [json_name="SecLabelStmt"];
+    CreateForeignTableStmt create_foreign_table_stmt = 148 [json_name="CreateForeignTableStmt"];
+    ImportForeignSchemaStmt import_foreign_schema_stmt = 149 [json_name="ImportForeignSchemaStmt"];
+    CreateExtensionStmt create_extension_stmt = 150 [json_name="CreateExtensionStmt"];
+    AlterExtensionStmt alter_extension_stmt = 151 [json_name="AlterExtensionStmt"];
+    AlterExtensionContentsStmt alter_extension_contents_stmt = 152 [json_name="AlterExtensionContentsStmt"];
+    CreateEventTrigStmt create_event_trig_stmt = 153 [json_name="CreateEventTrigStmt"];
+    AlterEventTrigStmt alter_event_trig_stmt = 154 [json_name="AlterEventTrigStmt"];
+    RefreshMatViewStmt refresh_mat_view_stmt = 155 [json_name="RefreshMatViewStmt"];
+    ReplicaIdentityStmt replica_identity_stmt = 156 [json_name="ReplicaIdentityStmt"];
+    AlterSystemStmt alter_system_stmt = 157 [json_name="AlterSystemStmt"];
+    CreatePolicyStmt create_policy_stmt = 158 [json_name="CreatePolicyStmt"];
+    AlterPolicyStmt alter_policy_stmt = 159 [json_name="AlterPolicyStmt"];
+    CreateTransformStmt create_transform_stmt = 160 [json_name="CreateTransformStmt"];
+    CreateAmStmt create_am_stmt = 161 [json_name="CreateAmStmt"];
+    CreatePublicationStmt create_publication_stmt = 162 [json_name="CreatePublicationStmt"];
+    AlterPublicationStmt alter_publication_stmt = 163 [json_name="AlterPublicationStmt"];
+    CreateSubscriptionStmt create_subscription_stmt = 164 [json_name="CreateSubscriptionStmt"];
+    AlterSubscriptionStmt alter_subscription_stmt = 165 [json_name="AlterSubscriptionStmt"];
+    DropSubscriptionStmt drop_subscription_stmt = 166 [json_name="DropSubscriptionStmt"];
+    CreateStatsStmt create_stats_stmt = 167 [json_name="CreateStatsStmt"];
+    AlterCollationStmt alter_collation_stmt = 168 [json_name="AlterCollationStmt"];
+    CallStmt call_stmt = 169 [json_name="CallStmt"];
+    AlterStatsStmt alter_stats_stmt = 170 [json_name="AlterStatsStmt"];
+    A_Expr a_expr = 171 [json_name="A_Expr"];
+    ColumnRef column_ref = 172 [json_name="ColumnRef"];
+    ParamRef param_ref = 173 [json_name="ParamRef"];
+    FuncCall func_call = 174 [json_name="FuncCall"];
+    A_Star a_star = 175 [json_name="A_Star"];
+    A_Indices a_indices = 176 [json_name="A_Indices"];
+    A_Indirection a_indirection = 177 [json_name="A_Indirection"];
+    A_ArrayExpr a_array_expr = 178 [json_name="A_ArrayExpr"];
+    ResTarget res_target = 179 [json_name="ResTarget"];
+    MultiAssignRef multi_assign_ref = 180 [json_name="MultiAssignRef"];
+    TypeCast type_cast = 181 [json_name="TypeCast"];
+    CollateClause collate_clause = 182 [json_name="CollateClause"];
+    SortBy sort_by = 183 [json_name="SortBy"];
+    WindowDef window_def = 184 [json_name="WindowDef"];
+    RangeSubselect range_subselect = 185 [json_name="RangeSubselect"];
+    RangeFunction range_function = 186 [json_name="RangeFunction"];
+    RangeTableSample range_table_sample = 187 [json_name="RangeTableSample"];
+    RangeTableFunc range_table_func = 188 [json_name="RangeTableFunc"];
+    RangeTableFuncCol range_table_func_col = 189 [json_name="RangeTableFuncCol"];
+    TypeName type_name = 190 [json_name="TypeName"];
+    ColumnDef column_def = 191 [json_name="ColumnDef"];
+    IndexElem index_elem = 192 [json_name="IndexElem"];
+    StatsElem stats_elem = 193 [json_name="StatsElem"];
+    Constraint constraint = 194 [json_name="Constraint"];
+    DefElem def_elem = 195 [json_name="DefElem"];
+    RangeTblEntry range_tbl_entry = 196 [json_name="RangeTblEntry"];
+    RangeTblFunction range_tbl_function = 197 [json_name="RangeTblFunction"];
+    TableSampleClause table_sample_clause = 198 [json_name="TableSampleClause"];
+    WithCheckOption with_check_option = 199 [json_name="WithCheckOption"];
+    SortGroupClause sort_group_clause = 200 [json_name="SortGroupClause"];
+    GroupingSet grouping_set = 201 [json_name="GroupingSet"];
+    WindowClause window_clause = 202 [json_name="WindowClause"];
+    ObjectWithArgs object_with_args = 203 [json_name="ObjectWithArgs"];
+    AccessPriv access_priv = 204 [json_name="AccessPriv"];
+    CreateOpClassItem create_op_class_item = 205 [json_name="CreateOpClassItem"];
+    TableLikeClause table_like_clause = 206 [json_name="TableLikeClause"];
+    FunctionParameter function_parameter = 207 [json_name="FunctionParameter"];
+    LockingClause locking_clause = 208 [json_name="LockingClause"];
+    RowMarkClause row_mark_clause = 209 [json_name="RowMarkClause"];
+    XmlSerialize xml_serialize = 210 [json_name="XmlSerialize"];
+    WithClause with_clause = 211 [json_name="WithClause"];
+    InferClause infer_clause = 212 [json_name="InferClause"];
+    OnConflictClause on_conflict_clause = 213 [json_name="OnConflictClause"];
+    CTESearchClause ctesearch_clause = 214 [json_name="CTESearchClause"];
+    CTECycleClause ctecycle_clause = 215 [json_name="CTECycleClause"];
+    CommonTableExpr common_table_expr = 216 [json_name="CommonTableExpr"];
+    MergeWhenClause merge_when_clause = 217 [json_name="MergeWhenClause"];
+    RoleSpec role_spec = 218 [json_name="RoleSpec"];
+    TriggerTransition trigger_transition = 219 [json_name="TriggerTransition"];
+    PartitionElem partition_elem = 220 [json_name="PartitionElem"];
+    PartitionSpec partition_spec = 221 [json_name="PartitionSpec"];
+    PartitionBoundSpec partition_bound_spec = 222 [json_name="PartitionBoundSpec"];
+    PartitionRangeDatum partition_range_datum = 223 [json_name="PartitionRangeDatum"];
+    PartitionCmd partition_cmd = 224 [json_name="PartitionCmd"];
+    VacuumRelation vacuum_relation = 225 [json_name="VacuumRelation"];
+    PublicationObjSpec publication_obj_spec = 226 [json_name="PublicationObjSpec"];
+    PublicationTable publication_table = 227 [json_name="PublicationTable"];
+    InlineCodeBlock inline_code_block = 228 [json_name="InlineCodeBlock"];
+    CallContext call_context = 229 [json_name="CallContext"];
+    Integer integer = 230 [json_name="Integer"];
+    Float float = 231 [json_name="Float"];
+    Boolean boolean = 232 [json_name="Boolean"];
+    String string = 233 [json_name="String"];
+    BitString bit_string = 234 [json_name="BitString"];
+    List list = 235 [json_name="List"];
+    IntList int_list = 236 [json_name="IntList"];
+    OidList oid_list = 237 [json_name="OidList"];
+    A_Const a_const = 238 [json_name="A_Const"];
+  }
+}
+
+message Integer
+{
+  int32 ival = 1; /* machine integer */
+}
+
+message Float
+{
+  string fval = 1; /* string */
+}
+
+message Boolean
+{
+  bool boolval = 1;
+}
+
+message String
+{
+  string sval = 1; /* string */
+}
+
+message BitString
+{
+  string bsval = 1; /* string */
+}
+
+message List
+{
+  repeated Node items = 1;
+}
+
+message OidList
+{
+  repeated Node items = 1;
+}
+
+message IntList
+{
+  repeated Node items = 1;
+}
+
+message A_Const
+{
+  oneof val {
+    Integer ival = 1;
+    Float fval = 2;
+    Boolean boolval = 3;
+    String sval = 4;
+    BitString bsval = 5;
+  }
+  bool isnull = 10;
+  int32 location = 11;
+}
+
+message Alias
+{
+  string aliasname = 1 [json_name="aliasname"];
+  repeated Node colnames = 2 [json_name="colnames"];
+}
+
+message RangeVar
+{
+  string catalogname = 1 [json_name="catalogname"];
+  string schemaname = 2 [json_name="schemaname"];
+  string relname = 3 [json_name="relname"];
+  bool inh = 4 [json_name="inh"];
+  string relpersistence = 5 [json_name="relpersistence"];
+  Alias alias = 6 [json_name="alias"];
+  int32 location = 7 [json_name="location"];
+}
+
+message TableFunc
+{
+  repeated Node ns_uris = 1 [json_name="ns_uris"];
+  repeated Node ns_names = 2 [json_name="ns_names"];
+  Node docexpr = 3 [json_name="docexpr"];
+  Node rowexpr = 4 [json_name="rowexpr"];
+  repeated Node colnames = 5 [json_name="colnames"];
+  repeated Node coltypes = 6 [json_name="coltypes"];
+  repeated Node coltypmods = 7 [json_name="coltypmods"];
+  repeated Node colcollations = 8 [json_name="colcollations"];
+  repeated Node colexprs = 9 [json_name="colexprs"];
+  repeated Node coldefexprs = 10 [json_name="coldefexprs"];
+  repeated uint64 notnulls = 11 [json_name="notnulls"];
+  int32 ordinalitycol = 12 [json_name="ordinalitycol"];
+  int32 location = 13 [json_name="location"];
+}
+
+message Var
+{
+  Node xpr = 1 [json_name="xpr"];
+  int32 varno = 2 [json_name="varno"];
+  int32 varattno = 3 [json_name="varattno"];
+  uint32 vartype = 4 [json_name="vartype"];
+  int32 vartypmod = 5 [json_name="vartypmod"];
+  uint32 varcollid = 6 [json_name="varcollid"];
+  uint32 varlevelsup = 7 [json_name="varlevelsup"];
+  uint32 varnosyn = 8 [json_name="varnosyn"];
+  int32 varattnosyn = 9 [json_name="varattnosyn"];
+  int32 location = 10 [json_name="location"];
+}
+
+message Param
+{
+  Node xpr = 1 [json_name="xpr"];
+  ParamKind paramkind = 2 [json_name="paramkind"];
+  int32 paramid = 3 [json_name="paramid"];
+  uint32 paramtype = 4 [json_name="paramtype"];
+  int32 paramtypmod = 5 [json_name="paramtypmod"];
+  uint32 paramcollid = 6 [json_name="paramcollid"];
+  int32 location = 7 [json_name="location"];
+}
+
+message Aggref
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 aggfnoid = 2 [json_name="aggfnoid"];
+  uint32 aggtype = 3 [json_name="aggtype"];
+  uint32 aggcollid = 4 [json_name="aggcollid"];
+  uint32 inputcollid = 5 [json_name="inputcollid"];
+  uint32 aggtranstype = 6 [json_name="aggtranstype"];
+  repeated Node aggargtypes = 7 [json_name="aggargtypes"];
+  repeated Node aggdirectargs = 8 [json_name="aggdirectargs"];
+  repeated Node args = 9 [json_name="args"];
+  repeated Node aggorder = 10 [json_name="aggorder"];
+  repeated Node aggdistinct = 11 [json_name="aggdistinct"];
+  Node aggfilter = 12 [json_name="aggfilter"];
+  bool aggstar = 13 [json_name="aggstar"];
+  bool aggvariadic = 14 [json_name="aggvariadic"];
+  string aggkind = 15 [json_name="aggkind"];
+  uint32 agglevelsup = 16 [json_name="agglevelsup"];
+  AggSplit aggsplit = 17 [json_name="aggsplit"];
+  int32 aggno = 18 [json_name="aggno"];
+  int32 aggtransno = 19 [json_name="aggtransno"];
+  int32 location = 20 [json_name="location"];
+}
+
+message GroupingFunc
+{
+  Node xpr = 1 [json_name="xpr"];
+  repeated Node args = 2 [json_name="args"];
+  repeated Node refs = 3 [json_name="refs"];
+  repeated Node cols = 4 [json_name="cols"];
+  uint32 agglevelsup = 5 [json_name="agglevelsup"];
+  int32 location = 6 [json_name="location"];
+}
+
+message WindowFunc
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 winfnoid = 2 [json_name="winfnoid"];
+  uint32 wintype = 3 [json_name="wintype"];
+  uint32 wincollid = 4 [json_name="wincollid"];
+  uint32 inputcollid = 5 [json_name="inputcollid"];
+  repeated Node args = 6 [json_name="args"];
+  Node aggfilter = 7 [json_name="aggfilter"];
+  uint32 winref = 8 [json_name="winref"];
+  bool winstar = 9 [json_name="winstar"];
+  bool winagg = 10 [json_name="winagg"];
+  int32 location = 11 [json_name="location"];
+}
+
+message SubscriptingRef
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 refcontainertype = 2 [json_name="refcontainertype"];
+  uint32 refelemtype = 3 [json_name="refelemtype"];
+  uint32 refrestype = 4 [json_name="refrestype"];
+  int32 reftypmod = 5 [json_name="reftypmod"];
+  uint32 refcollid = 6 [json_name="refcollid"];
+  repeated Node refupperindexpr = 7 [json_name="refupperindexpr"];
+  repeated Node reflowerindexpr = 8 [json_name="reflowerindexpr"];
+  Node refexpr = 9 [json_name="refexpr"];
+  Node refassgnexpr = 10 [json_name="refassgnexpr"];
+}
+
+message FuncExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 funcid = 2 [json_name="funcid"];
+  uint32 funcresulttype = 3 [json_name="funcresulttype"];
+  bool funcretset = 4 [json_name="funcretset"];
+  bool funcvariadic = 5 [json_name="funcvariadic"];
+  CoercionForm funcformat = 6 [json_name="funcformat"];
+  uint32 funccollid = 7 [json_name="funccollid"];
+  uint32 inputcollid = 8 [json_name="inputcollid"];
+  repeated Node args = 9 [json_name="args"];
+  int32 location = 10 [json_name="location"];
+}
+
+message NamedArgExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  string name = 3 [json_name="name"];
+  int32 argnumber = 4 [json_name="argnumber"];
+  int32 location = 5 [json_name="location"];
+}
+
+message OpExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 opno = 2 [json_name="opno"];
+  uint32 opfuncid = 3 [json_name="opfuncid"];
+  uint32 opresulttype = 4 [json_name="opresulttype"];
+  bool opretset = 5 [json_name="opretset"];
+  uint32 opcollid = 6 [json_name="opcollid"];
+  uint32 inputcollid = 7 [json_name="inputcollid"];
+  repeated Node args = 8 [json_name="args"];
+  int32 location = 9 [json_name="location"];
+}
+
+message DistinctExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 opno = 2 [json_name="opno"];
+  uint32 opfuncid = 3 [json_name="opfuncid"];
+  uint32 opresulttype = 4 [json_name="opresulttype"];
+  bool opretset = 5 [json_name="opretset"];
+  uint32 opcollid = 6 [json_name="opcollid"];
+  uint32 inputcollid = 7 [json_name="inputcollid"];
+  repeated Node args = 8 [json_name="args"];
+  int32 location = 9 [json_name="location"];
+}
+
+message NullIfExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 opno = 2 [json_name="opno"];
+  uint32 opfuncid = 3 [json_name="opfuncid"];
+  uint32 opresulttype = 4 [json_name="opresulttype"];
+  bool opretset = 5 [json_name="opretset"];
+  uint32 opcollid = 6 [json_name="opcollid"];
+  uint32 inputcollid = 7 [json_name="inputcollid"];
+  repeated Node args = 8 [json_name="args"];
+  int32 location = 9 [json_name="location"];
+}
+
+message ScalarArrayOpExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 opno = 2 [json_name="opno"];
+  uint32 opfuncid = 3 [json_name="opfuncid"];
+  uint32 hashfuncid = 4 [json_name="hashfuncid"];
+  uint32 negfuncid = 5 [json_name="negfuncid"];
+  bool use_or = 6 [json_name="useOr"];
+  uint32 inputcollid = 7 [json_name="inputcollid"];
+  repeated Node args = 8 [json_name="args"];
+  int32 location = 9 [json_name="location"];
+}
+
+message BoolExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  BoolExprType boolop = 2 [json_name="boolop"];
+  repeated Node args = 3 [json_name="args"];
+  int32 location = 4 [json_name="location"];
+}
+
+message SubLink
+{
+  Node xpr = 1 [json_name="xpr"];
+  SubLinkType sub_link_type = 2 [json_name="subLinkType"];
+  int32 sub_link_id = 3 [json_name="subLinkId"];
+  Node testexpr = 4 [json_name="testexpr"];
+  repeated Node oper_name = 5 [json_name="operName"];
+  Node subselect = 6 [json_name="subselect"];
+  int32 location = 7 [json_name="location"];
+}
+
+message SubPlan
+{
+  Node xpr = 1 [json_name="xpr"];
+  SubLinkType sub_link_type = 2 [json_name="subLinkType"];
+  Node testexpr = 3 [json_name="testexpr"];
+  repeated Node param_ids = 4 [json_name="paramIds"];
+  int32 plan_id = 5 [json_name="plan_id"];
+  string plan_name = 6 [json_name="plan_name"];
+  uint32 first_col_type = 7 [json_name="firstColType"];
+  int32 first_col_typmod = 8 [json_name="firstColTypmod"];
+  uint32 first_col_collation = 9 [json_name="firstColCollation"];
+  bool use_hash_table = 10 [json_name="useHashTable"];
+  bool unknown_eq_false = 11 [json_name="unknownEqFalse"];
+  bool parallel_safe = 12 [json_name="parallel_safe"];
+  repeated Node set_param = 13 [json_name="setParam"];
+  repeated Node par_param = 14 [json_name="parParam"];
+  repeated Node args = 15 [json_name="args"];
+  double startup_cost = 16 [json_name="startup_cost"];
+  double per_call_cost = 17 [json_name="per_call_cost"];
+}
+
+message AlternativeSubPlan
+{
+  Node xpr = 1 [json_name="xpr"];
+  repeated Node subplans = 2 [json_name="subplans"];
+}
+
+message FieldSelect
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  int32 fieldnum = 3 [json_name="fieldnum"];
+  uint32 resulttype = 4 [json_name="resulttype"];
+  int32 resulttypmod = 5 [json_name="resulttypmod"];
+  uint32 resultcollid = 6 [json_name="resultcollid"];
+}
+
+message FieldStore
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  repeated Node newvals = 3 [json_name="newvals"];
+  repeated Node fieldnums = 4 [json_name="fieldnums"];
+  uint32 resulttype = 5 [json_name="resulttype"];
+}
+
+message RelabelType
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  uint32 resulttype = 3 [json_name="resulttype"];
+  int32 resulttypmod = 4 [json_name="resulttypmod"];
+  uint32 resultcollid = 5 [json_name="resultcollid"];
+  CoercionForm relabelformat = 6 [json_name="relabelformat"];
+  int32 location = 7 [json_name="location"];
+}
+
+message CoerceViaIO
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  uint32 resulttype = 3 [json_name="resulttype"];
+  uint32 resultcollid = 4 [json_name="resultcollid"];
+  CoercionForm coerceformat = 5 [json_name="coerceformat"];
+  int32 location = 6 [json_name="location"];
+}
+
+message ArrayCoerceExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  Node elemexpr = 3 [json_name="elemexpr"];
+  uint32 resulttype = 4 [json_name="resulttype"];
+  int32 resulttypmod = 5 [json_name="resulttypmod"];
+  uint32 resultcollid = 6 [json_name="resultcollid"];
+  CoercionForm coerceformat = 7 [json_name="coerceformat"];
+  int32 location = 8 [json_name="location"];
+}
+
+message ConvertRowtypeExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  uint32 resulttype = 3 [json_name="resulttype"];
+  CoercionForm convertformat = 4 [json_name="convertformat"];
+  int32 location = 5 [json_name="location"];
+}
+
+message CollateExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  uint32 coll_oid = 3 [json_name="collOid"];
+  int32 location = 4 [json_name="location"];
+}
+
+message CaseExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 casetype = 2 [json_name="casetype"];
+  uint32 casecollid = 3 [json_name="casecollid"];
+  Node arg = 4 [json_name="arg"];
+  repeated Node args = 5 [json_name="args"];
+  Node defresult = 6 [json_name="defresult"];
+  int32 location = 7 [json_name="location"];
+}
+
+message CaseWhen
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node expr = 2 [json_name="expr"];
+  Node result = 3 [json_name="result"];
+  int32 location = 4 [json_name="location"];
+}
+
+message CaseTestExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 type_id = 2 [json_name="typeId"];
+  int32 type_mod = 3 [json_name="typeMod"];
+  uint32 collation = 4 [json_name="collation"];
+}
+
+message ArrayExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 array_typeid = 2 [json_name="array_typeid"];
+  uint32 array_collid = 3 [json_name="array_collid"];
+  uint32 element_typeid = 4 [json_name="element_typeid"];
+  repeated Node elements = 5 [json_name="elements"];
+  bool multidims = 6 [json_name="multidims"];
+  int32 location = 7 [json_name="location"];
+}
+
+message RowExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  repeated Node args = 2 [json_name="args"];
+  uint32 row_typeid = 3 [json_name="row_typeid"];
+  CoercionForm row_format = 4 [json_name="row_format"];
+  repeated Node colnames = 5 [json_name="colnames"];
+  int32 location = 6 [json_name="location"];
+}
+
+message RowCompareExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  RowCompareType rctype = 2 [json_name="rctype"];
+  repeated Node opnos = 3 [json_name="opnos"];
+  repeated Node opfamilies = 4 [json_name="opfamilies"];
+  repeated Node inputcollids = 5 [json_name="inputcollids"];
+  repeated Node largs = 6 [json_name="largs"];
+  repeated Node rargs = 7 [json_name="rargs"];
+}
+
+message CoalesceExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 coalescetype = 2 [json_name="coalescetype"];
+  uint32 coalescecollid = 3 [json_name="coalescecollid"];
+  repeated Node args = 4 [json_name="args"];
+  int32 location = 5 [json_name="location"];
+}
+
+message MinMaxExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 minmaxtype = 2 [json_name="minmaxtype"];
+  uint32 minmaxcollid = 3 [json_name="minmaxcollid"];
+  uint32 inputcollid = 4 [json_name="inputcollid"];
+  MinMaxOp op = 5 [json_name="op"];
+  repeated Node args = 6 [json_name="args"];
+  int32 location = 7 [json_name="location"];
+}
+
+message SQLValueFunction
+{
+  Node xpr = 1 [json_name="xpr"];
+  SQLValueFunctionOp op = 2 [json_name="op"];
+  uint32 type = 3 [json_name="type"];
+  int32 typmod = 4 [json_name="typmod"];
+  int32 location = 5 [json_name="location"];
+}
+
+message XmlExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  XmlExprOp op = 2 [json_name="op"];
+  string name = 3 [json_name="name"];
+  repeated Node named_args = 4 [json_name="named_args"];
+  repeated Node arg_names = 5 [json_name="arg_names"];
+  repeated Node args = 6 [json_name="args"];
+  XmlOptionType xmloption = 7 [json_name="xmloption"];
+  uint32 type = 8 [json_name="type"];
+  int32 typmod = 9 [json_name="typmod"];
+  int32 location = 10 [json_name="location"];
+}
+
+message NullTest
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  NullTestType nulltesttype = 3 [json_name="nulltesttype"];
+  bool argisrow = 4 [json_name="argisrow"];
+  int32 location = 5 [json_name="location"];
+}
+
+message BooleanTest
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  BoolTestType booltesttype = 3 [json_name="booltesttype"];
+  int32 location = 4 [json_name="location"];
+}
+
+message CoerceToDomain
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node arg = 2 [json_name="arg"];
+  uint32 resulttype = 3 [json_name="resulttype"];
+  int32 resulttypmod = 4 [json_name="resulttypmod"];
+  uint32 resultcollid = 5 [json_name="resultcollid"];
+  CoercionForm coercionformat = 6 [json_name="coercionformat"];
+  int32 location = 7 [json_name="location"];
+}
+
+message CoerceToDomainValue
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 type_id = 2 [json_name="typeId"];
+  int32 type_mod = 3 [json_name="typeMod"];
+  uint32 collation = 4 [json_name="collation"];
+  int32 location = 5 [json_name="location"];
+}
+
+message SetToDefault
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 type_id = 2 [json_name="typeId"];
+  int32 type_mod = 3 [json_name="typeMod"];
+  uint32 collation = 4 [json_name="collation"];
+  int32 location = 5 [json_name="location"];
+}
+
+message CurrentOfExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 cvarno = 2 [json_name="cvarno"];
+  string cursor_name = 3 [json_name="cursor_name"];
+  int32 cursor_param = 4 [json_name="cursor_param"];
+}
+
+message NextValueExpr
+{
+  Node xpr = 1 [json_name="xpr"];
+  uint32 seqid = 2 [json_name="seqid"];
+  uint32 type_id = 3 [json_name="typeId"];
+}
+
+message InferenceElem
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node expr = 2 [json_name="expr"];
+  uint32 infercollid = 3 [json_name="infercollid"];
+  uint32 inferopclass = 4 [json_name="inferopclass"];
+}
+
+message TargetEntry
+{
+  Node xpr = 1 [json_name="xpr"];
+  Node expr = 2 [json_name="expr"];
+  int32 resno = 3 [json_name="resno"];
+  string resname = 4 [json_name="resname"];
+  uint32 ressortgroupref = 5 [json_name="ressortgroupref"];
+  uint32 resorigtbl = 6 [json_name="resorigtbl"];
+  int32 resorigcol = 7 [json_name="resorigcol"];
+  bool resjunk = 8 [json_name="resjunk"];
+}
+
+message RangeTblRef
+{
+  int32 rtindex = 1 [json_name="rtindex"];
+}
+
+message JoinExpr
+{
+  JoinType jointype = 1 [json_name="jointype"];
+  bool is_natural = 2 [json_name="isNatural"];
+  Node larg = 3 [json_name="larg"];
+  Node rarg = 4 [json_name="rarg"];
+  repeated Node using_clause = 5 [json_name="usingClause"];
+  Alias join_using_alias = 6 [json_name="join_using_alias"];
+  Node quals = 7 [json_name="quals"];
+  Alias alias = 8 [json_name="alias"];
+  int32 rtindex = 9 [json_name="rtindex"];
+}
+
+message FromExpr
+{
+  repeated Node fromlist = 1 [json_name="fromlist"];
+  Node quals = 2 [json_name="quals"];
+}
+
+message OnConflictExpr
+{
+  OnConflictAction action = 1 [json_name="action"];
+  repeated Node arbiter_elems = 2 [json_name="arbiterElems"];
+  Node arbiter_where = 3 [json_name="arbiterWhere"];
+  uint32 constraint = 4 [json_name="constraint"];
+  repeated Node on_conflict_set = 5 [json_name="onConflictSet"];
+  Node on_conflict_where = 6 [json_name="onConflictWhere"];
+  int32 excl_rel_index = 7 [json_name="exclRelIndex"];
+  repeated Node excl_rel_tlist = 8 [json_name="exclRelTlist"];
+}
+
+message IntoClause
+{
+  RangeVar rel = 1 [json_name="rel"];
+  repeated Node col_names = 2 [json_name="colNames"];
+  string access_method = 3 [json_name="accessMethod"];
+  repeated Node options = 4 [json_name="options"];
+  OnCommitAction on_commit = 5 [json_name="onCommit"];
+  string table_space_name = 6 [json_name="tableSpaceName"];
+  Node view_query = 7 [json_name="viewQuery"];
+  bool skip_data = 8 [json_name="skipData"];
+}
+
+message MergeAction
+{
+  bool matched = 1 [json_name="matched"];
+  CmdType command_type = 2 [json_name="commandType"];
+  OverridingKind override = 3 [json_name="override"];
+  Node qual = 4 [json_name="qual"];
+  repeated Node target_list = 5 [json_name="targetList"];
+  repeated Node update_colnos = 6 [json_name="updateColnos"];
+}
+
+message RawStmt
+{
+  Node stmt = 1 [json_name="stmt"];
+  int32 stmt_location = 2 [json_name="stmt_location"];
+  int32 stmt_len = 3 [json_name="stmt_len"];
+}
+
+message Query
+{
+  CmdType command_type = 1 [json_name="commandType"];
+  QuerySource query_source = 2 [json_name="querySource"];
+  bool can_set_tag = 3 [json_name="canSetTag"];
+  Node utility_stmt = 4 [json_name="utilityStmt"];
+  int32 result_relation = 5 [json_name="resultRelation"];
+  bool has_aggs = 6 [json_name="hasAggs"];
+  bool has_window_funcs = 7 [json_name="hasWindowFuncs"];
+  bool has_target_srfs = 8 [json_name="hasTargetSRFs"];
+  bool has_sub_links = 9 [json_name="hasSubLinks"];
+  bool has_distinct_on = 10 [json_name="hasDistinctOn"];
+  bool has_recursive = 11 [json_name="hasRecursive"];
+  bool has_modifying_cte = 12 [json_name="hasModifyingCTE"];
+  bool has_for_update = 13 [json_name="hasForUpdate"];
+  bool has_row_security = 14 [json_name="hasRowSecurity"];
+  bool is_return = 15 [json_name="isReturn"];
+  repeated Node cte_list = 16 [json_name="cteList"];
+  repeated Node rtable = 17 [json_name="rtable"];
+  FromExpr jointree = 18 [json_name="jointree"];
+  repeated Node merge_action_list = 19 [json_name="mergeActionList"];
+  bool merge_use_outer_join = 20 [json_name="mergeUseOuterJoin"];
+  repeated Node target_list = 21 [json_name="targetList"];
+  OverridingKind override = 22 [json_name="override"];
+  OnConflictExpr on_conflict = 23 [json_name="onConflict"];
+  repeated Node returning_list = 24 [json_name="returningList"];
+  repeated Node group_clause = 25 [json_name="groupClause"];
+  bool group_distinct = 26 [json_name="groupDistinct"];
+  repeated Node grouping_sets = 27 [json_name="groupingSets"];
+  Node having_qual = 28 [json_name="havingQual"];
+  repeated Node window_clause = 29 [json_name="windowClause"];
+  repeated Node distinct_clause = 30 [json_name="distinctClause"];
+  repeated Node sort_clause = 31 [json_name="sortClause"];
+  Node limit_offset = 32 [json_name="limitOffset"];
+  Node limit_count = 33 [json_name="limitCount"];
+  LimitOption limit_option = 34 [json_name="limitOption"];
+  repeated Node row_marks = 35 [json_name="rowMarks"];
+  Node set_operations = 36 [json_name="setOperations"];
+  repeated Node constraint_deps = 37 [json_name="constraintDeps"];
+  repeated Node with_check_options = 38 [json_name="withCheckOptions"];
+  int32 stmt_location = 39 [json_name="stmt_location"];
+  int32 stmt_len = 40 [json_name="stmt_len"];
+}
+
+message InsertStmt
+{
+  RangeVar relation = 1 [json_name="relation"];
+  repeated Node cols = 2 [json_name="cols"];
+  Node select_stmt = 3 [json_name="selectStmt"];
+  OnConflictClause on_conflict_clause = 4 [json_name="onConflictClause"];
+  repeated Node returning_list = 5 [json_name="returningList"];
+  WithClause with_clause = 6 [json_name="withClause"];
+  OverridingKind override = 7 [json_name="override"];
+}
+
+message DeleteStmt
+{
+  RangeVar relation = 1 [json_name="relation"];
+  repeated Node using_clause = 2 [json_name="usingClause"];
+  Node where_clause = 3 [json_name="whereClause"];
+  repeated Node returning_list = 4 [json_name="returningList"];
+  WithClause with_clause = 5 [json_name="withClause"];
+}
+
+message UpdateStmt
+{
+  RangeVar relation = 1 [json_name="relation"];
+  repeated Node target_list = 2 [json_name="targetList"];
+  Node where_clause = 3 [json_name="whereClause"];
+  repeated Node from_clause = 4 [json_name="fromClause"];
+  repeated Node returning_list = 5 [json_name="returningList"];
+  WithClause with_clause = 6 [json_name="withClause"];
+}
+
+message MergeStmt
+{
+  RangeVar relation = 1 [json_name="relation"];
+  Node source_relation = 2 [json_name="sourceRelation"];
+  Node join_condition = 3 [json_name="joinCondition"];
+  repeated Node merge_when_clauses = 4 [json_name="mergeWhenClauses"];
+  WithClause with_clause = 5 [json_name="withClause"];
+}
+
+message SelectStmt
+{
+  repeated Node distinct_clause = 1 [json_name="distinctClause"];
+  IntoClause into_clause = 2 [json_name="intoClause"];
+  repeated Node target_list = 3 [json_name="targetList"];
+  repeated Node from_clause = 4 [json_name="fromClause"];
+  Node where_clause = 5 [json_name="whereClause"];
+  repeated Node group_clause = 6 [json_name="groupClause"];
+  bool group_distinct = 7 [json_name="groupDistinct"];
+  Node having_clause = 8 [json_name="havingClause"];
+  repeated Node window_clause = 9 [json_name="windowClause"];
+  repeated Node values_lists = 10 [json_name="valuesLists"];
+  repeated Node sort_clause = 11 [json_name="sortClause"];
+  Node limit_offset = 12 [json_name="limitOffset"];
+  Node limit_count = 13 [json_name="limitCount"];
+  LimitOption limit_option = 14 [json_name="limitOption"];
+  repeated Node locking_clause = 15 [json_name="lockingClause"];
+  WithClause with_clause = 16 [json_name="withClause"];
+  SetOperation op = 17 [json_name="op"];
+  bool all = 18 [json_name="all"];
+  SelectStmt larg = 19 [json_name="larg"];
+  SelectStmt rarg = 20 [json_name="rarg"];
+}
+
+message ReturnStmt
+{
+  Node returnval = 1 [json_name="returnval"];
+}
+
+message PLAssignStmt
+{
+  string name = 1 [json_name="name"];
+  repeated Node indirection = 2 [json_name="indirection"];
+  int32 nnames = 3 [json_name="nnames"];
+  SelectStmt val = 4 [json_name="val"];
+  int32 location = 5 [json_name="location"];
+}
+
+message AlterTableStmt
+{
+  RangeVar relation = 1 [json_name="relation"];
+  repeated Node cmds = 2 [json_name="cmds"];
+  ObjectType objtype = 3 [json_name="objtype"];
+  bool missing_ok = 4 [json_name="missing_ok"];
+}
+
+message AlterTableCmd
+{
+  AlterTableType subtype = 1 [json_name="subtype"];
+  string name = 2 [json_name="name"];
+  int32 num = 3 [json_name="num"];
+  RoleSpec newowner = 4 [json_name="newowner"];
+  Node def = 5 [json_name="def"];
+  DropBehavior behavior = 6 [json_name="behavior"];
+  bool missing_ok = 7 [json_name="missing_ok"];
+  bool recurse = 8 [json_name="recurse"];
+}
+
+message AlterDomainStmt
+{
+  string subtype = 1 [json_name="subtype"];
+  repeated Node type_name = 2 [json_name="typeName"];
+  string name = 3 [json_name="name"];
+  Node def = 4 [json_name="def"];
+  DropBehavior behavior = 5 [json_name="behavior"];
+  bool missing_ok = 6 [json_name="missing_ok"];
+}
+
+message SetOperationStmt
+{
+  SetOperation op = 1 [json_name="op"];
+  bool all = 2 [json_name="all"];
+  Node larg = 3 [json_name="larg"];
+  Node rarg = 4 [json_name="rarg"];
+  repeated Node col_types = 5 [json_name="colTypes"];
+  repeated Node col_typmods = 6 [json_name="colTypmods"];
+  repeated Node col_collations = 7 [json_name="colCollations"];
+  repeated Node group_clauses = 8 [json_name="groupClauses"];
+}
+
+message GrantStmt
+{
+  bool is_grant = 1 [json_name="is_grant"];
+  GrantTargetType targtype = 2 [json_name="targtype"];
+  ObjectType objtype = 3 [json_name="objtype"];
+  repeated Node objects = 4 [json_name="objects"];
+  repeated Node privileges = 5 [json_name="privileges"];
+  repeated Node grantees = 6 [json_name="grantees"];
+  bool grant_option = 7 [json_name="grant_option"];
+  RoleSpec grantor = 8 [json_name="grantor"];
+  DropBehavior behavior = 9 [json_name="behavior"];
+}
+
+message GrantRoleStmt
+{
+  repeated Node granted_roles = 1 [json_name="granted_roles"];
+  repeated Node grantee_roles = 2 [json_name="grantee_roles"];
+  bool is_grant = 3 [json_name="is_grant"];
+  bool admin_opt = 4 [json_name="admin_opt"];
+  RoleSpec grantor = 5 [json_name="grantor"];
+  DropBehavior behavior = 6 [json_name="behavior"];
+}
+
+message AlterDefaultPrivilegesStmt
+{
+  repeated Node options = 1 [json_name="options"];
+  GrantStmt action = 2 [json_name="action"];
+}
+
+message ClosePortalStmt
+{
+  string portalname = 1 [json_name="portalname"];
+}
+
+message ClusterStmt
+{
+  RangeVar relation = 1 [json_name="relation"];
+  string indexname = 2 [json_name="indexname"];
+  repeated Node params = 3 [json_name="params"];
+}
+
+message CopyStmt
+{
+  RangeVar relation = 1 [json_name="relation"];
+  Node query = 2 [json_name="query"];
+  repeated Node attlist = 3 [json_name="attlist"];
+  bool is_from = 4 [json_name="is_from"];
+  bool is_program = 5 [json_name="is_program"];
+  string filename = 6 [json_name="filename"];
+  repeated Node options = 7 [json_name="options"];
+  Node where_clause = 8 [json_name="whereClause"];
+}
+
+message CreateStmt
+{
+  RangeVar relation = 1 [json_name="relation"];
+  repeated Node table_elts = 2 [json_name="tableElts"];
+  repeated Node inh_relations = 3 [json_name="inhRelations"];
+  PartitionBoundSpec partbound = 4 [json_name="partbound"];
+  PartitionSpec partspec = 5 [json_name="partspec"];
+  TypeName of_typename = 6 [json_name="ofTypename"];
+  repeated Node constraints = 7 [json_name="constraints"];
+  repeated Node options = 8 [json_name="options"];
+  OnCommitAction oncommit = 9 [json_name="oncommit"];
+  string tablespacename = 10 [json_name="tablespacename"];
+  string access_method = 11 [json_name="accessMethod"];
+  bool if_not_exists = 12 [json_name="if_not_exists"];
+}
+
+message DefineStmt
+{
+  ObjectType kind = 1 [json_name="kind"];
+  bool oldstyle = 2 [json_name="oldstyle"];
+  repeated Node defnames = 3 [json_name="defnames"];
+  repeated Node args = 4 [json_name="args"];
+  repeated Node definition = 5 [json_name="definition"];
+  bool if_not_exists = 6 [json_name="if_not_exists"];
+  bool replace = 7 [json_name="replace"];
+}
+
+message DropStmt
+{
+  repeated Node objects = 1 [json_name="objects"];
+  ObjectType remove_type = 2 [json_name="removeType"];
+  DropBehavior behavior = 3 [json_name="behavior"];
+  bool missing_ok = 4 [json_name="missing_ok"];
+  bool concurrent = 5 [json_name="concurrent"];
+}
+
+message TruncateStmt
+{
+  repeated Node relations = 1 [json_name="relations"];
+  bool restart_seqs = 2 [json_name="restart_seqs"];
+  DropBehavior behavior = 3 [json_name="behavior"];
+}
+
+message CommentStmt
+{
+  ObjectType objtype = 1 [json_name="objtype"];
+  Node object = 2 [json_name="object"];
+  string comment = 3 [json_name="comment"];
+}
+
+message FetchStmt
+{
+  FetchDirection direction = 1 [json_name="direction"];
+  int64 how_many = 2 [json_name="howMany"];
+  string portalname = 3 [json_name="portalname"];
+  bool ismove = 4 [json_name="ismove"];
+}
+
+message IndexStmt
+{
+  string idxname = 1 [json_name="idxname"];
+  RangeVar relation = 2 [json_name="relation"];
+  string access_method = 3 [json_name="accessMethod"];
+  string table_space = 4 [json_name="tableSpace"];
+  repeated Node index_params = 5 [json_name="indexParams"];
+  repeated Node index_including_params = 6 [json_name="indexIncludingParams"];
+  repeated Node options = 7 [json_name="options"];
+  Node where_clause = 8 [json_name="whereClause"];
+  repeated Node exclude_op_names = 9 [json_name="excludeOpNames"];
+  string idxcomment = 10 [json_name="idxcomment"];
+  uint32 index_oid = 11 [json_name="indexOid"];
+  uint32 old_node = 12 [json_name="oldNode"];
+  uint32 old_create_subid = 13 [json_name="oldCreateSubid"];
+  uint32 old_first_relfilenode_subid = 14 [json_name="oldFirstRelfilenodeSubid"];
+  bool unique = 15 [json_name="unique"];
+  bool nulls_not_distinct = 16 [json_name="nulls_not_distinct"];
+  bool primary = 17 [json_name="primary"];
+  bool isconstraint = 18 [json_name="isconstraint"];
+  bool deferrable = 19 [json_name="deferrable"];
+  bool initdeferred = 20 [json_name="initdeferred"];
+  bool transformed = 21 [json_name="transformed"];
+  bool concurrent = 22 [json_name="concurrent"];
+  bool if_not_exists = 23 [json_name="if_not_exists"];
+  bool reset_default_tblspc = 24 [json_name="reset_default_tblspc"];
+}
+
+message CreateFunctionStmt
+{
+  bool is_procedure = 1 [json_name="is_procedure"];
+  bool replace = 2 [json_name="replace"];
+  repeated Node funcname = 3 [json_name="funcname"];
+  repeated Node parameters = 4 [json_name="parameters"];
+  TypeName return_type = 5 [json_name="returnType"];
+  repeated Node options = 6 [json_name="options"];
+  Node sql_body = 7 [json_name="sql_body"];
+}
+
+message AlterFunctionStmt
+{
+  ObjectType objtype = 1 [json_name="objtype"];
+  ObjectWithArgs func = 2 [json_name="func"];
+  repeated Node actions = 3 [json_name="actions"];
+}
+
+message DoStmt
+{
+  repeated Node args = 1 [json_name="args"];
+}
+
+message RenameStmt
+{
+  ObjectType rename_type = 1 [json_name="renameType"];
+  ObjectType relation_type = 2 [json_name="relationType"];
+  RangeVar relation = 3 [json_name="relation"];
+  Node object = 4 [json_name="object"];
+  string subname = 5 [json_name="subname"];
+  string newname = 6 [json_name="newname"];
+  DropBehavior behavior = 7 [json_name="behavior"];
+  bool missing_ok = 8 [json_name="missing_ok"];
+}
+
+message RuleStmt
+{
+  RangeVar relation = 1 [json_name="relation"];
+  string rulename = 2 [json_name="rulename"];
+  Node where_clause = 3 [json_name="whereClause"];
+  CmdType event = 4 [json_name="event"];
+  bool instead = 5 [json_name="instead"];
+  repeated Node actions = 6 [json_name="actions"];
+  bool replace = 7 [json_name="replace"];
+}
+
+message NotifyStmt
+{
+  string conditionname = 1 [json_name="conditionname"];
+  string payload = 2 [json_name="payload"];
+}
+
+message ListenStmt
+{
+  string conditionname = 1 [json_name="conditionname"];
+}
+
+message UnlistenStmt
+{
+  string conditionname = 1 [json_name="conditionname"];
+}
+
+message TransactionStmt
+{
+  TransactionStmtKind kind = 1 [json_name="kind"];
+  repeated Node options = 2 [json_name="options"];
+  string savepoint_name = 3 [json_name="savepoint_name"];
+  string gid = 4 [json_name="gid"];
+  bool chain = 5 [json_name="chain"];
+}
+
+message ViewStmt
+{
+  RangeVar view = 1 [json_name="view"];
+  repeated Node aliases = 2 [json_name="aliases"];
+  Node query = 3 [json_name="query"];
+  bool replace = 4 [json_name="replace"];
+  repeated Node options = 5 [json_name="options"];
+  ViewCheckOption with_check_option = 6 [json_name="withCheckOption"];
+}
+
+message LoadStmt
+{
+  string filename = 1 [json_name="filename"];
+}
+
+message CreateDomainStmt
+{
+  repeated Node domainname = 1 [json_name="domainname"];
+  TypeName type_name = 2 [json_name="typeName"];
+  CollateClause coll_clause = 3 [json_name="collClause"];
+  repeated Node constraints = 4 [json_name="constraints"];
+}
+
+message CreatedbStmt
+{
+  string dbname = 1 [json_name="dbname"];
+  repeated Node options = 2 [json_name="options"];
+}
+
+message DropdbStmt
+{
+  string dbname = 1 [json_name="dbname"];
+  bool missing_ok = 2 [json_name="missing_ok"];
+  repeated Node options = 3 [json_name="options"];
+}
+
+message VacuumStmt
+{
+  repeated Node options = 1 [json_name="options"];
+  repeated Node rels = 2 [json_name="rels"];
+  bool is_vacuumcmd = 3 [json_name="is_vacuumcmd"];
+}
+
+message ExplainStmt
+{
+  Node query = 1 [json_name="query"];
+  repeated Node options = 2 [json_name="options"];
+}
+
+message CreateTableAsStmt
+{
+  Node query = 1 [json_name="query"];
+  IntoClause into = 2 [json_name="into"];
+  ObjectType objtype = 3 [json_name="objtype"];
+  bool is_select_into = 4 [json_name="is_select_into"];
+  bool if_not_exists = 5 [json_name="if_not_exists"];
+}
+
+message CreateSeqStmt
+{
+  RangeVar sequence = 1 [json_name="sequence"];
+  repeated Node options = 2 [json_name="options"];
+  uint32 owner_id = 3 [json_name="ownerId"];
+  bool for_identity = 4 [json_name="for_identity"];
+  bool if_not_exists = 5 [json_name="if_not_exists"];
+}
+
+message AlterSeqStmt
+{
+  RangeVar sequence = 1 [json_name="sequence"];
+  repeated Node options = 2 [json_name="options"];
+  bool for_identity = 3 [json_name="for_identity"];
+  bool missing_ok = 4 [json_name="missing_ok"];
+}
+
+message VariableSetStmt
+{
+  VariableSetKind kind = 1 [json_name="kind"];
+  string name = 2 [json_name="name"];
+  repeated Node args = 3 [json_name="args"];
+  bool is_local = 4 [json_name="is_local"];
+}
+
+message VariableShowStmt
+{
+  string name = 1 [json_name="name"];
+}
+
+message DiscardStmt
+{
+  DiscardMode target = 1 [json_name="target"];
+}
+
+message CreateTrigStmt
+{
+  bool replace = 1 [json_name="replace"];
+  bool isconstraint = 2 [json_name="isconstraint"];
+  string trigname = 3 [json_name="trigname"];
+  RangeVar relation = 4 [json_name="relation"];
+  repeated Node funcname = 5 [json_name="funcname"];
+  repeated Node args = 6 [json_name="args"];
+  bool row = 7 [json_name="row"];
+  int32 timing = 8 [json_name="timing"];
+  int32 events = 9 [json_name="events"];
+  repeated Node columns = 10 [json_name="columns"];
+  Node when_clause = 11 [json_name="whenClause"];
+  repeated Node transition_rels = 12 [json_name="transitionRels"];
+  bool deferrable = 13 [json_name="deferrable"];
+  bool initdeferred = 14 [json_name="initdeferred"];
+  RangeVar constrrel = 15 [json_name="constrrel"];
+}
+
+message CreatePLangStmt
+{
+  bool replace = 1 [json_name="replace"];
+  string plname = 2 [json_name="plname"];
+  repeated Node plhandler = 3 [json_name="plhandler"];
+  repeated Node plinline = 4 [json_name="plinline"];
+  repeated Node plvalidator = 5 [json_name="plvalidator"];
+  bool pltrusted = 6 [json_name="pltrusted"];
+}
+
+message CreateRoleStmt
+{
+  RoleStmtType stmt_type = 1 [json_name="stmt_type"];
+  string role = 2 [json_name="role"];
+  repeated Node options = 3 [json_name="options"];
+}
+
+message AlterRoleStmt
+{
+  RoleSpec role = 1 [json_name="role"];
+  repeated Node options = 2 [json_name="options"];
+  int32 action = 3 [json_name="action"];
+}
+
+message DropRoleStmt
+{
+  repeated Node roles = 1 [json_name="roles"];
+  bool missing_ok = 2 [json_name="missing_ok"];
+}
+
+message LockStmt
+{
+  repeated Node relations = 1 [json_name="relations"];
+  int32 mode = 2 [json_name="mode"];
+  bool nowait = 3 [json_name="nowait"];
+}
+
+message ConstraintsSetStmt
+{
+  repeated Node constraints = 1 [json_name="constraints"];
+  bool deferred = 2 [json_name="deferred"];
+}
+
+message ReindexStmt
+{
+  ReindexObjectType kind = 1 [json_name="kind"];
+  RangeVar relation = 2 [json_name="relation"];
+  string name = 3 [json_name="name"];
+  repeated Node params = 4 [json_name="params"];
+}
+
+message CheckPointStmt
+{
+}
+
+message CreateSchemaStmt
+{
+  string schemaname = 1 [json_name="schemaname"];
+  RoleSpec authrole = 2 [json_name="authrole"];
+  repeated Node schema_elts = 3 [json_name="schemaElts"];
+  bool if_not_exists = 4 [json_name="if_not_exists"];
+}
+
+message AlterDatabaseStmt
+{
+  string dbname = 1 [json_name="dbname"];
+  repeated Node options = 2 [json_name="options"];
+}
+
+message AlterDatabaseRefreshCollStmt
+{
+  string dbname = 1 [json_name="dbname"];
+}
+
+message AlterDatabaseSetStmt
+{
+  string dbname = 1 [json_name="dbname"];
+  VariableSetStmt setstmt = 2 [json_name="setstmt"];
+}
+
+message AlterRoleSetStmt
+{
+  RoleSpec role = 1 [json_name="role"];
+  string database = 2 [json_name="database"];
+  VariableSetStmt setstmt = 3 [json_name="setstmt"];
+}
+
+message CreateConversionStmt
+{
+  repeated Node conversion_name = 1 [json_name="conversion_name"];
+  string for_encoding_name = 2 [json_name="for_encoding_name"];
+  string to_encoding_name = 3 [json_name="to_encoding_name"];
+  repeated Node func_name = 4 [json_name="func_name"];
+  bool def = 5 [json_name="def"];
+}
+
+message CreateCastStmt
+{
+  TypeName sourcetype = 1 [json_name="sourcetype"];
+  TypeName targettype = 2 [json_name="targettype"];
+  ObjectWithArgs func = 3 [json_name="func"];
+  CoercionContext context = 4 [json_name="context"];
+  bool inout = 5 [json_name="inout"];
+}
+
+message CreateOpClassStmt
+{
+  repeated Node opclassname = 1 [json_name="opclassname"];
+  repeated Node opfamilyname = 2 [json_name="opfamilyname"];
+  string amname = 3 [json_name="amname"];
+  TypeName datatype = 4 [json_name="datatype"];
+  repeated Node items = 5 [json_name="items"];
+  bool is_default = 6 [json_name="isDefault"];
+}
+
+message CreateOpFamilyStmt
+{
+  repeated Node opfamilyname = 1 [json_name="opfamilyname"];
+  string amname = 2 [json_name="amname"];
+}
+
+message AlterOpFamilyStmt
+{
+  repeated Node opfamilyname = 1 [json_name="opfamilyname"];
+  string amname = 2 [json_name="amname"];
+  bool is_drop = 3 [json_name="isDrop"];
+  repeated Node items = 4 [json_name="items"];
+}
+
+message PrepareStmt
+{
+  string name = 1 [json_name="name"];
+  repeated Node argtypes = 2 [json_name="argtypes"];
+  Node query = 3 [json_name="query"];
+}
+
+message ExecuteStmt
+{
+  string name = 1 [json_name="name"];
+  repeated Node params = 2 [json_name="params"];
+}
+
+message DeallocateStmt
+{
+  string name = 1 [json_name="name"];
+}
+
+message DeclareCursorStmt
+{
+  string portalname = 1 [json_name="portalname"];
+  int32 options = 2 [json_name="options"];
+  Node query = 3 [json_name="query"];
+}
+
+message CreateTableSpaceStmt
+{
+  string tablespacename = 1 [json_name="tablespacename"];
+  RoleSpec owner = 2 [json_name="owner"];
+  string location = 3 [json_name="location"];
+  repeated Node options = 4 [json_name="options"];
+}
+
+message DropTableSpaceStmt
+{
+  string tablespacename = 1 [json_name="tablespacename"];
+  bool missing_ok = 2 [json_name="missing_ok"];
+}
+
+message AlterObjectDependsStmt
+{
+  ObjectType object_type = 1 [json_name="objectType"];
+  RangeVar relation = 2 [json_name="relation"];
+  Node object = 3 [json_name="object"];
+  String extname = 4 [json_name="extname"];
+  bool remove = 5 [json_name="remove"];
+}
+
+message AlterObjectSchemaStmt
+{
+  ObjectType object_type = 1 [json_name="objectType"];
+  RangeVar relation = 2 [json_name="relation"];
+  Node object = 3 [json_name="object"];
+  string newschema = 4 [json_name="newschema"];
+  bool missing_ok = 5 [json_name="missing_ok"];
+}
+
+message AlterOwnerStmt
+{
+  ObjectType object_type = 1 [json_name="objectType"];
+  RangeVar relation = 2 [json_name="relation"];
+  Node object = 3 [json_name="object"];
+  RoleSpec newowner = 4 [json_name="newowner"];
+}
+
+message AlterOperatorStmt
+{
+  ObjectWithArgs opername = 1 [json_name="opername"];
+  repeated Node options = 2 [json_name="options"];
+}
+
+message AlterTypeStmt
+{
+  repeated Node type_name = 1 [json_name="typeName"];
+  repeated Node options = 2 [json_name="options"];
+}
+
+message DropOwnedStmt
+{
+  repeated Node roles = 1 [json_name="roles"];
+  DropBehavior behavior = 2 [json_name="behavior"];
+}
+
+message ReassignOwnedStmt
+{
+  repeated Node roles = 1 [json_name="roles"];
+  RoleSpec newrole = 2 [json_name="newrole"];
+}
+
+message CompositeTypeStmt
+{
+  RangeVar typevar = 1 [json_name="typevar"];
+  repeated Node coldeflist = 2 [json_name="coldeflist"];
+}
+
+message CreateEnumStmt
+{
+  repeated Node type_name = 1 [json_name="typeName"];
+  repeated Node vals = 2 [json_name="vals"];
+}
+
+message CreateRangeStmt
+{
+  repeated Node type_name = 1 [json_name="typeName"];
+  repeated Node params = 2 [json_name="params"];
+}
+
+message AlterEnumStmt
+{
+  repeated Node type_name = 1 [json_name="typeName"];
+  string old_val = 2 [json_name="oldVal"];
+  string new_val = 3 [json_name="newVal"];
+  string new_val_neighbor = 4 [json_name="newValNeighbor"];
+  bool new_val_is_after = 5 [json_name="newValIsAfter"];
+  bool skip_if_new_val_exists = 6 [json_name="skipIfNewValExists"];
+}
+
+message AlterTSDictionaryStmt
+{
+  repeated Node dictname = 1 [json_name="dictname"];
+  repeated Node options = 2 [json_name="options"];
+}
+
+message AlterTSConfigurationStmt
+{
+  AlterTSConfigType kind = 1 [json_name="kind"];
+  repeated Node cfgname = 2 [json_name="cfgname"];
+  repeated Node tokentype = 3 [json_name="tokentype"];
+  repeated Node dicts = 4 [json_name="dicts"];
+  bool override = 5 [json_name="override"];
+  bool replace = 6 [json_name="replace"];
+  bool missing_ok = 7 [json_name="missing_ok"];
+}
+
+message CreateFdwStmt
+{
+  string fdwname = 1 [json_name="fdwname"];
+  repeated Node func_options = 2 [json_name="func_options"];
+  repeated Node options = 3 [json_name="options"];
+}
+
+message AlterFdwStmt
+{
+  string fdwname = 1 [json_name="fdwname"];
+  repeated Node func_options = 2 [json_name="func_options"];
+  repeated Node options = 3 [json_name="options"];
+}
+
+message CreateForeignServerStmt
+{
+  string servername = 1 [json_name="servername"];
+  string servertype = 2 [json_name="servertype"];
+  string version = 3 [json_name="version"];
+  string fdwname = 4 [json_name="fdwname"];
+  bool if_not_exists = 5 [json_name="if_not_exists"];
+  repeated Node options = 6 [json_name="options"];
+}
+
+message AlterForeignServerStmt
+{
+  string servername = 1 [json_name="servername"];
+  string version = 2 [json_name="version"];
+  repeated Node options = 3 [json_name="options"];
+  bool has_version = 4 [json_name="has_version"];
+}
+
+message CreateUserMappingStmt
+{
+  RoleSpec user = 1 [json_name="user"];
+  string servername = 2 [json_name="servername"];
+  bool if_not_exists = 3 [json_name="if_not_exists"];
+  repeated Node options = 4 [json_name="options"];
+}
+
+message AlterUserMappingStmt
+{
+  RoleSpec user = 1 [json_name="user"];
+  string servername = 2 [json_name="servername"];
+  repeated Node options = 3 [json_name="options"];
+}
+
+message DropUserMappingStmt
+{
+  RoleSpec user = 1 [json_name="user"];
+  string servername = 2 [json_name="servername"];
+  bool missing_ok = 3 [json_name="missing_ok"];
+}
+
+message AlterTableSpaceOptionsStmt
+{
+  string tablespacename = 1 [json_name="tablespacename"];
+  repeated Node options = 2 [json_name="options"];
+  bool is_reset = 3 [json_name="isReset"];
+}
+
+message AlterTableMoveAllStmt
+{
+  string orig_tablespacename = 1 [json_name="orig_tablespacename"];
+  ObjectType objtype = 2 [json_name="objtype"];
+  repeated Node roles = 3 [json_name="roles"];
+  string new_tablespacename = 4 [json_name="new_tablespacename"];
+  bool nowait = 5 [json_name="nowait"];
+}
+
+message SecLabelStmt
+{
+  ObjectType objtype = 1 [json_name="objtype"];
+  Node object = 2 [json_name="object"];
+  string provider = 3 [json_name="provider"];
+  string label = 4 [json_name="label"];
+}
+
+message CreateForeignTableStmt
+{
+  CreateStmt base_stmt = 1 [json_name="base"];
+  string servername = 2 [json_name="servername"];
+  repeated Node options = 3 [json_name="options"];
+}
+
+message ImportForeignSchemaStmt
+{
+  string server_name = 1 [json_name="server_name"];
+  string remote_schema = 2 [json_name="remote_schema"];
+  string local_schema = 3 [json_name="local_schema"];
+  ImportForeignSchemaType list_type = 4 [json_name="list_type"];
+  repeated Node table_list = 5 [json_name="table_list"];
+  repeated Node options = 6 [json_name="options"];
+}
+
+message CreateExtensionStmt
+{
+  string extname = 1 [json_name="extname"];
+  bool if_not_exists = 2 [json_name="if_not_exists"];
+  repeated Node options = 3 [json_name="options"];
+}
+
+message AlterExtensionStmt
+{
+  string extname = 1 [json_name="extname"];
+  repeated Node options = 2 [json_name="options"];
+}
+
+message AlterExtensionContentsStmt
+{
+  string extname = 1 [json_name="extname"];
+  int32 action = 2 [json_name="action"];
+  ObjectType objtype = 3 [json_name="objtype"];
+  Node object = 4 [json_name="object"];
+}
+
+message CreateEventTrigStmt
+{
+  string trigname = 1 [json_name="trigname"];
+  string eventname = 2 [json_name="eventname"];
+  repeated Node whenclause = 3 [json_name="whenclause"];
+  repeated Node funcname = 4 [json_name="funcname"];
+}
+
+message AlterEventTrigStmt
+{
+  string trigname = 1 [json_name="trigname"];
+  string tgenabled = 2 [json_name="tgenabled"];
+}
+
+message RefreshMatViewStmt
+{
+  bool concurrent = 1 [json_name="concurrent"];
+  bool skip_data = 2 [json_name="skipData"];
+  RangeVar relation = 3 [json_name="relation"];
+}
+
+message ReplicaIdentityStmt
+{
+  string identity_type = 1 [json_name="identity_type"];
+  string name = 2 [json_name="name"];
+}
+
+message AlterSystemStmt
+{
+  VariableSetStmt setstmt = 1 [json_name="setstmt"];
+}
+
+message CreatePolicyStmt
+{
+  string policy_name = 1 [json_name="policy_name"];
+  RangeVar table = 2 [json_name="table"];
+  string cmd_name = 3 [json_name="cmd_name"];
+  bool permissive = 4 [json_name="permissive"];
+  repeated Node roles = 5 [json_name="roles"];
+  Node qual = 6 [json_name="qual"];
+  Node with_check = 7 [json_name="with_check"];
+}
+
+message AlterPolicyStmt
+{
+  string policy_name = 1 [json_name="policy_name"];
+  RangeVar table = 2 [json_name="table"];
+  repeated Node roles = 3 [json_name="roles"];
+  Node qual = 4 [json_name="qual"];
+  Node with_check = 5 [json_name="with_check"];
+}
+
+message CreateTransformStmt
+{
+  bool replace = 1 [json_name="replace"];
+  TypeName type_name = 2 [json_name="type_name"];
+  string lang = 3 [json_name="lang"];
+  ObjectWithArgs fromsql = 4 [json_name="fromsql"];
+  ObjectWithArgs tosql = 5 [json_name="tosql"];
+}
+
+message CreateAmStmt
+{
+  string amname = 1 [json_name="amname"];
+  repeated Node handler_name = 2 [json_name="handler_name"];
+  string amtype = 3 [json_name="amtype"];
+}
+
+message CreatePublicationStmt
+{
+  string pubname = 1 [json_name="pubname"];
+  repeated Node options = 2 [json_name="options"];
+  repeated Node pubobjects = 3 [json_name="pubobjects"];
+  bool for_all_tables = 4 [json_name="for_all_tables"];
+}
+
+message AlterPublicationStmt
+{
+  string pubname = 1 [json_name="pubname"];
+  repeated Node options = 2 [json_name="options"];
+  repeated Node pubobjects = 3 [json_name="pubobjects"];
+  bool for_all_tables = 4 [json_name="for_all_tables"];
+  AlterPublicationAction action = 5 [json_name="action"];
+}
+
+message CreateSubscriptionStmt
+{
+  string subname = 1 [json_name="subname"];
+  string conninfo = 2 [json_name="conninfo"];
+  repeated Node publication = 3 [json_name="publication"];
+  repeated Node options = 4 [json_name="options"];
+}
+
+message AlterSubscriptionStmt
+{
+  AlterSubscriptionType kind = 1 [json_name="kind"];
+  string subname = 2 [json_name="subname"];
+  string conninfo = 3 [json_name="conninfo"];
+  repeated Node publication = 4 [json_name="publication"];
+  repeated Node options = 5 [json_name="options"];
+}
+
+message DropSubscriptionStmt
+{
+  string subname = 1 [json_name="subname"];
+  bool missing_ok = 2 [json_name="missing_ok"];
+  DropBehavior behavior = 3 [json_name="behavior"];
+}
+
+message CreateStatsStmt
+{
+  repeated Node defnames = 1 [json_name="defnames"];
+  repeated Node stat_types = 2 [json_name="stat_types"];
+  repeated Node exprs = 3 [json_name="exprs"];
+  repeated Node relations = 4 [json_name="relations"];
+  string stxcomment = 5 [json_name="stxcomment"];
+  bool transformed = 6 [json_name="transformed"];
+  bool if_not_exists = 7 [json_name="if_not_exists"];
+}
+
+message AlterCollationStmt
+{
+  repeated Node collname = 1 [json_name="collname"];
+}
+
+message CallStmt
+{
+  FuncCall funccall = 1 [json_name="funccall"];
+  FuncExpr funcexpr = 2 [json_name="funcexpr"];
+  repeated Node outargs = 3 [json_name="outargs"];
+}
+
+message AlterStatsStmt
+{
+  repeated Node defnames = 1 [json_name="defnames"];
+  int32 stxstattarget = 2 [json_name="stxstattarget"];
+  bool missing_ok = 3 [json_name="missing_ok"];
+}
+
+message A_Expr
+{
+  A_Expr_Kind kind = 1 [json_name="kind"];
+  repeated Node name = 2 [json_name="name"];
+  Node lexpr = 3 [json_name="lexpr"];
+  Node rexpr = 4 [json_name="rexpr"];
+  int32 location = 5 [json_name="location"];
+}
+
+message ColumnRef
+{
+  repeated Node fields = 1 [json_name="fields"];
+  int32 location = 2 [json_name="location"];
+}
+
+message ParamRef
+{
+  int32 number = 1 [json_name="number"];
+  int32 location = 2 [json_name="location"];
+}
+
+message FuncCall
+{
+  repeated Node funcname = 1 [json_name="funcname"];
+  repeated Node args = 2 [json_name="args"];
+  repeated Node agg_order = 3 [json_name="agg_order"];
+  Node agg_filter = 4 [json_name="agg_filter"];
+  WindowDef over = 5 [json_name="over"];
+  bool agg_within_group = 6 [json_name="agg_within_group"];
+  bool agg_star = 7 [json_name="agg_star"];
+  bool agg_distinct = 8 [json_name="agg_distinct"];
+  bool func_variadic = 9 [json_name="func_variadic"];
+  CoercionForm funcformat = 10 [json_name="funcformat"];
+  int32 location = 11 [json_name="location"];
+}
+
+message A_Star
+{
+}
+
+message A_Indices
+{
+  bool is_slice = 1 [json_name="is_slice"];
+  Node lidx = 2 [json_name="lidx"];
+  Node uidx = 3 [json_name="uidx"];
+}
+
+message A_Indirection
+{
+  Node arg = 1 [json_name="arg"];
+  repeated Node indirection = 2 [json_name="indirection"];
+}
+
+message A_ArrayExpr
+{
+  repeated Node elements = 1 [json_name="elements"];
+  int32 location = 2 [json_name="location"];
+}
+
+message ResTarget
+{
+  string name = 1 [json_name="name"];
+  repeated Node indirection = 2 [json_name="indirection"];
+  Node val = 3 [json_name="val"];
+  int32 location = 4 [json_name="location"];
+}
+
+message MultiAssignRef
+{
+  Node source = 1 [json_name="source"];
+  int32 colno = 2 [json_name="colno"];
+  int32 ncolumns = 3 [json_name="ncolumns"];
+}
+
+message TypeCast
+{
+  Node arg = 1 [json_name="arg"];
+  TypeName type_name = 2 [json_name="typeName"];
+  int32 location = 3 [json_name="location"];
+}
+
+message CollateClause
+{
+  Node arg = 1 [json_name="arg"];
+  repeated Node collname = 2 [json_name="collname"];
+  int32 location = 3 [json_name="location"];
+}
+
+message SortBy
+{
+  Node node = 1 [json_name="node"];
+  SortByDir sortby_dir = 2 [json_name="sortby_dir"];
+  SortByNulls sortby_nulls = 3 [json_name="sortby_nulls"];
+  repeated Node use_op = 4 [json_name="useOp"];
+  int32 location = 5 [json_name="location"];
+}
+
+message WindowDef
+{
+  string name = 1 [json_name="name"];
+  string refname = 2 [json_name="refname"];
+  repeated Node partition_clause = 3 [json_name="partitionClause"];
+  repeated Node order_clause = 4 [json_name="orderClause"];
+  int32 frame_options = 5 [json_name="frameOptions"];
+  Node start_offset = 6 [json_name="startOffset"];
+  Node end_offset = 7 [json_name="endOffset"];
+  int32 location = 8 [json_name="location"];
+}
+
+message RangeSubselect
+{
+  bool lateral = 1 [json_name="lateral"];
+  Node subquery = 2 [json_name="subquery"];
+  Alias alias = 3 [json_name="alias"];
+}
+
+message RangeFunction
+{
+  bool lateral = 1 [json_name="lateral"];
+  bool ordinality = 2 [json_name="ordinality"];
+  bool is_rowsfrom = 3 [json_name="is_rowsfrom"];
+  repeated Node functions = 4 [json_name="functions"];
+  Alias alias = 5 [json_name="alias"];
+  repeated Node coldeflist = 6 [json_name="coldeflist"];
+}
+
+message RangeTableSample
+{
+  Node relation = 1 [json_name="relation"];
+  repeated Node method = 2 [json_name="method"];
+  repeated Node args = 3 [json_name="args"];
+  Node repeatable = 4 [json_name="repeatable"];
+  int32 location = 5 [json_name="location"];
+}
+
+message RangeTableFunc
+{
+  bool lateral = 1 [json_name="lateral"];
+  Node docexpr = 2 [json_name="docexpr"];
+  Node rowexpr = 3 [json_name="rowexpr"];
+  repeated Node namespaces = 4 [json_name="namespaces"];
+  repeated Node columns = 5 [json_name="columns"];
+  Alias alias = 6 [json_name="alias"];
+  int32 location = 7 [json_name="location"];
+}
+
+message RangeTableFuncCol
+{
+  string colname = 1 [json_name="colname"];
+  TypeName type_name = 2 [json_name="typeName"];
+  bool for_ordinality = 3 [json_name="for_ordinality"];
+  bool is_not_null = 4 [json_name="is_not_null"];
+  Node colexpr = 5 [json_name="colexpr"];
+  Node coldefexpr = 6 [json_name="coldefexpr"];
+  int32 location = 7 [json_name="location"];
+}
+
+message TypeName
+{
+  repeated Node names = 1 [json_name="names"];
+  uint32 type_oid = 2 [json_name="typeOid"];
+  bool setof = 3 [json_name="setof"];
+  bool pct_type = 4 [json_name="pct_type"];
+  repeated Node typmods = 5 [json_name="typmods"];
+  int32 typemod = 6 [json_name="typemod"];
+  repeated Node array_bounds = 7 [json_name="arrayBounds"];
+  int32 location = 8 [json_name="location"];
+}
+
+message ColumnDef
+{
+  string colname = 1 [json_name="colname"];
+  TypeName type_name = 2 [json_name="typeName"];
+  string compression = 3 [json_name="compression"];
+  int32 inhcount = 4 [json_name="inhcount"];
+  bool is_local = 5 [json_name="is_local"];
+  bool is_not_null = 6 [json_name="is_not_null"];
+  bool is_from_type = 7 [json_name="is_from_type"];
+  string storage = 8 [json_name="storage"];
+  Node raw_default = 9 [json_name="raw_default"];
+  Node cooked_default = 10 [json_name="cooked_default"];
+  string identity = 11 [json_name="identity"];
+  RangeVar identity_sequence = 12 [json_name="identitySequence"];
+  string generated = 13 [json_name="generated"];
+  CollateClause coll_clause = 14 [json_name="collClause"];
+  uint32 coll_oid = 15 [json_name="collOid"];
+  repeated Node constraints = 16 [json_name="constraints"];
+  repeated Node fdwoptions = 17 [json_name="fdwoptions"];
+  int32 location = 18 [json_name="location"];
+}
+
+message IndexElem
+{
+  string name = 1 [json_name="name"];
+  Node expr = 2 [json_name="expr"];
+  string indexcolname = 3 [json_name="indexcolname"];
+  repeated Node collation = 4 [json_name="collation"];
+  repeated Node opclass = 5 [json_name="opclass"];
+  repeated Node opclassopts = 6 [json_name="opclassopts"];
+  SortByDir ordering = 7 [json_name="ordering"];
+  SortByNulls nulls_ordering = 8 [json_name="nulls_ordering"];
+}
+
+message StatsElem
+{
+  string name = 1 [json_name="name"];
+  Node expr = 2 [json_name="expr"];
+}
+
+message Constraint
+{
+  ConstrType contype = 1 [json_name="contype"];
+  string conname = 2 [json_name="conname"];
+  bool deferrable = 3 [json_name="deferrable"];
+  bool initdeferred = 4 [json_name="initdeferred"];
+  int32 location = 5 [json_name="location"];
+  bool is_no_inherit = 6 [json_name="is_no_inherit"];
+  Node raw_expr = 7 [json_name="raw_expr"];
+  string cooked_expr = 8 [json_name="cooked_expr"];
+  string generated_when = 9 [json_name="generated_when"];
+  bool nulls_not_distinct = 10 [json_name="nulls_not_distinct"];
+  repeated Node keys = 11 [json_name="keys"];
+  repeated Node including = 12 [json_name="including"];
+  repeated Node exclusions = 13 [json_name="exclusions"];
+  repeated Node options = 14 [json_name="options"];
+  string indexname = 15 [json_name="indexname"];
+  string indexspace = 16 [json_name="indexspace"];
+  bool reset_default_tblspc = 17 [json_name="reset_default_tblspc"];
+  string access_method = 18 [json_name="access_method"];
+  Node where_clause = 19 [json_name="where_clause"];
+  RangeVar pktable = 20 [json_name="pktable"];
+  repeated Node fk_attrs = 21 [json_name="fk_attrs"];
+  repeated Node pk_attrs = 22 [json_name="pk_attrs"];
+  string fk_matchtype = 23 [json_name="fk_matchtype"];
+  string fk_upd_action = 24 [json_name="fk_upd_action"];
+  string fk_del_action = 25 [json_name="fk_del_action"];
+  repeated Node fk_del_set_cols = 26 [json_name="fk_del_set_cols"];
+  repeated Node old_conpfeqop = 27 [json_name="old_conpfeqop"];
+  uint32 old_pktable_oid = 28 [json_name="old_pktable_oid"];
+  bool skip_validation = 29 [json_name="skip_validation"];
+  bool initially_valid = 30 [json_name="initially_valid"];
+}
+
+message DefElem
+{
+  string defnamespace = 1 [json_name="defnamespace"];
+  string defname = 2 [json_name="defname"];
+  Node arg = 3 [json_name="arg"];
+  DefElemAction defaction = 4 [json_name="defaction"];
+  int32 location = 5 [json_name="location"];
+}
+
+message RangeTblEntry
+{
+  RTEKind rtekind = 1 [json_name="rtekind"];
+  uint32 relid = 2 [json_name="relid"];
+  string relkind = 3 [json_name="relkind"];
+  int32 rellockmode = 4 [json_name="rellockmode"];
+  TableSampleClause tablesample = 5 [json_name="tablesample"];
+  Query subquery = 6 [json_name="subquery"];
+  bool security_barrier = 7 [json_name="security_barrier"];
+  JoinType jointype = 8 [json_name="jointype"];
+  int32 joinmergedcols = 9 [json_name="joinmergedcols"];
+  repeated Node joinaliasvars = 10 [json_name="joinaliasvars"];
+  repeated Node joinleftcols = 11 [json_name="joinleftcols"];
+  repeated Node joinrightcols = 12 [json_name="joinrightcols"];
+  Alias join_using_alias = 13 [json_name="join_using_alias"];
+  repeated Node functions = 14 [json_name="functions"];
+  bool funcordinality = 15 [json_name="funcordinality"];
+  TableFunc tablefunc = 16 [json_name="tablefunc"];
+  repeated Node values_lists = 17 [json_name="values_lists"];
+  string ctename = 18 [json_name="ctename"];
+  uint32 ctelevelsup = 19 [json_name="ctelevelsup"];
+  bool self_reference = 20 [json_name="self_reference"];
+  repeated Node coltypes = 21 [json_name="coltypes"];
+  repeated Node coltypmods = 22 [json_name="coltypmods"];
+  repeated Node colcollations = 23 [json_name="colcollations"];
+  string enrname = 24 [json_name="enrname"];
+  double enrtuples = 25 [json_name="enrtuples"];
+  Alias alias = 26 [json_name="alias"];
+  Alias eref = 27 [json_name="eref"];
+  bool lateral = 28 [json_name="lateral"];
+  bool inh = 29 [json_name="inh"];
+  bool in_from_cl = 30 [json_name="inFromCl"];
+  uint32 required_perms = 31 [json_name="requiredPerms"];
+  uint32 check_as_user = 32 [json_name="checkAsUser"];
+  repeated uint64 selected_cols = 33 [json_name="selectedCols"];
+  repeated uint64 inserted_cols = 34 [json_name="insertedCols"];
+  repeated uint64 updated_cols = 35 [json_name="updatedCols"];
+  repeated uint64 extra_updated_cols = 36 [json_name="extraUpdatedCols"];
+  repeated Node security_quals = 37 [json_name="securityQuals"];
+}
+
+message RangeTblFunction
+{
+  Node funcexpr = 1 [json_name="funcexpr"];
+  int32 funccolcount = 2 [json_name="funccolcount"];
+  repeated Node funccolnames = 3 [json_name="funccolnames"];
+  repeated Node funccoltypes = 4 [json_name="funccoltypes"];
+  repeated Node funccoltypmods = 5 [json_name="funccoltypmods"];
+  repeated Node funccolcollations = 6 [json_name="funccolcollations"];
+  repeated uint64 funcparams = 7 [json_name="funcparams"];
+}
+
+message TableSampleClause
+{
+  uint32 tsmhandler = 1 [json_name="tsmhandler"];
+  repeated Node args = 2 [json_name="args"];
+  Node repeatable = 3 [json_name="repeatable"];
+}
+
+message WithCheckOption
+{
+  WCOKind kind = 1 [json_name="kind"];
+  string relname = 2 [json_name="relname"];
+  string polname = 3 [json_name="polname"];
+  Node qual = 4 [json_name="qual"];
+  bool cascaded = 5 [json_name="cascaded"];
+}
+
+message SortGroupClause
+{
+  uint32 tle_sort_group_ref = 1 [json_name="tleSortGroupRef"];
+  uint32 eqop = 2 [json_name="eqop"];
+  uint32 sortop = 3 [json_name="sortop"];
+  bool nulls_first = 4 [json_name="nulls_first"];
+  bool hashable = 5 [json_name="hashable"];
+}
+
+message GroupingSet
+{
+  GroupingSetKind kind = 1 [json_name="kind"];
+  repeated Node content = 2 [json_name="content"];
+  int32 location = 3 [json_name="location"];
+}
+
+message WindowClause
+{
+  string name = 1 [json_name="name"];
+  string refname = 2 [json_name="refname"];
+  repeated Node partition_clause = 3 [json_name="partitionClause"];
+  repeated Node order_clause = 4 [json_name="orderClause"];
+  int32 frame_options = 5 [json_name="frameOptions"];
+  Node start_offset = 6 [json_name="startOffset"];
+  Node end_offset = 7 [json_name="endOffset"];
+  repeated Node run_condition = 8 [json_name="runCondition"];
+  uint32 start_in_range_func = 9 [json_name="startInRangeFunc"];
+  uint32 end_in_range_func = 10 [json_name="endInRangeFunc"];
+  uint32 in_range_coll = 11 [json_name="inRangeColl"];
+  bool in_range_asc = 12 [json_name="inRangeAsc"];
+  bool in_range_nulls_first = 13 [json_name="inRangeNullsFirst"];
+  uint32 winref = 14 [json_name="winref"];
+  bool copied_order = 15 [json_name="copiedOrder"];
+}
+
+message ObjectWithArgs
+{
+  repeated Node objname = 1 [json_name="objname"];
+  repeated Node objargs = 2 [json_name="objargs"];
+  repeated Node objfuncargs = 3 [json_name="objfuncargs"];
+  bool args_unspecified = 4 [json_name="args_unspecified"];
+}
+
+message AccessPriv
+{
+  string priv_name = 1 [json_name="priv_name"];
+  repeated Node cols = 2 [json_name="cols"];
+}
+
+message CreateOpClassItem
+{
+  int32 itemtype = 1 [json_name="itemtype"];
+  ObjectWithArgs name = 2 [json_name="name"];
+  int32 number = 3 [json_name="number"];
+  repeated Node order_family = 4 [json_name="order_family"];
+  repeated Node class_args = 5 [json_name="class_args"];
+  TypeName storedtype = 6 [json_name="storedtype"];
+}
+
+message TableLikeClause
+{
+  RangeVar relation = 1 [json_name="relation"];
+  uint32 options = 2 [json_name="options"];
+  uint32 relation_oid = 3 [json_name="relationOid"];
+}
+
+message FunctionParameter
+{
+  string name = 1 [json_name="name"];
+  TypeName arg_type = 2 [json_name="argType"];
+  FunctionParameterMode mode = 3 [json_name="mode"];
+  Node defexpr = 4 [json_name="defexpr"];
+}
+
+message LockingClause
+{
+  repeated Node locked_rels = 1 [json_name="lockedRels"];
+  LockClauseStrength strength = 2 [json_name="strength"];
+  LockWaitPolicy wait_policy = 3 [json_name="waitPolicy"];
+}
+
+message RowMarkClause
+{
+  uint32 rti = 1 [json_name="rti"];
+  LockClauseStrength strength = 2 [json_name="strength"];
+  LockWaitPolicy wait_policy = 3 [json_name="waitPolicy"];
+  bool pushed_down = 4 [json_name="pushedDown"];
+}
+
+message XmlSerialize
+{
+  XmlOptionType xmloption = 1 [json_name="xmloption"];
+  Node expr = 2 [json_name="expr"];
+  TypeName type_name = 3 [json_name="typeName"];
+  int32 location = 4 [json_name="location"];
+}
+
+message WithClause
+{
+  repeated Node ctes = 1 [json_name="ctes"];
+  bool recursive = 2 [json_name="recursive"];
+  int32 location = 3 [json_name="location"];
+}
+
+message InferClause
+{
+  repeated Node index_elems = 1 [json_name="indexElems"];
+  Node where_clause = 2 [json_name="whereClause"];
+  string conname = 3 [json_name="conname"];
+  int32 location = 4 [json_name="location"];
+}
+
+message OnConflictClause
+{
+  OnConflictAction action = 1 [json_name="action"];
+  InferClause infer = 2 [json_name="infer"];
+  repeated Node target_list = 3 [json_name="targetList"];
+  Node where_clause = 4 [json_name="whereClause"];
+  int32 location = 5 [json_name="location"];
+}
+
+message CTESearchClause
+{
+  repeated Node search_col_list = 1 [json_name="search_col_list"];
+  bool search_breadth_first = 2 [json_name="search_breadth_first"];
+  string search_seq_column = 3 [json_name="search_seq_column"];
+  int32 location = 4 [json_name="location"];
+}
+
+message CTECycleClause
+{
+  repeated Node cycle_col_list = 1 [json_name="cycle_col_list"];
+  string cycle_mark_column = 2 [json_name="cycle_mark_column"];
+  Node cycle_mark_value = 3 [json_name="cycle_mark_value"];
+  Node cycle_mark_default = 4 [json_name="cycle_mark_default"];
+  string cycle_path_column = 5 [json_name="cycle_path_column"];
+  int32 location = 6 [json_name="location"];
+  uint32 cycle_mark_type = 7 [json_name="cycle_mark_type"];
+  int32 cycle_mark_typmod = 8 [json_name="cycle_mark_typmod"];
+  uint32 cycle_mark_collation = 9 [json_name="cycle_mark_collation"];
+  uint32 cycle_mark_neop = 10 [json_name="cycle_mark_neop"];
+}
+
+message CommonTableExpr
+{
+  string ctename = 1 [json_name="ctename"];
+  repeated Node aliascolnames = 2 [json_name="aliascolnames"];
+  CTEMaterialize ctematerialized = 3 [json_name="ctematerialized"];
+  Node ctequery = 4 [json_name="ctequery"];
+  CTESearchClause search_clause = 5 [json_name="search_clause"];
+  CTECycleClause cycle_clause = 6 [json_name="cycle_clause"];
+  int32 location = 7 [json_name="location"];
+  bool cterecursive = 8 [json_name="cterecursive"];
+  int32 cterefcount = 9 [json_name="cterefcount"];
+  repeated Node ctecolnames = 10 [json_name="ctecolnames"];
+  repeated Node ctecoltypes = 11 [json_name="ctecoltypes"];
+  repeated Node ctecoltypmods = 12 [json_name="ctecoltypmods"];
+  repeated Node ctecolcollations = 13 [json_name="ctecolcollations"];
+}
+
+message MergeWhenClause
+{
+  bool matched = 1 [json_name="matched"];
+  CmdType command_type = 2 [json_name="commandType"];
+  OverridingKind override = 3 [json_name="override"];
+  Node condition = 4 [json_name="condition"];
+  repeated Node target_list = 5 [json_name="targetList"];
+  repeated Node values = 6 [json_name="values"];
+}
+
+message RoleSpec
+{
+  RoleSpecType roletype = 1 [json_name="roletype"];
+  string rolename = 2 [json_name="rolename"];
+  int32 location = 3 [json_name="location"];
+}
+
+message TriggerTransition
+{
+  string name = 1 [json_name="name"];
+  bool is_new = 2 [json_name="isNew"];
+  bool is_table = 3 [json_name="isTable"];
+}
+
+message PartitionElem
+{
+  string name = 1 [json_name="name"];
+  Node expr = 2 [json_name="expr"];
+  repeated Node collation = 3 [json_name="collation"];
+  repeated Node opclass = 4 [json_name="opclass"];
+  int32 location = 5 [json_name="location"];
+}
+
+message PartitionSpec
+{
+  string strategy = 1 [json_name="strategy"];
+  repeated Node part_params = 2 [json_name="partParams"];
+  int32 location = 3 [json_name="location"];
+}
+
+message PartitionBoundSpec
+{
+  string strategy = 1 [json_name="strategy"];
+  bool is_default = 2 [json_name="is_default"];
+  int32 modulus = 3 [json_name="modulus"];
+  int32 remainder = 4 [json_name="remainder"];
+  repeated Node listdatums = 5 [json_name="listdatums"];
+  repeated Node lowerdatums = 6 [json_name="lowerdatums"];
+  repeated Node upperdatums = 7 [json_name="upperdatums"];
+  int32 location = 8 [json_name="location"];
+}
+
+message PartitionRangeDatum
+{
+  PartitionRangeDatumKind kind = 1 [json_name="kind"];
+  Node value = 2 [json_name="value"];
+  int32 location = 3 [json_name="location"];
+}
+
+message PartitionCmd
+{
+  RangeVar name = 1 [json_name="name"];
+  PartitionBoundSpec bound = 2 [json_name="bound"];
+  bool concurrent = 3 [json_name="concurrent"];
+}
+
+message VacuumRelation
+{
+  RangeVar relation = 1 [json_name="relation"];
+  uint32 oid = 2 [json_name="oid"];
+  repeated Node va_cols = 3 [json_name="va_cols"];
+}
+
+message PublicationObjSpec
+{
+  PublicationObjSpecType pubobjtype = 1 [json_name="pubobjtype"];
+  string name = 2 [json_name="name"];
+  PublicationTable pubtable = 3 [json_name="pubtable"];
+  int32 location = 4 [json_name="location"];
+}
+
+message PublicationTable
+{
+  RangeVar relation = 1 [json_name="relation"];
+  Node where_clause = 2 [json_name="whereClause"];
+  repeated Node columns = 3 [json_name="columns"];
+}
+
+message InlineCodeBlock
+{
+  string source_text = 1 [json_name="source_text"];
+  uint32 lang_oid = 2 [json_name="langOid"];
+  bool lang_is_trusted = 3 [json_name="langIsTrusted"];
+  bool atomic = 4 [json_name="atomic"];
+}
+
+message CallContext
+{
+  bool atomic = 1 [json_name="atomic"];
+}
+
+enum OverridingKind
+{
+  OVERRIDING_KIND_UNDEFINED = 0;
+  OVERRIDING_NOT_SET = 1;
+  OVERRIDING_USER_VALUE = 2;
+  OVERRIDING_SYSTEM_VALUE = 3;
+}
+
+enum QuerySource
+{
+  QUERY_SOURCE_UNDEFINED = 0;
+  QSRC_ORIGINAL = 1;
+  QSRC_PARSER = 2;
+  QSRC_INSTEAD_RULE = 3;
+  QSRC_QUAL_INSTEAD_RULE = 4;
+  QSRC_NON_INSTEAD_RULE = 5;
+}
+
+enum SortByDir
+{
+  SORT_BY_DIR_UNDEFINED = 0;
+  SORTBY_DEFAULT = 1;
+  SORTBY_ASC = 2;
+  SORTBY_DESC = 3;
+  SORTBY_USING = 4;
+}
+
+enum SortByNulls
+{
+  SORT_BY_NULLS_UNDEFINED = 0;
+  SORTBY_NULLS_DEFAULT = 1;
+  SORTBY_NULLS_FIRST = 2;
+  SORTBY_NULLS_LAST = 3;
+}
+
+enum SetQuantifier
+{
+  SET_QUANTIFIER_UNDEFINED = 0;
+  SET_QUANTIFIER_DEFAULT = 1;
+  SET_QUANTIFIER_ALL = 2;
+  SET_QUANTIFIER_DISTINCT = 3;
+}
+
+enum A_Expr_Kind
+{
+  A_EXPR_KIND_UNDEFINED = 0;
+  AEXPR_OP = 1;
+  AEXPR_OP_ANY = 2;
+  AEXPR_OP_ALL = 3;
+  AEXPR_DISTINCT = 4;
+  AEXPR_NOT_DISTINCT = 5;
+  AEXPR_NULLIF = 6;
+  AEXPR_IN = 7;
+  AEXPR_LIKE = 8;
+  AEXPR_ILIKE = 9;
+  AEXPR_SIMILAR = 10;
+  AEXPR_BETWEEN = 11;
+  AEXPR_NOT_BETWEEN = 12;
+  AEXPR_BETWEEN_SYM = 13;
+  AEXPR_NOT_BETWEEN_SYM = 14;
+}
+
+enum RoleSpecType
+{
+  ROLE_SPEC_TYPE_UNDEFINED = 0;
+  ROLESPEC_CSTRING = 1;
+  ROLESPEC_CURRENT_ROLE = 2;
+  ROLESPEC_CURRENT_USER = 3;
+  ROLESPEC_SESSION_USER = 4;
+  ROLESPEC_PUBLIC = 5;
+}
+
+enum TableLikeOption
+{
+  TABLE_LIKE_OPTION_UNDEFINED = 0;
+  CREATE_TABLE_LIKE_COMMENTS = 1;
+  CREATE_TABLE_LIKE_COMPRESSION = 2;
+  CREATE_TABLE_LIKE_CONSTRAINTS = 3;
+  CREATE_TABLE_LIKE_DEFAULTS = 4;
+  CREATE_TABLE_LIKE_GENERATED = 5;
+  CREATE_TABLE_LIKE_IDENTITY = 6;
+  CREATE_TABLE_LIKE_INDEXES = 7;
+  CREATE_TABLE_LIKE_STATISTICS = 8;
+  CREATE_TABLE_LIKE_STORAGE = 9;
+  CREATE_TABLE_LIKE_ALL = 10;
+}
+
+enum DefElemAction
+{
+  DEF_ELEM_ACTION_UNDEFINED = 0;
+  DEFELEM_UNSPEC = 1;
+  DEFELEM_SET = 2;
+  DEFELEM_ADD = 3;
+  DEFELEM_DROP = 4;
+}
+
+enum PartitionRangeDatumKind
+{
+  PARTITION_RANGE_DATUM_KIND_UNDEFINED = 0;
+  PARTITION_RANGE_DATUM_MINVALUE = 1;
+  PARTITION_RANGE_DATUM_VALUE = 2;
+  PARTITION_RANGE_DATUM_MAXVALUE = 3;
+}
+
+enum RTEKind
+{
+  RTEKIND_UNDEFINED = 0;
+  RTE_RELATION = 1;
+  RTE_SUBQUERY = 2;
+  RTE_JOIN = 3;
+  RTE_FUNCTION = 4;
+  RTE_TABLEFUNC = 5;
+  RTE_VALUES = 6;
+  RTE_CTE = 7;
+  RTE_NAMEDTUPLESTORE = 8;
+  RTE_RESULT = 9;
+}
+
+enum WCOKind
+{
+  WCOKIND_UNDEFINED = 0;
+  WCO_VIEW_CHECK = 1;
+  WCO_RLS_INSERT_CHECK = 2;
+  WCO_RLS_UPDATE_CHECK = 3;
+  WCO_RLS_CONFLICT_CHECK = 4;
+  WCO_RLS_MERGE_UPDATE_CHECK = 5;
+  WCO_RLS_MERGE_DELETE_CHECK = 6;
+}
+
+enum GroupingSetKind
+{
+  GROUPING_SET_KIND_UNDEFINED = 0;
+  GROUPING_SET_EMPTY = 1;
+  GROUPING_SET_SIMPLE = 2;
+  GROUPING_SET_ROLLUP = 3;
+  GROUPING_SET_CUBE = 4;
+  GROUPING_SET_SETS = 5;
+}
+
+enum CTEMaterialize
+{
+  CTEMATERIALIZE_UNDEFINED = 0;
+  CTEMaterializeDefault = 1;
+  CTEMaterializeAlways = 2;
+  CTEMaterializeNever = 3;
+}
+
+enum SetOperation
+{
+  SET_OPERATION_UNDEFINED = 0;
+  SETOP_NONE = 1;
+  SETOP_UNION = 2;
+  SETOP_INTERSECT = 3;
+  SETOP_EXCEPT = 4;
+}
+
+enum ObjectType
+{
+  OBJECT_TYPE_UNDEFINED = 0;
+  OBJECT_ACCESS_METHOD = 1;
+  OBJECT_AGGREGATE = 2;
+  OBJECT_AMOP = 3;
+  OBJECT_AMPROC = 4;
+  OBJECT_ATTRIBUTE = 5;
+  OBJECT_CAST = 6;
+  OBJECT_COLUMN = 7;
+  OBJECT_COLLATION = 8;
+  OBJECT_CONVERSION = 9;
+  OBJECT_DATABASE = 10;
+  OBJECT_DEFAULT = 11;
+  OBJECT_DEFACL = 12;
+  OBJECT_DOMAIN = 13;
+  OBJECT_DOMCONSTRAINT = 14;
+  OBJECT_EVENT_TRIGGER = 15;
+  OBJECT_EXTENSION = 16;
+  OBJECT_FDW = 17;
+  OBJECT_FOREIGN_SERVER = 18;
+  OBJECT_FOREIGN_TABLE = 19;
+  OBJECT_FUNCTION = 20;
+  OBJECT_INDEX = 21;
+  OBJECT_LANGUAGE = 22;
+  OBJECT_LARGEOBJECT = 23;
+  OBJECT_MATVIEW = 24;
+  OBJECT_OPCLASS = 25;
+  OBJECT_OPERATOR = 26;
+  OBJECT_OPFAMILY = 27;
+  OBJECT_PARAMETER_ACL = 28;
+  OBJECT_POLICY = 29;
+  OBJECT_PROCEDURE = 30;
+  OBJECT_PUBLICATION = 31;
+  OBJECT_PUBLICATION_NAMESPACE = 32;
+  OBJECT_PUBLICATION_REL = 33;
+  OBJECT_ROLE = 34;
+  OBJECT_ROUTINE = 35;
+  OBJECT_RULE = 36;
+  OBJECT_SCHEMA = 37;
+  OBJECT_SEQUENCE = 38;
+  OBJECT_SUBSCRIPTION = 39;
+  OBJECT_STATISTIC_EXT = 40;
+  OBJECT_TABCONSTRAINT = 41;
+  OBJECT_TABLE = 42;
+  OBJECT_TABLESPACE = 43;
+  OBJECT_TRANSFORM = 44;
+  OBJECT_TRIGGER = 45;
+  OBJECT_TSCONFIGURATION = 46;
+  OBJECT_TSDICTIONARY = 47;
+  OBJECT_TSPARSER = 48;
+  OBJECT_TSTEMPLATE = 49;
+  OBJECT_TYPE = 50;
+  OBJECT_USER_MAPPING = 51;
+  OBJECT_VIEW = 52;
+}
+
+enum DropBehavior
+{
+  DROP_BEHAVIOR_UNDEFINED = 0;
+  DROP_RESTRICT = 1;
+  DROP_CASCADE = 2;
+}
+
+enum AlterTableType
+{
+  ALTER_TABLE_TYPE_UNDEFINED = 0;
+  AT_AddColumn = 1;
+  AT_AddColumnRecurse = 2;
+  AT_AddColumnToView = 3;
+  AT_ColumnDefault = 4;
+  AT_CookedColumnDefault = 5;
+  AT_DropNotNull = 6;
+  AT_SetNotNull = 7;
+  AT_DropExpression = 8;
+  AT_CheckNotNull = 9;
+  AT_SetStatistics = 10;
+  AT_SetOptions = 11;
+  AT_ResetOptions = 12;
+  AT_SetStorage = 13;
+  AT_SetCompression = 14;
+  AT_DropColumn = 15;
+  AT_DropColumnRecurse = 16;
+  AT_AddIndex = 17;
+  AT_ReAddIndex = 18;
+  AT_AddConstraint = 19;
+  AT_AddConstraintRecurse = 20;
+  AT_ReAddConstraint = 21;
+  AT_ReAddDomainConstraint = 22;
+  AT_AlterConstraint = 23;
+  AT_ValidateConstraint = 24;
+  AT_ValidateConstraintRecurse = 25;
+  AT_AddIndexConstraint = 26;
+  AT_DropConstraint = 27;
+  AT_DropConstraintRecurse = 28;
+  AT_ReAddComment = 29;
+  AT_AlterColumnType = 30;
+  AT_AlterColumnGenericOptions = 31;
+  AT_ChangeOwner = 32;
+  AT_ClusterOn = 33;
+  AT_DropCluster = 34;
+  AT_SetLogged = 35;
+  AT_SetUnLogged = 36;
+  AT_DropOids = 37;
+  AT_SetAccessMethod = 38;
+  AT_SetTableSpace = 39;
+  AT_SetRelOptions = 40;
+  AT_ResetRelOptions = 41;
+  AT_ReplaceRelOptions = 42;
+  AT_EnableTrig = 43;
+  AT_EnableAlwaysTrig = 44;
+  AT_EnableReplicaTrig = 45;
+  AT_DisableTrig = 46;
+  AT_EnableTrigAll = 47;
+  AT_DisableTrigAll = 48;
+  AT_EnableTrigUser = 49;
+  AT_DisableTrigUser = 50;
+  AT_EnableRule = 51;
+  AT_EnableAlwaysRule = 52;
+  AT_EnableReplicaRule = 53;
+  AT_DisableRule = 54;
+  AT_AddInherit = 55;
+  AT_DropInherit = 56;
+  AT_AddOf = 57;
+  AT_DropOf = 58;
+  AT_ReplicaIdentity = 59;
+  AT_EnableRowSecurity = 60;
+  AT_DisableRowSecurity = 61;
+  AT_ForceRowSecurity = 62;
+  AT_NoForceRowSecurity = 63;
+  AT_GenericOptions = 64;
+  AT_AttachPartition = 65;
+  AT_DetachPartition = 66;
+  AT_DetachPartitionFinalize = 67;
+  AT_AddIdentity = 68;
+  AT_SetIdentity = 69;
+  AT_DropIdentity = 70;
+  AT_ReAddStatistics = 71;
+}
+
+enum GrantTargetType
+{
+  GRANT_TARGET_TYPE_UNDEFINED = 0;
+  ACL_TARGET_OBJECT = 1;
+  ACL_TARGET_ALL_IN_SCHEMA = 2;
+  ACL_TARGET_DEFAULTS = 3;
+}
+
+enum VariableSetKind
+{
+  VARIABLE_SET_KIND_UNDEFINED = 0;
+  VAR_SET_VALUE = 1;
+  VAR_SET_DEFAULT = 2;
+  VAR_SET_CURRENT = 3;
+  VAR_SET_MULTI = 4;
+  VAR_RESET = 5;
+  VAR_RESET_ALL = 6;
+}
+
+enum ConstrType
+{
+  CONSTR_TYPE_UNDEFINED = 0;
+  CONSTR_NULL = 1;
+  CONSTR_NOTNULL = 2;
+  CONSTR_DEFAULT = 3;
+  CONSTR_IDENTITY = 4;
+  CONSTR_GENERATED = 5;
+  CONSTR_CHECK = 6;
+  CONSTR_PRIMARY = 7;
+  CONSTR_UNIQUE = 8;
+  CONSTR_EXCLUSION = 9;
+  CONSTR_FOREIGN = 10;
+  CONSTR_ATTR_DEFERRABLE = 11;
+  CONSTR_ATTR_NOT_DEFERRABLE = 12;
+  CONSTR_ATTR_DEFERRED = 13;
+  CONSTR_ATTR_IMMEDIATE = 14;
+}
+
+enum ImportForeignSchemaType
+{
+  IMPORT_FOREIGN_SCHEMA_TYPE_UNDEFINED = 0;
+  FDW_IMPORT_SCHEMA_ALL = 1;
+  FDW_IMPORT_SCHEMA_LIMIT_TO = 2;
+  FDW_IMPORT_SCHEMA_EXCEPT = 3;
+}
+
+enum RoleStmtType
+{
+  ROLE_STMT_TYPE_UNDEFINED = 0;
+  ROLESTMT_ROLE = 1;
+  ROLESTMT_USER = 2;
+  ROLESTMT_GROUP = 3;
+}
+
+enum FetchDirection
+{
+  FETCH_DIRECTION_UNDEFINED = 0;
+  FETCH_FORWARD = 1;
+  FETCH_BACKWARD = 2;
+  FETCH_ABSOLUTE = 3;
+  FETCH_RELATIVE = 4;
+}
+
+enum FunctionParameterMode
+{
+  FUNCTION_PARAMETER_MODE_UNDEFINED = 0;
+  FUNC_PARAM_IN = 1;
+  FUNC_PARAM_OUT = 2;
+  FUNC_PARAM_INOUT = 3;
+  FUNC_PARAM_VARIADIC = 4;
+  FUNC_PARAM_TABLE = 5;
+  FUNC_PARAM_DEFAULT = 6;
+}
+
+enum TransactionStmtKind
+{
+  TRANSACTION_STMT_KIND_UNDEFINED = 0;
+  TRANS_STMT_BEGIN = 1;
+  TRANS_STMT_START = 2;
+  TRANS_STMT_COMMIT = 3;
+  TRANS_STMT_ROLLBACK = 4;
+  TRANS_STMT_SAVEPOINT = 5;
+  TRANS_STMT_RELEASE = 6;
+  TRANS_STMT_ROLLBACK_TO = 7;
+  TRANS_STMT_PREPARE = 8;
+  TRANS_STMT_COMMIT_PREPARED = 9;
+  TRANS_STMT_ROLLBACK_PREPARED = 10;
+}
+
+enum ViewCheckOption
+{
+  VIEW_CHECK_OPTION_UNDEFINED = 0;
+  NO_CHECK_OPTION = 1;
+  LOCAL_CHECK_OPTION = 2;
+  CASCADED_CHECK_OPTION = 3;
+}
+
+enum DiscardMode
+{
+  DISCARD_MODE_UNDEFINED = 0;
+  DISCARD_ALL = 1;
+  DISCARD_PLANS = 2;
+  DISCARD_SEQUENCES = 3;
+  DISCARD_TEMP = 4;
+}
+
+enum ReindexObjectType
+{
+  REINDEX_OBJECT_TYPE_UNDEFINED = 0;
+  REINDEX_OBJECT_INDEX = 1;
+  REINDEX_OBJECT_TABLE = 2;
+  REINDEX_OBJECT_SCHEMA = 3;
+  REINDEX_OBJECT_SYSTEM = 4;
+  REINDEX_OBJECT_DATABASE = 5;
+}
+
+enum AlterTSConfigType
+{
+  ALTER_TSCONFIG_TYPE_UNDEFINED = 0;
+  ALTER_TSCONFIG_ADD_MAPPING = 1;
+  ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN = 2;
+  ALTER_TSCONFIG_REPLACE_DICT = 3;
+  ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN = 4;
+  ALTER_TSCONFIG_DROP_MAPPING = 5;
+}
+
+enum PublicationObjSpecType
+{
+  PUBLICATION_OBJ_SPEC_TYPE_UNDEFINED = 0;
+  PUBLICATIONOBJ_TABLE = 1;
+  PUBLICATIONOBJ_TABLES_IN_SCHEMA = 2;
+  PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA = 3;
+  PUBLICATIONOBJ_CONTINUATION = 4;
+}
+
+enum AlterPublicationAction
+{
+  ALTER_PUBLICATION_ACTION_UNDEFINED = 0;
+  AP_AddObjects = 1;
+  AP_DropObjects = 2;
+  AP_SetObjects = 3;
+}
+
+enum AlterSubscriptionType
+{
+  ALTER_SUBSCRIPTION_TYPE_UNDEFINED = 0;
+  ALTER_SUBSCRIPTION_OPTIONS = 1;
+  ALTER_SUBSCRIPTION_CONNECTION = 2;
+  ALTER_SUBSCRIPTION_SET_PUBLICATION = 3;
+  ALTER_SUBSCRIPTION_ADD_PUBLICATION = 4;
+  ALTER_SUBSCRIPTION_DROP_PUBLICATION = 5;
+  ALTER_SUBSCRIPTION_REFRESH = 6;
+  ALTER_SUBSCRIPTION_ENABLED = 7;
+  ALTER_SUBSCRIPTION_SKIP = 8;
+}
+
+enum OnCommitAction
+{
+  ON_COMMIT_ACTION_UNDEFINED = 0;
+  ONCOMMIT_NOOP = 1;
+  ONCOMMIT_PRESERVE_ROWS = 2;
+  ONCOMMIT_DELETE_ROWS = 3;
+  ONCOMMIT_DROP = 4;
+}
+
+enum ParamKind
+{
+  PARAM_KIND_UNDEFINED = 0;
+  PARAM_EXTERN = 1;
+  PARAM_EXEC = 2;
+  PARAM_SUBLINK = 3;
+  PARAM_MULTIEXPR = 4;
+}
+
+enum CoercionContext
+{
+  COERCION_CONTEXT_UNDEFINED = 0;
+  COERCION_IMPLICIT = 1;
+  COERCION_ASSIGNMENT = 2;
+  COERCION_PLPGSQL = 3;
+  COERCION_EXPLICIT = 4;
+}
+
+enum CoercionForm
+{
+  COERCION_FORM_UNDEFINED = 0;
+  COERCE_EXPLICIT_CALL = 1;
+  COERCE_EXPLICIT_CAST = 2;
+  COERCE_IMPLICIT_CAST = 3;
+  COERCE_SQL_SYNTAX = 4;
+}
+
+enum BoolExprType
+{
+  BOOL_EXPR_TYPE_UNDEFINED = 0;
+  AND_EXPR = 1;
+  OR_EXPR = 2;
+  NOT_EXPR = 3;
+}
+
+enum SubLinkType
+{
+  SUB_LINK_TYPE_UNDEFINED = 0;
+  EXISTS_SUBLINK = 1;
+  ALL_SUBLINK = 2;
+  ANY_SUBLINK = 3;
+  ROWCOMPARE_SUBLINK = 4;
+  EXPR_SUBLINK = 5;
+  MULTIEXPR_SUBLINK = 6;
+  ARRAY_SUBLINK = 7;
+  CTE_SUBLINK = 8;
+}
+
+enum RowCompareType
+{
+  ROW_COMPARE_TYPE_UNDEFINED = 0;
+  ROWCOMPARE_LT = 1;
+  ROWCOMPARE_LE = 2;
+  ROWCOMPARE_EQ = 3;
+  ROWCOMPARE_GE = 4;
+  ROWCOMPARE_GT = 5;
+  ROWCOMPARE_NE = 6;
+}
+
+enum MinMaxOp
+{
+  MIN_MAX_OP_UNDEFINED = 0;
+  IS_GREATEST = 1;
+  IS_LEAST = 2;
+}
+
+enum SQLValueFunctionOp
+{
+  SQLVALUE_FUNCTION_OP_UNDEFINED = 0;
+  SVFOP_CURRENT_DATE = 1;
+  SVFOP_CURRENT_TIME = 2;
+  SVFOP_CURRENT_TIME_N = 3;
+  SVFOP_CURRENT_TIMESTAMP = 4;
+  SVFOP_CURRENT_TIMESTAMP_N = 5;
+  SVFOP_LOCALTIME = 6;
+  SVFOP_LOCALTIME_N = 7;
+  SVFOP_LOCALTIMESTAMP = 8;
+  SVFOP_LOCALTIMESTAMP_N = 9;
+  SVFOP_CURRENT_ROLE = 10;
+  SVFOP_CURRENT_USER = 11;
+  SVFOP_USER = 12;
+  SVFOP_SESSION_USER = 13;
+  SVFOP_CURRENT_CATALOG = 14;
+  SVFOP_CURRENT_SCHEMA = 15;
+}
+
+enum XmlExprOp
+{
+  XML_EXPR_OP_UNDEFINED = 0;
+  IS_XMLCONCAT = 1;
+  IS_XMLELEMENT = 2;
+  IS_XMLFOREST = 3;
+  IS_XMLPARSE = 4;
+  IS_XMLPI = 5;
+  IS_XMLROOT = 6;
+  IS_XMLSERIALIZE = 7;
+  IS_DOCUMENT = 8;
+}
+
+enum XmlOptionType
+{
+  XML_OPTION_TYPE_UNDEFINED = 0;
+  XMLOPTION_DOCUMENT = 1;
+  XMLOPTION_CONTENT = 2;
+}
+
+enum NullTestType
+{
+  NULL_TEST_TYPE_UNDEFINED = 0;
+  IS_NULL = 1;
+  IS_NOT_NULL = 2;
+}
+
+enum BoolTestType
+{
+  BOOL_TEST_TYPE_UNDEFINED = 0;
+  IS_TRUE = 1;
+  IS_NOT_TRUE = 2;
+  IS_FALSE = 3;
+  IS_NOT_FALSE = 4;
+  IS_UNKNOWN = 5;
+  IS_NOT_UNKNOWN = 6;
+}
+
+enum CmdType
+{
+  CMD_TYPE_UNDEFINED = 0;
+  CMD_UNKNOWN = 1;
+  CMD_SELECT = 2;
+  CMD_UPDATE = 3;
+  CMD_INSERT = 4;
+  CMD_DELETE = 5;
+  CMD_MERGE = 6;
+  CMD_UTILITY = 7;
+  CMD_NOTHING = 8;
+}
+
+enum JoinType
+{
+  JOIN_TYPE_UNDEFINED = 0;
+  JOIN_INNER = 1;
+  JOIN_LEFT = 2;
+  JOIN_FULL = 3;
+  JOIN_RIGHT = 4;
+  JOIN_SEMI = 5;
+  JOIN_ANTI = 6;
+  JOIN_UNIQUE_OUTER = 7;
+  JOIN_UNIQUE_INNER = 8;
+}
+
+enum AggStrategy
+{
+  AGG_STRATEGY_UNDEFINED = 0;
+  AGG_PLAIN = 1;
+  AGG_SORTED = 2;
+  AGG_HASHED = 3;
+  AGG_MIXED = 4;
+}
+
+enum AggSplit
+{
+  AGG_SPLIT_UNDEFINED = 0;
+  AGGSPLIT_SIMPLE = 1;
+  AGGSPLIT_INITIAL_SERIAL = 2;
+  AGGSPLIT_FINAL_DESERIAL = 3;
+}
+
+enum SetOpCmd
+{
+  SET_OP_CMD_UNDEFINED = 0;
+  SETOPCMD_INTERSECT = 1;
+  SETOPCMD_INTERSECT_ALL = 2;
+  SETOPCMD_EXCEPT = 3;
+  SETOPCMD_EXCEPT_ALL = 4;
+}
+
+enum SetOpStrategy
+{
+  SET_OP_STRATEGY_UNDEFINED = 0;
+  SETOP_SORTED = 1;
+  SETOP_HASHED = 2;
+}
+
+enum OnConflictAction
+{
+  ON_CONFLICT_ACTION_UNDEFINED = 0;
+  ONCONFLICT_NONE = 1;
+  ONCONFLICT_NOTHING = 2;
+  ONCONFLICT_UPDATE = 3;
+}
+
+enum LimitOption
+{
+  LIMIT_OPTION_UNDEFINED = 0;
+  LIMIT_OPTION_DEFAULT = 1;
+  LIMIT_OPTION_COUNT = 2;
+  LIMIT_OPTION_WITH_TIES = 3;
+}
+
+enum LockClauseStrength
+{
+  LOCK_CLAUSE_STRENGTH_UNDEFINED = 0;
+  LCS_NONE = 1;
+  LCS_FORKEYSHARE = 2;
+  LCS_FORSHARE = 3;
+  LCS_FORNOKEYUPDATE = 4;
+  LCS_FORUPDATE = 5;
+}
+
+enum LockWaitPolicy
+{
+  LOCK_WAIT_POLICY_UNDEFINED = 0;
+  LockWaitBlock = 1;
+  LockWaitSkip = 2;
+  LockWaitError = 3;
+}
+
+enum LockTupleMode
+{
+  LOCK_TUPLE_MODE_UNDEFINED = 0;
+  LockTupleKeyShare = 1;
+  LockTupleShare = 2;
+  LockTupleNoKeyExclusive = 3;
+  LockTupleExclusive = 4;
+}
+
+message ScanToken {
+  int32 start = 1;
+  int32 end = 2;
+  Token token = 4;
+  KeywordKind keyword_kind = 5;
+}
+
+enum KeywordKind {
+  NO_KEYWORD = 0;
+  UNRESERVED_KEYWORD = 1;
+  COL_NAME_KEYWORD = 2;
+  TYPE_FUNC_NAME_KEYWORD = 3;
+  RESERVED_KEYWORD = 4;
+}
+
+enum Token {
+  NUL = 0;
+  // Single-character tokens that are returned 1:1 (identical with "self" list in scan.l)
+  // Either supporting syntax, or single-character operators (some can be both)
+  // Also see https://www.postgresql.org/docs/12/sql-syntax-lexical.html#SQL-SYNTAX-SPECIAL-CHARS
+  ASCII_37 = 37; // "%"
+  ASCII_40 = 40; // "("
+  ASCII_41 = 41; // ")"
+  ASCII_42 = 42; // "*"
+  ASCII_43 = 43; // "+"
+  ASCII_44 = 44; // ","
+  ASCII_45 = 45; // "-"
+  ASCII_46 = 46; // "."
+  ASCII_47 = 47; // "/"
+  ASCII_58 = 58; // ":"
+  ASCII_59 = 59; // ";"
+  ASCII_60 = 60; // "<"
+  ASCII_61 = 61; // "="
+  ASCII_62 = 62; // ">"
+  ASCII_63 = 63; // "?"
+  ASCII_91 = 91; // "["
+  ASCII_92 = 92; // "\"
+  ASCII_93 = 93; // "]"
+  ASCII_94 = 94; // "^"
+  // Named tokens in scan.l
+  IDENT = 258;
+  UIDENT = 259;
+  FCONST = 260;
+  SCONST = 261;
+  USCONST = 262;
+  BCONST = 263;
+  XCONST = 264;
+  Op = 265;
+  ICONST = 266;
+  PARAM = 267;
+  TYPECAST = 268;
+  DOT_DOT = 269;
+  COLON_EQUALS = 270;
+  EQUALS_GREATER = 271;
+  LESS_EQUALS = 272;
+  GREATER_EQUALS = 273;
+  NOT_EQUALS = 274;
+  SQL_COMMENT = 275;
+  C_COMMENT = 276;
+  ABORT_P = 277;
+  ABSOLUTE_P = 278;
+  ACCESS = 279;
+  ACTION = 280;
+  ADD_P = 281;
+  ADMIN = 282;
+  AFTER = 283;
+  AGGREGATE = 284;
+  ALL = 285;
+  ALSO = 286;
+  ALTER = 287;
+  ALWAYS = 288;
+  ANALYSE = 289;
+  ANALYZE = 290;
+  AND = 291;
+  ANY = 292;
+  ARRAY = 293;
+  AS = 294;
+  ASC = 295;
+  ASENSITIVE = 296;
+  ASSERTION = 297;
+  ASSIGNMENT = 298;
+  ASYMMETRIC = 299;
+  ATOMIC = 300;
+  AT = 301;
+  ATTACH = 302;
+  ATTRIBUTE = 303;
+  AUTHORIZATION = 304;
+  BACKWARD = 305;
+  BEFORE = 306;
+  BEGIN_P = 307;
+  BETWEEN = 308;
+  BIGINT = 309;
+  BINARY = 310;
+  BIT = 311;
+  BOOLEAN_P = 312;
+  BOTH = 313;
+  BREADTH = 314;
+  BY = 315;
+  CACHE = 316;
+  CALL = 317;
+  CALLED = 318;
+  CASCADE = 319;
+  CASCADED = 320;
+  CASE = 321;
+  CAST = 322;
+  CATALOG_P = 323;
+  CHAIN = 324;
+  CHAR_P = 325;
+  CHARACTER = 326;
+  CHARACTERISTICS = 327;
+  CHECK = 328;
+  CHECKPOINT = 329;
+  CLASS = 330;
+  CLOSE = 331;
+  CLUSTER = 332;
+  COALESCE = 333;
+  COLLATE = 334;
+  COLLATION = 335;
+  COLUMN = 336;
+  COLUMNS = 337;
+  COMMENT = 338;
+  COMMENTS = 339;
+  COMMIT = 340;
+  COMMITTED = 341;
+  COMPRESSION = 342;
+  CONCURRENTLY = 343;
+  CONFIGURATION = 344;
+  CONFLICT = 345;
+  CONNECTION = 346;
+  CONSTRAINT = 347;
+  CONSTRAINTS = 348;
+  CONTENT_P = 349;
+  CONTINUE_P = 350;
+  CONVERSION_P = 351;
+  COPY = 352;
+  COST = 353;
+  CREATE = 354;
+  CROSS = 355;
+  CSV = 356;
+  CUBE = 357;
+  CURRENT_P = 358;
+  CURRENT_CATALOG = 359;
+  CURRENT_DATE = 360;
+  CURRENT_ROLE = 361;
+  CURRENT_SCHEMA = 362;
+  CURRENT_TIME = 363;
+  CURRENT_TIMESTAMP = 364;
+  CURRENT_USER = 365;
+  CURSOR = 366;
+  CYCLE = 367;
+  DATA_P = 368;
+  DATABASE = 369;
+  DAY_P = 370;
+  DEALLOCATE = 371;
+  DEC = 372;
+  DECIMAL_P = 373;
+  DECLARE = 374;
+  DEFAULT = 375;
+  DEFAULTS = 376;
+  DEFERRABLE = 377;
+  DEFERRED = 378;
+  DEFINER = 379;
+  DELETE_P = 380;
+  DELIMITER = 381;
+  DELIMITERS = 382;
+  DEPENDS = 383;
+  DEPTH = 384;
+  DESC = 385;
+  DETACH = 386;
+  DICTIONARY = 387;
+  DISABLE_P = 388;
+  DISCARD = 389;
+  DISTINCT = 390;
+  DO = 391;
+  DOCUMENT_P = 392;
+  DOMAIN_P = 393;
+  DOUBLE_P = 394;
+  DROP = 395;
+  EACH = 396;
+  ELSE = 397;
+  ENABLE_P = 398;
+  ENCODING = 399;
+  ENCRYPTED = 400;
+  END_P = 401;
+  ENUM_P = 402;
+  ESCAPE = 403;
+  EVENT = 404;
+  EXCEPT = 405;
+  EXCLUDE = 406;
+  EXCLUDING = 407;
+  EXCLUSIVE = 408;
+  EXECUTE = 409;
+  EXISTS = 410;
+  EXPLAIN = 411;
+  EXPRESSION = 412;
+  EXTENSION = 413;
+  EXTERNAL = 414;
+  EXTRACT = 415;
+  FALSE_P = 416;
+  FAMILY = 417;
+  FETCH = 418;
+  FILTER = 419;
+  FINALIZE = 420;
+  FIRST_P = 421;
+  FLOAT_P = 422;
+  FOLLOWING = 423;
+  FOR = 424;
+  FORCE = 425;
+  FOREIGN = 426;
+  FORWARD = 427;
+  FREEZE = 428;
+  FROM = 429;
+  FULL = 430;
+  FUNCTION = 431;
+  FUNCTIONS = 432;
+  GENERATED = 433;
+  GLOBAL = 434;
+  GRANT = 435;
+  GRANTED = 436;
+  GREATEST = 437;
+  GROUP_P = 438;
+  GROUPING = 439;
+  GROUPS = 440;
+  HANDLER = 441;
+  HAVING = 442;
+  HEADER_P = 443;
+  HOLD = 444;
+  HOUR_P = 445;
+  IDENTITY_P = 446;
+  IF_P = 447;
+  ILIKE = 448;
+  IMMEDIATE = 449;
+  IMMUTABLE = 450;
+  IMPLICIT_P = 451;
+  IMPORT_P = 452;
+  IN_P = 453;
+  INCLUDE = 454;
+  INCLUDING = 455;
+  INCREMENT = 456;
+  INDEX = 457;
+  INDEXES = 458;
+  INHERIT = 459;
+  INHERITS = 460;
+  INITIALLY = 461;
+  INLINE_P = 462;
+  INNER_P = 463;
+  INOUT = 464;
+  INPUT_P = 465;
+  INSENSITIVE = 466;
+  INSERT = 467;
+  INSTEAD = 468;
+  INT_P = 469;
+  INTEGER = 470;
+  INTERSECT = 471;
+  INTERVAL = 472;
+  INTO = 473;
+  INVOKER = 474;
+  IS = 475;
+  ISNULL = 476;
+  ISOLATION = 477;
+  JOIN = 478;
+  KEY = 479;
+  LABEL = 480;
+  LANGUAGE = 481;
+  LARGE_P = 482;
+  LAST_P = 483;
+  LATERAL_P = 484;
+  LEADING = 485;
+  LEAKPROOF = 486;
+  LEAST = 487;
+  LEFT = 488;
+  LEVEL = 489;
+  LIKE = 490;
+  LIMIT = 491;
+  LISTEN = 492;
+  LOAD = 493;
+  LOCAL = 494;
+  LOCALTIME = 495;
+  LOCALTIMESTAMP = 496;
+  LOCATION = 497;
+  LOCK_P = 498;
+  LOCKED = 499;
+  LOGGED = 500;
+  MAPPING = 501;
+  MATCH = 502;
+  MATCHED = 503;
+  MATERIALIZED = 504;
+  MAXVALUE = 505;
+  MERGE = 506;
+  METHOD = 507;
+  MINUTE_P = 508;
+  MINVALUE = 509;
+  MODE = 510;
+  MONTH_P = 511;
+  MOVE = 512;
+  NAME_P = 513;
+  NAMES = 514;
+  NATIONAL = 515;
+  NATURAL = 516;
+  NCHAR = 517;
+  NEW = 518;
+  NEXT = 519;
+  NFC = 520;
+  NFD = 521;
+  NFKC = 522;
+  NFKD = 523;
+  NO = 524;
+  NONE = 525;
+  NORMALIZE = 526;
+  NORMALIZED = 527;
+  NOT = 528;
+  NOTHING = 529;
+  NOTIFY = 530;
+  NOTNULL = 531;
+  NOWAIT = 532;
+  NULL_P = 533;
+  NULLIF = 534;
+  NULLS_P = 535;
+  NUMERIC = 536;
+  OBJECT_P = 537;
+  OF = 538;
+  OFF = 539;
+  OFFSET = 540;
+  OIDS = 541;
+  OLD = 542;
+  ON = 543;
+  ONLY = 544;
+  OPERATOR = 545;
+  OPTION = 546;
+  OPTIONS = 547;
+  OR = 548;
+  ORDER = 549;
+  ORDINALITY = 550;
+  OTHERS = 551;
+  OUT_P = 552;
+  OUTER_P = 553;
+  OVER = 554;
+  OVERLAPS = 555;
+  OVERLAY = 556;
+  OVERRIDING = 557;
+  OWNED = 558;
+  OWNER = 559;
+  PARALLEL = 560;
+  PARAMETER = 561;
+  PARSER = 562;
+  PARTIAL = 563;
+  PARTITION = 564;
+  PASSING = 565;
+  PASSWORD = 566;
+  PLACING = 567;
+  PLANS = 568;
+  POLICY = 569;
+  POSITION = 570;
+  PRECEDING = 571;
+  PRECISION = 572;
+  PRESERVE = 573;
+  PREPARE = 574;
+  PREPARED = 575;
+  PRIMARY = 576;
+  PRIOR = 577;
+  PRIVILEGES = 578;
+  PROCEDURAL = 579;
+  PROCEDURE = 580;
+  PROCEDURES = 581;
+  PROGRAM = 582;
+  PUBLICATION = 583;
+  QUOTE = 584;
+  RANGE = 585;
+  READ = 586;
+  REAL = 587;
+  REASSIGN = 588;
+  RECHECK = 589;
+  RECURSIVE = 590;
+  REF_P = 591;
+  REFERENCES = 592;
+  REFERENCING = 593;
+  REFRESH = 594;
+  REINDEX = 595;
+  RELATIVE_P = 596;
+  RELEASE = 597;
+  RENAME = 598;
+  REPEATABLE = 599;
+  REPLACE = 600;
+  REPLICA = 601;
+  RESET = 602;
+  RESTART = 603;
+  RESTRICT = 604;
+  RETURN = 605;
+  RETURNING = 606;
+  RETURNS = 607;
+  REVOKE = 608;
+  RIGHT = 609;
+  ROLE = 610;
+  ROLLBACK = 611;
+  ROLLUP = 612;
+  ROUTINE = 613;
+  ROUTINES = 614;
+  ROW = 615;
+  ROWS = 616;
+  RULE = 617;
+  SAVEPOINT = 618;
+  SCHEMA = 619;
+  SCHEMAS = 620;
+  SCROLL = 621;
+  SEARCH = 622;
+  SECOND_P = 623;
+  SECURITY = 624;
+  SELECT = 625;
+  SEQUENCE = 626;
+  SEQUENCES = 627;
+  SERIALIZABLE = 628;
+  SERVER = 629;
+  SESSION = 630;
+  SESSION_USER = 631;
+  SET = 632;
+  SETS = 633;
+  SETOF = 634;
+  SHARE = 635;
+  SHOW = 636;
+  SIMILAR = 637;
+  SIMPLE = 638;
+  SKIP = 639;
+  SMALLINT = 640;
+  SNAPSHOT = 641;
+  SOME = 642;
+  SQL_P = 643;
+  STABLE = 644;
+  STANDALONE_P = 645;
+  START = 646;
+  STATEMENT = 647;
+  STATISTICS = 648;
+  STDIN = 649;
+  STDOUT = 650;
+  STORAGE = 651;
+  STORED = 652;
+  STRICT_P = 653;
+  STRIP_P = 654;
+  SUBSCRIPTION = 655;
+  SUBSTRING = 656;
+  SUPPORT = 657;
+  SYMMETRIC = 658;
+  SYSID = 659;
+  SYSTEM_P = 660;
+  TABLE = 661;
+  TABLES = 662;
+  TABLESAMPLE = 663;
+  TABLESPACE = 664;
+  TEMP = 665;
+  TEMPLATE = 666;
+  TEMPORARY = 667;
+  TEXT_P = 668;
+  THEN = 669;
+  TIES = 670;
+  TIME = 671;
+  TIMESTAMP = 672;
+  TO = 673;
+  TRAILING = 674;
+  TRANSACTION = 675;
+  TRANSFORM = 676;
+  TREAT = 677;
+  TRIGGER = 678;
+  TRIM = 679;
+  TRUE_P = 680;
+  TRUNCATE = 681;
+  TRUSTED = 682;
+  TYPE_P = 683;
+  TYPES_P = 684;
+  UESCAPE = 685;
+  UNBOUNDED = 686;
+  UNCOMMITTED = 687;
+  UNENCRYPTED = 688;
+  UNION = 689;
+  UNIQUE = 690;
+  UNKNOWN = 691;
+  UNLISTEN = 692;
+  UNLOGGED = 693;
+  UNTIL = 694;
+  UPDATE = 695;
+  USER = 696;
+  USING = 697;
+  VACUUM = 698;
+  VALID = 699;
+  VALIDATE = 700;
+  VALIDATOR = 701;
+  VALUE_P = 702;
+  VALUES = 703;
+  VARCHAR = 704;
+  VARIADIC = 705;
+  VARYING = 706;
+  VERBOSE = 707;
+  VERSION_P = 708;
+  VIEW = 709;
+  VIEWS = 710;
+  VOLATILE = 711;
+  WHEN = 712;
+  WHERE = 713;
+  WHITESPACE_P = 714;
+  WINDOW = 715;
+  WITH = 716;
+  WITHIN = 717;
+  WITHOUT = 718;
+  WORK = 719;
+  WRAPPER = 720;
+  WRITE = 721;
+  XML_P = 722;
+  XMLATTRIBUTES = 723;
+  XMLCONCAT = 724;
+  XMLELEMENT = 725;
+  XMLEXISTS = 726;
+  XMLFOREST = 727;
+  XMLNAMESPACES = 728;
+  XMLPARSE = 729;
+  XMLPI = 730;
+  XMLROOT = 731;
+  XMLSERIALIZE = 732;
+  XMLTABLE = 733;
+  YEAR_P = 734;
+  YES_P = 735;
+  ZONE = 736;
+  NOT_LA = 737;
+  NULLS_LA = 738;
+  WITH_LA = 739;
+  MODE_TYPE_NAME = 740;
+  MODE_PLPGSQL_EXPR = 741;
+  MODE_PLPGSQL_ASSIGN1 = 742;
+  MODE_PLPGSQL_ASSIGN2 = 743;
+  MODE_PLPGSQL_ASSIGN3 = 744;
+  UMINUS = 745;
+}
diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
new file mode 100644
index 00000000..aa274f66
--- /dev/null
+++ b/crates/parser/src/bin/generate.rs
@@ -0,0 +1,148 @@
+use pg_query_proto_parser::{ProtoFile, ProtoParser};
+use sourcegen::{Attribute, Builder, Comment, Enum, Function, Implementation, Match, SourceFile};
+use std::fs;
+
+fn main() {
+    let parser = ProtoParser::new("./proto/source.proto");
+    let file = parser.parse();
+
+    fs::write(
+        "./src/syntax_kind_generated.rs",
+        generate_syntax_kind(&file),
+    )
+    .unwrap();
+}
+
+fn generate_pg_query_utils(f: &ProtoFile) -> String {
+    SourceFile::new()
+        .add_comment(
+            Comment::new("//!".to_string())
+                .with_text("Utilities for working with pg_query.rs".to_string())
+                .with_text("This file is generated from the libg_query proto".to_string())
+                .finish(),
+        )
+        .add_block(
+            Function::new("get_position_for_pg_query_node".to_string())
+                .public()
+                .with_parameter("node".to_string(), "&NodeRef".to_string())
+                .with_return_type("i32".to_string())
+                .with_body(
+                    Match::new("node".to_string())
+                        .with_arm(pattern, body)
+                        .finish(),
+                )
+                .finish(),
+        )
+        .finish()
+}
+
+fn generate_syntax_kind(f: &ProtoFile) -> String {
+    SourceFile::new()
+    .add_comment(
+        Comment::new("//!".to_string())
+        .with_text("This module bridges the gap between pg_query.rs nodes, and the `SyntaxKind` cstree requires.".to_string())
+        .with_text("The file is generated from the libg_query proto".to_string())
+        .finish()
+    )
+    .add_block(
+        Enum::new("SyntaxKind".to_string())
+        .public()
+        .with_comment("An u32 enum of all valid syntax elements (nodes and tokens) of the postgres sql dialect, and a few custom ones that are not parsed by pg_query.rs, such as `Whitespace`.".to_string())
+        .with_attribute(
+            Attribute::new("derive".to_string())
+            .with_argument("Copy".to_string(), None)
+            .with_argument("PartialEq".to_string(), None)
+            .with_argument("Eq".to_string(), None)
+            .with_argument("PartialOrd".to_string(), None)
+            .with_argument("Ord".to_string(), None)
+            .with_argument("Hash".to_string(), None)
+            .with_argument("Debug".to_string(), None)
+            .with_argument("Syntax".to_string(), None)
+            .finish()
+        )
+        .with_attribute(
+             Attribute::new("repr".to_string())
+            .with_argument("u32".to_string(), None)
+            .finish(),
+        )
+        .with(|b| {
+            vec![
+                "SourceFile".to_string(),
+                "Comment".to_string(),
+                "Whitespace".to_string(),
+                "Newline".to_string(),
+                "Tab".to_string(),
+                "Word".to_string(),
+                "Stmt".to_string(),
+            ].iter().for_each(|kind| {
+                b.with_value(kind.to_string(), None);
+            });
+
+            f.nodes.iter().for_each(|node| {
+                b.with_value(node.name.to_string(), None);
+            });
+
+            f.tokens.iter().for_each(|token| {
+                b.with_value(token.name.to_string(), None);
+            });
+
+            b
+        })
+        .finish()
+    )
+    .add_block(
+        Implementation::new("SyntaxKind".to_string())
+        .add_block(
+            Function::new("new_from_pg_query_node".to_string())
+            .public()
+            .with_comment(
+                Comment::new("//".to_string())
+                .with_text("Converts a `pg_query` node to a `SyntaxKind`".to_string())
+                .finish()
+            )
+            .with_return_type("Self".to_string())
+            .with_parameter("node".to_string(), "&NodeRef".to_string())
+            .with_body(
+                Match::new("node.kind()".to_string())
+                .with(|b| {
+                    f.nodes.iter().for_each(|node| {
+                        b.with_arm(
+                            format!("NodeRef::{}(_)", node.name.to_string()),
+                            format!("SyntaxKind::{}", node.name.to_string()),
+                        );
+                    });
+                    b
+                })
+                .finish()
+            )
+            .finish()
+        )
+        .add_block(
+            Function::new("new_from_pg_query_token".to_string())
+            .public()
+            .with_comment(
+                Comment::new("//".to_string())
+                .with_text("Converts a `pg_query` token to a `SyntaxKind`".to_string())
+                .finish()
+            )
+            .with_return_type("Self".to_string())
+            .with_parameter("token".to_string(), "&ScanToken".to_string())
+            .with_body(
+                Match::new("token.token".to_string())
+               .with(|b| {
+                   f.tokens.iter().for_each(|token| {
+                       b.with_arm(
+                           token.value.to_string(),
+                           format!("SyntaxKind::{}", token.name.to_string()),
+                       );
+                   });
+                   b
+               })
+               .finish()
+            )
+            .finish()
+        )
+        .finish()
+    )
+    .finish()
+}
diff --git a/crates/parser/src/pg_query_utils.rs b/crates/parser/src/pg_query_utils.rs
index 53fe07c5..5ed80ea2 100644
--- a/crates/parser/src/pg_query_utils.rs
+++ b/crates/parser/src/pg_query_utils.rs
@@ -1,4 +1,29 @@
-use pg_query::NodeRef;
+use pg_query::{Node, NodeRef};
+
+/// Returns the array children nodes
+pub fn get_flat_nodes<'a>(node: &'a NodeRef) -> Vec<NodeRef<'a>> {
+    match node {
+        NodeRef::CreateStmt(n) => {
+            let mut nodes: Vec<NodeRef> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .table_elts
+                    .iter()
+                    .map(|x| x.node.as_ref().unwrap().to_ref())
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .map(|x| x.node.as_ref().unwrap().to_ref())
+                    .collect(),
+            );
+            nodes
+        }
+        n => vec![n.clone()],
+    }
+}
 
 /// Gets the position value for a pg_query node
 ///
@@ -13,6 +38,253 @@ pub fn get_position_for_pg_query_node(node: &NodeRef) -> i32 {
         NodeRef::RangeVar(n) => n.location,
         NodeRef::ColumnRef(n) => n.location,
         NodeRef::AConst(n) => n.location,
+        NodeRef::Alias(n) => todo!("Alias"),
+        NodeRef::TableFunc(n) => n.location,
+        NodeRef::Expr(n) => todo!("Expr"),
+        NodeRef::Var(n) => n.location,
+        NodeRef::Param(n) => n.location,
+        NodeRef::Aggref(n) => n.location,
+        NodeRef::GroupingFunc(n) => n.location,
+        NodeRef::WindowFunc(n) => n.location,
+        NodeRef::SubscriptingRef(n) => todo!("SubscriptingRef"),
+        NodeRef::FuncExpr(n) => n.location,
+        NodeRef::NamedArgExpr(n) => n.location,
+        NodeRef::OpExpr(n) => n.location,
+        NodeRef::DistinctExpr(n) => n.location,
+        NodeRef::NullIfExpr(n) => n.location,
+        NodeRef::ScalarArrayOpExpr(n) => n.location,
+        NodeRef::BoolExpr(n) => n.location,
+        NodeRef::SubLink(n) => n.location,
+        NodeRef::SubPlan(n) => {
+            get_position_for_pg_query_node(&n.xpr.as_ref().unwrap().node.as_ref().unwrap().to_ref())
+        }
+        NodeRef::AlternativeSubPlan(n) => todo!("AlternativeSubPlan"),
+        NodeRef::FieldSelect(n) => todo!("FieldSelect"),
+        NodeRef::FieldStore(n) => todo!("FieldStore"),
+        NodeRef::RelabelType(n) => n.location,
+        NodeRef::CoerceViaIo(n) => n.location,
+        NodeRef::ArrayCoerceExpr(n) => n.location,
+        NodeRef::ConvertRowtypeExpr(n) => n.location,
+        NodeRef::CollateExpr(n) => n.location,
+        NodeRef::CaseExpr(n) => n.location,
+        NodeRef::CaseWhen(n) => n.location,
+        NodeRef::CaseTestExpr(n) => todo!("CaseTestExpr"),
+        NodeRef::ArrayExpr(n) => n.location,
+        NodeRef::RowExpr(n) => n.location,
+        NodeRef::RowCompareExpr(n) => todo!("RowCompareExpr"),
+        NodeRef::CoalesceExpr(n) => n.location,
+        NodeRef::MinMaxExpr(n) => n.location,
+        NodeRef::SqlvalueFunction(n) => n.location,
+        NodeRef::XmlExpr(n) => n.location,
+        NodeRef::NullTest(n) => n.location,
+        NodeRef::BooleanTest(n) => n.location,
+        NodeRef::CoerceToDomain(n) => n.location,
+        NodeRef::CoerceToDomainValue(n) => n.location,
+        NodeRef::SetToDefault(n) => n.location,
+        NodeRef::CurrentOfExpr(n) => todo!("CurrentOfExpr"),
+        NodeRef::NextValueExpr(_) => todo!("NextValueExpr"),
+        NodeRef::InferenceElem(_) => todo!("InferenceElem"),
+        NodeRef::TargetEntry(_) => todo!("TargetEntry"),
+        NodeRef::RangeTblRef(_) => todo!("RangeTblRef"),
+        NodeRef::JoinExpr(_) => todo!("JoinExpr"),
+        NodeRef::FromExpr(_) => todo!("FromExpr"),
+        NodeRef::OnConflictExpr(_) => todo!("OnConflictExpr"),
+        NodeRef::IntoClause(_) => todo!("IntoClause"),
+        NodeRef::RawStmt(_) => todo!("RawStmt"),
+        NodeRef::Query(_) => todo!("Query"),
+        NodeRef::InsertStmt(_) => todo!("InsertStmt"),
+        NodeRef::DeleteStmt(_) => todo!("DeleteStmt"),
+        NodeRef::UpdateStmt(_) => todo!("UpdateStmt"),
+        NodeRef::SelectStmt(_) => todo!("SelectStmt"),
+        NodeRef::AlterTableStmt(_) => -1,
+        NodeRef::AlterTableCmd(_) => todo!("AlterTableCmd"),
+        NodeRef::AlterDomainStmt(_) => todo!("AlterDomainStmt"),
+        NodeRef::SetOperationStmt(_) => todo!("SetOperationStmt"),
+        NodeRef::GrantStmt(_) => -1,
+        NodeRef::GrantRoleStmt(_) => todo!("GrantRoleStmt"),
+        NodeRef::AlterDefaultPrivilegesStmt(_) => todo!("AlterDefaultPrivilegesStmt"),
+        NodeRef::ClosePortalStmt(_) => todo!("ClosePortalStmt"),
+        NodeRef::ClusterStmt(_) => todo!("ClusterStmt"),
+        NodeRef::CopyStmt(_) => todo!("CopyStmt"),
+        NodeRef::CreateStmt(_) => -1,
+        NodeRef::DefineStmt(_) => todo!("DefineStmt"),
+        NodeRef::DropStmt(_) => todo!("DropStmt"),
+        NodeRef::TruncateStmt(_) => todo!("TruncateStmt"),
+        NodeRef::CommentStmt(_) => todo!("CommentStmt"),
+        NodeRef::FetchStmt(_) => todo!("FetchStmt"),
+        NodeRef::IndexStmt(_) => todo!("IndexStmt"),
+        NodeRef::CreateFunctionStmt(_) => todo!("CreateFunctionStmt"),
+        NodeRef::AlterFunctionStmt(_) => todo!("AlterFunctionStmt"),
+        NodeRef::DoStmt(_) => todo!("DoStmt"),
+        NodeRef::RenameStmt(_) => todo!("RenameStmt"),
+        NodeRef::RuleStmt(_) => todo!("RuleStmt"),
+        NodeRef::NotifyStmt(_) => todo!("NotifyStmt"),
+        NodeRef::ListenStmt(_) => todo!("ListenStmt"),
+        NodeRef::UnlistenStmt(_) => todo!("UnlistenStmt"),
+        NodeRef::TransactionStmt(_) => todo!("TransactionStmt"),
+        NodeRef::ViewStmt(_) => todo!("ViewStmt"),
+        NodeRef::LoadStmt(_) => todo!("LoadStmt"),
+        NodeRef::CreateDomainStmt(_) => todo!("CreateDomainStmt"),
+        NodeRef::CreatedbStmt(_) => todo!("CreatedbStmt"),
+        NodeRef::DropdbStmt(_) => todo!("DropdbStmt"),
+        NodeRef::VacuumStmt(_) => todo!("VacuumStmt"),
+        NodeRef::ExplainStmt(_) => todo!("ExplainStmt"),
+        NodeRef::CreateTableAsStmt(_) => todo!("CreateTableAsStmt"),
+        NodeRef::CreateSeqStmt(_) => todo!("CreateSeqStmt"),
+        NodeRef::AlterSeqStmt(_) => todo!("AlterSeqStmt"),
+        NodeRef::VariableSetStmt(_) => todo!("VariableSetStmt"),
+        NodeRef::VariableShowStmt(_) => todo!("VariableShowStmt"),
+        NodeRef::DiscardStmt(_) => todo!("DiscardStmt"),
+        NodeRef::CreateTrigStmt(_) => todo!("CreateTrigStmt"),
+        NodeRef::CreatePlangStmt(_) => todo!("CreatePlangStmt"),
+        NodeRef::CreateRoleStmt(_) => todo!("CreateRoleStmt"),
+        NodeRef::AlterRoleStmt(_) => todo!("AlterRoleStmt"),
+        NodeRef::DropRoleStmt(_) => todo!("DropRoleStmt"),
+        NodeRef::LockStmt(_) => todo!("LockStmt"),
+        NodeRef::ConstraintsSetStmt(_) => todo!("ConstraintsSetStmt"),
+        NodeRef::ReindexStmt(_) => todo!("ReindexStmt"),
+        NodeRef::CheckPointStmt(_) => todo!("CheckPointStmt"),
+        NodeRef::CreateSchemaStmt(_) => todo!("CreateSchemaStmt"),
+        NodeRef::AlterDatabaseStmt(_) => todo!("AlterDatabaseStmt"),
+        NodeRef::AlterDatabaseSetStmt(_) => todo!("AlterDatabaseSetStmt"),
+        NodeRef::AlterRoleSetStmt(_) => todo!("AlterRoleSetStmt"),
+        NodeRef::CreateConversionStmt(_) => todo!("CreateConversionStmt"),
+        NodeRef::CreateCastStmt(_) => todo!("CreateCastStmt"),
+        NodeRef::CreateOpClassStmt(_) => todo!("CreateOpClassStmt"),
+        NodeRef::CreateOpFamilyStmt(_) => todo!("CreateOpFamilyStmt"),
+        NodeRef::AlterOpFamilyStmt(_) => todo!("AlterOpFamilyStmt"),
+        NodeRef::PrepareStmt(_) => todo!("PrepareStmt"),
+        NodeRef::ExecuteStmt(_) => todo!("ExecuteStmt"),
+        NodeRef::DeallocateStmt(_) => todo!("DeallocateStmt"),
+        NodeRef::DeclareCursorStmt(_) => todo!("DeclareCursorStmt"),
+        NodeRef::CreateTableSpaceStmt(_) => todo!("CreateTableSpaceStmt"),
+        NodeRef::DropTableSpaceStmt(_) => todo!("DropTableSpaceStmt"),
+        NodeRef::AlterObjectDependsStmt(_) => todo!("AlterObjectDependsStmt"),
+        NodeRef::AlterObjectSchemaStmt(_) => todo!("AlterObjectSchemaStmt"),
+        NodeRef::AlterOwnerStmt(_) => todo!("AlterOwnerStmt"),
+        NodeRef::AlterOperatorStmt(_) => todo!("AlterOperatorStmt"),
+        NodeRef::AlterTypeStmt(_) => todo!("AlterTypeStmt"),
+        NodeRef::DropOwnedStmt(_) => todo!("DropOwnedStmt"),
+        NodeRef::ReassignOwnedStmt(_) => todo!("ReassignOwnedStmt"),
+        NodeRef::CompositeTypeStmt(_) => todo!("CompositeTypeStmt"),
+        NodeRef::CreateEnumStmt(_) => todo!("CreateEnumStmt"),
+        NodeRef::CreateRangeStmt(_) => todo!("CreateRangeStmt"),
+        NodeRef::AlterEnumStmt(_) => todo!("AlterEnumStmt"),
+        NodeRef::AlterTsdictionaryStmt(_) => todo!("AlterTsdictionaryStmt"),
+        NodeRef::AlterTsconfigurationStmt(_) => todo!("AlterTsconfigurationStmt"),
+        NodeRef::CreateFdwStmt(_) => todo!("CreateFdwStmt"),
+        NodeRef::AlterFdwStmt(_) => todo!("AlterFdwStmt"),
+        NodeRef::CreateForeignServerStmt(_) => todo!("CreateForeignServerStmt"),
+        NodeRef::AlterForeignServerStmt(_) => todo!("AlterForeignServerStmt"),
+        NodeRef::CreateUserMappingStmt(_) => todo!("CreateUserMappingStmt"),
+        NodeRef::AlterUserMappingStmt(_) => todo!("AlterUserMappingStmt"),
+        NodeRef::DropUserMappingStmt(_) => todo!("DropUserMappingStmt"),
+        NodeRef::AlterTableSpaceOptionsStmt(_) => todo!("AlterTableSpaceOptionsStmt"),
+        NodeRef::AlterTableMoveAllStmt(_) => todo!("AlterTableMoveAllStmt"),
+        NodeRef::SecLabelStmt(_) => todo!("SecLabelStmt"),
+        NodeRef::CreateForeignTableStmt(_) => todo!("CreateForeignTableStmt"),
+        NodeRef::ImportForeignSchemaStmt(_) => todo!("ImportForeignSchemaStmt"),
+        NodeRef::CreateExtensionStmt(_) => todo!("CreateExtensionStmt"),
+        NodeRef::AlterExtensionStmt(_) => todo!("AlterExtensionStmt"),
+        NodeRef::AlterExtensionContentsStmt(_) => todo!("AlterExtensionContentsStmt"),
+        NodeRef::CreateEventTrigStmt(_) => todo!("CreateEventTrigStmt"),
+        NodeRef::AlterEventTrigStmt(_) => todo!("AlterEventTrigStmt"),
+        NodeRef::RefreshMatViewStmt(_) => todo!("RefreshMatViewStmt"),
+        NodeRef::ReplicaIdentityStmt(_) => todo!("ReplicaIdentityStmt"),
+        NodeRef::AlterSystemStmt(_) => todo!("AlterSystemStmt"),
+        NodeRef::CreatePolicyStmt(_) => todo!("CreatePolicyStmt"),
+        NodeRef::AlterPolicyStmt(_) => todo!("AlterPolicyStmt"),
+        NodeRef::CreateTransformStmt(_) => todo!("CreateTransformStmt"),
+        NodeRef::CreateAmStmt(_) => todo!("CreateAmStmt"),
+        NodeRef::CreatePublicationStmt(_) => todo!("CreatePublicationStmt"),
+        NodeRef::AlterPublicationStmt(_) => todo!("AlterPublicationStmt"),
+        NodeRef::CreateSubscriptionStmt(_) => todo!("CreateSubscriptionStmt"),
+        NodeRef::AlterSubscriptionStmt(_) => todo!("AlterSubscriptionStmt"),
+        NodeRef::DropSubscriptionStmt(_) => todo!("DropSubscriptionStmt"),
+        NodeRef::CreateStatsStmt(_) => todo!("CreateStatsStmt"),
+        NodeRef::AlterCollationStmt(_) => todo!("AlterCollationStmt"),
+        NodeRef::CallStmt(_) => todo!("CallStmt"),
+        NodeRef::AlterStatsStmt(_) => todo!("AlterStatsStmt"),
+        NodeRef::ParamRef(n) => n.location,
+        NodeRef::FuncCall(n) => n.location,
+        NodeRef::AStar(n) => todo!("AStar"),
+        NodeRef::AIndices(n) => todo!("AIndices"),
+        NodeRef::AIndirection(n) => todo!("AIndirection"),
+        NodeRef::AArrayExpr(n) => n.location,
+        NodeRef::MultiAssignRef(n) => todo!("MultiAssignRef"),
+        NodeRef::TypeCast(n) => n.location,
+        NodeRef::CollateClause(n) => n.location,
+        NodeRef::SortBy(n) => n.location,
+        NodeRef::WindowDef(n) => n.location,
+        NodeRef::RangeSubselect(n) => todo!("RangeSubselect"),
+        NodeRef::RangeFunction(n) => todo!("RangeFunction"),
+        NodeRef::RangeTableSample(n) => n.location,
+        NodeRef::RangeTableFunc(n) => n.location,
+        NodeRef::RangeTableFuncCol(n) => n.location,
+        NodeRef::TypeName(n) => n.location,
+        NodeRef::ColumnDef(n) => n.location,
+        NodeRef::IndexElem(n) => todo!("IndexElem"),
+        NodeRef::Constraint(n) => n.location,
+        NodeRef::DefElem(n) => n.location,
+        NodeRef::RangeTblEntry(n) => todo!("RangeTblEntry"),
+        NodeRef::RangeTblFunction(n) => todo!("RangeTblFunction"),
+        NodeRef::TableSampleClause(n) => todo!("TableSampleClause"),
+        NodeRef::WithCheckOption(n) => todo!("WithCheckOption"),
+        NodeRef::SortGroupClause(n) => todo!("SortGroupClause"),
+        NodeRef::GroupingSet(n) => n.location,
+        NodeRef::WindowClause(n) => todo!("WindowClause"),
+        NodeRef::ObjectWithArgs(n) => todo!("ObjectWithArgs"),
+        NodeRef::AccessPriv(n) => todo!("AccessPriv"),
+        NodeRef::CreateOpClassItem(n) => todo!("CreateOpClassItem"),
+        NodeRef::TableLikeClause(n) => todo!("TableLikeClause"),
+        NodeRef::FunctionParameter(n) => todo!("FunctionParameter"),
+        NodeRef::LockingClause(n) => todo!("LockingClause"),
+        NodeRef::RowMarkClause(n) => todo!("RowMarkClause"),
+        NodeRef::XmlSerialize(n) => n.location,
+        NodeRef::WithClause(n) => n.location,
+        NodeRef::InferClause(n) => n.location,
+        NodeRef::OnConflictClause(n) => n.location,
+        NodeRef::CommonTableExpr(n) => n.location,
+        NodeRef::RoleSpec(n) => n.location,
+        NodeRef::TriggerTransition(n) => todo!("TriggerTransition"),
+        NodeRef::PartitionElem(n) => n.location,
+        NodeRef::PartitionSpec(n) => n.location,
+        NodeRef::PartitionBoundSpec(n) => n.location,
+        NodeRef::PartitionRangeDatum(n) => n.location,
+        NodeRef::PartitionCmd(n) => todo!("PartitionCmd"),
+        NodeRef::VacuumRelation(n) => todo!("VacuumRelation"),
+        NodeRef::InlineCodeBlock(n) => todo!("InlineCodeBlock"),
+        NodeRef::CallContext(n) => todo!("CallContext"),
+        NodeRef::Integer(n) => todo!("Integer"),
+        NodeRef::Float(n) => todo!("Float"),
+        NodeRef::String(n) => todo!("String"),
+        NodeRef::BitString(n) => todo!("BitString"),
+        NodeRef::Null(n) => todo!("Null"),
+        NodeRef::List(n) => todo!("List"),
+        NodeRef::IntList(n) => todo!("IntList"),
+        NodeRef::OidList(n) => todo!("OidList"),
         _ => -1,
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+    use std::fs;
+    use std::path::Path;
+
+    use super::*;
+
+    #[test]
+    fn test_get_flat_nodes() {
+        let input = "CREATE TABLE products (
+    product_no integer,
+    name text,
+    price numeric CHECK (price > 0),
+    discounted_price numeric CHECK (discounted_price > 0),
+    CHECK (price > discounted_price)
+);";
+
+        let parsed = pg_query::parse(input);
+    }
+}
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 6de2e1fe..57cf3e85 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -236,9 +236,13 @@ impl Parser {
 #[cfg(test)]
 mod tests {
     use std::assert_eq;
+    use std::fs;
+    use std::path::Path;
 
     use super::*;
 
+    const VALID_STATEMENTS_PATH: &str = "test_data/statements/valid/";
+
     #[test]
     fn test_statement_lexer() {
         let input = "select * from contact where id = '123 4 5';";
@@ -284,16 +288,44 @@ mod tests {
     }
 
     #[test]
-    fn test_statement_parser() {
-        let input = "select *,some_col from contact where id = '123 4 5';";
-
-        let mut parser = Parser::new();
-        parser.parse_statement(input, None);
-        let parsed = parser.finish();
-
-        dbg!(&parsed.cst);
+    fn test_valid_statements() {
+        let p = Path::new(VALID_STATEMENTS_PATH);
+        println!("path: {:?}", p.display());
+        fs::read_dir(VALID_STATEMENTS_PATH)
+            .unwrap()
+            .into_iter()
+            .for_each(|f| {
+                let path = f.unwrap().path();
+
+                let contents = fs::read_to_string(&path).unwrap();
+
+                println!("testing {}:\n'{}'", path.display(), contents);
+
+                let mut parser = Parser::new();
+                parser.parse_statement(&contents, None);
+                let parsed = parser.finish();
+
+                let fail = parsed.cst.text() != contents.as_str();
+
+                if fail == true {
+                    dbg!(&parsed.cst);
+                    let parsed = pg_query::parse(contents.as_str());
+                    match parsed {
+                        Ok(n) => {
+                            let proto = n.protobuf;
+                            proto.nodes().iter().for_each(|node| {
+                                println!("####");
+                                println!("{:?}", node);
+                            });
+                        }
+                        Err(e) => {
+                            dbg!(e);
+                        }
+                    }
+                }
 
-        assert_eq!(parsed.cst.text(), input);
+                assert_eq!(parsed.cst.text(), contents.as_str())
+            });
     }
 
     #[test]
diff --git a/crates/parser/src/syntax_kind.rs b/crates/parser/src/syntax_kind.rs
index a2f63b06..00558a71 100644
--- a/crates/parser/src/syntax_kind.rs
+++ b/crates/parser/src/syntax_kind.rs
@@ -804,12 +804,233 @@ impl SyntaxKind {
     pub fn from_pg_query_node(node: &NodeRef) -> Self {
         match node {
             NodeRef::SelectStmt(_) => SyntaxKind::SelectStmt,
+            NodeRef::Alias(_) => SyntaxKind::Alias,
+            NodeRef::RangeVar(_) => SyntaxKind::RangeVar,
+            NodeRef::TableFunc(_) => SyntaxKind::TableFunc,
+            NodeRef::Expr(_) => SyntaxKind::Expr,
+            NodeRef::Var(_) => SyntaxKind::Var,
+            NodeRef::Param(_) => SyntaxKind::Param,
+            NodeRef::Aggref(_) => SyntaxKind::Aggref,
+            NodeRef::GroupingFunc(_) => SyntaxKind::GroupingFunc,
+            NodeRef::WindowFunc(_) => SyntaxKind::WindowFunc,
+            NodeRef::SubscriptingRef(_) => SyntaxKind::SubscriptingRef,
+            NodeRef::FuncExpr(_) => SyntaxKind::FuncExpr,
+            NodeRef::NamedArgExpr(_) => SyntaxKind::NamedArgExpr,
+            NodeRef::OpExpr(_) => SyntaxKind::OpExpr,
+            NodeRef::DistinctExpr(_) => SyntaxKind::DistinctExpr,
+            NodeRef::NullIfExpr(_) => SyntaxKind::NullIfExpr,
+            NodeRef::ScalarArrayOpExpr(_) => SyntaxKind::ScalarArrayOpExpr,
+            NodeRef::BoolExpr(_) => SyntaxKind::BoolExpr,
+            NodeRef::SubLink(_) => SyntaxKind::SubLink,
+            NodeRef::SubPlan(_) => SyntaxKind::SubPlan,
+            NodeRef::AlternativeSubPlan(_) => SyntaxKind::AlternativeSubPlan,
+            NodeRef::FieldSelect(_) => SyntaxKind::FieldSelect,
+            NodeRef::FieldStore(_) => SyntaxKind::FieldStore,
+            NodeRef::RelabelType(_) => SyntaxKind::RelabelType,
+            NodeRef::CoerceViaIo(_) => SyntaxKind::CoerceViaIo,
+            NodeRef::ArrayCoerceExpr(_) => SyntaxKind::ArrayCoerceExpr,
+            NodeRef::ConvertRowtypeExpr(_) => SyntaxKind::ConvertRowtypeExpr,
+            NodeRef::CollateExpr(_) => SyntaxKind::CollateExpr,
+            NodeRef::CaseExpr(_) => SyntaxKind::CaseExpr,
+            NodeRef::CaseWhen(_) => SyntaxKind::CaseWhen,
+            NodeRef::CaseTestExpr(_) => SyntaxKind::CaseTestExpr,
+            NodeRef::ArrayExpr(_) => SyntaxKind::ArrayExpr,
+            NodeRef::RowExpr(_) => SyntaxKind::RowExpr,
+            NodeRef::RowCompareExpr(_) => SyntaxKind::RowCompareExpr,
+            NodeRef::CoalesceExpr(_) => SyntaxKind::CoalesceExpr,
+            NodeRef::MinMaxExpr(_) => SyntaxKind::MinMaxExpr,
+            NodeRef::SqlvalueFunction(_) => SyntaxKind::SqlvalueFunction,
+            NodeRef::XmlExpr(_) => SyntaxKind::XmlExpr,
+            NodeRef::NullTest(_) => SyntaxKind::NullTest,
+            NodeRef::BooleanTest(_) => SyntaxKind::BooleanTest,
+            NodeRef::CoerceToDomain(_) => SyntaxKind::CoerceToDomain,
+            NodeRef::CoerceToDomainValue(_) => SyntaxKind::CoerceToDomainValue,
+            NodeRef::SetToDefault(_) => SyntaxKind::SetToDefault,
+            NodeRef::CurrentOfExpr(_) => SyntaxKind::CurrentOfExpr,
+            NodeRef::NextValueExpr(_) => SyntaxKind::NextValueExpr,
+            NodeRef::InferenceElem(_) => SyntaxKind::InferenceElem,
+            NodeRef::TargetEntry(_) => SyntaxKind::TargetEntry,
+            NodeRef::RangeTblRef(_) => SyntaxKind::RangeTblRef,
+            NodeRef::JoinExpr(_) => SyntaxKind::JoinExpr,
+            NodeRef::FromExpr(_) => SyntaxKind::FromExpr,
+            NodeRef::OnConflictExpr(_) => SyntaxKind::OnConflictExpr,
+            NodeRef::IntoClause(_) => SyntaxKind::IntoClause,
+            NodeRef::RawStmt(_) => SyntaxKind::RawStmt,
+            NodeRef::Query(_) => SyntaxKind::Query,
+            NodeRef::InsertStmt(_) => SyntaxKind::InsertStmt,
+            NodeRef::DeleteStmt(_) => SyntaxKind::DeleteStmt,
+            NodeRef::UpdateStmt(_) => SyntaxKind::UpdateStmt,
+            NodeRef::AlterTableStmt(_) => SyntaxKind::AlterTableStmt,
+            NodeRef::AlterTableCmd(_) => SyntaxKind::AlterTableCmd,
+            NodeRef::AlterDomainStmt(_) => SyntaxKind::AlterDomainStmt,
+            NodeRef::SetOperationStmt(_) => SyntaxKind::SetOperationStmt,
+            NodeRef::GrantStmt(_) => SyntaxKind::GrantStmt,
+            NodeRef::GrantRoleStmt(_) => SyntaxKind::GrantRoleStmt,
+            NodeRef::AlterDefaultPrivilegesStmt(_) => SyntaxKind::AlterDefaultPrivilegesStmt,
+            NodeRef::ClosePortalStmt(_) => SyntaxKind::ClosePortalStmt,
+            NodeRef::ClusterStmt(_) => SyntaxKind::ClusterStmt,
+            NodeRef::CopyStmt(_) => SyntaxKind::CopyStmt,
+            NodeRef::CreateStmt(_) => SyntaxKind::CreateStmt,
+            NodeRef::DefineStmt(_) => SyntaxKind::DefineStmt,
+            NodeRef::DropStmt(_) => SyntaxKind::DropStmt,
+            NodeRef::TruncateStmt(_) => SyntaxKind::TruncateStmt,
+            NodeRef::CommentStmt(_) => SyntaxKind::CommentStmt,
+            NodeRef::FetchStmt(_) => SyntaxKind::FetchStmt,
+            NodeRef::IndexStmt(_) => SyntaxKind::IndexStmt,
             NodeRef::CreateFunctionStmt(_) => SyntaxKind::CreateFunctionStmt,
-            NodeRef::ResTarget(_) => SyntaxKind::ResTarget,
+            NodeRef::AlterFunctionStmt(_) => SyntaxKind::AlterFunctionStmt,
+            NodeRef::DoStmt(_) => SyntaxKind::DoStmt,
+            NodeRef::RenameStmt(_) => SyntaxKind::RenameStmt,
+            NodeRef::RuleStmt(_) => SyntaxKind::RuleStmt,
+            NodeRef::NotifyStmt(_) => SyntaxKind::NotifyStmt,
+            NodeRef::ListenStmt(_) => SyntaxKind::ListenStmt,
+            NodeRef::UnlistenStmt(_) => SyntaxKind::UnlistenStmt,
+            NodeRef::TransactionStmt(_) => SyntaxKind::TransactionStmt,
+            NodeRef::ViewStmt(_) => SyntaxKind::ViewStmt,
+            NodeRef::LoadStmt(_) => SyntaxKind::LoadStmt,
+            NodeRef::CreateDomainStmt(_) => SyntaxKind::CreateDomainStmt,
+            NodeRef::CreatedbStmt(_) => SyntaxKind::CreatedbStmt,
+            NodeRef::DropdbStmt(_) => SyntaxKind::DropdbStmt,
+            NodeRef::VacuumStmt(_) => SyntaxKind::VacuumStmt,
+            NodeRef::ExplainStmt(_) => SyntaxKind::ExplainStmt,
+            NodeRef::CreateTableAsStmt(_) => SyntaxKind::CreateTableAsStmt,
+            NodeRef::CreateSeqStmt(_) => SyntaxKind::CreateSeqStmt,
+            NodeRef::AlterSeqStmt(_) => SyntaxKind::AlterSeqStmt,
+            NodeRef::VariableSetStmt(_) => SyntaxKind::VariableSetStmt,
+            NodeRef::VariableShowStmt(_) => SyntaxKind::VariableShowStmt,
+            NodeRef::DiscardStmt(_) => SyntaxKind::DiscardStmt,
+            NodeRef::CreateTrigStmt(_) => SyntaxKind::CreateTrigStmt,
+            NodeRef::CreatePlangStmt(_) => SyntaxKind::CreatePlangStmt,
+            NodeRef::CreateRoleStmt(_) => SyntaxKind::CreateRoleStmt,
+            NodeRef::AlterRoleStmt(_) => SyntaxKind::AlterRoleStmt,
+            NodeRef::DropRoleStmt(_) => SyntaxKind::DropRoleStmt,
+            NodeRef::LockStmt(_) => SyntaxKind::LockStmt,
+            NodeRef::ConstraintsSetStmt(_) => SyntaxKind::ConstraintsSetStmt,
+            NodeRef::ReindexStmt(_) => SyntaxKind::ReindexStmt,
+            NodeRef::CheckPointStmt(_) => SyntaxKind::CheckPointStmt,
+            NodeRef::CreateSchemaStmt(_) => SyntaxKind::CreateSchemaStmt,
+            NodeRef::AlterDatabaseStmt(_) => SyntaxKind::AlterDatabaseStmt,
+            NodeRef::AlterDatabaseSetStmt(_) => SyntaxKind::AlterDatabaseSetStmt,
+            NodeRef::AlterRoleSetStmt(_) => SyntaxKind::AlterRoleSetStmt,
+            NodeRef::CreateConversionStmt(_) => SyntaxKind::CreateConversionStmt,
+            NodeRef::CreateCastStmt(_) => SyntaxKind::CreateCastStmt,
+            NodeRef::CreateOpClassStmt(_) => SyntaxKind::CreateOpClassStmt,
+            NodeRef::CreateOpFamilyStmt(_) => SyntaxKind::CreateOpFamilyStmt,
+            NodeRef::AlterOpFamilyStmt(_) => SyntaxKind::AlterOpFamilyStmt,
+            NodeRef::PrepareStmt(_) => SyntaxKind::PrepareStmt,
+            NodeRef::ExecuteStmt(_) => SyntaxKind::ExecuteStmt,
+            NodeRef::DeallocateStmt(_) => SyntaxKind::DeallocateStmt,
+            NodeRef::DeclareCursorStmt(_) => SyntaxKind::DeclareCursorStmt,
+            NodeRef::CreateTableSpaceStmt(_) => SyntaxKind::CreateTableSpaceStmt,
+            NodeRef::DropTableSpaceStmt(_) => SyntaxKind::DropTableSpaceStmt,
+            NodeRef::AlterObjectDependsStmt(_) => SyntaxKind::AlterObjectDependsStmt,
+            NodeRef::AlterObjectSchemaStmt(_) => SyntaxKind::AlterObjectSchemaStmt,
+            NodeRef::AlterOwnerStmt(_) => SyntaxKind::AlterOwnerStmt,
+            NodeRef::AlterOperatorStmt(_) => SyntaxKind::AlterOperatorStmt,
+            NodeRef::AlterTypeStmt(_) => SyntaxKind::AlterTypeStmt,
+            NodeRef::DropOwnedStmt(_) => SyntaxKind::DropOwnedStmt,
+            NodeRef::ReassignOwnedStmt(_) => SyntaxKind::ReassignOwnedStmt,
+            NodeRef::CompositeTypeStmt(_) => SyntaxKind::CompositeTypeStmt,
+            NodeRef::CreateEnumStmt(_) => SyntaxKind::CreateEnumStmt,
+            NodeRef::CreateRangeStmt(_) => SyntaxKind::CreateRangeStmt,
+            NodeRef::AlterEnumStmt(_) => SyntaxKind::AlterEnumStmt,
+            NodeRef::AlterTsdictionaryStmt(_) => SyntaxKind::AlterTsdictionaryStmt,
+            NodeRef::AlterTsconfigurationStmt(_) => SyntaxKind::AlterTsconfigurationStmt,
+            NodeRef::CreateFdwStmt(_) => SyntaxKind::CreateFdwStmt,
+            NodeRef::AlterFdwStmt(_) => SyntaxKind::AlterFdwStmt,
+            NodeRef::CreateForeignServerStmt(_) => SyntaxKind::CreateForeignServerStmt,
+            NodeRef::AlterForeignServerStmt(_) => SyntaxKind::AlterForeignServerStmt,
+            NodeRef::CreateUserMappingStmt(_) => SyntaxKind::CreateUserMappingStmt,
+            NodeRef::AlterUserMappingStmt(_) => SyntaxKind::AlterUserMappingStmt,
+            NodeRef::DropUserMappingStmt(_) => SyntaxKind::DropUserMappingStmt,
+            NodeRef::AlterTableSpaceOptionsStmt(_) => SyntaxKind::AlterTableSpaceOptionsStmt,
+            NodeRef::AlterTableMoveAllStmt(_) => SyntaxKind::AlterTableMoveAllStmt,
+            NodeRef::SecLabelStmt(_) => SyntaxKind::SecLabelStmt,
+            NodeRef::CreateForeignTableStmt(_) => SyntaxKind::CreateForeignTableStmt,
+            NodeRef::ImportForeignSchemaStmt(_) => SyntaxKind::ImportForeignSchemaStmt,
+            NodeRef::CreateExtensionStmt(_) => SyntaxKind::CreateExtensionStmt,
+            NodeRef::AlterExtensionStmt(_) => SyntaxKind::AlterExtensionStmt,
+            NodeRef::AlterExtensionContentsStmt(_) => SyntaxKind::AlterExtensionContentsStmt,
+            NodeRef::CreateEventTrigStmt(_) => SyntaxKind::CreateEventTrigStmt,
+            NodeRef::AlterEventTrigStmt(_) => SyntaxKind::AlterEventTrigStmt,
+            NodeRef::RefreshMatViewStmt(_) => SyntaxKind::RefreshMatViewStmt,
+            NodeRef::ReplicaIdentityStmt(_) => SyntaxKind::ReplicaIdentityStmt,
+            NodeRef::AlterSystemStmt(_) => SyntaxKind::AlterSystemStmt,
+            NodeRef::CreatePolicyStmt(_) => SyntaxKind::CreatePolicyStmt,
+            NodeRef::AlterPolicyStmt(_) => SyntaxKind::AlterPolicyStmt,
+            NodeRef::CreateTransformStmt(_) => SyntaxKind::CreateTransformStmt,
+            NodeRef::CreateAmStmt(_) => SyntaxKind::CreateAmStmt,
+            NodeRef::CreatePublicationStmt(_) => SyntaxKind::CreatePublicationStmt,
+            NodeRef::AlterPublicationStmt(_) => SyntaxKind::AlterPublicationStmt,
+            NodeRef::CreateSubscriptionStmt(_) => SyntaxKind::CreateSubscriptionStmt,
+            NodeRef::AlterSubscriptionStmt(_) => SyntaxKind::AlterSubscriptionStmt,
+            NodeRef::DropSubscriptionStmt(_) => SyntaxKind::DropSubscriptionStmt,
+            NodeRef::CreateStatsStmt(_) => SyntaxKind::CreateStatsStmt,
+            NodeRef::AlterCollationStmt(_) => SyntaxKind::AlterCollationStmt,
+            NodeRef::CallStmt(_) => SyntaxKind::CallStmt,
+            NodeRef::AlterStatsStmt(_) => SyntaxKind::AlterStatsStmt,
             NodeRef::AExpr(_) => SyntaxKind::AExpr,
-            NodeRef::RangeVar(_) => SyntaxKind::RangeVar,
             NodeRef::ColumnRef(_) => SyntaxKind::ColumnRef,
+            NodeRef::ParamRef(_) => SyntaxKind::ParamRef,
             NodeRef::AConst(_) => SyntaxKind::AConst,
+            NodeRef::FuncCall(_) => SyntaxKind::FuncCall,
+            NodeRef::AStar(_) => SyntaxKind::AStar,
+            NodeRef::AIndices(_) => SyntaxKind::AIndices,
+            NodeRef::AIndirection(_) => SyntaxKind::AIndirection,
+            NodeRef::AArrayExpr(_) => SyntaxKind::AArrayExpr,
+            NodeRef::ResTarget(_) => SyntaxKind::ResTarget,
+            NodeRef::MultiAssignRef(_) => SyntaxKind::MultiAssignRef,
+            NodeRef::TypeCast(_) => SyntaxKind::TypeCast,
+            NodeRef::CollateClause(_) => SyntaxKind::CollateClause,
+            NodeRef::SortBy(_) => SyntaxKind::SortBy,
+            NodeRef::WindowDef(_) => SyntaxKind::WindowDef,
+            NodeRef::RangeSubselect(_) => SyntaxKind::RangeSubselect,
+            NodeRef::RangeFunction(_) => SyntaxKind::RangeFunction,
+            NodeRef::RangeTableSample(_) => SyntaxKind::RangeTableSample,
+            NodeRef::RangeTableFunc(_) => SyntaxKind::RangeTableFunc,
+            NodeRef::RangeTableFuncCol(_) => SyntaxKind::RangeTableFuncCol,
+            NodeRef::TypeName(_) => SyntaxKind::TypeName,
+            NodeRef::ColumnDef(_) => SyntaxKind::ColumnDef,
+            NodeRef::IndexElem(_) => SyntaxKind::IndexElem,
+            NodeRef::Constraint(_) => SyntaxKind::Constraint,
+            NodeRef::DefElem(_) => SyntaxKind::DefElem,
+            NodeRef::RangeTblEntry(_) => SyntaxKind::RangeTblEntry,
+            NodeRef::RangeTblFunction(_) => SyntaxKind::RangeTblFunction,
+            NodeRef::TableSampleClause(_) => SyntaxKind::TableSampleClause,
+            NodeRef::WithCheckOption(_) => SyntaxKind::WithCheckOption,
+            NodeRef::SortGroupClause(_) => SyntaxKind::SortGroupClause,
+            NodeRef::GroupingSet(_) => SyntaxKind::GroupingSet,
+            NodeRef::WindowClause(_) => SyntaxKind::WindowClause,
+            NodeRef::ObjectWithArgs(_) => SyntaxKind::ObjectWithArgs,
+            NodeRef::AccessPriv(_) => SyntaxKind::AccessPriv,
+            NodeRef::CreateOpClassItem(_) => SyntaxKind::CreateOpClassItem,
+            NodeRef::TableLikeClause(_) => SyntaxKind::TableLikeClause,
+            NodeRef::FunctionParameter(_) => SyntaxKind::FunctionParameter,
+            NodeRef::LockingClause(_) => SyntaxKind::LockingClause,
+            NodeRef::RowMarkClause(_) => SyntaxKind::RowMarkClause,
+            NodeRef::XmlSerialize(_) => SyntaxKind::XmlSerialize,
+            NodeRef::WithClause(_) => SyntaxKind::WithClause,
+            NodeRef::InferClause(_) => SyntaxKind::InferClause,
+            NodeRef::OnConflictClause(_) => SyntaxKind::OnConflictClause,
+            NodeRef::CommonTableExpr(_) => SyntaxKind::CommonTableExpr,
+            NodeRef::RoleSpec(_) => SyntaxKind::RoleSpec,
+            NodeRef::TriggerTransition(_) => SyntaxKind::TriggerTransition,
+            NodeRef::PartitionElem(_) => SyntaxKind::PartitionElem,
+            NodeRef::PartitionSpec(_) => SyntaxKind::PartitionSpec,
+            NodeRef::PartitionBoundSpec(_) => SyntaxKind::PartitionBoundSpec,
+            NodeRef::PartitionRangeDatum(_) => SyntaxKind::PartitionRangeDatum,
+            NodeRef::PartitionCmd(_) => SyntaxKind::PartitionCmd,
+            NodeRef::VacuumRelation(_) => SyntaxKind::VacuumRelation,
+            NodeRef::InlineCodeBlock(_) => SyntaxKind::InlineCodeBlock,
+            NodeRef::CallContext(_) => SyntaxKind::CallContext,
+            NodeRef::Integer(_) => SyntaxKind::Integer,
+            NodeRef::Float(_) => SyntaxKind::Float,
+            NodeRef::String(_) => SyntaxKind::String,
+            NodeRef::BitString(_) => SyntaxKind::BitString,
+            NodeRef::Null(_) => SyntaxKind::Null,
+            NodeRef::List(_) => SyntaxKind::List,
+            NodeRef::IntList(_) => SyntaxKind::IntList,
+            NodeRef::OidList(_) => SyntaxKind::OidList,
             _ => panic!("Unknown node type: {:?}", node),
         }
     }
@@ -1319,14 +1540,498 @@ impl SyntaxKind {
     /// Maybe this can be generated from the ScanToken type in pg_query.rs
     pub fn get_type(&self) -> Option<SyntaxKindType> {
         match self {
+            SyntaxKind::Newline => Some(SyntaxKindType::Follow),
             SyntaxKind::Whitespace => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nul => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii37 => Some(SyntaxKindType::Follow),
             SyntaxKind::Ascii40 => Some(SyntaxKindType::Follow),
             SyntaxKind::Ascii41 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii42 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii43 => Some(SyntaxKindType::Follow),
             SyntaxKind::Ascii44 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii45 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii46 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii47 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii58 => Some(SyntaxKindType::Follow),
             SyntaxKind::Ascii59 => Some(SyntaxKindType::Close),
+            SyntaxKind::Ascii60 => Some(SyntaxKindType::Follow),
             SyntaxKind::Ascii61 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii62 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii63 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii91 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii92 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii93 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii94 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Uident => Some(SyntaxKindType::Follow),
+            SyntaxKind::Fconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Usconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Bconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Op => Some(SyntaxKindType::Follow),
+            SyntaxKind::Iconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Typecast => Some(SyntaxKindType::Follow),
+            SyntaxKind::DotDot => Some(SyntaxKindType::Follow),
+            SyntaxKind::ColonEquals => Some(SyntaxKindType::Follow),
+            SyntaxKind::EqualsGreater => Some(SyntaxKindType::Follow),
+            SyntaxKind::LessEquals => Some(SyntaxKindType::Follow),
+            SyntaxKind::GreaterEquals => Some(SyntaxKindType::Follow),
+            SyntaxKind::NotEquals => Some(SyntaxKindType::Follow),
+            SyntaxKind::SqlComment => Some(SyntaxKindType::Follow),
+            SyntaxKind::CComment => Some(SyntaxKindType::Follow),
+            SyntaxKind::AbortP => Some(SyntaxKindType::Follow),
+            SyntaxKind::AbsoluteP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Access => Some(SyntaxKindType::Follow),
+            SyntaxKind::Action => Some(SyntaxKindType::Follow),
+            SyntaxKind::AddP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Admin => Some(SyntaxKindType::Follow),
+            SyntaxKind::After => Some(SyntaxKindType::Follow),
+            SyntaxKind::Aggregate => Some(SyntaxKindType::Follow),
+            SyntaxKind::All => Some(SyntaxKindType::Follow),
+            SyntaxKind::Also => Some(SyntaxKindType::Follow),
+            SyntaxKind::Alter => Some(SyntaxKindType::Follow),
+            SyntaxKind::Always => Some(SyntaxKindType::Follow),
+            SyntaxKind::Analyse => Some(SyntaxKindType::Follow),
+            SyntaxKind::Analyze => Some(SyntaxKindType::Follow),
+            SyntaxKind::And => Some(SyntaxKindType::Follow),
+            SyntaxKind::Any => Some(SyntaxKindType::Follow),
+            SyntaxKind::Array => Some(SyntaxKindType::Follow),
+            SyntaxKind::As => Some(SyntaxKindType::Follow),
+            SyntaxKind::Asc => Some(SyntaxKindType::Follow),
+            SyntaxKind::Assertion => Some(SyntaxKindType::Follow),
+            SyntaxKind::Assignment => Some(SyntaxKindType::Follow),
+            SyntaxKind::Asymmetric => Some(SyntaxKindType::Follow),
+            SyntaxKind::At => Some(SyntaxKindType::Follow),
+            SyntaxKind::Attach => Some(SyntaxKindType::Follow),
+            SyntaxKind::Attribute => Some(SyntaxKindType::Follow),
+            SyntaxKind::Authorization => Some(SyntaxKindType::Follow),
+            SyntaxKind::Backward => Some(SyntaxKindType::Follow),
+            SyntaxKind::Before => Some(SyntaxKindType::Follow),
+            SyntaxKind::BeginP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Between => Some(SyntaxKindType::Follow),
+            SyntaxKind::Bigint => Some(SyntaxKindType::Follow),
+            SyntaxKind::Binary => Some(SyntaxKindType::Follow),
+            SyntaxKind::Bit => Some(SyntaxKindType::Follow),
+            SyntaxKind::BooleanP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Both => Some(SyntaxKindType::Follow),
+            SyntaxKind::By => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cache => Some(SyntaxKindType::Follow),
+            SyntaxKind::Call => Some(SyntaxKindType::Follow),
+            SyntaxKind::Called => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cascade => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cascaded => Some(SyntaxKindType::Follow),
+            SyntaxKind::Case => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cast => Some(SyntaxKindType::Follow),
+            SyntaxKind::CatalogP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Chain => Some(SyntaxKindType::Follow),
+            SyntaxKind::CharP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Character => Some(SyntaxKindType::Follow),
+            SyntaxKind::Characteristics => Some(SyntaxKindType::Follow),
+            SyntaxKind::Check => Some(SyntaxKindType::Follow),
+            SyntaxKind::Checkpoint => Some(SyntaxKindType::Follow),
+            SyntaxKind::Class => Some(SyntaxKindType::Follow),
+            SyntaxKind::Close => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cluster => Some(SyntaxKindType::Follow),
+            SyntaxKind::Coalesce => Some(SyntaxKindType::Follow),
+            SyntaxKind::Collate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Collation => Some(SyntaxKindType::Follow),
+            SyntaxKind::Column => Some(SyntaxKindType::Follow),
+            SyntaxKind::Columns => Some(SyntaxKindType::Follow),
+            SyntaxKind::Comments => Some(SyntaxKindType::Follow),
+            SyntaxKind::Commit => Some(SyntaxKindType::Follow),
+            SyntaxKind::Committed => Some(SyntaxKindType::Follow),
+            SyntaxKind::Concurrently => Some(SyntaxKindType::Follow),
+            SyntaxKind::Configuration => Some(SyntaxKindType::Follow),
+            SyntaxKind::Conflict => Some(SyntaxKindType::Follow),
+            SyntaxKind::Connection => Some(SyntaxKindType::Follow),
+            SyntaxKind::Constraints => Some(SyntaxKindType::Follow),
+            SyntaxKind::ContentP => Some(SyntaxKindType::Follow),
+            SyntaxKind::ContinueP => Some(SyntaxKindType::Follow),
+            SyntaxKind::ConversionP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Copy => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cost => Some(SyntaxKindType::Follow),
+            SyntaxKind::Create => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cross => Some(SyntaxKindType::Follow),
+            SyntaxKind::Csv => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cube => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentP => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentCatalog => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentDate => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentRole => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentSchema => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentTime => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentTimestamp => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentUser => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cursor => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cycle => Some(SyntaxKindType::Follow),
+            SyntaxKind::DataP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Database => Some(SyntaxKindType::Follow),
+            SyntaxKind::DayP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Deallocate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Dec => Some(SyntaxKindType::Follow),
+            SyntaxKind::DecimalP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Declare => Some(SyntaxKindType::Follow),
+            SyntaxKind::Default => Some(SyntaxKindType::Follow),
+            SyntaxKind::Defaults => Some(SyntaxKindType::Follow),
+            SyntaxKind::Deferrable => Some(SyntaxKindType::Follow),
+            SyntaxKind::Deferred => Some(SyntaxKindType::Follow),
+            SyntaxKind::Definer => Some(SyntaxKindType::Follow),
+            SyntaxKind::DeleteP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Delimiter => Some(SyntaxKindType::Follow),
+            SyntaxKind::Delimiters => Some(SyntaxKindType::Follow),
+            SyntaxKind::Depends => Some(SyntaxKindType::Follow),
+            SyntaxKind::Desc => Some(SyntaxKindType::Follow),
+            SyntaxKind::Detach => Some(SyntaxKindType::Follow),
+            SyntaxKind::Dictionary => Some(SyntaxKindType::Follow),
+            SyntaxKind::DisableP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Discard => Some(SyntaxKindType::Follow),
+            SyntaxKind::Distinct => Some(SyntaxKindType::Follow),
+            SyntaxKind::Do => Some(SyntaxKindType::Follow),
+            SyntaxKind::DocumentP => Some(SyntaxKindType::Follow),
+            SyntaxKind::DomainP => Some(SyntaxKindType::Follow),
+            SyntaxKind::DoubleP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Drop => Some(SyntaxKindType::Follow),
+            SyntaxKind::Each => Some(SyntaxKindType::Follow),
+            SyntaxKind::Else => Some(SyntaxKindType::Follow),
+            SyntaxKind::EnableP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Encoding => Some(SyntaxKindType::Follow),
+            SyntaxKind::Encrypted => Some(SyntaxKindType::Follow),
+            SyntaxKind::EndP => Some(SyntaxKindType::Follow),
+            SyntaxKind::EnumP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Escape => Some(SyntaxKindType::Follow),
+            SyntaxKind::Event => Some(SyntaxKindType::Follow),
+            SyntaxKind::Except => Some(SyntaxKindType::Follow),
+            SyntaxKind::Exclude => Some(SyntaxKindType::Follow),
+            SyntaxKind::Excluding => Some(SyntaxKindType::Follow),
+            SyntaxKind::Exclusive => Some(SyntaxKindType::Follow),
+            SyntaxKind::Execute => Some(SyntaxKindType::Follow),
+            SyntaxKind::Exists => Some(SyntaxKindType::Follow),
+            SyntaxKind::Explain => Some(SyntaxKindType::Follow),
+            SyntaxKind::Expression => Some(SyntaxKindType::Follow),
+            SyntaxKind::Extension => Some(SyntaxKindType::Follow),
+            SyntaxKind::External => Some(SyntaxKindType::Follow),
+            SyntaxKind::Extract => Some(SyntaxKindType::Follow),
+            SyntaxKind::FalseP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Family => Some(SyntaxKindType::Follow),
+            SyntaxKind::Fetch => Some(SyntaxKindType::Follow),
+            SyntaxKind::Filter => Some(SyntaxKindType::Follow),
+            SyntaxKind::FirstP => Some(SyntaxKindType::Follow),
+            SyntaxKind::FloatP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Following => Some(SyntaxKindType::Follow),
+            SyntaxKind::For => Some(SyntaxKindType::Follow),
+            SyntaxKind::Force => Some(SyntaxKindType::Follow),
+            SyntaxKind::Foreign => Some(SyntaxKindType::Follow),
+            SyntaxKind::Forward => Some(SyntaxKindType::Follow),
+            SyntaxKind::Freeze => Some(SyntaxKindType::Follow),
             SyntaxKind::From => Some(SyntaxKindType::Follow),
+            SyntaxKind::Full => Some(SyntaxKindType::Follow),
+            SyntaxKind::Function => Some(SyntaxKindType::Follow),
+            SyntaxKind::Functions => Some(SyntaxKindType::Follow),
+            SyntaxKind::Generated => Some(SyntaxKindType::Follow),
+            SyntaxKind::Global => Some(SyntaxKindType::Follow),
+            SyntaxKind::Grant => Some(SyntaxKindType::Follow),
+            SyntaxKind::Granted => Some(SyntaxKindType::Follow),
+            SyntaxKind::Greatest => Some(SyntaxKindType::Follow),
+            SyntaxKind::GroupP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Grouping => Some(SyntaxKindType::Follow),
+            SyntaxKind::Groups => Some(SyntaxKindType::Follow),
+            SyntaxKind::Handler => Some(SyntaxKindType::Follow),
+            SyntaxKind::Having => Some(SyntaxKindType::Follow),
+            SyntaxKind::HeaderP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Hold => Some(SyntaxKindType::Follow),
+            SyntaxKind::HourP => Some(SyntaxKindType::Follow),
+            SyntaxKind::IdentityP => Some(SyntaxKindType::Follow),
+            SyntaxKind::IfP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ilike => Some(SyntaxKindType::Follow),
+            SyntaxKind::Immediate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Immutable => Some(SyntaxKindType::Follow),
+            SyntaxKind::ImplicitP => Some(SyntaxKindType::Follow),
+            SyntaxKind::ImportP => Some(SyntaxKindType::Follow),
+            SyntaxKind::InP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Include => Some(SyntaxKindType::Follow),
+            SyntaxKind::Including => Some(SyntaxKindType::Follow),
+            SyntaxKind::Increment => Some(SyntaxKindType::Follow),
+            SyntaxKind::Index => Some(SyntaxKindType::Follow),
+            SyntaxKind::Indexes => Some(SyntaxKindType::Follow),
+            SyntaxKind::Inherit => Some(SyntaxKindType::Follow),
+            SyntaxKind::Inherits => Some(SyntaxKindType::Follow),
+            SyntaxKind::Initially => Some(SyntaxKindType::Follow),
+            SyntaxKind::InlineP => Some(SyntaxKindType::Follow),
+            SyntaxKind::InnerP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Inout => Some(SyntaxKindType::Follow),
+            SyntaxKind::InputP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Insensitive => Some(SyntaxKindType::Follow),
+            SyntaxKind::Insert => Some(SyntaxKindType::Follow),
+            SyntaxKind::Instead => Some(SyntaxKindType::Follow),
+            SyntaxKind::IntP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Integer => Some(SyntaxKindType::Follow),
+            SyntaxKind::Intersect => Some(SyntaxKindType::Follow),
+            SyntaxKind::Interval => Some(SyntaxKindType::Follow),
+            SyntaxKind::Into => Some(SyntaxKindType::Follow),
+            SyntaxKind::Invoker => Some(SyntaxKindType::Follow),
+            SyntaxKind::Is => Some(SyntaxKindType::Follow),
+            SyntaxKind::Isnull => Some(SyntaxKindType::Follow),
+            SyntaxKind::Isolation => Some(SyntaxKindType::Follow),
+            SyntaxKind::Join => Some(SyntaxKindType::Follow),
+            SyntaxKind::Key => Some(SyntaxKindType::Follow),
+            SyntaxKind::Label => Some(SyntaxKindType::Follow),
+            SyntaxKind::Language => Some(SyntaxKindType::Follow),
+            SyntaxKind::LargeP => Some(SyntaxKindType::Follow),
+            SyntaxKind::LastP => Some(SyntaxKindType::Follow),
+            SyntaxKind::LateralP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Leading => Some(SyntaxKindType::Follow),
+            SyntaxKind::Leakproof => Some(SyntaxKindType::Follow),
+            SyntaxKind::Least => Some(SyntaxKindType::Follow),
+            SyntaxKind::Left => Some(SyntaxKindType::Follow),
+            SyntaxKind::Level => Some(SyntaxKindType::Follow),
+            SyntaxKind::Like => Some(SyntaxKindType::Follow),
+            SyntaxKind::Limit => Some(SyntaxKindType::Follow),
+            SyntaxKind::Listen => Some(SyntaxKindType::Follow),
+            SyntaxKind::Load => Some(SyntaxKindType::Follow),
+            SyntaxKind::Local => Some(SyntaxKindType::Follow),
+            SyntaxKind::Localtime => Some(SyntaxKindType::Follow),
+            SyntaxKind::Localtimestamp => Some(SyntaxKindType::Follow),
+            SyntaxKind::Location => Some(SyntaxKindType::Follow),
+            SyntaxKind::LockP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Locked => Some(SyntaxKindType::Follow),
+            SyntaxKind::Logged => Some(SyntaxKindType::Follow),
+            SyntaxKind::Mapping => Some(SyntaxKindType::Follow),
+            SyntaxKind::Match => Some(SyntaxKindType::Follow),
+            SyntaxKind::Materialized => Some(SyntaxKindType::Follow),
+            SyntaxKind::Maxvalue => Some(SyntaxKindType::Follow),
+            SyntaxKind::Method => Some(SyntaxKindType::Follow),
+            SyntaxKind::MinuteP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Minvalue => Some(SyntaxKindType::Follow),
+            SyntaxKind::Mode => Some(SyntaxKindType::Follow),
+            SyntaxKind::MonthP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Move => Some(SyntaxKindType::Follow),
+            SyntaxKind::NameP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Names => Some(SyntaxKindType::Follow),
+            SyntaxKind::National => Some(SyntaxKindType::Follow),
+            SyntaxKind::Natural => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nchar => Some(SyntaxKindType::Follow),
+            SyntaxKind::New => Some(SyntaxKindType::Follow),
+            SyntaxKind::Next => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nfc => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nfd => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nfkc => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nfkd => Some(SyntaxKindType::Follow),
+            SyntaxKind::No => Some(SyntaxKindType::Follow),
+            SyntaxKind::None => Some(SyntaxKindType::Follow),
+            SyntaxKind::Normalize => Some(SyntaxKindType::Follow),
+            SyntaxKind::Normalized => Some(SyntaxKindType::Follow),
+            SyntaxKind::Not => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nothing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Notify => Some(SyntaxKindType::Follow),
+            SyntaxKind::Notnull => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nowait => Some(SyntaxKindType::Follow),
+            SyntaxKind::NullP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nullif => Some(SyntaxKindType::Follow),
+            SyntaxKind::NullsP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Numeric => Some(SyntaxKindType::Follow),
+            SyntaxKind::ObjectP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Of => Some(SyntaxKindType::Follow),
+            SyntaxKind::Off => Some(SyntaxKindType::Follow),
+            SyntaxKind::Offset => Some(SyntaxKindType::Follow),
+            SyntaxKind::Oids => Some(SyntaxKindType::Follow),
+            SyntaxKind::Old => Some(SyntaxKindType::Follow),
+            SyntaxKind::On => Some(SyntaxKindType::Follow),
+            SyntaxKind::Only => Some(SyntaxKindType::Follow),
+            SyntaxKind::Operator => Some(SyntaxKindType::Follow),
+            SyntaxKind::Option => Some(SyntaxKindType::Follow),
+            SyntaxKind::Options => Some(SyntaxKindType::Follow),
+            SyntaxKind::Or => Some(SyntaxKindType::Follow),
+            SyntaxKind::Order => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ordinality => Some(SyntaxKindType::Follow),
+            SyntaxKind::Others => Some(SyntaxKindType::Follow),
+            SyntaxKind::OutP => Some(SyntaxKindType::Follow),
+            SyntaxKind::OuterP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Over => Some(SyntaxKindType::Follow),
+            SyntaxKind::Overlaps => Some(SyntaxKindType::Follow),
+            SyntaxKind::Overlay => Some(SyntaxKindType::Follow),
+            SyntaxKind::Overriding => Some(SyntaxKindType::Follow),
+            SyntaxKind::Owned => Some(SyntaxKindType::Follow),
+            SyntaxKind::Owner => Some(SyntaxKindType::Follow),
+            SyntaxKind::Parallel => Some(SyntaxKindType::Follow),
+            SyntaxKind::Parser => Some(SyntaxKindType::Follow),
+            SyntaxKind::Partial => Some(SyntaxKindType::Follow),
+            SyntaxKind::Partition => Some(SyntaxKindType::Follow),
+            SyntaxKind::Passing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Password => Some(SyntaxKindType::Follow),
+            SyntaxKind::Placing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Plans => Some(SyntaxKindType::Follow),
+            SyntaxKind::Policy => Some(SyntaxKindType::Follow),
+            SyntaxKind::Position => Some(SyntaxKindType::Follow),
+            SyntaxKind::Preceding => Some(SyntaxKindType::Follow),
+            SyntaxKind::Precision => Some(SyntaxKindType::Follow),
+            SyntaxKind::Preserve => Some(SyntaxKindType::Follow),
+            SyntaxKind::Prepare => Some(SyntaxKindType::Follow),
+            SyntaxKind::Prepared => Some(SyntaxKindType::Follow),
+            SyntaxKind::Primary => Some(SyntaxKindType::Follow),
+            SyntaxKind::Prior => Some(SyntaxKindType::Follow),
+            SyntaxKind::Privileges => Some(SyntaxKindType::Follow),
+            SyntaxKind::Procedural => Some(SyntaxKindType::Follow),
+            SyntaxKind::Procedure => Some(SyntaxKindType::Follow),
+            SyntaxKind::Procedures => Some(SyntaxKindType::Follow),
+            SyntaxKind::Program => Some(SyntaxKindType::Follow),
+            SyntaxKind::Publication => Some(SyntaxKindType::Follow),
+            SyntaxKind::Quote => Some(SyntaxKindType::Follow),
+            SyntaxKind::Range => Some(SyntaxKindType::Follow),
+            SyntaxKind::Read => Some(SyntaxKindType::Follow),
+            SyntaxKind::Real => Some(SyntaxKindType::Follow),
+            SyntaxKind::Reassign => Some(SyntaxKindType::Follow),
+            SyntaxKind::Recheck => Some(SyntaxKindType::Follow),
+            SyntaxKind::Recursive => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ref => Some(SyntaxKindType::Follow),
+            SyntaxKind::References => Some(SyntaxKindType::Follow),
+            SyntaxKind::Referencing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Refresh => Some(SyntaxKindType::Follow),
+            SyntaxKind::Reindex => Some(SyntaxKindType::Follow),
+            SyntaxKind::RelativeP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Release => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rename => Some(SyntaxKindType::Follow),
+            SyntaxKind::Repeatable => Some(SyntaxKindType::Follow),
+            SyntaxKind::Replace => Some(SyntaxKindType::Follow),
+            SyntaxKind::Replica => Some(SyntaxKindType::Follow),
+            SyntaxKind::Reset => Some(SyntaxKindType::Follow),
+            SyntaxKind::Restart => Some(SyntaxKindType::Follow),
+            SyntaxKind::Restrict => Some(SyntaxKindType::Follow),
+            SyntaxKind::Returning => Some(SyntaxKindType::Follow),
+            SyntaxKind::Returns => Some(SyntaxKindType::Follow),
+            SyntaxKind::Revoke => Some(SyntaxKindType::Follow),
+            SyntaxKind::Right => Some(SyntaxKindType::Follow),
+            SyntaxKind::Role => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rollback => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rollup => Some(SyntaxKindType::Follow),
+            SyntaxKind::Routine => Some(SyntaxKindType::Follow),
+            SyntaxKind::Routines => Some(SyntaxKindType::Follow),
+            SyntaxKind::Row => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rows => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rule => Some(SyntaxKindType::Follow),
+            SyntaxKind::Savepoint => Some(SyntaxKindType::Follow),
+            SyntaxKind::Schema => Some(SyntaxKindType::Follow),
+            SyntaxKind::Schemas => Some(SyntaxKindType::Follow),
+            SyntaxKind::Scroll => Some(SyntaxKindType::Follow),
+            SyntaxKind::Search => Some(SyntaxKindType::Follow),
+            SyntaxKind::SecondP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Security => Some(SyntaxKindType::Follow),
+            SyntaxKind::Select => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sequence => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sequences => Some(SyntaxKindType::Follow),
+            SyntaxKind::Serializable => Some(SyntaxKindType::Follow),
+            SyntaxKind::Server => Some(SyntaxKindType::Follow),
+            SyntaxKind::Session => Some(SyntaxKindType::Follow),
+            SyntaxKind::SessionUser => Some(SyntaxKindType::Follow),
+            SyntaxKind::Set => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sets => Some(SyntaxKindType::Follow),
+            SyntaxKind::Setof => Some(SyntaxKindType::Follow),
+            SyntaxKind::Share => Some(SyntaxKindType::Follow),
+            SyntaxKind::Show => Some(SyntaxKindType::Follow),
+            SyntaxKind::Similar => Some(SyntaxKindType::Follow),
+            SyntaxKind::Simple => Some(SyntaxKindType::Follow),
+            SyntaxKind::Skip => Some(SyntaxKindType::Follow),
+            SyntaxKind::Smallint => Some(SyntaxKindType::Follow),
+            SyntaxKind::Snapshot => Some(SyntaxKindType::Follow),
+            SyntaxKind::Some => Some(SyntaxKindType::Follow),
+            SyntaxKind::SqlP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Stable => Some(SyntaxKindType::Follow),
+            SyntaxKind::StandaloneP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Start => Some(SyntaxKindType::Follow),
+            SyntaxKind::Statement => Some(SyntaxKindType::Follow),
+            SyntaxKind::Statistics => Some(SyntaxKindType::Follow),
+            SyntaxKind::Stdin => Some(SyntaxKindType::Follow),
+            SyntaxKind::Stdout => Some(SyntaxKindType::Follow),
+            SyntaxKind::Storage => Some(SyntaxKindType::Follow),
+            SyntaxKind::Stored => Some(SyntaxKindType::Follow),
+            SyntaxKind::StrictP => Some(SyntaxKindType::Follow),
+            SyntaxKind::StripP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Subscription => Some(SyntaxKindType::Follow),
+            SyntaxKind::Substring => Some(SyntaxKindType::Follow),
+            SyntaxKind::Support => Some(SyntaxKindType::Follow),
+            SyntaxKind::Symmetric => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sysid => Some(SyntaxKindType::Follow),
+            SyntaxKind::SystemP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Table => Some(SyntaxKindType::Follow),
+            SyntaxKind::Tables => Some(SyntaxKindType::Follow),
+            SyntaxKind::Tablesample => Some(SyntaxKindType::Follow),
+            SyntaxKind::Tablespace => Some(SyntaxKindType::Follow),
+            SyntaxKind::Temp => Some(SyntaxKindType::Follow),
+            SyntaxKind::Template => Some(SyntaxKindType::Follow),
+            SyntaxKind::Temporary => Some(SyntaxKindType::Follow),
+            SyntaxKind::TextP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Then => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ties => Some(SyntaxKindType::Follow),
+            SyntaxKind::Time => Some(SyntaxKindType::Follow),
+            SyntaxKind::Timestamp => Some(SyntaxKindType::Follow),
+            SyntaxKind::To => Some(SyntaxKindType::Follow),
+            SyntaxKind::Trailing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Transaction => Some(SyntaxKindType::Follow),
+            SyntaxKind::Transform => Some(SyntaxKindType::Follow),
+            SyntaxKind::Treat => Some(SyntaxKindType::Follow),
+            SyntaxKind::Trigger => Some(SyntaxKindType::Follow),
+            SyntaxKind::Trim => Some(SyntaxKindType::Follow),
+            SyntaxKind::TrueP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Truncate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Trusted => Some(SyntaxKindType::Follow),
+            SyntaxKind::TypeP => Some(SyntaxKindType::Follow),
+            SyntaxKind::TypesP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Uescape => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unbounded => Some(SyntaxKindType::Follow),
+            SyntaxKind::Uncommitted => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unencrypted => Some(SyntaxKindType::Follow),
+            SyntaxKind::Union => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unique => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unknown => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unlisten => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unlogged => Some(SyntaxKindType::Follow),
+            SyntaxKind::Until => Some(SyntaxKindType::Follow),
+            SyntaxKind::Update => Some(SyntaxKindType::Follow),
+            SyntaxKind::User => Some(SyntaxKindType::Follow),
+            SyntaxKind::Using => Some(SyntaxKindType::Follow),
+            SyntaxKind::Vacuum => Some(SyntaxKindType::Follow),
+            SyntaxKind::Valid => Some(SyntaxKindType::Follow),
+            SyntaxKind::Validate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Validator => Some(SyntaxKindType::Follow),
+            SyntaxKind::ValueP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Values => Some(SyntaxKindType::Follow),
+            SyntaxKind::Varchar => Some(SyntaxKindType::Follow),
+            SyntaxKind::Variadic => Some(SyntaxKindType::Follow),
+            SyntaxKind::Varying => Some(SyntaxKindType::Follow),
+            SyntaxKind::Verbose => Some(SyntaxKindType::Follow),
+            SyntaxKind::VersionP => Some(SyntaxKindType::Follow),
+            SyntaxKind::View => Some(SyntaxKindType::Follow),
+            SyntaxKind::Views => Some(SyntaxKindType::Follow),
+            SyntaxKind::Volatile => Some(SyntaxKindType::Follow),
+            SyntaxKind::When => Some(SyntaxKindType::Follow),
             SyntaxKind::Where => Some(SyntaxKindType::Follow),
+            SyntaxKind::WhitespaceP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Window => Some(SyntaxKindType::Follow),
+            SyntaxKind::With => Some(SyntaxKindType::Follow),
+            SyntaxKind::Within => Some(SyntaxKindType::Follow),
+            SyntaxKind::Without => Some(SyntaxKindType::Follow),
+            SyntaxKind::Work => Some(SyntaxKindType::Follow),
+            SyntaxKind::Wrapper => Some(SyntaxKindType::Follow),
+            SyntaxKind::Write => Some(SyntaxKindType::Follow),
+            SyntaxKind::XmlP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlattributes => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlconcat => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlelement => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlexists => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlforest => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlnamespaces => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlparse => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlpi => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlroot => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlserialize => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmltable => Some(SyntaxKindType::Follow),
+            SyntaxKind::YearP => Some(SyntaxKindType::Follow),
+            SyntaxKind::YesP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Zone => Some(SyntaxKindType::Follow),
+            SyntaxKind::NotLa => Some(SyntaxKindType::Follow),
+            SyntaxKind::NullsLa => Some(SyntaxKindType::Follow),
+            SyntaxKind::WithLa => Some(SyntaxKindType::Follow),
+            SyntaxKind::Postfixop => Some(SyntaxKindType::Follow),
+            SyntaxKind::Uminus => Some(SyntaxKindType::Follow),
             _ => None,
         }
     }
diff --git a/crates/parser/src/syntax_kind_generated.rs b/crates/parser/src/syntax_kind_generated.rs
new file mode 100644
index 00000000..f05c5678
--- /dev/null
+++ b/crates/parser/src/syntax_kind_generated.rs
@@ -0,0 +1,762 @@
+//! This module bridges the gap between pg_query.rs nodes, and the `SyntaxKind` cstree requires.
+//! It is generated from libg_query proto.
+
+/// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres sql dialect, and a few custom ones that are not parsed by pg_query.rs, such as `Whitespace`.
+#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Syntax)]
+#[repr(u32)]
+pub enum SyntaxKind {
+    SourceFile,
+    Comment,
+    Whitespace,
+    Newline,
+    Tab,
+    Word,
+    Stmt,
+    Alias,
+    RangeVar,
+    TableFunc,
+    Var,
+    Param,
+    Aggref,
+    GroupingFunc,
+    WindowFunc,
+    SubscriptingRef,
+    FuncExpr,
+    NamedArgExpr,
+    OpExpr,
+    DistinctExpr,
+    NullIfExpr,
+    ScalarArrayOpExpr,
+    BoolExpr,
+    SubLink,
+    SubPlan,
+    AlternativeSubPlan,
+    FieldSelect,
+    FieldStore,
+    RelabelType,
+    CoerceViaIO,
+    ArrayCoerceExpr,
+    ConvertRowtypeExpr,
+    CollateExpr,
+    CaseExpr,
+    CaseWhen,
+    CaseTestExpr,
+    ArrayExpr,
+    RowExpr,
+    RowCompareExpr,
+    CoalesceExpr,
+    MinMaxExpr,
+    SQLValueFunction,
+    XmlExpr,
+    NullTest,
+    BooleanTest,
+    CoerceToDomain,
+    CoerceToDomainValue,
+    SetToDefault,
+    CurrentOfExpr,
+    NextValueExpr,
+    InferenceElem,
+    TargetEntry,
+    RangeTblRef,
+    JoinExpr,
+    FromExpr,
+    OnConflictExpr,
+    IntoClause,
+    MergeAction,
+    RawStmt,
+    Query,
+    InsertStmt,
+    DeleteStmt,
+    UpdateStmt,
+    MergeStmt,
+    SelectStmt,
+    ReturnStmt,
+    PLAssignStmt,
+    AlterTableStmt,
+    AlterTableCmd,
+    AlterDomainStmt,
+    SetOperationStmt,
+    GrantStmt,
+    GrantRoleStmt,
+    AlterDefaultPrivilegesStmt,
+    ClosePortalStmt,
+    ClusterStmt,
+    CopyStmt,
+    CreateStmt,
+    DefineStmt,
+    DropStmt,
+    TruncateStmt,
+    CommentStmt,
+    FetchStmt,
+    IndexStmt,
+    CreateFunctionStmt,
+    AlterFunctionStmt,
+    DoStmt,
+    RenameStmt,
+    RuleStmt,
+    NotifyStmt,
+    ListenStmt,
+    UnlistenStmt,
+    TransactionStmt,
+    ViewStmt,
+    LoadStmt,
+    CreateDomainStmt,
+    CreatedbStmt,
+    DropdbStmt,
+    VacuumStmt,
+    ExplainStmt,
+    CreateTableAsStmt,
+    CreateSeqStmt,
+    AlterSeqStmt,
+    VariableSetStmt,
+    VariableShowStmt,
+    DiscardStmt,
+    CreateTrigStmt,
+    CreatePLangStmt,
+    CreateRoleStmt,
+    AlterRoleStmt,
+    DropRoleStmt,
+    LockStmt,
+    ConstraintsSetStmt,
+    ReindexStmt,
+    CheckPointStmt,
+    CreateSchemaStmt,
+    AlterDatabaseStmt,
+    AlterDatabaseRefreshCollStmt,
+    AlterDatabaseSetStmt,
+    AlterRoleSetStmt,
+    CreateConversionStmt,
+    CreateCastStmt,
+    CreateOpClassStmt,
+    CreateOpFamilyStmt,
+    AlterOpFamilyStmt,
+    PrepareStmt,
+    ExecuteStmt,
+    DeallocateStmt,
+    DeclareCursorStmt,
+    CreateTableSpaceStmt,
+    DropTableSpaceStmt,
+    AlterObjectDependsStmt,
+    AlterObjectSchemaStmt,
+    AlterOwnerStmt,
+    AlterOperatorStmt,
+    AlterTypeStmt,
+    DropOwnedStmt,
+    ReassignOwnedStmt,
+    CompositeTypeStmt,
+    CreateEnumStmt,
+    CreateRangeStmt,
+    AlterEnumStmt,
+    AlterTSDictionaryStmt,
+    AlterTSConfigurationStmt,
+    CreateFdwStmt,
+    AlterFdwStmt,
+    CreateForeignServerStmt,
+    AlterForeignServerStmt,
+    CreateUserMappingStmt,
+    AlterUserMappingStmt,
+    DropUserMappingStmt,
+    AlterTableSpaceOptionsStmt,
+    AlterTableMoveAllStmt,
+    SecLabelStmt,
+    CreateForeignTableStmt,
+    ImportForeignSchemaStmt,
+    CreateExtensionStmt,
+    AlterExtensionStmt,
+    AlterExtensionContentsStmt,
+    CreateEventTrigStmt,
+    AlterEventTrigStmt,
+    RefreshMatViewStmt,
+    ReplicaIdentityStmt,
+    AlterSystemStmt,
+    CreatePolicyStmt,
+    AlterPolicyStmt,
+    CreateTransformStmt,
+    CreateAmStmt,
+    CreatePublicationStmt,
+    AlterPublicationStmt,
+    CreateSubscriptionStmt,
+    AlterSubscriptionStmt,
+    DropSubscriptionStmt,
+    CreateStatsStmt,
+    AlterCollationStmt,
+    CallStmt,
+    AlterStatsStmt,
+    A_Expr,
+    ColumnRef,
+    ParamRef,
+    FuncCall,
+    A_Star,
+    A_Indices,
+    A_Indirection,
+    A_ArrayExpr,
+    ResTarget,
+    MultiAssignRef,
+    TypeCast,
+    CollateClause,
+    SortBy,
+    WindowDef,
+    RangeSubselect,
+    RangeFunction,
+    RangeTableSample,
+    RangeTableFunc,
+    RangeTableFuncCol,
+    TypeName,
+    ColumnDef,
+    IndexElem,
+    StatsElem,
+    Constraint,
+    DefElem,
+    RangeTblEntry,
+    RangeTblFunction,
+    TableSampleClause,
+    WithCheckOption,
+    SortGroupClause,
+    GroupingSet,
+    WindowClause,
+    ObjectWithArgs,
+    AccessPriv,
+    CreateOpClassItem,
+    TableLikeClause,
+    FunctionParameter,
+    LockingClause,
+    RowMarkClause,
+    XmlSerialize,
+    WithClause,
+    InferClause,
+    OnConflictClause,
+    CTESearchClause,
+    CTECycleClause,
+    CommonTableExpr,
+    MergeWhenClause,
+    RoleSpec,
+    TriggerTransition,
+    PartitionElem,
+    PartitionSpec,
+    PartitionBoundSpec,
+    PartitionRangeDatum,
+    PartitionCmd,
+    VacuumRelation,
+    PublicationObjSpec,
+    PublicationTable,
+    InlineCodeBlock,
+    CallContext,
+    Integer,
+    Float,
+    Boolean,
+    String,
+    BitString,
+    List,
+    IntList,
+    OidList,
+    A_Const,
+    Nul,
+    Ascii37,
+    Ascii40,
+    Ascii41,
+    Ascii42,
+    Ascii43,
+    Ascii44,
+    Ascii45,
+    Ascii46,
+    Ascii47,
+    Ascii58,
+    Ascii59,
+    Ascii60,
+    Ascii61,
+    Ascii62,
+    Ascii63,
+    Ascii91,
+    Ascii92,
+    Ascii93,
+    Ascii94,
+    Ident,
+    Uident,
+    Fconst,
+    Sconst,
+    Usconst,
+    Bconst,
+    Xconst,
+    Op,
+    Iconst,
+    Param,
+    Typecast,
+    DotDot,
+    ColonEquals,
+    EqualsGreater,
+    LessEquals,
+    GreaterEquals,
+    NotEquals,
+    SqlComment,
+    CComment,
+    AbortP,
+    AbsoluteP,
+    Access,
+    Action,
+    AddP,
+    Admin,
+    After,
+    Aggregate,
+    All,
+    Also,
+    Alter,
+    Always,
+    Analyse,
+    Analyze,
+    And,
+    Any,
+    Array,
+    As,
+    Asc,
+    Asensitive,
+    Assertion,
+    Assignment,
+    Asymmetric,
+    Atomic,
+    At,
+    Attach,
+    Attribute,
+    Authorization,
+    Backward,
+    Before,
+    BeginP,
+    Between,
+    Bigint,
+    Binary,
+    Bit,
+    BooleanP,
+    Both,
+    Breadth,
+    By,
+    Cache,
+    Call,
+    Called,
+    Cascade,
+    Cascaded,
+    Case,
+    Cast,
+    CatalogP,
+    Chain,
+    CharP,
+    Character,
+    Characteristics,
+    Check,
+    Checkpoint,
+    Class,
+    Close,
+    Cluster,
+    Coalesce,
+    Collate,
+    Collation,
+    Column,
+    Columns,
+    Comment,
+    Comments,
+    Commit,
+    Committed,
+    Compression,
+    Concurrently,
+    Configuration,
+    Conflict,
+    Connection,
+    Constraint,
+    Constraints,
+    ContentP,
+    ContinueP,
+    ConversionP,
+    Copy,
+    Cost,
+    Create,
+    Cross,
+    Csv,
+    Cube,
+    CurrentP,
+    CurrentCatalog,
+    CurrentDate,
+    CurrentRole,
+    CurrentSchema,
+    CurrentTime,
+    CurrentTimestamp,
+    CurrentUser,
+    Cursor,
+    Cycle,
+    DataP,
+    Database,
+    DayP,
+    Deallocate,
+    Dec,
+    DecimalP,
+    Declare,
+    Default,
+    Defaults,
+    Deferrable,
+    Deferred,
+    Definer,
+    DeleteP,
+    Delimiter,
+    Delimiters,
+    Depends,
+    Depth,
+    Desc,
+    Detach,
+    Dictionary,
+    DisableP,
+    Discard,
+    Distinct,
+    Do,
+    DocumentP,
+    DomainP,
+    DoubleP,
+    Drop,
+    Each,
+    Else,
+    EnableP,
+    Encoding,
+    Encrypted,
+    EndP,
+    EnumP,
+    Escape,
+    Event,
+    Except,
+    Exclude,
+    Excluding,
+    Exclusive,
+    Execute,
+    Exists,
+    Explain,
+    Expression,
+    Extension,
+    External,
+    Extract,
+    FalseP,
+    Family,
+    Fetch,
+    Filter,
+    Finalize,
+    FirstP,
+    FloatP,
+    Following,
+    For,
+    Force,
+    Foreign,
+    Forward,
+    Freeze,
+    From,
+    Full,
+    Function,
+    Functions,
+    Generated,
+    Global,
+    Grant,
+    Granted,
+    Greatest,
+    GroupP,
+    Grouping,
+    Groups,
+    Handler,
+    Having,
+    HeaderP,
+    Hold,
+    HourP,
+    IdentityP,
+    IfP,
+    Ilike,
+    Immediate,
+    Immutable,
+    ImplicitP,
+    ImportP,
+    InP,
+    Include,
+    Including,
+    Increment,
+    Index,
+    Indexes,
+    Inherit,
+    Inherits,
+    Initially,
+    InlineP,
+    InnerP,
+    Inout,
+    InputP,
+    Insensitive,
+    Insert,
+    Instead,
+    IntP,
+    Integer,
+    Intersect,
+    Interval,
+    Into,
+    Invoker,
+    Is,
+    Isnull,
+    Isolation,
+    Join,
+    Key,
+    Label,
+    Language,
+    LargeP,
+    LastP,
+    LateralP,
+    Leading,
+    Leakproof,
+    Least,
+    Left,
+    Level,
+    Like,
+    Limit,
+    Listen,
+    Load,
+    Local,
+    Localtime,
+    Localtimestamp,
+    Location,
+    LockP,
+    Locked,
+    Logged,
+    Mapping,
+    Match,
+    Matched,
+    Materialized,
+    Maxvalue,
+    Merge,
+    Method,
+    MinuteP,
+    Minvalue,
+    Mode,
+    MonthP,
+    Move,
+    NameP,
+    Names,
+    National,
+    Natural,
+    Nchar,
+    New,
+    Next,
+    Nfc,
+    Nfd,
+    Nfkc,
+    Nfkd,
+    No,
+    None,
+    Normalize,
+    Normalized,
+    Not,
+    Nothing,
+    Notify,
+    Notnull,
+    Nowait,
+    NullP,
+    Nullif,
+    NullsP,
+    Numeric,
+    ObjectP,
+    Of,
+    Off,
+    Offset,
+    Oids,
+    Old,
+    On,
+    Only,
+    Operator,
+    Option,
+    Options,
+    Or,
+    Order,
+    Ordinality,
+    Others,
+    OutP,
+    OuterP,
+    Over,
+    Overlaps,
+    Overlay,
+    Overriding,
+    Owned,
+    Owner,
+    Parallel,
+    Parameter,
+    Parser,
+    Partial,
+    Partition,
+    Passing,
+    Password,
+    Placing,
+    Plans,
+    Policy,
+    Position,
+    Preceding,
+    Precision,
+    Preserve,
+    Prepare,
+    Prepared,
+    Primary,
+    Prior,
+    Privileges,
+    Procedural,
+    Procedure,
+    Procedures,
+    Program,
+    Publication,
+    Quote,
+    Range,
+    Read,
+    Real,
+    Reassign,
+    Recheck,
+    Recursive,
+    RefP,
+    References,
+    Referencing,
+    Refresh,
+    Reindex,
+    RelativeP,
+    Release,
+    Rename,
+    Repeatable,
+    Replace,
+    Replica,
+    Reset,
+    Restart,
+    Restrict,
+    Return,
+    Returning,
+    Returns,
+    Revoke,
+    Right,
+    Role,
+    Rollback,
+    Rollup,
+    Routine,
+    Routines,
+    Row,
+    Rows,
+    Rule,
+    Savepoint,
+    Schema,
+    Schemas,
+    Scroll,
+    Search,
+    SecondP,
+    Security,
+    Select,
+    Sequence,
+    Sequences,
+    Serializable,
+    Server,
+    Session,
+    SessionUser,
+    Set,
+    Sets,
+    Setof,
+    Share,
+    Show,
+    Similar,
+    Simple,
+    Skip,
+    Smallint,
+    Snapshot,
+    Some,
+    SqlP,
+    Stable,
+    StandaloneP,
+    Start,
+    Statement,
+    Statistics,
+    Stdin,
+    Stdout,
+    Storage,
+    Stored,
+    StrictP,
+    StripP,
+    Subscription,
+    Substring,
+    Support,
+    Symmetric,
+    Sysid,
+    SystemP,
+    Table,
+    Tables,
+    Tablesample,
+    Tablespace,
+    Temp,
+    Template,
+    Temporary,
+    TextP,
+    Then,
+    Ties,
+    Time,
+    Timestamp,
+    To,
+    Trailing,
+    Transaction,
+    Transform,
+    Treat,
+    Trigger,
+    Trim,
+    TrueP,
+    Truncate,
+    Trusted,
+    TypeP,
+    TypesP,
+    Uescape,
+    Unbounded,
+    Uncommitted,
+    Unencrypted,
+    Union,
+    Unique,
+    Unknown,
+    Unlisten,
+    Unlogged,
+    Until,
+    Update,
+    User,
+    Using,
+    Vacuum,
+    Valid,
+    Validate,
+    Validator,
+    ValueP,
+    Values,
+    Varchar,
+    Variadic,
+    Varying,
+    Verbose,
+    VersionP,
+    View,
+    Views,
+    Volatile,
+    When,
+    Where,
+    WhitespaceP,
+    Window,
+    With,
+    Within,
+    Without,
+    Work,
+    Wrapper,
+    Write,
+    XmlP,
+    Xmlattributes,
+    Xmlconcat,
+    Xmlelement,
+    Xmlexists,
+    Xmlforest,
+    Xmlnamespaces,
+    Xmlparse,
+    Xmlpi,
+    Xmlroot,
+    Xmlserialize,
+    Xmltable,
+    YearP,
+    YesP,
+    Zone,
+    NotLa,
+    NullsLa,
+    WithLa,
+    ModeTypeName,
+    ModePlpgsqlExpr,
+    ModePlpgsqlAssign1,
+    ModePlpgsqlAssign2,
+    ModePlpgsqlAssign3,
+    Uminus,
+}
+
diff --git a/crates/parser/test_data/source/valid/0001.sql b/crates/parser/test_data/source/valid/0001.sql
new file mode 100644
index 00000000..82cc0bf0
--- /dev/null
+++ b/crates/parser/test_data/source/valid/0001.sql
@@ -0,0 +1,11 @@
+BEGIN;
+UPDATE accounts SET balance = balance - 100.00
+    WHERE name = 'Alice';
+SAVEPOINT my_savepoint;
+UPDATE accounts SET balance = balance + 100.00
+    WHERE name = 'Bob';
+-- oops ... forget that and use Wally's account
+ROLLBACK TO my_savepoint;
+UPDATE accounts SET balance = balance + 100.00
+    WHERE name = 'Wally';
+COMMIT;
diff --git a/crates/parser/test_data/statements/valid/0001.sql b/crates/parser/test_data/statements/valid/0001.sql
new file mode 100644
index 00000000..831b69ab
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0001.sql
@@ -0,0 +1,3 @@
+SELECT city, count(*) FILTER (WHERE temp_lo < 45), max(temp_lo)
+    FROM weather
+    GROUP BY city;
diff --git a/crates/parser/test_data/statements/valid/0002.sql b/crates/parser/test_data/statements/valid/0002.sql
new file mode 100644
index 00000000..938d1e40
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0002.sql
@@ -0,0 +1 @@
+COPY weather FROM '/home/user/weather.txt';
diff --git a/crates/parser/test_data/statements/valid/0003.sql b/crates/parser/test_data/statements/valid/0003.sql
new file mode 100644
index 00000000..0ac47170
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0003.sql
@@ -0,0 +1,7 @@
+CREATE TABLE weather (
+        city      varchar(80) references cities(name),
+        temp_lo   int,
+        temp_hi   int,
+        prcp      real,
+        date      date
+);
diff --git a/crates/parser/test_data/statements/valid/0004.sql b/crates/parser/test_data/statements/valid/0004.sql
new file mode 100644
index 00000000..e97f771f
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0004.sql
@@ -0,0 +1,4 @@
+CREATE VIEW myview AS
+    SELECT name, temp_lo, temp_hi, prcp, date, location
+        FROM weather, cities
+        WHERE city = name;
diff --git a/crates/parser/test_data/statements/valid/0005.sql b/crates/parser/test_data/statements/valid/0005.sql
new file mode 100644
index 00000000..136067af
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0005.sql
@@ -0,0 +1 @@
+DELETE FROM weather WHERE city = 'Hayward';
diff --git a/crates/parser/test_data/statements/valid/0006.sql b/crates/parser/test_data/statements/valid/0006.sql
new file mode 100644
index 00000000..664437a4
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0006.sql
@@ -0,0 +1 @@
+DROP TABLE tablename;
diff --git a/crates/parser/test_data/statements/valid/0007.sql b/crates/parser/test_data/statements/valid/0007.sql
new file mode 100644
index 00000000..f0e8fc3d
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0007.sql
@@ -0,0 +1,6 @@
+CREATE TABLE cities (
+  name       text,
+  population real,
+  elevation  int     -- (in ft)
+);
+
diff --git a/crates/parser/test_data/statements/valid/0008.sql b/crates/parser/test_data/statements/valid/0008.sql
new file mode 100644
index 00000000..308d8d2c
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0008.sql
@@ -0,0 +1,2 @@
+INSERT INTO weather (date, city, temp_hi, temp_lo)
+    VALUES ('1994-11-29', 'Hayward', 54, 37);
diff --git a/crates/parser/test_data/statements/valid/0009.sql b/crates/parser/test_data/statements/valid/0009.sql
new file mode 100644
index 00000000..d631c061
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0009.sql
@@ -0,0 +1,4 @@
+SELECT w1.city, w1.temp_lo AS low, w1.temp_hi AS high,
+       w2.city, w2.temp_lo AS low, w2.temp_hi AS high
+    FROM weather w1 JOIN weather w2
+        ON w1.temp_lo < w2.temp_lo AND w1.temp_hi > w2.temp_hi;
diff --git a/crates/parser/test_data/statements/valid/0010.sql b/crates/parser/test_data/statements/valid/0010.sql
new file mode 100644
index 00000000..97d05a75
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0010.sql
@@ -0,0 +1 @@
+INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');
diff --git a/crates/parser/test_data/statements/valid/0011.sql b/crates/parser/test_data/statements/valid/0011.sql
new file mode 100644
index 00000000..f1b088ca
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0011.sql
@@ -0,0 +1,3 @@
+SELECT DISTINCT city
+    FROM weather
+    ORDER BY city;
diff --git a/crates/parser/test_data/statements/valid/0012.sql b/crates/parser/test_data/statements/valid/0012.sql
new file mode 100644
index 00000000..15073751
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0012.sql
@@ -0,0 +1,4 @@
+CREATE TABLE measurement_y2008m01 PARTITION OF measurement
+    FOR VALUES FROM ('2008-01-01') TO ('2008-02-01')
+    WITH (parallel_workers = 4)
+    TABLESPACE fasttablespace;
diff --git a/crates/parser/test_data/statements/valid/0013.sql b/crates/parser/test_data/statements/valid/0013.sql
new file mode 100644
index 00000000..24154690
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0013.sql
@@ -0,0 +1,3 @@
+UPDATE weather
+    SET temp_hi = temp_hi - 2,  temp_lo = temp_lo - 2
+    WHERE date > '1994-11-28';
diff --git a/crates/parser/test_data/statements/valid/0014.sql b/crates/parser/test_data/statements/valid/0014.sql
new file mode 100644
index 00000000..aafd6fab
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0014.sql
@@ -0,0 +1,3 @@
+SELECT sum(salary) OVER w, avg(salary) OVER w
+  FROM empsalary
+  WINDOW w AS (PARTITION BY depname ORDER BY salary DESC);
diff --git a/crates/parser/test_data/statements/valid/0015.sql b/crates/parser/test_data/statements/valid/0015.sql
new file mode 100644
index 00000000..62866cad
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0015.sql
@@ -0,0 +1,4 @@
+SELECT
+    count(*) AS unfiltered,
+    count(*) FILTER (WHERE i < 5) AS filtered
+FROM generate_series(1,10) AS s(i);
diff --git a/crates/parser/test_data/statements/valid/0016.sql b/crates/parser/test_data/statements/valid/0016.sql
new file mode 100644
index 00000000..4d7ce856
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0016.sql
@@ -0,0 +1 @@
+SELECT * FROM tbl WHERE a COLLATE "C" > 'foo';
diff --git a/crates/parser/test_data/statements/valid/0017.sql b/crates/parser/test_data/statements/valid/0017.sql
new file mode 100644
index 00000000..f9d7b1f0
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0017.sql
@@ -0,0 +1,2 @@
+SELECT name, (SELECT max(pop) FROM cities WHERE cities.state = states.name)
+    FROM states;
diff --git a/crates/parser/test_data/statements/valid/0018.sql b/crates/parser/test_data/statements/valid/0018.sql
new file mode 100644
index 00000000..9ab1949a
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0018.sql
@@ -0,0 +1 @@
+SELECT ARRAY[1,2,22.7]::integer[];
diff --git a/crates/parser/test_data/statements/valid/0019.sql b/crates/parser/test_data/statements/valid/0019.sql
new file mode 100644
index 00000000..822511cf
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0019.sql
@@ -0,0 +1,4 @@
+SELECT CASE WHEN min(employees) > 0
+            THEN avg(expenses / employees)
+       END
+    FROM departments;
diff --git a/crates/parser/test_data/statements/valid/0020.sql b/crates/parser/test_data/statements/valid/0020.sql
new file mode 100644
index 00000000..989af6c2
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0020.sql
@@ -0,0 +1,10 @@
+CREATE FUNCTION concat_lower_or_upper(a text, b text, uppercase boolean DEFAULT false)
+RETURNS text
+AS
+$$
+ SELECT CASE
+        WHEN $3 THEN UPPER($1 || ' ' || $2)
+        ELSE LOWER($1 || ' ' || $2)
+        END;
+$$
+LANGUAGE SQL IMMUTABLE STRICT;
diff --git a/crates/parser/test_data/statements/valid/0021.sql b/crates/parser/test_data/statements/valid/0021.sql
new file mode 100644
index 00000000..155b7f48
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0021.sql
@@ -0,0 +1 @@
+SELECT concat_lower_or_upper(a => 'Hello', b => 'World', uppercase => true);
diff --git a/crates/parser/test_data/statements/valid/0022.sql b/crates/parser/test_data/statements/valid/0022.sql
new file mode 100644
index 00000000..f4cf2e26
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0022.sql
@@ -0,0 +1,5 @@
+CREATE TABLE products (
+    product_no integer,
+    name text,
+    price numeric DEFAULT 9.99
+);
diff --git a/crates/parser/test_data/statements/valid/0023.sql b/crates/parser/test_data/statements/valid/0023.sql
new file mode 100644
index 00000000..908e3839
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0023.sql
@@ -0,0 +1,7 @@
+CREATE TABLE products (
+    product_no integer,
+    name text,
+    price numeric CHECK (price > 0),
+    discounted_price numeric CHECK (discounted_price > 0),
+    CHECK (price > discounted_price)
+);
diff --git a/crates/parser/test_data/statements/valid/0024.sql b/crates/parser/test_data/statements/valid/0024.sql
new file mode 100644
index 00000000..0a97d2bd
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0024.sql
@@ -0,0 +1,6 @@
+CREATE TABLE order_items (
+    product_no integer REFERENCES products,
+    order_id integer REFERENCES orders,
+    quantity integer,
+    PRIMARY KEY (product_no, order_id)
+);
diff --git a/crates/parser/test_data/statements/valid/0025.sql b/crates/parser/test_data/statements/valid/0025.sql
new file mode 100644
index 00000000..a4872682
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0025.sql
@@ -0,0 +1 @@
+ALTER TABLE products ADD CHECK (name <> '');
diff --git a/crates/parser/test_data/statements/valid/0026.sql b/crates/parser/test_data/statements/valid/0026.sql
new file mode 100644
index 00000000..fc18e84d
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0026.sql
@@ -0,0 +1 @@
+ALTER TABLE products ALTER COLUMN price TYPE numeric(10,2);
diff --git a/crates/parser/test_data/statements/valid/0027.sql b/crates/parser/test_data/statements/valid/0027.sql
new file mode 100644
index 00000000..8b7e3047
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0027.sql
@@ -0,0 +1 @@
+GRANT UPDATE ON accounts TO joe;
diff --git a/crates/parser/test_data/statements/valid/0028.sql b/crates/parser/test_data/statements/valid/0028.sql
new file mode 100644
index 00000000..03fc8b91
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0028.sql
@@ -0,0 +1 @@
+REVOKE ALL ON accounts FROM PUBLIC;
diff --git a/crates/parser/test_data/statements/valid/0029.sql b/crates/parser/test_data/statements/valid/0029.sql
new file mode 100644
index 00000000..9612a088
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0029.sql
@@ -0,0 +1 @@
+GRANT SELECT (col1), UPDATE (col1) ON mytable TO miriam_rw;
diff --git a/crates/parser/test_data/statements/valid/0030.sql b/crates/parser/test_data/statements/valid/0030.sql
new file mode 100644
index 00000000..7a333a33
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0030.sql
@@ -0,0 +1,2 @@
+CREATE POLICY account_managers ON accounts TO managers
+    USING (manager = current_user);
diff --git a/crates/parser/test_data/statements/valid/0031.sql b/crates/parser/test_data/statements/valid/0031.sql
new file mode 100644
index 00000000..cdbb7b20
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0031.sql
@@ -0,0 +1,6 @@
+CREATE POLICY user_mod ON passwd FOR UPDATE
+  USING (current_user = user_name)
+  WITH CHECK (
+    current_user = user_name AND
+    shell IN ('/bin/bash','/bin/sh','/bin/dash','/bin/zsh','/bin/tcsh')
+  );
diff --git a/crates/parser/test_data/statements/valid/0032.sql b/crates/parser/test_data/statements/valid/0032.sql
new file mode 100644
index 00000000..6d28c679
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0032.sql
@@ -0,0 +1 @@
+SET search_path TO myschema,public;
diff --git a/crates/parser/test_data/statements/valid/0033.sql b/crates/parser/test_data/statements/valid/0033.sql
new file mode 100644
index 00000000..219c2e7b
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0033.sql
@@ -0,0 +1,6 @@
+CREATE TABLE measurement (
+    city_id         int not null,
+    logdate         date not null,
+    peaktemp        int,
+    unitsales       int
+) PARTITION BY RANGE (logdate);
diff --git a/crates/parser/test_data/statements/valid/0034.sql b/crates/parser/test_data/statements/valid/0034.sql
new file mode 100644
index 00000000..2e4bf534
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0034.sql
@@ -0,0 +1 @@
+select *,some_col from contact where id = '123 4 5';
diff --git a/crates/parser/test_data/statements/valid/0035.sql b/crates/parser/test_data/statements/valid/0035.sql
new file mode 100644
index 00000000..2e4bf534
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0035.sql
@@ -0,0 +1 @@
+select *,some_col from contact where id = '123 4 5';
diff --git a/crates/parser/test_data/statements/valid/0036.sql b/crates/parser/test_data/statements/valid/0036.sql
new file mode 100644
index 00000000..fd9214ce
--- /dev/null
+++ b/crates/parser/test_data/statements/valid/0036.sql
@@ -0,0 +1,3 @@
+CREATE FUNCTION dup(in int, out f1 int, out f2 text)
+    AS $$ SELECT $1, CAST($1 AS text) || ' is text' $$
+    LANGUAGE SQL;
diff --git a/crates/pg_query_proto_parser/Cargo.toml b/crates/pg_query_proto_parser/Cargo.toml
new file mode 100644
index 00000000..36679697
--- /dev/null
+++ b/crates/pg_query_proto_parser/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "pg_query_proto_parser"
+version = "0.0.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+protobuf-parse = "3.2.0"
+protobuf = "3.2.0"
+convert_case = "0.6.0"
diff --git a/crates/pg_query_proto_parser/src/lib.rs b/crates/pg_query_proto_parser/src/lib.rs
new file mode 100644
index 00000000..12f8cf9c
--- /dev/null
+++ b/crates/pg_query_proto_parser/src/lib.rs
@@ -0,0 +1,9 @@
+//! A parser for the libg_query proto file
+//!
+//! This crate provides a parser for the libg_query proto file, and a struct to represent and interact with the parsed file.
+
+mod proto_file;
+mod proto_parser;
+
+pub use crate::proto_file::{Field, FieldType, Node, ProtoFile, Token};
+pub use crate::proto_parser::ProtoParser;
diff --git a/crates/pg_query_proto_parser/src/proto_file.rs b/crates/pg_query_proto_parser/src/proto_file.rs
new file mode 100644
index 00000000..fd59932c
--- /dev/null
+++ b/crates/pg_query_proto_parser/src/proto_file.rs
@@ -0,0 +1,57 @@
+/// The FieldTypes of a protobuf message
+#[derive(Debug)]
+pub enum FieldType {
+    Node,
+    Double,
+    Float,
+    Int64,
+    Uint64,
+    Int32,
+    Fixed64,
+    Fixed32,
+    Bool,
+    String,
+    Group,
+    Message,
+    Bytes,
+    Uint32,
+    Enum,
+    Sfixed32,
+    Sfixed64,
+    Sint32,
+    Sint64,
+}
+
+/// A libg_query token
+#[derive(Debug)]
+pub struct Token {
+    pub name: String,
+    pub value: i32,
+}
+
+/// A libg_query field
+#[derive(Debug)]
+pub struct Field {
+    pub name: String,
+    pub field_type: FieldType,
+    pub repeated: bool,
+}
+
+/// A libg_query node
+#[derive(Debug)]
+pub struct Node {
+    pub name: String,
+    pub fields: Vec<Field>,
+}
+
+/// The libg_query proto file
+pub struct ProtoFile {
+    pub tokens: Vec<Token>,
+    pub nodes: Vec<Node>,
+}
+
+impl ProtoFile {
+    pub fn node(&self, name: &str) -> Option<&Node> {
+        self.nodes.iter().find(|n| n.name == name)
+    }
+}
diff --git a/crates/pg_query_proto_parser/src/proto_parser.rs b/crates/pg_query_proto_parser/src/proto_parser.rs
new file mode 100644
index 00000000..85263be2
--- /dev/null
+++ b/crates/pg_query_proto_parser/src/proto_parser.rs
@@ -0,0 +1,110 @@
+use convert_case::{Case, Casing};
+use protobuf::descriptor::{field_descriptor_proto::Label, FileDescriptorProto};
+use protobuf_parse::Parser;
+use std::path::Path;
+
+use crate::proto_file::{Field, FieldType, Node, ProtoFile, Token};
+
+/// The parser for the libg_query proto file
+pub struct ProtoParser {
+    inner: FileDescriptorProto,
+}
+
+impl ProtoParser {
+    pub fn new(file_path: &str) -> Self {
+        let proto_file = Path::new(file_path);
+        let proto_dir = proto_file.parent().unwrap();
+
+        let result = Parser::new()
+            .pure()
+            .include(proto_dir)
+            .input(proto_file)
+            .parse_and_typecheck()
+            .unwrap();
+
+        ProtoParser {
+            inner: result.file_descriptors[0].clone(),
+        }
+    }
+
+    pub fn parse(&self) -> ProtoFile {
+        ProtoFile {
+            tokens: self.tokens(),
+            nodes: self.nodes(),
+        }
+    }
+
+    fn tokens(&self) -> Vec<Token> {
+        self.inner
+            .enum_type
+            .iter()
+            .find(|e| e.name == Some("Token".into()))
+            .unwrap()
+            .value
+            .iter()
+            .map(|e| Token {
+                // token names in proto are UPPERCASE_SNAKE_CASE
+                name: e.name.clone().unwrap().to_case(Case::UpperCamel),
+                value: e.number.unwrap(),
+            })
+            .collect()
+    }
+
+    fn nodes(&self) -> Vec<Node> {
+        self.inner
+            .message_type
+            .iter()
+            .find(|e| e.name == Some("Node".into()))
+            .unwrap()
+            .field
+            .iter()
+            .map(|e| {
+                let name: String = e.json_name.to_owned().unwrap();
+                Node {
+                    // token names in proto are UPPERCASE_SNAKE_CASE
+                    name: name.clone(),
+                    fields: self
+                        .inner
+                        .message_type
+                        .iter()
+                        .find(|n| n.name.clone().unwrap() == name)
+                        .unwrap()
+                        .field
+                        .iter()
+                        .map(|e| {
+                            // use label and type to get the field type
+                            let type_name: FieldType = match e.type_name() {
+                                ".pg_query.Node" => FieldType::Node,
+                                _ => match e.type_() {
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_DOUBLE => FieldType::Double,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_FLOAT => FieldType::Float,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_INT64 => FieldType::Int64,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_UINT64 => FieldType::Uint64,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_INT32 => FieldType::Int32,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_FIXED64 => FieldType::Fixed64,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_FIXED32 => FieldType::Fixed32,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_BOOL => FieldType::Bool,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_STRING => FieldType::String,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_GROUP => FieldType::Group,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_MESSAGE => FieldType::Message,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_BYTES => FieldType::Bytes,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_UINT32 => FieldType::Uint32,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_ENUM => FieldType::Enum,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_SFIXED32 => FieldType::Sfixed32,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_SFIXED64 => FieldType::Sfixed64,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_SINT32 => FieldType::Sint32,
+                                    protobuf::descriptor::field_descriptor_proto::Type::TYPE_SINT64 => FieldType::Sint64,
+                                },
+                            };
+                            Field {
+                                name: e.name.clone().unwrap(),
+                                field_type: type_name,
+                                repeated: e.label() == Label::LABEL_REPEATED,
+                            }
+                        })
+                        .collect(),
+                }
+            })
+            .collect()
+    }
+}
diff --git a/crates/postgres_lsp/Cargo.toml b/crates/postgres_lsp/Cargo.toml
index b9d6c8ca..1220fda3 100644
--- a/crates/postgres_lsp/Cargo.toml
+++ b/crates/postgres_lsp/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "postgres_lsp"
-version = "0.1.0"
+version = "0.0.0"
 edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/crates/sourcegen/Cargo.toml b/crates/sourcegen/Cargo.toml
new file mode 100644
index 00000000..ec859dee
--- /dev/null
+++ b/crates/sourcegen/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "sourcegen"
+version = "0.0.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+textwrap = "0.16.0"
diff --git a/crates/sourcegen/src/attribute.rs b/crates/sourcegen/src/attribute.rs
new file mode 100644
index 00000000..0a05a6a8
--- /dev/null
+++ b/crates/sourcegen/src/attribute.rs
@@ -0,0 +1,76 @@
+use crate::builder::Builder;
+
+#[derive(Debug, Clone)]
+pub struct AttributeArgument {
+    name: String,
+    value: Option<String>,
+}
+
+/// A builder for a rust Attribute
+#[derive(Debug, Clone)]
+pub struct Attribute {
+    name: String,
+    arguments: Vec<AttributeArgument>,
+}
+
+impl Builder for Attribute {
+    fn finish(&mut self) -> String {
+        let mut result = String::new();
+        result.push_str("#[");
+        result.push_str(&self.name);
+        if !self.arguments.is_empty() {
+            result.push_str("(");
+            result.push_str(
+                &self
+                    .arguments
+                    .iter()
+                    .map(|arg| {
+                        let mut result = String::new();
+                        result.push_str(&arg.name);
+                        if let Some(value) = &arg.value {
+                            result.push_str(" = ");
+                            result.push_str(&value);
+                        }
+                        result
+                    })
+                    .collect::<Vec<String>>()
+                    .join(", "),
+            );
+            result.push_str(")");
+        }
+        result.push_str("]\n");
+        result
+    }
+}
+
+impl Attribute {
+    pub fn new(name: String) -> Self {
+        Attribute {
+            name,
+            arguments: Vec::new(),
+        }
+    }
+
+    pub fn with_argument(&mut self, name: String, value: Option<String>) -> &mut Self {
+        self.arguments.push(AttributeArgument { name, value });
+        self
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::{attribute::Attribute, builder::Builder};
+
+    #[test]
+    fn test_attribute() {
+        assert_eq!(
+            Attribute::new("derive".into())
+                .with_argument("Debug".to_string(), None)
+                .with_argument("Copy".to_string(), Some("value".to_string()))
+                .finish(),
+            "#[derive(Debug, Copy = value)]\n"
+        )
+    }
+}
diff --git a/crates/sourcegen/src/builder.rs b/crates/sourcegen/src/builder.rs
new file mode 100644
index 00000000..6ec942b9
--- /dev/null
+++ b/crates/sourcegen/src/builder.rs
@@ -0,0 +1,10 @@
+pub trait Builder {
+    fn with<F>(&mut self, mut f: F) -> &mut Self
+    where
+        F: FnMut(&mut Self) -> &mut Self,
+    {
+        f(self)
+    }
+
+    fn finish(&mut self) -> String;
+}
diff --git a/crates/sourcegen/src/comment.rs b/crates/sourcegen/src/comment.rs
new file mode 100644
index 00000000..b9dff806
--- /dev/null
+++ b/crates/sourcegen/src/comment.rs
@@ -0,0 +1,58 @@
+use textwrap::wrap;
+
+use crate::builder::Builder;
+
+#[derive(Debug, Clone)]
+pub struct Comment {
+    prefix: String,
+    parts: Vec<String>,
+}
+
+impl Builder for Comment {
+    fn finish(&mut self) -> String {
+        wrap(
+            self.parts.join('\n'.to_string().as_str()).as_str(),
+            80 - self.prefix.len(),
+        )
+        .iter()
+        .map(|line| format!("{} {}", self.prefix, line))
+        .collect::<Vec<String>>()
+        .join("\n")
+    }
+}
+
+/// A builder for a rust function
+impl Comment {
+    pub fn new(prefix: String) -> Self {
+        Comment {
+            prefix,
+            parts: Vec::new(),
+        }
+    }
+
+    pub fn with_text(&mut self, text: String) -> &mut Self {
+        self.parts.push(text);
+        self
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::{builder::Builder, comment::Comment};
+
+    #[test]
+    fn test_comment() {
+        assert_eq!(
+            Comment::new("//".into())
+                .with_text(
+                    "one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three"
+                        .to_string()
+                )
+                .with_text("three two one".to_string())
+                .finish(),
+            "// one two three one two three one two three one two three one two three one two\n// three one two three one two three one two three one two three one two three\n// one two three one two three one two three one two three\n// three two one"
+        )
+    }
+}
diff --git a/crates/sourcegen/src/enum_.rs b/crates/sourcegen/src/enum_.rs
new file mode 100644
index 00000000..f58b9a99
--- /dev/null
+++ b/crates/sourcegen/src/enum_.rs
@@ -0,0 +1,100 @@
+use crate::builder::Builder;
+
+#[derive(Debug, Clone)]
+pub struct EnumValue {
+    name: String,
+    value: Option<String>,
+}
+
+/// Generate a rust enum
+#[derive(Debug, Clone)]
+pub struct Enum {
+    name: String,
+    comments: Vec<String>,
+    public: bool,
+    values: Vec<EnumValue>,
+    attributes: Vec<String>,
+}
+
+impl Builder for Enum {
+    fn finish(&mut self) -> String {
+        let mut result = String::new();
+        for comment in &self.comments {
+            result.push_str("/// ");
+            result.push_str(&comment);
+            result.push_str("\n");
+        }
+        for attribute in &self.attributes {
+            result.push_str(&attribute);
+        }
+        if self.public {
+            result.push_str("pub ");
+        }
+        result.push_str("enum ");
+        result.push_str(&self.name);
+        result.push_str(" {\n");
+        for value in &self.values {
+            result.push_str("    ");
+            result.push_str(&value.name);
+            if let Some(value) = &value.value {
+                result.push_str(" = ");
+                result.push_str(&value);
+            }
+            result.push_str(",\n");
+        }
+        result.push_str("}\n");
+        result
+    }
+}
+
+impl Enum {
+    pub fn new(name: String) -> Self {
+        Enum {
+            name,
+            comments: Vec::new(),
+            public: false,
+            values: Vec::new(),
+            attributes: Vec::new(),
+        }
+    }
+
+    pub fn public(&mut self) -> &mut Self {
+        self.public = true;
+        self
+    }
+
+    pub fn with_comment(&mut self, comment: String) -> &mut Self {
+        self.comments.push(comment);
+        self
+    }
+
+    pub fn with_value(&mut self, name: String, value: Option<String>) -> &mut Self {
+        self.values.push(EnumValue { name, value });
+        self
+    }
+
+    pub fn with_attribute(&mut self, attribute: String) -> &mut Self {
+        self.attributes.push(attribute);
+        self
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::{builder::Builder, enum_::Enum};
+
+    #[test]
+    fn test_enum() {
+        assert_eq!(
+            Enum::new("my_enum".into())
+                .public()
+                .with_value("A".into(), None)
+                .with_attribute("#[derive(Copy)]\n".to_string())
+                .with_value("".into(), Some("5".into()))
+                .finish(),
+            "#[derive(Copy)]\npub enum my_enum {\n    A,\n    B = 5,\n}\n"
+        )
+    }
+}
diff --git a/crates/sourcegen/src/function.rs b/crates/sourcegen/src/function.rs
new file mode 100644
index 00000000..47b401f4
--- /dev/null
+++ b/crates/sourcegen/src/function.rs
@@ -0,0 +1,96 @@
+use crate::builder::Builder;
+
+#[derive(Debug, Clone)]
+pub struct Function {
+    body: String,
+    name: String,
+    public: bool,
+    return_type: Option<String>,
+    parameters: Vec<String>,
+    comments: Vec<String>,
+}
+
+impl Builder for Function {
+    fn finish(&mut self) -> String {
+        let mut result = String::new();
+        for comment in &self.comments {
+            result.push_str("/// ");
+            result.push_str(&comment);
+            result.push_str("\n");
+        }
+        if self.public {
+            result.push_str("pub ");
+        }
+        result.push_str("fn ");
+        result.push_str(&self.name);
+        result.push_str("(");
+        result.push_str(&self.parameters.join(", "));
+        result.push_str(")");
+        if let Some(return_type) = &self.return_type {
+            result.push_str(" -> ");
+            result.push_str(&return_type);
+        }
+        result.push_str("{\n");
+        result.push_str(&self.body);
+        result.push_str("\n}\n");
+        result
+    }
+}
+
+/// A builder for a rust function
+impl Function {
+    pub fn new(name: String) -> Self {
+        Function {
+            body: "".into(),
+            public: false,
+            name,
+            return_type: None,
+            parameters: Vec::new(),
+            comments: Vec::new(),
+        }
+    }
+
+    pub fn public(&mut self) -> &mut Self {
+        self.public = true;
+        self
+    }
+
+    pub fn with_return_type(&mut self, return_type: String) -> &mut Self {
+        self.return_type = Some(return_type);
+        self
+    }
+
+    pub fn with_parameter(&mut self, name: String, type_: String) -> &mut Self {
+        self.parameters.push(format!("{}: {}", name, type_));
+        self
+    }
+
+    pub fn with_comment(&mut self, comment: String) -> &mut Self {
+        self.comments.push(comment);
+        self
+    }
+
+    pub fn with_body(&mut self, body: String) -> &mut Self {
+        self.body = body;
+        self
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::{builder::Builder, function::Function};
+
+    #[test]
+    fn test_function() {
+        assert_eq!(
+            Function::new("my_function".into())
+                .public()
+                .with_return_type("String".to_string())
+                .with_body("println!(\"Hello, world!\");".into())
+                .finish(),
+            "pub fn my_function() -> String{\nprintln!(\"Hello, world!\");\n}\n"
+        )
+    }
+}
diff --git a/crates/sourcegen/src/implementation.rs b/crates/sourcegen/src/implementation.rs
new file mode 100644
index 00000000..f7a5ac21
--- /dev/null
+++ b/crates/sourcegen/src/implementation.rs
@@ -0,0 +1,54 @@
+use crate::builder::Builder;
+
+/// Generate a rust implementation
+#[derive(Debug, Clone)]
+pub struct Implementation {
+    for_: String,
+    blocks: Vec<String>,
+}
+
+impl Builder for Implementation {
+    fn finish(&mut self) -> String {
+        let mut result = String::new();
+        result.push_str("impl ");
+        result.push_str(&self.for_);
+        result.push_str(" {\n");
+        for block in &self.blocks {
+            result.push_str(&block);
+            result.push_str("\n");
+        }
+        result.push_str("}\n");
+        result
+    }
+}
+
+impl Implementation {
+    pub fn new(for_: String) -> Self {
+        Implementation {
+            for_,
+            blocks: Vec::new(),
+        }
+    }
+
+    pub fn add_block(&mut self, block: String) -> &mut Self {
+        self.blocks.push(block);
+        self
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::{builder::Builder, implementation::Implementation};
+
+    #[test]
+    fn test_implementation() {
+        assert_eq!(
+            Implementation::new("my_enum".into())
+                .add_block("test".to_string())
+                .finish(),
+            "impl my_enum {\ntest}\n"
+        )
+    }
+}
diff --git a/crates/sourcegen/src/imports.rs b/crates/sourcegen/src/imports.rs
new file mode 100644
index 00000000..79666460
--- /dev/null
+++ b/crates/sourcegen/src/imports.rs
@@ -0,0 +1,64 @@
+use crate::builder::Builder;
+
+#[derive(Debug, Clone)]
+pub struct Import {
+    path: String,
+    items: Vec<String>,
+}
+
+#[derive(Debug, Clone)]
+pub struct Imports {
+    imports: Vec<Import>,
+}
+
+impl Builder for Imports {
+    fn finish(&mut self) -> String {
+        let mut result = String::new();
+        for import in &self.imports {
+            result.push_str("use ");
+            result.push_str(&import.path);
+            if !import.items.is_empty() {
+                result.push_str("::{");
+                result.push_str(&import.items.join(", "));
+                result.push_str("}");
+            }
+            result.push_str(";\n");
+        }
+        result
+    }
+}
+
+/// A builder for a rust function
+impl Imports {
+    pub fn new() -> Self {
+        Imports {
+            imports: Vec::new(),
+        }
+    }
+
+    pub fn with_import(&mut self, path: String, items: Vec<String>) -> &mut Self {
+        self.imports.push(Import { path, items });
+        self
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::{builder::Builder, imports::Imports};
+
+    #[test]
+    fn test_imports() {
+        assert_eq!(
+            Imports::new()
+                .with_import("deeply::nested".to_string(), vec!["function".to_string()])
+                .with_import(
+                    "another::deeply::nested".to_string(),
+                    vec!["function".to_string(), "another_item".to_string()]
+                )
+                .finish(),
+            "use deeply::nested::{function};\nuse another::deeply::nested::{function, another_item};\n"
+        )
+    }
+}
diff --git a/crates/sourcegen/src/lib.rs b/crates/sourcegen/src/lib.rs
new file mode 100644
index 00000000..9a60f4b5
--- /dev/null
+++ b/crates/sourcegen/src/lib.rs
@@ -0,0 +1,60 @@
+//! Helpers to generate rust code
+//!
+//! This crate provides utilities to generate rust source code.
+
+mod attribute;
+mod builder;
+mod comment;
+mod enum_;
+mod function;
+mod implementation;
+mod imports;
+mod match_;
+mod source_file;
+
+pub use attribute::Attribute;
+pub use builder::Builder;
+pub use comment::Comment;
+pub use enum_::Enum;
+pub use function::Function;
+pub use implementation::Implementation;
+pub use imports::Imports;
+pub use match_::Match;
+pub use source_file::SourceFile;
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::builder::Builder;
+    use crate::enum_::Enum;
+    use crate::function::Function;
+    use crate::match_::Match;
+    use crate::source_file::SourceFile;
+
+    #[test]
+    fn test_sourcegen() {
+        let test_enum = Enum::new("TestEnum".into())
+            .with_value("A".into(), None)
+            .with_value("B".into(), Some("Test".into()))
+            .finish();
+
+        let test_match = Match::new("value".into())
+            .with_arm("A".into(), "1".into())
+            .with_arm("B".into(), "2".into())
+            .finish();
+
+        let test_fn = Function::new("TestEnum".into())
+            .public()
+            .with_body(test_match)
+            .finish();
+
+        assert_eq!(
+            SourceFile::new()
+                .add_block(test_enum)
+                .add_block(test_fn)
+                .finish(),
+            "enum TestEnum {\n    A,\n    B = Test,\n}\n\npub fn TestEnum(){\nmatch value {\n    A => 1,\n    B => 2,\n}\n\n}\n\n"
+        )
+    }
+}
diff --git a/crates/sourcegen/src/match_.rs b/crates/sourcegen/src/match_.rs
new file mode 100644
index 00000000..2d644c05
--- /dev/null
+++ b/crates/sourcegen/src/match_.rs
@@ -0,0 +1,65 @@
+use crate::builder::Builder;
+
+#[derive(Debug, Clone)]
+pub struct MatchArm {
+    pattern: String,
+    body: String,
+}
+
+#[derive(Debug, Clone)]
+pub struct Match {
+    variable: String,
+    arms: Vec<MatchArm>,
+}
+
+impl Builder for Match {
+    fn finish(&mut self) -> String {
+        let mut result = String::new();
+        result.push_str("match ");
+        result.push_str(&self.variable);
+        result.push_str(" {\n");
+        for arm in &self.arms {
+            result.push_str("    ");
+            result.push_str(&arm.pattern);
+            result.push_str(" => ");
+            result.push_str(&arm.body);
+            result.push_str(",\n");
+        }
+        result.push_str("}\n");
+        result
+    }
+}
+
+/// A builder for a Rust match expression.
+impl Match {
+    pub fn new(variable: String) -> Self {
+        Match {
+            variable,
+            arms: Vec::new(),
+        }
+    }
+
+    pub fn with_arm(&mut self, pattern: String, body: String) -> &mut Self {
+        self.arms.push(MatchArm { pattern, body });
+        self
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::{builder::Builder, match_::Match};
+
+    #[test]
+    fn test_match() {
+        assert_eq!(
+            Match::new("variable".into())
+                .with_arm("one".into(), "result one".into())
+                .with_arm("two".into(), "result two".into())
+                .with_arm("_".into(), "result catch all".into())
+                .finish(),
+            "match variable {\n    one => result one,\n    two => result two,\n    _ => result catch all,\n}\n"
+        )
+    }
+}
diff --git a/crates/sourcegen/src/source_file.rs b/crates/sourcegen/src/source_file.rs
new file mode 100644
index 00000000..499659b6
--- /dev/null
+++ b/crates/sourcegen/src/source_file.rs
@@ -0,0 +1,60 @@
+use crate::builder::Builder;
+
+#[derive(Debug, Clone)]
+pub struct SourceFile {
+    content: String,
+    comments: Vec<String>,
+}
+
+impl Builder for SourceFile {
+    fn finish(&mut self) -> String {
+        let mut result = String::new();
+        for comment in &self.comments {
+            result.push_str("//! ");
+            result.push_str(&comment);
+            result.push_str("\n");
+        }
+        result.push_str("\n");
+        result.push_str(&self.content);
+        result
+    }
+}
+
+/// Generate a rust source file
+impl SourceFile {
+    pub fn new() -> Self {
+        SourceFile {
+            content: "".to_string(),
+            comments: Vec::new(),
+        }
+    }
+
+    pub fn add_comment(&mut self, comment: String) -> &mut SourceFile {
+        self.comments.push(comment);
+        self
+    }
+
+    pub fn add_block(&mut self, block: String) -> &mut SourceFile {
+        self.content.push_str(block.as_str());
+        self.content.push_str("\n");
+        self
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::{builder::Builder, source_file::SourceFile};
+
+    #[test]
+    fn test_source_file() {
+        assert_eq!(
+            SourceFile::new()
+                .add_block("block 1".into())
+                .add_block("block 2".into())
+                .finish(),
+            "block 1\nblock 2\n"
+        )
+    }
+}

From 4c1da43bd4c7c4e65c1073079e7cc620c3e7e600 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Tue, 1 Aug 2023 16:35:49 +0200
Subject: [PATCH 02/23] feat: sourcegen for get_location and get_children

---
 crates/parser/Cargo.toml                      |    2 +-
 crates/parser/src/bin/generate.rs             |  225 +-
 crates/parser/src/lib.rs                      |    2 +
 crates/parser/src/pg_query_utils.rs           |  492 +-
 crates/parser/src/pg_query_utils_generated.rs | 4071 +++++++++++++++++
 crates/parser/src/statement.rs                |   23 +-
 crates/parser/src/syntax_kind.rs              |    6 +-
 crates/parser/src/syntax_kind_generated.rs    | 1352 +++++-
 .../pg_query_proto_parser/src/proto_file.rs   |    5 +-
 .../pg_query_proto_parser/src/proto_parser.rs |  104 +-
 crates/sourcegen/Cargo.toml                   |    1 +
 crates/sourcegen/src/enum_.rs                 |   18 +-
 crates/sourcegen/src/function.rs              |   11 +-
 crates/sourcegen/src/source_file.rs           |   23 +-
 14 files changed, 5996 insertions(+), 339 deletions(-)
 create mode 100644 crates/parser/src/pg_query_utils_generated.rs

diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml
index 171be408..8b7b94a0 100644
--- a/crates/parser/Cargo.toml
+++ b/crates/parser/Cargo.toml
@@ -7,7 +7,7 @@ edition = "2021"
 
 [dependencies]
 cstree = { version = "0.12.0", features = ["derive"] }
-pg_query = "0.7"
+pg_query = "0.8"
 logos = "0.13.0"
 serde_json = "1.0"
 regex = "1.9.1"
diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
index aa274f66..01ac663d 100644
--- a/crates/parser/src/bin/generate.rs
+++ b/crates/parser/src/bin/generate.rs
@@ -1,7 +1,32 @@
-use pg_query_proto_parser::{ProtoFile, ProtoParser};
-use sourcegen::{Attribute, Builder, Comment, Enum, Function, Implementation, Match, SourceFile};
+use pg_query_proto_parser::{FieldType, ProtoFile, ProtoParser};
+use sourcegen::{
+    Attribute, Builder, Comment, Enum, Function, Implementation, Imports, Match, SourceFile,
+};
 use std::fs;
 
+// NodeEnum::Expr(_) => todo!(),
+// NodeEnum::SqlvalueFunction(_) => todo!(),
+// NodeEnum::CreatePlangStmt(_) => todo!(),
+// NodeEnum::AlterTsdictionaryStmt(_) => todo!(),
+// NodeEnum::AlterTsconfigurationStmt(_) => todo!(),
+// NodeEnum::Null(_) => todo!(),
+
+const UNKNOWN_NODES: [&str; 12] = [
+    // ignore nodes not known to pg_query.rs
+    "MergeAction",
+    "MergeStmt",
+    "PlAssignStmt",
+    "AlterDatabaseRefreshCollStmt",
+    "StatsElem",
+    "CteSearchClause",
+    "CteCycleClause",
+    "MergeWhenClause",
+    "PublicationObjSpec",
+    "PublicationTable",
+    "Boolean",
+    "ReturnStmt",
+];
+
 fn main() {
     let parser = ProtoParser::new("./proto/source.proto");
     let file = parser.parse();
@@ -11,24 +36,108 @@ fn main() {
         generate_syntax_kind(&file),
     )
     .unwrap();
+
+    fs::write(
+        "./src/pg_query_utils_generated.rs",
+        generate_pg_query_utils(&file),
+    )
+    .unwrap();
 }
 
 fn generate_pg_query_utils(f: &ProtoFile) -> String {
     SourceFile::new()
-        .add_comment(
-            Comment::new("//!".to_string())
-                .with_text("Utilities for working with pg_query.rs".to_string())
-                .with_text("This file is generated from the libg_query proto".to_string())
+        .add_comment("Utilities for working with pg_query.rs".to_string())
+        .add_comment("This file is generated from the libg_query proto".to_string())
+        .add_block(
+            Imports::new()
+                .with_import(
+                    "pg_query".to_string(),
+                    vec!["NodeEnum".to_string(), "NodeRef".to_string()],
+                )
                 .finish(),
         )
         .add_block(
-            Function::new("get_position_for_pg_query_node".to_string())
+            Function::new("get_location".to_string())
                 .public()
-                .with_parameter("node".to_string(), "&NodeRef".to_string())
-                .with_return_type("i32".to_string())
+                .with_parameter("node".to_string(), Some("NodeEnum".to_string()))
+                .with_return_type("Option<i32>".to_string())
                 .with_body(
-                    Match::new("node".to_string())
-                        .with_arm(pattern, body)
+                    Match::new("&node".to_string())
+                        .with(|b| {
+                            f.nodes.iter().for_each(|node| {
+                                let mut right = "None";
+                                let mut left = format!("NodeEnum::{}(_)", node.name.to_string());
+                                if node
+                                    .fields
+                                    .iter()
+                                    .find(|n| {
+                                        n.name == "location" && n.field_type == FieldType::Int32
+                                    })
+                                    .is_some()
+                                {
+                                    right = "Some(n.location)";
+                                    left = format!("NodeEnum::{}(n)", node.name.to_string());
+                                }
+
+                                b.with_arm(left.to_string(), right.to_string());
+                            });
+                            b
+                        })
+                        .finish(),
+                )
+                .finish(),
+        )
+        .add_block(
+            Function::new("get_nested_nodes".to_string())
+                .public()
+                .with_comment("Returns the node and all its childrens, recursively".to_string())
+                .with_parameter("node".to_string(), Some("NodeEnum".to_string()))
+                .with_return_type("Vec<NodeEnum>".to_string())
+                .with_body(
+                    Match::new("&node".to_string())
+                        .with(|b| {
+                            f.nodes.iter().for_each(|node| {
+                                let mut content = "".to_string();
+                                content.push_str("{\n");
+                                content.push_str(
+                                    "let mut nodes: Vec<NodeEnum> = vec![node.clone()];\n",
+                                );
+                                node.fields.iter().for_each(|field| {
+                                    if field.field_type == FieldType::Node && field.repeated {
+                                        content.push_str(
+                                            format!(
+                                                "nodes.append(&mut n.{}.iter().flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned())).collect());\n",
+                                                field.name.to_string()
+                                            ).as_str()
+                                        );
+                                    } else if field.field_type == FieldType::Node && field.is_one_of == false {
+                                        if field.node_name == Some("Node".to_owned()) {
+                                            content.push_str(
+                                                format!(
+                                                    "nodes.append(&mut get_nested_nodes(n.{}.as_ref().unwrap().to_owned().node.unwrap()));\n",
+                                                    field.name.to_string(),
+                                                ).as_str()
+                                            );
+                                        } else {
+                                            content.push_str(
+                                                format!(
+                                                    "nodes.append(&mut get_nested_nodes(NodeEnum::{}(n.{}.as_ref().unwrap().to_owned())));\n",
+                                                    field.enum_variant_name.as_ref().unwrap(),
+                                                    field.name.to_string()
+                                                ).as_str()
+                                            );
+                                        }
+                                    }
+                                });
+                                content.push_str("nodes\n}");
+                                b.with_arm(
+                                    format!("NodeEnum::{}(n)", node.name.to_string()),
+                                    format!("{}", content),
+                                );
+                            });
+
+                            b
+                        })
                         .finish(),
                 )
                 .finish(),
@@ -44,6 +153,12 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
         .with_text("The file is generated from the libg_query proto".to_string())
         .finish()
     )
+    .add_block(
+        Imports::new()
+        .with_import("cstree".to_string(), vec!["Syntax".to_string()])
+        .with_import("pg_query".to_string(), vec!["protobuf::ScanToken".to_string(), "NodeEnum".to_string()])
+        .finish()
+    )
     .add_block(
         Enum::new("SyntaxKind".to_string())
         .public()
@@ -51,6 +166,7 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
         .with_attribute(
             Attribute::new("derive".to_string())
             .with_argument("Copy".to_string(), None)
+            .with_argument("Clone".to_string(), None)
             .with_argument("PartialEq".to_string(), None)
             .with_argument("Eq".to_string(), None)
             .with_argument("PartialOrd".to_string(), None)
@@ -79,7 +195,9 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
             });
 
             f.nodes.iter().for_each(|node| {
-                b.with_value(node.name.to_string(), None);
+                if !UNKNOWN_NODES.contains(&node.name.as_str()) {
+                    b.with_value(node.name.to_string(), None);
+                }
             });
 
             f.tokens.iter().for_each(|token| {
@@ -90,26 +208,57 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
         })
         .finish()
     )
+    .add_block(
+        Enum::new("SyntaxKindType".to_string())
+        .with_comment("
+ Kind of a `SyntaxKind`
+ This is the only manual definition required for properly creating a concrete syntax tree.
+ If a token is of type `Follow`, it is not immediately applied to the syntax tree, but put into
+ a buffer. Before the next node is started, all buffered tokens are applied to the syntax tree
+ at the depth of the node that is opened next.
+
+ For example, in `select * from contact;`, the whitespace between `*` and `from` should be a direct
+ child of the `SelectStmt` node. Without this concept, it would be put into the `ColumnRef`
+ node.
+
+ SelectStmt@0..22
+   Select@0..6 \"select\"
+   Whitespace@6..7 \" \"
+   ResTarget@7..8
+     ColumnRef@7..8
+       Ascii42@7..8 \"*\"
+   Whitespace@8..9 \" \"
+   From@9..13 \"from\"
+  Whitespace@13..14 \" \"
+   RangeVar@14..21
+     Ident@14..21 \"contact\"
+   Ascii59@21..22 \";\"".to_string()
+   )
+        .public()
+        .with_value("Follow".to_string(), None)
+        .with_value("Close".to_string(), None)
+        .finish()
+    )
     .add_block(
         Implementation::new("SyntaxKind".to_string())
         .add_block(
             Function::new("new_from_pg_query_node".to_string())
             .public()
             .with_comment(
-                Comment::new("//".to_string())
-                .with_text("Converts a `pg_query` node to a `SyntaxKind`".to_string())
-                .finish()
+                "Converts a `pg_query` node to a `SyntaxKind`".to_string()
             )
             .with_return_type("Self".to_string())
-            .with_parameter("node".to_string(), "&NodeRef".to_string())
+            .with_parameter("node".to_string(), Some("&NodeEnum".to_string()))
             .with_body(
-                Match::new("node.kind()".to_string())
+                Match::new("node".to_string())
                 .with(|b| {
                     f.nodes.iter().for_each(|node| {
-                        b.with_arm(
-                            format!("NodeRef::{}(_)", node.name.to_string()),
-                            format!("SyntaxKind::{}", node.name.to_string()),
-                        );
+                        if !UNKNOWN_NODES.contains(&node.name.as_str()) {
+                            b.with_arm(
+                                format!("NodeEnum::{}(_)", node.name.to_string()),
+                                format!("SyntaxKind::{}", node.name.to_string()),
+                            );
+                        }
                     });
                     b
                 })
@@ -121,12 +270,10 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
             Function::new("new_from_pg_query_token".to_string())
             .public()
             .with_comment(
-                Comment::new("//".to_string())
-                .with_text("Converts a `pg_query` token to a `SyntaxKind`".to_string())
-                .finish()
+                "Converts a `pg_query` token to a `SyntaxKind`".to_string()
             )
             .with_return_type("Self".to_string())
-            .with_parameter("token".to_string(), "&ScanToken".to_string())
+            .with_parameter("token".to_string(), Some("&ScanToken".to_string()))
             .with_body(
                 Match::new("token.token".to_string())
                .with(|b| {
@@ -142,7 +289,35 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
             )
             .finish()
         )
+        .add_block(
+            Function::new("get_type".to_string())
+            .public()
+            .with_comment(
+                "Returns the `SyntaxKindType` of a `SyntaxKind`".to_string()
+            )
+            .with_return_type("Option<SyntaxKindType>".to_string())
+            .with_parameter("&self".to_string(), None)
+            .with_body(
+                Match::new("self".to_string())
+               .with(|b| {
+                   f.tokens.iter().for_each(|token| {
+                       // Ascii59 (";") closes a statement
+                       let value = match token.name.to_string().as_str() {
+                            "Ascii59" => "Some(SyntaxKindType::Close)",
+                            _ => "Some(SyntaxKindType::Follow)",
+                       };
+                       b.with_arm(
+                           format!("SyntaxKind::{}", token.name.to_string()),
+                           value.to_string(),
+                        );
+                   });
+                   b
+               })
+               .finish()
+            )
         .finish()
     )
     .finish()
+    )
+    .finish()
 }
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 69076f3e..7eaca93f 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -18,10 +18,12 @@
 mod ast_node;
 mod parser;
 mod pg_query_utils;
+mod pg_query_utils_generated;
 mod source_file;
 mod statement;
 mod syntax_error;
 mod syntax_kind;
+// mod syntax_kind_generated;
 mod syntax_node;
 
 pub use crate::parser::{Parse, Parser};
diff --git a/crates/parser/src/pg_query_utils.rs b/crates/parser/src/pg_query_utils.rs
index 5ed80ea2..a229ba84 100644
--- a/crates/parser/src/pg_query_utils.rs
+++ b/crates/parser/src/pg_query_utils.rs
@@ -1,268 +1,281 @@
-use pg_query::{Node, NodeRef};
+use pg_query::{NodeEnum, NodeRef};
 
 /// Returns the array children nodes
-pub fn get_flat_nodes<'a>(node: &'a NodeRef) -> Vec<NodeRef<'a>> {
-    match node {
-        NodeRef::CreateStmt(n) => {
-            let mut nodes: Vec<NodeRef> = vec![node.clone()];
+pub fn get_children(node: NodeEnum) -> Vec<NodeEnum> {
+    match &node {
+        NodeEnum::CreateStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_children(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
             nodes.append(
                 &mut n
                     .table_elts
                     .iter()
-                    .map(|x| x.node.as_ref().unwrap().to_ref())
+                    .flat_map(|x| get_children(x.node.as_ref().unwrap().to_owned()))
                     .collect(),
             );
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .map(|x| x.node.as_ref().unwrap().to_ref())
+                    .flat_map(|x| get_children(x.node.as_ref().unwrap().to_owned()))
                     .collect(),
             );
             nodes
         }
+        NodeEnum::Var(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_children(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
         n => vec![n.clone()],
     }
 }
 
+// TODO: we need two functions, one to return Option<i32> for every node enum,
+// and one to get all childrens, the Option<i32> position for each, and the smallest one from it
+
 /// Gets the position value for a pg_query node
 ///
 /// This can mostly be generated by just returning `node.location` if the type has the property,
 /// but there are some exceptions where the location on the node itself is not leftmost position, e.g. for `AExpr`.
 pub fn get_position_for_pg_query_node(node: &NodeRef) -> i32 {
     match node {
-        NodeRef::ResTarget(n) => n.location,
-        NodeRef::AExpr(n) => get_position_for_pg_query_node(
-            &n.lexpr.as_ref().unwrap().node.as_ref().unwrap().to_ref(),
-        ),
-        NodeRef::RangeVar(n) => n.location,
-        NodeRef::ColumnRef(n) => n.location,
-        NodeRef::AConst(n) => n.location,
-        NodeRef::Alias(n) => todo!("Alias"),
-        NodeRef::TableFunc(n) => n.location,
-        NodeRef::Expr(n) => todo!("Expr"),
-        NodeRef::Var(n) => n.location,
-        NodeRef::Param(n) => n.location,
-        NodeRef::Aggref(n) => n.location,
-        NodeRef::GroupingFunc(n) => n.location,
-        NodeRef::WindowFunc(n) => n.location,
-        NodeRef::SubscriptingRef(n) => todo!("SubscriptingRef"),
-        NodeRef::FuncExpr(n) => n.location,
-        NodeRef::NamedArgExpr(n) => n.location,
-        NodeRef::OpExpr(n) => n.location,
-        NodeRef::DistinctExpr(n) => n.location,
-        NodeRef::NullIfExpr(n) => n.location,
-        NodeRef::ScalarArrayOpExpr(n) => n.location,
-        NodeRef::BoolExpr(n) => n.location,
-        NodeRef::SubLink(n) => n.location,
-        NodeRef::SubPlan(n) => {
-            get_position_for_pg_query_node(&n.xpr.as_ref().unwrap().node.as_ref().unwrap().to_ref())
-        }
-        NodeRef::AlternativeSubPlan(n) => todo!("AlternativeSubPlan"),
-        NodeRef::FieldSelect(n) => todo!("FieldSelect"),
-        NodeRef::FieldStore(n) => todo!("FieldStore"),
-        NodeRef::RelabelType(n) => n.location,
-        NodeRef::CoerceViaIo(n) => n.location,
-        NodeRef::ArrayCoerceExpr(n) => n.location,
-        NodeRef::ConvertRowtypeExpr(n) => n.location,
-        NodeRef::CollateExpr(n) => n.location,
-        NodeRef::CaseExpr(n) => n.location,
-        NodeRef::CaseWhen(n) => n.location,
-        NodeRef::CaseTestExpr(n) => todo!("CaseTestExpr"),
-        NodeRef::ArrayExpr(n) => n.location,
-        NodeRef::RowExpr(n) => n.location,
-        NodeRef::RowCompareExpr(n) => todo!("RowCompareExpr"),
-        NodeRef::CoalesceExpr(n) => n.location,
-        NodeRef::MinMaxExpr(n) => n.location,
-        NodeRef::SqlvalueFunction(n) => n.location,
-        NodeRef::XmlExpr(n) => n.location,
-        NodeRef::NullTest(n) => n.location,
-        NodeRef::BooleanTest(n) => n.location,
-        NodeRef::CoerceToDomain(n) => n.location,
-        NodeRef::CoerceToDomainValue(n) => n.location,
-        NodeRef::SetToDefault(n) => n.location,
-        NodeRef::CurrentOfExpr(n) => todo!("CurrentOfExpr"),
-        NodeRef::NextValueExpr(_) => todo!("NextValueExpr"),
-        NodeRef::InferenceElem(_) => todo!("InferenceElem"),
-        NodeRef::TargetEntry(_) => todo!("TargetEntry"),
-        NodeRef::RangeTblRef(_) => todo!("RangeTblRef"),
-        NodeRef::JoinExpr(_) => todo!("JoinExpr"),
-        NodeRef::FromExpr(_) => todo!("FromExpr"),
-        NodeRef::OnConflictExpr(_) => todo!("OnConflictExpr"),
-        NodeRef::IntoClause(_) => todo!("IntoClause"),
-        NodeRef::RawStmt(_) => todo!("RawStmt"),
-        NodeRef::Query(_) => todo!("Query"),
-        NodeRef::InsertStmt(_) => todo!("InsertStmt"),
-        NodeRef::DeleteStmt(_) => todo!("DeleteStmt"),
-        NodeRef::UpdateStmt(_) => todo!("UpdateStmt"),
-        NodeRef::SelectStmt(_) => todo!("SelectStmt"),
-        NodeRef::AlterTableStmt(_) => -1,
-        NodeRef::AlterTableCmd(_) => todo!("AlterTableCmd"),
-        NodeRef::AlterDomainStmt(_) => todo!("AlterDomainStmt"),
-        NodeRef::SetOperationStmt(_) => todo!("SetOperationStmt"),
-        NodeRef::GrantStmt(_) => -1,
-        NodeRef::GrantRoleStmt(_) => todo!("GrantRoleStmt"),
-        NodeRef::AlterDefaultPrivilegesStmt(_) => todo!("AlterDefaultPrivilegesStmt"),
-        NodeRef::ClosePortalStmt(_) => todo!("ClosePortalStmt"),
-        NodeRef::ClusterStmt(_) => todo!("ClusterStmt"),
-        NodeRef::CopyStmt(_) => todo!("CopyStmt"),
-        NodeRef::CreateStmt(_) => -1,
-        NodeRef::DefineStmt(_) => todo!("DefineStmt"),
-        NodeRef::DropStmt(_) => todo!("DropStmt"),
-        NodeRef::TruncateStmt(_) => todo!("TruncateStmt"),
-        NodeRef::CommentStmt(_) => todo!("CommentStmt"),
-        NodeRef::FetchStmt(_) => todo!("FetchStmt"),
-        NodeRef::IndexStmt(_) => todo!("IndexStmt"),
-        NodeRef::CreateFunctionStmt(_) => todo!("CreateFunctionStmt"),
-        NodeRef::AlterFunctionStmt(_) => todo!("AlterFunctionStmt"),
-        NodeRef::DoStmt(_) => todo!("DoStmt"),
-        NodeRef::RenameStmt(_) => todo!("RenameStmt"),
-        NodeRef::RuleStmt(_) => todo!("RuleStmt"),
-        NodeRef::NotifyStmt(_) => todo!("NotifyStmt"),
-        NodeRef::ListenStmt(_) => todo!("ListenStmt"),
-        NodeRef::UnlistenStmt(_) => todo!("UnlistenStmt"),
-        NodeRef::TransactionStmt(_) => todo!("TransactionStmt"),
-        NodeRef::ViewStmt(_) => todo!("ViewStmt"),
-        NodeRef::LoadStmt(_) => todo!("LoadStmt"),
-        NodeRef::CreateDomainStmt(_) => todo!("CreateDomainStmt"),
-        NodeRef::CreatedbStmt(_) => todo!("CreatedbStmt"),
-        NodeRef::DropdbStmt(_) => todo!("DropdbStmt"),
-        NodeRef::VacuumStmt(_) => todo!("VacuumStmt"),
-        NodeRef::ExplainStmt(_) => todo!("ExplainStmt"),
-        NodeRef::CreateTableAsStmt(_) => todo!("CreateTableAsStmt"),
-        NodeRef::CreateSeqStmt(_) => todo!("CreateSeqStmt"),
-        NodeRef::AlterSeqStmt(_) => todo!("AlterSeqStmt"),
-        NodeRef::VariableSetStmt(_) => todo!("VariableSetStmt"),
-        NodeRef::VariableShowStmt(_) => todo!("VariableShowStmt"),
-        NodeRef::DiscardStmt(_) => todo!("DiscardStmt"),
-        NodeRef::CreateTrigStmt(_) => todo!("CreateTrigStmt"),
-        NodeRef::CreatePlangStmt(_) => todo!("CreatePlangStmt"),
-        NodeRef::CreateRoleStmt(_) => todo!("CreateRoleStmt"),
-        NodeRef::AlterRoleStmt(_) => todo!("AlterRoleStmt"),
-        NodeRef::DropRoleStmt(_) => todo!("DropRoleStmt"),
-        NodeRef::LockStmt(_) => todo!("LockStmt"),
-        NodeRef::ConstraintsSetStmt(_) => todo!("ConstraintsSetStmt"),
-        NodeRef::ReindexStmt(_) => todo!("ReindexStmt"),
-        NodeRef::CheckPointStmt(_) => todo!("CheckPointStmt"),
-        NodeRef::CreateSchemaStmt(_) => todo!("CreateSchemaStmt"),
-        NodeRef::AlterDatabaseStmt(_) => todo!("AlterDatabaseStmt"),
-        NodeRef::AlterDatabaseSetStmt(_) => todo!("AlterDatabaseSetStmt"),
-        NodeRef::AlterRoleSetStmt(_) => todo!("AlterRoleSetStmt"),
-        NodeRef::CreateConversionStmt(_) => todo!("CreateConversionStmt"),
-        NodeRef::CreateCastStmt(_) => todo!("CreateCastStmt"),
-        NodeRef::CreateOpClassStmt(_) => todo!("CreateOpClassStmt"),
-        NodeRef::CreateOpFamilyStmt(_) => todo!("CreateOpFamilyStmt"),
-        NodeRef::AlterOpFamilyStmt(_) => todo!("AlterOpFamilyStmt"),
-        NodeRef::PrepareStmt(_) => todo!("PrepareStmt"),
-        NodeRef::ExecuteStmt(_) => todo!("ExecuteStmt"),
-        NodeRef::DeallocateStmt(_) => todo!("DeallocateStmt"),
-        NodeRef::DeclareCursorStmt(_) => todo!("DeclareCursorStmt"),
-        NodeRef::CreateTableSpaceStmt(_) => todo!("CreateTableSpaceStmt"),
-        NodeRef::DropTableSpaceStmt(_) => todo!("DropTableSpaceStmt"),
-        NodeRef::AlterObjectDependsStmt(_) => todo!("AlterObjectDependsStmt"),
-        NodeRef::AlterObjectSchemaStmt(_) => todo!("AlterObjectSchemaStmt"),
-        NodeRef::AlterOwnerStmt(_) => todo!("AlterOwnerStmt"),
-        NodeRef::AlterOperatorStmt(_) => todo!("AlterOperatorStmt"),
-        NodeRef::AlterTypeStmt(_) => todo!("AlterTypeStmt"),
-        NodeRef::DropOwnedStmt(_) => todo!("DropOwnedStmt"),
-        NodeRef::ReassignOwnedStmt(_) => todo!("ReassignOwnedStmt"),
-        NodeRef::CompositeTypeStmt(_) => todo!("CompositeTypeStmt"),
-        NodeRef::CreateEnumStmt(_) => todo!("CreateEnumStmt"),
-        NodeRef::CreateRangeStmt(_) => todo!("CreateRangeStmt"),
-        NodeRef::AlterEnumStmt(_) => todo!("AlterEnumStmt"),
-        NodeRef::AlterTsdictionaryStmt(_) => todo!("AlterTsdictionaryStmt"),
-        NodeRef::AlterTsconfigurationStmt(_) => todo!("AlterTsconfigurationStmt"),
-        NodeRef::CreateFdwStmt(_) => todo!("CreateFdwStmt"),
-        NodeRef::AlterFdwStmt(_) => todo!("AlterFdwStmt"),
-        NodeRef::CreateForeignServerStmt(_) => todo!("CreateForeignServerStmt"),
-        NodeRef::AlterForeignServerStmt(_) => todo!("AlterForeignServerStmt"),
-        NodeRef::CreateUserMappingStmt(_) => todo!("CreateUserMappingStmt"),
-        NodeRef::AlterUserMappingStmt(_) => todo!("AlterUserMappingStmt"),
-        NodeRef::DropUserMappingStmt(_) => todo!("DropUserMappingStmt"),
-        NodeRef::AlterTableSpaceOptionsStmt(_) => todo!("AlterTableSpaceOptionsStmt"),
-        NodeRef::AlterTableMoveAllStmt(_) => todo!("AlterTableMoveAllStmt"),
-        NodeRef::SecLabelStmt(_) => todo!("SecLabelStmt"),
-        NodeRef::CreateForeignTableStmt(_) => todo!("CreateForeignTableStmt"),
-        NodeRef::ImportForeignSchemaStmt(_) => todo!("ImportForeignSchemaStmt"),
-        NodeRef::CreateExtensionStmt(_) => todo!("CreateExtensionStmt"),
-        NodeRef::AlterExtensionStmt(_) => todo!("AlterExtensionStmt"),
-        NodeRef::AlterExtensionContentsStmt(_) => todo!("AlterExtensionContentsStmt"),
-        NodeRef::CreateEventTrigStmt(_) => todo!("CreateEventTrigStmt"),
-        NodeRef::AlterEventTrigStmt(_) => todo!("AlterEventTrigStmt"),
-        NodeRef::RefreshMatViewStmt(_) => todo!("RefreshMatViewStmt"),
-        NodeRef::ReplicaIdentityStmt(_) => todo!("ReplicaIdentityStmt"),
-        NodeRef::AlterSystemStmt(_) => todo!("AlterSystemStmt"),
-        NodeRef::CreatePolicyStmt(_) => todo!("CreatePolicyStmt"),
-        NodeRef::AlterPolicyStmt(_) => todo!("AlterPolicyStmt"),
-        NodeRef::CreateTransformStmt(_) => todo!("CreateTransformStmt"),
-        NodeRef::CreateAmStmt(_) => todo!("CreateAmStmt"),
-        NodeRef::CreatePublicationStmt(_) => todo!("CreatePublicationStmt"),
-        NodeRef::AlterPublicationStmt(_) => todo!("AlterPublicationStmt"),
-        NodeRef::CreateSubscriptionStmt(_) => todo!("CreateSubscriptionStmt"),
-        NodeRef::AlterSubscriptionStmt(_) => todo!("AlterSubscriptionStmt"),
-        NodeRef::DropSubscriptionStmt(_) => todo!("DropSubscriptionStmt"),
-        NodeRef::CreateStatsStmt(_) => todo!("CreateStatsStmt"),
-        NodeRef::AlterCollationStmt(_) => todo!("AlterCollationStmt"),
-        NodeRef::CallStmt(_) => todo!("CallStmt"),
-        NodeRef::AlterStatsStmt(_) => todo!("AlterStatsStmt"),
-        NodeRef::ParamRef(n) => n.location,
-        NodeRef::FuncCall(n) => n.location,
-        NodeRef::AStar(n) => todo!("AStar"),
-        NodeRef::AIndices(n) => todo!("AIndices"),
-        NodeRef::AIndirection(n) => todo!("AIndirection"),
-        NodeRef::AArrayExpr(n) => n.location,
-        NodeRef::MultiAssignRef(n) => todo!("MultiAssignRef"),
-        NodeRef::TypeCast(n) => n.location,
-        NodeRef::CollateClause(n) => n.location,
-        NodeRef::SortBy(n) => n.location,
-        NodeRef::WindowDef(n) => n.location,
-        NodeRef::RangeSubselect(n) => todo!("RangeSubselect"),
-        NodeRef::RangeFunction(n) => todo!("RangeFunction"),
-        NodeRef::RangeTableSample(n) => n.location,
-        NodeRef::RangeTableFunc(n) => n.location,
-        NodeRef::RangeTableFuncCol(n) => n.location,
-        NodeRef::TypeName(n) => n.location,
-        NodeRef::ColumnDef(n) => n.location,
-        NodeRef::IndexElem(n) => todo!("IndexElem"),
-        NodeRef::Constraint(n) => n.location,
-        NodeRef::DefElem(n) => n.location,
-        NodeRef::RangeTblEntry(n) => todo!("RangeTblEntry"),
-        NodeRef::RangeTblFunction(n) => todo!("RangeTblFunction"),
-        NodeRef::TableSampleClause(n) => todo!("TableSampleClause"),
-        NodeRef::WithCheckOption(n) => todo!("WithCheckOption"),
-        NodeRef::SortGroupClause(n) => todo!("SortGroupClause"),
-        NodeRef::GroupingSet(n) => n.location,
-        NodeRef::WindowClause(n) => todo!("WindowClause"),
-        NodeRef::ObjectWithArgs(n) => todo!("ObjectWithArgs"),
-        NodeRef::AccessPriv(n) => todo!("AccessPriv"),
-        NodeRef::CreateOpClassItem(n) => todo!("CreateOpClassItem"),
-        NodeRef::TableLikeClause(n) => todo!("TableLikeClause"),
-        NodeRef::FunctionParameter(n) => todo!("FunctionParameter"),
-        NodeRef::LockingClause(n) => todo!("LockingClause"),
-        NodeRef::RowMarkClause(n) => todo!("RowMarkClause"),
-        NodeRef::XmlSerialize(n) => n.location,
-        NodeRef::WithClause(n) => n.location,
-        NodeRef::InferClause(n) => n.location,
-        NodeRef::OnConflictClause(n) => n.location,
-        NodeRef::CommonTableExpr(n) => n.location,
-        NodeRef::RoleSpec(n) => n.location,
-        NodeRef::TriggerTransition(n) => todo!("TriggerTransition"),
-        NodeRef::PartitionElem(n) => n.location,
-        NodeRef::PartitionSpec(n) => n.location,
-        NodeRef::PartitionBoundSpec(n) => n.location,
-        NodeRef::PartitionRangeDatum(n) => n.location,
-        NodeRef::PartitionCmd(n) => todo!("PartitionCmd"),
-        NodeRef::VacuumRelation(n) => todo!("VacuumRelation"),
-        NodeRef::InlineCodeBlock(n) => todo!("InlineCodeBlock"),
-        NodeRef::CallContext(n) => todo!("CallContext"),
-        NodeRef::Integer(n) => todo!("Integer"),
-        NodeRef::Float(n) => todo!("Float"),
-        NodeRef::String(n) => todo!("String"),
-        NodeRef::BitString(n) => todo!("BitString"),
-        NodeRef::Null(n) => todo!("Null"),
-        NodeRef::List(n) => todo!("List"),
-        NodeRef::IntList(n) => todo!("IntList"),
-        NodeRef::OidList(n) => todo!("OidList"),
+        // NodeEnum::ResTarget(n) => get_children(n).iter().min_by(|x, y| x.lo).n.location,
+        // NodeRef::AExpr(n) => get_position_for_pg_query_node(
+        //     &n.lexpr.as_ref().unwrap().node.as_ref().unwrap().to_ref(),
+        // ),
+        // NodeRef::RangeVar(n) => n.location,
+        // NodeRef::ColumnRef(n) => n.location,
+        // NodeRef::AConst(n) => n.location,
+        // NodeRef::Alias(n) => todo!("Alias"),
+        // NodeRef::TableFunc(n) => n.location,
+        // NodeRef::Expr(n) => todo!("Expr"),
+        // NodeRef::Var(n) => n.location,
+        // NodeRef::Param(n) => n.location,
+        // NodeRef::Aggref(n) => n.location,
+        // NodeRef::GroupingFunc(n) => n.location,
+        // NodeRef::WindowFunc(n) => n.location,
+        // NodeRef::SubscriptingRef(n) => todo!("SubscriptingRef"),
+        // NodeRef::FuncExpr(n) => n.location,
+        // NodeRef::NamedArgExpr(n) => n.location,
+        // NodeRef::OpExpr(n) => n.location,
+        // NodeRef::DistinctExpr(n) => n.location,
+        // NodeRef::NullIfExpr(n) => n.location,
+        // NodeRef::ScalarArrayOpExpr(n) => n.location,
+        // NodeRef::BoolExpr(n) => n.location,
+        // NodeRef::SubLink(n) => n.location,
+        // NodeRef::SubPlan(n) => {
+        //     get_position_for_pg_query_node(&n.xpr.as_ref().unwrap().node.as_ref().unwrap().to_ref())
+        // }
+        // NodeRef::AlternativeSubPlan(n) => todo!("AlternativeSubPlan"),
+        // NodeRef::FieldSelect(n) => todo!("FieldSelect"),
+        // NodeRef::FieldStore(n) => todo!("FieldStore"),
+        // NodeRef::RelabelType(n) => n.location,
+        // NodeRef::CoerceViaIo(n) => n.location,
+        // NodeRef::ArrayCoerceExpr(n) => n.location,
+        // NodeRef::ConvertRowtypeExpr(n) => n.location,
+        // NodeRef::CollateExpr(n) => n.location,
+        // NodeRef::CaseExpr(n) => n.location,
+        // NodeRef::CaseWhen(n) => n.location,
+        // NodeRef::CaseTestExpr(n) => todo!("CaseTestExpr"),
+        // NodeRef::ArrayExpr(n) => n.location,
+        // NodeRef::RowExpr(n) => n.location,
+        // NodeRef::RowCompareExpr(n) => todo!("RowCompareExpr"),
+        // NodeRef::CoalesceExpr(n) => n.location,
+        // NodeRef::MinMaxExpr(n) => n.location,
+        // NodeRef::SqlvalueFunction(n) => n.location,
+        // NodeRef::XmlExpr(n) => n.location,
+        // NodeRef::NullTest(n) => n.location,
+        // NodeRef::BooleanTest(n) => n.location,
+        // NodeRef::CoerceToDomain(n) => n.location,
+        // NodeRef::CoerceToDomainValue(n) => n.location,
+        // NodeRef::SetToDefault(n) => n.location,
+        // NodeRef::CurrentOfExpr(n) => todo!("CurrentOfExpr"),
+        // NodeRef::NextValueExpr(_) => todo!("NextValueExpr"),
+        // NodeRef::InferenceElem(_) => todo!("InferenceElem"),
+        // NodeRef::TargetEntry(_) => todo!("TargetEntry"),
+        // NodeRef::RangeTblRef(_) => todo!("RangeTblRef"),
+        // NodeRef::JoinExpr(_) => todo!("JoinExpr"),
+        // NodeRef::FromExpr(_) => todo!("FromExpr"),
+        // NodeRef::OnConflictExpr(_) => todo!("OnConflictExpr"),
+        // NodeRef::IntoClause(_) => todo!("IntoClause"),
+        // NodeRef::RawStmt(_) => todo!("RawStmt"),
+        // NodeRef::Query(_) => todo!("Query"),
+        // NodeRef::InsertStmt(_) => todo!("InsertStmt"),
+        // NodeRef::DeleteStmt(_) => todo!("DeleteStmt"),
+        // NodeRef::UpdateStmt(_) => todo!("UpdateStmt"),
+        // NodeRef::SelectStmt(_) => todo!("SelectStmt"),
+        // NodeRef::AlterTableStmt(_) => -1,
+        // NodeRef::AlterTableCmd(_) => todo!("AlterTableCmd"),
+        // NodeRef::AlterDomainStmt(_) => todo!("AlterDomainStmt"),
+        // NodeRef::SetOperationStmt(_) => todo!("SetOperationStmt"),
+        // NodeRef::GrantStmt(_) => -1,
+        // NodeRef::GrantRoleStmt(_) => todo!("GrantRoleStmt"),
+        // NodeRef::AlterDefaultPrivilegesStmt(_) => todo!("AlterDefaultPrivilegesStmt"),
+        // NodeRef::ClosePortalStmt(_) => todo!("ClosePortalStmt"),
+        // NodeRef::ClusterStmt(_) => todo!("ClusterStmt"),
+        // NodeRef::CopyStmt(_) => todo!("CopyStmt"),
+        // NodeRef::CreateStmt(_) => -1,
+        // NodeRef::DefineStmt(_) => todo!("DefineStmt"),
+        // NodeRef::DropStmt(_) => todo!("DropStmt"),
+        // NodeRef::TruncateStmt(_) => todo!("TruncateStmt"),
+        // NodeRef::CommentStmt(_) => todo!("CommentStmt"),
+        // NodeRef::FetchStmt(_) => todo!("FetchStmt"),
+        // NodeRef::IndexStmt(_) => todo!("IndexStmt"),
+        // NodeRef::CreateFunctionStmt(_) => todo!("CreateFunctionStmt"),
+        // NodeRef::AlterFunctionStmt(_) => todo!("AlterFunctionStmt"),
+        // NodeRef::DoStmt(_) => todo!("DoStmt"),
+        // NodeRef::RenameStmt(_) => todo!("RenameStmt"),
+        // NodeRef::RuleStmt(_) => todo!("RuleStmt"),
+        // NodeRef::NotifyStmt(_) => todo!("NotifyStmt"),
+        // NodeRef::ListenStmt(_) => todo!("ListenStmt"),
+        // NodeRef::UnlistenStmt(_) => todo!("UnlistenStmt"),
+        // NodeRef::TransactionStmt(_) => todo!("TransactionStmt"),
+        // NodeRef::ViewStmt(_) => todo!("ViewStmt"),
+        // NodeRef::LoadStmt(_) => todo!("LoadStmt"),
+        // NodeRef::CreateDomainStmt(_) => todo!("CreateDomainStmt"),
+        // NodeRef::CreatedbStmt(_) => todo!("CreatedbStmt"),
+        // NodeRef::DropdbStmt(_) => todo!("DropdbStmt"),
+        // NodeRef::VacuumStmt(_) => todo!("VacuumStmt"),
+        // NodeRef::ExplainStmt(_) => todo!("ExplainStmt"),
+        // NodeRef::CreateTableAsStmt(_) => todo!("CreateTableAsStmt"),
+        // NodeRef::CreateSeqStmt(_) => todo!("CreateSeqStmt"),
+        // NodeRef::AlterSeqStmt(_) => todo!("AlterSeqStmt"),
+        // NodeRef::VariableSetStmt(_) => todo!("VariableSetStmt"),
+        // NodeRef::VariableShowStmt(_) => todo!("VariableShowStmt"),
+        // NodeRef::DiscardStmt(_) => todo!("DiscardStmt"),
+        // NodeRef::CreateTrigStmt(_) => todo!("CreateTrigStmt"),
+        // NodeRef::CreatePlangStmt(_) => todo!("CreatePlangStmt"),
+        // NodeRef::CreateRoleStmt(_) => todo!("CreateRoleStmt"),
+        // NodeRef::AlterRoleStmt(_) => todo!("AlterRoleStmt"),
+        // NodeRef::DropRoleStmt(_) => todo!("DropRoleStmt"),
+        // NodeRef::LockStmt(_) => todo!("LockStmt"),
+        // NodeRef::ConstraintsSetStmt(_) => todo!("ConstraintsSetStmt"),
+        // NodeRef::ReindexStmt(_) => todo!("ReindexStmt"),
+        // NodeRef::CheckPointStmt(_) => todo!("CheckPointStmt"),
+        // NodeRef::CreateSchemaStmt(_) => todo!("CreateSchemaStmt"),
+        // NodeRef::AlterDatabaseStmt(_) => todo!("AlterDatabaseStmt"),
+        // NodeRef::AlterDatabaseSetStmt(_) => todo!("AlterDatabaseSetStmt"),
+        // NodeRef::AlterRoleSetStmt(_) => todo!("AlterRoleSetStmt"),
+        // NodeRef::CreateConversionStmt(_) => todo!("CreateConversionStmt"),
+        // NodeRef::CreateCastStmt(_) => todo!("CreateCastStmt"),
+        // NodeRef::CreateOpClassStmt(_) => todo!("CreateOpClassStmt"),
+        // NodeRef::CreateOpFamilyStmt(_) => todo!("CreateOpFamilyStmt"),
+        // NodeRef::AlterOpFamilyStmt(_) => todo!("AlterOpFamilyStmt"),
+        // NodeRef::PrepareStmt(_) => todo!("PrepareStmt"),
+        // NodeRef::ExecuteStmt(_) => todo!("ExecuteStmt"),
+        // NodeRef::DeallocateStmt(_) => todo!("DeallocateStmt"),
+        // NodeRef::DeclareCursorStmt(_) => todo!("DeclareCursorStmt"),
+        // NodeRef::CreateTableSpaceStmt(_) => todo!("CreateTableSpaceStmt"),
+        // NodeRef::DropTableSpaceStmt(_) => todo!("DropTableSpaceStmt"),
+        // NodeRef::AlterObjectDependsStmt(_) => todo!("AlterObjectDependsStmt"),
+        // NodeRef::AlterObjectSchemaStmt(_) => todo!("AlterObjectSchemaStmt"),
+        // NodeRef::AlterOwnerStmt(_) => todo!("AlterOwnerStmt"),
+        // NodeRef::AlterOperatorStmt(_) => todo!("AlterOperatorStmt"),
+        // NodeRef::AlterTypeStmt(_) => todo!("AlterTypeStmt"),
+        // NodeRef::DropOwnedStmt(_) => todo!("DropOwnedStmt"),
+        // NodeRef::ReassignOwnedStmt(_) => todo!("ReassignOwnedStmt"),
+        // NodeRef::CompositeTypeStmt(_) => todo!("CompositeTypeStmt"),
+        // NodeRef::CreateEnumStmt(_) => todo!("CreateEnumStmt"),
+        // NodeRef::CreateRangeStmt(_) => todo!("CreateRangeStmt"),
+        // NodeRef::AlterEnumStmt(_) => todo!("AlterEnumStmt"),
+        // NodeRef::AlterTsdictionaryStmt(_) => todo!("AlterTsdictionaryStmt"),
+        // NodeRef::AlterTsconfigurationStmt(_) => todo!("AlterTsconfigurationStmt"),
+        // NodeRef::CreateFdwStmt(_) => todo!("CreateFdwStmt"),
+        // NodeRef::AlterFdwStmt(_) => todo!("AlterFdwStmt"),
+        // NodeRef::CreateForeignServerStmt(_) => todo!("CreateForeignServerStmt"),
+        // NodeRef::AlterForeignServerStmt(_) => todo!("AlterForeignServerStmt"),
+        // NodeRef::CreateUserMappingStmt(_) => todo!("CreateUserMappingStmt"),
+        // NodeRef::AlterUserMappingStmt(_) => todo!("AlterUserMappingStmt"),
+        // NodeRef::DropUserMappingStmt(_) => todo!("DropUserMappingStmt"),
+        // NodeRef::AlterTableSpaceOptionsStmt(_) => todo!("AlterTableSpaceOptionsStmt"),
+        // NodeRef::AlterTableMoveAllStmt(_) => todo!("AlterTableMoveAllStmt"),
+        // NodeRef::SecLabelStmt(_) => todo!("SecLabelStmt"),
+        // NodeRef::CreateForeignTableStmt(_) => todo!("CreateForeignTableStmt"),
+        // NodeRef::ImportForeignSchemaStmt(_) => todo!("ImportForeignSchemaStmt"),
+        // NodeRef::CreateExtensionStmt(_) => todo!("CreateExtensionStmt"),
+        // NodeRef::AlterExtensionStmt(_) => todo!("AlterExtensionStmt"),
+        // NodeRef::AlterExtensionContentsStmt(_) => todo!("AlterExtensionContentsStmt"),
+        // NodeRef::CreateEventTrigStmt(_) => todo!("CreateEventTrigStmt"),
+        // NodeRef::AlterEventTrigStmt(_) => todo!("AlterEventTrigStmt"),
+        // NodeRef::RefreshMatViewStmt(_) => todo!("RefreshMatViewStmt"),
+        // NodeRef::ReplicaIdentityStmt(_) => todo!("ReplicaIdentityStmt"),
+        // NodeRef::AlterSystemStmt(_) => todo!("AlterSystemStmt"),
+        // NodeRef::CreatePolicyStmt(_) => todo!("CreatePolicyStmt"),
+        // NodeRef::AlterPolicyStmt(_) => todo!("AlterPolicyStmt"),
+        // NodeRef::CreateTransformStmt(_) => todo!("CreateTransformStmt"),
+        // NodeRef::CreateAmStmt(_) => todo!("CreateAmStmt"),
+        // NodeRef::CreatePublicationStmt(_) => todo!("CreatePublicationStmt"),
+        // NodeRef::AlterPublicationStmt(_) => todo!("AlterPublicationStmt"),
+        // NodeRef::CreateSubscriptionStmt(_) => todo!("CreateSubscriptionStmt"),
+        // NodeRef::AlterSubscriptionStmt(_) => todo!("AlterSubscriptionStmt"),
+        // NodeRef::DropSubscriptionStmt(_) => todo!("DropSubscriptionStmt"),
+        // NodeRef::CreateStatsStmt(_) => todo!("CreateStatsStmt"),
+        // NodeRef::AlterCollationStmt(_) => todo!("AlterCollationStmt"),
+        // NodeRef::CallStmt(_) => todo!("CallStmt"),
+        // NodeRef::AlterStatsStmt(_) => todo!("AlterStatsStmt"),
+        // NodeRef::ParamRef(n) => n.location,
+        // NodeRef::FuncCall(n) => n.location,
+        // NodeRef::AStar(n) => todo!("AStar"),
+        // NodeRef::AIndices(n) => todo!("AIndices"),
+        // NodeRef::AIndirection(n) => todo!("AIndirection"),
+        // NodeRef::AArrayExpr(n) => n.location,
+        // NodeRef::MultiAssignRef(n) => todo!("MultiAssignRef"),
+        // NodeRef::TypeCast(n) => n.location,
+        // NodeRef::CollateClause(n) => n.location,
+        // NodeRef::SortBy(n) => n.location,
+        // NodeRef::WindowDef(n) => n.location,
+        // NodeRef::RangeSubselect(n) => todo!("RangeSubselect"),
+        // NodeRef::RangeFunction(n) => todo!("RangeFunction"),
+        // NodeRef::RangeTableSample(n) => n.location,
+        // NodeRef::RangeTableFunc(n) => n.location,
+        // NodeRef::RangeTableFuncCol(n) => n.location,
+        // NodeRef::TypeName(n) => n.location,
+        // NodeRef::ColumnDef(n) => n.location,
+        // NodeRef::IndexElem(n) => todo!("IndexElem"),
+        // NodeRef::Constraint(n) => n.location,
+        // NodeRef::DefElem(n) => n.location,
+        // NodeRef::RangeTblEntry(n) => todo!("RangeTblEntry"),
+        // NodeRef::RangeTblFunction(n) => todo!("RangeTblFunction"),
+        // NodeRef::TableSampleClause(n) => todo!("TableSampleClause"),
+        // NodeRef::WithCheckOption(n) => todo!("WithCheckOption"),
+        // NodeRef::SortGroupClause(n) => todo!("SortGroupClause"),
+        // NodeRef::GroupingSet(n) => n.location,
+        // NodeRef::WindowClause(n) => todo!("WindowClause"),
+        // NodeRef::ObjectWithArgs(n) => todo!("ObjectWithArgs"),
+        // NodeRef::AccessPriv(n) => todo!("AccessPriv"),
+        // NodeRef::CreateOpClassItem(n) => todo!("CreateOpClassItem"),
+        // NodeRef::TableLikeClause(n) => todo!("TableLikeClause"),
+        // NodeRef::FunctionParameter(n) => todo!("FunctionParameter"),
+        // NodeRef::LockingClause(n) => todo!("LockingClause"),
+        // NodeRef::RowMarkClause(n) => todo!("RowMarkClause"),
+        // NodeRef::XmlSerialize(n) => n.location,
+        // NodeRef::WithClause(n) => n.location,
+        // NodeRef::InferClause(n) => n.location,
+        // NodeRef::OnConflictClause(n) => n.location,
+        // NodeRef::CommonTableExpr(n) => n.location,
+        // NodeRef::RoleSpec(n) => n.location,
+        // NodeRef::TriggerTransition(n) => todo!("TriggerTransition"),
+        // NodeRef::PartitionElem(n) => n.location,
+        // NodeRef::PartitionSpec(n) => n.location,
+        // NodeRef::PartitionBoundSpec(n) => n.location,
+        // NodeRef::PartitionRangeDatum(n) => n.location,
+        // NodeRef::PartitionCmd(n) => todo!("PartitionCmd"),
+        // NodeRef::VacuumRelation(n) => todo!("VacuumRelation"),
+        // NodeRef::InlineCodeBlock(n) => todo!("InlineCodeBlock"),
+        // NodeRef::CallContext(n) => todo!("CallContext"),
+        // NodeRef::Integer(n) => todo!("Integer"),
+        // NodeRef::Float(n) => todo!("Float"),
+        // NodeRef::String(n) => todo!("String"),
+        // NodeRef::BitString(n) => todo!("BitString"),
+        // NodeRef::Null(n) => todo!("Null"),
+        // NodeRef::List(n) => todo!("List"),
+        // NodeRef::IntList(n) => todo!("IntList"),
+        // NodeRef::OidList(n) => todo!("OidList"),
         _ => -1,
     }
 }
@@ -286,5 +299,6 @@ mod tests {
 );";
 
         let parsed = pg_query::parse(input);
+        parsed.unwrap().protobuf.nodes().iter().for_each(|n| {});
     }
 }
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
new file mode 100644
index 00000000..e6237e2b
--- /dev/null
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -0,0 +1,4071 @@
+//! Utilities for working with pg_query.rs
+//! This file is generated from the libg_query proto
+use pg_query::{NodeEnum, NodeRef};
+
+pub fn get_location(node: NodeEnum) -> Option<i32> {
+    match &node {
+        NodeEnum::Alias(_) => None,
+        NodeEnum::RangeVar(n) => Some(n.location),
+        NodeEnum::TableFunc(n) => Some(n.location),
+        NodeEnum::Var(n) => Some(n.location),
+        NodeEnum::Param(n) => Some(n.location),
+        NodeEnum::Aggref(n) => Some(n.location),
+        NodeEnum::GroupingFunc(n) => Some(n.location),
+        NodeEnum::WindowFunc(n) => Some(n.location),
+        NodeEnum::SubscriptingRef(_) => None,
+        NodeEnum::FuncExpr(n) => Some(n.location),
+        NodeEnum::NamedArgExpr(n) => Some(n.location),
+        NodeEnum::OpExpr(n) => Some(n.location),
+        NodeEnum::DistinctExpr(n) => Some(n.location),
+        NodeEnum::NullIfExpr(n) => Some(n.location),
+        NodeEnum::ScalarArrayOpExpr(n) => Some(n.location),
+        NodeEnum::BoolExpr(n) => Some(n.location),
+        NodeEnum::SubLink(n) => Some(n.location),
+        NodeEnum::SubPlan(_) => None,
+        NodeEnum::AlternativeSubPlan(_) => None,
+        NodeEnum::FieldSelect(_) => None,
+        NodeEnum::FieldStore(_) => None,
+        NodeEnum::RelabelType(n) => Some(n.location),
+        NodeEnum::CoerceViaIo(n) => Some(n.location),
+        NodeEnum::ArrayCoerceExpr(n) => Some(n.location),
+        NodeEnum::ConvertRowtypeExpr(n) => Some(n.location),
+        NodeEnum::CollateExpr(n) => Some(n.location),
+        NodeEnum::CaseExpr(n) => Some(n.location),
+        NodeEnum::CaseWhen(n) => Some(n.location),
+        NodeEnum::CaseTestExpr(_) => None,
+        NodeEnum::ArrayExpr(n) => Some(n.location),
+        NodeEnum::RowExpr(n) => Some(n.location),
+        NodeEnum::RowCompareExpr(_) => None,
+        NodeEnum::CoalesceExpr(n) => Some(n.location),
+        NodeEnum::MinMaxExpr(n) => Some(n.location),
+        NodeEnum::SqlvalueFunction(n) => Some(n.location),
+        NodeEnum::XmlExpr(n) => Some(n.location),
+        NodeEnum::NullTest(n) => Some(n.location),
+        NodeEnum::BooleanTest(n) => Some(n.location),
+        NodeEnum::CoerceToDomain(n) => Some(n.location),
+        NodeEnum::CoerceToDomainValue(n) => Some(n.location),
+        NodeEnum::SetToDefault(n) => Some(n.location),
+        NodeEnum::CurrentOfExpr(_) => None,
+        NodeEnum::NextValueExpr(_) => None,
+        NodeEnum::InferenceElem(_) => None,
+        NodeEnum::TargetEntry(_) => None,
+        NodeEnum::RangeTblRef(_) => None,
+        NodeEnum::JoinExpr(_) => None,
+        NodeEnum::FromExpr(_) => None,
+        NodeEnum::OnConflictExpr(_) => None,
+        NodeEnum::IntoClause(_) => None,
+        NodeEnum::MergeAction(_) => None,
+        NodeEnum::RawStmt(_) => None,
+        NodeEnum::Query(_) => None,
+        NodeEnum::InsertStmt(_) => None,
+        NodeEnum::DeleteStmt(_) => None,
+        NodeEnum::UpdateStmt(_) => None,
+        NodeEnum::MergeStmt(_) => None,
+        NodeEnum::SelectStmt(_) => None,
+        NodeEnum::ReturnStmt(_) => None,
+        NodeEnum::PlassignStmt(n) => Some(n.location),
+        NodeEnum::AlterTableStmt(_) => None,
+        NodeEnum::AlterTableCmd(_) => None,
+        NodeEnum::AlterDomainStmt(_) => None,
+        NodeEnum::SetOperationStmt(_) => None,
+        NodeEnum::GrantStmt(_) => None,
+        NodeEnum::GrantRoleStmt(_) => None,
+        NodeEnum::AlterDefaultPrivilegesStmt(_) => None,
+        NodeEnum::ClosePortalStmt(_) => None,
+        NodeEnum::ClusterStmt(_) => None,
+        NodeEnum::CopyStmt(_) => None,
+        NodeEnum::CreateStmt(_) => None,
+        NodeEnum::DefineStmt(_) => None,
+        NodeEnum::DropStmt(_) => None,
+        NodeEnum::TruncateStmt(_) => None,
+        NodeEnum::CommentStmt(_) => None,
+        NodeEnum::FetchStmt(_) => None,
+        NodeEnum::IndexStmt(_) => None,
+        NodeEnum::CreateFunctionStmt(_) => None,
+        NodeEnum::AlterFunctionStmt(_) => None,
+        NodeEnum::DoStmt(_) => None,
+        NodeEnum::RenameStmt(_) => None,
+        NodeEnum::RuleStmt(_) => None,
+        NodeEnum::NotifyStmt(_) => None,
+        NodeEnum::ListenStmt(_) => None,
+        NodeEnum::UnlistenStmt(_) => None,
+        NodeEnum::TransactionStmt(_) => None,
+        NodeEnum::ViewStmt(_) => None,
+        NodeEnum::LoadStmt(_) => None,
+        NodeEnum::CreateDomainStmt(_) => None,
+        NodeEnum::CreatedbStmt(_) => None,
+        NodeEnum::DropdbStmt(_) => None,
+        NodeEnum::VacuumStmt(_) => None,
+        NodeEnum::ExplainStmt(_) => None,
+        NodeEnum::CreateTableAsStmt(_) => None,
+        NodeEnum::CreateSeqStmt(_) => None,
+        NodeEnum::AlterSeqStmt(_) => None,
+        NodeEnum::VariableSetStmt(_) => None,
+        NodeEnum::VariableShowStmt(_) => None,
+        NodeEnum::DiscardStmt(_) => None,
+        NodeEnum::CreateTrigStmt(_) => None,
+        NodeEnum::CreatePlangStmt(_) => None,
+        NodeEnum::CreateRoleStmt(_) => None,
+        NodeEnum::AlterRoleStmt(_) => None,
+        NodeEnum::DropRoleStmt(_) => None,
+        NodeEnum::LockStmt(_) => None,
+        NodeEnum::ConstraintsSetStmt(_) => None,
+        NodeEnum::ReindexStmt(_) => None,
+        NodeEnum::CheckPointStmt(_) => None,
+        NodeEnum::CreateSchemaStmt(_) => None,
+        NodeEnum::AlterDatabaseStmt(_) => None,
+        NodeEnum::AlterDatabaseRefreshCollStmt(_) => None,
+        NodeEnum::AlterDatabaseSetStmt(_) => None,
+        NodeEnum::AlterRoleSetStmt(_) => None,
+        NodeEnum::CreateConversionStmt(_) => None,
+        NodeEnum::CreateCastStmt(_) => None,
+        NodeEnum::CreateOpClassStmt(_) => None,
+        NodeEnum::CreateOpFamilyStmt(_) => None,
+        NodeEnum::AlterOpFamilyStmt(_) => None,
+        NodeEnum::PrepareStmt(_) => None,
+        NodeEnum::ExecuteStmt(_) => None,
+        NodeEnum::DeallocateStmt(_) => None,
+        NodeEnum::DeclareCursorStmt(_) => None,
+        NodeEnum::CreateTableSpaceStmt(_) => None,
+        NodeEnum::DropTableSpaceStmt(_) => None,
+        NodeEnum::AlterObjectDependsStmt(_) => None,
+        NodeEnum::AlterObjectSchemaStmt(_) => None,
+        NodeEnum::AlterOwnerStmt(_) => None,
+        NodeEnum::AlterOperatorStmt(_) => None,
+        NodeEnum::AlterTypeStmt(_) => None,
+        NodeEnum::DropOwnedStmt(_) => None,
+        NodeEnum::ReassignOwnedStmt(_) => None,
+        NodeEnum::CompositeTypeStmt(_) => None,
+        NodeEnum::CreateEnumStmt(_) => None,
+        NodeEnum::CreateRangeStmt(_) => None,
+        NodeEnum::AlterEnumStmt(_) => None,
+        NodeEnum::AlterTsdictionaryStmt(_) => None,
+        NodeEnum::AlterTsconfigurationStmt(_) => None,
+        NodeEnum::CreateFdwStmt(_) => None,
+        NodeEnum::AlterFdwStmt(_) => None,
+        NodeEnum::CreateForeignServerStmt(_) => None,
+        NodeEnum::AlterForeignServerStmt(_) => None,
+        NodeEnum::CreateUserMappingStmt(_) => None,
+        NodeEnum::AlterUserMappingStmt(_) => None,
+        NodeEnum::DropUserMappingStmt(_) => None,
+        NodeEnum::AlterTableSpaceOptionsStmt(_) => None,
+        NodeEnum::AlterTableMoveAllStmt(_) => None,
+        NodeEnum::SecLabelStmt(_) => None,
+        NodeEnum::CreateForeignTableStmt(_) => None,
+        NodeEnum::ImportForeignSchemaStmt(_) => None,
+        NodeEnum::CreateExtensionStmt(_) => None,
+        NodeEnum::AlterExtensionStmt(_) => None,
+        NodeEnum::AlterExtensionContentsStmt(_) => None,
+        NodeEnum::CreateEventTrigStmt(_) => None,
+        NodeEnum::AlterEventTrigStmt(_) => None,
+        NodeEnum::RefreshMatViewStmt(_) => None,
+        NodeEnum::ReplicaIdentityStmt(_) => None,
+        NodeEnum::AlterSystemStmt(_) => None,
+        NodeEnum::CreatePolicyStmt(_) => None,
+        NodeEnum::AlterPolicyStmt(_) => None,
+        NodeEnum::CreateTransformStmt(_) => None,
+        NodeEnum::CreateAmStmt(_) => None,
+        NodeEnum::CreatePublicationStmt(_) => None,
+        NodeEnum::AlterPublicationStmt(_) => None,
+        NodeEnum::CreateSubscriptionStmt(_) => None,
+        NodeEnum::AlterSubscriptionStmt(_) => None,
+        NodeEnum::DropSubscriptionStmt(_) => None,
+        NodeEnum::CreateStatsStmt(_) => None,
+        NodeEnum::AlterCollationStmt(_) => None,
+        NodeEnum::CallStmt(_) => None,
+        NodeEnum::AlterStatsStmt(_) => None,
+        NodeEnum::AExpr(n) => Some(n.location),
+        NodeEnum::ColumnRef(n) => Some(n.location),
+        NodeEnum::ParamRef(n) => Some(n.location),
+        NodeEnum::FuncCall(n) => Some(n.location),
+        NodeEnum::AStar(_) => None,
+        NodeEnum::AIndices(_) => None,
+        NodeEnum::AIndirection(_) => None,
+        NodeEnum::AArrayExpr(n) => Some(n.location),
+        NodeEnum::ResTarget(n) => Some(n.location),
+        NodeEnum::MultiAssignRef(_) => None,
+        NodeEnum::TypeCast(n) => Some(n.location),
+        NodeEnum::CollateClause(n) => Some(n.location),
+        NodeEnum::SortBy(n) => Some(n.location),
+        NodeEnum::WindowDef(n) => Some(n.location),
+        NodeEnum::RangeSubselect(_) => None,
+        NodeEnum::RangeFunction(_) => None,
+        NodeEnum::RangeTableSample(n) => Some(n.location),
+        NodeEnum::RangeTableFunc(n) => Some(n.location),
+        NodeEnum::RangeTableFuncCol(n) => Some(n.location),
+        NodeEnum::TypeName(n) => Some(n.location),
+        NodeEnum::ColumnDef(n) => Some(n.location),
+        NodeEnum::IndexElem(_) => None,
+        NodeEnum::StatsElem(_) => None,
+        NodeEnum::Constraint(n) => Some(n.location),
+        NodeEnum::DefElem(n) => Some(n.location),
+        NodeEnum::RangeTblEntry(_) => None,
+        NodeEnum::RangeTblFunction(_) => None,
+        NodeEnum::TableSampleClause(_) => None,
+        NodeEnum::WithCheckOption(_) => None,
+        NodeEnum::SortGroupClause(_) => None,
+        NodeEnum::GroupingSet(n) => Some(n.location),
+        NodeEnum::WindowClause(_) => None,
+        NodeEnum::ObjectWithArgs(_) => None,
+        NodeEnum::AccessPriv(_) => None,
+        NodeEnum::CreateOpClassItem(_) => None,
+        NodeEnum::TableLikeClause(_) => None,
+        NodeEnum::FunctionParameter(_) => None,
+        NodeEnum::LockingClause(_) => None,
+        NodeEnum::RowMarkClause(_) => None,
+        NodeEnum::XmlSerialize(n) => Some(n.location),
+        NodeEnum::WithClause(n) => Some(n.location),
+        NodeEnum::InferClause(n) => Some(n.location),
+        NodeEnum::OnConflictClause(n) => Some(n.location),
+        NodeEnum::CtesearchClause(n) => Some(n.location),
+        NodeEnum::CtecycleClause(n) => Some(n.location),
+        NodeEnum::CommonTableExpr(n) => Some(n.location),
+        NodeEnum::MergeWhenClause(_) => None,
+        NodeEnum::RoleSpec(n) => Some(n.location),
+        NodeEnum::TriggerTransition(_) => None,
+        NodeEnum::PartitionElem(n) => Some(n.location),
+        NodeEnum::PartitionSpec(n) => Some(n.location),
+        NodeEnum::PartitionBoundSpec(n) => Some(n.location),
+        NodeEnum::PartitionRangeDatum(n) => Some(n.location),
+        NodeEnum::PartitionCmd(_) => None,
+        NodeEnum::VacuumRelation(_) => None,
+        NodeEnum::PublicationObjSpec(n) => Some(n.location),
+        NodeEnum::PublicationTable(_) => None,
+        NodeEnum::InlineCodeBlock(_) => None,
+        NodeEnum::CallContext(_) => None,
+        NodeEnum::Integer(_) => None,
+        NodeEnum::Float(_) => None,
+        NodeEnum::Boolean(_) => None,
+        NodeEnum::String(_) => None,
+        NodeEnum::BitString(_) => None,
+        NodeEnum::List(_) => None,
+        NodeEnum::IntList(_) => None,
+        NodeEnum::OidList(_) => None,
+        NodeEnum::AConst(n) => Some(n.location),
+    }
+}
+
+/// Returns the node and all its childrens, recursively
+pub fn get_nested_nodes(node: NodeEnum) -> Vec<NodeEnum> {
+    match &node {
+        NodeEnum::Alias(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .colnames
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RangeVar(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
+                n.alias.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::TableFunc(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .ns_uris
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .ns_names
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.docexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.rowexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .colnames
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .coltypes
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .coltypmods
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .colcollations
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .colexprs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .coldefexprs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::Var(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::Param(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::Aggref(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .aggargtypes
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .aggdirectargs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .aggorder
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .aggdistinct
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.aggfilter.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::GroupingFunc(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .refs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .cols
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::WindowFunc(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.aggfilter.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::SubscriptingRef(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .refupperindexpr
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .reflowerindexpr
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.refexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.refassgnexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::FuncExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::NamedArgExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::OpExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DistinctExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::NullIfExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ScalarArrayOpExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::BoolExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::SubLink(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.testexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .oper_name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.subselect.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::SubPlan(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.testexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .param_ids
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .set_param
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .par_param
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlternativeSubPlan(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .subplans
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::FieldSelect(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::FieldStore(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .newvals
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .fieldnums
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RelabelType(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CoerceViaIo(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::ArrayCoerceExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.elemexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::ConvertRowtypeExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CollateExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CaseExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.defresult.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CaseWhen(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.result.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CaseTestExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::ArrayExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .elements
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RowExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .colnames
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RowCompareExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .opnos
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .opfamilies
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .inputcollids
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .largs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .rargs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CoalesceExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::MinMaxExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::SqlvalueFunction(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::XmlExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .named_args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .arg_names
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::NullTest(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::BooleanTest(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CoerceToDomain(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CoerceToDomainValue(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::SetToDefault(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CurrentOfExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::NextValueExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::InferenceElem(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::TargetEntry(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::RangeTblRef(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::JoinExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.larg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.rarg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .using_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
+                n.join_using_alias.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.quals.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
+                n.alias.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::FromExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .fromlist
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.quals.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::OnConflictExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .arbiter_elems
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.arbiter_where.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .on_conflict_set
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.on_conflict_where
+                    .as_ref()
+                    .unwrap()
+                    .to_owned()
+                    .node
+                    .unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .excl_rel_tlist
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::IntoClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.rel.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .col_names
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.view_query.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::MergeAction(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.qual.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .target_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .update_colnos
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RawStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.stmt.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::Query(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.utility_stmt.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .cte_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .rtable
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::FromExpr(
+                n.jointree.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .merge_action_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .target_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::OnConflictExpr(
+                n.on_conflict.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .returning_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .group_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .grouping_sets
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.having_qual.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .window_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .distinct_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .sort_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.limit_offset.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.limit_count.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .row_marks
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.set_operations.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .constraint_deps
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .with_check_options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::InsertStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .cols
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.select_stmt.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::OnConflictClause(
+                n.on_conflict_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .returning_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
+                n.with_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::DeleteStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .using_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .returning_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
+                n.with_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::UpdateStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .target_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .from_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .returning_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
+                n.with_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::MergeStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.source_relation.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.join_condition.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .merge_when_clauses
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
+                n.with_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::SelectStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .distinct_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::IntoClause(
+                n.into_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .target_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .from_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .group_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.having_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .window_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .values_lists
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .sort_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.limit_offset.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.limit_count.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .locking_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
+                n.with_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::SelectStmt(
+                n.larg.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::SelectStmt(
+                n.rarg.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::ReturnStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.returnval.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::PlassignStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .indirection
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::SelectStmt(
+                n.val.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::AlterTableStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .cmds
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterTableCmd(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.newowner.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.def.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::AlterDomainStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .type_name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.def.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::SetOperationStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.larg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.rarg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .col_types
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .col_typmods
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .col_collations
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .group_clauses
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::GrantStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .objects
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .privileges
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .grantees
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.grantor.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::GrantRoleStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .granted_roles
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .grantee_roles
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.grantor.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::AlterDefaultPrivilegesStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::GrantStmt(
+                n.action.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::ClosePortalStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::ClusterStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .params
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CopyStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.query.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .attlist
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CreateStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .table_elts
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .inh_relations
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::PartitionBoundSpec(
+                n.partbound.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::PartitionSpec(
+                n.partspec.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.of_typename.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .constraints
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DefineStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .defnames
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .definition
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DropStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .objects
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::TruncateStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .relations
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CommentStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.object.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::FetchStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::IndexStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .index_params
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .index_including_params
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .exclude_op_names
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateFunctionStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .funcname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .parameters
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.return_type.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.sql_body.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::AlterFunctionStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
+                n.func.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .actions
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DoStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RenameStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.object.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::RuleStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .actions
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::NotifyStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::ListenStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::UnlistenStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::TransactionStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ViewStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.view.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .aliases
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.query.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::LoadStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::CreateDomainStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .domainname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.type_name.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::CollateClause(
+                n.coll_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .constraints
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreatedbStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DropdbStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::VacuumStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .rels
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ExplainStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.query.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateTableAsStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.query.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::IntoClause(
+                n.into.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::CreateSeqStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.sequence.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterSeqStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.sequence.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::VariableSetStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::VariableShowStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::DiscardStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::CreateTrigStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .funcname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .columns
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.when_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .transition_rels
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.constrrel.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::CreatePlangStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .plhandler
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .plinline
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .plvalidator
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateRoleStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterRoleStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.role.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DropRoleStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .roles
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::LockStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .relations
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ConstraintsSetStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .constraints
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ReindexStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .params
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CheckPointStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::CreateSchemaStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.authrole.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .schema_elts
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterDatabaseStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterDatabaseRefreshCollStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::AlterDatabaseSetStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::VariableSetStmt(
+                n.setstmt.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::AlterRoleSetStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.role.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::VariableSetStmt(
+                n.setstmt.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::CreateConversionStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .conversion_name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .func_name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateCastStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.sourcetype.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.targettype.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
+                n.func.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::CreateOpClassStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .opclassname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .opfamilyname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.datatype.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .items
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateOpFamilyStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .opfamilyname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterOpFamilyStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .opfamilyname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .items
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::PrepareStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .argtypes
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.query.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::ExecuteStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .params
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DeallocateStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::DeclareCursorStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.query.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CreateTableSpaceStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.owner.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DropTableSpaceStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::AlterObjectDependsStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.object.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::String(
+                n.extname.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::AlterObjectSchemaStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.object.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::AlterOwnerStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.object.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.newowner.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::AlterOperatorStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
+                n.opername.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterTypeStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .type_name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DropOwnedStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .roles
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ReassignOwnedStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .roles
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.newrole.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::CompositeTypeStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.typevar.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .coldeflist
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateEnumStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .type_name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .vals
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateRangeStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .type_name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .params
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterEnumStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .type_name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterTsdictionaryStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .dictname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterTsconfigurationStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .cfgname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .tokentype
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .dicts
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateFdwStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .func_options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterFdwStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .func_options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateForeignServerStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterForeignServerStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateUserMappingStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.user.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterUserMappingStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.user.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DropUserMappingStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
+                n.user.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::AlterTableSpaceOptionsStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterTableMoveAllStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .roles
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::SecLabelStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.object.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CreateForeignTableStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::CreateStmt(
+                n.base_stmt.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ImportForeignSchemaStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .table_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateExtensionStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterExtensionStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterExtensionContentsStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.object.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CreateEventTrigStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .whenclause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .funcname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterEventTrigStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::RefreshMatViewStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::ReplicaIdentityStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::AlterSystemStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::VariableSetStmt(
+                n.setstmt.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::CreatePolicyStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.table.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .roles
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.qual.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.with_check.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::AlterPolicyStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.table.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .roles
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.qual.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.with_check.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CreateTransformStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.type_name.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
+                n.fromsql.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
+                n.tosql.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::CreateAmStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .handler_name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreatePublicationStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .pubobjects
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterPublicationStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .pubobjects
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateSubscriptionStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .publication
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterSubscriptionStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .publication
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DropSubscriptionStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::CreateStatsStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .defnames
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .stat_types
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .exprs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .relations
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterCollationStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .collname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CallStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::FuncCall(
+                n.funccall.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::FuncExpr(
+                n.funcexpr.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .outargs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AlterStatsStmt(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .defnames
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .name
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.lexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.rexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::ColumnRef(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .fields
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ParamRef(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::FuncCall(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .funcname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .agg_order
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.agg_filter.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::WindowDef(
+                n.over.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::AStar(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::AIndices(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.lidx.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.uidx.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::AIndirection(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .indirection
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AArrayExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .elements
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ResTarget(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .indirection
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.val.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::MultiAssignRef(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.source.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::TypeCast(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.type_name.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::CollateClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .collname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::SortBy(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.node.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .use_op
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::WindowDef(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .partition_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .order_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.start_offset.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.end_offset.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::RangeSubselect(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.subquery.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
+                n.alias.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::RangeFunction(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .functions
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
+                n.alias.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .coldeflist
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RangeTableSample(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.relation.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .method
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.repeatable.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::RangeTableFunc(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.docexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.rowexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .namespaces
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .columns
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
+                n.alias.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::RangeTableFuncCol(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.type_name.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.colexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.coldefexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::TypeName(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .names
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .typmods
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .array_bounds
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ColumnDef(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.type_name.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.raw_default.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.cooked_default.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.identity_sequence.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::CollateClause(
+                n.coll_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .constraints
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .fdwoptions
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::IndexElem(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .collation
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .opclass
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .opclassopts
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::StatsElem(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::Constraint(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.raw_expr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .keys
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .including
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .exclusions
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .options
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.pktable.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .fk_attrs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .pk_attrs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .fk_del_set_cols
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .old_conpfeqop
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::DefElem(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::RangeTblEntry(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::TableSampleClause(
+                n.tablesample.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::Query(
+                n.subquery.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .joinaliasvars
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .joinleftcols
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .joinrightcols
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
+                n.join_using_alias.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .functions
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::TableFunc(
+                n.tablefunc.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .values_lists
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .coltypes
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .coltypmods
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .colcollations
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
+                n.alias.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
+                n.eref.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .security_quals
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RangeTblFunction(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.funcexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .funccolnames
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .funccoltypes
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .funccoltypmods
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .funccolcollations
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::TableSampleClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.repeatable.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::WithCheckOption(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.qual.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::SortGroupClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::GroupingSet(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .content
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::WindowClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .partition_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .order_clause
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.start_offset.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.end_offset.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .run_condition
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::ObjectWithArgs(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .objname
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .objargs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .objfuncargs
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AccessPriv(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .cols
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CreateOpClassItem(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
+                n.name.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .order_family
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .class_args
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.storedtype.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::TableLikeClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::FunctionParameter(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.arg_type.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.defexpr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::LockingClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .locked_rels
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RowMarkClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::XmlSerialize(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
+                n.type_name.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::WithClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .ctes
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::InferClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .index_elems
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::OnConflictClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::InferClause(
+                n.infer.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .target_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CtesearchClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .search_col_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::CtecycleClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .cycle_col_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.cycle_mark_value
+                    .as_ref()
+                    .unwrap()
+                    .to_owned()
+                    .node
+                    .unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(
+                n.cycle_mark_default
+                    .as_ref()
+                    .unwrap()
+                    .to_owned()
+                    .node
+                    .unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::CommonTableExpr(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .aliascolnames
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(&mut get_nested_nodes(
+                n.ctequery.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(&mut get_nested_nodes(NodeEnum::CtesearchClause(
+                n.search_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::CtecycleClause(
+                n.cycle_clause.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .ctecolnames
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .ctecoltypes
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .ctecoltypmods
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .ctecolcollations
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::MergeWhenClause(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.condition.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .target_list
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .values
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::RoleSpec(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::TriggerTransition(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::PartitionElem(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .collation
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .opclass
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::PartitionSpec(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .part_params
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::PartitionBoundSpec(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .listdatums
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .lowerdatums
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes.append(
+                &mut n
+                    .upperdatums
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::PartitionRangeDatum(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(
+                n.value.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes
+        }
+        NodeEnum::PartitionCmd(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.name.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(NodeEnum::PartitionBoundSpec(
+                n.bound.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::VacuumRelation(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(
+                &mut n
+                    .va_cols
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::PublicationObjSpec(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::PublicationTable(
+                n.pubtable.as_ref().unwrap().to_owned(),
+            )));
+            nodes
+        }
+        NodeEnum::PublicationTable(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
+                n.relation.as_ref().unwrap().to_owned(),
+            )));
+            nodes.append(&mut get_nested_nodes(
+                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
+            ));
+            nodes.append(
+                &mut n
+                    .columns
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::InlineCodeBlock(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::CallContext(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::Integer(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::Float(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::Boolean(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::String(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::BitString(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+        NodeEnum::List(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .items
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::IntList(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .items
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::OidList(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes.append(
+                &mut n
+                    .items
+                    .iter()
+                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .collect(),
+            );
+            nodes
+        }
+        NodeEnum::AConst(n) => {
+            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            nodes
+        }
+    }
+}
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 57cf3e85..272c96e8 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -3,7 +3,8 @@ use logos::Logos;
 use regex::Regex;
 
 use crate::{
-    parser::Parser, pg_query_utils::get_position_for_pg_query_node, syntax_kind::SyntaxKind,
+    parser::Parser, pg_query_utils::get_position_for_pg_query_node,
+    pg_query_utils_generated::get_location, syntax_kind::SyntaxKind,
 };
 
 /// A super simple lexer for sql statements.
@@ -159,6 +160,7 @@ impl Parser {
         let mut lexer = StatementToken::lexer(&text);
 
         // parse root node if no syntax errors
+        // TODO: find root node based on depth
         if pg_query_nodes.peek().is_some() {
             let (node, depth, _) = pg_query_nodes.next().unwrap();
             self.stmt(node.to_enum(), range);
@@ -355,4 +357,23 @@ mod tests {
 
         assert_eq!(parsed.cst.text(), input);
     }
+
+    #[test]
+    fn test_cst() {
+        let input =
+            "with test as (insert into contact (id) values (1) returning *) select * from test";
+
+        pg_query::parse(input)
+            .unwrap()
+            .protobuf
+            .nodes()
+            .iter()
+            .for_each(|node| {
+                println!("####");
+                println!("{:?}", node);
+                println!("{:?}", get_location(node.0.to_enum()));
+            });
+
+        assert_eq!(1, 1);
+    }
 }
diff --git a/crates/parser/src/syntax_kind.rs b/crates/parser/src/syntax_kind.rs
index 00558a71..90b87503 100644
--- a/crates/parser/src/syntax_kind.rs
+++ b/crates/parser/src/syntax_kind.rs
@@ -2,7 +2,7 @@
 //! Most of the code here can be generated.
 
 use cstree::Syntax;
-use pg_query::{protobuf::ScanToken, NodeRef};
+use pg_query::{protobuf::ScanToken, NodeEnum, NodeRef};
 
 /// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres sql dialect, and a few custom ones
 /// that are not parsed by pg_query.rs, such as `Whitespace`.
@@ -807,7 +807,7 @@ impl SyntaxKind {
             NodeRef::Alias(_) => SyntaxKind::Alias,
             NodeRef::RangeVar(_) => SyntaxKind::RangeVar,
             NodeRef::TableFunc(_) => SyntaxKind::TableFunc,
-            NodeRef::Expr(_) => SyntaxKind::Expr,
+            // NodeRef::Expr(_) => SyntaxKind::Expr,
             NodeRef::Var(_) => SyntaxKind::Var,
             NodeRef::Param(_) => SyntaxKind::Param,
             NodeRef::Aggref(_) => SyntaxKind::Aggref,
@@ -1027,7 +1027,7 @@ impl SyntaxKind {
             NodeRef::Float(_) => SyntaxKind::Float,
             NodeRef::String(_) => SyntaxKind::String,
             NodeRef::BitString(_) => SyntaxKind::BitString,
-            NodeRef::Null(_) => SyntaxKind::Null,
+            // NodeRef::Null(_) => SyntaxKind::Null,
             NodeRef::List(_) => SyntaxKind::List,
             NodeRef::IntList(_) => SyntaxKind::IntList,
             NodeRef::OidList(_) => SyntaxKind::OidList,
diff --git a/crates/parser/src/syntax_kind_generated.rs b/crates/parser/src/syntax_kind_generated.rs
index f05c5678..f4168cc4 100644
--- a/crates/parser/src/syntax_kind_generated.rs
+++ b/crates/parser/src/syntax_kind_generated.rs
@@ -1,8 +1,14 @@
-//! This module bridges the gap between pg_query.rs nodes, and the `SyntaxKind` cstree requires.
-//! It is generated from libg_query proto.
+//! //! This module bridges the gap between pg_query.rs nodes, and the
+//! `SyntaxKind`
+//! //! cstree requires.
+//! //! The file is generated from the libg_query proto
+use cstree::Syntax;
+use pg_query::{protobuf::ScanToken, NodeEnum};
 
-/// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres sql dialect, and a few custom ones that are not parsed by pg_query.rs, such as `Whitespace`.
-#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Syntax)]
+/// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres
+/// sql dialect, and a few custom ones that are not parsed by pg_query.rs, such
+/// as `Whitespace`.
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Syntax)]
 #[repr(u32)]
 pub enum SyntaxKind {
     SourceFile,
@@ -34,7 +40,7 @@ pub enum SyntaxKind {
     FieldSelect,
     FieldStore,
     RelabelType,
-    CoerceViaIO,
+    CoerceViaIo,
     ArrayCoerceExpr,
     ConvertRowtypeExpr,
     CollateExpr,
@@ -46,7 +52,7 @@ pub enum SyntaxKind {
     RowCompareExpr,
     CoalesceExpr,
     MinMaxExpr,
-    SQLValueFunction,
+    SqlvalueFunction,
     XmlExpr,
     NullTest,
     BooleanTest,
@@ -62,16 +68,13 @@ pub enum SyntaxKind {
     FromExpr,
     OnConflictExpr,
     IntoClause,
-    MergeAction,
     RawStmt,
     Query,
     InsertStmt,
     DeleteStmt,
     UpdateStmt,
-    MergeStmt,
     SelectStmt,
-    ReturnStmt,
-    PLAssignStmt,
+    PlassignStmt,
     AlterTableStmt,
     AlterTableCmd,
     AlterDomainStmt,
@@ -112,7 +115,7 @@ pub enum SyntaxKind {
     VariableShowStmt,
     DiscardStmt,
     CreateTrigStmt,
-    CreatePLangStmt,
+    CreatePlangStmt,
     CreateRoleStmt,
     AlterRoleStmt,
     DropRoleStmt,
@@ -122,7 +125,6 @@ pub enum SyntaxKind {
     CheckPointStmt,
     CreateSchemaStmt,
     AlterDatabaseStmt,
-    AlterDatabaseRefreshCollStmt,
     AlterDatabaseSetStmt,
     AlterRoleSetStmt,
     CreateConversionStmt,
@@ -147,8 +149,8 @@ pub enum SyntaxKind {
     CreateEnumStmt,
     CreateRangeStmt,
     AlterEnumStmt,
-    AlterTSDictionaryStmt,
-    AlterTSConfigurationStmt,
+    AlterTsdictionaryStmt,
+    AlterTsconfigurationStmt,
     CreateFdwStmt,
     AlterFdwStmt,
     CreateForeignServerStmt,
@@ -182,14 +184,14 @@ pub enum SyntaxKind {
     AlterCollationStmt,
     CallStmt,
     AlterStatsStmt,
-    A_Expr,
+    AExpr,
     ColumnRef,
     ParamRef,
     FuncCall,
-    A_Star,
-    A_Indices,
-    A_Indirection,
-    A_ArrayExpr,
+    AStar,
+    AIndices,
+    AIndirection,
+    AArrayExpr,
     ResTarget,
     MultiAssignRef,
     TypeCast,
@@ -204,7 +206,6 @@ pub enum SyntaxKind {
     TypeName,
     ColumnDef,
     IndexElem,
-    StatsElem,
     Constraint,
     DefElem,
     RangeTblEntry,
@@ -225,10 +226,9 @@ pub enum SyntaxKind {
     WithClause,
     InferClause,
     OnConflictClause,
-    CTESearchClause,
-    CTECycleClause,
+    CtesearchClause,
+    CtecycleClause,
     CommonTableExpr,
-    MergeWhenClause,
     RoleSpec,
     TriggerTransition,
     PartitionElem,
@@ -237,19 +237,16 @@ pub enum SyntaxKind {
     PartitionRangeDatum,
     PartitionCmd,
     VacuumRelation,
-    PublicationObjSpec,
-    PublicationTable,
     InlineCodeBlock,
     CallContext,
     Integer,
     Float,
-    Boolean,
     String,
     BitString,
     List,
     IntList,
     OidList,
-    A_Const,
+    AConst,
     Nul,
     Ascii37,
     Ascii40,
@@ -279,7 +276,6 @@ pub enum SyntaxKind {
     Xconst,
     Op,
     Iconst,
-    Param,
     Typecast,
     DotDot,
     ColonEquals,
@@ -350,7 +346,6 @@ pub enum SyntaxKind {
     Collation,
     Column,
     Columns,
-    Comment,
     Comments,
     Commit,
     Committed,
@@ -359,7 +354,6 @@ pub enum SyntaxKind {
     Configuration,
     Conflict,
     Connection,
-    Constraint,
     Constraints,
     ContentP,
     ContinueP,
@@ -482,7 +476,6 @@ pub enum SyntaxKind {
     Insert,
     Instead,
     IntP,
-    Integer,
     Intersect,
     Interval,
     Into,
@@ -760,3 +753,1300 @@ pub enum SyntaxKind {
     Uminus,
 }
 
+///
+///  Kind of a `SyntaxKind`
+///  This is the only manual definition required for properly creating a concrete
+/// syntax tree.
+///  If a token is of type `Follow`, it is not immediately applied to the syntax
+/// tree, but put into
+///  a buffer. Before the next node is started, all buffered tokens are applied
+/// to the syntax tree
+///  at the depth of the node that is opened next.
+///
+///  For example, in `select * from contact;`, the whitespace between `*` and
+/// `from` should be a direct
+///  child of the `SelectStmt` node. Without this concept, it would be put into
+/// the `ColumnRef`
+///  node.
+///
+///  SelectStmt@0..22
+///    Select@0..6 "select"
+///    Whitespace@6..7 " "
+///    ResTarget@7..8
+///      ColumnRef@7..8
+///        Ascii42@7..8 "*"
+///    Whitespace@8..9 " "
+///    From@9..13 "from"
+///   Whitespace@13..14 " "
+///    RangeVar@14..21
+///      Ident@14..21 "contact"
+///    Ascii59@21..22 ";"
+pub enum SyntaxKindType {
+    Follow,
+    Close,
+}
+
+impl SyntaxKind {
+    /// Converts a `pg_query` node to a `SyntaxKind`
+    pub fn new_from_pg_query_node(node: &NodeEnum) -> Self {
+        match node {
+            NodeEnum::Alias(_) => SyntaxKind::Alias,
+            NodeEnum::RangeVar(_) => SyntaxKind::RangeVar,
+            NodeEnum::TableFunc(_) => SyntaxKind::TableFunc,
+            NodeEnum::Var(_) => SyntaxKind::Var,
+            NodeEnum::Param(_) => SyntaxKind::Param,
+            NodeEnum::Aggref(_) => SyntaxKind::Aggref,
+            NodeEnum::GroupingFunc(_) => SyntaxKind::GroupingFunc,
+            NodeEnum::WindowFunc(_) => SyntaxKind::WindowFunc,
+            NodeEnum::SubscriptingRef(_) => SyntaxKind::SubscriptingRef,
+            NodeEnum::FuncExpr(_) => SyntaxKind::FuncExpr,
+            NodeEnum::NamedArgExpr(_) => SyntaxKind::NamedArgExpr,
+            NodeEnum::OpExpr(_) => SyntaxKind::OpExpr,
+            NodeEnum::DistinctExpr(_) => SyntaxKind::DistinctExpr,
+            NodeEnum::NullIfExpr(_) => SyntaxKind::NullIfExpr,
+            NodeEnum::ScalarArrayOpExpr(_) => SyntaxKind::ScalarArrayOpExpr,
+            NodeEnum::BoolExpr(_) => SyntaxKind::BoolExpr,
+            NodeEnum::SubLink(_) => SyntaxKind::SubLink,
+            NodeEnum::SubPlan(_) => SyntaxKind::SubPlan,
+            NodeEnum::AlternativeSubPlan(_) => SyntaxKind::AlternativeSubPlan,
+            NodeEnum::FieldSelect(_) => SyntaxKind::FieldSelect,
+            NodeEnum::FieldStore(_) => SyntaxKind::FieldStore,
+            NodeEnum::RelabelType(_) => SyntaxKind::RelabelType,
+            NodeEnum::CoerceViaIo(_) => SyntaxKind::CoerceViaIo,
+            NodeEnum::ArrayCoerceExpr(_) => SyntaxKind::ArrayCoerceExpr,
+            NodeEnum::ConvertRowtypeExpr(_) => SyntaxKind::ConvertRowtypeExpr,
+            NodeEnum::CollateExpr(_) => SyntaxKind::CollateExpr,
+            NodeEnum::CaseExpr(_) => SyntaxKind::CaseExpr,
+            NodeEnum::CaseWhen(_) => SyntaxKind::CaseWhen,
+            NodeEnum::CaseTestExpr(_) => SyntaxKind::CaseTestExpr,
+            NodeEnum::ArrayExpr(_) => SyntaxKind::ArrayExpr,
+            NodeEnum::RowExpr(_) => SyntaxKind::RowExpr,
+            NodeEnum::RowCompareExpr(_) => SyntaxKind::RowCompareExpr,
+            NodeEnum::CoalesceExpr(_) => SyntaxKind::CoalesceExpr,
+            NodeEnum::MinMaxExpr(_) => SyntaxKind::MinMaxExpr,
+            NodeEnum::SqlvalueFunction(_) => SyntaxKind::SqlvalueFunction,
+            NodeEnum::XmlExpr(_) => SyntaxKind::XmlExpr,
+            NodeEnum::NullTest(_) => SyntaxKind::NullTest,
+            NodeEnum::BooleanTest(_) => SyntaxKind::BooleanTest,
+            NodeEnum::CoerceToDomain(_) => SyntaxKind::CoerceToDomain,
+            NodeEnum::CoerceToDomainValue(_) => SyntaxKind::CoerceToDomainValue,
+            NodeEnum::SetToDefault(_) => SyntaxKind::SetToDefault,
+            NodeEnum::CurrentOfExpr(_) => SyntaxKind::CurrentOfExpr,
+            NodeEnum::NextValueExpr(_) => SyntaxKind::NextValueExpr,
+            NodeEnum::InferenceElem(_) => SyntaxKind::InferenceElem,
+            NodeEnum::TargetEntry(_) => SyntaxKind::TargetEntry,
+            NodeEnum::RangeTblRef(_) => SyntaxKind::RangeTblRef,
+            NodeEnum::JoinExpr(_) => SyntaxKind::JoinExpr,
+            NodeEnum::FromExpr(_) => SyntaxKind::FromExpr,
+            NodeEnum::OnConflictExpr(_) => SyntaxKind::OnConflictExpr,
+            NodeEnum::IntoClause(_) => SyntaxKind::IntoClause,
+            NodeEnum::RawStmt(_) => SyntaxKind::RawStmt,
+            NodeEnum::Query(_) => SyntaxKind::Query,
+            NodeEnum::InsertStmt(_) => SyntaxKind::InsertStmt,
+            NodeEnum::DeleteStmt(_) => SyntaxKind::DeleteStmt,
+            NodeEnum::UpdateStmt(_) => SyntaxKind::UpdateStmt,
+            NodeEnum::SelectStmt(_) => SyntaxKind::SelectStmt,
+            NodeEnum::PlassignStmt(_) => SyntaxKind::PlassignStmt,
+            NodeEnum::AlterTableStmt(_) => SyntaxKind::AlterTableStmt,
+            NodeEnum::AlterTableCmd(_) => SyntaxKind::AlterTableCmd,
+            NodeEnum::AlterDomainStmt(_) => SyntaxKind::AlterDomainStmt,
+            NodeEnum::SetOperationStmt(_) => SyntaxKind::SetOperationStmt,
+            NodeEnum::GrantStmt(_) => SyntaxKind::GrantStmt,
+            NodeEnum::GrantRoleStmt(_) => SyntaxKind::GrantRoleStmt,
+            NodeEnum::AlterDefaultPrivilegesStmt(_) => SyntaxKind::AlterDefaultPrivilegesStmt,
+            NodeEnum::ClosePortalStmt(_) => SyntaxKind::ClosePortalStmt,
+            NodeEnum::ClusterStmt(_) => SyntaxKind::ClusterStmt,
+            NodeEnum::CopyStmt(_) => SyntaxKind::CopyStmt,
+            NodeEnum::CreateStmt(_) => SyntaxKind::CreateStmt,
+            NodeEnum::DefineStmt(_) => SyntaxKind::DefineStmt,
+            NodeEnum::DropStmt(_) => SyntaxKind::DropStmt,
+            NodeEnum::TruncateStmt(_) => SyntaxKind::TruncateStmt,
+            NodeEnum::CommentStmt(_) => SyntaxKind::CommentStmt,
+            NodeEnum::FetchStmt(_) => SyntaxKind::FetchStmt,
+            NodeEnum::IndexStmt(_) => SyntaxKind::IndexStmt,
+            NodeEnum::CreateFunctionStmt(_) => SyntaxKind::CreateFunctionStmt,
+            NodeEnum::AlterFunctionStmt(_) => SyntaxKind::AlterFunctionStmt,
+            NodeEnum::DoStmt(_) => SyntaxKind::DoStmt,
+            NodeEnum::RenameStmt(_) => SyntaxKind::RenameStmt,
+            NodeEnum::RuleStmt(_) => SyntaxKind::RuleStmt,
+            NodeEnum::NotifyStmt(_) => SyntaxKind::NotifyStmt,
+            NodeEnum::ListenStmt(_) => SyntaxKind::ListenStmt,
+            NodeEnum::UnlistenStmt(_) => SyntaxKind::UnlistenStmt,
+            NodeEnum::TransactionStmt(_) => SyntaxKind::TransactionStmt,
+            NodeEnum::ViewStmt(_) => SyntaxKind::ViewStmt,
+            NodeEnum::LoadStmt(_) => SyntaxKind::LoadStmt,
+            NodeEnum::CreateDomainStmt(_) => SyntaxKind::CreateDomainStmt,
+            NodeEnum::CreatedbStmt(_) => SyntaxKind::CreatedbStmt,
+            NodeEnum::DropdbStmt(_) => SyntaxKind::DropdbStmt,
+            NodeEnum::VacuumStmt(_) => SyntaxKind::VacuumStmt,
+            NodeEnum::ExplainStmt(_) => SyntaxKind::ExplainStmt,
+            NodeEnum::CreateTableAsStmt(_) => SyntaxKind::CreateTableAsStmt,
+            NodeEnum::CreateSeqStmt(_) => SyntaxKind::CreateSeqStmt,
+            NodeEnum::AlterSeqStmt(_) => SyntaxKind::AlterSeqStmt,
+            NodeEnum::VariableSetStmt(_) => SyntaxKind::VariableSetStmt,
+            NodeEnum::VariableShowStmt(_) => SyntaxKind::VariableShowStmt,
+            NodeEnum::DiscardStmt(_) => SyntaxKind::DiscardStmt,
+            NodeEnum::CreateTrigStmt(_) => SyntaxKind::CreateTrigStmt,
+            NodeEnum::CreatePlangStmt(_) => SyntaxKind::CreatePlangStmt,
+            NodeEnum::CreateRoleStmt(_) => SyntaxKind::CreateRoleStmt,
+            NodeEnum::AlterRoleStmt(_) => SyntaxKind::AlterRoleStmt,
+            NodeEnum::DropRoleStmt(_) => SyntaxKind::DropRoleStmt,
+            NodeEnum::LockStmt(_) => SyntaxKind::LockStmt,
+            NodeEnum::ConstraintsSetStmt(_) => SyntaxKind::ConstraintsSetStmt,
+            NodeEnum::ReindexStmt(_) => SyntaxKind::ReindexStmt,
+            NodeEnum::CheckPointStmt(_) => SyntaxKind::CheckPointStmt,
+            NodeEnum::CreateSchemaStmt(_) => SyntaxKind::CreateSchemaStmt,
+            NodeEnum::AlterDatabaseStmt(_) => SyntaxKind::AlterDatabaseStmt,
+            NodeEnum::AlterDatabaseSetStmt(_) => SyntaxKind::AlterDatabaseSetStmt,
+            NodeEnum::AlterRoleSetStmt(_) => SyntaxKind::AlterRoleSetStmt,
+            NodeEnum::CreateConversionStmt(_) => SyntaxKind::CreateConversionStmt,
+            NodeEnum::CreateCastStmt(_) => SyntaxKind::CreateCastStmt,
+            NodeEnum::CreateOpClassStmt(_) => SyntaxKind::CreateOpClassStmt,
+            NodeEnum::CreateOpFamilyStmt(_) => SyntaxKind::CreateOpFamilyStmt,
+            NodeEnum::AlterOpFamilyStmt(_) => SyntaxKind::AlterOpFamilyStmt,
+            NodeEnum::PrepareStmt(_) => SyntaxKind::PrepareStmt,
+            NodeEnum::ExecuteStmt(_) => SyntaxKind::ExecuteStmt,
+            NodeEnum::DeallocateStmt(_) => SyntaxKind::DeallocateStmt,
+            NodeEnum::DeclareCursorStmt(_) => SyntaxKind::DeclareCursorStmt,
+            NodeEnum::CreateTableSpaceStmt(_) => SyntaxKind::CreateTableSpaceStmt,
+            NodeEnum::DropTableSpaceStmt(_) => SyntaxKind::DropTableSpaceStmt,
+            NodeEnum::AlterObjectDependsStmt(_) => SyntaxKind::AlterObjectDependsStmt,
+            NodeEnum::AlterObjectSchemaStmt(_) => SyntaxKind::AlterObjectSchemaStmt,
+            NodeEnum::AlterOwnerStmt(_) => SyntaxKind::AlterOwnerStmt,
+            NodeEnum::AlterOperatorStmt(_) => SyntaxKind::AlterOperatorStmt,
+            NodeEnum::AlterTypeStmt(_) => SyntaxKind::AlterTypeStmt,
+            NodeEnum::DropOwnedStmt(_) => SyntaxKind::DropOwnedStmt,
+            NodeEnum::ReassignOwnedStmt(_) => SyntaxKind::ReassignOwnedStmt,
+            NodeEnum::CompositeTypeStmt(_) => SyntaxKind::CompositeTypeStmt,
+            NodeEnum::CreateEnumStmt(_) => SyntaxKind::CreateEnumStmt,
+            NodeEnum::CreateRangeStmt(_) => SyntaxKind::CreateRangeStmt,
+            NodeEnum::AlterEnumStmt(_) => SyntaxKind::AlterEnumStmt,
+            NodeEnum::AlterTsdictionaryStmt(_) => SyntaxKind::AlterTsdictionaryStmt,
+            NodeEnum::AlterTsconfigurationStmt(_) => SyntaxKind::AlterTsconfigurationStmt,
+            NodeEnum::CreateFdwStmt(_) => SyntaxKind::CreateFdwStmt,
+            NodeEnum::AlterFdwStmt(_) => SyntaxKind::AlterFdwStmt,
+            NodeEnum::CreateForeignServerStmt(_) => SyntaxKind::CreateForeignServerStmt,
+            NodeEnum::AlterForeignServerStmt(_) => SyntaxKind::AlterForeignServerStmt,
+            NodeEnum::CreateUserMappingStmt(_) => SyntaxKind::CreateUserMappingStmt,
+            NodeEnum::AlterUserMappingStmt(_) => SyntaxKind::AlterUserMappingStmt,
+            NodeEnum::DropUserMappingStmt(_) => SyntaxKind::DropUserMappingStmt,
+            NodeEnum::AlterTableSpaceOptionsStmt(_) => SyntaxKind::AlterTableSpaceOptionsStmt,
+            NodeEnum::AlterTableMoveAllStmt(_) => SyntaxKind::AlterTableMoveAllStmt,
+            NodeEnum::SecLabelStmt(_) => SyntaxKind::SecLabelStmt,
+            NodeEnum::CreateForeignTableStmt(_) => SyntaxKind::CreateForeignTableStmt,
+            NodeEnum::ImportForeignSchemaStmt(_) => SyntaxKind::ImportForeignSchemaStmt,
+            NodeEnum::CreateExtensionStmt(_) => SyntaxKind::CreateExtensionStmt,
+            NodeEnum::AlterExtensionStmt(_) => SyntaxKind::AlterExtensionStmt,
+            NodeEnum::AlterExtensionContentsStmt(_) => SyntaxKind::AlterExtensionContentsStmt,
+            NodeEnum::CreateEventTrigStmt(_) => SyntaxKind::CreateEventTrigStmt,
+            NodeEnum::AlterEventTrigStmt(_) => SyntaxKind::AlterEventTrigStmt,
+            NodeEnum::RefreshMatViewStmt(_) => SyntaxKind::RefreshMatViewStmt,
+            NodeEnum::ReplicaIdentityStmt(_) => SyntaxKind::ReplicaIdentityStmt,
+            NodeEnum::AlterSystemStmt(_) => SyntaxKind::AlterSystemStmt,
+            NodeEnum::CreatePolicyStmt(_) => SyntaxKind::CreatePolicyStmt,
+            NodeEnum::AlterPolicyStmt(_) => SyntaxKind::AlterPolicyStmt,
+            NodeEnum::CreateTransformStmt(_) => SyntaxKind::CreateTransformStmt,
+            NodeEnum::CreateAmStmt(_) => SyntaxKind::CreateAmStmt,
+            NodeEnum::CreatePublicationStmt(_) => SyntaxKind::CreatePublicationStmt,
+            NodeEnum::AlterPublicationStmt(_) => SyntaxKind::AlterPublicationStmt,
+            NodeEnum::CreateSubscriptionStmt(_) => SyntaxKind::CreateSubscriptionStmt,
+            NodeEnum::AlterSubscriptionStmt(_) => SyntaxKind::AlterSubscriptionStmt,
+            NodeEnum::DropSubscriptionStmt(_) => SyntaxKind::DropSubscriptionStmt,
+            NodeEnum::CreateStatsStmt(_) => SyntaxKind::CreateStatsStmt,
+            NodeEnum::AlterCollationStmt(_) => SyntaxKind::AlterCollationStmt,
+            NodeEnum::CallStmt(_) => SyntaxKind::CallStmt,
+            NodeEnum::AlterStatsStmt(_) => SyntaxKind::AlterStatsStmt,
+            NodeEnum::AExpr(_) => SyntaxKind::AExpr,
+            NodeEnum::ColumnRef(_) => SyntaxKind::ColumnRef,
+            NodeEnum::ParamRef(_) => SyntaxKind::ParamRef,
+            NodeEnum::FuncCall(_) => SyntaxKind::FuncCall,
+            NodeEnum::AStar(_) => SyntaxKind::AStar,
+            NodeEnum::AIndices(_) => SyntaxKind::AIndices,
+            NodeEnum::AIndirection(_) => SyntaxKind::AIndirection,
+            NodeEnum::AArrayExpr(_) => SyntaxKind::AArrayExpr,
+            NodeEnum::ResTarget(_) => SyntaxKind::ResTarget,
+            NodeEnum::MultiAssignRef(_) => SyntaxKind::MultiAssignRef,
+            NodeEnum::TypeCast(_) => SyntaxKind::TypeCast,
+            NodeEnum::CollateClause(_) => SyntaxKind::CollateClause,
+            NodeEnum::SortBy(_) => SyntaxKind::SortBy,
+            NodeEnum::WindowDef(_) => SyntaxKind::WindowDef,
+            NodeEnum::RangeSubselect(_) => SyntaxKind::RangeSubselect,
+            NodeEnum::RangeFunction(_) => SyntaxKind::RangeFunction,
+            NodeEnum::RangeTableSample(_) => SyntaxKind::RangeTableSample,
+            NodeEnum::RangeTableFunc(_) => SyntaxKind::RangeTableFunc,
+            NodeEnum::RangeTableFuncCol(_) => SyntaxKind::RangeTableFuncCol,
+            NodeEnum::TypeName(_) => SyntaxKind::TypeName,
+            NodeEnum::ColumnDef(_) => SyntaxKind::ColumnDef,
+            NodeEnum::IndexElem(_) => SyntaxKind::IndexElem,
+            NodeEnum::Constraint(_) => SyntaxKind::Constraint,
+            NodeEnum::DefElem(_) => SyntaxKind::DefElem,
+            NodeEnum::RangeTblEntry(_) => SyntaxKind::RangeTblEntry,
+            NodeEnum::RangeTblFunction(_) => SyntaxKind::RangeTblFunction,
+            NodeEnum::TableSampleClause(_) => SyntaxKind::TableSampleClause,
+            NodeEnum::WithCheckOption(_) => SyntaxKind::WithCheckOption,
+            NodeEnum::SortGroupClause(_) => SyntaxKind::SortGroupClause,
+            NodeEnum::GroupingSet(_) => SyntaxKind::GroupingSet,
+            NodeEnum::WindowClause(_) => SyntaxKind::WindowClause,
+            NodeEnum::ObjectWithArgs(_) => SyntaxKind::ObjectWithArgs,
+            NodeEnum::AccessPriv(_) => SyntaxKind::AccessPriv,
+            NodeEnum::CreateOpClassItem(_) => SyntaxKind::CreateOpClassItem,
+            NodeEnum::TableLikeClause(_) => SyntaxKind::TableLikeClause,
+            NodeEnum::FunctionParameter(_) => SyntaxKind::FunctionParameter,
+            NodeEnum::LockingClause(_) => SyntaxKind::LockingClause,
+            NodeEnum::RowMarkClause(_) => SyntaxKind::RowMarkClause,
+            NodeEnum::XmlSerialize(_) => SyntaxKind::XmlSerialize,
+            NodeEnum::WithClause(_) => SyntaxKind::WithClause,
+            NodeEnum::InferClause(_) => SyntaxKind::InferClause,
+            NodeEnum::OnConflictClause(_) => SyntaxKind::OnConflictClause,
+            NodeEnum::CtesearchClause(_) => SyntaxKind::CtesearchClause,
+            NodeEnum::CtecycleClause(_) => SyntaxKind::CtecycleClause,
+            NodeEnum::CommonTableExpr(_) => SyntaxKind::CommonTableExpr,
+            NodeEnum::RoleSpec(_) => SyntaxKind::RoleSpec,
+            NodeEnum::TriggerTransition(_) => SyntaxKind::TriggerTransition,
+            NodeEnum::PartitionElem(_) => SyntaxKind::PartitionElem,
+            NodeEnum::PartitionSpec(_) => SyntaxKind::PartitionSpec,
+            NodeEnum::PartitionBoundSpec(_) => SyntaxKind::PartitionBoundSpec,
+            NodeEnum::PartitionRangeDatum(_) => SyntaxKind::PartitionRangeDatum,
+            NodeEnum::PartitionCmd(_) => SyntaxKind::PartitionCmd,
+            NodeEnum::VacuumRelation(_) => SyntaxKind::VacuumRelation,
+            NodeEnum::InlineCodeBlock(_) => SyntaxKind::InlineCodeBlock,
+            NodeEnum::CallContext(_) => SyntaxKind::CallContext,
+            NodeEnum::Integer(_) => SyntaxKind::Integer,
+            NodeEnum::Float(_) => SyntaxKind::Float,
+            NodeEnum::String(_) => SyntaxKind::String,
+            NodeEnum::BitString(_) => SyntaxKind::BitString,
+            NodeEnum::List(_) => SyntaxKind::List,
+            NodeEnum::IntList(_) => SyntaxKind::IntList,
+            NodeEnum::OidList(_) => SyntaxKind::OidList,
+            NodeEnum::AConst(_) => SyntaxKind::AConst,
+        }
+    }
+
+    /// Converts a `pg_query` token to a `SyntaxKind`
+    pub fn new_from_pg_query_token(token: &ScanToken) -> Self {
+        match token.token {
+            0 => SyntaxKind::Nul,
+            37 => SyntaxKind::Ascii37,
+            40 => SyntaxKind::Ascii40,
+            41 => SyntaxKind::Ascii41,
+            42 => SyntaxKind::Ascii42,
+            43 => SyntaxKind::Ascii43,
+            44 => SyntaxKind::Ascii44,
+            45 => SyntaxKind::Ascii45,
+            46 => SyntaxKind::Ascii46,
+            47 => SyntaxKind::Ascii47,
+            58 => SyntaxKind::Ascii58,
+            59 => SyntaxKind::Ascii59,
+            60 => SyntaxKind::Ascii60,
+            61 => SyntaxKind::Ascii61,
+            62 => SyntaxKind::Ascii62,
+            63 => SyntaxKind::Ascii63,
+            91 => SyntaxKind::Ascii91,
+            92 => SyntaxKind::Ascii92,
+            93 => SyntaxKind::Ascii93,
+            94 => SyntaxKind::Ascii94,
+            258 => SyntaxKind::Ident,
+            259 => SyntaxKind::Uident,
+            260 => SyntaxKind::Fconst,
+            261 => SyntaxKind::Sconst,
+            262 => SyntaxKind::Usconst,
+            263 => SyntaxKind::Bconst,
+            264 => SyntaxKind::Xconst,
+            265 => SyntaxKind::Op,
+            266 => SyntaxKind::Iconst,
+            267 => SyntaxKind::Param,
+            268 => SyntaxKind::Typecast,
+            269 => SyntaxKind::DotDot,
+            270 => SyntaxKind::ColonEquals,
+            271 => SyntaxKind::EqualsGreater,
+            272 => SyntaxKind::LessEquals,
+            273 => SyntaxKind::GreaterEquals,
+            274 => SyntaxKind::NotEquals,
+            275 => SyntaxKind::SqlComment,
+            276 => SyntaxKind::CComment,
+            277 => SyntaxKind::AbortP,
+            278 => SyntaxKind::AbsoluteP,
+            279 => SyntaxKind::Access,
+            280 => SyntaxKind::Action,
+            281 => SyntaxKind::AddP,
+            282 => SyntaxKind::Admin,
+            283 => SyntaxKind::After,
+            284 => SyntaxKind::Aggregate,
+            285 => SyntaxKind::All,
+            286 => SyntaxKind::Also,
+            287 => SyntaxKind::Alter,
+            288 => SyntaxKind::Always,
+            289 => SyntaxKind::Analyse,
+            290 => SyntaxKind::Analyze,
+            291 => SyntaxKind::And,
+            292 => SyntaxKind::Any,
+            293 => SyntaxKind::Array,
+            294 => SyntaxKind::As,
+            295 => SyntaxKind::Asc,
+            296 => SyntaxKind::Asensitive,
+            297 => SyntaxKind::Assertion,
+            298 => SyntaxKind::Assignment,
+            299 => SyntaxKind::Asymmetric,
+            300 => SyntaxKind::Atomic,
+            301 => SyntaxKind::At,
+            302 => SyntaxKind::Attach,
+            303 => SyntaxKind::Attribute,
+            304 => SyntaxKind::Authorization,
+            305 => SyntaxKind::Backward,
+            306 => SyntaxKind::Before,
+            307 => SyntaxKind::BeginP,
+            308 => SyntaxKind::Between,
+            309 => SyntaxKind::Bigint,
+            310 => SyntaxKind::Binary,
+            311 => SyntaxKind::Bit,
+            312 => SyntaxKind::BooleanP,
+            313 => SyntaxKind::Both,
+            314 => SyntaxKind::Breadth,
+            315 => SyntaxKind::By,
+            316 => SyntaxKind::Cache,
+            317 => SyntaxKind::Call,
+            318 => SyntaxKind::Called,
+            319 => SyntaxKind::Cascade,
+            320 => SyntaxKind::Cascaded,
+            321 => SyntaxKind::Case,
+            322 => SyntaxKind::Cast,
+            323 => SyntaxKind::CatalogP,
+            324 => SyntaxKind::Chain,
+            325 => SyntaxKind::CharP,
+            326 => SyntaxKind::Character,
+            327 => SyntaxKind::Characteristics,
+            328 => SyntaxKind::Check,
+            329 => SyntaxKind::Checkpoint,
+            330 => SyntaxKind::Class,
+            331 => SyntaxKind::Close,
+            332 => SyntaxKind::Cluster,
+            333 => SyntaxKind::Coalesce,
+            334 => SyntaxKind::Collate,
+            335 => SyntaxKind::Collation,
+            336 => SyntaxKind::Column,
+            337 => SyntaxKind::Columns,
+            338 => SyntaxKind::Comment,
+            339 => SyntaxKind::Comments,
+            340 => SyntaxKind::Commit,
+            341 => SyntaxKind::Committed,
+            342 => SyntaxKind::Compression,
+            343 => SyntaxKind::Concurrently,
+            344 => SyntaxKind::Configuration,
+            345 => SyntaxKind::Conflict,
+            346 => SyntaxKind::Connection,
+            347 => SyntaxKind::Constraint,
+            348 => SyntaxKind::Constraints,
+            349 => SyntaxKind::ContentP,
+            350 => SyntaxKind::ContinueP,
+            351 => SyntaxKind::ConversionP,
+            352 => SyntaxKind::Copy,
+            353 => SyntaxKind::Cost,
+            354 => SyntaxKind::Create,
+            355 => SyntaxKind::Cross,
+            356 => SyntaxKind::Csv,
+            357 => SyntaxKind::Cube,
+            358 => SyntaxKind::CurrentP,
+            359 => SyntaxKind::CurrentCatalog,
+            360 => SyntaxKind::CurrentDate,
+            361 => SyntaxKind::CurrentRole,
+            362 => SyntaxKind::CurrentSchema,
+            363 => SyntaxKind::CurrentTime,
+            364 => SyntaxKind::CurrentTimestamp,
+            365 => SyntaxKind::CurrentUser,
+            366 => SyntaxKind::Cursor,
+            367 => SyntaxKind::Cycle,
+            368 => SyntaxKind::DataP,
+            369 => SyntaxKind::Database,
+            370 => SyntaxKind::DayP,
+            371 => SyntaxKind::Deallocate,
+            372 => SyntaxKind::Dec,
+            373 => SyntaxKind::DecimalP,
+            374 => SyntaxKind::Declare,
+            375 => SyntaxKind::Default,
+            376 => SyntaxKind::Defaults,
+            377 => SyntaxKind::Deferrable,
+            378 => SyntaxKind::Deferred,
+            379 => SyntaxKind::Definer,
+            380 => SyntaxKind::DeleteP,
+            381 => SyntaxKind::Delimiter,
+            382 => SyntaxKind::Delimiters,
+            383 => SyntaxKind::Depends,
+            384 => SyntaxKind::Depth,
+            385 => SyntaxKind::Desc,
+            386 => SyntaxKind::Detach,
+            387 => SyntaxKind::Dictionary,
+            388 => SyntaxKind::DisableP,
+            389 => SyntaxKind::Discard,
+            390 => SyntaxKind::Distinct,
+            391 => SyntaxKind::Do,
+            392 => SyntaxKind::DocumentP,
+            393 => SyntaxKind::DomainP,
+            394 => SyntaxKind::DoubleP,
+            395 => SyntaxKind::Drop,
+            396 => SyntaxKind::Each,
+            397 => SyntaxKind::Else,
+            398 => SyntaxKind::EnableP,
+            399 => SyntaxKind::Encoding,
+            400 => SyntaxKind::Encrypted,
+            401 => SyntaxKind::EndP,
+            402 => SyntaxKind::EnumP,
+            403 => SyntaxKind::Escape,
+            404 => SyntaxKind::Event,
+            405 => SyntaxKind::Except,
+            406 => SyntaxKind::Exclude,
+            407 => SyntaxKind::Excluding,
+            408 => SyntaxKind::Exclusive,
+            409 => SyntaxKind::Execute,
+            410 => SyntaxKind::Exists,
+            411 => SyntaxKind::Explain,
+            412 => SyntaxKind::Expression,
+            413 => SyntaxKind::Extension,
+            414 => SyntaxKind::External,
+            415 => SyntaxKind::Extract,
+            416 => SyntaxKind::FalseP,
+            417 => SyntaxKind::Family,
+            418 => SyntaxKind::Fetch,
+            419 => SyntaxKind::Filter,
+            420 => SyntaxKind::Finalize,
+            421 => SyntaxKind::FirstP,
+            422 => SyntaxKind::FloatP,
+            423 => SyntaxKind::Following,
+            424 => SyntaxKind::For,
+            425 => SyntaxKind::Force,
+            426 => SyntaxKind::Foreign,
+            427 => SyntaxKind::Forward,
+            428 => SyntaxKind::Freeze,
+            429 => SyntaxKind::From,
+            430 => SyntaxKind::Full,
+            431 => SyntaxKind::Function,
+            432 => SyntaxKind::Functions,
+            433 => SyntaxKind::Generated,
+            434 => SyntaxKind::Global,
+            435 => SyntaxKind::Grant,
+            436 => SyntaxKind::Granted,
+            437 => SyntaxKind::Greatest,
+            438 => SyntaxKind::GroupP,
+            439 => SyntaxKind::Grouping,
+            440 => SyntaxKind::Groups,
+            441 => SyntaxKind::Handler,
+            442 => SyntaxKind::Having,
+            443 => SyntaxKind::HeaderP,
+            444 => SyntaxKind::Hold,
+            445 => SyntaxKind::HourP,
+            446 => SyntaxKind::IdentityP,
+            447 => SyntaxKind::IfP,
+            448 => SyntaxKind::Ilike,
+            449 => SyntaxKind::Immediate,
+            450 => SyntaxKind::Immutable,
+            451 => SyntaxKind::ImplicitP,
+            452 => SyntaxKind::ImportP,
+            453 => SyntaxKind::InP,
+            454 => SyntaxKind::Include,
+            455 => SyntaxKind::Including,
+            456 => SyntaxKind::Increment,
+            457 => SyntaxKind::Index,
+            458 => SyntaxKind::Indexes,
+            459 => SyntaxKind::Inherit,
+            460 => SyntaxKind::Inherits,
+            461 => SyntaxKind::Initially,
+            462 => SyntaxKind::InlineP,
+            463 => SyntaxKind::InnerP,
+            464 => SyntaxKind::Inout,
+            465 => SyntaxKind::InputP,
+            466 => SyntaxKind::Insensitive,
+            467 => SyntaxKind::Insert,
+            468 => SyntaxKind::Instead,
+            469 => SyntaxKind::IntP,
+            470 => SyntaxKind::Integer,
+            471 => SyntaxKind::Intersect,
+            472 => SyntaxKind::Interval,
+            473 => SyntaxKind::Into,
+            474 => SyntaxKind::Invoker,
+            475 => SyntaxKind::Is,
+            476 => SyntaxKind::Isnull,
+            477 => SyntaxKind::Isolation,
+            478 => SyntaxKind::Join,
+            479 => SyntaxKind::Key,
+            480 => SyntaxKind::Label,
+            481 => SyntaxKind::Language,
+            482 => SyntaxKind::LargeP,
+            483 => SyntaxKind::LastP,
+            484 => SyntaxKind::LateralP,
+            485 => SyntaxKind::Leading,
+            486 => SyntaxKind::Leakproof,
+            487 => SyntaxKind::Least,
+            488 => SyntaxKind::Left,
+            489 => SyntaxKind::Level,
+            490 => SyntaxKind::Like,
+            491 => SyntaxKind::Limit,
+            492 => SyntaxKind::Listen,
+            493 => SyntaxKind::Load,
+            494 => SyntaxKind::Local,
+            495 => SyntaxKind::Localtime,
+            496 => SyntaxKind::Localtimestamp,
+            497 => SyntaxKind::Location,
+            498 => SyntaxKind::LockP,
+            499 => SyntaxKind::Locked,
+            500 => SyntaxKind::Logged,
+            501 => SyntaxKind::Mapping,
+            502 => SyntaxKind::Match,
+            503 => SyntaxKind::Matched,
+            504 => SyntaxKind::Materialized,
+            505 => SyntaxKind::Maxvalue,
+            506 => SyntaxKind::Merge,
+            507 => SyntaxKind::Method,
+            508 => SyntaxKind::MinuteP,
+            509 => SyntaxKind::Minvalue,
+            510 => SyntaxKind::Mode,
+            511 => SyntaxKind::MonthP,
+            512 => SyntaxKind::Move,
+            513 => SyntaxKind::NameP,
+            514 => SyntaxKind::Names,
+            515 => SyntaxKind::National,
+            516 => SyntaxKind::Natural,
+            517 => SyntaxKind::Nchar,
+            518 => SyntaxKind::New,
+            519 => SyntaxKind::Next,
+            520 => SyntaxKind::Nfc,
+            521 => SyntaxKind::Nfd,
+            522 => SyntaxKind::Nfkc,
+            523 => SyntaxKind::Nfkd,
+            524 => SyntaxKind::No,
+            525 => SyntaxKind::None,
+            526 => SyntaxKind::Normalize,
+            527 => SyntaxKind::Normalized,
+            528 => SyntaxKind::Not,
+            529 => SyntaxKind::Nothing,
+            530 => SyntaxKind::Notify,
+            531 => SyntaxKind::Notnull,
+            532 => SyntaxKind::Nowait,
+            533 => SyntaxKind::NullP,
+            534 => SyntaxKind::Nullif,
+            535 => SyntaxKind::NullsP,
+            536 => SyntaxKind::Numeric,
+            537 => SyntaxKind::ObjectP,
+            538 => SyntaxKind::Of,
+            539 => SyntaxKind::Off,
+            540 => SyntaxKind::Offset,
+            541 => SyntaxKind::Oids,
+            542 => SyntaxKind::Old,
+            543 => SyntaxKind::On,
+            544 => SyntaxKind::Only,
+            545 => SyntaxKind::Operator,
+            546 => SyntaxKind::Option,
+            547 => SyntaxKind::Options,
+            548 => SyntaxKind::Or,
+            549 => SyntaxKind::Order,
+            550 => SyntaxKind::Ordinality,
+            551 => SyntaxKind::Others,
+            552 => SyntaxKind::OutP,
+            553 => SyntaxKind::OuterP,
+            554 => SyntaxKind::Over,
+            555 => SyntaxKind::Overlaps,
+            556 => SyntaxKind::Overlay,
+            557 => SyntaxKind::Overriding,
+            558 => SyntaxKind::Owned,
+            559 => SyntaxKind::Owner,
+            560 => SyntaxKind::Parallel,
+            561 => SyntaxKind::Parameter,
+            562 => SyntaxKind::Parser,
+            563 => SyntaxKind::Partial,
+            564 => SyntaxKind::Partition,
+            565 => SyntaxKind::Passing,
+            566 => SyntaxKind::Password,
+            567 => SyntaxKind::Placing,
+            568 => SyntaxKind::Plans,
+            569 => SyntaxKind::Policy,
+            570 => SyntaxKind::Position,
+            571 => SyntaxKind::Preceding,
+            572 => SyntaxKind::Precision,
+            573 => SyntaxKind::Preserve,
+            574 => SyntaxKind::Prepare,
+            575 => SyntaxKind::Prepared,
+            576 => SyntaxKind::Primary,
+            577 => SyntaxKind::Prior,
+            578 => SyntaxKind::Privileges,
+            579 => SyntaxKind::Procedural,
+            580 => SyntaxKind::Procedure,
+            581 => SyntaxKind::Procedures,
+            582 => SyntaxKind::Program,
+            583 => SyntaxKind::Publication,
+            584 => SyntaxKind::Quote,
+            585 => SyntaxKind::Range,
+            586 => SyntaxKind::Read,
+            587 => SyntaxKind::Real,
+            588 => SyntaxKind::Reassign,
+            589 => SyntaxKind::Recheck,
+            590 => SyntaxKind::Recursive,
+            591 => SyntaxKind::RefP,
+            592 => SyntaxKind::References,
+            593 => SyntaxKind::Referencing,
+            594 => SyntaxKind::Refresh,
+            595 => SyntaxKind::Reindex,
+            596 => SyntaxKind::RelativeP,
+            597 => SyntaxKind::Release,
+            598 => SyntaxKind::Rename,
+            599 => SyntaxKind::Repeatable,
+            600 => SyntaxKind::Replace,
+            601 => SyntaxKind::Replica,
+            602 => SyntaxKind::Reset,
+            603 => SyntaxKind::Restart,
+            604 => SyntaxKind::Restrict,
+            605 => SyntaxKind::Return,
+            606 => SyntaxKind::Returning,
+            607 => SyntaxKind::Returns,
+            608 => SyntaxKind::Revoke,
+            609 => SyntaxKind::Right,
+            610 => SyntaxKind::Role,
+            611 => SyntaxKind::Rollback,
+            612 => SyntaxKind::Rollup,
+            613 => SyntaxKind::Routine,
+            614 => SyntaxKind::Routines,
+            615 => SyntaxKind::Row,
+            616 => SyntaxKind::Rows,
+            617 => SyntaxKind::Rule,
+            618 => SyntaxKind::Savepoint,
+            619 => SyntaxKind::Schema,
+            620 => SyntaxKind::Schemas,
+            621 => SyntaxKind::Scroll,
+            622 => SyntaxKind::Search,
+            623 => SyntaxKind::SecondP,
+            624 => SyntaxKind::Security,
+            625 => SyntaxKind::Select,
+            626 => SyntaxKind::Sequence,
+            627 => SyntaxKind::Sequences,
+            628 => SyntaxKind::Serializable,
+            629 => SyntaxKind::Server,
+            630 => SyntaxKind::Session,
+            631 => SyntaxKind::SessionUser,
+            632 => SyntaxKind::Set,
+            633 => SyntaxKind::Sets,
+            634 => SyntaxKind::Setof,
+            635 => SyntaxKind::Share,
+            636 => SyntaxKind::Show,
+            637 => SyntaxKind::Similar,
+            638 => SyntaxKind::Simple,
+            639 => SyntaxKind::Skip,
+            640 => SyntaxKind::Smallint,
+            641 => SyntaxKind::Snapshot,
+            642 => SyntaxKind::Some,
+            643 => SyntaxKind::SqlP,
+            644 => SyntaxKind::Stable,
+            645 => SyntaxKind::StandaloneP,
+            646 => SyntaxKind::Start,
+            647 => SyntaxKind::Statement,
+            648 => SyntaxKind::Statistics,
+            649 => SyntaxKind::Stdin,
+            650 => SyntaxKind::Stdout,
+            651 => SyntaxKind::Storage,
+            652 => SyntaxKind::Stored,
+            653 => SyntaxKind::StrictP,
+            654 => SyntaxKind::StripP,
+            655 => SyntaxKind::Subscription,
+            656 => SyntaxKind::Substring,
+            657 => SyntaxKind::Support,
+            658 => SyntaxKind::Symmetric,
+            659 => SyntaxKind::Sysid,
+            660 => SyntaxKind::SystemP,
+            661 => SyntaxKind::Table,
+            662 => SyntaxKind::Tables,
+            663 => SyntaxKind::Tablesample,
+            664 => SyntaxKind::Tablespace,
+            665 => SyntaxKind::Temp,
+            666 => SyntaxKind::Template,
+            667 => SyntaxKind::Temporary,
+            668 => SyntaxKind::TextP,
+            669 => SyntaxKind::Then,
+            670 => SyntaxKind::Ties,
+            671 => SyntaxKind::Time,
+            672 => SyntaxKind::Timestamp,
+            673 => SyntaxKind::To,
+            674 => SyntaxKind::Trailing,
+            675 => SyntaxKind::Transaction,
+            676 => SyntaxKind::Transform,
+            677 => SyntaxKind::Treat,
+            678 => SyntaxKind::Trigger,
+            679 => SyntaxKind::Trim,
+            680 => SyntaxKind::TrueP,
+            681 => SyntaxKind::Truncate,
+            682 => SyntaxKind::Trusted,
+            683 => SyntaxKind::TypeP,
+            684 => SyntaxKind::TypesP,
+            685 => SyntaxKind::Uescape,
+            686 => SyntaxKind::Unbounded,
+            687 => SyntaxKind::Uncommitted,
+            688 => SyntaxKind::Unencrypted,
+            689 => SyntaxKind::Union,
+            690 => SyntaxKind::Unique,
+            691 => SyntaxKind::Unknown,
+            692 => SyntaxKind::Unlisten,
+            693 => SyntaxKind::Unlogged,
+            694 => SyntaxKind::Until,
+            695 => SyntaxKind::Update,
+            696 => SyntaxKind::User,
+            697 => SyntaxKind::Using,
+            698 => SyntaxKind::Vacuum,
+            699 => SyntaxKind::Valid,
+            700 => SyntaxKind::Validate,
+            701 => SyntaxKind::Validator,
+            702 => SyntaxKind::ValueP,
+            703 => SyntaxKind::Values,
+            704 => SyntaxKind::Varchar,
+            705 => SyntaxKind::Variadic,
+            706 => SyntaxKind::Varying,
+            707 => SyntaxKind::Verbose,
+            708 => SyntaxKind::VersionP,
+            709 => SyntaxKind::View,
+            710 => SyntaxKind::Views,
+            711 => SyntaxKind::Volatile,
+            712 => SyntaxKind::When,
+            713 => SyntaxKind::Where,
+            714 => SyntaxKind::WhitespaceP,
+            715 => SyntaxKind::Window,
+            716 => SyntaxKind::With,
+            717 => SyntaxKind::Within,
+            718 => SyntaxKind::Without,
+            719 => SyntaxKind::Work,
+            720 => SyntaxKind::Wrapper,
+            721 => SyntaxKind::Write,
+            722 => SyntaxKind::XmlP,
+            723 => SyntaxKind::Xmlattributes,
+            724 => SyntaxKind::Xmlconcat,
+            725 => SyntaxKind::Xmlelement,
+            726 => SyntaxKind::Xmlexists,
+            727 => SyntaxKind::Xmlforest,
+            728 => SyntaxKind::Xmlnamespaces,
+            729 => SyntaxKind::Xmlparse,
+            730 => SyntaxKind::Xmlpi,
+            731 => SyntaxKind::Xmlroot,
+            732 => SyntaxKind::Xmlserialize,
+            733 => SyntaxKind::Xmltable,
+            734 => SyntaxKind::YearP,
+            735 => SyntaxKind::YesP,
+            736 => SyntaxKind::Zone,
+            737 => SyntaxKind::NotLa,
+            738 => SyntaxKind::NullsLa,
+            739 => SyntaxKind::WithLa,
+            740 => SyntaxKind::ModeTypeName,
+            741 => SyntaxKind::ModePlpgsqlExpr,
+            742 => SyntaxKind::ModePlpgsqlAssign1,
+            743 => SyntaxKind::ModePlpgsqlAssign2,
+            744 => SyntaxKind::ModePlpgsqlAssign3,
+            745 => SyntaxKind::Uminus,
+        }
+    }
+
+    /// Returns the `SyntaxKindType` of a `SyntaxKind`
+    pub fn get_type(&self) -> Option<SyntaxKindType> {
+        match self {
+            SyntaxKind::Nul => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii37 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii40 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii41 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii42 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii43 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii44 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii45 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii46 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii47 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii58 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii59 => Some(SyntaxKindType::Close),
+            SyntaxKind::Ascii60 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii61 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii62 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii63 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii91 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii92 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii93 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ascii94 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ident => Some(SyntaxKindType::Follow),
+            SyntaxKind::Uident => Some(SyntaxKindType::Follow),
+            SyntaxKind::Fconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Usconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Bconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Op => Some(SyntaxKindType::Follow),
+            SyntaxKind::Iconst => Some(SyntaxKindType::Follow),
+            SyntaxKind::Param => Some(SyntaxKindType::Follow),
+            SyntaxKind::Typecast => Some(SyntaxKindType::Follow),
+            SyntaxKind::DotDot => Some(SyntaxKindType::Follow),
+            SyntaxKind::ColonEquals => Some(SyntaxKindType::Follow),
+            SyntaxKind::EqualsGreater => Some(SyntaxKindType::Follow),
+            SyntaxKind::LessEquals => Some(SyntaxKindType::Follow),
+            SyntaxKind::GreaterEquals => Some(SyntaxKindType::Follow),
+            SyntaxKind::NotEquals => Some(SyntaxKindType::Follow),
+            SyntaxKind::SqlComment => Some(SyntaxKindType::Follow),
+            SyntaxKind::CComment => Some(SyntaxKindType::Follow),
+            SyntaxKind::AbortP => Some(SyntaxKindType::Follow),
+            SyntaxKind::AbsoluteP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Access => Some(SyntaxKindType::Follow),
+            SyntaxKind::Action => Some(SyntaxKindType::Follow),
+            SyntaxKind::AddP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Admin => Some(SyntaxKindType::Follow),
+            SyntaxKind::After => Some(SyntaxKindType::Follow),
+            SyntaxKind::Aggregate => Some(SyntaxKindType::Follow),
+            SyntaxKind::All => Some(SyntaxKindType::Follow),
+            SyntaxKind::Also => Some(SyntaxKindType::Follow),
+            SyntaxKind::Alter => Some(SyntaxKindType::Follow),
+            SyntaxKind::Always => Some(SyntaxKindType::Follow),
+            SyntaxKind::Analyse => Some(SyntaxKindType::Follow),
+            SyntaxKind::Analyze => Some(SyntaxKindType::Follow),
+            SyntaxKind::And => Some(SyntaxKindType::Follow),
+            SyntaxKind::Any => Some(SyntaxKindType::Follow),
+            SyntaxKind::Array => Some(SyntaxKindType::Follow),
+            SyntaxKind::As => Some(SyntaxKindType::Follow),
+            SyntaxKind::Asc => Some(SyntaxKindType::Follow),
+            SyntaxKind::Asensitive => Some(SyntaxKindType::Follow),
+            SyntaxKind::Assertion => Some(SyntaxKindType::Follow),
+            SyntaxKind::Assignment => Some(SyntaxKindType::Follow),
+            SyntaxKind::Asymmetric => Some(SyntaxKindType::Follow),
+            SyntaxKind::Atomic => Some(SyntaxKindType::Follow),
+            SyntaxKind::At => Some(SyntaxKindType::Follow),
+            SyntaxKind::Attach => Some(SyntaxKindType::Follow),
+            SyntaxKind::Attribute => Some(SyntaxKindType::Follow),
+            SyntaxKind::Authorization => Some(SyntaxKindType::Follow),
+            SyntaxKind::Backward => Some(SyntaxKindType::Follow),
+            SyntaxKind::Before => Some(SyntaxKindType::Follow),
+            SyntaxKind::BeginP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Between => Some(SyntaxKindType::Follow),
+            SyntaxKind::Bigint => Some(SyntaxKindType::Follow),
+            SyntaxKind::Binary => Some(SyntaxKindType::Follow),
+            SyntaxKind::Bit => Some(SyntaxKindType::Follow),
+            SyntaxKind::BooleanP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Both => Some(SyntaxKindType::Follow),
+            SyntaxKind::Breadth => Some(SyntaxKindType::Follow),
+            SyntaxKind::By => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cache => Some(SyntaxKindType::Follow),
+            SyntaxKind::Call => Some(SyntaxKindType::Follow),
+            SyntaxKind::Called => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cascade => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cascaded => Some(SyntaxKindType::Follow),
+            SyntaxKind::Case => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cast => Some(SyntaxKindType::Follow),
+            SyntaxKind::CatalogP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Chain => Some(SyntaxKindType::Follow),
+            SyntaxKind::CharP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Character => Some(SyntaxKindType::Follow),
+            SyntaxKind::Characteristics => Some(SyntaxKindType::Follow),
+            SyntaxKind::Check => Some(SyntaxKindType::Follow),
+            SyntaxKind::Checkpoint => Some(SyntaxKindType::Follow),
+            SyntaxKind::Class => Some(SyntaxKindType::Follow),
+            SyntaxKind::Close => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cluster => Some(SyntaxKindType::Follow),
+            SyntaxKind::Coalesce => Some(SyntaxKindType::Follow),
+            SyntaxKind::Collate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Collation => Some(SyntaxKindType::Follow),
+            SyntaxKind::Column => Some(SyntaxKindType::Follow),
+            SyntaxKind::Columns => Some(SyntaxKindType::Follow),
+            SyntaxKind::Comment => Some(SyntaxKindType::Follow),
+            SyntaxKind::Comments => Some(SyntaxKindType::Follow),
+            SyntaxKind::Commit => Some(SyntaxKindType::Follow),
+            SyntaxKind::Committed => Some(SyntaxKindType::Follow),
+            SyntaxKind::Compression => Some(SyntaxKindType::Follow),
+            SyntaxKind::Concurrently => Some(SyntaxKindType::Follow),
+            SyntaxKind::Configuration => Some(SyntaxKindType::Follow),
+            SyntaxKind::Conflict => Some(SyntaxKindType::Follow),
+            SyntaxKind::Connection => Some(SyntaxKindType::Follow),
+            SyntaxKind::Constraint => Some(SyntaxKindType::Follow),
+            SyntaxKind::Constraints => Some(SyntaxKindType::Follow),
+            SyntaxKind::ContentP => Some(SyntaxKindType::Follow),
+            SyntaxKind::ContinueP => Some(SyntaxKindType::Follow),
+            SyntaxKind::ConversionP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Copy => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cost => Some(SyntaxKindType::Follow),
+            SyntaxKind::Create => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cross => Some(SyntaxKindType::Follow),
+            SyntaxKind::Csv => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cube => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentP => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentCatalog => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentDate => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentRole => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentSchema => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentTime => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentTimestamp => Some(SyntaxKindType::Follow),
+            SyntaxKind::CurrentUser => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cursor => Some(SyntaxKindType::Follow),
+            SyntaxKind::Cycle => Some(SyntaxKindType::Follow),
+            SyntaxKind::DataP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Database => Some(SyntaxKindType::Follow),
+            SyntaxKind::DayP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Deallocate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Dec => Some(SyntaxKindType::Follow),
+            SyntaxKind::DecimalP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Declare => Some(SyntaxKindType::Follow),
+            SyntaxKind::Default => Some(SyntaxKindType::Follow),
+            SyntaxKind::Defaults => Some(SyntaxKindType::Follow),
+            SyntaxKind::Deferrable => Some(SyntaxKindType::Follow),
+            SyntaxKind::Deferred => Some(SyntaxKindType::Follow),
+            SyntaxKind::Definer => Some(SyntaxKindType::Follow),
+            SyntaxKind::DeleteP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Delimiter => Some(SyntaxKindType::Follow),
+            SyntaxKind::Delimiters => Some(SyntaxKindType::Follow),
+            SyntaxKind::Depends => Some(SyntaxKindType::Follow),
+            SyntaxKind::Depth => Some(SyntaxKindType::Follow),
+            SyntaxKind::Desc => Some(SyntaxKindType::Follow),
+            SyntaxKind::Detach => Some(SyntaxKindType::Follow),
+            SyntaxKind::Dictionary => Some(SyntaxKindType::Follow),
+            SyntaxKind::DisableP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Discard => Some(SyntaxKindType::Follow),
+            SyntaxKind::Distinct => Some(SyntaxKindType::Follow),
+            SyntaxKind::Do => Some(SyntaxKindType::Follow),
+            SyntaxKind::DocumentP => Some(SyntaxKindType::Follow),
+            SyntaxKind::DomainP => Some(SyntaxKindType::Follow),
+            SyntaxKind::DoubleP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Drop => Some(SyntaxKindType::Follow),
+            SyntaxKind::Each => Some(SyntaxKindType::Follow),
+            SyntaxKind::Else => Some(SyntaxKindType::Follow),
+            SyntaxKind::EnableP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Encoding => Some(SyntaxKindType::Follow),
+            SyntaxKind::Encrypted => Some(SyntaxKindType::Follow),
+            SyntaxKind::EndP => Some(SyntaxKindType::Follow),
+            SyntaxKind::EnumP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Escape => Some(SyntaxKindType::Follow),
+            SyntaxKind::Event => Some(SyntaxKindType::Follow),
+            SyntaxKind::Except => Some(SyntaxKindType::Follow),
+            SyntaxKind::Exclude => Some(SyntaxKindType::Follow),
+            SyntaxKind::Excluding => Some(SyntaxKindType::Follow),
+            SyntaxKind::Exclusive => Some(SyntaxKindType::Follow),
+            SyntaxKind::Execute => Some(SyntaxKindType::Follow),
+            SyntaxKind::Exists => Some(SyntaxKindType::Follow),
+            SyntaxKind::Explain => Some(SyntaxKindType::Follow),
+            SyntaxKind::Expression => Some(SyntaxKindType::Follow),
+            SyntaxKind::Extension => Some(SyntaxKindType::Follow),
+            SyntaxKind::External => Some(SyntaxKindType::Follow),
+            SyntaxKind::Extract => Some(SyntaxKindType::Follow),
+            SyntaxKind::FalseP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Family => Some(SyntaxKindType::Follow),
+            SyntaxKind::Fetch => Some(SyntaxKindType::Follow),
+            SyntaxKind::Filter => Some(SyntaxKindType::Follow),
+            SyntaxKind::Finalize => Some(SyntaxKindType::Follow),
+            SyntaxKind::FirstP => Some(SyntaxKindType::Follow),
+            SyntaxKind::FloatP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Following => Some(SyntaxKindType::Follow),
+            SyntaxKind::For => Some(SyntaxKindType::Follow),
+            SyntaxKind::Force => Some(SyntaxKindType::Follow),
+            SyntaxKind::Foreign => Some(SyntaxKindType::Follow),
+            SyntaxKind::Forward => Some(SyntaxKindType::Follow),
+            SyntaxKind::Freeze => Some(SyntaxKindType::Follow),
+            SyntaxKind::From => Some(SyntaxKindType::Follow),
+            SyntaxKind::Full => Some(SyntaxKindType::Follow),
+            SyntaxKind::Function => Some(SyntaxKindType::Follow),
+            SyntaxKind::Functions => Some(SyntaxKindType::Follow),
+            SyntaxKind::Generated => Some(SyntaxKindType::Follow),
+            SyntaxKind::Global => Some(SyntaxKindType::Follow),
+            SyntaxKind::Grant => Some(SyntaxKindType::Follow),
+            SyntaxKind::Granted => Some(SyntaxKindType::Follow),
+            SyntaxKind::Greatest => Some(SyntaxKindType::Follow),
+            SyntaxKind::GroupP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Grouping => Some(SyntaxKindType::Follow),
+            SyntaxKind::Groups => Some(SyntaxKindType::Follow),
+            SyntaxKind::Handler => Some(SyntaxKindType::Follow),
+            SyntaxKind::Having => Some(SyntaxKindType::Follow),
+            SyntaxKind::HeaderP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Hold => Some(SyntaxKindType::Follow),
+            SyntaxKind::HourP => Some(SyntaxKindType::Follow),
+            SyntaxKind::IdentityP => Some(SyntaxKindType::Follow),
+            SyntaxKind::IfP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ilike => Some(SyntaxKindType::Follow),
+            SyntaxKind::Immediate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Immutable => Some(SyntaxKindType::Follow),
+            SyntaxKind::ImplicitP => Some(SyntaxKindType::Follow),
+            SyntaxKind::ImportP => Some(SyntaxKindType::Follow),
+            SyntaxKind::InP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Include => Some(SyntaxKindType::Follow),
+            SyntaxKind::Including => Some(SyntaxKindType::Follow),
+            SyntaxKind::Increment => Some(SyntaxKindType::Follow),
+            SyntaxKind::Index => Some(SyntaxKindType::Follow),
+            SyntaxKind::Indexes => Some(SyntaxKindType::Follow),
+            SyntaxKind::Inherit => Some(SyntaxKindType::Follow),
+            SyntaxKind::Inherits => Some(SyntaxKindType::Follow),
+            SyntaxKind::Initially => Some(SyntaxKindType::Follow),
+            SyntaxKind::InlineP => Some(SyntaxKindType::Follow),
+            SyntaxKind::InnerP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Inout => Some(SyntaxKindType::Follow),
+            SyntaxKind::InputP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Insensitive => Some(SyntaxKindType::Follow),
+            SyntaxKind::Insert => Some(SyntaxKindType::Follow),
+            SyntaxKind::Instead => Some(SyntaxKindType::Follow),
+            SyntaxKind::IntP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Integer => Some(SyntaxKindType::Follow),
+            SyntaxKind::Intersect => Some(SyntaxKindType::Follow),
+            SyntaxKind::Interval => Some(SyntaxKindType::Follow),
+            SyntaxKind::Into => Some(SyntaxKindType::Follow),
+            SyntaxKind::Invoker => Some(SyntaxKindType::Follow),
+            SyntaxKind::Is => Some(SyntaxKindType::Follow),
+            SyntaxKind::Isnull => Some(SyntaxKindType::Follow),
+            SyntaxKind::Isolation => Some(SyntaxKindType::Follow),
+            SyntaxKind::Join => Some(SyntaxKindType::Follow),
+            SyntaxKind::Key => Some(SyntaxKindType::Follow),
+            SyntaxKind::Label => Some(SyntaxKindType::Follow),
+            SyntaxKind::Language => Some(SyntaxKindType::Follow),
+            SyntaxKind::LargeP => Some(SyntaxKindType::Follow),
+            SyntaxKind::LastP => Some(SyntaxKindType::Follow),
+            SyntaxKind::LateralP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Leading => Some(SyntaxKindType::Follow),
+            SyntaxKind::Leakproof => Some(SyntaxKindType::Follow),
+            SyntaxKind::Least => Some(SyntaxKindType::Follow),
+            SyntaxKind::Left => Some(SyntaxKindType::Follow),
+            SyntaxKind::Level => Some(SyntaxKindType::Follow),
+            SyntaxKind::Like => Some(SyntaxKindType::Follow),
+            SyntaxKind::Limit => Some(SyntaxKindType::Follow),
+            SyntaxKind::Listen => Some(SyntaxKindType::Follow),
+            SyntaxKind::Load => Some(SyntaxKindType::Follow),
+            SyntaxKind::Local => Some(SyntaxKindType::Follow),
+            SyntaxKind::Localtime => Some(SyntaxKindType::Follow),
+            SyntaxKind::Localtimestamp => Some(SyntaxKindType::Follow),
+            SyntaxKind::Location => Some(SyntaxKindType::Follow),
+            SyntaxKind::LockP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Locked => Some(SyntaxKindType::Follow),
+            SyntaxKind::Logged => Some(SyntaxKindType::Follow),
+            SyntaxKind::Mapping => Some(SyntaxKindType::Follow),
+            SyntaxKind::Match => Some(SyntaxKindType::Follow),
+            SyntaxKind::Matched => Some(SyntaxKindType::Follow),
+            SyntaxKind::Materialized => Some(SyntaxKindType::Follow),
+            SyntaxKind::Maxvalue => Some(SyntaxKindType::Follow),
+            SyntaxKind::Merge => Some(SyntaxKindType::Follow),
+            SyntaxKind::Method => Some(SyntaxKindType::Follow),
+            SyntaxKind::MinuteP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Minvalue => Some(SyntaxKindType::Follow),
+            SyntaxKind::Mode => Some(SyntaxKindType::Follow),
+            SyntaxKind::MonthP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Move => Some(SyntaxKindType::Follow),
+            SyntaxKind::NameP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Names => Some(SyntaxKindType::Follow),
+            SyntaxKind::National => Some(SyntaxKindType::Follow),
+            SyntaxKind::Natural => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nchar => Some(SyntaxKindType::Follow),
+            SyntaxKind::New => Some(SyntaxKindType::Follow),
+            SyntaxKind::Next => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nfc => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nfd => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nfkc => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nfkd => Some(SyntaxKindType::Follow),
+            SyntaxKind::No => Some(SyntaxKindType::Follow),
+            SyntaxKind::None => Some(SyntaxKindType::Follow),
+            SyntaxKind::Normalize => Some(SyntaxKindType::Follow),
+            SyntaxKind::Normalized => Some(SyntaxKindType::Follow),
+            SyntaxKind::Not => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nothing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Notify => Some(SyntaxKindType::Follow),
+            SyntaxKind::Notnull => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nowait => Some(SyntaxKindType::Follow),
+            SyntaxKind::NullP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Nullif => Some(SyntaxKindType::Follow),
+            SyntaxKind::NullsP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Numeric => Some(SyntaxKindType::Follow),
+            SyntaxKind::ObjectP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Of => Some(SyntaxKindType::Follow),
+            SyntaxKind::Off => Some(SyntaxKindType::Follow),
+            SyntaxKind::Offset => Some(SyntaxKindType::Follow),
+            SyntaxKind::Oids => Some(SyntaxKindType::Follow),
+            SyntaxKind::Old => Some(SyntaxKindType::Follow),
+            SyntaxKind::On => Some(SyntaxKindType::Follow),
+            SyntaxKind::Only => Some(SyntaxKindType::Follow),
+            SyntaxKind::Operator => Some(SyntaxKindType::Follow),
+            SyntaxKind::Option => Some(SyntaxKindType::Follow),
+            SyntaxKind::Options => Some(SyntaxKindType::Follow),
+            SyntaxKind::Or => Some(SyntaxKindType::Follow),
+            SyntaxKind::Order => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ordinality => Some(SyntaxKindType::Follow),
+            SyntaxKind::Others => Some(SyntaxKindType::Follow),
+            SyntaxKind::OutP => Some(SyntaxKindType::Follow),
+            SyntaxKind::OuterP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Over => Some(SyntaxKindType::Follow),
+            SyntaxKind::Overlaps => Some(SyntaxKindType::Follow),
+            SyntaxKind::Overlay => Some(SyntaxKindType::Follow),
+            SyntaxKind::Overriding => Some(SyntaxKindType::Follow),
+            SyntaxKind::Owned => Some(SyntaxKindType::Follow),
+            SyntaxKind::Owner => Some(SyntaxKindType::Follow),
+            SyntaxKind::Parallel => Some(SyntaxKindType::Follow),
+            SyntaxKind::Parameter => Some(SyntaxKindType::Follow),
+            SyntaxKind::Parser => Some(SyntaxKindType::Follow),
+            SyntaxKind::Partial => Some(SyntaxKindType::Follow),
+            SyntaxKind::Partition => Some(SyntaxKindType::Follow),
+            SyntaxKind::Passing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Password => Some(SyntaxKindType::Follow),
+            SyntaxKind::Placing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Plans => Some(SyntaxKindType::Follow),
+            SyntaxKind::Policy => Some(SyntaxKindType::Follow),
+            SyntaxKind::Position => Some(SyntaxKindType::Follow),
+            SyntaxKind::Preceding => Some(SyntaxKindType::Follow),
+            SyntaxKind::Precision => Some(SyntaxKindType::Follow),
+            SyntaxKind::Preserve => Some(SyntaxKindType::Follow),
+            SyntaxKind::Prepare => Some(SyntaxKindType::Follow),
+            SyntaxKind::Prepared => Some(SyntaxKindType::Follow),
+            SyntaxKind::Primary => Some(SyntaxKindType::Follow),
+            SyntaxKind::Prior => Some(SyntaxKindType::Follow),
+            SyntaxKind::Privileges => Some(SyntaxKindType::Follow),
+            SyntaxKind::Procedural => Some(SyntaxKindType::Follow),
+            SyntaxKind::Procedure => Some(SyntaxKindType::Follow),
+            SyntaxKind::Procedures => Some(SyntaxKindType::Follow),
+            SyntaxKind::Program => Some(SyntaxKindType::Follow),
+            SyntaxKind::Publication => Some(SyntaxKindType::Follow),
+            SyntaxKind::Quote => Some(SyntaxKindType::Follow),
+            SyntaxKind::Range => Some(SyntaxKindType::Follow),
+            SyntaxKind::Read => Some(SyntaxKindType::Follow),
+            SyntaxKind::Real => Some(SyntaxKindType::Follow),
+            SyntaxKind::Reassign => Some(SyntaxKindType::Follow),
+            SyntaxKind::Recheck => Some(SyntaxKindType::Follow),
+            SyntaxKind::Recursive => Some(SyntaxKindType::Follow),
+            SyntaxKind::RefP => Some(SyntaxKindType::Follow),
+            SyntaxKind::References => Some(SyntaxKindType::Follow),
+            SyntaxKind::Referencing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Refresh => Some(SyntaxKindType::Follow),
+            SyntaxKind::Reindex => Some(SyntaxKindType::Follow),
+            SyntaxKind::RelativeP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Release => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rename => Some(SyntaxKindType::Follow),
+            SyntaxKind::Repeatable => Some(SyntaxKindType::Follow),
+            SyntaxKind::Replace => Some(SyntaxKindType::Follow),
+            SyntaxKind::Replica => Some(SyntaxKindType::Follow),
+            SyntaxKind::Reset => Some(SyntaxKindType::Follow),
+            SyntaxKind::Restart => Some(SyntaxKindType::Follow),
+            SyntaxKind::Restrict => Some(SyntaxKindType::Follow),
+            SyntaxKind::Return => Some(SyntaxKindType::Follow),
+            SyntaxKind::Returning => Some(SyntaxKindType::Follow),
+            SyntaxKind::Returns => Some(SyntaxKindType::Follow),
+            SyntaxKind::Revoke => Some(SyntaxKindType::Follow),
+            SyntaxKind::Right => Some(SyntaxKindType::Follow),
+            SyntaxKind::Role => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rollback => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rollup => Some(SyntaxKindType::Follow),
+            SyntaxKind::Routine => Some(SyntaxKindType::Follow),
+            SyntaxKind::Routines => Some(SyntaxKindType::Follow),
+            SyntaxKind::Row => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rows => Some(SyntaxKindType::Follow),
+            SyntaxKind::Rule => Some(SyntaxKindType::Follow),
+            SyntaxKind::Savepoint => Some(SyntaxKindType::Follow),
+            SyntaxKind::Schema => Some(SyntaxKindType::Follow),
+            SyntaxKind::Schemas => Some(SyntaxKindType::Follow),
+            SyntaxKind::Scroll => Some(SyntaxKindType::Follow),
+            SyntaxKind::Search => Some(SyntaxKindType::Follow),
+            SyntaxKind::SecondP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Security => Some(SyntaxKindType::Follow),
+            SyntaxKind::Select => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sequence => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sequences => Some(SyntaxKindType::Follow),
+            SyntaxKind::Serializable => Some(SyntaxKindType::Follow),
+            SyntaxKind::Server => Some(SyntaxKindType::Follow),
+            SyntaxKind::Session => Some(SyntaxKindType::Follow),
+            SyntaxKind::SessionUser => Some(SyntaxKindType::Follow),
+            SyntaxKind::Set => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sets => Some(SyntaxKindType::Follow),
+            SyntaxKind::Setof => Some(SyntaxKindType::Follow),
+            SyntaxKind::Share => Some(SyntaxKindType::Follow),
+            SyntaxKind::Show => Some(SyntaxKindType::Follow),
+            SyntaxKind::Similar => Some(SyntaxKindType::Follow),
+            SyntaxKind::Simple => Some(SyntaxKindType::Follow),
+            SyntaxKind::Skip => Some(SyntaxKindType::Follow),
+            SyntaxKind::Smallint => Some(SyntaxKindType::Follow),
+            SyntaxKind::Snapshot => Some(SyntaxKindType::Follow),
+            SyntaxKind::Some => Some(SyntaxKindType::Follow),
+            SyntaxKind::SqlP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Stable => Some(SyntaxKindType::Follow),
+            SyntaxKind::StandaloneP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Start => Some(SyntaxKindType::Follow),
+            SyntaxKind::Statement => Some(SyntaxKindType::Follow),
+            SyntaxKind::Statistics => Some(SyntaxKindType::Follow),
+            SyntaxKind::Stdin => Some(SyntaxKindType::Follow),
+            SyntaxKind::Stdout => Some(SyntaxKindType::Follow),
+            SyntaxKind::Storage => Some(SyntaxKindType::Follow),
+            SyntaxKind::Stored => Some(SyntaxKindType::Follow),
+            SyntaxKind::StrictP => Some(SyntaxKindType::Follow),
+            SyntaxKind::StripP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Subscription => Some(SyntaxKindType::Follow),
+            SyntaxKind::Substring => Some(SyntaxKindType::Follow),
+            SyntaxKind::Support => Some(SyntaxKindType::Follow),
+            SyntaxKind::Symmetric => Some(SyntaxKindType::Follow),
+            SyntaxKind::Sysid => Some(SyntaxKindType::Follow),
+            SyntaxKind::SystemP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Table => Some(SyntaxKindType::Follow),
+            SyntaxKind::Tables => Some(SyntaxKindType::Follow),
+            SyntaxKind::Tablesample => Some(SyntaxKindType::Follow),
+            SyntaxKind::Tablespace => Some(SyntaxKindType::Follow),
+            SyntaxKind::Temp => Some(SyntaxKindType::Follow),
+            SyntaxKind::Template => Some(SyntaxKindType::Follow),
+            SyntaxKind::Temporary => Some(SyntaxKindType::Follow),
+            SyntaxKind::TextP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Then => Some(SyntaxKindType::Follow),
+            SyntaxKind::Ties => Some(SyntaxKindType::Follow),
+            SyntaxKind::Time => Some(SyntaxKindType::Follow),
+            SyntaxKind::Timestamp => Some(SyntaxKindType::Follow),
+            SyntaxKind::To => Some(SyntaxKindType::Follow),
+            SyntaxKind::Trailing => Some(SyntaxKindType::Follow),
+            SyntaxKind::Transaction => Some(SyntaxKindType::Follow),
+            SyntaxKind::Transform => Some(SyntaxKindType::Follow),
+            SyntaxKind::Treat => Some(SyntaxKindType::Follow),
+            SyntaxKind::Trigger => Some(SyntaxKindType::Follow),
+            SyntaxKind::Trim => Some(SyntaxKindType::Follow),
+            SyntaxKind::TrueP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Truncate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Trusted => Some(SyntaxKindType::Follow),
+            SyntaxKind::TypeP => Some(SyntaxKindType::Follow),
+            SyntaxKind::TypesP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Uescape => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unbounded => Some(SyntaxKindType::Follow),
+            SyntaxKind::Uncommitted => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unencrypted => Some(SyntaxKindType::Follow),
+            SyntaxKind::Union => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unique => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unknown => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unlisten => Some(SyntaxKindType::Follow),
+            SyntaxKind::Unlogged => Some(SyntaxKindType::Follow),
+            SyntaxKind::Until => Some(SyntaxKindType::Follow),
+            SyntaxKind::Update => Some(SyntaxKindType::Follow),
+            SyntaxKind::User => Some(SyntaxKindType::Follow),
+            SyntaxKind::Using => Some(SyntaxKindType::Follow),
+            SyntaxKind::Vacuum => Some(SyntaxKindType::Follow),
+            SyntaxKind::Valid => Some(SyntaxKindType::Follow),
+            SyntaxKind::Validate => Some(SyntaxKindType::Follow),
+            SyntaxKind::Validator => Some(SyntaxKindType::Follow),
+            SyntaxKind::ValueP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Values => Some(SyntaxKindType::Follow),
+            SyntaxKind::Varchar => Some(SyntaxKindType::Follow),
+            SyntaxKind::Variadic => Some(SyntaxKindType::Follow),
+            SyntaxKind::Varying => Some(SyntaxKindType::Follow),
+            SyntaxKind::Verbose => Some(SyntaxKindType::Follow),
+            SyntaxKind::VersionP => Some(SyntaxKindType::Follow),
+            SyntaxKind::View => Some(SyntaxKindType::Follow),
+            SyntaxKind::Views => Some(SyntaxKindType::Follow),
+            SyntaxKind::Volatile => Some(SyntaxKindType::Follow),
+            SyntaxKind::When => Some(SyntaxKindType::Follow),
+            SyntaxKind::Where => Some(SyntaxKindType::Follow),
+            SyntaxKind::WhitespaceP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Window => Some(SyntaxKindType::Follow),
+            SyntaxKind::With => Some(SyntaxKindType::Follow),
+            SyntaxKind::Within => Some(SyntaxKindType::Follow),
+            SyntaxKind::Without => Some(SyntaxKindType::Follow),
+            SyntaxKind::Work => Some(SyntaxKindType::Follow),
+            SyntaxKind::Wrapper => Some(SyntaxKindType::Follow),
+            SyntaxKind::Write => Some(SyntaxKindType::Follow),
+            SyntaxKind::XmlP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlattributes => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlconcat => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlelement => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlexists => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlforest => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlnamespaces => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlparse => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlpi => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlroot => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmlserialize => Some(SyntaxKindType::Follow),
+            SyntaxKind::Xmltable => Some(SyntaxKindType::Follow),
+            SyntaxKind::YearP => Some(SyntaxKindType::Follow),
+            SyntaxKind::YesP => Some(SyntaxKindType::Follow),
+            SyntaxKind::Zone => Some(SyntaxKindType::Follow),
+            SyntaxKind::NotLa => Some(SyntaxKindType::Follow),
+            SyntaxKind::NullsLa => Some(SyntaxKindType::Follow),
+            SyntaxKind::WithLa => Some(SyntaxKindType::Follow),
+            SyntaxKind::ModeTypeName => Some(SyntaxKindType::Follow),
+            SyntaxKind::ModePlpgsqlExpr => Some(SyntaxKindType::Follow),
+            SyntaxKind::ModePlpgsqlAssign1 => Some(SyntaxKindType::Follow),
+            SyntaxKind::ModePlpgsqlAssign2 => Some(SyntaxKindType::Follow),
+            SyntaxKind::ModePlpgsqlAssign3 => Some(SyntaxKindType::Follow),
+            SyntaxKind::Uminus => Some(SyntaxKindType::Follow),
+        }
+    }
+}
diff --git a/crates/pg_query_proto_parser/src/proto_file.rs b/crates/pg_query_proto_parser/src/proto_file.rs
index fd59932c..2cc32798 100644
--- a/crates/pg_query_proto_parser/src/proto_file.rs
+++ b/crates/pg_query_proto_parser/src/proto_file.rs
@@ -1,5 +1,5 @@
 /// The FieldTypes of a protobuf message
-#[derive(Debug)]
+#[derive(Debug, Eq, PartialEq)]
 pub enum FieldType {
     Node,
     Double,
@@ -33,8 +33,11 @@ pub struct Token {
 #[derive(Debug)]
 pub struct Field {
     pub name: String,
+    pub node_name: Option<String>,
+    pub enum_variant_name: Option<String>,
     pub field_type: FieldType,
     pub repeated: bool,
+    pub is_one_of: bool,
 }
 
 /// A libg_query node
diff --git a/crates/pg_query_proto_parser/src/proto_parser.rs b/crates/pg_query_proto_parser/src/proto_parser.rs
index 85263be2..f393b0a1 100644
--- a/crates/pg_query_proto_parser/src/proto_parser.rs
+++ b/crates/pg_query_proto_parser/src/proto_parser.rs
@@ -50,6 +50,22 @@ impl ProtoParser {
             .collect()
     }
 
+    fn get_enum_variant_name(&self, type_name: &str) -> Option<String> {
+        let variant = self
+            .inner
+            .message_type
+            .iter()
+            .find(|e| e.name == Some("Node".into()))
+            .unwrap()
+            .field
+            .iter()
+            .find(|e| e.type_name().split(".").last().unwrap() == type_name);
+        match variant {
+            Some(v) => Some(v.name.clone().unwrap().to_case(Case::UpperCamel)),
+            None => None,
+        }
+    }
+
     fn nodes(&self) -> Vec<Node> {
         self.inner
             .message_type
@@ -59,23 +75,31 @@ impl ProtoParser {
             .field
             .iter()
             .map(|e| {
-                let name: String = e.json_name.to_owned().unwrap();
-                Node {
-                    // token names in proto are UPPERCASE_SNAKE_CASE
-                    name: name.clone(),
-                    fields: self
-                        .inner
-                        .message_type
-                        .iter()
-                        .find(|n| n.name.clone().unwrap() == name)
-                        .unwrap()
+                let name: String = e.name.to_owned().unwrap().to_case(Case::UpperCamel);
+                let node = self
+                    .inner
+                    .message_type
+                    .iter()
+                    .find(|n| {
+                        n.name.clone().unwrap().to_case(Case::UpperCamel)
+                            == e.json_name.as_ref().unwrap().to_case(Case::UpperCamel)
+                    })
+                    .unwrap();
+
+                let mut fields: Vec<Field> = Vec::new();
+                // from node fields
+                fields.append(&mut
+                        node
                         .field
                         .iter()
-                        .map(|e| {
+                        .filter_map(|e| {
+                            // skip one of fields, they are handled separately
+                            if e.has_oneof_index() {
+                                return None;
+                            }
                             // use label and type to get the field type
                             let type_name: FieldType = match e.type_name() {
-                                ".pg_query.Node" => FieldType::Node,
-                                _ => match e.type_() {
+                                "" => match e.type_() {
                                     protobuf::descriptor::field_descriptor_proto::Type::TYPE_DOUBLE => FieldType::Double,
                                     protobuf::descriptor::field_descriptor_proto::Type::TYPE_FLOAT => FieldType::Float,
                                     protobuf::descriptor::field_descriptor_proto::Type::TYPE_INT64 => FieldType::Int64,
@@ -95,14 +119,62 @@ impl ProtoParser {
                                     protobuf::descriptor::field_descriptor_proto::Type::TYPE_SINT32 => FieldType::Sint32,
                                     protobuf::descriptor::field_descriptor_proto::Type::TYPE_SINT64 => FieldType::Sint64,
                                 },
+                                _ => {
+                                    if !e.type_name().starts_with(".pg_query") {
+                                        panic!("Unknown type: {}", e.type_name());
+
+                                    }
+                                    if e.type_() == protobuf::descriptor::field_descriptor_proto::Type::TYPE_ENUM {
+                                        FieldType::Enum
+                                    } else {
+                                        FieldType::Node
+                                    }
+                                },
                             };
-                            Field {
+                            let mut node_name = None;
+                            let mut enum_variant_name = None;
+                            if e.type_name().starts_with(".pg_query") {
+                                let n = e.type_name().split(".").last().unwrap().to_string();
+                                node_name = Some(n.clone());
+                                if n != "Node" {
+                                    enum_variant_name = self.get_enum_variant_name(e.type_name().split(".").last().unwrap().to_string().as_str());
+                                }
+                            }
+                            // TODO: node name must be derived from the property name in the node
+                            // enum
+                            Some(Field {
                                 name: e.name.clone().unwrap(),
+                                node_name,
+                                enum_variant_name,
                                 field_type: type_name,
                                 repeated: e.label() == Label::LABEL_REPEATED,
-                            }
+                                is_one_of: false,
+                            })
+                        })
+                        .collect()
+                    );
+
+                    // one of declarations
+                    fields.append(&mut
+                        node
+                        .oneof_decl
+                        .iter()
+                        .map(|e| {
+                            Field {
+                       name: e.name.clone().unwrap(),
+                       node_name: Some("Node".to_string()),
+                       enum_variant_name: None,
+                       field_type: FieldType::Node,
+                       repeated: false,
+                       is_one_of: true,
+                   }
                         })
-                        .collect(),
+                        .collect()
+                              );
+                Node {
+                    // token names in proto are UPPERCASE_SNAKE_CASE
+                    name: name.clone(),
+                    fields,
                 }
             })
             .collect()
diff --git a/crates/sourcegen/Cargo.toml b/crates/sourcegen/Cargo.toml
index ec859dee..e5cfb4a5 100644
--- a/crates/sourcegen/Cargo.toml
+++ b/crates/sourcegen/Cargo.toml
@@ -7,3 +7,4 @@ edition = "2021"
 
 [dependencies]
 textwrap = "0.16.0"
+rustfmt-wrapper = "0.2.0"
diff --git a/crates/sourcegen/src/enum_.rs b/crates/sourcegen/src/enum_.rs
index f58b9a99..5f150cf4 100644
--- a/crates/sourcegen/src/enum_.rs
+++ b/crates/sourcegen/src/enum_.rs
@@ -1,4 +1,4 @@
-use crate::builder::Builder;
+use crate::{builder::Builder, Comment};
 
 #[derive(Debug, Clone)]
 pub struct EnumValue {
@@ -10,7 +10,7 @@ pub struct EnumValue {
 #[derive(Debug, Clone)]
 pub struct Enum {
     name: String,
-    comments: Vec<String>,
+    comments: Comment,
     public: bool,
     values: Vec<EnumValue>,
     attributes: Vec<String>,
@@ -19,11 +19,8 @@ pub struct Enum {
 impl Builder for Enum {
     fn finish(&mut self) -> String {
         let mut result = String::new();
-        for comment in &self.comments {
-            result.push_str("/// ");
-            result.push_str(&comment);
-            result.push_str("\n");
-        }
+        result.push_str(self.comments.finish().as_str());
+        result.push_str("\n");
         for attribute in &self.attributes {
             result.push_str(&attribute);
         }
@@ -51,7 +48,7 @@ impl Enum {
     pub fn new(name: String) -> Self {
         Enum {
             name,
-            comments: Vec::new(),
+            comments: Comment::new("///".to_string()),
             public: false,
             values: Vec::new(),
             attributes: Vec::new(),
@@ -64,11 +61,14 @@ impl Enum {
     }
 
     pub fn with_comment(&mut self, comment: String) -> &mut Self {
-        self.comments.push(comment);
+        self.comments.with_text(comment);
         self
     }
 
     pub fn with_value(&mut self, name: String, value: Option<String>) -> &mut Self {
+        if self.values.iter().find(|v| v.name == name).is_some() {
+            return self;
+        }
         self.values.push(EnumValue { name, value });
         self
     }
diff --git a/crates/sourcegen/src/function.rs b/crates/sourcegen/src/function.rs
index 47b401f4..cbb7daa5 100644
--- a/crates/sourcegen/src/function.rs
+++ b/crates/sourcegen/src/function.rs
@@ -30,7 +30,7 @@ impl Builder for Function {
             result.push_str(" -> ");
             result.push_str(&return_type);
         }
-        result.push_str("{\n");
+        result.push_str("{\n\t");
         result.push_str(&self.body);
         result.push_str("\n}\n");
         result
@@ -60,8 +60,13 @@ impl Function {
         self
     }
 
-    pub fn with_parameter(&mut self, name: String, type_: String) -> &mut Self {
-        self.parameters.push(format!("{}: {}", name, type_));
+    pub fn with_parameter(&mut self, name: String, type_: Option<String>) -> &mut Self {
+        let mut parameter = name;
+        if let Some(type_) = type_ {
+            parameter.push_str(": ");
+            parameter.push_str(&type_);
+        }
+        self.parameters.push(parameter);
         self
     }
 
diff --git a/crates/sourcegen/src/source_file.rs b/crates/sourcegen/src/source_file.rs
index 499659b6..727f4fe9 100644
--- a/crates/sourcegen/src/source_file.rs
+++ b/crates/sourcegen/src/source_file.rs
@@ -1,22 +1,25 @@
-use crate::builder::Builder;
+use crate::{builder::Builder, Comment};
+use rustfmt_wrapper::rustfmt;
 
 #[derive(Debug, Clone)]
 pub struct SourceFile {
     content: String,
-    comments: Vec<String>,
+    comments: Comment,
 }
 
 impl Builder for SourceFile {
     fn finish(&mut self) -> String {
         let mut result = String::new();
-        for comment in &self.comments {
-            result.push_str("//! ");
-            result.push_str(&comment);
-            result.push_str("\n");
-        }
+        result.push_str(self.comments.finish().as_str());
         result.push_str("\n");
         result.push_str(&self.content);
-        result
+        match rustfmt(&result) {
+            Ok(formatted) => formatted,
+            Err(e) => {
+                println!("rustfmt error: {:?}", e);
+                result
+            }
+        }
     }
 }
 
@@ -25,12 +28,12 @@ impl SourceFile {
     pub fn new() -> Self {
         SourceFile {
             content: "".to_string(),
-            comments: Vec::new(),
+            comments: Comment::new("//!".to_string()),
         }
     }
 
     pub fn add_comment(&mut self, comment: String) -> &mut SourceFile {
-        self.comments.push(comment);
+        self.comments.with_text(comment);
         self
     }
 

From 4ca2870808579e40e188d7ffdfe53e9b4abcf7d1 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Thu, 3 Aug 2023 18:21:21 +0200
Subject: [PATCH 03/23] progress

---
 crates/parser/src/bin/generate.rs             |  113 +-
 crates/parser/src/lib.rs                      |    7 +-
 crates/parser/src/parser.rs                   |    2 +-
 crates/parser/src/pg_query_utils_generated.rs | 4195 +++++++++++------
 .../src/pg_query_utils_generated_test.rs      |   40 +
 crates/parser/src/source_file.rs              |    2 +-
 crates/parser/src/statement.rs                |  233 +-
 crates/parser/src/syntax_kind_generated.rs    |   20 +
 crates/parser/src/syntax_node.rs              |    2 +-
 crates/sourcegen/src/lib.rs                   |    2 +
 crates/sourcegen/src/struct_.rs               |   83 +
 11 files changed, 3199 insertions(+), 1500 deletions(-)
 create mode 100644 crates/parser/src/pg_query_utils_generated_test.rs
 create mode 100644 crates/sourcegen/src/struct_.rs

diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
index 01ac663d..293cfdb9 100644
--- a/crates/parser/src/bin/generate.rs
+++ b/crates/parser/src/bin/generate.rs
@@ -1,6 +1,6 @@
 use pg_query_proto_parser::{FieldType, ProtoFile, ProtoParser};
 use sourcegen::{
-    Attribute, Builder, Comment, Enum, Function, Implementation, Imports, Match, SourceFile,
+    Attribute, Builder, Comment, Enum, Function, Implementation, Imports, Match, SourceFile, Struct,
 };
 use std::fs;
 
@@ -11,20 +11,8 @@ use std::fs;
 // NodeEnum::AlterTsconfigurationStmt(_) => todo!(),
 // NodeEnum::Null(_) => todo!(),
 
-const UNKNOWN_NODES: [&str; 12] = [
+const UNKNOWN_NODES: [&str; 0] = [
     // ignore nodes not known to pg_query.rs
-    "MergeAction",
-    "MergeStmt",
-    "PlAssignStmt",
-    "AlterDatabaseRefreshCollStmt",
-    "StatsElem",
-    "CteSearchClause",
-    "CteCycleClause",
-    "MergeWhenClause",
-    "PublicationObjSpec",
-    "PublicationTable",
-    "Boolean",
-    "ReturnStmt",
 ];
 
 fn main() {
@@ -52,17 +40,17 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
             Imports::new()
                 .with_import(
                     "pg_query".to_string(),
-                    vec!["NodeEnum".to_string(), "NodeRef".to_string()],
+                    vec!["NodeEnum".to_string()],
                 )
                 .finish(),
         )
         .add_block(
             Function::new("get_location".to_string())
                 .public()
-                .with_parameter("node".to_string(), Some("NodeEnum".to_string()))
+                .with_parameter("node".to_string(), Some("&NodeEnum".to_string()))
                 .with_return_type("Option<i32>".to_string())
                 .with_body(
-                    Match::new("&node".to_string())
+                    Match::new("node".to_string())
                         .with(|b| {
                             f.nodes.iter().for_each(|node| {
                                 let mut right = "None";
@@ -88,25 +76,44 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                 .finish(),
         )
         .add_block(
-            Function::new("get_nested_nodes".to_string())
+            Struct::new("NestedNode".to_string())
+            .public()
+            .with_field("node".to_string(), "NodeEnum".to_string())
+            .with_field("depth".to_string(), "i32".to_string())
+            .with_field("location".to_string(), "i32".to_string())
+            .finish()
+        )
+        // TODO: 1) always use match or if .is_some() when unwrapping a node and ignore if none
+        // TODO: 2) add location to NestedNode, and use it in get_children.
+        // TODO:    to get location, first check if node has location field.
+        // TODO:    if not, use the location of the parent.
+        // in some cases, for example cte, location is on a generic Node child, which has a node prop that
+        // contains the actual node (e.g. insert statement) --> if we get the location within
+        // get_children, we can easily get the location of the actual node because we can just
+        // fallback to the location of the immediate parent if the current node does not have a
+        // location.
+        .add_block(
+            Function::new("get_children".to_string())
                 .public()
-                .with_comment("Returns the node and all its childrens, recursively".to_string())
-                .with_parameter("node".to_string(), Some("NodeEnum".to_string()))
-                .with_return_type("Vec<NodeEnum>".to_string())
-                .with_body(
-                    Match::new("&node".to_string())
+                .with_comment("Returns all children of the node, recursively".to_string())
+                .with_parameter("node".to_string(), Some("&NodeEnum".to_string()))
+                .with_parameter("current_depth".to_string(), Some("i32".to_string()))
+                .with_return_type("Vec<NestedNode>".to_string())
+                .with(|b| {
+                    let mut content = "let current_depth = current_depth + 1;".to_string();
+                    let match_ = Match::new("&node".to_string())
                         .with(|b| {
                             f.nodes.iter().for_each(|node| {
                                 let mut content = "".to_string();
                                 content.push_str("{\n");
                                 content.push_str(
-                                    "let mut nodes: Vec<NodeEnum> = vec![node.clone()];\n",
+                                    "let mut nodes: Vec<NestedNode> = vec![];\n",
                                 );
                                 node.fields.iter().for_each(|field| {
                                     if field.field_type == FieldType::Node && field.repeated {
                                         content.push_str(
                                             format!(
-                                                "nodes.append(&mut n.{}.iter().flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned())).collect());\n",
+                                                "nodes.append(&mut n.{}.iter().flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth)).collect());\n",
                                                 field.name.to_string()
                                             ).as_str()
                                         );
@@ -114,20 +121,55 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                         if field.node_name == Some("Node".to_owned()) {
                                             content.push_str(
                                                 format!(
-                                                    "nodes.append(&mut get_nested_nodes(n.{}.as_ref().unwrap().to_owned().node.unwrap()));\n",
+                                                    "let {} = n.{}.as_ref().unwrap().to_owned().node.unwrap();\n",
                                                     field.name.to_string(),
-                                                ).as_str()
+                                                    field.name.to_string(),
+                                                ).as_str(),
+                                            );
+                                            content.push_str(
+                                                format!(
+                                                    "nodes.append(&mut get_children(&{}, current_depth));\n",
+                                                    field.name.to_string()
+                                                ).as_str(),
+
+                                            );
+                                            content.push_str(
+                                                format!(
+                                                    "nodes.push(NestedNode {{
+                                                        node: {},
+                                                        depth: current_depth,
+                                                    }});\n",
+                                                    field.name.to_string()
+                                                ).as_str(),
                                             );
                                         } else {
                                             content.push_str(
                                                 format!(
-                                                    "nodes.append(&mut get_nested_nodes(NodeEnum::{}(n.{}.as_ref().unwrap().to_owned())));\n",
+                                                    "let {} = NodeEnum::{}(n.{}.as_ref().unwrap().to_owned());\n",
+                                                    field.name.to_string(),
                                                     field.enum_variant_name.as_ref().unwrap(),
                                                     field.name.to_string()
+                                                )
+                                                .as_str()
+                                            );
+                                            content.push_str(
+                                                format!(
+                                                    "nodes.append(&mut get_children(&{}, current_depth));\n",
+                                                    field.name.to_string()
+                                                ).as_str()
+                                            );
+                                            content.push_str(
+                                                format!(
+                                                    "nodes.push(NestedNode {{
+                                                        node: {},
+                                                        depth: current_depth,
+                                                    }});\n",
+                                                    field.name.to_string()
                                                 ).as_str()
                                             );
                                         }
                                     }
+                                    content.push_str("\n");
                                 });
                                 content.push_str("nodes\n}");
                                 b.with_arm(
@@ -138,8 +180,14 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
 
                             b
                         })
-                        .finish(),
-                )
+                        .finish();
+
+                    content.push_str(match_.to_string().as_str());
+
+                    b.with_body(content);
+
+                    b
+                })
                 .finish(),
         )
         .finish()
@@ -283,6 +331,7 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
                            format!("SyntaxKind::{}", token.name.to_string()),
                        );
                    });
+                   b.with_arm("_".to_string(), "panic!(\"Unknown token\")".to_string());
                    b
                })
                .finish()
@@ -311,6 +360,10 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
                            value.to_string(),
                         );
                    });
+                   b.with_arm(
+                       "_".to_string(),
+                       "None".to_string(),
+                   );
                    b
                })
                .finish()
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 7eaca93f..4264c919 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -19,13 +19,14 @@ mod ast_node;
 mod parser;
 mod pg_query_utils;
 mod pg_query_utils_generated;
+mod pg_query_utils_generated_test;
 mod source_file;
 mod statement;
 mod syntax_error;
-mod syntax_kind;
-// mod syntax_kind_generated;
+// mod syntax_kind;
+mod syntax_kind_generated;
 mod syntax_node;
 
 pub use crate::parser::{Parse, Parser};
-pub use crate::syntax_kind::SyntaxKind;
+pub use crate::syntax_kind_generated::SyntaxKind;
 pub use crate::syntax_node::{SyntaxElement, SyntaxNode, SyntaxToken};
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index 3f9201c3..1902eacb 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -4,7 +4,7 @@ use pg_query::NodeEnum;
 
 use crate::ast_node::RawStmt;
 use crate::syntax_error::SyntaxError;
-use crate::syntax_kind::{SyntaxKind, SyntaxKindType};
+use crate::syntax_kind_generated::{SyntaxKind, SyntaxKindType};
 use crate::syntax_node::SyntaxNode;
 
 /// Main parser that controls the cst building process, and collects errors and statements
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index e6237e2b..a0797516 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -1,9 +1,9 @@
 //! Utilities for working with pg_query.rs
 //! This file is generated from the libg_query proto
-use pg_query::{NodeEnum, NodeRef};
+use pg_query::NodeEnum;
 
-pub fn get_location(node: NodeEnum) -> Option<i32> {
-    match &node {
+pub fn get_location(node: &NodeEnum) -> Option<i32> {
+    match node {
         NodeEnum::Alias(_) => None,
         NodeEnum::RangeVar(n) => Some(n.location),
         NodeEnum::TableFunc(n) => Some(n.location),
@@ -245,3826 +245,5317 @@ pub fn get_location(node: NodeEnum) -> Option<i32> {
     }
 }
 
-/// Returns the node and all its childrens, recursively
-pub fn get_nested_nodes(node: NodeEnum) -> Vec<NodeEnum> {
+#[derive(Debug, Clone)]
+pub struct NestedNode {
+    node: NodeEnum,
+    depth: i32,
+}
+
+/// Returns all children of the node, recursively
+pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
+    let current_depth = current_depth + 1;
     match &node {
         NodeEnum::Alias(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .colnames
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RangeVar(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
-                n.alias.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&alias, current_depth));
+            nodes.push(NestedNode {
+                node: alias,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::TableFunc(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .ns_uris
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .ns_names
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.docexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.rowexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let docexpr = n.docexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&docexpr, current_depth));
+            nodes.push(NestedNode {
+                node: docexpr,
+                depth: current_depth,
+            });
+
+            let rowexpr = n.rowexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&rowexpr, current_depth));
+            nodes.push(NestedNode {
+                node: rowexpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .colnames
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .coltypes
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .coltypmods
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .colcollations
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .colexprs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .coldefexprs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::Var(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::Param(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::Aggref(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .aggargtypes
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .aggdirectargs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .aggorder
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .aggdistinct
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.aggfilter.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let aggfilter = n.aggfilter.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&aggfilter, current_depth));
+            nodes.push(NestedNode {
+                node: aggfilter,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::GroupingFunc(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .refs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .cols
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::WindowFunc(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.aggfilter.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let aggfilter = n.aggfilter.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&aggfilter, current_depth));
+            nodes.push(NestedNode {
+                node: aggfilter,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::SubscriptingRef(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .refupperindexpr
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .reflowerindexpr
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.refexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.refassgnexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let refexpr = n.refexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&refexpr, current_depth));
+            nodes.push(NestedNode {
+                node: refexpr,
+                depth: current_depth,
+            });
+
+            let refassgnexpr = n.refassgnexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&refassgnexpr, current_depth));
+            nodes.push(NestedNode {
+                node: refassgnexpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::FuncExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::NamedArgExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::OpExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DistinctExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::NullIfExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ScalarArrayOpExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::BoolExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::SubLink(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.testexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let testexpr = n.testexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&testexpr, current_depth));
+            nodes.push(NestedNode {
+                node: testexpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .oper_name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.subselect.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let subselect = n.subselect.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&subselect, current_depth));
+            nodes.push(NestedNode {
+                node: subselect,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::SubPlan(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.testexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let testexpr = n.testexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&testexpr, current_depth));
+            nodes.push(NestedNode {
+                node: testexpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .param_ids
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .set_param
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .par_param
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlternativeSubPlan(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .subplans
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::FieldSelect(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::FieldStore(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .newvals
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .fieldnums
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RelabelType(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CoerceViaIo(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::ArrayCoerceExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.elemexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
+            let elemexpr = n.elemexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&elemexpr, current_depth));
+            nodes.push(NestedNode {
+                node: elemexpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::ConvertRowtypeExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CollateExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CaseExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.defresult.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let defresult = n.defresult.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&defresult, current_depth));
+            nodes.push(NestedNode {
+                node: defresult,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CaseWhen(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.result.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&expr, current_depth));
+            nodes.push(NestedNode {
+                node: expr,
+                depth: current_depth,
+            });
+
+            let result = n.result.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&result, current_depth));
+            nodes.push(NestedNode {
+                node: result,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CaseTestExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::ArrayExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .elements
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RowExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .colnames
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RowCompareExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .opnos
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .opfamilies
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .inputcollids
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .largs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .rargs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CoalesceExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::MinMaxExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::SqlvalueFunction(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::XmlExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .named_args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .arg_names
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::NullTest(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::BooleanTest(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CoerceToDomain(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CoerceToDomainValue(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::SetToDefault(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CurrentOfExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::NextValueExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::InferenceElem(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&expr, current_depth));
+            nodes.push(NestedNode {
+                node: expr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::TargetEntry(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&xpr, current_depth));
+            nodes.push(NestedNode {
+                node: xpr,
+                depth: current_depth,
+            });
+
+            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&expr, current_depth));
+            nodes.push(NestedNode {
+                node: expr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::RangeTblRef(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::JoinExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.larg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.rarg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let larg = n.larg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&larg, current_depth));
+            nodes.push(NestedNode {
+                node: larg,
+                depth: current_depth,
+            });
+
+            let rarg = n.rarg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&rarg, current_depth));
+            nodes.push(NestedNode {
+                node: rarg,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .using_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
-                n.join_using_alias.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.quals.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
-                n.alias.as_ref().unwrap().to_owned(),
-            )));
+
+            let join_using_alias = NodeEnum::Alias(n.join_using_alias.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&join_using_alias, current_depth));
+            nodes.push(NestedNode {
+                node: join_using_alias,
+                depth: current_depth,
+            });
+
+            let quals = n.quals.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&quals, current_depth));
+            nodes.push(NestedNode {
+                node: quals,
+                depth: current_depth,
+            });
+
+            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&alias, current_depth));
+            nodes.push(NestedNode {
+                node: alias,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::FromExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .fromlist
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.quals.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let quals = n.quals.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&quals, current_depth));
+            nodes.push(NestedNode {
+                node: quals,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::OnConflictExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .arbiter_elems
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.arbiter_where.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let arbiter_where = n.arbiter_where.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arbiter_where, current_depth));
+            nodes.push(NestedNode {
+                node: arbiter_where,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .on_conflict_set
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.on_conflict_where
-                    .as_ref()
-                    .unwrap()
-                    .to_owned()
-                    .node
-                    .unwrap(),
-            ));
+
+            let on_conflict_where = n
+                .on_conflict_where
+                .as_ref()
+                .unwrap()
+                .to_owned()
+                .node
+                .unwrap();
+            nodes.append(&mut get_children(&on_conflict_where, current_depth));
+            nodes.push(NestedNode {
+                node: on_conflict_where,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .excl_rel_tlist
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::IntoClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.rel.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let rel = NodeEnum::RangeVar(n.rel.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&rel, current_depth));
+            nodes.push(NestedNode {
+                node: rel,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .col_names
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.view_query.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let view_query = n.view_query.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&view_query, current_depth));
+            nodes.push(NestedNode {
+                node: view_query,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::MergeAction(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.qual.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&qual, current_depth));
+            nodes.push(NestedNode {
+                node: qual,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .update_colnos
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RawStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.stmt.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let stmt = n.stmt.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&stmt, current_depth));
+            nodes.push(NestedNode {
+                node: stmt,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::Query(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.utility_stmt.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let utility_stmt = n.utility_stmt.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&utility_stmt, current_depth));
+            nodes.push(NestedNode {
+                node: utility_stmt,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .cte_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .rtable
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::FromExpr(
-                n.jointree.as_ref().unwrap().to_owned(),
-            )));
+
+            let jointree = NodeEnum::FromExpr(n.jointree.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&jointree, current_depth));
+            nodes.push(NestedNode {
+                node: jointree,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .merge_action_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::OnConflictExpr(
-                n.on_conflict.as_ref().unwrap().to_owned(),
-            )));
+
+            let on_conflict = NodeEnum::OnConflictExpr(n.on_conflict.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&on_conflict, current_depth));
+            nodes.push(NestedNode {
+                node: on_conflict,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .returning_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .group_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .grouping_sets
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.having_qual.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let having_qual = n.having_qual.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&having_qual, current_depth));
+            nodes.push(NestedNode {
+                node: having_qual,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .window_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .distinct_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .sort_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.limit_offset.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.limit_count.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let limit_offset = n.limit_offset.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&limit_offset, current_depth));
+            nodes.push(NestedNode {
+                node: limit_offset,
+                depth: current_depth,
+            });
+
+            let limit_count = n.limit_count.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&limit_count, current_depth));
+            nodes.push(NestedNode {
+                node: limit_count,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .row_marks
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.set_operations.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let set_operations = n.set_operations.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&set_operations, current_depth));
+            nodes.push(NestedNode {
+                node: set_operations,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .constraint_deps
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .with_check_options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::InsertStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .cols
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.select_stmt.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::OnConflictClause(
-                n.on_conflict_clause.as_ref().unwrap().to_owned(),
-            )));
+
+            let select_stmt = n.select_stmt.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&select_stmt, current_depth));
+            nodes.push(NestedNode {
+                node: select_stmt,
+                depth: current_depth,
+            });
+
+            let on_conflict_clause =
+                NodeEnum::OnConflictClause(n.on_conflict_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&on_conflict_clause, current_depth));
+            nodes.push(NestedNode {
+                node: on_conflict_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .returning_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
-                n.with_clause.as_ref().unwrap().to_owned(),
-            )));
+
+            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&with_clause, current_depth));
+            nodes.push(NestedNode {
+                node: with_clause,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::DeleteStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .using_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .returning_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
-                n.with_clause.as_ref().unwrap().to_owned(),
-            )));
+
+            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&with_clause, current_depth));
+            nodes.push(NestedNode {
+                node: with_clause,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::UpdateStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .from_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .returning_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
-                n.with_clause.as_ref().unwrap().to_owned(),
-            )));
+
+            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&with_clause, current_depth));
+            nodes.push(NestedNode {
+                node: with_clause,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::MergeStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.source_relation.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.join_condition.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
+            let source_relation = n.source_relation.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&source_relation, current_depth));
+            nodes.push(NestedNode {
+                node: source_relation,
+                depth: current_depth,
+            });
+
+            let join_condition = n.join_condition.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&join_condition, current_depth));
+            nodes.push(NestedNode {
+                node: join_condition,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .merge_when_clauses
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
-                n.with_clause.as_ref().unwrap().to_owned(),
-            )));
+
+            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&with_clause, current_depth));
+            nodes.push(NestedNode {
+                node: with_clause,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::SelectStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .distinct_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::IntoClause(
-                n.into_clause.as_ref().unwrap().to_owned(),
-            )));
+
+            let into_clause = NodeEnum::IntoClause(n.into_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&into_clause, current_depth));
+            nodes.push(NestedNode {
+                node: into_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .from_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .group_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.having_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let having_clause = n.having_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&having_clause, current_depth));
+            nodes.push(NestedNode {
+                node: having_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .window_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .values_lists
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .sort_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.limit_offset.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.limit_count.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let limit_offset = n.limit_offset.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&limit_offset, current_depth));
+            nodes.push(NestedNode {
+                node: limit_offset,
+                depth: current_depth,
+            });
+
+            let limit_count = n.limit_count.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&limit_count, current_depth));
+            nodes.push(NestedNode {
+                node: limit_count,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .locking_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::WithClause(
-                n.with_clause.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::SelectStmt(
-                n.larg.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::SelectStmt(
-                n.rarg.as_ref().unwrap().to_owned(),
-            )));
+
+            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&with_clause, current_depth));
+            nodes.push(NestedNode {
+                node: with_clause,
+                depth: current_depth,
+            });
+
+            let larg = NodeEnum::SelectStmt(n.larg.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&larg, current_depth));
+            nodes.push(NestedNode {
+                node: larg,
+                depth: current_depth,
+            });
+
+            let rarg = NodeEnum::SelectStmt(n.rarg.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&rarg, current_depth));
+            nodes.push(NestedNode {
+                node: rarg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::ReturnStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.returnval.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let returnval = n.returnval.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&returnval, current_depth));
+            nodes.push(NestedNode {
+                node: returnval,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::PlassignStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .indirection
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::SelectStmt(
-                n.val.as_ref().unwrap().to_owned(),
-            )));
+
+            let val = NodeEnum::SelectStmt(n.val.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&val, current_depth));
+            nodes.push(NestedNode {
+                node: val,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterTableStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .cmds
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterTableCmd(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.newowner.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.def.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let newowner = NodeEnum::RoleSpec(n.newowner.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&newowner, current_depth));
+            nodes.push(NestedNode {
+                node: newowner,
+                depth: current_depth,
+            });
+
+            let def = n.def.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&def, current_depth));
+            nodes.push(NestedNode {
+                node: def,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterDomainStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.def.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let def = n.def.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&def, current_depth));
+            nodes.push(NestedNode {
+                node: def,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::SetOperationStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.larg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.rarg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let larg = n.larg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&larg, current_depth));
+            nodes.push(NestedNode {
+                node: larg,
+                depth: current_depth,
+            });
+
+            let rarg = n.rarg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&rarg, current_depth));
+            nodes.push(NestedNode {
+                node: rarg,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .col_types
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .col_typmods
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .col_collations
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .group_clauses
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::GrantStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .objects
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .privileges
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .grantees
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.grantor.as_ref().unwrap().to_owned(),
-            )));
+
+            let grantor = NodeEnum::RoleSpec(n.grantor.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&grantor, current_depth));
+            nodes.push(NestedNode {
+                node: grantor,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::GrantRoleStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .granted_roles
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .grantee_roles
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.grantor.as_ref().unwrap().to_owned(),
-            )));
+
+            let grantor = NodeEnum::RoleSpec(n.grantor.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&grantor, current_depth));
+            nodes.push(NestedNode {
+                node: grantor,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterDefaultPrivilegesStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::GrantStmt(
-                n.action.as_ref().unwrap().to_owned(),
-            )));
+
+            let action = NodeEnum::GrantStmt(n.action.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&action, current_depth));
+            nodes.push(NestedNode {
+                node: action,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::ClosePortalStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::ClusterStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .params
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CopyStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.query.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
+            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&query, current_depth));
+            nodes.push(NestedNode {
+                node: query,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .attlist
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreateStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .table_elts
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .inh_relations
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::PartitionBoundSpec(
-                n.partbound.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::PartitionSpec(
-                n.partspec.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.of_typename.as_ref().unwrap().to_owned(),
-            )));
+
+            let partbound = NodeEnum::PartitionBoundSpec(n.partbound.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&partbound, current_depth));
+            nodes.push(NestedNode {
+                node: partbound,
+                depth: current_depth,
+            });
+
+            let partspec = NodeEnum::PartitionSpec(n.partspec.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&partspec, current_depth));
+            nodes.push(NestedNode {
+                node: partspec,
+                depth: current_depth,
+            });
+
+            let of_typename = NodeEnum::TypeName(n.of_typename.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&of_typename, current_depth));
+            nodes.push(NestedNode {
+                node: of_typename,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .constraints
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DefineStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .defnames
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .definition
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DropStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .objects
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::TruncateStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .relations
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CommentStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.object.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&object, current_depth));
+            nodes.push(NestedNode {
+                node: object,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::FetchStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::IndexStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .index_params
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .index_including_params
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .exclude_op_names
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateFunctionStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .funcname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .parameters
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.return_type.as_ref().unwrap().to_owned(),
-            )));
+
+            let return_type = NodeEnum::TypeName(n.return_type.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&return_type, current_depth));
+            nodes.push(NestedNode {
+                node: return_type,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.sql_body.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let sql_body = n.sql_body.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&sql_body, current_depth));
+            nodes.push(NestedNode {
+                node: sql_body,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterFunctionStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
-                n.func.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let func = NodeEnum::ObjectWithArgs(n.func.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&func, current_depth));
+            nodes.push(NestedNode {
+                node: func,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .actions
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DoStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RenameStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.object.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
+            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&object, current_depth));
+            nodes.push(NestedNode {
+                node: object,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::RuleStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .actions
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::NotifyStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::ListenStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::UnlistenStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::TransactionStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ViewStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.view.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let view = NodeEnum::RangeVar(n.view.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&view, current_depth));
+            nodes.push(NestedNode {
+                node: view,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .aliases
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.query.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&query, current_depth));
+            nodes.push(NestedNode {
+                node: query,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::LoadStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::CreateDomainStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .domainname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.type_name.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::CollateClause(
-                n.coll_clause.as_ref().unwrap().to_owned(),
-            )));
+
+            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&type_name, current_depth));
+            nodes.push(NestedNode {
+                node: type_name,
+                depth: current_depth,
+            });
+
+            let coll_clause = NodeEnum::CollateClause(n.coll_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&coll_clause, current_depth));
+            nodes.push(NestedNode {
+                node: coll_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .constraints
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreatedbStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DropdbStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::VacuumStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .rels
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ExplainStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.query.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&query, current_depth));
+            nodes.push(NestedNode {
+                node: query,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateTableAsStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.query.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::IntoClause(
-                n.into.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&query, current_depth));
+            nodes.push(NestedNode {
+                node: query,
+                depth: current_depth,
+            });
+
+            let into = NodeEnum::IntoClause(n.into.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&into, current_depth));
+            nodes.push(NestedNode {
+                node: into,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreateSeqStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.sequence.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let sequence = NodeEnum::RangeVar(n.sequence.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&sequence, current_depth));
+            nodes.push(NestedNode {
+                node: sequence,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterSeqStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.sequence.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let sequence = NodeEnum::RangeVar(n.sequence.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&sequence, current_depth));
+            nodes.push(NestedNode {
+                node: sequence,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::VariableSetStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::VariableShowStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::DiscardStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::CreateTrigStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .funcname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .columns
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.when_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let when_clause = n.when_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&when_clause, current_depth));
+            nodes.push(NestedNode {
+                node: when_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .transition_rels
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.constrrel.as_ref().unwrap().to_owned(),
-            )));
+
+            let constrrel = NodeEnum::RangeVar(n.constrrel.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&constrrel, current_depth));
+            nodes.push(NestedNode {
+                node: constrrel,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreatePlangStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .plhandler
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .plinline
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .plvalidator
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateRoleStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterRoleStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.role.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let role = NodeEnum::RoleSpec(n.role.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&role, current_depth));
+            nodes.push(NestedNode {
+                node: role,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DropRoleStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::LockStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .relations
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ConstraintsSetStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .constraints
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ReindexStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .params
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CheckPointStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes
         }
         NodeEnum::CreateSchemaStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.authrole.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let authrole = NodeEnum::RoleSpec(n.authrole.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&authrole, current_depth));
+            nodes.push(NestedNode {
+                node: authrole,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .schema_elts
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterDatabaseStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterDatabaseRefreshCollStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::AlterDatabaseSetStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::VariableSetStmt(
-                n.setstmt.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&setstmt, current_depth));
+            nodes.push(NestedNode {
+                node: setstmt,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterRoleSetStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.role.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::VariableSetStmt(
-                n.setstmt.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let role = NodeEnum::RoleSpec(n.role.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&role, current_depth));
+            nodes.push(NestedNode {
+                node: role,
+                depth: current_depth,
+            });
+
+            let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&setstmt, current_depth));
+            nodes.push(NestedNode {
+                node: setstmt,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreateConversionStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .conversion_name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .func_name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateCastStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.sourcetype.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.targettype.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
-                n.func.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let sourcetype = NodeEnum::TypeName(n.sourcetype.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&sourcetype, current_depth));
+            nodes.push(NestedNode {
+                node: sourcetype,
+                depth: current_depth,
+            });
+
+            let targettype = NodeEnum::TypeName(n.targettype.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&targettype, current_depth));
+            nodes.push(NestedNode {
+                node: targettype,
+                depth: current_depth,
+            });
+
+            let func = NodeEnum::ObjectWithArgs(n.func.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&func, current_depth));
+            nodes.push(NestedNode {
+                node: func,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreateOpClassStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .opclassname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .opfamilyname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.datatype.as_ref().unwrap().to_owned(),
-            )));
+
+            let datatype = NodeEnum::TypeName(n.datatype.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&datatype, current_depth));
+            nodes.push(NestedNode {
+                node: datatype,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateOpFamilyStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .opfamilyname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterOpFamilyStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .opfamilyname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::PrepareStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .argtypes
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.query.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&query, current_depth));
+            nodes.push(NestedNode {
+                node: query,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::ExecuteStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .params
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DeallocateStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::DeclareCursorStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.query.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&query, current_depth));
+            nodes.push(NestedNode {
+                node: query,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreateTableSpaceStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.owner.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let owner = NodeEnum::RoleSpec(n.owner.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&owner, current_depth));
+            nodes.push(NestedNode {
+                node: owner,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DropTableSpaceStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::AlterObjectDependsStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.object.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::String(
-                n.extname.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
+            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&object, current_depth));
+            nodes.push(NestedNode {
+                node: object,
+                depth: current_depth,
+            });
+
+            let extname = NodeEnum::String(n.extname.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&extname, current_depth));
+            nodes.push(NestedNode {
+                node: extname,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterObjectSchemaStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.object.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
+            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&object, current_depth));
+            nodes.push(NestedNode {
+                node: object,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterOwnerStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.object.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.newowner.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
+            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&object, current_depth));
+            nodes.push(NestedNode {
+                node: object,
+                depth: current_depth,
+            });
+
+            let newowner = NodeEnum::RoleSpec(n.newowner.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&newowner, current_depth));
+            nodes.push(NestedNode {
+                node: newowner,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterOperatorStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
-                n.opername.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let opername = NodeEnum::ObjectWithArgs(n.opername.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&opername, current_depth));
+            nodes.push(NestedNode {
+                node: opername,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterTypeStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DropOwnedStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ReassignOwnedStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.newrole.as_ref().unwrap().to_owned(),
-            )));
+
+            let newrole = NodeEnum::RoleSpec(n.newrole.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&newrole, current_depth));
+            nodes.push(NestedNode {
+                node: newrole,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CompositeTypeStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.typevar.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let typevar = NodeEnum::RangeVar(n.typevar.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&typevar, current_depth));
+            nodes.push(NestedNode {
+                node: typevar,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .coldeflist
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateEnumStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .vals
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateRangeStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .params
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterEnumStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterTsdictionaryStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .dictname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterTsconfigurationStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .cfgname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .tokentype
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .dicts
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateFdwStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .func_options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterFdwStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .func_options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateForeignServerStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterForeignServerStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateUserMappingStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.user.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&user, current_depth));
+            nodes.push(NestedNode {
+                node: user,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterUserMappingStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.user.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&user, current_depth));
+            nodes.push(NestedNode {
+                node: user,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DropUserMappingStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RoleSpec(
-                n.user.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&user, current_depth));
+            nodes.push(NestedNode {
+                node: user,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterTableSpaceOptionsStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterTableMoveAllStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::SecLabelStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.object.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&object, current_depth));
+            nodes.push(NestedNode {
+                node: object,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreateForeignTableStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::CreateStmt(
-                n.base_stmt.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let base_stmt = NodeEnum::CreateStmt(n.base_stmt.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&base_stmt, current_depth));
+            nodes.push(NestedNode {
+                node: base_stmt,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ImportForeignSchemaStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .table_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateExtensionStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterExtensionStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterExtensionContentsStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.object.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&object, current_depth));
+            nodes.push(NestedNode {
+                node: object,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreateEventTrigStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .whenclause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .funcname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterEventTrigStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::RefreshMatViewStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::ReplicaIdentityStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::AlterSystemStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::VariableSetStmt(
-                n.setstmt.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&setstmt, current_depth));
+            nodes.push(NestedNode {
+                node: setstmt,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreatePolicyStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.table.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let table = NodeEnum::RangeVar(n.table.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&table, current_depth));
+            nodes.push(NestedNode {
+                node: table,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.qual.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.with_check.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&qual, current_depth));
+            nodes.push(NestedNode {
+                node: qual,
+                depth: current_depth,
+            });
+
+            let with_check = n.with_check.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&with_check, current_depth));
+            nodes.push(NestedNode {
+                node: with_check,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AlterPolicyStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.table.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let table = NodeEnum::RangeVar(n.table.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&table, current_depth));
+            nodes.push(NestedNode {
+                node: table,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.qual.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.with_check.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&qual, current_depth));
+            nodes.push(NestedNode {
+                node: qual,
+                depth: current_depth,
+            });
+
+            let with_check = n.with_check.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&with_check, current_depth));
+            nodes.push(NestedNode {
+                node: with_check,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreateTransformStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.type_name.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
-                n.fromsql.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
-                n.tosql.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&type_name, current_depth));
+            nodes.push(NestedNode {
+                node: type_name,
+                depth: current_depth,
+            });
+
+            let fromsql = NodeEnum::ObjectWithArgs(n.fromsql.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&fromsql, current_depth));
+            nodes.push(NestedNode {
+                node: fromsql,
+                depth: current_depth,
+            });
+
+            let tosql = NodeEnum::ObjectWithArgs(n.tosql.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&tosql, current_depth));
+            nodes.push(NestedNode {
+                node: tosql,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CreateAmStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .handler_name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreatePublicationStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .pubobjects
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterPublicationStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .pubobjects
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateSubscriptionStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .publication
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterSubscriptionStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .publication
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DropSubscriptionStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::CreateStatsStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .defnames
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .stat_types
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .exprs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .relations
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterCollationStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .collname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CallStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::FuncCall(
-                n.funccall.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::FuncExpr(
-                n.funcexpr.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let funccall = NodeEnum::FuncCall(n.funccall.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&funccall, current_depth));
+            nodes.push(NestedNode {
+                node: funccall,
+                depth: current_depth,
+            });
+
+            let funcexpr = NodeEnum::FuncExpr(n.funcexpr.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&funcexpr, current_depth));
+            nodes.push(NestedNode {
+                node: funcexpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .outargs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AlterStatsStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .defnames
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .name
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.lexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.rexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let lexpr = n.lexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&lexpr, current_depth));
+            nodes.push(NestedNode {
+                node: lexpr,
+                depth: current_depth,
+            });
+
+            let rexpr = n.rexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&rexpr, current_depth));
+            nodes.push(NestedNode {
+                node: rexpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::ColumnRef(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .fields
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ParamRef(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::FuncCall(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .funcname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .agg_order
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.agg_filter.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::WindowDef(
-                n.over.as_ref().unwrap().to_owned(),
-            )));
+
+            let agg_filter = n.agg_filter.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&agg_filter, current_depth));
+            nodes.push(NestedNode {
+                node: agg_filter,
+                depth: current_depth,
+            });
+
+            let over = NodeEnum::WindowDef(n.over.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&over, current_depth));
+            nodes.push(NestedNode {
+                node: over,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AStar(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes
         }
         NodeEnum::AIndices(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.lidx.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.uidx.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let lidx = n.lidx.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&lidx, current_depth));
+            nodes.push(NestedNode {
+                node: lidx,
+                depth: current_depth,
+            });
+
+            let uidx = n.uidx.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&uidx, current_depth));
+            nodes.push(NestedNode {
+                node: uidx,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::AIndirection(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .indirection
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AArrayExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .elements
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ResTarget(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .indirection
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.val.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let val = n.val.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&val, current_depth));
+            nodes.push(NestedNode {
+                node: val,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::MultiAssignRef(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.source.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let source = n.source.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&source, current_depth));
+            nodes.push(NestedNode {
+                node: source,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::TypeCast(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.type_name.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
+            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&type_name, current_depth));
+            nodes.push(NestedNode {
+                node: type_name,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CollateClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .collname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::SortBy(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.node.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let node = n.node.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&node, current_depth));
+            nodes.push(NestedNode {
+                node: node,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .use_op
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::WindowDef(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .partition_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .order_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.start_offset.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.end_offset.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let start_offset = n.start_offset.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&start_offset, current_depth));
+            nodes.push(NestedNode {
+                node: start_offset,
+                depth: current_depth,
+            });
+
+            let end_offset = n.end_offset.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&end_offset, current_depth));
+            nodes.push(NestedNode {
+                node: end_offset,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::RangeSubselect(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.subquery.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
-                n.alias.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let subquery = n.subquery.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&subquery, current_depth));
+            nodes.push(NestedNode {
+                node: subquery,
+                depth: current_depth,
+            });
+
+            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&alias, current_depth));
+            nodes.push(NestedNode {
+                node: alias,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::RangeFunction(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .functions
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
-                n.alias.as_ref().unwrap().to_owned(),
-            )));
+
+            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&alias, current_depth));
+            nodes.push(NestedNode {
+                node: alias,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .coldeflist
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RangeTableSample(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.relation.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = n.relation.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .method
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.repeatable.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let repeatable = n.repeatable.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&repeatable, current_depth));
+            nodes.push(NestedNode {
+                node: repeatable,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::RangeTableFunc(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.docexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.rowexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let docexpr = n.docexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&docexpr, current_depth));
+            nodes.push(NestedNode {
+                node: docexpr,
+                depth: current_depth,
+            });
+
+            let rowexpr = n.rowexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&rowexpr, current_depth));
+            nodes.push(NestedNode {
+                node: rowexpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .namespaces
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .columns
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
-                n.alias.as_ref().unwrap().to_owned(),
-            )));
+
+            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&alias, current_depth));
+            nodes.push(NestedNode {
+                node: alias,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::RangeTableFuncCol(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.type_name.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.colexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.coldefexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&type_name, current_depth));
+            nodes.push(NestedNode {
+                node: type_name,
+                depth: current_depth,
+            });
+
+            let colexpr = n.colexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&colexpr, current_depth));
+            nodes.push(NestedNode {
+                node: colexpr,
+                depth: current_depth,
+            });
+
+            let coldefexpr = n.coldefexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&coldefexpr, current_depth));
+            nodes.push(NestedNode {
+                node: coldefexpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::TypeName(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .names
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .typmods
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .array_bounds
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ColumnDef(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.type_name.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.raw_default.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.cooked_default.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.identity_sequence.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::CollateClause(
-                n.coll_clause.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&type_name, current_depth));
+            nodes.push(NestedNode {
+                node: type_name,
+                depth: current_depth,
+            });
+
+            let raw_default = n.raw_default.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&raw_default, current_depth));
+            nodes.push(NestedNode {
+                node: raw_default,
+                depth: current_depth,
+            });
+
+            let cooked_default = n.cooked_default.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&cooked_default, current_depth));
+            nodes.push(NestedNode {
+                node: cooked_default,
+                depth: current_depth,
+            });
+
+            let identity_sequence =
+                NodeEnum::RangeVar(n.identity_sequence.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&identity_sequence, current_depth));
+            nodes.push(NestedNode {
+                node: identity_sequence,
+                depth: current_depth,
+            });
+
+            let coll_clause = NodeEnum::CollateClause(n.coll_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&coll_clause, current_depth));
+            nodes.push(NestedNode {
+                node: coll_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .constraints
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .fdwoptions
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::IndexElem(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&expr, current_depth));
+            nodes.push(NestedNode {
+                node: expr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .collation
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .opclass
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .opclassopts
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::StatsElem(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&expr, current_depth));
+            nodes.push(NestedNode {
+                node: expr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::Constraint(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.raw_expr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let raw_expr = n.raw_expr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&raw_expr, current_depth));
+            nodes.push(NestedNode {
+                node: raw_expr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .keys
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .including
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .exclusions
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.pktable.as_ref().unwrap().to_owned(),
-            )));
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
+            let pktable = NodeEnum::RangeVar(n.pktable.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&pktable, current_depth));
+            nodes.push(NestedNode {
+                node: pktable,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .fk_attrs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .pk_attrs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .fk_del_set_cols
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .old_conpfeqop
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::DefElem(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.arg.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&arg, current_depth));
+            nodes.push(NestedNode {
+                node: arg,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::RangeTblEntry(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::TableSampleClause(
-                n.tablesample.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::Query(
-                n.subquery.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let tablesample =
+                NodeEnum::TableSampleClause(n.tablesample.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&tablesample, current_depth));
+            nodes.push(NestedNode {
+                node: tablesample,
+                depth: current_depth,
+            });
+
+            let subquery = NodeEnum::Query(n.subquery.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&subquery, current_depth));
+            nodes.push(NestedNode {
+                node: subquery,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .joinaliasvars
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .joinleftcols
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .joinrightcols
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
-                n.join_using_alias.as_ref().unwrap().to_owned(),
-            )));
+
+            let join_using_alias = NodeEnum::Alias(n.join_using_alias.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&join_using_alias, current_depth));
+            nodes.push(NestedNode {
+                node: join_using_alias,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .functions
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::TableFunc(
-                n.tablefunc.as_ref().unwrap().to_owned(),
-            )));
+
+            let tablefunc = NodeEnum::TableFunc(n.tablefunc.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&tablefunc, current_depth));
+            nodes.push(NestedNode {
+                node: tablefunc,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .values_lists
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .coltypes
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .coltypmods
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .colcollations
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
-                n.alias.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::Alias(
-                n.eref.as_ref().unwrap().to_owned(),
-            )));
+
+            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&alias, current_depth));
+            nodes.push(NestedNode {
+                node: alias,
+                depth: current_depth,
+            });
+
+            let eref = NodeEnum::Alias(n.eref.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&eref, current_depth));
+            nodes.push(NestedNode {
+                node: eref,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .security_quals
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RangeTblFunction(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.funcexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let funcexpr = n.funcexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&funcexpr, current_depth));
+            nodes.push(NestedNode {
+                node: funcexpr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .funccolnames
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .funccoltypes
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .funccoltypmods
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .funccolcollations
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::TableSampleClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.repeatable.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let repeatable = n.repeatable.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&repeatable, current_depth));
+            nodes.push(NestedNode {
+                node: repeatable,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::WithCheckOption(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.qual.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&qual, current_depth));
+            nodes.push(NestedNode {
+                node: qual,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::SortGroupClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::GroupingSet(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .content
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::WindowClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .partition_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .order_clause
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.start_offset.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.end_offset.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let start_offset = n.start_offset.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&start_offset, current_depth));
+            nodes.push(NestedNode {
+                node: start_offset,
+                depth: current_depth,
+            });
+
+            let end_offset = n.end_offset.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&end_offset, current_depth));
+            nodes.push(NestedNode {
+                node: end_offset,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .run_condition
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::ObjectWithArgs(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .objname
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .objargs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .objfuncargs
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AccessPriv(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .cols
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CreateOpClassItem(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::ObjectWithArgs(
-                n.name.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let name = NodeEnum::ObjectWithArgs(n.name.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&name, current_depth));
+            nodes.push(NestedNode {
+                node: name,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .order_family
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .class_args
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.storedtype.as_ref().unwrap().to_owned(),
-            )));
+
+            let storedtype = NodeEnum::TypeName(n.storedtype.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&storedtype, current_depth));
+            nodes.push(NestedNode {
+                node: storedtype,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::TableLikeClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::FunctionParameter(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.arg_type.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.defexpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let arg_type = NodeEnum::TypeName(n.arg_type.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&arg_type, current_depth));
+            nodes.push(NestedNode {
+                node: arg_type,
+                depth: current_depth,
+            });
+
+            let defexpr = n.defexpr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&defexpr, current_depth));
+            nodes.push(NestedNode {
+                node: defexpr,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::LockingClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .locked_rels
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RowMarkClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::XmlSerialize(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::TypeName(
-                n.type_name.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&expr, current_depth));
+            nodes.push(NestedNode {
+                node: expr,
+                depth: current_depth,
+            });
+
+            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&type_name, current_depth));
+            nodes.push(NestedNode {
+                node: type_name,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::WithClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .ctes
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::InferClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .index_elems
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::OnConflictClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::InferClause(
-                n.infer.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let infer = NodeEnum::InferClause(n.infer.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&infer, current_depth));
+            nodes.push(NestedNode {
+                node: infer,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CtesearchClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .search_col_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::CtecycleClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .cycle_col_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.cycle_mark_value
-                    .as_ref()
-                    .unwrap()
-                    .to_owned()
-                    .node
-                    .unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(
-                n.cycle_mark_default
-                    .as_ref()
-                    .unwrap()
-                    .to_owned()
-                    .node
-                    .unwrap(),
-            ));
+
+            let cycle_mark_value = n
+                .cycle_mark_value
+                .as_ref()
+                .unwrap()
+                .to_owned()
+                .node
+                .unwrap();
+            nodes.append(&mut get_children(&cycle_mark_value, current_depth));
+            nodes.push(NestedNode {
+                node: cycle_mark_value,
+                depth: current_depth,
+            });
+
+            let cycle_mark_default = n
+                .cycle_mark_default
+                .as_ref()
+                .unwrap()
+                .to_owned()
+                .node
+                .unwrap();
+            nodes.append(&mut get_children(&cycle_mark_default, current_depth));
+            nodes.push(NestedNode {
+                node: cycle_mark_default,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::CommonTableExpr(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .aliascolnames
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
-            nodes.append(&mut get_nested_nodes(
-                n.ctequery.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes.append(&mut get_nested_nodes(NodeEnum::CtesearchClause(
-                n.search_clause.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::CtecycleClause(
-                n.cycle_clause.as_ref().unwrap().to_owned(),
-            )));
+
+            let ctequery = n.ctequery.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&ctequery, current_depth));
+            nodes.push(NestedNode {
+                node: ctequery,
+                depth: current_depth,
+            });
+
+            let search_clause =
+                NodeEnum::CtesearchClause(n.search_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&search_clause, current_depth));
+            nodes.push(NestedNode {
+                node: search_clause,
+                depth: current_depth,
+            });
+
+            let cycle_clause =
+                NodeEnum::CtecycleClause(n.cycle_clause.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&cycle_clause, current_depth));
+            nodes.push(NestedNode {
+                node: cycle_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .ctecolnames
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .ctecoltypes
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .ctecoltypmods
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .ctecolcollations
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::MergeWhenClause(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.condition.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let condition = n.condition.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&condition, current_depth));
+            nodes.push(NestedNode {
+                node: condition,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .values
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::RoleSpec(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::TriggerTransition(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::PartitionElem(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.expr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&expr, current_depth));
+            nodes.push(NestedNode {
+                node: expr,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .collation
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .opclass
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::PartitionSpec(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .part_params
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::PartitionBoundSpec(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes.append(
                 &mut n
                     .listdatums
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .lowerdatums
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes.append(
                 &mut n
                     .upperdatums
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::PartitionRangeDatum(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(
-                n.value.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let value = n.value.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&value, current_depth));
+            nodes.push(NestedNode {
+                node: value,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::PartitionCmd(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.name.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(NodeEnum::PartitionBoundSpec(
-                n.bound.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let name = NodeEnum::RangeVar(n.name.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&name, current_depth));
+            nodes.push(NestedNode {
+                node: name,
+                depth: current_depth,
+            });
+
+            let bound = NodeEnum::PartitionBoundSpec(n.bound.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&bound, current_depth));
+            nodes.push(NestedNode {
+                node: bound,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::VacuumRelation(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .va_cols
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::PublicationObjSpec(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::PublicationTable(
-                n.pubtable.as_ref().unwrap().to_owned(),
-            )));
+            let mut nodes: Vec<NestedNode> = vec![];
+
+            let pubtable = NodeEnum::PublicationTable(n.pubtable.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&pubtable, current_depth));
+            nodes.push(NestedNode {
+                node: pubtable,
+                depth: current_depth,
+            });
+
             nodes
         }
         NodeEnum::PublicationTable(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_nested_nodes(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(&mut get_nested_nodes(
-                n.where_clause.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
+            let mut nodes: Vec<NestedNode> = vec![];
+            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+            nodes.append(&mut get_children(&relation, current_depth));
+            nodes.push(NestedNode {
+                node: relation,
+                depth: current_depth,
+            });
+
+            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+            nodes.append(&mut get_children(&where_clause, current_depth));
+            nodes.push(NestedNode {
+                node: where_clause,
+                depth: current_depth,
+            });
+
             nodes.append(
                 &mut n
                     .columns
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::InlineCodeBlock(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::CallContext(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::Integer(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::Float(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::Boolean(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::String(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::BitString(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
         NodeEnum::List(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::IntList(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::OidList(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
             nodes.append(
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_nested_nodes(x.node.as_ref().unwrap().to_owned()))
+                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
                     .collect(),
             );
+
             nodes
         }
         NodeEnum::AConst(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
+            let mut nodes: Vec<NestedNode> = vec![];
+
             nodes
         }
     }
diff --git a/crates/parser/src/pg_query_utils_generated_test.rs b/crates/parser/src/pg_query_utils_generated_test.rs
new file mode 100644
index 00000000..e07f2f4e
--- /dev/null
+++ b/crates/parser/src/pg_query_utils_generated_test.rs
@@ -0,0 +1,40 @@
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+    use std::fs;
+    use std::path::Path;
+
+    use crate::pg_query_utils_generated::get_children;
+
+    const VALID_STATEMENTS_PATH: &str = "test_data/statements/valid/";
+
+    #[test]
+    fn test_get_children() {
+        let input = "with t as (insert into contact (id) values ('id')) select * from t;";
+
+        let pg_query_root = match pg_query::parse(input) {
+            Ok(parsed) => {
+                parsed
+                    .protobuf
+                    .nodes()
+                    .iter()
+                    .for_each(|n| println!("{:?}", n));
+                Some(
+                    parsed
+                        .protobuf
+                        .nodes()
+                        .iter()
+                        .find(|n| n.1 == 1)
+                        .unwrap()
+                        .0
+                        .to_enum(),
+                )
+            }
+            Err(_) => None,
+        };
+
+        let result = get_children(&pg_query_root.unwrap(), 1);
+
+        result.iter().for_each(|n| println!("{:?}", n));
+    }
+}
diff --git a/crates/parser/src/source_file.rs b/crates/parser/src/source_file.rs
index 0a433966..16827eaf 100644
--- a/crates/parser/src/source_file.rs
+++ b/crates/parser/src/source_file.rs
@@ -1,6 +1,6 @@
 use logos::Logos;
 
-use crate::{parser::Parser, syntax_kind::SyntaxKind};
+use crate::{parser::Parser, syntax_kind_generated::SyntaxKind};
 
 /// A super simple lexer for sql files that splits the input into indivudual statements and
 /// comments.
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 272c96e8..31f2b854 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -3,8 +3,10 @@ use logos::Logos;
 use regex::Regex;
 
 use crate::{
-    parser::Parser, pg_query_utils::get_position_for_pg_query_node,
-    pg_query_utils_generated::get_location, syntax_kind::SyntaxKind,
+    parser::Parser,
+    pg_query_utils_generated::{get_children, get_location},
+    // pg_query_utils::{get_location, get_nested_nodes},
+    syntax_kind_generated::SyntaxKind,
 };
 
 /// A super simple lexer for sql statements.
@@ -136,102 +138,128 @@ impl Parser {
             }
         };
 
-        let parsed = pg_query::parse(text);
-        let proto;
-        let mut nodes;
-        let mut pg_query_nodes = match parsed {
-            Ok(parsed) => {
-                proto = parsed.protobuf;
-
-                nodes = proto.nodes();
-
-                nodes.sort_by(|a, b| {
-                    get_position_for_pg_query_node(&a.0).cmp(&get_position_for_pg_query_node(&b.0))
-                });
-
-                nodes.into_iter().peekable()
-            }
+        // Get root node with depth 1
+        // Since we are parsing only a single statement there can be only a single node at depth 1
+        let pg_query_root = match pg_query::parse(text) {
+            Ok(parsed) => Some(
+                parsed
+                    .protobuf
+                    .nodes()
+                    .iter()
+                    .find(|n| n.1 == 1)
+                    .unwrap()
+                    .0
+                    .to_enum(),
+            ),
             Err(e) => {
                 self.error(e.to_string(), range);
-                Vec::new().into_iter().peekable()
+                None
             }
         };
 
-        let mut lexer = StatementToken::lexer(&text);
-
-        // parse root node if no syntax errors
-        // TODO: find root node based on depth
-        if pg_query_nodes.peek().is_some() {
-            let (node, depth, _) = pg_query_nodes.next().unwrap();
-            self.stmt(node.to_enum(), range);
-            self.start_node_at(SyntaxKind::from_pg_query_node(&node), Some(depth));
-            // if there is only one node, there are no children, and we do not need to buffer the
-            // tokens. this happens for example with create or alter function statements.
-            self.set_checkpoint(pg_query_nodes.peek().is_none());
-        } else {
-            // fallback to generic node as root
-            self.start_node_at(SyntaxKind::Stmt, None);
-            self.set_checkpoint(true);
-        }
-
-        // FIXME: the lexer, for some reason, does not parse dollar quoted string
-        // so we check if the error is one
-        while let Some(token) = lexer.next() {
-            let t: Option<StatementToken> = match token {
-                Ok(token) => Some(token),
-                Err(_) => {
-                    if Regex::new("'([^']+)'|\\$(\\w)?\\$.*\\$(\\w)?\\$")
-                        .unwrap()
-                        .is_match_at(lexer.slice(), 0)
-                    {
-                        Some(StatementToken::Sconst)
-                    } else {
-                        None
-                    }
-                }
-            };
-
-            match t {
-                Some(token) => {
-                    let span = lexer.span();
-
-                    // consume pg_query nodes until there is none, or the node is outside of the current text span
-                    while let Some(node) = pg_query_nodes.peek() {
-                        let pos = get_position_for_pg_query_node(&node.0);
-                        if span.contains(&usize::try_from(pos).unwrap()) == false {
-                            break;
-                        } else {
-                            // node is within span
-                            let (node, depth, _) = pg_query_nodes.next().unwrap();
-                            self.start_node_at(SyntaxKind::from_pg_query_node(&node), Some(depth));
-                        }
-                    }
-
-                    // consume pg_query token if it is within the current text span
-                    let next_pg_query_token = pg_query_tokens.peek();
-                    if next_pg_query_token.is_some()
-                        && (span.contains(
-                            &usize::try_from(next_pg_query_token.unwrap().start).unwrap(),
-                        ) || span
-                            .contains(&usize::try_from(next_pg_query_token.unwrap().end).unwrap()))
-                    {
-                        // TODO: if within function declaration and current token is Sconst, its
-                        // the function body. it should be passed into parse_source_file.
-                        self.token(
-                            SyntaxKind::from_pg_query_token(&pg_query_tokens.next().unwrap()),
-                            lexer.slice(),
-                        );
-                    } else {
-                        // fallback to statement token
-                        self.token(token.syntax_kind(), lexer.slice());
-                    }
-                }
-                None => panic!("Unknown StatementToken: {:?}", lexer.slice()),
-            }
-        }
-
-        // close up nodes
-        self.close_checkpoint();
+        // let pg_query_children;
+        // if pg_query_root.is_some() {
+        //     let children = get_children(&pg_query_root.unwrap(), 1);
+        //     children.sort_by(|a, b| get_location(a).cmp(get_children(b)));
+        // } else {
+        //     pg_query_children = Vec::new().iter().peekable();
+        // };
+
+        //
+        //     // let mut pg_query_nodes = match parsed {
+        //     //     Ok(parsed) => {
+        //     //         proto = parsed.protobuf;
+        //     //
+        //     //         nodes = proto.nodes();
+        //     //
+        //     //         nodes.sort_by(|a, b| {
+        //     //             get_position_for_pg_query_node(&a.0).cmp(&get_position_for_pg_query_node(&b.0))
+        //     //         });
+        //     //
+        //     //         nodes.into_iter().peekable()
+        //     //     }
+        //     //     Err(e) => {
+        //     //         self.error(e.to_string(), range);
+        //     //         Vec::new().into_iter().peekable()
+        //     //     }
+        //     // };
+        //
+        //     TOD: return depth from get_children()
+        //
+        //     let mut lexer = StatementToken::lexer(&text);
+        //
+        //     // parse root node if no syntax errors
+        //     if pg_query_root.is_some() {
+        //         let root_node = pg_query_root.unwrap();
+        //         self.stmt(root_node, range);
+        //         self.start_node_at(SyntaxKind::new_from_pg_query_node(&root_node), Some(1));
+        //         // if there is only one node, there are no children, and we do not need to buffer the
+        //         // tokens. this happens for example with create or alter function statements.
+        //         self.set_checkpoint(pg_query_children.len() == 0);
+        //     } else {
+        //         // fallback to generic node as root
+        //         self.start_node_at(SyntaxKind::Stmt, None);
+        //         self.set_checkpoint(true);
+        //     }
+        //
+        //     // FIXME: the lexer, for some reason, does not parse dollar quoted string
+        //     // so we check if the error is one
+        //     while let Some(token) = lexer.next() {
+        //         let t: Option<StatementToken> = match token {
+        //             Ok(token) => Some(token),
+        //             Err(_) => {
+        //                 if Regex::new("'([^']+)'|\\$(\\w)?\\$.*\\$(\\w)?\\$")
+        //                     .unwrap()
+        //                     .is_match_at(lexer.slice(), 0)
+        //                 {
+        //                     Some(StatementToken::Sconst)
+        //                 } else {
+        //                     None
+        //                 }
+        //             }
+        //         };
+        //
+        //         match t {
+        //             Some(token) => {
+        //                 let span = lexer.span();
+        //
+        //                 // consume pg_query nodes until there is none, or the node is outside of the current text span
+        //                 while let Some(node) = pg_query_children.peek() {
+        //                     let pos = get_location(&node);
+        //                     if span.contains(&usize::try_from(pos.unwrap()).unwrap()) == false {
+        //                         break;
+        //                     } else {
+        //                         // node is within span
+        //                         // let (node, depth, _) = pg_query_children.next().unwrap();
+        //                         // self.start_node_at(SyntaxKind::from_pg_query_node(&node), Some(depth));
+        //                     }
+        //                 }
+        //
+        //                 // consume pg_query token if it is within the current text span
+        //                 let next_pg_query_token = pg_query_tokens.peek();
+        //                 if next_pg_query_token.is_some()
+        //                     && (span.contains(
+        //                         &usize::try_from(next_pg_query_token.unwrap().start).unwrap(),
+        //                     ) || span
+        //                         .contains(&usize::try_from(next_pg_query_token.unwrap().end).unwrap()))
+        //                 {
+        //                     // TODO: if within function declaration and current token is Sconst, its
+        //                     // the function body. it should be passed into parse_source_file.
+        //                     // self.token(
+        //                     //     SyntaxKind::from_pg_query_token(&pg_query_tokens.next().unwrap()),
+        //                     //     lexer.slice(),
+        //                     // );
+        //                 } else {
+        //                     // fallback to statement token
+        //                     self.token(token.syntax_kind(), lexer.slice());
+        //                 }
+        //             }
+        //             None => panic!("Unknown StatementToken: {:?}", lexer.slice()),
+        //         }
+        //     }
+        //
+        //     // close up nodes
+        //     self.close_checkpoint();
     }
 }
 
@@ -357,23 +385,4 @@ mod tests {
 
         assert_eq!(parsed.cst.text(), input);
     }
-
-    #[test]
-    fn test_cst() {
-        let input =
-            "with test as (insert into contact (id) values (1) returning *) select * from test";
-
-        pg_query::parse(input)
-            .unwrap()
-            .protobuf
-            .nodes()
-            .iter()
-            .for_each(|node| {
-                println!("####");
-                println!("{:?}", node);
-                println!("{:?}", get_location(node.0.to_enum()));
-            });
-
-        assert_eq!(1, 1);
-    }
 }
diff --git a/crates/parser/src/syntax_kind_generated.rs b/crates/parser/src/syntax_kind_generated.rs
index f4168cc4..58cc8494 100644
--- a/crates/parser/src/syntax_kind_generated.rs
+++ b/crates/parser/src/syntax_kind_generated.rs
@@ -68,12 +68,15 @@ pub enum SyntaxKind {
     FromExpr,
     OnConflictExpr,
     IntoClause,
+    MergeAction,
     RawStmt,
     Query,
     InsertStmt,
     DeleteStmt,
     UpdateStmt,
+    MergeStmt,
     SelectStmt,
+    ReturnStmt,
     PlassignStmt,
     AlterTableStmt,
     AlterTableCmd,
@@ -125,6 +128,7 @@ pub enum SyntaxKind {
     CheckPointStmt,
     CreateSchemaStmt,
     AlterDatabaseStmt,
+    AlterDatabaseRefreshCollStmt,
     AlterDatabaseSetStmt,
     AlterRoleSetStmt,
     CreateConversionStmt,
@@ -206,6 +210,7 @@ pub enum SyntaxKind {
     TypeName,
     ColumnDef,
     IndexElem,
+    StatsElem,
     Constraint,
     DefElem,
     RangeTblEntry,
@@ -229,6 +234,7 @@ pub enum SyntaxKind {
     CtesearchClause,
     CtecycleClause,
     CommonTableExpr,
+    MergeWhenClause,
     RoleSpec,
     TriggerTransition,
     PartitionElem,
@@ -237,10 +243,13 @@ pub enum SyntaxKind {
     PartitionRangeDatum,
     PartitionCmd,
     VacuumRelation,
+    PublicationObjSpec,
+    PublicationTable,
     InlineCodeBlock,
     CallContext,
     Integer,
     Float,
+    Boolean,
     String,
     BitString,
     List,
@@ -840,12 +849,15 @@ impl SyntaxKind {
             NodeEnum::FromExpr(_) => SyntaxKind::FromExpr,
             NodeEnum::OnConflictExpr(_) => SyntaxKind::OnConflictExpr,
             NodeEnum::IntoClause(_) => SyntaxKind::IntoClause,
+            NodeEnum::MergeAction(_) => SyntaxKind::MergeAction,
             NodeEnum::RawStmt(_) => SyntaxKind::RawStmt,
             NodeEnum::Query(_) => SyntaxKind::Query,
             NodeEnum::InsertStmt(_) => SyntaxKind::InsertStmt,
             NodeEnum::DeleteStmt(_) => SyntaxKind::DeleteStmt,
             NodeEnum::UpdateStmt(_) => SyntaxKind::UpdateStmt,
+            NodeEnum::MergeStmt(_) => SyntaxKind::MergeStmt,
             NodeEnum::SelectStmt(_) => SyntaxKind::SelectStmt,
+            NodeEnum::ReturnStmt(_) => SyntaxKind::ReturnStmt,
             NodeEnum::PlassignStmt(_) => SyntaxKind::PlassignStmt,
             NodeEnum::AlterTableStmt(_) => SyntaxKind::AlterTableStmt,
             NodeEnum::AlterTableCmd(_) => SyntaxKind::AlterTableCmd,
@@ -897,6 +909,7 @@ impl SyntaxKind {
             NodeEnum::CheckPointStmt(_) => SyntaxKind::CheckPointStmt,
             NodeEnum::CreateSchemaStmt(_) => SyntaxKind::CreateSchemaStmt,
             NodeEnum::AlterDatabaseStmt(_) => SyntaxKind::AlterDatabaseStmt,
+            NodeEnum::AlterDatabaseRefreshCollStmt(_) => SyntaxKind::AlterDatabaseRefreshCollStmt,
             NodeEnum::AlterDatabaseSetStmt(_) => SyntaxKind::AlterDatabaseSetStmt,
             NodeEnum::AlterRoleSetStmt(_) => SyntaxKind::AlterRoleSetStmt,
             NodeEnum::CreateConversionStmt(_) => SyntaxKind::CreateConversionStmt,
@@ -978,6 +991,7 @@ impl SyntaxKind {
             NodeEnum::TypeName(_) => SyntaxKind::TypeName,
             NodeEnum::ColumnDef(_) => SyntaxKind::ColumnDef,
             NodeEnum::IndexElem(_) => SyntaxKind::IndexElem,
+            NodeEnum::StatsElem(_) => SyntaxKind::StatsElem,
             NodeEnum::Constraint(_) => SyntaxKind::Constraint,
             NodeEnum::DefElem(_) => SyntaxKind::DefElem,
             NodeEnum::RangeTblEntry(_) => SyntaxKind::RangeTblEntry,
@@ -1001,6 +1015,7 @@ impl SyntaxKind {
             NodeEnum::CtesearchClause(_) => SyntaxKind::CtesearchClause,
             NodeEnum::CtecycleClause(_) => SyntaxKind::CtecycleClause,
             NodeEnum::CommonTableExpr(_) => SyntaxKind::CommonTableExpr,
+            NodeEnum::MergeWhenClause(_) => SyntaxKind::MergeWhenClause,
             NodeEnum::RoleSpec(_) => SyntaxKind::RoleSpec,
             NodeEnum::TriggerTransition(_) => SyntaxKind::TriggerTransition,
             NodeEnum::PartitionElem(_) => SyntaxKind::PartitionElem,
@@ -1009,10 +1024,13 @@ impl SyntaxKind {
             NodeEnum::PartitionRangeDatum(_) => SyntaxKind::PartitionRangeDatum,
             NodeEnum::PartitionCmd(_) => SyntaxKind::PartitionCmd,
             NodeEnum::VacuumRelation(_) => SyntaxKind::VacuumRelation,
+            NodeEnum::PublicationObjSpec(_) => SyntaxKind::PublicationObjSpec,
+            NodeEnum::PublicationTable(_) => SyntaxKind::PublicationTable,
             NodeEnum::InlineCodeBlock(_) => SyntaxKind::InlineCodeBlock,
             NodeEnum::CallContext(_) => SyntaxKind::CallContext,
             NodeEnum::Integer(_) => SyntaxKind::Integer,
             NodeEnum::Float(_) => SyntaxKind::Float,
+            NodeEnum::Boolean(_) => SyntaxKind::Boolean,
             NodeEnum::String(_) => SyntaxKind::String,
             NodeEnum::BitString(_) => SyntaxKind::BitString,
             NodeEnum::List(_) => SyntaxKind::List,
@@ -1533,6 +1551,7 @@ impl SyntaxKind {
             743 => SyntaxKind::ModePlpgsqlAssign2,
             744 => SyntaxKind::ModePlpgsqlAssign3,
             745 => SyntaxKind::Uminus,
+            _ => panic!("Unknown token"),
         }
     }
 
@@ -2047,6 +2066,7 @@ impl SyntaxKind {
             SyntaxKind::ModePlpgsqlAssign2 => Some(SyntaxKindType::Follow),
             SyntaxKind::ModePlpgsqlAssign3 => Some(SyntaxKindType::Follow),
             SyntaxKind::Uminus => Some(SyntaxKindType::Follow),
+            _ => None,
         }
     }
 }
diff --git a/crates/parser/src/syntax_node.rs b/crates/parser/src/syntax_node.rs
index b0f9389a..95a9c5b5 100644
--- a/crates/parser/src/syntax_node.rs
+++ b/crates/parser/src/syntax_node.rs
@@ -6,7 +6,7 @@
 //! The *real* implementation is in the (language-agnostic) `cstree` crate, this
 //! module just wraps its API.
 
-use crate::syntax_kind::SyntaxKind;
+use crate::syntax_kind_generated::SyntaxKind;
 
 pub type SyntaxNode = cstree::syntax::SyntaxNode<SyntaxKind>;
 pub type SyntaxToken = cstree::syntax::SyntaxToken<SyntaxKind>;
diff --git a/crates/sourcegen/src/lib.rs b/crates/sourcegen/src/lib.rs
index 9a60f4b5..f974fc41 100644
--- a/crates/sourcegen/src/lib.rs
+++ b/crates/sourcegen/src/lib.rs
@@ -11,6 +11,7 @@ mod implementation;
 mod imports;
 mod match_;
 mod source_file;
+mod struct_;
 
 pub use attribute::Attribute;
 pub use builder::Builder;
@@ -21,6 +22,7 @@ pub use implementation::Implementation;
 pub use imports::Imports;
 pub use match_::Match;
 pub use source_file::SourceFile;
+pub use struct_::Struct;
 
 #[cfg(test)]
 mod tests {
diff --git a/crates/sourcegen/src/struct_.rs b/crates/sourcegen/src/struct_.rs
new file mode 100644
index 00000000..d5376481
--- /dev/null
+++ b/crates/sourcegen/src/struct_.rs
@@ -0,0 +1,83 @@
+use crate::builder::Builder;
+
+#[derive(Debug, Clone)]
+pub struct StructField {
+    name: String,
+    type_: String,
+}
+
+/// A builder for a rust Struct
+#[derive(Debug, Clone)]
+pub struct Struct {
+    name: String,
+    fields: Vec<StructField>,
+    public: bool,
+}
+
+impl Builder for Struct {
+    fn finish(&mut self) -> String {
+        let mut result = String::new();
+        if self.public {
+            result.push_str("pub ");
+        }
+        result.push_str("struct ");
+        result.push_str(&self.name);
+        result.push_str(" {\n");
+        result.push_str(
+            &self
+                .fields
+                .iter()
+                .map(|field| {
+                    let mut result = String::new();
+                    result.push_str("    ");
+                    result.push_str(&field.name);
+                    result.push_str(": ");
+                    result.push_str(&field.type_);
+                    result.push_str(",\n");
+                    result
+                })
+                .collect::<Vec<String>>()
+                .join(""),
+        );
+        result.push_str("}\n");
+        result
+    }
+}
+
+impl Struct {
+    pub fn new(name: String) -> Self {
+        Struct {
+            name,
+            fields: Vec::new(),
+            public: false,
+        }
+    }
+
+    pub fn public(&mut self) -> &mut Self {
+        self.public = true;
+        self
+    }
+
+    pub fn with_field(&mut self, name: String, type_: String) -> &mut Self {
+        self.fields.push(StructField { name, type_ });
+        self
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use crate::{attribute::Attribute, builder::Builder};
+
+    #[test]
+    fn test_struct() {
+        assert_eq!(
+            Attribute::new("derive".into())
+                .with_argument("Debug".to_string(), None)
+                .with_argument("Copy".to_string(), Some("value".to_string()))
+                .finish(),
+            "#[derive(Debug, Copy = value)]\n"
+        )
+    }
+}

From 8711c6a2750dc2e252560f11b00a5da87d00fb61 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Thu, 3 Aug 2023 23:52:15 +0200
Subject: [PATCH 04/23] fix: get_children return nodes of repeated children,
 not only their children

---
 crates/parser/src/bin/generate.rs             |   46 +-
 crates/parser/src/pg_query_utils_generated.rs | 6792 ++++++++++++-----
 .../src/pg_query_utils_generated_test.rs      |   13 +-
 crates/sourcegen/src/struct_.rs               |    8 +
 4 files changed, 4881 insertions(+), 1978 deletions(-)

diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
index 293cfdb9..c0d04167 100644
--- a/crates/parser/src/bin/generate.rs
+++ b/crates/parser/src/bin/generate.rs
@@ -4,17 +4,6 @@ use sourcegen::{
 };
 use std::fs;
 
-// NodeEnum::Expr(_) => todo!(),
-// NodeEnum::SqlvalueFunction(_) => todo!(),
-// NodeEnum::CreatePlangStmt(_) => todo!(),
-// NodeEnum::AlterTsdictionaryStmt(_) => todo!(),
-// NodeEnum::AlterTsconfigurationStmt(_) => todo!(),
-// NodeEnum::Null(_) => todo!(),
-
-const UNKNOWN_NODES: [&str; 0] = [
-    // ignore nodes not known to pg_query.rs
-];
-
 fn main() {
     let parser = ProtoParser::new("./proto/source.proto");
     let file = parser.parse();
@@ -78,12 +67,19 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
         .add_block(
             Struct::new("NestedNode".to_string())
             .public()
+            .with_attribute(
+                Attribute::new("derive".to_string())
+                .with_argument("Debug".to_string(), None)
+                .with_argument("Clone".to_string(), None)
+                .finish()
+            )
             .with_field("node".to_string(), "NodeEnum".to_string())
             .with_field("depth".to_string(), "i32".to_string())
-            .with_field("location".to_string(), "i32".to_string())
+            // .with_field("location".to_string(), "i32".to_string())
             .finish()
         )
         // TODO: 1) always use match or if .is_some() when unwrapping a node and ignore if none
+        // TODO: 1.2) parse AConst manually
         // TODO: 2) add location to NestedNode, and use it in get_children.
         // TODO:    to get location, first check if node has location field.
         // TODO:    if not, use the location of the parent.
@@ -92,6 +88,7 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
         // get_children, we can easily get the location of the actual node because we can just
         // fallback to the location of the immediate parent if the current node does not have a
         // location.
+        //
         .add_block(
             Function::new("get_children".to_string())
                 .public()
@@ -113,12 +110,18 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                     if field.field_type == FieldType::Node && field.repeated {
                                         content.push_str(
                                             format!(
-                                                "nodes.append(&mut n.{}.iter().flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth)).collect());\n",
+                                                "nodes.append(&mut n.{}.iter().flat_map(|x| {{
+                                                    let mut result = vec![];
+                                                    result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                                                    result.push(NestedNode {{ node: x.node.as_ref().unwrap().to_owned(), depth: current_depth }});
+                                                    result
+                                                }}).collect());\n",
                                                 field.name.to_string()
                                             ).as_str()
                                         );
                                     } else if field.field_type == FieldType::Node && field.is_one_of == false {
                                         if field.node_name == Some("Node".to_owned()) {
+                                            content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
                                             content.push_str(
                                                 format!(
                                                     "let {} = n.{}.as_ref().unwrap().to_owned().node.unwrap();\n",
@@ -142,7 +145,9 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                                     field.name.to_string()
                                                 ).as_str(),
                                             );
+                                            content.push_str("}\n");
                                         } else {
+                                            content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
                                             content.push_str(
                                                 format!(
                                                     "let {} = NodeEnum::{}(n.{}.as_ref().unwrap().to_owned());\n",
@@ -167,6 +172,7 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                                     field.name.to_string()
                                                 ).as_str()
                                             );
+                                            content.push_str("}\n");
                                         }
                                     }
                                     content.push_str("\n");
@@ -243,9 +249,7 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
             });
 
             f.nodes.iter().for_each(|node| {
-                if !UNKNOWN_NODES.contains(&node.name.as_str()) {
-                    b.with_value(node.name.to_string(), None);
-                }
+                b.with_value(node.name.to_string(), None);
             });
 
             f.tokens.iter().for_each(|token| {
@@ -301,12 +305,10 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
                 Match::new("node".to_string())
                 .with(|b| {
                     f.nodes.iter().for_each(|node| {
-                        if !UNKNOWN_NODES.contains(&node.name.as_str()) {
-                            b.with_arm(
-                                format!("NodeEnum::{}(_)", node.name.to_string()),
-                                format!("SyntaxKind::{}", node.name.to_string()),
-                            );
-                        }
+                        b.with_arm(
+                            format!("NodeEnum::{}(_)", node.name.to_string()),
+                            format!("SyntaxKind::{}", node.name.to_string()),
+                        );
                     });
                     b
                 })
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index a0797516..55f42906 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -262,7 +262,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .colnames
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -271,12 +279,14 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::RangeVar(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&alias, current_depth));
-            nodes.push(NestedNode {
-                node: alias,
-                depth: current_depth,
-            });
+            if n.alias.is_some() {
+                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&alias, current_depth));
+                nodes.push(NestedNode {
+                    node: alias,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -286,7 +296,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .ns_uris
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -294,29 +312,49 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .ns_names
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let docexpr = n.docexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&docexpr, current_depth));
-            nodes.push(NestedNode {
-                node: docexpr,
-                depth: current_depth,
-            });
+            if n.docexpr.is_some() {
+                let docexpr = n.docexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&docexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: docexpr,
+                    depth: current_depth,
+                });
+            }
 
-            let rowexpr = n.rowexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&rowexpr, current_depth));
-            nodes.push(NestedNode {
-                node: rowexpr,
-                depth: current_depth,
-            });
+            if n.rowexpr.is_some() {
+                let rowexpr = n.rowexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&rowexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: rowexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .colnames
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -324,7 +362,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .coltypes
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -332,7 +378,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .coltypmods
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -340,7 +394,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .colcollations
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -348,7 +410,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .colexprs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -356,7 +426,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .coldefexprs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -364,40 +442,54 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::Var(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::Param(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::Aggref(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .aggargtypes
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -405,7 +497,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .aggdirectargs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -413,7 +513,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -421,7 +529,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .aggorder
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -429,33 +545,53 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .aggdistinct
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let aggfilter = n.aggfilter.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&aggfilter, current_depth));
-            nodes.push(NestedNode {
-                node: aggfilter,
-                depth: current_depth,
-            });
+            if n.aggfilter.is_some() {
+                let aggfilter = n.aggfilter.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&aggfilter, current_depth));
+                nodes.push(NestedNode {
+                    node: aggfilter,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::GroupingFunc(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -463,7 +599,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .refs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -471,7 +615,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .cols
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -479,44 +631,66 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::WindowFunc(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let aggfilter = n.aggfilter.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&aggfilter, current_depth));
-            nodes.push(NestedNode {
-                node: aggfilter,
-                depth: current_depth,
-            });
+            if n.aggfilter.is_some() {
+                let aggfilter = n.aggfilter.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&aggfilter, current_depth));
+                nodes.push(NestedNode {
+                    node: aggfilter,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::SubscriptingRef(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .refupperindexpr
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -524,40 +698,62 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .reflowerindexpr
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let refexpr = n.refexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&refexpr, current_depth));
-            nodes.push(NestedNode {
-                node: refexpr,
-                depth: current_depth,
-            });
+            if n.refexpr.is_some() {
+                let refexpr = n.refexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&refexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: refexpr,
+                    depth: current_depth,
+                });
+            }
 
-            let refassgnexpr = n.refassgnexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&refassgnexpr, current_depth));
-            nodes.push(NestedNode {
-                node: refassgnexpr,
-                depth: current_depth,
-            });
+            if n.refassgnexpr.is_some() {
+                let refassgnexpr = n.refassgnexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&refassgnexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: refassgnexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::FuncExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -565,36 +761,50 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::NamedArgExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::OpExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -602,18 +812,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::DistinctExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -621,18 +841,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::NullIfExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -640,18 +870,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::ScalarArrayOpExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -659,18 +899,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::BoolExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -678,58 +928,84 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::SubLink(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let testexpr = n.testexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&testexpr, current_depth));
-            nodes.push(NestedNode {
-                node: testexpr,
-                depth: current_depth,
-            });
+            if n.testexpr.is_some() {
+                let testexpr = n.testexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&testexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: testexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .oper_name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let subselect = n.subselect.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&subselect, current_depth));
-            nodes.push(NestedNode {
-                node: subselect,
-                depth: current_depth,
-            });
+            if n.subselect.is_some() {
+                let subselect = n.subselect.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&subselect, current_depth));
+                nodes.push(NestedNode {
+                    node: subselect,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::SubPlan(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let testexpr = n.testexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&testexpr, current_depth));
-            nodes.push(NestedNode {
-                node: testexpr,
-                depth: current_depth,
-            });
+            if n.testexpr.is_some() {
+                let testexpr = n.testexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&testexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: testexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .param_ids
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -737,7 +1013,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .set_param
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -745,7 +1029,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .par_param
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -753,7 +1045,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -761,18 +1061,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::AlternativeSubPlan(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .subplans
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -780,43 +1090,59 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::FieldSelect(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::FieldStore(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .newvals
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -824,7 +1150,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .fieldnums
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -832,184 +1166,238 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::RelabelType(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CoerceViaIo(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::ArrayCoerceExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
-
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
-
-            let elemexpr = n.elemexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&elemexpr, current_depth));
-            nodes.push(NestedNode {
-                node: elemexpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
+
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
+
+            if n.elemexpr.is_some() {
+                let elemexpr = n.elemexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&elemexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: elemexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::ConvertRowtypeExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CollateExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CaseExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let defresult = n.defresult.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&defresult, current_depth));
-            nodes.push(NestedNode {
-                node: defresult,
-                depth: current_depth,
-            });
+            if n.defresult.is_some() {
+                let defresult = n.defresult.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&defresult, current_depth));
+                nodes.push(NestedNode {
+                    node: defresult,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CaseWhen(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
-
-            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&expr, current_depth));
-            nodes.push(NestedNode {
-                node: expr,
-                depth: current_depth,
-            });
-
-            let result = n.result.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&result, current_depth));
-            nodes.push(NestedNode {
-                node: result,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
+
+            if n.expr.is_some() {
+                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&expr, current_depth));
+                nodes.push(NestedNode {
+                    node: expr,
+                    depth: current_depth,
+                });
+            }
+
+            if n.result.is_some() {
+                let result = n.result.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&result, current_depth));
+                nodes.push(NestedNode {
+                    node: result,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CaseTestExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::ArrayExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .elements
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1017,18 +1405,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::RowExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1036,7 +1434,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .colnames
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1044,18 +1450,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::RowCompareExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .opnos
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1063,7 +1479,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .opfamilies
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1071,7 +1495,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .inputcollids
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1079,7 +1511,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .largs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1087,7 +1527,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .rargs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1095,18 +1543,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::CoalesceExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1114,18 +1572,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::MinMaxExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1133,29 +1601,41 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::SqlvalueFunction(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::XmlExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .named_args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1163,7 +1643,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .arg_names
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1171,7 +1659,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1179,135 +1675,163 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::NullTest(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::BooleanTest(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CoerceToDomain(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CoerceToDomainValue(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::SetToDefault(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CurrentOfExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::NextValueExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::InferenceElem(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&expr, current_depth));
-            nodes.push(NestedNode {
-                node: expr,
-                depth: current_depth,
-            });
+            if n.expr.is_some() {
+                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&expr, current_depth));
+                nodes.push(NestedNode {
+                    node: expr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::TargetEntry(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&xpr, current_depth));
-            nodes.push(NestedNode {
-                node: xpr,
-                depth: current_depth,
-            });
+            if n.xpr.is_some() {
+                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&xpr, current_depth));
+                nodes.push(NestedNode {
+                    node: xpr,
+                    depth: current_depth,
+                });
+            }
 
-            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&expr, current_depth));
-            nodes.push(NestedNode {
-                node: expr,
-                depth: current_depth,
-            });
+            if n.expr.is_some() {
+                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&expr, current_depth));
+                nodes.push(NestedNode {
+                    node: expr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -1319,48 +1843,67 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::JoinExpr(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let larg = n.larg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&larg, current_depth));
-            nodes.push(NestedNode {
-                node: larg,
-                depth: current_depth,
-            });
+            if n.larg.is_some() {
+                let larg = n.larg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&larg, current_depth));
+                nodes.push(NestedNode {
+                    node: larg,
+                    depth: current_depth,
+                });
+            }
 
-            let rarg = n.rarg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&rarg, current_depth));
-            nodes.push(NestedNode {
-                node: rarg,
-                depth: current_depth,
-            });
+            if n.rarg.is_some() {
+                let rarg = n.rarg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&rarg, current_depth));
+                nodes.push(NestedNode {
+                    node: rarg,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .using_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
-                    .collect(),
-            );
-
-            let join_using_alias = NodeEnum::Alias(n.join_using_alias.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&join_using_alias, current_depth));
-            nodes.push(NestedNode {
-                node: join_using_alias,
-                depth: current_depth,
-            });
-
-            let quals = n.quals.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&quals, current_depth));
-            nodes.push(NestedNode {
-                node: quals,
-                depth: current_depth,
-            });
-
-            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&alias, current_depth));
-            nodes.push(NestedNode {
-                node: alias,
-                depth: current_depth,
-            });
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
+                    .collect(),
+            );
+
+            if n.join_using_alias.is_some() {
+                let join_using_alias =
+                    NodeEnum::Alias(n.join_using_alias.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&join_using_alias, current_depth));
+                nodes.push(NestedNode {
+                    node: join_using_alias,
+                    depth: current_depth,
+                });
+            }
+
+            if n.quals.is_some() {
+                let quals = n.quals.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&quals, current_depth));
+                nodes.push(NestedNode {
+                    node: quals,
+                    depth: current_depth,
+                });
+            }
+
+            if n.alias.is_some() {
+                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&alias, current_depth));
+                nodes.push(NestedNode {
+                    node: alias,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -1370,16 +1913,26 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .fromlist
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let quals = n.quals.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&quals, current_depth));
-            nodes.push(NestedNode {
-                node: quals,
-                depth: current_depth,
-            });
+            if n.quals.is_some() {
+                let quals = n.quals.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&quals, current_depth));
+                nodes.push(NestedNode {
+                    node: quals,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -1390,43 +1943,71 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .arbiter_elems
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let arbiter_where = n.arbiter_where.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arbiter_where, current_depth));
-            nodes.push(NestedNode {
-                node: arbiter_where,
-                depth: current_depth,
-            });
+            if n.arbiter_where.is_some() {
+                let arbiter_where = n.arbiter_where.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arbiter_where, current_depth));
+                nodes.push(NestedNode {
+                    node: arbiter_where,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .on_conflict_set
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let on_conflict_where = n
-                .on_conflict_where
-                .as_ref()
-                .unwrap()
-                .to_owned()
-                .node
-                .unwrap();
-            nodes.append(&mut get_children(&on_conflict_where, current_depth));
-            nodes.push(NestedNode {
-                node: on_conflict_where,
-                depth: current_depth,
-            });
+            if n.on_conflict_where.is_some() {
+                let on_conflict_where = n
+                    .on_conflict_where
+                    .as_ref()
+                    .unwrap()
+                    .to_owned()
+                    .node
+                    .unwrap();
+                nodes.append(&mut get_children(&on_conflict_where, current_depth));
+                nodes.push(NestedNode {
+                    node: on_conflict_where,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .excl_rel_tlist
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1434,18 +2015,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::IntoClause(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let rel = NodeEnum::RangeVar(n.rel.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&rel, current_depth));
-            nodes.push(NestedNode {
-                node: rel,
-                depth: current_depth,
-            });
+            if n.rel.is_some() {
+                let rel = NodeEnum::RangeVar(n.rel.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&rel, current_depth));
+                nodes.push(NestedNode {
+                    node: rel,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .col_names
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1453,34 +2044,54 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let view_query = n.view_query.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&view_query, current_depth));
-            nodes.push(NestedNode {
-                node: view_query,
-                depth: current_depth,
-            });
+            if n.view_query.is_some() {
+                let view_query = n.view_query.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&view_query, current_depth));
+                nodes.push(NestedNode {
+                    node: view_query,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::MergeAction(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&qual, current_depth));
-            nodes.push(NestedNode {
-                node: qual,
-                depth: current_depth,
-            });
+            if n.qual.is_some() {
+                let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&qual, current_depth));
+                nodes.push(NestedNode {
+                    node: qual,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1488,7 +2099,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .update_colnos
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1496,30 +2115,42 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::RawStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let stmt = n.stmt.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&stmt, current_depth));
-            nodes.push(NestedNode {
-                node: stmt,
-                depth: current_depth,
-            });
+            if n.stmt.is_some() {
+                let stmt = n.stmt.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&stmt, current_depth));
+                nodes.push(NestedNode {
+                    node: stmt,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::Query(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let utility_stmt = n.utility_stmt.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&utility_stmt, current_depth));
-            nodes.push(NestedNode {
-                node: utility_stmt,
-                depth: current_depth,
-            });
+            if n.utility_stmt.is_some() {
+                let utility_stmt = n.utility_stmt.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&utility_stmt, current_depth));
+                nodes.push(NestedNode {
+                    node: utility_stmt,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .cte_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1527,22 +2158,40 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .rtable
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let jointree = NodeEnum::FromExpr(n.jointree.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&jointree, current_depth));
-            nodes.push(NestedNode {
-                node: jointree,
-                depth: current_depth,
-            });
+            if n.jointree.is_some() {
+                let jointree = NodeEnum::FromExpr(n.jointree.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&jointree, current_depth));
+                nodes.push(NestedNode {
+                    node: jointree,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .merge_action_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1550,22 +2199,41 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let on_conflict = NodeEnum::OnConflictExpr(n.on_conflict.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&on_conflict, current_depth));
-            nodes.push(NestedNode {
-                node: on_conflict,
-                depth: current_depth,
-            });
+            if n.on_conflict.is_some() {
+                let on_conflict =
+                    NodeEnum::OnConflictExpr(n.on_conflict.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&on_conflict, current_depth));
+                nodes.push(NestedNode {
+                    node: on_conflict,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .returning_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1573,7 +2241,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .group_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1581,22 +2257,40 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .grouping_sets
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let having_qual = n.having_qual.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&having_qual, current_depth));
-            nodes.push(NestedNode {
-                node: having_qual,
-                depth: current_depth,
-            });
+            if n.having_qual.is_some() {
+                let having_qual = n.having_qual.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&having_qual, current_depth));
+                nodes.push(NestedNode {
+                    node: having_qual,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .window_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1604,7 +2298,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .distinct_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1612,44 +2314,74 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .sort_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let limit_offset = n.limit_offset.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&limit_offset, current_depth));
-            nodes.push(NestedNode {
-                node: limit_offset,
-                depth: current_depth,
-            });
+            if n.limit_offset.is_some() {
+                let limit_offset = n.limit_offset.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&limit_offset, current_depth));
+                nodes.push(NestedNode {
+                    node: limit_offset,
+                    depth: current_depth,
+                });
+            }
 
-            let limit_count = n.limit_count.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&limit_count, current_depth));
-            nodes.push(NestedNode {
-                node: limit_count,
-                depth: current_depth,
-            });
+            if n.limit_count.is_some() {
+                let limit_count = n.limit_count.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&limit_count, current_depth));
+                nodes.push(NestedNode {
+                    node: limit_count,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .row_marks
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let set_operations = n.set_operations.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&set_operations, current_depth));
-            nodes.push(NestedNode {
-                node: set_operations,
-                depth: current_depth,
-            });
+            if n.set_operations.is_some() {
+                let set_operations = n.set_operations.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&set_operations, current_depth));
+                nodes.push(NestedNode {
+                    node: set_operations,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .constraint_deps
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1657,7 +2389,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .with_check_options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1665,123 +2405,189 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::InsertStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .cols
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let select_stmt = n.select_stmt.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&select_stmt, current_depth));
-            nodes.push(NestedNode {
-                node: select_stmt,
-                depth: current_depth,
-            });
+            if n.select_stmt.is_some() {
+                let select_stmt = n.select_stmt.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&select_stmt, current_depth));
+                nodes.push(NestedNode {
+                    node: select_stmt,
+                    depth: current_depth,
+                });
+            }
 
-            let on_conflict_clause =
-                NodeEnum::OnConflictClause(n.on_conflict_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&on_conflict_clause, current_depth));
-            nodes.push(NestedNode {
-                node: on_conflict_clause,
-                depth: current_depth,
-            });
+            if n.on_conflict_clause.is_some() {
+                let on_conflict_clause =
+                    NodeEnum::OnConflictClause(n.on_conflict_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&on_conflict_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: on_conflict_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .returning_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&with_clause, current_depth));
-            nodes.push(NestedNode {
-                node: with_clause,
-                depth: current_depth,
-            });
+            if n.with_clause.is_some() {
+                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&with_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: with_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::DeleteStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .using_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .returning_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&with_clause, current_depth));
-            nodes.push(NestedNode {
-                node: with_clause,
-                depth: current_depth,
-            });
+            if n.with_clause.is_some() {
+                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&with_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: with_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::UpdateStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .from_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1789,56 +2595,82 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .returning_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&with_clause, current_depth));
-            nodes.push(NestedNode {
-                node: with_clause,
-                depth: current_depth,
-            });
+            if n.with_clause.is_some() {
+                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&with_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: with_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::MergeStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
-
-            let source_relation = n.source_relation.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&source_relation, current_depth));
-            nodes.push(NestedNode {
-                node: source_relation,
-                depth: current_depth,
-            });
-
-            let join_condition = n.join_condition.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&join_condition, current_depth));
-            nodes.push(NestedNode {
-                node: join_condition,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
+
+            if n.source_relation.is_some() {
+                let source_relation = n.source_relation.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&source_relation, current_depth));
+                nodes.push(NestedNode {
+                    node: source_relation,
+                    depth: current_depth,
+                });
+            }
+
+            if n.join_condition.is_some() {
+                let join_condition = n.join_condition.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&join_condition, current_depth));
+                nodes.push(NestedNode {
+                    node: join_condition,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .merge_when_clauses
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&with_clause, current_depth));
-            nodes.push(NestedNode {
-                node: with_clause,
-                depth: current_depth,
-            });
+            if n.with_clause.is_some() {
+                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&with_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: with_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -1848,22 +2680,40 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .distinct_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let into_clause = NodeEnum::IntoClause(n.into_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&into_clause, current_depth));
-            nodes.push(NestedNode {
-                node: into_clause,
-                depth: current_depth,
-            });
+            if n.into_clause.is_some() {
+                let into_clause = NodeEnum::IntoClause(n.into_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&into_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: into_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1871,37 +2721,65 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .from_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .group_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let having_clause = n.having_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&having_clause, current_depth));
-            nodes.push(NestedNode {
-                node: having_clause,
-                depth: current_depth,
-            });
+            if n.having_clause.is_some() {
+                let having_clause = n.having_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&having_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: having_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .window_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1909,7 +2787,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .values_lists
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -1917,63 +2803,91 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .sort_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let limit_offset = n.limit_offset.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&limit_offset, current_depth));
-            nodes.push(NestedNode {
-                node: limit_offset,
-                depth: current_depth,
-            });
+            if n.limit_offset.is_some() {
+                let limit_offset = n.limit_offset.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&limit_offset, current_depth));
+                nodes.push(NestedNode {
+                    node: limit_offset,
+                    depth: current_depth,
+                });
+            }
 
-            let limit_count = n.limit_count.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&limit_count, current_depth));
-            nodes.push(NestedNode {
-                node: limit_count,
-                depth: current_depth,
-            });
+            if n.limit_count.is_some() {
+                let limit_count = n.limit_count.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&limit_count, current_depth));
+                nodes.push(NestedNode {
+                    node: limit_count,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .locking_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
-                    .collect(),
-            );
-
-            let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&with_clause, current_depth));
-            nodes.push(NestedNode {
-                node: with_clause,
-                depth: current_depth,
-            });
-
-            let larg = NodeEnum::SelectStmt(n.larg.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&larg, current_depth));
-            nodes.push(NestedNode {
-                node: larg,
-                depth: current_depth,
-            });
-
-            let rarg = NodeEnum::SelectStmt(n.rarg.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&rarg, current_depth));
-            nodes.push(NestedNode {
-                node: rarg,
-                depth: current_depth,
-            });
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
+                    .collect(),
+            );
+
+            if n.with_clause.is_some() {
+                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&with_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: with_clause,
+                    depth: current_depth,
+                });
+            }
+
+            if n.larg.is_some() {
+                let larg = NodeEnum::SelectStmt(n.larg.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&larg, current_depth));
+                nodes.push(NestedNode {
+                    node: larg,
+                    depth: current_depth,
+                });
+            }
+
+            if n.rarg.is_some() {
+                let rarg = NodeEnum::SelectStmt(n.rarg.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&rarg, current_depth));
+                nodes.push(NestedNode {
+                    node: rarg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::ReturnStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let returnval = n.returnval.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&returnval, current_depth));
-            nodes.push(NestedNode {
-                node: returnval,
-                depth: current_depth,
-            });
+            if n.returnval.is_some() {
+                let returnval = n.returnval.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&returnval, current_depth));
+                nodes.push(NestedNode {
+                    node: returnval,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -1984,33 +2898,53 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .indirection
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let val = NodeEnum::SelectStmt(n.val.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&val, current_depth));
-            nodes.push(NestedNode {
-                node: val,
-                depth: current_depth,
-            });
+            if n.val.is_some() {
+                let val = NodeEnum::SelectStmt(n.val.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&val, current_depth));
+                nodes.push(NestedNode {
+                    node: val,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::AlterTableStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .cmds
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2019,19 +2953,23 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::AlterTableCmd(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let newowner = NodeEnum::RoleSpec(n.newowner.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&newowner, current_depth));
-            nodes.push(NestedNode {
-                node: newowner,
-                depth: current_depth,
-            });
+            if n.newowner.is_some() {
+                let newowner = NodeEnum::RoleSpec(n.newowner.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&newowner, current_depth));
+                nodes.push(NestedNode {
+                    node: newowner,
+                    depth: current_depth,
+                });
+            }
 
-            let def = n.def.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&def, current_depth));
-            nodes.push(NestedNode {
-                node: def,
-                depth: current_depth,
-            });
+            if n.def.is_some() {
+                let def = n.def.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&def, current_depth));
+                nodes.push(NestedNode {
+                    node: def,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -2042,41 +2980,63 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let def = n.def.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&def, current_depth));
-            nodes.push(NestedNode {
-                node: def,
-                depth: current_depth,
-            });
+            if n.def.is_some() {
+                let def = n.def.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&def, current_depth));
+                nodes.push(NestedNode {
+                    node: def,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::SetOperationStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let larg = n.larg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&larg, current_depth));
-            nodes.push(NestedNode {
-                node: larg,
-                depth: current_depth,
-            });
+            if n.larg.is_some() {
+                let larg = n.larg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&larg, current_depth));
+                nodes.push(NestedNode {
+                    node: larg,
+                    depth: current_depth,
+                });
+            }
 
-            let rarg = n.rarg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&rarg, current_depth));
-            nodes.push(NestedNode {
-                node: rarg,
-                depth: current_depth,
-            });
+            if n.rarg.is_some() {
+                let rarg = n.rarg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&rarg, current_depth));
+                nodes.push(NestedNode {
+                    node: rarg,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .col_types
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2084,7 +3044,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .col_typmods
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2092,7 +3060,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .col_collations
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2100,7 +3076,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .group_clauses
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2113,7 +3097,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .objects
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2121,7 +3113,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .privileges
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2129,16 +3129,26 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .grantees
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let grantor = NodeEnum::RoleSpec(n.grantor.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&grantor, current_depth));
-            nodes.push(NestedNode {
-                node: grantor,
-                depth: current_depth,
-            });
+            if n.grantor.is_some() {
+                let grantor = NodeEnum::RoleSpec(n.grantor.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&grantor, current_depth));
+                nodes.push(NestedNode {
+                    node: grantor,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -2148,7 +3158,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .granted_roles
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2156,16 +3174,26 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .grantee_roles
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let grantor = NodeEnum::RoleSpec(n.grantor.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&grantor, current_depth));
-            nodes.push(NestedNode {
-                node: grantor,
-                depth: current_depth,
-            });
+            if n.grantor.is_some() {
+                let grantor = NodeEnum::RoleSpec(n.grantor.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&grantor, current_depth));
+                nodes.push(NestedNode {
+                    node: grantor,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -2175,16 +3203,26 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let action = NodeEnum::GrantStmt(n.action.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&action, current_depth));
-            nodes.push(NestedNode {
-                node: action,
-                depth: current_depth,
-            });
+            if n.action.is_some() {
+                let action = NodeEnum::GrantStmt(n.action.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&action, current_depth));
+                nodes.push(NestedNode {
+                    node: action,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -2195,18 +3233,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::ClusterStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .params
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2214,25 +3262,37 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::CopyStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
-            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&query, current_depth));
-            nodes.push(NestedNode {
-                node: query,
-                depth: current_depth,
-            });
+            if n.query.is_some() {
+                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&query, current_depth));
+                nodes.push(NestedNode {
+                    node: query,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .attlist
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2240,33 +3300,53 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CreateStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .table_elts
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2274,36 +3354,59 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .inh_relations
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
-                    .collect(),
-            );
-
-            let partbound = NodeEnum::PartitionBoundSpec(n.partbound.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&partbound, current_depth));
-            nodes.push(NestedNode {
-                node: partbound,
-                depth: current_depth,
-            });
-
-            let partspec = NodeEnum::PartitionSpec(n.partspec.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&partspec, current_depth));
-            nodes.push(NestedNode {
-                node: partspec,
-                depth: current_depth,
-            });
-
-            let of_typename = NodeEnum::TypeName(n.of_typename.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&of_typename, current_depth));
-            nodes.push(NestedNode {
-                node: of_typename,
-                depth: current_depth,
-            });
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
+                    .collect(),
+            );
+
+            if n.partbound.is_some() {
+                let partbound =
+                    NodeEnum::PartitionBoundSpec(n.partbound.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&partbound, current_depth));
+                nodes.push(NestedNode {
+                    node: partbound,
+                    depth: current_depth,
+                });
+            }
+
+            if n.partspec.is_some() {
+                let partspec = NodeEnum::PartitionSpec(n.partspec.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&partspec, current_depth));
+                nodes.push(NestedNode {
+                    node: partspec,
+                    depth: current_depth,
+                });
+            }
+
+            if n.of_typename.is_some() {
+                let of_typename = NodeEnum::TypeName(n.of_typename.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&of_typename, current_depth));
+                nodes.push(NestedNode {
+                    node: of_typename,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .constraints
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2311,7 +3414,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2324,7 +3435,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .defnames
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2332,7 +3451,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2340,7 +3467,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .definition
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2352,7 +3487,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .objects
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2364,7 +3507,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .relations
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2373,12 +3524,14 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::CommentStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&object, current_depth));
-            nodes.push(NestedNode {
-                node: object,
-                depth: current_depth,
-            });
+            if n.object.is_some() {
+                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&object, current_depth));
+                nodes.push(NestedNode {
+                    node: object,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -2390,18 +3543,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::IndexStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .index_params
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2409,7 +3572,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .index_including_params
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2417,22 +3588,40 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .exclude_op_names
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2445,7 +3634,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .funcname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2453,49 +3650,79 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .parameters
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let return_type = NodeEnum::TypeName(n.return_type.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&return_type, current_depth));
-            nodes.push(NestedNode {
-                node: return_type,
-                depth: current_depth,
-            });
+            if n.return_type.is_some() {
+                let return_type = NodeEnum::TypeName(n.return_type.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&return_type, current_depth));
+                nodes.push(NestedNode {
+                    node: return_type,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let sql_body = n.sql_body.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&sql_body, current_depth));
-            nodes.push(NestedNode {
-                node: sql_body,
-                depth: current_depth,
-            });
+            if n.sql_body.is_some() {
+                let sql_body = n.sql_body.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&sql_body, current_depth));
+                nodes.push(NestedNode {
+                    node: sql_body,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::AlterFunctionStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let func = NodeEnum::ObjectWithArgs(n.func.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&func, current_depth));
-            nodes.push(NestedNode {
-                node: func,
-                depth: current_depth,
-            });
+            if n.func.is_some() {
+                let func = NodeEnum::ObjectWithArgs(n.func.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&func, current_depth));
+                nodes.push(NestedNode {
+                    node: func,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .actions
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2507,7 +3734,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2516,43 +3751,59 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::RenameStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
-            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&object, current_depth));
-            nodes.push(NestedNode {
-                node: object,
-                depth: current_depth,
-            });
+            if n.object.is_some() {
+                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&object, current_depth));
+                nodes.push(NestedNode {
+                    node: object,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::RuleStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .actions
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2580,7 +3831,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2588,33 +3847,53 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::ViewStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let view = NodeEnum::RangeVar(n.view.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&view, current_depth));
-            nodes.push(NestedNode {
-                node: view,
-                depth: current_depth,
-            });
+            if n.view.is_some() {
+                let view = NodeEnum::RangeVar(n.view.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&view, current_depth));
+                nodes.push(NestedNode {
+                    node: view,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .aliases
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&query, current_depth));
-            nodes.push(NestedNode {
-                node: query,
-                depth: current_depth,
-            });
+            if n.query.is_some() {
+                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&query, current_depth));
+                nodes.push(NestedNode {
+                    node: query,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2631,29 +3910,50 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .domainname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&type_name, current_depth));
-            nodes.push(NestedNode {
-                node: type_name,
-                depth: current_depth,
-            });
+            if n.type_name.is_some() {
+                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&type_name, current_depth));
+                nodes.push(NestedNode {
+                    node: type_name,
+                    depth: current_depth,
+                });
+            }
 
-            let coll_clause = NodeEnum::CollateClause(n.coll_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&coll_clause, current_depth));
-            nodes.push(NestedNode {
-                node: coll_clause,
-                depth: current_depth,
-            });
+            if n.coll_clause.is_some() {
+                let coll_clause =
+                    NodeEnum::CollateClause(n.coll_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&coll_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: coll_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .constraints
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2666,7 +3966,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2679,7 +3987,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2691,7 +4007,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2699,7 +4023,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .rels
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2707,18 +4039,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::ExplainStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&query, current_depth));
-            nodes.push(NestedNode {
-                node: query,
-                depth: current_depth,
-            });
+            if n.query.is_some() {
+                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&query, current_depth));
+                nodes.push(NestedNode {
+                    node: query,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2726,36 +4068,50 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::CreateTableAsStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&query, current_depth));
-            nodes.push(NestedNode {
-                node: query,
-                depth: current_depth,
-            });
+            if n.query.is_some() {
+                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&query, current_depth));
+                nodes.push(NestedNode {
+                    node: query,
+                    depth: current_depth,
+                });
+            }
 
-            let into = NodeEnum::IntoClause(n.into.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&into, current_depth));
-            nodes.push(NestedNode {
-                node: into,
-                depth: current_depth,
-            });
+            if n.into.is_some() {
+                let into = NodeEnum::IntoClause(n.into.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&into, current_depth));
+                nodes.push(NestedNode {
+                    node: into,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CreateSeqStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let sequence = NodeEnum::RangeVar(n.sequence.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&sequence, current_depth));
-            nodes.push(NestedNode {
-                node: sequence,
-                depth: current_depth,
-            });
+            if n.sequence.is_some() {
+                let sequence = NodeEnum::RangeVar(n.sequence.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&sequence, current_depth));
+                nodes.push(NestedNode {
+                    node: sequence,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2763,18 +4119,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::AlterSeqStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let sequence = NodeEnum::RangeVar(n.sequence.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&sequence, current_depth));
-            nodes.push(NestedNode {
-                node: sequence,
-                depth: current_depth,
-            });
+            if n.sequence.is_some() {
+                let sequence = NodeEnum::RangeVar(n.sequence.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&sequence, current_depth));
+                nodes.push(NestedNode {
+                    node: sequence,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2787,7 +4153,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2806,18 +4180,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::CreateTrigStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .funcname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2825,7 +4209,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2833,31 +4225,51 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .columns
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let when_clause = n.when_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&when_clause, current_depth));
-            nodes.push(NestedNode {
-                node: when_clause,
-                depth: current_depth,
-            });
+            if n.when_clause.is_some() {
+                let when_clause = n.when_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&when_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: when_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .transition_rels
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let constrrel = NodeEnum::RangeVar(n.constrrel.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&constrrel, current_depth));
-            nodes.push(NestedNode {
-                node: constrrel,
-                depth: current_depth,
-            });
+            if n.constrrel.is_some() {
+                let constrrel = NodeEnum::RangeVar(n.constrrel.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&constrrel, current_depth));
+                nodes.push(NestedNode {
+                    node: constrrel,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -2868,7 +4280,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .plhandler
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2876,7 +4296,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .plinline
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2884,7 +4312,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .plvalidator
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2897,7 +4333,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2905,18 +4349,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::AlterRoleStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let role = NodeEnum::RoleSpec(n.role.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&role, current_depth));
-            nodes.push(NestedNode {
-                node: role,
-                depth: current_depth,
-            });
+            if n.role.is_some() {
+                let role = NodeEnum::RoleSpec(n.role.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&role, current_depth));
+                nodes.push(NestedNode {
+                    node: role,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2928,7 +4382,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2940,7 +4402,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .relations
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2952,7 +4422,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .constraints
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2961,18 +4439,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::ReindexStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .params
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -2985,18 +4473,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::CreateSchemaStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let authrole = NodeEnum::RoleSpec(n.authrole.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&authrole, current_depth));
-            nodes.push(NestedNode {
-                node: authrole,
-                depth: current_depth,
-            });
+            if n.authrole.is_some() {
+                let authrole = NodeEnum::RoleSpec(n.authrole.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&authrole, current_depth));
+                nodes.push(NestedNode {
+                    node: authrole,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .schema_elts
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3009,7 +4507,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3023,30 +4529,36 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::AlterDatabaseSetStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&setstmt, current_depth));
-            nodes.push(NestedNode {
-                node: setstmt,
-                depth: current_depth,
-            });
+            if n.setstmt.is_some() {
+                let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&setstmt, current_depth));
+                nodes.push(NestedNode {
+                    node: setstmt,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::AlterRoleSetStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let role = NodeEnum::RoleSpec(n.role.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&role, current_depth));
-            nodes.push(NestedNode {
-                node: role,
-                depth: current_depth,
-            });
+            if n.role.is_some() {
+                let role = NodeEnum::RoleSpec(n.role.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&role, current_depth));
+                nodes.push(NestedNode {
+                    node: role,
+                    depth: current_depth,
+                });
+            }
 
-            let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&setstmt, current_depth));
-            nodes.push(NestedNode {
-                node: setstmt,
-                depth: current_depth,
-            });
+            if n.setstmt.is_some() {
+                let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&setstmt, current_depth));
+                nodes.push(NestedNode {
+                    node: setstmt,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -3056,7 +4568,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .conversion_name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3064,7 +4584,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .func_name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3072,26 +4600,32 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::CreateCastStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let sourcetype = NodeEnum::TypeName(n.sourcetype.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&sourcetype, current_depth));
-            nodes.push(NestedNode {
-                node: sourcetype,
-                depth: current_depth,
-            });
-
-            let targettype = NodeEnum::TypeName(n.targettype.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&targettype, current_depth));
-            nodes.push(NestedNode {
-                node: targettype,
-                depth: current_depth,
-            });
-
-            let func = NodeEnum::ObjectWithArgs(n.func.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&func, current_depth));
-            nodes.push(NestedNode {
-                node: func,
-                depth: current_depth,
-            });
+            if n.sourcetype.is_some() {
+                let sourcetype = NodeEnum::TypeName(n.sourcetype.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&sourcetype, current_depth));
+                nodes.push(NestedNode {
+                    node: sourcetype,
+                    depth: current_depth,
+                });
+            }
+
+            if n.targettype.is_some() {
+                let targettype = NodeEnum::TypeName(n.targettype.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&targettype, current_depth));
+                nodes.push(NestedNode {
+                    node: targettype,
+                    depth: current_depth,
+                });
+            }
+
+            if n.func.is_some() {
+                let func = NodeEnum::ObjectWithArgs(n.func.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&func, current_depth));
+                nodes.push(NestedNode {
+                    node: func,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -3101,7 +4635,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .opclassname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3109,22 +4651,40 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .opfamilyname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let datatype = NodeEnum::TypeName(n.datatype.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&datatype, current_depth));
-            nodes.push(NestedNode {
-                node: datatype,
-                depth: current_depth,
-            });
+            if n.datatype.is_some() {
+                let datatype = NodeEnum::TypeName(n.datatype.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&datatype, current_depth));
+                nodes.push(NestedNode {
+                    node: datatype,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3136,7 +4696,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .opfamilyname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3148,7 +4716,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .opfamilyname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3156,7 +4732,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3169,16 +4753,26 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .argtypes
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&query, current_depth));
-            nodes.push(NestedNode {
-                node: query,
-                depth: current_depth,
-            });
+            if n.query.is_some() {
+                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&query, current_depth));
+                nodes.push(NestedNode {
+                    node: query,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -3189,7 +4783,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .params
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3203,30 +4805,42 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::DeclareCursorStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&query, current_depth));
-            nodes.push(NestedNode {
-                node: query,
-                depth: current_depth,
-            });
+            if n.query.is_some() {
+                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&query, current_depth));
+                nodes.push(NestedNode {
+                    node: query,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CreateTableSpaceStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let owner = NodeEnum::RoleSpec(n.owner.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&owner, current_depth));
-            nodes.push(NestedNode {
-                node: owner,
-                depth: current_depth,
-            });
+            if n.owner.is_some() {
+                let owner = NodeEnum::RoleSpec(n.owner.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&owner, current_depth));
+                nodes.push(NestedNode {
+                    node: owner,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3240,88 +4854,114 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::AlterObjectDependsStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
-            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&object, current_depth));
-            nodes.push(NestedNode {
-                node: object,
-                depth: current_depth,
-            });
+            if n.object.is_some() {
+                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&object, current_depth));
+                nodes.push(NestedNode {
+                    node: object,
+                    depth: current_depth,
+                });
+            }
 
-            let extname = NodeEnum::String(n.extname.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&extname, current_depth));
-            nodes.push(NestedNode {
-                node: extname,
-                depth: current_depth,
-            });
+            if n.extname.is_some() {
+                let extname = NodeEnum::String(n.extname.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&extname, current_depth));
+                nodes.push(NestedNode {
+                    node: extname,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::AlterObjectSchemaStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
-            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&object, current_depth));
-            nodes.push(NestedNode {
-                node: object,
-                depth: current_depth,
-            });
+            if n.object.is_some() {
+                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&object, current_depth));
+                nodes.push(NestedNode {
+                    node: object,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::AlterOwnerStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
-            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&object, current_depth));
-            nodes.push(NestedNode {
-                node: object,
-                depth: current_depth,
-            });
+            if n.object.is_some() {
+                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&object, current_depth));
+                nodes.push(NestedNode {
+                    node: object,
+                    depth: current_depth,
+                });
+            }
 
-            let newowner = NodeEnum::RoleSpec(n.newowner.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&newowner, current_depth));
-            nodes.push(NestedNode {
-                node: newowner,
-                depth: current_depth,
-            });
+            if n.newowner.is_some() {
+                let newowner = NodeEnum::RoleSpec(n.newowner.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&newowner, current_depth));
+                nodes.push(NestedNode {
+                    node: newowner,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::AlterOperatorStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let opername = NodeEnum::ObjectWithArgs(n.opername.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&opername, current_depth));
-            nodes.push(NestedNode {
-                node: opername,
-                depth: current_depth,
-            });
+            if n.opername.is_some() {
+                let opername = NodeEnum::ObjectWithArgs(n.opername.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&opername, current_depth));
+                nodes.push(NestedNode {
+                    node: opername,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3333,7 +4973,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3341,7 +4989,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3353,7 +5009,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3365,33 +5029,53 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let newrole = NodeEnum::RoleSpec(n.newrole.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&newrole, current_depth));
-            nodes.push(NestedNode {
-                node: newrole,
-                depth: current_depth,
-            });
+            if n.newrole.is_some() {
+                let newrole = NodeEnum::RoleSpec(n.newrole.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&newrole, current_depth));
+                nodes.push(NestedNode {
+                    node: newrole,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CompositeTypeStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let typevar = NodeEnum::RangeVar(n.typevar.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&typevar, current_depth));
-            nodes.push(NestedNode {
-                node: typevar,
-                depth: current_depth,
-            });
+            if n.typevar.is_some() {
+                let typevar = NodeEnum::RangeVar(n.typevar.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&typevar, current_depth));
+                nodes.push(NestedNode {
+                    node: typevar,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .coldeflist
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3403,7 +5087,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3411,7 +5103,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .vals
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3423,7 +5123,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3431,7 +5139,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .params
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3443,7 +5159,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .type_name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3455,7 +5179,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .dictname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3463,7 +5195,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3476,7 +5216,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .cfgname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3484,7 +5232,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .tokentype
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3492,7 +5248,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .dicts
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3505,7 +5269,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .func_options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3513,7 +5285,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3526,7 +5306,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .func_options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3534,7 +5322,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3547,7 +5343,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3560,7 +5364,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3568,18 +5380,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::CreateUserMappingStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&user, current_depth));
-            nodes.push(NestedNode {
-                node: user,
-                depth: current_depth,
-            });
+            if n.user.is_some() {
+                let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&user, current_depth));
+                nodes.push(NestedNode {
+                    node: user,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3587,18 +5409,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::AlterUserMappingStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&user, current_depth));
-            nodes.push(NestedNode {
-                node: user,
-                depth: current_depth,
-            });
+            if n.user.is_some() {
+                let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&user, current_depth));
+                nodes.push(NestedNode {
+                    node: user,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3606,12 +5438,14 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::DropUserMappingStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&user, current_depth));
-            nodes.push(NestedNode {
-                node: user,
-                depth: current_depth,
-            });
+            if n.user.is_some() {
+                let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&user, current_depth));
+                nodes.push(NestedNode {
+                    node: user,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -3622,7 +5456,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3635,7 +5477,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3644,29 +5494,41 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::SecLabelStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&object, current_depth));
-            nodes.push(NestedNode {
-                node: object,
-                depth: current_depth,
-            });
+            if n.object.is_some() {
+                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&object, current_depth));
+                nodes.push(NestedNode {
+                    node: object,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CreateForeignTableStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let base_stmt = NodeEnum::CreateStmt(n.base_stmt.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&base_stmt, current_depth));
-            nodes.push(NestedNode {
-                node: base_stmt,
-                depth: current_depth,
-            });
+            if n.base_stmt.is_some() {
+                let base_stmt = NodeEnum::CreateStmt(n.base_stmt.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&base_stmt, current_depth));
+                nodes.push(NestedNode {
+                    node: base_stmt,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3679,7 +5541,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .table_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3687,7 +5557,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3700,7 +5578,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3713,7 +5599,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3722,12 +5616,14 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::AlterExtensionContentsStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&object, current_depth));
-            nodes.push(NestedNode {
-                node: object,
-                depth: current_depth,
-            });
+            if n.object.is_some() {
+                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&object, current_depth));
+                nodes.push(NestedNode {
+                    node: object,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -3738,7 +5634,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .whenclause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3746,7 +5650,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .funcname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3760,12 +5672,14 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::RefreshMatViewStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -3776,106 +5690,142 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::AlterSystemStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&setstmt, current_depth));
-            nodes.push(NestedNode {
-                node: setstmt,
-                depth: current_depth,
-            });
+            if n.setstmt.is_some() {
+                let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&setstmt, current_depth));
+                nodes.push(NestedNode {
+                    node: setstmt,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CreatePolicyStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let table = NodeEnum::RangeVar(n.table.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&table, current_depth));
-            nodes.push(NestedNode {
-                node: table,
-                depth: current_depth,
-            });
+            if n.table.is_some() {
+                let table = NodeEnum::RangeVar(n.table.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&table, current_depth));
+                nodes.push(NestedNode {
+                    node: table,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&qual, current_depth));
-            nodes.push(NestedNode {
-                node: qual,
-                depth: current_depth,
-            });
+            if n.qual.is_some() {
+                let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&qual, current_depth));
+                nodes.push(NestedNode {
+                    node: qual,
+                    depth: current_depth,
+                });
+            }
 
-            let with_check = n.with_check.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&with_check, current_depth));
-            nodes.push(NestedNode {
-                node: with_check,
-                depth: current_depth,
-            });
+            if n.with_check.is_some() {
+                let with_check = n.with_check.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&with_check, current_depth));
+                nodes.push(NestedNode {
+                    node: with_check,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::AlterPolicyStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let table = NodeEnum::RangeVar(n.table.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&table, current_depth));
-            nodes.push(NestedNode {
-                node: table,
-                depth: current_depth,
-            });
+            if n.table.is_some() {
+                let table = NodeEnum::RangeVar(n.table.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&table, current_depth));
+                nodes.push(NestedNode {
+                    node: table,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .roles
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&qual, current_depth));
-            nodes.push(NestedNode {
-                node: qual,
-                depth: current_depth,
-            });
+            if n.qual.is_some() {
+                let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&qual, current_depth));
+                nodes.push(NestedNode {
+                    node: qual,
+                    depth: current_depth,
+                });
+            }
 
-            let with_check = n.with_check.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&with_check, current_depth));
-            nodes.push(NestedNode {
-                node: with_check,
-                depth: current_depth,
-            });
+            if n.with_check.is_some() {
+                let with_check = n.with_check.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&with_check, current_depth));
+                nodes.push(NestedNode {
+                    node: with_check,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CreateTransformStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&type_name, current_depth));
-            nodes.push(NestedNode {
-                node: type_name,
-                depth: current_depth,
-            });
+            if n.type_name.is_some() {
+                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&type_name, current_depth));
+                nodes.push(NestedNode {
+                    node: type_name,
+                    depth: current_depth,
+                });
+            }
 
-            let fromsql = NodeEnum::ObjectWithArgs(n.fromsql.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&fromsql, current_depth));
-            nodes.push(NestedNode {
-                node: fromsql,
-                depth: current_depth,
-            });
+            if n.fromsql.is_some() {
+                let fromsql = NodeEnum::ObjectWithArgs(n.fromsql.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&fromsql, current_depth));
+                nodes.push(NestedNode {
+                    node: fromsql,
+                    depth: current_depth,
+                });
+            }
 
-            let tosql = NodeEnum::ObjectWithArgs(n.tosql.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&tosql, current_depth));
-            nodes.push(NestedNode {
-                node: tosql,
-                depth: current_depth,
-            });
+            if n.tosql.is_some() {
+                let tosql = NodeEnum::ObjectWithArgs(n.tosql.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&tosql, current_depth));
+                nodes.push(NestedNode {
+                    node: tosql,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -3886,7 +5836,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .handler_name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3899,7 +5857,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3907,7 +5873,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .pubobjects
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3920,7 +5894,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3928,7 +5910,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .pubobjects
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3941,7 +5931,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .publication
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3949,7 +5947,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3962,7 +5968,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .publication
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3970,7 +5984,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3987,7 +6009,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .defnames
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -3995,7 +6025,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .stat_types
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4003,7 +6041,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .exprs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4011,7 +6057,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .relations
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4023,7 +6077,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .collname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4031,25 +6093,37 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::CallStmt(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let funccall = NodeEnum::FuncCall(n.funccall.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&funccall, current_depth));
-            nodes.push(NestedNode {
-                node: funccall,
-                depth: current_depth,
-            });
+            if n.funccall.is_some() {
+                let funccall = NodeEnum::FuncCall(n.funccall.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&funccall, current_depth));
+                nodes.push(NestedNode {
+                    node: funccall,
+                    depth: current_depth,
+                });
+            }
 
-            let funcexpr = NodeEnum::FuncExpr(n.funcexpr.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&funcexpr, current_depth));
-            nodes.push(NestedNode {
-                node: funcexpr,
-                depth: current_depth,
-            });
+            if n.funcexpr.is_some() {
+                let funcexpr = NodeEnum::FuncExpr(n.funcexpr.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&funcexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: funcexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .outargs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4061,7 +6135,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .defnames
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4074,23 +6156,35 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .name
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let lexpr = n.lexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&lexpr, current_depth));
-            nodes.push(NestedNode {
-                node: lexpr,
-                depth: current_depth,
-            });
+            if n.lexpr.is_some() {
+                let lexpr = n.lexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&lexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: lexpr,
+                    depth: current_depth,
+                });
+            }
 
-            let rexpr = n.rexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&rexpr, current_depth));
-            nodes.push(NestedNode {
-                node: rexpr,
-                depth: current_depth,
-            });
+            if n.rexpr.is_some() {
+                let rexpr = n.rexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&rexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: rexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -4100,7 +6194,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .fields
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4117,7 +6219,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .funcname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4125,7 +6235,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4133,23 +6251,35 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .agg_order
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let agg_filter = n.agg_filter.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&agg_filter, current_depth));
-            nodes.push(NestedNode {
-                node: agg_filter,
-                depth: current_depth,
-            });
+            if n.agg_filter.is_some() {
+                let agg_filter = n.agg_filter.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&agg_filter, current_depth));
+                nodes.push(NestedNode {
+                    node: agg_filter,
+                    depth: current_depth,
+                });
+            }
 
-            let over = NodeEnum::WindowDef(n.over.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&over, current_depth));
-            nodes.push(NestedNode {
-                node: over,
-                depth: current_depth,
-            });
+            if n.over.is_some() {
+                let over = NodeEnum::WindowDef(n.over.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&over, current_depth));
+                nodes.push(NestedNode {
+                    node: over,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -4160,36 +6290,50 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::AIndices(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let lidx = n.lidx.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&lidx, current_depth));
-            nodes.push(NestedNode {
-                node: lidx,
-                depth: current_depth,
-            });
+            if n.lidx.is_some() {
+                let lidx = n.lidx.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&lidx, current_depth));
+                nodes.push(NestedNode {
+                    node: lidx,
+                    depth: current_depth,
+                });
+            }
 
-            let uidx = n.uidx.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&uidx, current_depth));
-            nodes.push(NestedNode {
-                node: uidx,
-                depth: current_depth,
-            });
+            if n.uidx.is_some() {
+                let uidx = n.uidx.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&uidx, current_depth));
+                nodes.push(NestedNode {
+                    node: uidx,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::AIndirection(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .indirection
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4201,7 +6345,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .elements
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4214,62 +6366,88 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .indirection
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let val = n.val.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&val, current_depth));
-            nodes.push(NestedNode {
-                node: val,
-                depth: current_depth,
-            });
+            if n.val.is_some() {
+                let val = n.val.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&val, current_depth));
+                nodes.push(NestedNode {
+                    node: val,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::MultiAssignRef(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let source = n.source.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&source, current_depth));
-            nodes.push(NestedNode {
-                node: source,
-                depth: current_depth,
-            });
+            if n.source.is_some() {
+                let source = n.source.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&source, current_depth));
+                nodes.push(NestedNode {
+                    node: source,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::TypeCast(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
-            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&type_name, current_depth));
-            nodes.push(NestedNode {
-                node: type_name,
-                depth: current_depth,
-            });
+            if n.type_name.is_some() {
+                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&type_name, current_depth));
+                nodes.push(NestedNode {
+                    node: type_name,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::CollateClause(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .collname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4277,18 +6455,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::SortBy(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let node = n.node.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&node, current_depth));
-            nodes.push(NestedNode {
-                node: node,
-                depth: current_depth,
-            });
+            if n.node.is_some() {
+                let node = n.node.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&node, current_depth));
+                nodes.push(NestedNode {
+                    node: node,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .use_op
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4301,7 +6489,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .partition_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4309,42 +6505,58 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .order_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let start_offset = n.start_offset.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&start_offset, current_depth));
-            nodes.push(NestedNode {
-                node: start_offset,
-                depth: current_depth,
-            });
+            if n.start_offset.is_some() {
+                let start_offset = n.start_offset.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&start_offset, current_depth));
+                nodes.push(NestedNode {
+                    node: start_offset,
+                    depth: current_depth,
+                });
+            }
 
-            let end_offset = n.end_offset.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&end_offset, current_depth));
-            nodes.push(NestedNode {
-                node: end_offset,
-                depth: current_depth,
-            });
+            if n.end_offset.is_some() {
+                let end_offset = n.end_offset.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&end_offset, current_depth));
+                nodes.push(NestedNode {
+                    node: end_offset,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::RangeSubselect(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let subquery = n.subquery.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&subquery, current_depth));
-            nodes.push(NestedNode {
-                node: subquery,
-                depth: current_depth,
-            });
+            if n.subquery.is_some() {
+                let subquery = n.subquery.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&subquery, current_depth));
+                nodes.push(NestedNode {
+                    node: subquery,
+                    depth: current_depth,
+                });
+            }
 
-            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&alias, current_depth));
-            nodes.push(NestedNode {
-                node: alias,
-                depth: current_depth,
-            });
+            if n.alias.is_some() {
+                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&alias, current_depth));
+                nodes.push(NestedNode {
+                    node: alias,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -4355,22 +6567,40 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .functions
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&alias, current_depth));
-            nodes.push(NestedNode {
-                node: alias,
-                depth: current_depth,
-            });
+            if n.alias.is_some() {
+                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&alias, current_depth));
+                nodes.push(NestedNode {
+                    node: alias,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .coldeflist
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4378,18 +6608,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::RangeTableSample(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = n.relation.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = n.relation.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .method
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4397,41 +6637,63 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let repeatable = n.repeatable.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&repeatable, current_depth));
-            nodes.push(NestedNode {
-                node: repeatable,
-                depth: current_depth,
-            });
+            if n.repeatable.is_some() {
+                let repeatable = n.repeatable.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&repeatable, current_depth));
+                nodes.push(NestedNode {
+                    node: repeatable,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::RangeTableFunc(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let docexpr = n.docexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&docexpr, current_depth));
-            nodes.push(NestedNode {
-                node: docexpr,
-                depth: current_depth,
-            });
+            if n.docexpr.is_some() {
+                let docexpr = n.docexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&docexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: docexpr,
+                    depth: current_depth,
+                });
+            }
 
-            let rowexpr = n.rowexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&rowexpr, current_depth));
-            nodes.push(NestedNode {
-                node: rowexpr,
-                depth: current_depth,
-            });
+            if n.rowexpr.is_some() {
+                let rowexpr = n.rowexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&rowexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: rowexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .namespaces
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4439,42 +6701,58 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .columns
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&alias, current_depth));
-            nodes.push(NestedNode {
-                node: alias,
-                depth: current_depth,
-            });
+            if n.alias.is_some() {
+                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&alias, current_depth));
+                nodes.push(NestedNode {
+                    node: alias,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::RangeTableFuncCol(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&type_name, current_depth));
-            nodes.push(NestedNode {
-                node: type_name,
-                depth: current_depth,
-            });
+            if n.type_name.is_some() {
+                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&type_name, current_depth));
+                nodes.push(NestedNode {
+                    node: type_name,
+                    depth: current_depth,
+                });
+            }
 
-            let colexpr = n.colexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&colexpr, current_depth));
-            nodes.push(NestedNode {
-                node: colexpr,
-                depth: current_depth,
-            });
+            if n.colexpr.is_some() {
+                let colexpr = n.colexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&colexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: colexpr,
+                    depth: current_depth,
+                });
+            }
 
-            let coldefexpr = n.coldefexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&coldefexpr, current_depth));
-            nodes.push(NestedNode {
-                node: coldefexpr,
-                depth: current_depth,
-            });
+            if n.coldefexpr.is_some() {
+                let coldefexpr = n.coldefexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&coldefexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: coldefexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -4484,7 +6762,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .names
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4492,7 +6778,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .typmods
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4500,7 +6794,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .array_bounds
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4509,47 +6811,66 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::ColumnDef(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&type_name, current_depth));
-            nodes.push(NestedNode {
-                node: type_name,
-                depth: current_depth,
-            });
-
-            let raw_default = n.raw_default.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&raw_default, current_depth));
-            nodes.push(NestedNode {
-                node: raw_default,
-                depth: current_depth,
-            });
-
-            let cooked_default = n.cooked_default.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&cooked_default, current_depth));
-            nodes.push(NestedNode {
-                node: cooked_default,
-                depth: current_depth,
-            });
-
-            let identity_sequence =
-                NodeEnum::RangeVar(n.identity_sequence.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&identity_sequence, current_depth));
-            nodes.push(NestedNode {
-                node: identity_sequence,
-                depth: current_depth,
-            });
-
-            let coll_clause = NodeEnum::CollateClause(n.coll_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&coll_clause, current_depth));
-            nodes.push(NestedNode {
-                node: coll_clause,
-                depth: current_depth,
-            });
+            if n.type_name.is_some() {
+                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&type_name, current_depth));
+                nodes.push(NestedNode {
+                    node: type_name,
+                    depth: current_depth,
+                });
+            }
+
+            if n.raw_default.is_some() {
+                let raw_default = n.raw_default.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&raw_default, current_depth));
+                nodes.push(NestedNode {
+                    node: raw_default,
+                    depth: current_depth,
+                });
+            }
+
+            if n.cooked_default.is_some() {
+                let cooked_default = n.cooked_default.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&cooked_default, current_depth));
+                nodes.push(NestedNode {
+                    node: cooked_default,
+                    depth: current_depth,
+                });
+            }
+
+            if n.identity_sequence.is_some() {
+                let identity_sequence =
+                    NodeEnum::RangeVar(n.identity_sequence.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&identity_sequence, current_depth));
+                nodes.push(NestedNode {
+                    node: identity_sequence,
+                    depth: current_depth,
+                });
+            }
+
+            if n.coll_clause.is_some() {
+                let coll_clause =
+                    NodeEnum::CollateClause(n.coll_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&coll_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: coll_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .constraints
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4557,7 +6878,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .fdwoptions
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4566,18 +6895,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::IndexElem(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&expr, current_depth));
-            nodes.push(NestedNode {
-                node: expr,
-                depth: current_depth,
-            });
+            if n.expr.is_some() {
+                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&expr, current_depth));
+                nodes.push(NestedNode {
+                    node: expr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .collation
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4585,7 +6924,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .opclass
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4593,7 +6940,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .opclassopts
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4602,30 +6957,42 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::StatsElem(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&expr, current_depth));
-            nodes.push(NestedNode {
-                node: expr,
-                depth: current_depth,
-            });
+            if n.expr.is_some() {
+                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&expr, current_depth));
+                nodes.push(NestedNode {
+                    node: expr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::Constraint(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let raw_expr = n.raw_expr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&raw_expr, current_depth));
-            nodes.push(NestedNode {
-                node: raw_expr,
-                depth: current_depth,
-            });
+            if n.raw_expr.is_some() {
+                let raw_expr = n.raw_expr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&raw_expr, current_depth));
+                nodes.push(NestedNode {
+                    node: raw_expr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .keys
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4633,7 +7000,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .including
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4641,7 +7016,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .exclusions
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4649,29 +7032,49 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .options
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
-            let pktable = NodeEnum::RangeVar(n.pktable.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&pktable, current_depth));
-            nodes.push(NestedNode {
-                node: pktable,
-                depth: current_depth,
-            });
+            if n.pktable.is_some() {
+                let pktable = NodeEnum::RangeVar(n.pktable.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&pktable, current_depth));
+                nodes.push(NestedNode {
+                    node: pktable,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .fk_attrs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4679,7 +7082,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .pk_attrs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4687,7 +7098,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .fk_del_set_cols
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4695,7 +7114,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .old_conpfeqop
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4704,38 +7131,52 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::DefElem(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&arg, current_depth));
-            nodes.push(NestedNode {
-                node: arg,
-                depth: current_depth,
-            });
+            if n.arg.is_some() {
+                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&arg, current_depth));
+                nodes.push(NestedNode {
+                    node: arg,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::RangeTblEntry(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let tablesample =
-                NodeEnum::TableSampleClause(n.tablesample.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&tablesample, current_depth));
-            nodes.push(NestedNode {
-                node: tablesample,
-                depth: current_depth,
-            });
+            if n.tablesample.is_some() {
+                let tablesample =
+                    NodeEnum::TableSampleClause(n.tablesample.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&tablesample, current_depth));
+                nodes.push(NestedNode {
+                    node: tablesample,
+                    depth: current_depth,
+                });
+            }
 
-            let subquery = NodeEnum::Query(n.subquery.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&subquery, current_depth));
-            nodes.push(NestedNode {
-                node: subquery,
-                depth: current_depth,
-            });
+            if n.subquery.is_some() {
+                let subquery = NodeEnum::Query(n.subquery.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&subquery, current_depth));
+                nodes.push(NestedNode {
+                    node: subquery,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .joinaliasvars
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4743,7 +7184,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .joinleftcols
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4751,37 +7200,66 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .joinrightcols
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let join_using_alias = NodeEnum::Alias(n.join_using_alias.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&join_using_alias, current_depth));
-            nodes.push(NestedNode {
-                node: join_using_alias,
-                depth: current_depth,
-            });
+            if n.join_using_alias.is_some() {
+                let join_using_alias =
+                    NodeEnum::Alias(n.join_using_alias.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&join_using_alias, current_depth));
+                nodes.push(NestedNode {
+                    node: join_using_alias,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .functions
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let tablefunc = NodeEnum::TableFunc(n.tablefunc.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&tablefunc, current_depth));
-            nodes.push(NestedNode {
-                node: tablefunc,
-                depth: current_depth,
-            });
+            if n.tablefunc.is_some() {
+                let tablefunc = NodeEnum::TableFunc(n.tablefunc.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&tablefunc, current_depth));
+                nodes.push(NestedNode {
+                    node: tablefunc,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .values_lists
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4789,7 +7267,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .coltypes
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4797,7 +7283,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .coltypmods
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4805,29 +7299,49 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .colcollations
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&alias, current_depth));
-            nodes.push(NestedNode {
-                node: alias,
-                depth: current_depth,
-            });
+            if n.alias.is_some() {
+                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&alias, current_depth));
+                nodes.push(NestedNode {
+                    node: alias,
+                    depth: current_depth,
+                });
+            }
 
-            let eref = NodeEnum::Alias(n.eref.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&eref, current_depth));
-            nodes.push(NestedNode {
-                node: eref,
-                depth: current_depth,
-            });
+            if n.eref.is_some() {
+                let eref = NodeEnum::Alias(n.eref.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&eref, current_depth));
+                nodes.push(NestedNode {
+                    node: eref,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .security_quals
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4835,18 +7349,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         }
         NodeEnum::RangeTblFunction(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let funcexpr = n.funcexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&funcexpr, current_depth));
-            nodes.push(NestedNode {
-                node: funcexpr,
-                depth: current_depth,
-            });
+            if n.funcexpr.is_some() {
+                let funcexpr = n.funcexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&funcexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: funcexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .funccolnames
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4854,7 +7378,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .funccoltypes
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4862,7 +7394,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .funccoltypmods
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4870,7 +7410,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .funccolcollations
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4883,28 +7431,40 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let repeatable = n.repeatable.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&repeatable, current_depth));
-            nodes.push(NestedNode {
-                node: repeatable,
-                depth: current_depth,
-            });
+            if n.repeatable.is_some() {
+                let repeatable = n.repeatable.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&repeatable, current_depth));
+                nodes.push(NestedNode {
+                    node: repeatable,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::WithCheckOption(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&qual, current_depth));
-            nodes.push(NestedNode {
-                node: qual,
-                depth: current_depth,
-            });
+            if n.qual.is_some() {
+                let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&qual, current_depth));
+                nodes.push(NestedNode {
+                    node: qual,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -4920,7 +7480,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .content
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4933,7 +7501,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .partition_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4941,29 +7517,49 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .order_clause
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let start_offset = n.start_offset.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&start_offset, current_depth));
-            nodes.push(NestedNode {
-                node: start_offset,
-                depth: current_depth,
-            });
+            if n.start_offset.is_some() {
+                let start_offset = n.start_offset.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&start_offset, current_depth));
+                nodes.push(NestedNode {
+                    node: start_offset,
+                    depth: current_depth,
+                });
+            }
 
-            let end_offset = n.end_offset.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&end_offset, current_depth));
-            nodes.push(NestedNode {
-                node: end_offset,
-                depth: current_depth,
-            });
+            if n.end_offset.is_some() {
+                let end_offset = n.end_offset.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&end_offset, current_depth));
+                nodes.push(NestedNode {
+                    node: end_offset,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .run_condition
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4975,7 +7571,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .objname
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4983,7 +7587,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .objargs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -4991,7 +7603,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .objfuncargs
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5004,7 +7624,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .cols
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5013,18 +7641,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::CreateOpClassItem(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let name = NodeEnum::ObjectWithArgs(n.name.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&name, current_depth));
-            nodes.push(NestedNode {
-                node: name,
-                depth: current_depth,
-            });
+            if n.name.is_some() {
+                let name = NodeEnum::ObjectWithArgs(n.name.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&name, current_depth));
+                nodes.push(NestedNode {
+                    node: name,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .order_family
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5032,46 +7670,62 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .class_args
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let storedtype = NodeEnum::TypeName(n.storedtype.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&storedtype, current_depth));
-            nodes.push(NestedNode {
-                node: storedtype,
-                depth: current_depth,
-            });
+            if n.storedtype.is_some() {
+                let storedtype = NodeEnum::TypeName(n.storedtype.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&storedtype, current_depth));
+                nodes.push(NestedNode {
+                    node: storedtype,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::TableLikeClause(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::FunctionParameter(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let arg_type = NodeEnum::TypeName(n.arg_type.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&arg_type, current_depth));
-            nodes.push(NestedNode {
-                node: arg_type,
-                depth: current_depth,
-            });
+            if n.arg_type.is_some() {
+                let arg_type = NodeEnum::TypeName(n.arg_type.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&arg_type, current_depth));
+                nodes.push(NestedNode {
+                    node: arg_type,
+                    depth: current_depth,
+                });
+            }
 
-            let defexpr = n.defexpr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&defexpr, current_depth));
-            nodes.push(NestedNode {
-                node: defexpr,
-                depth: current_depth,
-            });
+            if n.defexpr.is_some() {
+                let defexpr = n.defexpr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&defexpr, current_depth));
+                nodes.push(NestedNode {
+                    node: defexpr,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -5081,7 +7735,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .locked_rels
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5095,19 +7757,23 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::XmlSerialize(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&expr, current_depth));
-            nodes.push(NestedNode {
-                node: expr,
-                depth: current_depth,
-            });
+            if n.expr.is_some() {
+                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&expr, current_depth));
+                nodes.push(NestedNode {
+                    node: expr,
+                    depth: current_depth,
+                });
+            }
 
-            let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&type_name, current_depth));
-            nodes.push(NestedNode {
-                node: type_name,
-                depth: current_depth,
-            });
+            if n.type_name.is_some() {
+                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&type_name, current_depth));
+                nodes.push(NestedNode {
+                    node: type_name,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -5117,7 +7783,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .ctes
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5129,43 +7803,65 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .index_elems
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::OnConflictClause(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let infer = NodeEnum::InferClause(n.infer.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&infer, current_depth));
-            nodes.push(NestedNode {
-                node: infer,
-                depth: current_depth,
-            });
+            if n.infer.is_some() {
+                let infer = NodeEnum::InferClause(n.infer.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&infer, current_depth));
+                nodes.push(NestedNode {
+                    node: infer,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -5175,7 +7871,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .search_col_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5187,35 +7891,47 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .cycle_col_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
-                    .collect(),
-            );
-
-            let cycle_mark_value = n
-                .cycle_mark_value
-                .as_ref()
-                .unwrap()
-                .to_owned()
-                .node
-                .unwrap();
-            nodes.append(&mut get_children(&cycle_mark_value, current_depth));
-            nodes.push(NestedNode {
-                node: cycle_mark_value,
-                depth: current_depth,
-            });
-
-            let cycle_mark_default = n
-                .cycle_mark_default
-                .as_ref()
-                .unwrap()
-                .to_owned()
-                .node
-                .unwrap();
-            nodes.append(&mut get_children(&cycle_mark_default, current_depth));
-            nodes.push(NestedNode {
-                node: cycle_mark_default,
-                depth: current_depth,
-            });
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
+                    .collect(),
+            );
+
+            if n.cycle_mark_value.is_some() {
+                let cycle_mark_value = n
+                    .cycle_mark_value
+                    .as_ref()
+                    .unwrap()
+                    .to_owned()
+                    .node
+                    .unwrap();
+                nodes.append(&mut get_children(&cycle_mark_value, current_depth));
+                nodes.push(NestedNode {
+                    node: cycle_mark_value,
+                    depth: current_depth,
+                });
+            }
+
+            if n.cycle_mark_default.is_some() {
+                let cycle_mark_default = n
+                    .cycle_mark_default
+                    .as_ref()
+                    .unwrap()
+                    .to_owned()
+                    .node
+                    .unwrap();
+                nodes.append(&mut get_children(&cycle_mark_default, current_depth));
+                nodes.push(NestedNode {
+                    node: cycle_mark_default,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
@@ -5226,38 +7942,60 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .aliascolnames
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
-                    .collect(),
-            );
-
-            let ctequery = n.ctequery.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&ctequery, current_depth));
-            nodes.push(NestedNode {
-                node: ctequery,
-                depth: current_depth,
-            });
-
-            let search_clause =
-                NodeEnum::CtesearchClause(n.search_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&search_clause, current_depth));
-            nodes.push(NestedNode {
-                node: search_clause,
-                depth: current_depth,
-            });
-
-            let cycle_clause =
-                NodeEnum::CtecycleClause(n.cycle_clause.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&cycle_clause, current_depth));
-            nodes.push(NestedNode {
-                node: cycle_clause,
-                depth: current_depth,
-            });
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
+                    .collect(),
+            );
+
+            if n.ctequery.is_some() {
+                let ctequery = n.ctequery.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&ctequery, current_depth));
+                nodes.push(NestedNode {
+                    node: ctequery,
+                    depth: current_depth,
+                });
+            }
+
+            if n.search_clause.is_some() {
+                let search_clause =
+                    NodeEnum::CtesearchClause(n.search_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&search_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: search_clause,
+                    depth: current_depth,
+                });
+            }
+
+            if n.cycle_clause.is_some() {
+                let cycle_clause =
+                    NodeEnum::CtecycleClause(n.cycle_clause.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&cycle_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: cycle_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .ctecolnames
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5265,7 +8003,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .ctecoltypes
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5273,7 +8019,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .ctecoltypmods
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5281,7 +8035,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .ctecolcollations
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5290,18 +8052,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::MergeWhenClause(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let condition = n.condition.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&condition, current_depth));
-            nodes.push(NestedNode {
-                node: condition,
-                depth: current_depth,
-            });
+            if n.condition.is_some() {
+                let condition = n.condition.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&condition, current_depth));
+                nodes.push(NestedNode {
+                    node: condition,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .target_list
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5309,7 +8081,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .values
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5328,18 +8108,28 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::PartitionElem(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&expr, current_depth));
-            nodes.push(NestedNode {
-                node: expr,
-                depth: current_depth,
-            });
+            if n.expr.is_some() {
+                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&expr, current_depth));
+                nodes.push(NestedNode {
+                    node: expr,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .collation
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5347,7 +8137,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .opclass
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5360,7 +8158,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .part_params
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5373,7 +8179,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .listdatums
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5381,7 +8195,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .lowerdatums
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5389,7 +8211,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .upperdatums
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5398,47 +8228,63 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::PartitionRangeDatum(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let value = n.value.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&value, current_depth));
-            nodes.push(NestedNode {
-                node: value,
-                depth: current_depth,
-            });
+            if n.value.is_some() {
+                let value = n.value.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&value, current_depth));
+                nodes.push(NestedNode {
+                    node: value,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::PartitionCmd(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let name = NodeEnum::RangeVar(n.name.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&name, current_depth));
-            nodes.push(NestedNode {
-                node: name,
-                depth: current_depth,
-            });
+            if n.name.is_some() {
+                let name = NodeEnum::RangeVar(n.name.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&name, current_depth));
+                nodes.push(NestedNode {
+                    node: name,
+                    depth: current_depth,
+                });
+            }
 
-            let bound = NodeEnum::PartitionBoundSpec(n.bound.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&bound, current_depth));
-            nodes.push(NestedNode {
-                node: bound,
-                depth: current_depth,
-            });
+            if n.bound.is_some() {
+                let bound = NodeEnum::PartitionBoundSpec(n.bound.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&bound, current_depth));
+                nodes.push(NestedNode {
+                    node: bound,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::VacuumRelation(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .va_cols
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5447,36 +8293,50 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
         NodeEnum::PublicationObjSpec(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
 
-            let pubtable = NodeEnum::PublicationTable(n.pubtable.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&pubtable, current_depth));
-            nodes.push(NestedNode {
-                node: pubtable,
-                depth: current_depth,
-            });
+            if n.pubtable.is_some() {
+                let pubtable = NodeEnum::PublicationTable(n.pubtable.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&pubtable, current_depth));
+                nodes.push(NestedNode {
+                    node: pubtable,
+                    depth: current_depth,
+                });
+            }
 
             nodes
         }
         NodeEnum::PublicationTable(n) => {
             let mut nodes: Vec<NestedNode> = vec![];
-            let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-            nodes.append(&mut get_children(&relation, current_depth));
-            nodes.push(NestedNode {
-                node: relation,
-                depth: current_depth,
-            });
+            if n.relation.is_some() {
+                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
+                nodes.append(&mut get_children(&relation, current_depth));
+                nodes.push(NestedNode {
+                    node: relation,
+                    depth: current_depth,
+                });
+            }
 
-            let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-            nodes.append(&mut get_children(&where_clause, current_depth));
-            nodes.push(NestedNode {
-                node: where_clause,
-                depth: current_depth,
-            });
+            if n.where_clause.is_some() {
+                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
+                nodes.append(&mut get_children(&where_clause, current_depth));
+                nodes.push(NestedNode {
+                    node: where_clause,
+                    depth: current_depth,
+                });
+            }
 
             nodes.append(
                 &mut n
                     .columns
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5523,7 +8383,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5535,7 +8403,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
@@ -5547,7 +8423,15 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 &mut n
                     .items
                     .iter()
-                    .flat_map(|x| get_children(&x.node.as_ref().unwrap(), current_depth))
+                    .flat_map(|x| {
+                        let mut result = vec![];
+                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
+                        result.push(NestedNode {
+                            node: x.node.as_ref().unwrap().to_owned(),
+                            depth: current_depth,
+                        });
+                        result
+                    })
                     .collect(),
             );
 
diff --git a/crates/parser/src/pg_query_utils_generated_test.rs b/crates/parser/src/pg_query_utils_generated_test.rs
index e07f2f4e..63670e11 100644
--- a/crates/parser/src/pg_query_utils_generated_test.rs
+++ b/crates/parser/src/pg_query_utils_generated_test.rs
@@ -10,7 +10,7 @@ mod tests {
 
     #[test]
     fn test_get_children() {
-        let input = "with t as (insert into contact (id) values ('id')) select * from t;";
+        let input = "select id;";
 
         let pg_query_root = match pg_query::parse(input) {
             Ok(parsed) => {
@@ -33,8 +33,17 @@ mod tests {
             Err(_) => None,
         };
 
+        println!("{:?}", pg_query_root);
+
         let result = get_children(&pg_query_root.unwrap(), 1);
 
-        result.iter().for_each(|n| println!("{:?}", n));
+        println!("NUMBER OF CHILDREN: {:?}", result.len());
+
+        // TODO: parse AConst correctly
+
+        result.iter().for_each(|n| {
+            println!("##");
+            println!("{:?}", n)
+        });
     }
 }
diff --git a/crates/sourcegen/src/struct_.rs b/crates/sourcegen/src/struct_.rs
index d5376481..382d5953 100644
--- a/crates/sourcegen/src/struct_.rs
+++ b/crates/sourcegen/src/struct_.rs
@@ -12,11 +12,13 @@ pub struct Struct {
     name: String,
     fields: Vec<StructField>,
     public: bool,
+    attributes: Vec<String>,
 }
 
 impl Builder for Struct {
     fn finish(&mut self) -> String {
         let mut result = String::new();
+        result.push_str(&self.attributes.join("\n"));
         if self.public {
             result.push_str("pub ");
         }
@@ -50,6 +52,7 @@ impl Struct {
             name,
             fields: Vec::new(),
             public: false,
+            attributes: Vec::new(),
         }
     }
 
@@ -62,6 +65,11 @@ impl Struct {
         self.fields.push(StructField { name, type_ });
         self
     }
+
+    pub fn with_attribute(&mut self, attribute: String) -> &mut Self {
+        self.attributes.push(attribute);
+        self
+    }
 }
 
 #[cfg(test)]

From 14802c077d49c4dd054e2676529a0318c2c1b816 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Wed, 9 Aug 2023 16:39:41 +0200
Subject: [PATCH 05/23] refactor: dont use recursion

---
 crates/parser/src/bin/generate.rs             |   201 +-
 crates/parser/src/pg_query_utils_generated.rs | 13202 ++++++----------
 .../src/pg_query_utils_generated_test.rs      |    72 +-
 3 files changed, 5204 insertions(+), 8271 deletions(-)

diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
index c0d04167..be9b1f88 100644
--- a/crates/parser/src/bin/generate.rs
+++ b/crates/parser/src/bin/generate.rs
@@ -78,8 +78,8 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
             // .with_field("location".to_string(), "i32".to_string())
             .finish()
         )
-        // TODO: 1) always use match or if .is_some() when unwrapping a node and ignore if none
-        // TODO: 1.2) parse AConst manually
+        // TODO: 1) make it a non-recursive fn because recursiveness in rust ist bad.
+        //          --> for loop with array to put next iteration in.
         // TODO: 2) add location to NestedNode, and use it in get_children.
         // TODO:    to get location, first check if node has location field.
         // TODO:    if not, use the location of the parent.
@@ -97,91 +97,126 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                 .with_parameter("current_depth".to_string(), Some("i32".to_string()))
                 .with_return_type("Vec<NestedNode>".to_string())
                 .with(|b| {
-                    let mut content = "let current_depth = current_depth + 1;".to_string();
+                    let mut content = "let mut nodes: Vec<NestedNode> = vec![];\n".to_string();
+                    content.push_str("// Node, depth, location\n");
+                    content.push_str("let mut stack: Vec<(NodeEnum, i32)> = vec![(node.to_owned(), current_depth)];\n");
+                    content.push_str("while stack.len() > 0 {\n");
+                    content.push_str("let (node, depth) = stack.pop().unwrap();\n");
+                    content.push_str("let current_depth = depth + 1;\n");
+
                     let match_ = Match::new("&node".to_string())
                         .with(|b| {
                             f.nodes.iter().for_each(|node| {
-                                let mut content = "".to_string();
-                                content.push_str("{\n");
-                                content.push_str(
-                                    "let mut nodes: Vec<NestedNode> = vec![];\n",
-                                );
-                                node.fields.iter().for_each(|field| {
-                                    if field.field_type == FieldType::Node && field.repeated {
-                                        content.push_str(
-                                            format!(
-                                                "nodes.append(&mut n.{}.iter().flat_map(|x| {{
-                                                    let mut result = vec![];
-                                                    result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                                                    result.push(NestedNode {{ node: x.node.as_ref().unwrap().to_owned(), depth: current_depth }});
-                                                    result
-                                                }}).collect());\n",
-                                                field.name.to_string()
-                                            ).as_str()
-                                        );
-                                    } else if field.field_type == FieldType::Node && field.is_one_of == false {
-                                        if field.node_name == Some("Node".to_owned()) {
-                                            content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
-                                            content.push_str(
-                                                format!(
-                                                    "let {} = n.{}.as_ref().unwrap().to_owned().node.unwrap();\n",
-                                                    field.name.to_string(),
-                                                    field.name.to_string(),
-                                                ).as_str(),
-                                            );
-                                            content.push_str(
-                                                format!(
-                                                    "nodes.append(&mut get_children(&{}, current_depth));\n",
-                                                    field.name.to_string()
-                                                ).as_str(),
+                                if node.name == "AConst" {
+                                    // AConst is the only node with one of, so we handle it
+                                    // manually
+                                    let content = "{
+            if n.val.is_some() {
+                let value = match n.val.to_owned().unwrap() {
+                    pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
+                    pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
+                    pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
+                    pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
+                    pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
+                };
 
-                                            );
-                                            content.push_str(
+                nodes.push(NestedNode {
+                    node: value,
+                    depth: current_depth,
+                });
+            }
+        }";
+
+                                    b.with_arm(
+                                        format!("NodeEnum::{}(n)", node.name.to_string()),
+                                        format!("{}", content),
+                                    );
+                                } else {
+                                    let mut field_content: Vec<String> = vec![];
+                                    node.fields.iter().for_each(|field| {
+                                        if field.field_type == FieldType::Node && field.repeated {
+                                            field_content.push(
                                                 format!(
-                                                    "nodes.push(NestedNode {{
-                                                        node: {},
-                                                        depth: current_depth,
+                                                    "n.{}.iter().for_each(|x| {{
+                                                        stack.push((x.node.to_owned().unwrap(), current_depth));
+                                                        nodes.push(NestedNode {{ node: x.node.to_owned().unwrap(), depth: current_depth }});
                                                     }});\n",
                                                     field.name.to_string()
-                                                ).as_str(),
-                                            );
-                                            content.push_str("}\n");
-                                        } else {
-                                            content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
-                                            content.push_str(
-                                                format!(
-                                                    "let {} = NodeEnum::{}(n.{}.as_ref().unwrap().to_owned());\n",
-                                                    field.name.to_string(),
-                                                    field.enum_variant_name.as_ref().unwrap(),
-                                                    field.name.to_string()
                                                 )
-                                                .as_str()
-                                            );
-                                            content.push_str(
-                                                format!(
-                                                    "nodes.append(&mut get_children(&{}, current_depth));\n",
-                                                    field.name.to_string()
-                                                ).as_str()
-                                            );
-                                            content.push_str(
-                                                format!(
-                                                    "nodes.push(NestedNode {{
-                                                        node: {},
-                                                        depth: current_depth,
-                                                    }});\n",
-                                                    field.name.to_string()
-                                                ).as_str()
                                             );
-                                            content.push_str("}\n");
+                                        } else if field.field_type == FieldType::Node && field.is_one_of == false {
+                                            if field.node_name == Some("Node".to_owned()) {
+                                                let mut node_content = "".to_string();
+                                                node_content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
+                                                node_content.push_str(
+                                                    format!(
+                                                        "let {} = n.{}.to_owned().unwrap().node.unwrap();\n",
+                                                        field.name.to_string(),
+                                                        field.name.to_string(),
+                                                    ).as_str(),
+                                                );
+                                                node_content.push_str(
+                                                    format!(
+                                                        "stack.push(({}.to_owned(), current_depth));\n",
+                                                        field.name.to_string()
+                                                    ).as_str(),
+
+                                                );
+                                                node_content.push_str(
+                                                    format!(
+                                                        "nodes.push(NestedNode {{
+                                                            node: {},
+                                                            depth: current_depth,
+                                                        }});\n",
+                                                        field.name.to_string()
+                                                    ).as_str(),
+                                                );
+                                                node_content.push_str("}\n");
+                                                field_content.push(node_content);
+                                            } else {
+                                                let mut node_content = "".to_string();
+                                                node_content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
+                                                node_content.push_str(
+                                                    format!(
+                                                        "let {} = NodeEnum::{}(n.{}.to_owned().unwrap());\n",
+                                                        field.name.to_string(),
+                                                        field.enum_variant_name.as_ref().unwrap(),
+                                                        field.name.to_string()
+                                                    )
+                                                    .as_str()
+                                                );
+                                                node_content.push_str(
+                                                    format!(
+                                                        "stack.push(({}.to_owned(), current_depth));\n",
+                                                        field.name.to_string()
+                                                    ).as_str()
+                                                );
+                                                node_content.push_str(
+                                                    format!(
+                                                        "nodes.push(NestedNode {{
+                                                            node: {},
+                                                            depth: current_depth,
+                                                        }});\n",
+                                                        field.name.to_string()
+                                                    ).as_str()
+                                                );
+                                                node_content.push_str("}\n");
+                                                field_content.push(node_content);
+                                            }
                                         }
-                                    }
-                                    content.push_str("\n");
-                                });
-                                content.push_str("nodes\n}");
-                                b.with_arm(
-                                    format!("NodeEnum::{}(n)", node.name.to_string()),
-                                    format!("{}", content),
-                                );
+                                    });
+
+                                    let content = if field_content.len() > 0 {
+                                        format!("{{\n{}\n}}", field_content.join("\n"))
+                                    } else {
+                                        "()".to_string()
+                                    };
+
+                                    b.with_arm(
+                                        format!("NodeEnum::{}(n)", node.name.to_string()),
+                                        format!("{}", content),
+                                    );
+                                }
                             });
 
                             b
@@ -189,6 +224,18 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                         .finish();
 
                     content.push_str(match_.to_string().as_str());
+                    content.push_str(";\n");
+
+
+
+
+                    content.push_str("}\n");
+                    content.push_str("nodes");
+
+
+
+
+
 
                     b.with_body(content);
 
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index 55f42906..146647dc 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -253,8194 +253,5018 @@ pub struct NestedNode {
 
 /// Returns all children of the node, recursively
 pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
-    let current_depth = current_depth + 1;
-    match &node {
-        NodeEnum::Alias(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .colnames
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RangeVar(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.alias.is_some() {
-                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&alias, current_depth));
-                nodes.push(NestedNode {
-                    node: alias,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::TableFunc(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .ns_uris
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .ns_names
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.docexpr.is_some() {
-                let docexpr = n.docexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&docexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: docexpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.rowexpr.is_some() {
-                let rowexpr = n.rowexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&rowexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: rowexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .colnames
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .coltypes
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .coltypmods
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .colcollations
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .colexprs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .coldefexprs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::Var(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::Param(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::Aggref(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .aggargtypes
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .aggdirectargs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .aggorder
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .aggdistinct
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.aggfilter.is_some() {
-                let aggfilter = n.aggfilter.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&aggfilter, current_depth));
-                nodes.push(NestedNode {
-                    node: aggfilter,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::GroupingFunc(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .refs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .cols
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::WindowFunc(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.aggfilter.is_some() {
-                let aggfilter = n.aggfilter.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&aggfilter, current_depth));
-                nodes.push(NestedNode {
-                    node: aggfilter,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::SubscriptingRef(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .refupperindexpr
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .reflowerindexpr
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.refexpr.is_some() {
-                let refexpr = n.refexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&refexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: refexpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.refassgnexpr.is_some() {
-                let refassgnexpr = n.refassgnexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&refassgnexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: refassgnexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::FuncExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::NamedArgExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::OpExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DistinctExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::NullIfExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ScalarArrayOpExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::BoolExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::SubLink(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.testexpr.is_some() {
-                let testexpr = n.testexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&testexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: testexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .oper_name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.subselect.is_some() {
-                let subselect = n.subselect.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&subselect, current_depth));
-                nodes.push(NestedNode {
-                    node: subselect,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::SubPlan(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.testexpr.is_some() {
-                let testexpr = n.testexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&testexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: testexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .param_ids
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .set_param
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .par_param
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlternativeSubPlan(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .subplans
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::FieldSelect(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::FieldStore(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .newvals
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .fieldnums
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RelabelType(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CoerceViaIo(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::ArrayCoerceExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            if n.elemexpr.is_some() {
-                let elemexpr = n.elemexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&elemexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: elemexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::ConvertRowtypeExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CollateExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CaseExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.defresult.is_some() {
-                let defresult = n.defresult.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&defresult, current_depth));
-                nodes.push(NestedNode {
-                    node: defresult,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CaseWhen(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.expr.is_some() {
-                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&expr, current_depth));
-                nodes.push(NestedNode {
-                    node: expr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.result.is_some() {
-                let result = n.result.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&result, current_depth));
-                nodes.push(NestedNode {
-                    node: result,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CaseTestExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::ArrayExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .elements
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RowExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .colnames
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RowCompareExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .opnos
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .opfamilies
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .inputcollids
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .largs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .rargs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CoalesceExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::MinMaxExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::SqlvalueFunction(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::XmlExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .named_args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .arg_names
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::NullTest(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::BooleanTest(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CoerceToDomain(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CoerceToDomainValue(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::SetToDefault(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CurrentOfExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::NextValueExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::InferenceElem(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.expr.is_some() {
-                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&expr, current_depth));
-                nodes.push(NestedNode {
-                    node: expr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::TargetEntry(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.xpr.is_some() {
-                let xpr = n.xpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&xpr, current_depth));
-                nodes.push(NestedNode {
-                    node: xpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.expr.is_some() {
-                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&expr, current_depth));
-                nodes.push(NestedNode {
-                    node: expr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::RangeTblRef(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::JoinExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.larg.is_some() {
-                let larg = n.larg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&larg, current_depth));
-                nodes.push(NestedNode {
-                    node: larg,
-                    depth: current_depth,
-                });
-            }
-
-            if n.rarg.is_some() {
-                let rarg = n.rarg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&rarg, current_depth));
-                nodes.push(NestedNode {
-                    node: rarg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .using_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.join_using_alias.is_some() {
-                let join_using_alias =
-                    NodeEnum::Alias(n.join_using_alias.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&join_using_alias, current_depth));
-                nodes.push(NestedNode {
-                    node: join_using_alias,
-                    depth: current_depth,
-                });
-            }
-
-            if n.quals.is_some() {
-                let quals = n.quals.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&quals, current_depth));
-                nodes.push(NestedNode {
-                    node: quals,
-                    depth: current_depth,
-                });
-            }
-
-            if n.alias.is_some() {
-                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&alias, current_depth));
-                nodes.push(NestedNode {
-                    node: alias,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::FromExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .fromlist
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.quals.is_some() {
-                let quals = n.quals.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&quals, current_depth));
-                nodes.push(NestedNode {
-                    node: quals,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::OnConflictExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .arbiter_elems
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.arbiter_where.is_some() {
-                let arbiter_where = n.arbiter_where.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arbiter_where, current_depth));
-                nodes.push(NestedNode {
-                    node: arbiter_where,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .on_conflict_set
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.on_conflict_where.is_some() {
-                let on_conflict_where = n
-                    .on_conflict_where
-                    .as_ref()
-                    .unwrap()
-                    .to_owned()
-                    .node
-                    .unwrap();
-                nodes.append(&mut get_children(&on_conflict_where, current_depth));
-                nodes.push(NestedNode {
-                    node: on_conflict_where,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .excl_rel_tlist
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::IntoClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.rel.is_some() {
-                let rel = NodeEnum::RangeVar(n.rel.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&rel, current_depth));
-                nodes.push(NestedNode {
-                    node: rel,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .col_names
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.view_query.is_some() {
-                let view_query = n.view_query.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&view_query, current_depth));
-                nodes.push(NestedNode {
-                    node: view_query,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::MergeAction(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.qual.is_some() {
-                let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&qual, current_depth));
-                nodes.push(NestedNode {
-                    node: qual,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .target_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .update_colnos
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RawStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.stmt.is_some() {
-                let stmt = n.stmt.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&stmt, current_depth));
-                nodes.push(NestedNode {
-                    node: stmt,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::Query(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.utility_stmt.is_some() {
-                let utility_stmt = n.utility_stmt.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&utility_stmt, current_depth));
-                nodes.push(NestedNode {
-                    node: utility_stmt,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .cte_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .rtable
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.jointree.is_some() {
-                let jointree = NodeEnum::FromExpr(n.jointree.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&jointree, current_depth));
-                nodes.push(NestedNode {
-                    node: jointree,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .merge_action_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .target_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.on_conflict.is_some() {
-                let on_conflict =
-                    NodeEnum::OnConflictExpr(n.on_conflict.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&on_conflict, current_depth));
-                nodes.push(NestedNode {
-                    node: on_conflict,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .returning_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .group_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .grouping_sets
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.having_qual.is_some() {
-                let having_qual = n.having_qual.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&having_qual, current_depth));
-                nodes.push(NestedNode {
-                    node: having_qual,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .window_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .distinct_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .sort_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.limit_offset.is_some() {
-                let limit_offset = n.limit_offset.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&limit_offset, current_depth));
-                nodes.push(NestedNode {
-                    node: limit_offset,
-                    depth: current_depth,
-                });
-            }
-
-            if n.limit_count.is_some() {
-                let limit_count = n.limit_count.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&limit_count, current_depth));
-                nodes.push(NestedNode {
-                    node: limit_count,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .row_marks
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.set_operations.is_some() {
-                let set_operations = n.set_operations.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&set_operations, current_depth));
-                nodes.push(NestedNode {
-                    node: set_operations,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .constraint_deps
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .with_check_options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::InsertStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .cols
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.select_stmt.is_some() {
-                let select_stmt = n.select_stmt.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&select_stmt, current_depth));
-                nodes.push(NestedNode {
-                    node: select_stmt,
-                    depth: current_depth,
-                });
-            }
-
-            if n.on_conflict_clause.is_some() {
-                let on_conflict_clause =
-                    NodeEnum::OnConflictClause(n.on_conflict_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&on_conflict_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: on_conflict_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .returning_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.with_clause.is_some() {
-                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&with_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: with_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::DeleteStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .using_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .returning_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.with_clause.is_some() {
-                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&with_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: with_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::UpdateStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .target_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .from_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .returning_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.with_clause.is_some() {
-                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&with_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: with_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::MergeStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            if n.source_relation.is_some() {
-                let source_relation = n.source_relation.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&source_relation, current_depth));
-                nodes.push(NestedNode {
-                    node: source_relation,
-                    depth: current_depth,
-                });
-            }
-
-            if n.join_condition.is_some() {
-                let join_condition = n.join_condition.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&join_condition, current_depth));
-                nodes.push(NestedNode {
-                    node: join_condition,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .merge_when_clauses
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.with_clause.is_some() {
-                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&with_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: with_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::SelectStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .distinct_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.into_clause.is_some() {
-                let into_clause = NodeEnum::IntoClause(n.into_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&into_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: into_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .target_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .from_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .group_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.having_clause.is_some() {
-                let having_clause = n.having_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&having_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: having_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .window_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .values_lists
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .sort_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.limit_offset.is_some() {
-                let limit_offset = n.limit_offset.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&limit_offset, current_depth));
-                nodes.push(NestedNode {
-                    node: limit_offset,
-                    depth: current_depth,
-                });
-            }
-
-            if n.limit_count.is_some() {
-                let limit_count = n.limit_count.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&limit_count, current_depth));
-                nodes.push(NestedNode {
-                    node: limit_count,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .locking_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.with_clause.is_some() {
-                let with_clause = NodeEnum::WithClause(n.with_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&with_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: with_clause,
-                    depth: current_depth,
-                });
-            }
-
-            if n.larg.is_some() {
-                let larg = NodeEnum::SelectStmt(n.larg.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&larg, current_depth));
-                nodes.push(NestedNode {
-                    node: larg,
-                    depth: current_depth,
-                });
-            }
-
-            if n.rarg.is_some() {
-                let rarg = NodeEnum::SelectStmt(n.rarg.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&rarg, current_depth));
-                nodes.push(NestedNode {
-                    node: rarg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::ReturnStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.returnval.is_some() {
-                let returnval = n.returnval.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&returnval, current_depth));
-                nodes.push(NestedNode {
-                    node: returnval,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::PlassignStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .indirection
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.val.is_some() {
-                let val = NodeEnum::SelectStmt(n.val.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&val, current_depth));
-                nodes.push(NestedNode {
-                    node: val,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterTableStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .cmds
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterTableCmd(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.newowner.is_some() {
-                let newowner = NodeEnum::RoleSpec(n.newowner.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&newowner, current_depth));
-                nodes.push(NestedNode {
-                    node: newowner,
-                    depth: current_depth,
-                });
-            }
-
-            if n.def.is_some() {
-                let def = n.def.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&def, current_depth));
-                nodes.push(NestedNode {
-                    node: def,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterDomainStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .type_name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.def.is_some() {
-                let def = n.def.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&def, current_depth));
-                nodes.push(NestedNode {
-                    node: def,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::SetOperationStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.larg.is_some() {
-                let larg = n.larg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&larg, current_depth));
-                nodes.push(NestedNode {
-                    node: larg,
-                    depth: current_depth,
-                });
-            }
-
-            if n.rarg.is_some() {
-                let rarg = n.rarg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&rarg, current_depth));
-                nodes.push(NestedNode {
-                    node: rarg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .col_types
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .col_typmods
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .col_collations
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .group_clauses
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::GrantStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .objects
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .privileges
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .grantees
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.grantor.is_some() {
-                let grantor = NodeEnum::RoleSpec(n.grantor.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&grantor, current_depth));
-                nodes.push(NestedNode {
-                    node: grantor,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::GrantRoleStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .granted_roles
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .grantee_roles
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.grantor.is_some() {
-                let grantor = NodeEnum::RoleSpec(n.grantor.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&grantor, current_depth));
-                nodes.push(NestedNode {
-                    node: grantor,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterDefaultPrivilegesStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.action.is_some() {
-                let action = NodeEnum::GrantStmt(n.action.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&action, current_depth));
-                nodes.push(NestedNode {
-                    node: action,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::ClosePortalStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::ClusterStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .params
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CopyStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            if n.query.is_some() {
-                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&query, current_depth));
-                nodes.push(NestedNode {
-                    node: query,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .attlist
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreateStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .table_elts
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .inh_relations
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.partbound.is_some() {
-                let partbound =
-                    NodeEnum::PartitionBoundSpec(n.partbound.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&partbound, current_depth));
-                nodes.push(NestedNode {
-                    node: partbound,
-                    depth: current_depth,
-                });
-            }
-
-            if n.partspec.is_some() {
-                let partspec = NodeEnum::PartitionSpec(n.partspec.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&partspec, current_depth));
-                nodes.push(NestedNode {
-                    node: partspec,
-                    depth: current_depth,
-                });
-            }
-
-            if n.of_typename.is_some() {
-                let of_typename = NodeEnum::TypeName(n.of_typename.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&of_typename, current_depth));
-                nodes.push(NestedNode {
-                    node: of_typename,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .constraints
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DefineStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .defnames
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .definition
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DropStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .objects
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::TruncateStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .relations
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CommentStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.object.is_some() {
-                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&object, current_depth));
-                nodes.push(NestedNode {
-                    node: object,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::FetchStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::IndexStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .index_params
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .index_including_params
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .exclude_op_names
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateFunctionStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .funcname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .parameters
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.return_type.is_some() {
-                let return_type = NodeEnum::TypeName(n.return_type.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&return_type, current_depth));
-                nodes.push(NestedNode {
-                    node: return_type,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.sql_body.is_some() {
-                let sql_body = n.sql_body.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&sql_body, current_depth));
-                nodes.push(NestedNode {
-                    node: sql_body,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterFunctionStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.func.is_some() {
-                let func = NodeEnum::ObjectWithArgs(n.func.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&func, current_depth));
-                nodes.push(NestedNode {
-                    node: func,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .actions
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DoStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RenameStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            if n.object.is_some() {
-                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&object, current_depth));
-                nodes.push(NestedNode {
-                    node: object,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::RuleStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .actions
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::NotifyStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::ListenStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::UnlistenStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::TransactionStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ViewStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.view.is_some() {
-                let view = NodeEnum::RangeVar(n.view.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&view, current_depth));
-                nodes.push(NestedNode {
-                    node: view,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .aliases
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.query.is_some() {
-                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&query, current_depth));
-                nodes.push(NestedNode {
-                    node: query,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::LoadStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::CreateDomainStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .domainname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.type_name.is_some() {
-                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&type_name, current_depth));
-                nodes.push(NestedNode {
-                    node: type_name,
-                    depth: current_depth,
-                });
-            }
-
-            if n.coll_clause.is_some() {
-                let coll_clause =
-                    NodeEnum::CollateClause(n.coll_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&coll_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: coll_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .constraints
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreatedbStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DropdbStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::VacuumStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .rels
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ExplainStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.query.is_some() {
-                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&query, current_depth));
-                nodes.push(NestedNode {
-                    node: query,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateTableAsStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.query.is_some() {
-                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&query, current_depth));
-                nodes.push(NestedNode {
-                    node: query,
-                    depth: current_depth,
-                });
-            }
-
-            if n.into.is_some() {
-                let into = NodeEnum::IntoClause(n.into.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&into, current_depth));
-                nodes.push(NestedNode {
-                    node: into,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreateSeqStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.sequence.is_some() {
-                let sequence = NodeEnum::RangeVar(n.sequence.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&sequence, current_depth));
-                nodes.push(NestedNode {
-                    node: sequence,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterSeqStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.sequence.is_some() {
-                let sequence = NodeEnum::RangeVar(n.sequence.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&sequence, current_depth));
-                nodes.push(NestedNode {
-                    node: sequence,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::VariableSetStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::VariableShowStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::DiscardStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::CreateTrigStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .funcname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .columns
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.when_clause.is_some() {
-                let when_clause = n.when_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&when_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: when_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .transition_rels
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.constrrel.is_some() {
-                let constrrel = NodeEnum::RangeVar(n.constrrel.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&constrrel, current_depth));
-                nodes.push(NestedNode {
-                    node: constrrel,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreatePlangStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .plhandler
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .plinline
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .plvalidator
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateRoleStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterRoleStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.role.is_some() {
-                let role = NodeEnum::RoleSpec(n.role.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&role, current_depth));
-                nodes.push(NestedNode {
-                    node: role,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DropRoleStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .roles
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::LockStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .relations
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ConstraintsSetStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .constraints
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ReindexStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .params
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CheckPointStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes
-        }
-        NodeEnum::CreateSchemaStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.authrole.is_some() {
-                let authrole = NodeEnum::RoleSpec(n.authrole.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&authrole, current_depth));
-                nodes.push(NestedNode {
-                    node: authrole,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .schema_elts
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterDatabaseStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterDatabaseRefreshCollStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::AlterDatabaseSetStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.setstmt.is_some() {
-                let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&setstmt, current_depth));
-                nodes.push(NestedNode {
-                    node: setstmt,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterRoleSetStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.role.is_some() {
-                let role = NodeEnum::RoleSpec(n.role.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&role, current_depth));
-                nodes.push(NestedNode {
-                    node: role,
-                    depth: current_depth,
-                });
-            }
-
-            if n.setstmt.is_some() {
-                let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&setstmt, current_depth));
-                nodes.push(NestedNode {
-                    node: setstmt,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreateConversionStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .conversion_name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .func_name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateCastStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.sourcetype.is_some() {
-                let sourcetype = NodeEnum::TypeName(n.sourcetype.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&sourcetype, current_depth));
-                nodes.push(NestedNode {
-                    node: sourcetype,
-                    depth: current_depth,
-                });
-            }
-
-            if n.targettype.is_some() {
-                let targettype = NodeEnum::TypeName(n.targettype.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&targettype, current_depth));
-                nodes.push(NestedNode {
-                    node: targettype,
-                    depth: current_depth,
-                });
-            }
-
-            if n.func.is_some() {
-                let func = NodeEnum::ObjectWithArgs(n.func.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&func, current_depth));
-                nodes.push(NestedNode {
-                    node: func,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreateOpClassStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .opclassname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .opfamilyname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.datatype.is_some() {
-                let datatype = NodeEnum::TypeName(n.datatype.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&datatype, current_depth));
-                nodes.push(NestedNode {
-                    node: datatype,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .items
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateOpFamilyStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .opfamilyname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterOpFamilyStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .opfamilyname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .items
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::PrepareStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .argtypes
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.query.is_some() {
-                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&query, current_depth));
-                nodes.push(NestedNode {
-                    node: query,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::ExecuteStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .params
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DeallocateStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::DeclareCursorStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.query.is_some() {
-                let query = n.query.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&query, current_depth));
-                nodes.push(NestedNode {
-                    node: query,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreateTableSpaceStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.owner.is_some() {
-                let owner = NodeEnum::RoleSpec(n.owner.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&owner, current_depth));
-                nodes.push(NestedNode {
-                    node: owner,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DropTableSpaceStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::AlterObjectDependsStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            if n.object.is_some() {
-                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&object, current_depth));
-                nodes.push(NestedNode {
-                    node: object,
-                    depth: current_depth,
-                });
-            }
-
-            if n.extname.is_some() {
-                let extname = NodeEnum::String(n.extname.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&extname, current_depth));
-                nodes.push(NestedNode {
-                    node: extname,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterObjectSchemaStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            if n.object.is_some() {
-                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&object, current_depth));
-                nodes.push(NestedNode {
-                    node: object,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterOwnerStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            if n.object.is_some() {
-                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&object, current_depth));
-                nodes.push(NestedNode {
-                    node: object,
-                    depth: current_depth,
-                });
-            }
-
-            if n.newowner.is_some() {
-                let newowner = NodeEnum::RoleSpec(n.newowner.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&newowner, current_depth));
-                nodes.push(NestedNode {
-                    node: newowner,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterOperatorStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.opername.is_some() {
-                let opername = NodeEnum::ObjectWithArgs(n.opername.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&opername, current_depth));
-                nodes.push(NestedNode {
-                    node: opername,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterTypeStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .type_name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DropOwnedStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .roles
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ReassignOwnedStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .roles
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.newrole.is_some() {
-                let newrole = NodeEnum::RoleSpec(n.newrole.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&newrole, current_depth));
-                nodes.push(NestedNode {
-                    node: newrole,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CompositeTypeStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.typevar.is_some() {
-                let typevar = NodeEnum::RangeVar(n.typevar.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&typevar, current_depth));
-                nodes.push(NestedNode {
-                    node: typevar,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .coldeflist
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateEnumStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .type_name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .vals
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateRangeStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .type_name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .params
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterEnumStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .type_name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterTsdictionaryStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .dictname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterTsconfigurationStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .cfgname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .tokentype
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .dicts
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateFdwStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .func_options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterFdwStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .func_options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateForeignServerStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterForeignServerStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateUserMappingStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.user.is_some() {
-                let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&user, current_depth));
-                nodes.push(NestedNode {
-                    node: user,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterUserMappingStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.user.is_some() {
-                let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&user, current_depth));
-                nodes.push(NestedNode {
-                    node: user,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DropUserMappingStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.user.is_some() {
-                let user = NodeEnum::RoleSpec(n.user.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&user, current_depth));
-                nodes.push(NestedNode {
-                    node: user,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterTableSpaceOptionsStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterTableMoveAllStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .roles
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::SecLabelStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.object.is_some() {
-                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&object, current_depth));
-                nodes.push(NestedNode {
-                    node: object,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreateForeignTableStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.base_stmt.is_some() {
-                let base_stmt = NodeEnum::CreateStmt(n.base_stmt.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&base_stmt, current_depth));
-                nodes.push(NestedNode {
-                    node: base_stmt,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ImportForeignSchemaStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .table_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateExtensionStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterExtensionStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterExtensionContentsStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.object.is_some() {
-                let object = n.object.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&object, current_depth));
-                nodes.push(NestedNode {
-                    node: object,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreateEventTrigStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .whenclause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .funcname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterEventTrigStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::RefreshMatViewStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::ReplicaIdentityStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::AlterSystemStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.setstmt.is_some() {
-                let setstmt = NodeEnum::VariableSetStmt(n.setstmt.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&setstmt, current_depth));
-                nodes.push(NestedNode {
-                    node: setstmt,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreatePolicyStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.table.is_some() {
-                let table = NodeEnum::RangeVar(n.table.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&table, current_depth));
-                nodes.push(NestedNode {
-                    node: table,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .roles
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.qual.is_some() {
-                let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&qual, current_depth));
-                nodes.push(NestedNode {
-                    node: qual,
-                    depth: current_depth,
-                });
-            }
-
-            if n.with_check.is_some() {
-                let with_check = n.with_check.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&with_check, current_depth));
-                nodes.push(NestedNode {
-                    node: with_check,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AlterPolicyStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.table.is_some() {
-                let table = NodeEnum::RangeVar(n.table.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&table, current_depth));
-                nodes.push(NestedNode {
-                    node: table,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .roles
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.qual.is_some() {
-                let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&qual, current_depth));
-                nodes.push(NestedNode {
-                    node: qual,
-                    depth: current_depth,
-                });
-            }
-
-            if n.with_check.is_some() {
-                let with_check = n.with_check.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&with_check, current_depth));
-                nodes.push(NestedNode {
-                    node: with_check,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreateTransformStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.type_name.is_some() {
-                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&type_name, current_depth));
-                nodes.push(NestedNode {
-                    node: type_name,
-                    depth: current_depth,
-                });
-            }
-
-            if n.fromsql.is_some() {
-                let fromsql = NodeEnum::ObjectWithArgs(n.fromsql.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&fromsql, current_depth));
-                nodes.push(NestedNode {
-                    node: fromsql,
-                    depth: current_depth,
-                });
-            }
-
-            if n.tosql.is_some() {
-                let tosql = NodeEnum::ObjectWithArgs(n.tosql.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&tosql, current_depth));
-                nodes.push(NestedNode {
-                    node: tosql,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CreateAmStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .handler_name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreatePublicationStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .pubobjects
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterPublicationStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .pubobjects
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateSubscriptionStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .publication
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterSubscriptionStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .publication
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DropSubscriptionStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::CreateStatsStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .defnames
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .stat_types
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .exprs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .relations
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterCollationStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .collname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CallStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.funccall.is_some() {
-                let funccall = NodeEnum::FuncCall(n.funccall.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&funccall, current_depth));
-                nodes.push(NestedNode {
-                    node: funccall,
-                    depth: current_depth,
-                });
-            }
-
-            if n.funcexpr.is_some() {
-                let funcexpr = NodeEnum::FuncExpr(n.funcexpr.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&funcexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: funcexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .outargs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AlterStatsStmt(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .defnames
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .name
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.lexpr.is_some() {
-                let lexpr = n.lexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&lexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: lexpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.rexpr.is_some() {
-                let rexpr = n.rexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&rexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: rexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::ColumnRef(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .fields
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ParamRef(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::FuncCall(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .funcname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .agg_order
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.agg_filter.is_some() {
-                let agg_filter = n.agg_filter.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&agg_filter, current_depth));
-                nodes.push(NestedNode {
-                    node: agg_filter,
-                    depth: current_depth,
-                });
-            }
-
-            if n.over.is_some() {
-                let over = NodeEnum::WindowDef(n.over.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&over, current_depth));
-                nodes.push(NestedNode {
-                    node: over,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AStar(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes
-        }
-        NodeEnum::AIndices(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.lidx.is_some() {
-                let lidx = n.lidx.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&lidx, current_depth));
-                nodes.push(NestedNode {
-                    node: lidx,
-                    depth: current_depth,
-                });
-            }
-
-            if n.uidx.is_some() {
-                let uidx = n.uidx.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&uidx, current_depth));
-                nodes.push(NestedNode {
-                    node: uidx,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::AIndirection(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .indirection
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AArrayExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .elements
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ResTarget(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .indirection
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.val.is_some() {
-                let val = n.val.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&val, current_depth));
-                nodes.push(NestedNode {
-                    node: val,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::MultiAssignRef(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.source.is_some() {
-                let source = n.source.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&source, current_depth));
-                nodes.push(NestedNode {
-                    node: source,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::TypeCast(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            if n.type_name.is_some() {
-                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&type_name, current_depth));
-                nodes.push(NestedNode {
-                    node: type_name,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CollateClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .collname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::SortBy(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.node.is_some() {
-                let node = n.node.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&node, current_depth));
-                nodes.push(NestedNode {
-                    node: node,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .use_op
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::WindowDef(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .partition_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .order_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.start_offset.is_some() {
-                let start_offset = n.start_offset.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&start_offset, current_depth));
-                nodes.push(NestedNode {
-                    node: start_offset,
-                    depth: current_depth,
-                });
-            }
-
-            if n.end_offset.is_some() {
-                let end_offset = n.end_offset.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&end_offset, current_depth));
-                nodes.push(NestedNode {
-                    node: end_offset,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::RangeSubselect(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.subquery.is_some() {
-                let subquery = n.subquery.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&subquery, current_depth));
-                nodes.push(NestedNode {
-                    node: subquery,
-                    depth: current_depth,
-                });
-            }
-
-            if n.alias.is_some() {
-                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&alias, current_depth));
-                nodes.push(NestedNode {
-                    node: alias,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::RangeFunction(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .functions
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.alias.is_some() {
-                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&alias, current_depth));
-                nodes.push(NestedNode {
-                    node: alias,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .coldeflist
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RangeTableSample(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = n.relation.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .method
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.repeatable.is_some() {
-                let repeatable = n.repeatable.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&repeatable, current_depth));
-                nodes.push(NestedNode {
-                    node: repeatable,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::RangeTableFunc(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.docexpr.is_some() {
-                let docexpr = n.docexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&docexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: docexpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.rowexpr.is_some() {
-                let rowexpr = n.rowexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&rowexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: rowexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .namespaces
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .columns
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.alias.is_some() {
-                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&alias, current_depth));
-                nodes.push(NestedNode {
-                    node: alias,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::RangeTableFuncCol(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.type_name.is_some() {
-                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&type_name, current_depth));
-                nodes.push(NestedNode {
-                    node: type_name,
-                    depth: current_depth,
-                });
-            }
-
-            if n.colexpr.is_some() {
-                let colexpr = n.colexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&colexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: colexpr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.coldefexpr.is_some() {
-                let coldefexpr = n.coldefexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&coldefexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: coldefexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::TypeName(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .names
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .typmods
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .array_bounds
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ColumnDef(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.type_name.is_some() {
-                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&type_name, current_depth));
-                nodes.push(NestedNode {
-                    node: type_name,
-                    depth: current_depth,
-                });
-            }
-
-            if n.raw_default.is_some() {
-                let raw_default = n.raw_default.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&raw_default, current_depth));
-                nodes.push(NestedNode {
-                    node: raw_default,
-                    depth: current_depth,
-                });
-            }
-
-            if n.cooked_default.is_some() {
-                let cooked_default = n.cooked_default.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&cooked_default, current_depth));
-                nodes.push(NestedNode {
-                    node: cooked_default,
-                    depth: current_depth,
-                });
-            }
-
-            if n.identity_sequence.is_some() {
-                let identity_sequence =
-                    NodeEnum::RangeVar(n.identity_sequence.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&identity_sequence, current_depth));
-                nodes.push(NestedNode {
-                    node: identity_sequence,
-                    depth: current_depth,
-                });
-            }
-
-            if n.coll_clause.is_some() {
-                let coll_clause =
-                    NodeEnum::CollateClause(n.coll_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&coll_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: coll_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .constraints
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .fdwoptions
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::IndexElem(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.expr.is_some() {
-                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&expr, current_depth));
-                nodes.push(NestedNode {
-                    node: expr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .collation
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .opclass
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .opclassopts
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::StatsElem(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.expr.is_some() {
-                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&expr, current_depth));
-                nodes.push(NestedNode {
-                    node: expr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::Constraint(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.raw_expr.is_some() {
-                let raw_expr = n.raw_expr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&raw_expr, current_depth));
-                nodes.push(NestedNode {
-                    node: raw_expr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .keys
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .including
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .exclusions
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            if n.pktable.is_some() {
-                let pktable = NodeEnum::RangeVar(n.pktable.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&pktable, current_depth));
-                nodes.push(NestedNode {
-                    node: pktable,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .fk_attrs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .pk_attrs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .fk_del_set_cols
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .old_conpfeqop
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::DefElem(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.arg.is_some() {
-                let arg = n.arg.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&arg, current_depth));
-                nodes.push(NestedNode {
-                    node: arg,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::RangeTblEntry(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.tablesample.is_some() {
-                let tablesample =
-                    NodeEnum::TableSampleClause(n.tablesample.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&tablesample, current_depth));
-                nodes.push(NestedNode {
-                    node: tablesample,
-                    depth: current_depth,
-                });
-            }
-
-            if n.subquery.is_some() {
-                let subquery = NodeEnum::Query(n.subquery.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&subquery, current_depth));
-                nodes.push(NestedNode {
-                    node: subquery,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .joinaliasvars
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .joinleftcols
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .joinrightcols
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.join_using_alias.is_some() {
-                let join_using_alias =
-                    NodeEnum::Alias(n.join_using_alias.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&join_using_alias, current_depth));
-                nodes.push(NestedNode {
-                    node: join_using_alias,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .functions
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.tablefunc.is_some() {
-                let tablefunc = NodeEnum::TableFunc(n.tablefunc.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&tablefunc, current_depth));
-                nodes.push(NestedNode {
-                    node: tablefunc,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .values_lists
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .coltypes
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .coltypmods
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .colcollations
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.alias.is_some() {
-                let alias = NodeEnum::Alias(n.alias.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&alias, current_depth));
-                nodes.push(NestedNode {
-                    node: alias,
-                    depth: current_depth,
-                });
-            }
-
-            if n.eref.is_some() {
-                let eref = NodeEnum::Alias(n.eref.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&eref, current_depth));
-                nodes.push(NestedNode {
-                    node: eref,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .security_quals
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RangeTblFunction(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.funcexpr.is_some() {
-                let funcexpr = n.funcexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&funcexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: funcexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .funccolnames
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .funccoltypes
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .funccoltypmods
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .funccolcollations
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::TableSampleClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.repeatable.is_some() {
-                let repeatable = n.repeatable.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&repeatable, current_depth));
-                nodes.push(NestedNode {
-                    node: repeatable,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::WithCheckOption(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.qual.is_some() {
-                let qual = n.qual.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&qual, current_depth));
-                nodes.push(NestedNode {
-                    node: qual,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::SortGroupClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::GroupingSet(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .content
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::WindowClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .partition_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .order_clause
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.start_offset.is_some() {
-                let start_offset = n.start_offset.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&start_offset, current_depth));
-                nodes.push(NestedNode {
-                    node: start_offset,
-                    depth: current_depth,
-                });
-            }
-
-            if n.end_offset.is_some() {
-                let end_offset = n.end_offset.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&end_offset, current_depth));
-                nodes.push(NestedNode {
-                    node: end_offset,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .run_condition
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::ObjectWithArgs(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .objname
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .objargs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .objfuncargs
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AccessPriv(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .cols
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CreateOpClassItem(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.name.is_some() {
-                let name = NodeEnum::ObjectWithArgs(n.name.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&name, current_depth));
-                nodes.push(NestedNode {
-                    node: name,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .order_family
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .class_args
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.storedtype.is_some() {
-                let storedtype = NodeEnum::TypeName(n.storedtype.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&storedtype, current_depth));
-                nodes.push(NestedNode {
-                    node: storedtype,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::TableLikeClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::FunctionParameter(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.arg_type.is_some() {
-                let arg_type = NodeEnum::TypeName(n.arg_type.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&arg_type, current_depth));
-                nodes.push(NestedNode {
-                    node: arg_type,
-                    depth: current_depth,
-                });
-            }
-
-            if n.defexpr.is_some() {
-                let defexpr = n.defexpr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&defexpr, current_depth));
-                nodes.push(NestedNode {
-                    node: defexpr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::LockingClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .locked_rels
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RowMarkClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::XmlSerialize(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.expr.is_some() {
-                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&expr, current_depth));
-                nodes.push(NestedNode {
-                    node: expr,
-                    depth: current_depth,
-                });
-            }
-
-            if n.type_name.is_some() {
-                let type_name = NodeEnum::TypeName(n.type_name.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&type_name, current_depth));
-                nodes.push(NestedNode {
-                    node: type_name,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::WithClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .ctes
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::InferClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .index_elems
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::OnConflictClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.infer.is_some() {
-                let infer = NodeEnum::InferClause(n.infer.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&infer, current_depth));
-                nodes.push(NestedNode {
-                    node: infer,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .target_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CtesearchClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .search_col_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::CtecycleClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .cycle_col_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.cycle_mark_value.is_some() {
-                let cycle_mark_value = n
-                    .cycle_mark_value
-                    .as_ref()
-                    .unwrap()
-                    .to_owned()
-                    .node
-                    .unwrap();
-                nodes.append(&mut get_children(&cycle_mark_value, current_depth));
-                nodes.push(NestedNode {
-                    node: cycle_mark_value,
-                    depth: current_depth,
-                });
-            }
-
-            if n.cycle_mark_default.is_some() {
-                let cycle_mark_default = n
-                    .cycle_mark_default
-                    .as_ref()
-                    .unwrap()
-                    .to_owned()
-                    .node
-                    .unwrap();
-                nodes.append(&mut get_children(&cycle_mark_default, current_depth));
-                nodes.push(NestedNode {
-                    node: cycle_mark_default,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::CommonTableExpr(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .aliascolnames
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            if n.ctequery.is_some() {
-                let ctequery = n.ctequery.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&ctequery, current_depth));
-                nodes.push(NestedNode {
-                    node: ctequery,
-                    depth: current_depth,
-                });
-            }
-
-            if n.search_clause.is_some() {
-                let search_clause =
-                    NodeEnum::CtesearchClause(n.search_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&search_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: search_clause,
-                    depth: current_depth,
-                });
-            }
-
-            if n.cycle_clause.is_some() {
-                let cycle_clause =
-                    NodeEnum::CtecycleClause(n.cycle_clause.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&cycle_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: cycle_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .ctecolnames
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .ctecoltypes
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .ctecoltypmods
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .ctecolcollations
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::MergeWhenClause(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.condition.is_some() {
-                let condition = n.condition.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&condition, current_depth));
-                nodes.push(NestedNode {
-                    node: condition,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .target_list
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .values
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::RoleSpec(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::TriggerTransition(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::PartitionElem(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.expr.is_some() {
-                let expr = n.expr.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&expr, current_depth));
-                nodes.push(NestedNode {
-                    node: expr,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .collation
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .opclass
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::PartitionSpec(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .part_params
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::PartitionBoundSpec(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes.append(
-                &mut n
-                    .listdatums
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .lowerdatums
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes.append(
-                &mut n
-                    .upperdatums
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::PartitionRangeDatum(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.value.is_some() {
-                let value = n.value.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&value, current_depth));
-                nodes.push(NestedNode {
-                    node: value,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::PartitionCmd(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.name.is_some() {
-                let name = NodeEnum::RangeVar(n.name.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&name, current_depth));
-                nodes.push(NestedNode {
-                    node: name,
-                    depth: current_depth,
-                });
-            }
-
-            if n.bound.is_some() {
-                let bound = NodeEnum::PartitionBoundSpec(n.bound.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&bound, current_depth));
-                nodes.push(NestedNode {
-                    node: bound,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::VacuumRelation(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .va_cols
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::PublicationObjSpec(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            if n.pubtable.is_some() {
-                let pubtable = NodeEnum::PublicationTable(n.pubtable.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&pubtable, current_depth));
-                nodes.push(NestedNode {
-                    node: pubtable,
-                    depth: current_depth,
-                });
-            }
-
-            nodes
-        }
-        NodeEnum::PublicationTable(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            if n.relation.is_some() {
-                let relation = NodeEnum::RangeVar(n.relation.as_ref().unwrap().to_owned());
-                nodes.append(&mut get_children(&relation, current_depth));
-                nodes.push(NestedNode {
-                    node: relation,
-                    depth: current_depth,
-                });
-            }
-
-            if n.where_clause.is_some() {
-                let where_clause = n.where_clause.as_ref().unwrap().to_owned().node.unwrap();
-                nodes.append(&mut get_children(&where_clause, current_depth));
-                nodes.push(NestedNode {
-                    node: where_clause,
-                    depth: current_depth,
-                });
-            }
-
-            nodes.append(
-                &mut n
-                    .columns
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::InlineCodeBlock(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::CallContext(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::Integer(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::Float(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::Boolean(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::String(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::BitString(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
-        NodeEnum::List(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .items
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::IntList(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .items
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::OidList(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-            nodes.append(
-                &mut n
-                    .items
-                    .iter()
-                    .flat_map(|x| {
-                        let mut result = vec![];
-                        result.append(&mut get_children(&x.node.as_ref().unwrap(), current_depth));
-                        result.push(NestedNode {
-                            node: x.node.as_ref().unwrap().to_owned(),
-                            depth: current_depth,
-                        });
-                        result
-                    })
-                    .collect(),
-            );
-
-            nodes
-        }
-        NodeEnum::AConst(n) => {
-            let mut nodes: Vec<NestedNode> = vec![];
-
-            nodes
-        }
+    let mut nodes: Vec<NestedNode> = vec![];
+    // Node, depth, location
+    let mut stack: Vec<(NodeEnum, i32)> = vec![(node.to_owned(), current_depth)];
+    while stack.len() > 0 {
+        let (node, depth) = stack.pop().unwrap();
+        let current_depth = depth + 1;
+        match &node {
+            NodeEnum::Alias(n) => {
+                n.colnames.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RangeVar(n) => {
+                if n.alias.is_some() {
+                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
+                    stack.push((alias.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: alias,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::TableFunc(n) => {
+                n.ns_uris.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.ns_names.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.docexpr.is_some() {
+                    let docexpr = n.docexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((docexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: docexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.rowexpr.is_some() {
+                    let rowexpr = n.rowexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((rowexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: rowexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.colnames.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.coltypes.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.coltypmods.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.colcollations.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.colexprs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.coldefexprs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::Var(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::Param(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::Aggref(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.aggargtypes.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.aggdirectargs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.aggorder.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.aggdistinct.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.aggfilter.is_some() {
+                    let aggfilter = n.aggfilter.to_owned().unwrap().node.unwrap();
+                    stack.push((aggfilter.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: aggfilter,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::GroupingFunc(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.refs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.cols.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::WindowFunc(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.aggfilter.is_some() {
+                    let aggfilter = n.aggfilter.to_owned().unwrap().node.unwrap();
+                    stack.push((aggfilter.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: aggfilter,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::SubscriptingRef(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.refupperindexpr.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.reflowerindexpr.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.refexpr.is_some() {
+                    let refexpr = n.refexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((refexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: refexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.refassgnexpr.is_some() {
+                    let refassgnexpr = n.refassgnexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((refassgnexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: refassgnexpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::FuncExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::NamedArgExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::OpExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DistinctExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::NullIfExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ScalarArrayOpExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::BoolExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::SubLink(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.testexpr.is_some() {
+                    let testexpr = n.testexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((testexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: testexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.oper_name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.subselect.is_some() {
+                    let subselect = n.subselect.to_owned().unwrap().node.unwrap();
+                    stack.push((subselect.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: subselect,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::SubPlan(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.testexpr.is_some() {
+                    let testexpr = n.testexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((testexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: testexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.param_ids.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.set_param.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.par_param.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlternativeSubPlan(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.subplans.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::FieldSelect(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::FieldStore(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+
+                n.newvals.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.fieldnums.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RelabelType(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CoerceViaIo(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::ArrayCoerceExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.elemexpr.is_some() {
+                    let elemexpr = n.elemexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((elemexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: elemexpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::ConvertRowtypeExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CollateExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CaseExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.defresult.is_some() {
+                    let defresult = n.defresult.to_owned().unwrap().node.unwrap();
+                    stack.push((defresult.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: defresult,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CaseWhen(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.expr.is_some() {
+                    let expr = n.expr.to_owned().unwrap().node.unwrap();
+                    stack.push((expr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: expr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.result.is_some() {
+                    let result = n.result.to_owned().unwrap().node.unwrap();
+                    stack.push((result.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: result,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CaseTestExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::ArrayExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.elements.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RowExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.colnames.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RowCompareExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.opnos.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.opfamilies.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.inputcollids.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.largs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.rargs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CoalesceExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::MinMaxExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::SqlvalueFunction(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::XmlExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.named_args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.arg_names.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::NullTest(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::BooleanTest(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CoerceToDomain(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CoerceToDomainValue(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::SetToDefault(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CurrentOfExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::NextValueExpr(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::InferenceElem(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.expr.is_some() {
+                    let expr = n.expr.to_owned().unwrap().node.unwrap();
+                    stack.push((expr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: expr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::TargetEntry(n) => {
+                if n.xpr.is_some() {
+                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+                    stack.push((xpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: xpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.expr.is_some() {
+                    let expr = n.expr.to_owned().unwrap().node.unwrap();
+                    stack.push((expr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: expr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::RangeTblRef(n) => (),
+            NodeEnum::JoinExpr(n) => {
+                if n.larg.is_some() {
+                    let larg = n.larg.to_owned().unwrap().node.unwrap();
+                    stack.push((larg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: larg,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.rarg.is_some() {
+                    let rarg = n.rarg.to_owned().unwrap().node.unwrap();
+                    stack.push((rarg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: rarg,
+                        depth: current_depth,
+                    });
+                }
+
+                n.using_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.join_using_alias.is_some() {
+                    let join_using_alias = NodeEnum::Alias(n.join_using_alias.to_owned().unwrap());
+                    stack.push((join_using_alias.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: join_using_alias,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.quals.is_some() {
+                    let quals = n.quals.to_owned().unwrap().node.unwrap();
+                    stack.push((quals.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: quals,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.alias.is_some() {
+                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
+                    stack.push((alias.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: alias,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::FromExpr(n) => {
+                n.fromlist.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.quals.is_some() {
+                    let quals = n.quals.to_owned().unwrap().node.unwrap();
+                    stack.push((quals.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: quals,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::OnConflictExpr(n) => {
+                n.arbiter_elems.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.arbiter_where.is_some() {
+                    let arbiter_where = n.arbiter_where.to_owned().unwrap().node.unwrap();
+                    stack.push((arbiter_where.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arbiter_where,
+                        depth: current_depth,
+                    });
+                }
+
+                n.on_conflict_set.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.on_conflict_where.is_some() {
+                    let on_conflict_where = n.on_conflict_where.to_owned().unwrap().node.unwrap();
+                    stack.push((on_conflict_where.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: on_conflict_where,
+                        depth: current_depth,
+                    });
+                }
+
+                n.excl_rel_tlist.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::IntoClause(n) => {
+                if n.rel.is_some() {
+                    let rel = NodeEnum::RangeVar(n.rel.to_owned().unwrap());
+                    stack.push((rel.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: rel,
+                        depth: current_depth,
+                    });
+                }
+
+                n.col_names.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.view_query.is_some() {
+                    let view_query = n.view_query.to_owned().unwrap().node.unwrap();
+                    stack.push((view_query.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: view_query,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::MergeAction(n) => {
+                if n.qual.is_some() {
+                    let qual = n.qual.to_owned().unwrap().node.unwrap();
+                    stack.push((qual.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: qual,
+                        depth: current_depth,
+                    });
+                }
+
+                n.target_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.update_colnos.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RawStmt(n) => {
+                if n.stmt.is_some() {
+                    let stmt = n.stmt.to_owned().unwrap().node.unwrap();
+                    stack.push((stmt.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: stmt,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::Query(n) => {
+                if n.utility_stmt.is_some() {
+                    let utility_stmt = n.utility_stmt.to_owned().unwrap().node.unwrap();
+                    stack.push((utility_stmt.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: utility_stmt,
+                        depth: current_depth,
+                    });
+                }
+
+                n.cte_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.rtable.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.jointree.is_some() {
+                    let jointree = NodeEnum::FromExpr(n.jointree.to_owned().unwrap());
+                    stack.push((jointree.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: jointree,
+                        depth: current_depth,
+                    });
+                }
+
+                n.merge_action_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.target_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.on_conflict.is_some() {
+                    let on_conflict = NodeEnum::OnConflictExpr(n.on_conflict.to_owned().unwrap());
+                    stack.push((on_conflict.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: on_conflict,
+                        depth: current_depth,
+                    });
+                }
+
+                n.returning_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.group_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.grouping_sets.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.having_qual.is_some() {
+                    let having_qual = n.having_qual.to_owned().unwrap().node.unwrap();
+                    stack.push((having_qual.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: having_qual,
+                        depth: current_depth,
+                    });
+                }
+
+                n.window_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.distinct_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.sort_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.limit_offset.is_some() {
+                    let limit_offset = n.limit_offset.to_owned().unwrap().node.unwrap();
+                    stack.push((limit_offset.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: limit_offset,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.limit_count.is_some() {
+                    let limit_count = n.limit_count.to_owned().unwrap().node.unwrap();
+                    stack.push((limit_count.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: limit_count,
+                        depth: current_depth,
+                    });
+                }
+
+                n.row_marks.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.set_operations.is_some() {
+                    let set_operations = n.set_operations.to_owned().unwrap().node.unwrap();
+                    stack.push((set_operations.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: set_operations,
+                        depth: current_depth,
+                    });
+                }
+
+                n.constraint_deps.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.with_check_options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::InsertStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.cols.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.select_stmt.is_some() {
+                    let select_stmt = n.select_stmt.to_owned().unwrap().node.unwrap();
+                    stack.push((select_stmt.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: select_stmt,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.on_conflict_clause.is_some() {
+                    let on_conflict_clause =
+                        NodeEnum::OnConflictClause(n.on_conflict_clause.to_owned().unwrap());
+                    stack.push((on_conflict_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: on_conflict_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.returning_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.with_clause.is_some() {
+                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
+                    stack.push((with_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: with_clause,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::DeleteStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.using_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.returning_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.with_clause.is_some() {
+                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
+                    stack.push((with_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: with_clause,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::UpdateStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.target_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.from_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.returning_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.with_clause.is_some() {
+                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
+                    stack.push((with_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: with_clause,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::MergeStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.source_relation.is_some() {
+                    let source_relation = n.source_relation.to_owned().unwrap().node.unwrap();
+                    stack.push((source_relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: source_relation,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.join_condition.is_some() {
+                    let join_condition = n.join_condition.to_owned().unwrap().node.unwrap();
+                    stack.push((join_condition.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: join_condition,
+                        depth: current_depth,
+                    });
+                }
+
+                n.merge_when_clauses.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.with_clause.is_some() {
+                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
+                    stack.push((with_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: with_clause,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::SelectStmt(n) => {
+                n.distinct_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.into_clause.is_some() {
+                    let into_clause = NodeEnum::IntoClause(n.into_clause.to_owned().unwrap());
+                    stack.push((into_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: into_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.target_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.from_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.group_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.having_clause.is_some() {
+                    let having_clause = n.having_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((having_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: having_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.window_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.values_lists.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.sort_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.limit_offset.is_some() {
+                    let limit_offset = n.limit_offset.to_owned().unwrap().node.unwrap();
+                    stack.push((limit_offset.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: limit_offset,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.limit_count.is_some() {
+                    let limit_count = n.limit_count.to_owned().unwrap().node.unwrap();
+                    stack.push((limit_count.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: limit_count,
+                        depth: current_depth,
+                    });
+                }
+
+                n.locking_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.with_clause.is_some() {
+                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
+                    stack.push((with_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: with_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.larg.is_some() {
+                    let larg = NodeEnum::SelectStmt(n.larg.to_owned().unwrap());
+                    stack.push((larg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: larg,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.rarg.is_some() {
+                    let rarg = NodeEnum::SelectStmt(n.rarg.to_owned().unwrap());
+                    stack.push((rarg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: rarg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::ReturnStmt(n) => {
+                if n.returnval.is_some() {
+                    let returnval = n.returnval.to_owned().unwrap().node.unwrap();
+                    stack.push((returnval.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: returnval,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::PlassignStmt(n) => {
+                n.indirection.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.val.is_some() {
+                    let val = NodeEnum::SelectStmt(n.val.to_owned().unwrap());
+                    stack.push((val.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: val,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterTableStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.cmds.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterTableCmd(n) => {
+                if n.newowner.is_some() {
+                    let newowner = NodeEnum::RoleSpec(n.newowner.to_owned().unwrap());
+                    stack.push((newowner.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: newowner,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.def.is_some() {
+                    let def = n.def.to_owned().unwrap().node.unwrap();
+                    stack.push((def.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: def,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterDomainStmt(n) => {
+                n.type_name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.def.is_some() {
+                    let def = n.def.to_owned().unwrap().node.unwrap();
+                    stack.push((def.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: def,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::SetOperationStmt(n) => {
+                if n.larg.is_some() {
+                    let larg = n.larg.to_owned().unwrap().node.unwrap();
+                    stack.push((larg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: larg,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.rarg.is_some() {
+                    let rarg = n.rarg.to_owned().unwrap().node.unwrap();
+                    stack.push((rarg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: rarg,
+                        depth: current_depth,
+                    });
+                }
+
+                n.col_types.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.col_typmods.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.col_collations.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.group_clauses.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::GrantStmt(n) => {
+                n.objects.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.privileges.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.grantees.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.grantor.is_some() {
+                    let grantor = NodeEnum::RoleSpec(n.grantor.to_owned().unwrap());
+                    stack.push((grantor.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: grantor,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::GrantRoleStmt(n) => {
+                n.granted_roles.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.grantee_roles.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.grantor.is_some() {
+                    let grantor = NodeEnum::RoleSpec(n.grantor.to_owned().unwrap());
+                    stack.push((grantor.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: grantor,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterDefaultPrivilegesStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.action.is_some() {
+                    let action = NodeEnum::GrantStmt(n.action.to_owned().unwrap());
+                    stack.push((action.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: action,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::ClosePortalStmt(n) => (),
+            NodeEnum::ClusterStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.params.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CopyStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.query.is_some() {
+                    let query = n.query.to_owned().unwrap().node.unwrap();
+                    stack.push((query.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: query,
+                        depth: current_depth,
+                    });
+                }
+
+                n.attlist.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreateStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.table_elts.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.inh_relations.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.partbound.is_some() {
+                    let partbound = NodeEnum::PartitionBoundSpec(n.partbound.to_owned().unwrap());
+                    stack.push((partbound.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: partbound,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.partspec.is_some() {
+                    let partspec = NodeEnum::PartitionSpec(n.partspec.to_owned().unwrap());
+                    stack.push((partspec.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: partspec,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.of_typename.is_some() {
+                    let of_typename = NodeEnum::TypeName(n.of_typename.to_owned().unwrap());
+                    stack.push((of_typename.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: of_typename,
+                        depth: current_depth,
+                    });
+                }
+
+                n.constraints.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DefineStmt(n) => {
+                n.defnames.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.definition.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DropStmt(n) => {
+                n.objects.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::TruncateStmt(n) => {
+                n.relations.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CommentStmt(n) => {
+                if n.object.is_some() {
+                    let object = n.object.to_owned().unwrap().node.unwrap();
+                    stack.push((object.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: object,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::FetchStmt(n) => (),
+            NodeEnum::IndexStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.index_params.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.index_including_params.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.exclude_op_names.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateFunctionStmt(n) => {
+                n.funcname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.parameters.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.return_type.is_some() {
+                    let return_type = NodeEnum::TypeName(n.return_type.to_owned().unwrap());
+                    stack.push((return_type.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: return_type,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.sql_body.is_some() {
+                    let sql_body = n.sql_body.to_owned().unwrap().node.unwrap();
+                    stack.push((sql_body.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: sql_body,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterFunctionStmt(n) => {
+                if n.func.is_some() {
+                    let func = NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap());
+                    stack.push((func.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: func,
+                        depth: current_depth,
+                    });
+                }
+
+                n.actions.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DoStmt(n) => {
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RenameStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.object.is_some() {
+                    let object = n.object.to_owned().unwrap().node.unwrap();
+                    stack.push((object.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: object,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::RuleStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.actions.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::NotifyStmt(n) => (),
+            NodeEnum::ListenStmt(n) => (),
+            NodeEnum::UnlistenStmt(n) => (),
+            NodeEnum::TransactionStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ViewStmt(n) => {
+                if n.view.is_some() {
+                    let view = NodeEnum::RangeVar(n.view.to_owned().unwrap());
+                    stack.push((view.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: view,
+                        depth: current_depth,
+                    });
+                }
+
+                n.aliases.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.query.is_some() {
+                    let query = n.query.to_owned().unwrap().node.unwrap();
+                    stack.push((query.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: query,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::LoadStmt(n) => (),
+            NodeEnum::CreateDomainStmt(n) => {
+                n.domainname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.type_name.is_some() {
+                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
+                    stack.push((type_name.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: type_name,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.coll_clause.is_some() {
+                    let coll_clause = NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap());
+                    stack.push((coll_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: coll_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.constraints.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreatedbStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DropdbStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::VacuumStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.rels.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ExplainStmt(n) => {
+                if n.query.is_some() {
+                    let query = n.query.to_owned().unwrap().node.unwrap();
+                    stack.push((query.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: query,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateTableAsStmt(n) => {
+                if n.query.is_some() {
+                    let query = n.query.to_owned().unwrap().node.unwrap();
+                    stack.push((query.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: query,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.into.is_some() {
+                    let into = NodeEnum::IntoClause(n.into.to_owned().unwrap());
+                    stack.push((into.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: into,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreateSeqStmt(n) => {
+                if n.sequence.is_some() {
+                    let sequence = NodeEnum::RangeVar(n.sequence.to_owned().unwrap());
+                    stack.push((sequence.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: sequence,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterSeqStmt(n) => {
+                if n.sequence.is_some() {
+                    let sequence = NodeEnum::RangeVar(n.sequence.to_owned().unwrap());
+                    stack.push((sequence.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: sequence,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::VariableSetStmt(n) => {
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::VariableShowStmt(n) => (),
+            NodeEnum::DiscardStmt(n) => (),
+            NodeEnum::CreateTrigStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.funcname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.columns.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.when_clause.is_some() {
+                    let when_clause = n.when_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((when_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: when_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.transition_rels.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.constrrel.is_some() {
+                    let constrrel = NodeEnum::RangeVar(n.constrrel.to_owned().unwrap());
+                    stack.push((constrrel.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: constrrel,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreatePlangStmt(n) => {
+                n.plhandler.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.plinline.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.plvalidator.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateRoleStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterRoleStmt(n) => {
+                if n.role.is_some() {
+                    let role = NodeEnum::RoleSpec(n.role.to_owned().unwrap());
+                    stack.push((role.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: role,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DropRoleStmt(n) => {
+                n.roles.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::LockStmt(n) => {
+                n.relations.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ConstraintsSetStmt(n) => {
+                n.constraints.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ReindexStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.params.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CheckPointStmt(n) => (),
+            NodeEnum::CreateSchemaStmt(n) => {
+                if n.authrole.is_some() {
+                    let authrole = NodeEnum::RoleSpec(n.authrole.to_owned().unwrap());
+                    stack.push((authrole.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: authrole,
+                        depth: current_depth,
+                    });
+                }
+
+                n.schema_elts.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterDatabaseStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterDatabaseRefreshCollStmt(n) => (),
+            NodeEnum::AlterDatabaseSetStmt(n) => {
+                if n.setstmt.is_some() {
+                    let setstmt = NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap());
+                    stack.push((setstmt.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: setstmt,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterRoleSetStmt(n) => {
+                if n.role.is_some() {
+                    let role = NodeEnum::RoleSpec(n.role.to_owned().unwrap());
+                    stack.push((role.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: role,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.setstmt.is_some() {
+                    let setstmt = NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap());
+                    stack.push((setstmt.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: setstmt,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreateConversionStmt(n) => {
+                n.conversion_name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.func_name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateCastStmt(n) => {
+                if n.sourcetype.is_some() {
+                    let sourcetype = NodeEnum::TypeName(n.sourcetype.to_owned().unwrap());
+                    stack.push((sourcetype.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: sourcetype,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.targettype.is_some() {
+                    let targettype = NodeEnum::TypeName(n.targettype.to_owned().unwrap());
+                    stack.push((targettype.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: targettype,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.func.is_some() {
+                    let func = NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap());
+                    stack.push((func.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: func,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreateOpClassStmt(n) => {
+                n.opclassname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.opfamilyname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.datatype.is_some() {
+                    let datatype = NodeEnum::TypeName(n.datatype.to_owned().unwrap());
+                    stack.push((datatype.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: datatype,
+                        depth: current_depth,
+                    });
+                }
+
+                n.items.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateOpFamilyStmt(n) => {
+                n.opfamilyname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterOpFamilyStmt(n) => {
+                n.opfamilyname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.items.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::PrepareStmt(n) => {
+                n.argtypes.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.query.is_some() {
+                    let query = n.query.to_owned().unwrap().node.unwrap();
+                    stack.push((query.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: query,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::ExecuteStmt(n) => {
+                n.params.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DeallocateStmt(n) => (),
+            NodeEnum::DeclareCursorStmt(n) => {
+                if n.query.is_some() {
+                    let query = n.query.to_owned().unwrap().node.unwrap();
+                    stack.push((query.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: query,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreateTableSpaceStmt(n) => {
+                if n.owner.is_some() {
+                    let owner = NodeEnum::RoleSpec(n.owner.to_owned().unwrap());
+                    stack.push((owner.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: owner,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DropTableSpaceStmt(n) => (),
+            NodeEnum::AlterObjectDependsStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.object.is_some() {
+                    let object = n.object.to_owned().unwrap().node.unwrap();
+                    stack.push((object.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: object,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.extname.is_some() {
+                    let extname = NodeEnum::String(n.extname.to_owned().unwrap());
+                    stack.push((extname.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: extname,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterObjectSchemaStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.object.is_some() {
+                    let object = n.object.to_owned().unwrap().node.unwrap();
+                    stack.push((object.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: object,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterOwnerStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.object.is_some() {
+                    let object = n.object.to_owned().unwrap().node.unwrap();
+                    stack.push((object.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: object,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.newowner.is_some() {
+                    let newowner = NodeEnum::RoleSpec(n.newowner.to_owned().unwrap());
+                    stack.push((newowner.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: newowner,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterOperatorStmt(n) => {
+                if n.opername.is_some() {
+                    let opername = NodeEnum::ObjectWithArgs(n.opername.to_owned().unwrap());
+                    stack.push((opername.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: opername,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterTypeStmt(n) => {
+                n.type_name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DropOwnedStmt(n) => {
+                n.roles.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ReassignOwnedStmt(n) => {
+                n.roles.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.newrole.is_some() {
+                    let newrole = NodeEnum::RoleSpec(n.newrole.to_owned().unwrap());
+                    stack.push((newrole.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: newrole,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CompositeTypeStmt(n) => {
+                if n.typevar.is_some() {
+                    let typevar = NodeEnum::RangeVar(n.typevar.to_owned().unwrap());
+                    stack.push((typevar.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: typevar,
+                        depth: current_depth,
+                    });
+                }
+
+                n.coldeflist.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateEnumStmt(n) => {
+                n.type_name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.vals.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateRangeStmt(n) => {
+                n.type_name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.params.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterEnumStmt(n) => {
+                n.type_name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterTsdictionaryStmt(n) => {
+                n.dictname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterTsconfigurationStmt(n) => {
+                n.cfgname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.tokentype.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.dicts.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateFdwStmt(n) => {
+                n.func_options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterFdwStmt(n) => {
+                n.func_options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateForeignServerStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterForeignServerStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateUserMappingStmt(n) => {
+                if n.user.is_some() {
+                    let user = NodeEnum::RoleSpec(n.user.to_owned().unwrap());
+                    stack.push((user.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: user,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterUserMappingStmt(n) => {
+                if n.user.is_some() {
+                    let user = NodeEnum::RoleSpec(n.user.to_owned().unwrap());
+                    stack.push((user.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: user,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DropUserMappingStmt(n) => {
+                if n.user.is_some() {
+                    let user = NodeEnum::RoleSpec(n.user.to_owned().unwrap());
+                    stack.push((user.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: user,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterTableSpaceOptionsStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterTableMoveAllStmt(n) => {
+                n.roles.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::SecLabelStmt(n) => {
+                if n.object.is_some() {
+                    let object = n.object.to_owned().unwrap().node.unwrap();
+                    stack.push((object.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: object,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreateForeignTableStmt(n) => {
+                if n.base_stmt.is_some() {
+                    let base_stmt = NodeEnum::CreateStmt(n.base_stmt.to_owned().unwrap());
+                    stack.push((base_stmt.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: base_stmt,
+                        depth: current_depth,
+                    });
+                }
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ImportForeignSchemaStmt(n) => {
+                n.table_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateExtensionStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterExtensionStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterExtensionContentsStmt(n) => {
+                if n.object.is_some() {
+                    let object = n.object.to_owned().unwrap().node.unwrap();
+                    stack.push((object.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: object,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreateEventTrigStmt(n) => {
+                n.whenclause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.funcname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterEventTrigStmt(n) => (),
+            NodeEnum::RefreshMatViewStmt(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::ReplicaIdentityStmt(n) => (),
+            NodeEnum::AlterSystemStmt(n) => {
+                if n.setstmt.is_some() {
+                    let setstmt = NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap());
+                    stack.push((setstmt.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: setstmt,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreatePolicyStmt(n) => {
+                if n.table.is_some() {
+                    let table = NodeEnum::RangeVar(n.table.to_owned().unwrap());
+                    stack.push((table.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: table,
+                        depth: current_depth,
+                    });
+                }
+
+                n.roles.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.qual.is_some() {
+                    let qual = n.qual.to_owned().unwrap().node.unwrap();
+                    stack.push((qual.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: qual,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.with_check.is_some() {
+                    let with_check = n.with_check.to_owned().unwrap().node.unwrap();
+                    stack.push((with_check.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: with_check,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AlterPolicyStmt(n) => {
+                if n.table.is_some() {
+                    let table = NodeEnum::RangeVar(n.table.to_owned().unwrap());
+                    stack.push((table.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: table,
+                        depth: current_depth,
+                    });
+                }
+
+                n.roles.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.qual.is_some() {
+                    let qual = n.qual.to_owned().unwrap().node.unwrap();
+                    stack.push((qual.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: qual,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.with_check.is_some() {
+                    let with_check = n.with_check.to_owned().unwrap().node.unwrap();
+                    stack.push((with_check.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: with_check,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreateTransformStmt(n) => {
+                if n.type_name.is_some() {
+                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
+                    stack.push((type_name.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: type_name,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.fromsql.is_some() {
+                    let fromsql = NodeEnum::ObjectWithArgs(n.fromsql.to_owned().unwrap());
+                    stack.push((fromsql.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: fromsql,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.tosql.is_some() {
+                    let tosql = NodeEnum::ObjectWithArgs(n.tosql.to_owned().unwrap());
+                    stack.push((tosql.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: tosql,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CreateAmStmt(n) => {
+                n.handler_name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreatePublicationStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.pubobjects.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterPublicationStmt(n) => {
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.pubobjects.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateSubscriptionStmt(n) => {
+                n.publication.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterSubscriptionStmt(n) => {
+                n.publication.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DropSubscriptionStmt(n) => (),
+            NodeEnum::CreateStatsStmt(n) => {
+                n.defnames.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.stat_types.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.exprs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.relations.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterCollationStmt(n) => {
+                n.collname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CallStmt(n) => {
+                if n.funccall.is_some() {
+                    let funccall = NodeEnum::FuncCall(n.funccall.to_owned().unwrap());
+                    stack.push((funccall.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: funccall,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.funcexpr.is_some() {
+                    let funcexpr = NodeEnum::FuncExpr(n.funcexpr.to_owned().unwrap());
+                    stack.push((funcexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: funcexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.outargs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AlterStatsStmt(n) => {
+                n.defnames.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AExpr(n) => {
+                n.name.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.lexpr.is_some() {
+                    let lexpr = n.lexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((lexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: lexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.rexpr.is_some() {
+                    let rexpr = n.rexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((rexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: rexpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::ColumnRef(n) => {
+                n.fields.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ParamRef(n) => (),
+            NodeEnum::FuncCall(n) => {
+                n.funcname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.agg_order.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.agg_filter.is_some() {
+                    let agg_filter = n.agg_filter.to_owned().unwrap().node.unwrap();
+                    stack.push((agg_filter.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: agg_filter,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.over.is_some() {
+                    let over = NodeEnum::WindowDef(n.over.to_owned().unwrap());
+                    stack.push((over.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: over,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AStar(n) => (),
+            NodeEnum::AIndices(n) => {
+                if n.lidx.is_some() {
+                    let lidx = n.lidx.to_owned().unwrap().node.unwrap();
+                    stack.push((lidx.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: lidx,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.uidx.is_some() {
+                    let uidx = n.uidx.to_owned().unwrap().node.unwrap();
+                    stack.push((uidx.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: uidx,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::AIndirection(n) => {
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+
+                n.indirection.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AArrayExpr(n) => {
+                n.elements.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ResTarget(n) => {
+                n.indirection.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.val.is_some() {
+                    let val = n.val.to_owned().unwrap().node.unwrap();
+                    stack.push((val.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: val,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::MultiAssignRef(n) => {
+                if n.source.is_some() {
+                    let source = n.source.to_owned().unwrap().node.unwrap();
+                    stack.push((source.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: source,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::TypeCast(n) => {
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.type_name.is_some() {
+                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
+                    stack.push((type_name.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: type_name,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CollateClause(n) => {
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+
+                n.collname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::SortBy(n) => {
+                if n.node.is_some() {
+                    let node = n.node.to_owned().unwrap().node.unwrap();
+                    stack.push((node.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: node,
+                        depth: current_depth,
+                    });
+                }
+
+                n.use_op.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::WindowDef(n) => {
+                n.partition_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.order_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.start_offset.is_some() {
+                    let start_offset = n.start_offset.to_owned().unwrap().node.unwrap();
+                    stack.push((start_offset.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: start_offset,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.end_offset.is_some() {
+                    let end_offset = n.end_offset.to_owned().unwrap().node.unwrap();
+                    stack.push((end_offset.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: end_offset,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::RangeSubselect(n) => {
+                if n.subquery.is_some() {
+                    let subquery = n.subquery.to_owned().unwrap().node.unwrap();
+                    stack.push((subquery.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: subquery,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.alias.is_some() {
+                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
+                    stack.push((alias.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: alias,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::RangeFunction(n) => {
+                n.functions.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.alias.is_some() {
+                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
+                    stack.push((alias.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: alias,
+                        depth: current_depth,
+                    });
+                }
+
+                n.coldeflist.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RangeTableSample(n) => {
+                if n.relation.is_some() {
+                    let relation = n.relation.to_owned().unwrap().node.unwrap();
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.method.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.repeatable.is_some() {
+                    let repeatable = n.repeatable.to_owned().unwrap().node.unwrap();
+                    stack.push((repeatable.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: repeatable,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::RangeTableFunc(n) => {
+                if n.docexpr.is_some() {
+                    let docexpr = n.docexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((docexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: docexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.rowexpr.is_some() {
+                    let rowexpr = n.rowexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((rowexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: rowexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.namespaces.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.columns.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.alias.is_some() {
+                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
+                    stack.push((alias.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: alias,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::RangeTableFuncCol(n) => {
+                if n.type_name.is_some() {
+                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
+                    stack.push((type_name.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: type_name,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.colexpr.is_some() {
+                    let colexpr = n.colexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((colexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: colexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.coldefexpr.is_some() {
+                    let coldefexpr = n.coldefexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((coldefexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: coldefexpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::TypeName(n) => {
+                n.names.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.typmods.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.array_bounds.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ColumnDef(n) => {
+                if n.type_name.is_some() {
+                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
+                    stack.push((type_name.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: type_name,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.raw_default.is_some() {
+                    let raw_default = n.raw_default.to_owned().unwrap().node.unwrap();
+                    stack.push((raw_default.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: raw_default,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.cooked_default.is_some() {
+                    let cooked_default = n.cooked_default.to_owned().unwrap().node.unwrap();
+                    stack.push((cooked_default.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: cooked_default,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.identity_sequence.is_some() {
+                    let identity_sequence =
+                        NodeEnum::RangeVar(n.identity_sequence.to_owned().unwrap());
+                    stack.push((identity_sequence.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: identity_sequence,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.coll_clause.is_some() {
+                    let coll_clause = NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap());
+                    stack.push((coll_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: coll_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.constraints.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.fdwoptions.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::IndexElem(n) => {
+                if n.expr.is_some() {
+                    let expr = n.expr.to_owned().unwrap().node.unwrap();
+                    stack.push((expr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: expr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.collation.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.opclass.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.opclassopts.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::StatsElem(n) => {
+                if n.expr.is_some() {
+                    let expr = n.expr.to_owned().unwrap().node.unwrap();
+                    stack.push((expr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: expr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::Constraint(n) => {
+                if n.raw_expr.is_some() {
+                    let raw_expr = n.raw_expr.to_owned().unwrap().node.unwrap();
+                    stack.push((raw_expr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: raw_expr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.keys.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.including.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.exclusions.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.options.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.pktable.is_some() {
+                    let pktable = NodeEnum::RangeVar(n.pktable.to_owned().unwrap());
+                    stack.push((pktable.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: pktable,
+                        depth: current_depth,
+                    });
+                }
+
+                n.fk_attrs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.pk_attrs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.fk_del_set_cols.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.old_conpfeqop.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::DefElem(n) => {
+                if n.arg.is_some() {
+                    let arg = n.arg.to_owned().unwrap().node.unwrap();
+                    stack.push((arg.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::RangeTblEntry(n) => {
+                if n.tablesample.is_some() {
+                    let tablesample =
+                        NodeEnum::TableSampleClause(n.tablesample.to_owned().unwrap());
+                    stack.push((tablesample.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: tablesample,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.subquery.is_some() {
+                    let subquery = NodeEnum::Query(n.subquery.to_owned().unwrap());
+                    stack.push((subquery.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: subquery,
+                        depth: current_depth,
+                    });
+                }
+
+                n.joinaliasvars.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.joinleftcols.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.joinrightcols.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.join_using_alias.is_some() {
+                    let join_using_alias = NodeEnum::Alias(n.join_using_alias.to_owned().unwrap());
+                    stack.push((join_using_alias.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: join_using_alias,
+                        depth: current_depth,
+                    });
+                }
+
+                n.functions.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.tablefunc.is_some() {
+                    let tablefunc = NodeEnum::TableFunc(n.tablefunc.to_owned().unwrap());
+                    stack.push((tablefunc.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: tablefunc,
+                        depth: current_depth,
+                    });
+                }
+
+                n.values_lists.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.coltypes.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.coltypmods.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.colcollations.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.alias.is_some() {
+                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
+                    stack.push((alias.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: alias,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.eref.is_some() {
+                    let eref = NodeEnum::Alias(n.eref.to_owned().unwrap());
+                    stack.push((eref.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: eref,
+                        depth: current_depth,
+                    });
+                }
+
+                n.security_quals.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RangeTblFunction(n) => {
+                if n.funcexpr.is_some() {
+                    let funcexpr = n.funcexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((funcexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: funcexpr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.funccolnames.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.funccoltypes.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.funccoltypmods.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.funccolcollations.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::TableSampleClause(n) => {
+                n.args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.repeatable.is_some() {
+                    let repeatable = n.repeatable.to_owned().unwrap().node.unwrap();
+                    stack.push((repeatable.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: repeatable,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::WithCheckOption(n) => {
+                if n.qual.is_some() {
+                    let qual = n.qual.to_owned().unwrap().node.unwrap();
+                    stack.push((qual.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: qual,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::SortGroupClause(n) => (),
+            NodeEnum::GroupingSet(n) => {
+                n.content.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::WindowClause(n) => {
+                n.partition_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.order_clause.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.start_offset.is_some() {
+                    let start_offset = n.start_offset.to_owned().unwrap().node.unwrap();
+                    stack.push((start_offset.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: start_offset,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.end_offset.is_some() {
+                    let end_offset = n.end_offset.to_owned().unwrap().node.unwrap();
+                    stack.push((end_offset.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: end_offset,
+                        depth: current_depth,
+                    });
+                }
+
+                n.run_condition.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::ObjectWithArgs(n) => {
+                n.objname.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.objargs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.objfuncargs.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AccessPriv(n) => {
+                n.cols.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CreateOpClassItem(n) => {
+                if n.name.is_some() {
+                    let name = NodeEnum::ObjectWithArgs(n.name.to_owned().unwrap());
+                    stack.push((name.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: name,
+                        depth: current_depth,
+                    });
+                }
+
+                n.order_family.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.class_args.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.storedtype.is_some() {
+                    let storedtype = NodeEnum::TypeName(n.storedtype.to_owned().unwrap());
+                    stack.push((storedtype.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: storedtype,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::TableLikeClause(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::FunctionParameter(n) => {
+                if n.arg_type.is_some() {
+                    let arg_type = NodeEnum::TypeName(n.arg_type.to_owned().unwrap());
+                    stack.push((arg_type.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: arg_type,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.defexpr.is_some() {
+                    let defexpr = n.defexpr.to_owned().unwrap().node.unwrap();
+                    stack.push((defexpr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: defexpr,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::LockingClause(n) => {
+                n.locked_rels.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RowMarkClause(n) => (),
+            NodeEnum::XmlSerialize(n) => {
+                if n.expr.is_some() {
+                    let expr = n.expr.to_owned().unwrap().node.unwrap();
+                    stack.push((expr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: expr,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.type_name.is_some() {
+                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
+                    stack.push((type_name.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: type_name,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::WithClause(n) => {
+                n.ctes.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::InferClause(n) => {
+                n.index_elems.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::OnConflictClause(n) => {
+                if n.infer.is_some() {
+                    let infer = NodeEnum::InferClause(n.infer.to_owned().unwrap());
+                    stack.push((infer.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: infer,
+                        depth: current_depth,
+                    });
+                }
+
+                n.target_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CtesearchClause(n) => {
+                n.search_col_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::CtecycleClause(n) => {
+                n.cycle_col_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.cycle_mark_value.is_some() {
+                    let cycle_mark_value = n.cycle_mark_value.to_owned().unwrap().node.unwrap();
+                    stack.push((cycle_mark_value.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: cycle_mark_value,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.cycle_mark_default.is_some() {
+                    let cycle_mark_default = n.cycle_mark_default.to_owned().unwrap().node.unwrap();
+                    stack.push((cycle_mark_default.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: cycle_mark_default,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::CommonTableExpr(n) => {
+                n.aliascolnames.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                if n.ctequery.is_some() {
+                    let ctequery = n.ctequery.to_owned().unwrap().node.unwrap();
+                    stack.push((ctequery.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: ctequery,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.search_clause.is_some() {
+                    let search_clause =
+                        NodeEnum::CtesearchClause(n.search_clause.to_owned().unwrap());
+                    stack.push((search_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: search_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.cycle_clause.is_some() {
+                    let cycle_clause = NodeEnum::CtecycleClause(n.cycle_clause.to_owned().unwrap());
+                    stack.push((cycle_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: cycle_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.ctecolnames.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.ctecoltypes.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.ctecoltypmods.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.ctecolcollations.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::MergeWhenClause(n) => {
+                if n.condition.is_some() {
+                    let condition = n.condition.to_owned().unwrap().node.unwrap();
+                    stack.push((condition.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: condition,
+                        depth: current_depth,
+                    });
+                }
+
+                n.target_list.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.values.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::RoleSpec(n) => (),
+            NodeEnum::TriggerTransition(n) => (),
+            NodeEnum::PartitionElem(n) => {
+                if n.expr.is_some() {
+                    let expr = n.expr.to_owned().unwrap().node.unwrap();
+                    stack.push((expr.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: expr,
+                        depth: current_depth,
+                    });
+                }
+
+                n.collation.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.opclass.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::PartitionSpec(n) => {
+                n.part_params.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::PartitionBoundSpec(n) => {
+                n.listdatums.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.lowerdatums.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+
+                n.upperdatums.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::PartitionRangeDatum(n) => {
+                if n.value.is_some() {
+                    let value = n.value.to_owned().unwrap().node.unwrap();
+                    stack.push((value.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: value,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::PartitionCmd(n) => {
+                if n.name.is_some() {
+                    let name = NodeEnum::RangeVar(n.name.to_owned().unwrap());
+                    stack.push((name.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: name,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.bound.is_some() {
+                    let bound = NodeEnum::PartitionBoundSpec(n.bound.to_owned().unwrap());
+                    stack.push((bound.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: bound,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::VacuumRelation(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                n.va_cols.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::PublicationObjSpec(n) => {
+                if n.pubtable.is_some() {
+                    let pubtable = NodeEnum::PublicationTable(n.pubtable.to_owned().unwrap());
+                    stack.push((pubtable.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: pubtable,
+                        depth: current_depth,
+                    });
+                }
+            }
+            NodeEnum::PublicationTable(n) => {
+                if n.relation.is_some() {
+                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
+                    stack.push((relation.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: relation,
+                        depth: current_depth,
+                    });
+                }
+
+                if n.where_clause.is_some() {
+                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
+                    stack.push((where_clause.to_owned(), current_depth));
+                    nodes.push(NestedNode {
+                        node: where_clause,
+                        depth: current_depth,
+                    });
+                }
+
+                n.columns.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::InlineCodeBlock(n) => (),
+            NodeEnum::CallContext(n) => (),
+            NodeEnum::Integer(n) => (),
+            NodeEnum::Float(n) => (),
+            NodeEnum::Boolean(n) => (),
+            NodeEnum::String(n) => (),
+            NodeEnum::BitString(n) => (),
+            NodeEnum::List(n) => {
+                n.items.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::IntList(n) => {
+                n.items.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::OidList(n) => {
+                n.items.iter().for_each(|x| {
+                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    nodes.push(NestedNode {
+                        node: x.node.to_owned().unwrap(),
+                        depth: current_depth,
+                    });
+                });
+            }
+            NodeEnum::AConst(n) => {
+                if n.val.is_some() {
+                    let value = match n.val.to_owned().unwrap() {
+                        pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
+                        pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
+                        pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
+                        pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
+                        pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
+                    };
+
+                    nodes.push(NestedNode {
+                        node: value,
+                        depth: current_depth,
+                    });
+                }
+            }
+        };
     }
+    nodes
 }
diff --git a/crates/parser/src/pg_query_utils_generated_test.rs b/crates/parser/src/pg_query_utils_generated_test.rs
index 63670e11..b3d256ed 100644
--- a/crates/parser/src/pg_query_utils_generated_test.rs
+++ b/crates/parser/src/pg_query_utils_generated_test.rs
@@ -1,3 +1,68 @@
+use pg_query::NodeEnum;
+
+use crate::pg_query_utils_generated::NestedNode;
+
+pub trait RemoveFirst<T> {
+    fn remove_first(&mut self) -> Option<T>;
+}
+
+impl<T> RemoveFirst<T> for Vec<T> {
+    fn remove_first(&mut self) -> Option<T> {
+        if self.is_empty() {
+            return None;
+        }
+        Some(self.remove(0))
+    }
+}
+
+// pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
+//     let mut nodes: Vec<NestedNode> = vec![];
+//
+//     // Node, depth, location
+//     let mut stack: Vec<(NodeEnum, i32)> = vec![(node.to_owned(), current_depth)];
+//
+//     while stack.len() > 0 {
+//         let (node, depth) = stack.remove_first().unwrap();
+//
+//         let current_depth = depth + 1;
+//
+//         match &node {
+//             NodeEnum::Alias(n) => {
+//                 n.colnames.iter().for_each(|x| {
+//                     stack.push((x.node.to_owned().unwrap(), current_depth));
+//                     nodes.push(NestedNode {
+//                         node: x.node.to_owned().unwrap(),
+//                         depth: current_depth,
+//                     });
+//                 });
+//             }
+//             NodeEnum::RangeVar(n) => {
+//                 if n.alias.is_some() {
+//                     let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
+//                     stack.push((alias.to_owned(), current_depth));
+//                     nodes.push(NestedNode {
+//                         node: alias,
+//                         depth: current_depth,
+//                     });
+//                 }
+//             }
+//             NodeEnum::Param(n) => {
+//                 if n.xpr.is_some() {
+//                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
+//                     stack.push((xpr.to_owned(), current_depth));
+//                     nodes.push(NestedNode {
+//                         node: xpr,
+//                         depth: current_depth,
+//                     });
+//                 }
+//             }
+//             _ => panic!("Not implemented"),
+//         };
+//     }
+//
+//     nodes
+// }
+
 #[cfg(test)]
 mod tests {
     use std::assert_eq;
@@ -10,7 +75,8 @@ mod tests {
 
     #[test]
     fn test_get_children() {
-        let input = "select id;";
+        let input =
+            "with t as (insert into contact (id) values ('id') returning *) select id from t;";
 
         let pg_query_root = match pg_query::parse(input) {
             Ok(parsed) => {
@@ -36,11 +102,7 @@ mod tests {
         println!("{:?}", pg_query_root);
 
         let result = get_children(&pg_query_root.unwrap(), 1);
-
         println!("NUMBER OF CHILDREN: {:?}", result.len());
-
-        // TODO: parse AConst correctly
-
         result.iter().for_each(|n| {
             println!("##");
             println!("{:?}", n)

From 623a389079e56f938a075e061551c738354ab0f3 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Mon, 14 Aug 2023 21:38:29 +0200
Subject: [PATCH 06/23] progress on location parsing

---
 crates/parser/src/bin/generate.rs             |   57 +-
 crates/parser/src/lib.rs                      |    1 +
 crates/parser/src/pg_query_utils_generated.rs | 2816 +++++++++++++----
 .../src/pg_query_utils_generated_test.rs      |  178 +-
 crates/parser/src/pg_query_utils_manual.rs    |  361 +++
 5 files changed, 2764 insertions(+), 649 deletions(-)
 create mode 100644 crates/parser/src/pg_query_utils_manual.rs

diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
index be9b1f88..bf5c2996 100644
--- a/crates/parser/src/bin/generate.rs
+++ b/crates/parser/src/bin/generate.rs
@@ -31,6 +31,7 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                     "pg_query".to_string(),
                     vec!["NodeEnum".to_string()],
                 )
+                .with_import("std::collections".to_string(), vec!["VecDeque".to_string()])
                 .finish(),
         )
         .add_block(
@@ -75,20 +76,10 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
             )
             .with_field("node".to_string(), "NodeEnum".to_string())
             .with_field("depth".to_string(), "i32".to_string())
-            // .with_field("location".to_string(), "i32".to_string())
+            .with_field("location".to_string(), "i32".to_string())
+            .with_field("path".to_string(), "String".to_string())
             .finish()
         )
-        // TODO: 1) make it a non-recursive fn because recursiveness in rust ist bad.
-        //          --> for loop with array to put next iteration in.
-        // TODO: 2) add location to NestedNode, and use it in get_children.
-        // TODO:    to get location, first check if node has location field.
-        // TODO:    if not, use the location of the parent.
-        // in some cases, for example cte, location is on a generic Node child, which has a node prop that
-        // contains the actual node (e.g. insert statement) --> if we get the location within
-        // get_children, we can easily get the location of the actual node because we can just
-        // fallback to the location of the immediate parent if the current node does not have a
-        // location.
-        //
         .add_block(
             Function::new("get_children".to_string())
                 .public()
@@ -99,9 +90,9 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                 .with(|b| {
                     let mut content = "let mut nodes: Vec<NestedNode> = vec![];\n".to_string();
                     content.push_str("// Node, depth, location\n");
-                    content.push_str("let mut stack: Vec<(NodeEnum, i32)> = vec![(node.to_owned(), current_depth)];\n");
+                    content.push_str("let mut stack: VecDeque<(NodeEnum, i32, Option<i32>)> = VecDeque::from(vec![(node.to_owned(), current_depth, Some(0))]);\n");
                     content.push_str("while stack.len() > 0 {\n");
-                    content.push_str("let (node, depth) = stack.pop().unwrap();\n");
+                    content.push_str("let (node, depth, parent_location) = stack.pop_front().unwrap();\n");
                     content.push_str("let current_depth = depth + 1;\n");
 
                     let match_ = Match::new("&node".to_string())
@@ -123,6 +114,9 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                 nodes.push(NestedNode {
                     node: value,
                     depth: current_depth,
+                    // this is always the parent location
+                    location: parent_location,
+                    parent_location
                 });
             }
         }";
@@ -138,8 +132,9 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                             field_content.push(
                                                 format!(
                                                     "n.{}.iter().for_each(|x| {{
-                                                        stack.push((x.node.to_owned().unwrap(), current_depth));
-                                                        nodes.push(NestedNode {{ node: x.node.to_owned().unwrap(), depth: current_depth }});
+                                                        let location = get_location(&x.node.as_ref().unwrap());
+                                                        stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
+                                                        nodes.push(NestedNode {{ node: x.node.to_owned().unwrap(), depth: current_depth, location, parent_location }});
                                                     }});\n",
                                                     field.name.to_string()
                                                 )
@@ -157,16 +152,23 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                                 );
                                                 node_content.push_str(
                                                     format!(
-                                                        "stack.push(({}.to_owned(), current_depth));\n",
+                                                        "let location = get_location(&{});\n",
+                                                        field.name.to_string()
+                                                    ).as_str(),
+                                                );
+                                                node_content.push_str(
+                                                    format!(
+                                                        "stack.push_back(({}.to_owned(), current_depth, location));\n",
                                                         field.name.to_string()
                                                     ).as_str(),
-
                                                 );
                                                 node_content.push_str(
                                                     format!(
                                                         "nodes.push(NestedNode {{
                                                             node: {},
                                                             depth: current_depth,
+                                                            location,
+                                                            parent_location
                                                         }});\n",
                                                         field.name.to_string()
                                                     ).as_str(),
@@ -187,7 +189,13 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                                 );
                                                 node_content.push_str(
                                                     format!(
-                                                        "stack.push(({}.to_owned(), current_depth));\n",
+                                                        "let location = get_location(&{});\n",
+                                                        field.name.to_string()
+                                                    ).as_str(),
+                                                );
+                                                node_content.push_str(
+                                                    format!(
+                                                        "stack.push_back(({}.to_owned(), current_depth, location));\n",
                                                         field.name.to_string()
                                                     ).as_str()
                                                 );
@@ -196,6 +204,8 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                                         "nodes.push(NestedNode {{
                                                             node: {},
                                                             depth: current_depth,
+                                                            location,
+                                                            parent_location
                                                         }});\n",
                                                         field.name.to_string()
                                                     ).as_str()
@@ -226,17 +236,10 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                     content.push_str(match_.to_string().as_str());
                     content.push_str(";\n");
 
-
-
-
                     content.push_str("}\n");
+                    content.push_str("nodes.sort_by_key(|n| n.location);\n");
                     content.push_str("nodes");
 
-
-
-
-
-
                     b.with_body(content);
 
                     b
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 4264c919..5bba8887 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -20,6 +20,7 @@ mod parser;
 mod pg_query_utils;
 mod pg_query_utils_generated;
 mod pg_query_utils_generated_test;
+mod pg_query_utils_manual;
 mod source_file;
 mod statement;
 mod syntax_error;
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index 146647dc..e4eb8d84 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -1,6 +1,7 @@
 //! Utilities for working with pg_query.rs
 //! This file is generated from the libg_query proto
 use pg_query::NodeEnum;
+use std::collections::VecDeque;
 
 pub fn get_location(node: &NodeEnum) -> Option<i32> {
     match node {
@@ -247,1075 +248,1432 @@ pub fn get_location(node: &NodeEnum) -> Option<i32> {
 
 #[derive(Debug, Clone)]
 pub struct NestedNode {
-    node: NodeEnum,
-    depth: i32,
+    pub node: NodeEnum,
+    pub depth: i32,
+    pub location: Option<i32>,
+    pub parent_location: Option<i32>,
 }
 
 /// Returns all children of the node, recursively
 pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
     let mut nodes: Vec<NestedNode> = vec![];
     // Node, depth, location
-    let mut stack: Vec<(NodeEnum, i32)> = vec![(node.to_owned(), current_depth)];
+    let mut stack: VecDeque<(NodeEnum, i32, Option<i32>)> =
+        VecDeque::from(vec![(node.to_owned(), current_depth, Some(0))]);
     while stack.len() > 0 {
-        let (node, depth) = stack.pop().unwrap();
+        let (node, depth, parent_location) = stack.pop_front().unwrap();
         let current_depth = depth + 1;
         match &node {
             NodeEnum::Alias(n) => {
                 n.colnames.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::RangeVar(n) => {
                 if n.alias.is_some() {
                     let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    stack.push((alias.to_owned(), current_depth));
+                    let location = get_location(&alias);
+                    stack.push_back((alias.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: alias,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::TableFunc(n) => {
                 n.ns_uris.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.ns_names.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.docexpr.is_some() {
                     let docexpr = n.docexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((docexpr.to_owned(), current_depth));
+                    let location = get_location(&docexpr);
+                    stack.push_back((docexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: docexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.rowexpr.is_some() {
                     let rowexpr = n.rowexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((rowexpr.to_owned(), current_depth));
+                    let location = get_location(&rowexpr);
+                    stack.push_back((rowexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: rowexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.colnames.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.coltypes.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.coltypmods.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.colcollations.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.colexprs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.coldefexprs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::Var(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::Param(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::Aggref(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.aggargtypes.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.aggdirectargs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.aggorder.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.aggdistinct.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.aggfilter.is_some() {
                     let aggfilter = n.aggfilter.to_owned().unwrap().node.unwrap();
-                    stack.push((aggfilter.to_owned(), current_depth));
+                    let location = get_location(&aggfilter);
+                    stack.push_back((aggfilter.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: aggfilter,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::GroupingFunc(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.refs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.cols.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::WindowFunc(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.aggfilter.is_some() {
                     let aggfilter = n.aggfilter.to_owned().unwrap().node.unwrap();
-                    stack.push((aggfilter.to_owned(), current_depth));
+                    let location = get_location(&aggfilter);
+                    stack.push_back((aggfilter.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: aggfilter,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::SubscriptingRef(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.refupperindexpr.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.reflowerindexpr.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.refexpr.is_some() {
                     let refexpr = n.refexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((refexpr.to_owned(), current_depth));
+                    let location = get_location(&refexpr);
+                    stack.push_back((refexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: refexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.refassgnexpr.is_some() {
                     let refassgnexpr = n.refassgnexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((refassgnexpr.to_owned(), current_depth));
+                    let location = get_location(&refassgnexpr);
+                    stack.push_back((refassgnexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: refassgnexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::FuncExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::NamedArgExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::OpExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DistinctExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::NullIfExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ScalarArrayOpExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::BoolExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::SubLink(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.testexpr.is_some() {
                     let testexpr = n.testexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((testexpr.to_owned(), current_depth));
+                    let location = get_location(&testexpr);
+                    stack.push_back((testexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: testexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.oper_name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.subselect.is_some() {
                     let subselect = n.subselect.to_owned().unwrap().node.unwrap();
-                    stack.push((subselect.to_owned(), current_depth));
+                    let location = get_location(&subselect);
+                    stack.push_back((subselect.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: subselect,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::SubPlan(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.testexpr.is_some() {
                     let testexpr = n.testexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((testexpr.to_owned(), current_depth));
+                    let location = get_location(&testexpr);
+                    stack.push_back((testexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: testexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.param_ids.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.set_param.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.par_param.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlternativeSubPlan(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.subplans.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::FieldSelect(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::FieldStore(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.newvals.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.fieldnums.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::RelabelType(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CoerceViaIo(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::ArrayCoerceExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.elemexpr.is_some() {
                     let elemexpr = n.elemexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((elemexpr.to_owned(), current_depth));
+                    let location = get_location(&elemexpr);
+                    stack.push_back((elemexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: elemexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::ConvertRowtypeExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CollateExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CaseExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.defresult.is_some() {
                     let defresult = n.defresult.to_owned().unwrap().node.unwrap();
-                    stack.push((defresult.to_owned(), current_depth));
+                    let location = get_location(&defresult);
+                    stack.push_back((defresult.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: defresult,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CaseWhen(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.expr.is_some() {
                     let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    stack.push((expr.to_owned(), current_depth));
+                    let location = get_location(&expr);
+                    stack.push_back((expr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: expr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.result.is_some() {
                     let result = n.result.to_owned().unwrap().node.unwrap();
-                    stack.push((result.to_owned(), current_depth));
+                    let location = get_location(&result);
+                    stack.push_back((result.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: result,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CaseTestExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::ArrayExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.elements.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::RowExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.colnames.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::RowCompareExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.opnos.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.opfamilies.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.inputcollids.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.largs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.rargs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CoalesceExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::MinMaxExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::SqlvalueFunction(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::XmlExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.named_args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.arg_names.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::NullTest(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::BooleanTest(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CoerceToDomain(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CoerceToDomainValue(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::SetToDefault(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CurrentOfExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::NextValueExpr(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::InferenceElem(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.expr.is_some() {
                     let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    stack.push((expr.to_owned(), current_depth));
+                    let location = get_location(&expr);
+                    stack.push_back((expr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: expr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::TargetEntry(n) => {
                 if n.xpr.is_some() {
                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    stack.push((xpr.to_owned(), current_depth));
+                    let location = get_location(&xpr);
+                    stack.push_back((xpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: xpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.expr.is_some() {
                     let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    stack.push((expr.to_owned(), current_depth));
+                    let location = get_location(&expr);
+                    stack.push_back((expr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: expr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
@@ -1323,898 +1681,1207 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::JoinExpr(n) => {
                 if n.larg.is_some() {
                     let larg = n.larg.to_owned().unwrap().node.unwrap();
-                    stack.push((larg.to_owned(), current_depth));
+                    let location = get_location(&larg);
+                    stack.push_back((larg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: larg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.rarg.is_some() {
                     let rarg = n.rarg.to_owned().unwrap().node.unwrap();
-                    stack.push((rarg.to_owned(), current_depth));
+                    let location = get_location(&rarg);
+                    stack.push_back((rarg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: rarg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.using_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.join_using_alias.is_some() {
                     let join_using_alias = NodeEnum::Alias(n.join_using_alias.to_owned().unwrap());
-                    stack.push((join_using_alias.to_owned(), current_depth));
+                    let location = get_location(&join_using_alias);
+                    stack.push_back((join_using_alias.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: join_using_alias,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.quals.is_some() {
                     let quals = n.quals.to_owned().unwrap().node.unwrap();
-                    stack.push((quals.to_owned(), current_depth));
+                    let location = get_location(&quals);
+                    stack.push_back((quals.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: quals,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.alias.is_some() {
                     let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    stack.push((alias.to_owned(), current_depth));
+                    let location = get_location(&alias);
+                    stack.push_back((alias.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: alias,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::FromExpr(n) => {
                 n.fromlist.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.quals.is_some() {
                     let quals = n.quals.to_owned().unwrap().node.unwrap();
-                    stack.push((quals.to_owned(), current_depth));
+                    let location = get_location(&quals);
+                    stack.push_back((quals.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: quals,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::OnConflictExpr(n) => {
                 n.arbiter_elems.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.arbiter_where.is_some() {
                     let arbiter_where = n.arbiter_where.to_owned().unwrap().node.unwrap();
-                    stack.push((arbiter_where.to_owned(), current_depth));
+                    let location = get_location(&arbiter_where);
+                    stack.push_back((arbiter_where.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arbiter_where,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.on_conflict_set.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.on_conflict_where.is_some() {
                     let on_conflict_where = n.on_conflict_where.to_owned().unwrap().node.unwrap();
-                    stack.push((on_conflict_where.to_owned(), current_depth));
+                    let location = get_location(&on_conflict_where);
+                    stack.push_back((on_conflict_where.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: on_conflict_where,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.excl_rel_tlist.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::IntoClause(n) => {
                 if n.rel.is_some() {
                     let rel = NodeEnum::RangeVar(n.rel.to_owned().unwrap());
-                    stack.push((rel.to_owned(), current_depth));
+                    let location = get_location(&rel);
+                    stack.push_back((rel.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: rel,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.col_names.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.view_query.is_some() {
                     let view_query = n.view_query.to_owned().unwrap().node.unwrap();
-                    stack.push((view_query.to_owned(), current_depth));
+                    let location = get_location(&view_query);
+                    stack.push_back((view_query.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: view_query,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::MergeAction(n) => {
                 if n.qual.is_some() {
                     let qual = n.qual.to_owned().unwrap().node.unwrap();
-                    stack.push((qual.to_owned(), current_depth));
+                    let location = get_location(&qual);
+                    stack.push_back((qual.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: qual,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.target_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.update_colnos.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::RawStmt(n) => {
                 if n.stmt.is_some() {
                     let stmt = n.stmt.to_owned().unwrap().node.unwrap();
-                    stack.push((stmt.to_owned(), current_depth));
+                    let location = get_location(&stmt);
+                    stack.push_back((stmt.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: stmt,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::Query(n) => {
                 if n.utility_stmt.is_some() {
                     let utility_stmt = n.utility_stmt.to_owned().unwrap().node.unwrap();
-                    stack.push((utility_stmt.to_owned(), current_depth));
+                    let location = get_location(&utility_stmt);
+                    stack.push_back((utility_stmt.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: utility_stmt,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.cte_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.rtable.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.jointree.is_some() {
                     let jointree = NodeEnum::FromExpr(n.jointree.to_owned().unwrap());
-                    stack.push((jointree.to_owned(), current_depth));
+                    let location = get_location(&jointree);
+                    stack.push_back((jointree.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: jointree,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.merge_action_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.target_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.on_conflict.is_some() {
                     let on_conflict = NodeEnum::OnConflictExpr(n.on_conflict.to_owned().unwrap());
-                    stack.push((on_conflict.to_owned(), current_depth));
+                    let location = get_location(&on_conflict);
+                    stack.push_back((on_conflict.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: on_conflict,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.returning_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.group_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.grouping_sets.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.having_qual.is_some() {
                     let having_qual = n.having_qual.to_owned().unwrap().node.unwrap();
-                    stack.push((having_qual.to_owned(), current_depth));
+                    let location = get_location(&having_qual);
+                    stack.push_back((having_qual.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: having_qual,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.window_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.distinct_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.sort_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.limit_offset.is_some() {
                     let limit_offset = n.limit_offset.to_owned().unwrap().node.unwrap();
-                    stack.push((limit_offset.to_owned(), current_depth));
+                    let location = get_location(&limit_offset);
+                    stack.push_back((limit_offset.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: limit_offset,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.limit_count.is_some() {
                     let limit_count = n.limit_count.to_owned().unwrap().node.unwrap();
-                    stack.push((limit_count.to_owned(), current_depth));
+                    let location = get_location(&limit_count);
+                    stack.push_back((limit_count.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: limit_count,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.row_marks.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.set_operations.is_some() {
                     let set_operations = n.set_operations.to_owned().unwrap().node.unwrap();
-                    stack.push((set_operations.to_owned(), current_depth));
+                    let location = get_location(&set_operations);
+                    stack.push_back((set_operations.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: set_operations,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.constraint_deps.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.with_check_options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::InsertStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.cols.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.select_stmt.is_some() {
                     let select_stmt = n.select_stmt.to_owned().unwrap().node.unwrap();
-                    stack.push((select_stmt.to_owned(), current_depth));
+                    let location = get_location(&select_stmt);
+                    stack.push_back((select_stmt.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: select_stmt,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.on_conflict_clause.is_some() {
                     let on_conflict_clause =
                         NodeEnum::OnConflictClause(n.on_conflict_clause.to_owned().unwrap());
-                    stack.push((on_conflict_clause.to_owned(), current_depth));
+                    let location = get_location(&on_conflict_clause);
+                    stack.push_back((on_conflict_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: on_conflict_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.returning_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.with_clause.is_some() {
                     let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    stack.push((with_clause.to_owned(), current_depth));
+                    let location = get_location(&with_clause);
+                    stack.push_back((with_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: with_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::DeleteStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.using_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.returning_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.with_clause.is_some() {
                     let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    stack.push((with_clause.to_owned(), current_depth));
+                    let location = get_location(&with_clause);
+                    stack.push_back((with_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: with_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::UpdateStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.target_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.from_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.returning_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.with_clause.is_some() {
                     let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    stack.push((with_clause.to_owned(), current_depth));
+                    let location = get_location(&with_clause);
+                    stack.push_back((with_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: with_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::MergeStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.source_relation.is_some() {
                     let source_relation = n.source_relation.to_owned().unwrap().node.unwrap();
-                    stack.push((source_relation.to_owned(), current_depth));
+                    let location = get_location(&source_relation);
+                    stack.push_back((source_relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: source_relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.join_condition.is_some() {
                     let join_condition = n.join_condition.to_owned().unwrap().node.unwrap();
-                    stack.push((join_condition.to_owned(), current_depth));
+                    let location = get_location(&join_condition);
+                    stack.push_back((join_condition.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: join_condition,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.merge_when_clauses.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.with_clause.is_some() {
                     let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    stack.push((with_clause.to_owned(), current_depth));
+                    let location = get_location(&with_clause);
+                    stack.push_back((with_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: with_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::SelectStmt(n) => {
                 n.distinct_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.into_clause.is_some() {
                     let into_clause = NodeEnum::IntoClause(n.into_clause.to_owned().unwrap());
-                    stack.push((into_clause.to_owned(), current_depth));
+                    let location = get_location(&into_clause);
+                    stack.push_back((into_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: into_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.target_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.from_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.group_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.having_clause.is_some() {
                     let having_clause = n.having_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((having_clause.to_owned(), current_depth));
+                    let location = get_location(&having_clause);
+                    stack.push_back((having_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: having_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.window_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.values_lists.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.sort_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.limit_offset.is_some() {
                     let limit_offset = n.limit_offset.to_owned().unwrap().node.unwrap();
-                    stack.push((limit_offset.to_owned(), current_depth));
+                    let location = get_location(&limit_offset);
+                    stack.push_back((limit_offset.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: limit_offset,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.limit_count.is_some() {
                     let limit_count = n.limit_count.to_owned().unwrap().node.unwrap();
-                    stack.push((limit_count.to_owned(), current_depth));
+                    let location = get_location(&limit_count);
+                    stack.push_back((limit_count.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: limit_count,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.locking_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.with_clause.is_some() {
                     let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    stack.push((with_clause.to_owned(), current_depth));
+                    let location = get_location(&with_clause);
+                    stack.push_back((with_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: with_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.larg.is_some() {
                     let larg = NodeEnum::SelectStmt(n.larg.to_owned().unwrap());
-                    stack.push((larg.to_owned(), current_depth));
+                    let location = get_location(&larg);
+                    stack.push_back((larg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: larg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.rarg.is_some() {
                     let rarg = NodeEnum::SelectStmt(n.rarg.to_owned().unwrap());
-                    stack.push((rarg.to_owned(), current_depth));
+                    let location = get_location(&rarg);
+                    stack.push_back((rarg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: rarg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::ReturnStmt(n) => {
                 if n.returnval.is_some() {
                     let returnval = n.returnval.to_owned().unwrap().node.unwrap();
-                    stack.push((returnval.to_owned(), current_depth));
+                    let location = get_location(&returnval);
+                    stack.push_back((returnval.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: returnval,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::PlassignStmt(n) => {
                 n.indirection.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.val.is_some() {
                     let val = NodeEnum::SelectStmt(n.val.to_owned().unwrap());
-                    stack.push((val.to_owned(), current_depth));
+                    let location = get_location(&val);
+                    stack.push_back((val.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: val,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterTableStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.cmds.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterTableCmd(n) => {
                 if n.newowner.is_some() {
                     let newowner = NodeEnum::RoleSpec(n.newowner.to_owned().unwrap());
-                    stack.push((newowner.to_owned(), current_depth));
+                    let location = get_location(&newowner);
+                    stack.push_back((newowner.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: newowner,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.def.is_some() {
                     let def = n.def.to_owned().unwrap().node.unwrap();
-                    stack.push((def.to_owned(), current_depth));
+                    let location = get_location(&def);
+                    stack.push_back((def.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: def,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterDomainStmt(n) => {
                 n.type_name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.def.is_some() {
                     let def = n.def.to_owned().unwrap().node.unwrap();
-                    stack.push((def.to_owned(), current_depth));
+                    let location = get_location(&def);
+                    stack.push_back((def.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: def,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::SetOperationStmt(n) => {
                 if n.larg.is_some() {
                     let larg = n.larg.to_owned().unwrap().node.unwrap();
-                    stack.push((larg.to_owned(), current_depth));
+                    let location = get_location(&larg);
+                    stack.push_back((larg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: larg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.rarg.is_some() {
                     let rarg = n.rarg.to_owned().unwrap().node.unwrap();
-                    stack.push((rarg.to_owned(), current_depth));
+                    let location = get_location(&rarg);
+                    stack.push_back((rarg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: rarg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.col_types.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.col_typmods.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.col_collations.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.group_clauses.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::GrantStmt(n) => {
                 n.objects.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.privileges.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.grantees.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.grantor.is_some() {
                     let grantor = NodeEnum::RoleSpec(n.grantor.to_owned().unwrap());
-                    stack.push((grantor.to_owned(), current_depth));
+                    let location = get_location(&grantor);
+                    stack.push_back((grantor.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: grantor,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::GrantRoleStmt(n) => {
                 n.granted_roles.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.grantee_roles.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.grantor.is_some() {
                     let grantor = NodeEnum::RoleSpec(n.grantor.to_owned().unwrap());
-                    stack.push((grantor.to_owned(), current_depth));
+                    let location = get_location(&grantor);
+                    stack.push_back((grantor.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: grantor,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterDefaultPrivilegesStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.action.is_some() {
                     let action = NodeEnum::GrantStmt(n.action.to_owned().unwrap());
-                    stack.push((action.to_owned(), current_depth));
+                    let location = get_location(&action);
+                    stack.push_back((action.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: action,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
@@ -2222,184 +2889,247 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::ClusterStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.params.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CopyStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.query.is_some() {
                     let query = n.query.to_owned().unwrap().node.unwrap();
-                    stack.push((query.to_owned(), current_depth));
+                    let location = get_location(&query);
+                    stack.push_back((query.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: query,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.attlist.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreateStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.table_elts.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.inh_relations.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.partbound.is_some() {
                     let partbound = NodeEnum::PartitionBoundSpec(n.partbound.to_owned().unwrap());
-                    stack.push((partbound.to_owned(), current_depth));
+                    let location = get_location(&partbound);
+                    stack.push_back((partbound.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: partbound,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.partspec.is_some() {
                     let partspec = NodeEnum::PartitionSpec(n.partspec.to_owned().unwrap());
-                    stack.push((partspec.to_owned(), current_depth));
+                    let location = get_location(&partspec);
+                    stack.push_back((partspec.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: partspec,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.of_typename.is_some() {
                     let of_typename = NodeEnum::TypeName(n.of_typename.to_owned().unwrap());
-                    stack.push((of_typename.to_owned(), current_depth));
+                    let location = get_location(&of_typename);
+                    stack.push_back((of_typename.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: of_typename,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.constraints.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DefineStmt(n) => {
                 n.defnames.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.definition.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DropStmt(n) => {
                 n.objects.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::TruncateStmt(n) => {
                 n.relations.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CommentStmt(n) => {
                 if n.object.is_some() {
                     let object = n.object.to_owned().unwrap().node.unwrap();
-                    stack.push((object.to_owned(), current_depth));
+                    let location = get_location(&object);
+                    stack.push_back((object.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: object,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
@@ -2407,167 +3137,224 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::IndexStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.index_params.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.index_including_params.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.exclude_op_names.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateFunctionStmt(n) => {
                 n.funcname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.parameters.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.return_type.is_some() {
                     let return_type = NodeEnum::TypeName(n.return_type.to_owned().unwrap());
-                    stack.push((return_type.to_owned(), current_depth));
+                    let location = get_location(&return_type);
+                    stack.push_back((return_type.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: return_type,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.sql_body.is_some() {
                     let sql_body = n.sql_body.to_owned().unwrap().node.unwrap();
-                    stack.push((sql_body.to_owned(), current_depth));
+                    let location = get_location(&sql_body);
+                    stack.push_back((sql_body.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: sql_body,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterFunctionStmt(n) => {
                 if n.func.is_some() {
                     let func = NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap());
-                    stack.push((func.to_owned(), current_depth));
+                    let location = get_location(&func);
+                    stack.push_back((func.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: func,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.actions.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DoStmt(n) => {
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::RenameStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.object.is_some() {
                     let object = n.object.to_owned().unwrap().node.unwrap();
-                    stack.push((object.to_owned(), current_depth));
+                    let location = get_location(&object);
+                    stack.push_back((object.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: object,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::RuleStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.actions.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -2576,198 +3363,264 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::UnlistenStmt(n) => (),
             NodeEnum::TransactionStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ViewStmt(n) => {
                 if n.view.is_some() {
                     let view = NodeEnum::RangeVar(n.view.to_owned().unwrap());
-                    stack.push((view.to_owned(), current_depth));
+                    let location = get_location(&view);
+                    stack.push_back((view.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: view,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.aliases.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.query.is_some() {
                     let query = n.query.to_owned().unwrap().node.unwrap();
-                    stack.push((query.to_owned(), current_depth));
+                    let location = get_location(&query);
+                    stack.push_back((query.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: query,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::LoadStmt(n) => (),
             NodeEnum::CreateDomainStmt(n) => {
                 n.domainname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.type_name.is_some() {
                     let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    stack.push((type_name.to_owned(), current_depth));
+                    let location = get_location(&type_name);
+                    stack.push_back((type_name.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: type_name,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.coll_clause.is_some() {
                     let coll_clause = NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap());
-                    stack.push((coll_clause.to_owned(), current_depth));
+                    let location = get_location(&coll_clause);
+                    stack.push_back((coll_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: coll_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.constraints.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreatedbStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DropdbStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::VacuumStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.rels.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ExplainStmt(n) => {
                 if n.query.is_some() {
                     let query = n.query.to_owned().unwrap().node.unwrap();
-                    stack.push((query.to_owned(), current_depth));
+                    let location = get_location(&query);
+                    stack.push_back((query.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: query,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateTableAsStmt(n) => {
                 if n.query.is_some() {
                     let query = n.query.to_owned().unwrap().node.unwrap();
-                    stack.push((query.to_owned(), current_depth));
+                    let location = get_location(&query);
+                    stack.push_back((query.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: query,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.into.is_some() {
                     let into = NodeEnum::IntoClause(n.into.to_owned().unwrap());
-                    stack.push((into.to_owned(), current_depth));
+                    let location = get_location(&into);
+                    stack.push_back((into.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: into,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreateSeqStmt(n) => {
                 if n.sequence.is_some() {
                     let sequence = NodeEnum::RangeVar(n.sequence.to_owned().unwrap());
-                    stack.push((sequence.to_owned(), current_depth));
+                    let location = get_location(&sequence);
+                    stack.push_back((sequence.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: sequence,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterSeqStmt(n) => {
                 if n.sequence.is_some() {
                     let sequence = NodeEnum::RangeVar(n.sequence.to_owned().unwrap());
-                    stack.push((sequence.to_owned(), current_depth));
+                    let location = get_location(&sequence);
+                    stack.push_back((sequence.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: sequence,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::VariableSetStmt(n) => {
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -2776,157 +3629,211 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::CreateTrigStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.funcname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.columns.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.when_clause.is_some() {
                     let when_clause = n.when_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((when_clause.to_owned(), current_depth));
+                    let location = get_location(&when_clause);
+                    stack.push_back((when_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: when_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.transition_rels.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.constrrel.is_some() {
                     let constrrel = NodeEnum::RangeVar(n.constrrel.to_owned().unwrap());
-                    stack.push((constrrel.to_owned(), current_depth));
+                    let location = get_location(&constrrel);
+                    stack.push_back((constrrel.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: constrrel,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreatePlangStmt(n) => {
                 n.plhandler.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.plinline.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.plvalidator.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateRoleStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterRoleStmt(n) => {
                 if n.role.is_some() {
                     let role = NodeEnum::RoleSpec(n.role.to_owned().unwrap());
-                    stack.push((role.to_owned(), current_depth));
+                    let location = get_location(&role);
+                    stack.push_back((role.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: role,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DropRoleStmt(n) => {
                 n.roles.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::LockStmt(n) => {
                 n.relations.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ConstraintsSetStmt(n) => {
                 n.constraints.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ReindexStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.params.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -2934,27 +3841,36 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::CreateSchemaStmt(n) => {
                 if n.authrole.is_some() {
                     let authrole = NodeEnum::RoleSpec(n.authrole.to_owned().unwrap());
-                    stack.push((authrole.to_owned(), current_depth));
+                    let location = get_location(&authrole);
+                    stack.push_back((authrole.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: authrole,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.schema_elts.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterDatabaseStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -2962,161 +3878,215 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::AlterDatabaseSetStmt(n) => {
                 if n.setstmt.is_some() {
                     let setstmt = NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap());
-                    stack.push((setstmt.to_owned(), current_depth));
+                    let location = get_location(&setstmt);
+                    stack.push_back((setstmt.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: setstmt,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterRoleSetStmt(n) => {
                 if n.role.is_some() {
                     let role = NodeEnum::RoleSpec(n.role.to_owned().unwrap());
-                    stack.push((role.to_owned(), current_depth));
+                    let location = get_location(&role);
+                    stack.push_back((role.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: role,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.setstmt.is_some() {
                     let setstmt = NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap());
-                    stack.push((setstmt.to_owned(), current_depth));
+                    let location = get_location(&setstmt);
+                    stack.push_back((setstmt.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: setstmt,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreateConversionStmt(n) => {
                 n.conversion_name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.func_name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateCastStmt(n) => {
                 if n.sourcetype.is_some() {
                     let sourcetype = NodeEnum::TypeName(n.sourcetype.to_owned().unwrap());
-                    stack.push((sourcetype.to_owned(), current_depth));
+                    let location = get_location(&sourcetype);
+                    stack.push_back((sourcetype.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: sourcetype,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.targettype.is_some() {
                     let targettype = NodeEnum::TypeName(n.targettype.to_owned().unwrap());
-                    stack.push((targettype.to_owned(), current_depth));
+                    let location = get_location(&targettype);
+                    stack.push_back((targettype.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: targettype,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.func.is_some() {
                     let func = NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap());
-                    stack.push((func.to_owned(), current_depth));
+                    let location = get_location(&func);
+                    stack.push_back((func.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: func,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreateOpClassStmt(n) => {
                 n.opclassname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.opfamilyname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.datatype.is_some() {
                     let datatype = NodeEnum::TypeName(n.datatype.to_owned().unwrap());
-                    stack.push((datatype.to_owned(), current_depth));
+                    let location = get_location(&datatype);
+                    stack.push_back((datatype.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: datatype,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.items.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateOpFamilyStmt(n) => {
                 n.opfamilyname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterOpFamilyStmt(n) => {
                 n.opfamilyname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.items.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::PrepareStmt(n) => {
                 n.argtypes.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.query.is_some() {
                     let query = n.query.to_owned().unwrap().node.unwrap();
-                    stack.push((query.to_owned(), current_depth));
+                    let location = get_location(&query);
+                    stack.push_back((query.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: query,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::ExecuteStmt(n) => {
                 n.params.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -3124,28 +4094,37 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::DeclareCursorStmt(n) => {
                 if n.query.is_some() {
                     let query = n.query.to_owned().unwrap().node.unwrap();
-                    stack.push((query.to_owned(), current_depth));
+                    let location = get_location(&query);
+                    stack.push_back((query.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: query,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreateTableSpaceStmt(n) => {
                 if n.owner.is_some() {
                     let owner = NodeEnum::RoleSpec(n.owner.to_owned().unwrap());
-                    stack.push((owner.to_owned(), current_depth));
+                    let location = get_location(&owner);
+                    stack.push_back((owner.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: owner,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -3153,446 +4132,596 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::AlterObjectDependsStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.object.is_some() {
                     let object = n.object.to_owned().unwrap().node.unwrap();
-                    stack.push((object.to_owned(), current_depth));
+                    let location = get_location(&object);
+                    stack.push_back((object.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: object,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.extname.is_some() {
                     let extname = NodeEnum::String(n.extname.to_owned().unwrap());
-                    stack.push((extname.to_owned(), current_depth));
+                    let location = get_location(&extname);
+                    stack.push_back((extname.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: extname,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterObjectSchemaStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.object.is_some() {
                     let object = n.object.to_owned().unwrap().node.unwrap();
-                    stack.push((object.to_owned(), current_depth));
+                    let location = get_location(&object);
+                    stack.push_back((object.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: object,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterOwnerStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.object.is_some() {
                     let object = n.object.to_owned().unwrap().node.unwrap();
-                    stack.push((object.to_owned(), current_depth));
+                    let location = get_location(&object);
+                    stack.push_back((object.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: object,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.newowner.is_some() {
                     let newowner = NodeEnum::RoleSpec(n.newowner.to_owned().unwrap());
-                    stack.push((newowner.to_owned(), current_depth));
+                    let location = get_location(&newowner);
+                    stack.push_back((newowner.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: newowner,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterOperatorStmt(n) => {
                 if n.opername.is_some() {
                     let opername = NodeEnum::ObjectWithArgs(n.opername.to_owned().unwrap());
-                    stack.push((opername.to_owned(), current_depth));
+                    let location = get_location(&opername);
+                    stack.push_back((opername.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: opername,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterTypeStmt(n) => {
                 n.type_name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DropOwnedStmt(n) => {
                 n.roles.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ReassignOwnedStmt(n) => {
                 n.roles.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.newrole.is_some() {
                     let newrole = NodeEnum::RoleSpec(n.newrole.to_owned().unwrap());
-                    stack.push((newrole.to_owned(), current_depth));
+                    let location = get_location(&newrole);
+                    stack.push_back((newrole.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: newrole,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CompositeTypeStmt(n) => {
                 if n.typevar.is_some() {
                     let typevar = NodeEnum::RangeVar(n.typevar.to_owned().unwrap());
-                    stack.push((typevar.to_owned(), current_depth));
+                    let location = get_location(&typevar);
+                    stack.push_back((typevar.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: typevar,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.coldeflist.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateEnumStmt(n) => {
                 n.type_name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.vals.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateRangeStmt(n) => {
                 n.type_name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.params.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterEnumStmt(n) => {
                 n.type_name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterTsdictionaryStmt(n) => {
                 n.dictname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterTsconfigurationStmt(n) => {
                 n.cfgname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.tokentype.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.dicts.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateFdwStmt(n) => {
                 n.func_options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterFdwStmt(n) => {
                 n.func_options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateForeignServerStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterForeignServerStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateUserMappingStmt(n) => {
                 if n.user.is_some() {
                     let user = NodeEnum::RoleSpec(n.user.to_owned().unwrap());
-                    stack.push((user.to_owned(), current_depth));
+                    let location = get_location(&user);
+                    stack.push_back((user.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: user,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterUserMappingStmt(n) => {
                 if n.user.is_some() {
                     let user = NodeEnum::RoleSpec(n.user.to_owned().unwrap());
-                    stack.push((user.to_owned(), current_depth));
+                    let location = get_location(&user);
+                    stack.push_back((user.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: user,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DropUserMappingStmt(n) => {
                 if n.user.is_some() {
                     let user = NodeEnum::RoleSpec(n.user.to_owned().unwrap());
-                    stack.push((user.to_owned(), current_depth));
+                    let location = get_location(&user);
+                    stack.push_back((user.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: user,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterTableSpaceOptionsStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterTableMoveAllStmt(n) => {
                 n.roles.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::SecLabelStmt(n) => {
                 if n.object.is_some() {
                     let object = n.object.to_owned().unwrap().node.unwrap();
-                    stack.push((object.to_owned(), current_depth));
+                    let location = get_location(&object);
+                    stack.push_back((object.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: object,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreateForeignTableStmt(n) => {
                 if n.base_stmt.is_some() {
                     let base_stmt = NodeEnum::CreateStmt(n.base_stmt.to_owned().unwrap());
-                    stack.push((base_stmt.to_owned(), current_depth));
+                    let location = get_location(&base_stmt);
+                    stack.push_back((base_stmt.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: base_stmt,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ImportForeignSchemaStmt(n) => {
                 n.table_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateExtensionStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterExtensionStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterExtensionContentsStmt(n) => {
                 if n.object.is_some() {
                     let object = n.object.to_owned().unwrap().node.unwrap();
-                    stack.push((object.to_owned(), current_depth));
+                    let location = get_location(&object);
+                    stack.push_back((object.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: object,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreateEventTrigStmt(n) => {
                 n.whenclause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.funcname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -3600,10 +4729,13 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::RefreshMatViewStmt(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
@@ -3611,346 +4743,463 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::AlterSystemStmt(n) => {
                 if n.setstmt.is_some() {
                     let setstmt = NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap());
-                    stack.push((setstmt.to_owned(), current_depth));
+                    let location = get_location(&setstmt);
+                    stack.push_back((setstmt.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: setstmt,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreatePolicyStmt(n) => {
                 if n.table.is_some() {
                     let table = NodeEnum::RangeVar(n.table.to_owned().unwrap());
-                    stack.push((table.to_owned(), current_depth));
+                    let location = get_location(&table);
+                    stack.push_back((table.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: table,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.roles.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.qual.is_some() {
                     let qual = n.qual.to_owned().unwrap().node.unwrap();
-                    stack.push((qual.to_owned(), current_depth));
+                    let location = get_location(&qual);
+                    stack.push_back((qual.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: qual,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.with_check.is_some() {
                     let with_check = n.with_check.to_owned().unwrap().node.unwrap();
-                    stack.push((with_check.to_owned(), current_depth));
+                    let location = get_location(&with_check);
+                    stack.push_back((with_check.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: with_check,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AlterPolicyStmt(n) => {
                 if n.table.is_some() {
                     let table = NodeEnum::RangeVar(n.table.to_owned().unwrap());
-                    stack.push((table.to_owned(), current_depth));
+                    let location = get_location(&table);
+                    stack.push_back((table.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: table,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.roles.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.qual.is_some() {
                     let qual = n.qual.to_owned().unwrap().node.unwrap();
-                    stack.push((qual.to_owned(), current_depth));
+                    let location = get_location(&qual);
+                    stack.push_back((qual.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: qual,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.with_check.is_some() {
                     let with_check = n.with_check.to_owned().unwrap().node.unwrap();
-                    stack.push((with_check.to_owned(), current_depth));
+                    let location = get_location(&with_check);
+                    stack.push_back((with_check.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: with_check,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreateTransformStmt(n) => {
                 if n.type_name.is_some() {
                     let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    stack.push((type_name.to_owned(), current_depth));
+                    let location = get_location(&type_name);
+                    stack.push_back((type_name.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: type_name,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.fromsql.is_some() {
                     let fromsql = NodeEnum::ObjectWithArgs(n.fromsql.to_owned().unwrap());
-                    stack.push((fromsql.to_owned(), current_depth));
+                    let location = get_location(&fromsql);
+                    stack.push_back((fromsql.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: fromsql,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.tosql.is_some() {
                     let tosql = NodeEnum::ObjectWithArgs(n.tosql.to_owned().unwrap());
-                    stack.push((tosql.to_owned(), current_depth));
+                    let location = get_location(&tosql);
+                    stack.push_back((tosql.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: tosql,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CreateAmStmt(n) => {
                 n.handler_name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreatePublicationStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.pubobjects.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterPublicationStmt(n) => {
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.pubobjects.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateSubscriptionStmt(n) => {
                 n.publication.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterSubscriptionStmt(n) => {
                 n.publication.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DropSubscriptionStmt(n) => (),
             NodeEnum::CreateStatsStmt(n) => {
                 n.defnames.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.stat_types.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.exprs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.relations.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterCollationStmt(n) => {
                 n.collname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CallStmt(n) => {
                 if n.funccall.is_some() {
                     let funccall = NodeEnum::FuncCall(n.funccall.to_owned().unwrap());
-                    stack.push((funccall.to_owned(), current_depth));
+                    let location = get_location(&funccall);
+                    stack.push_back((funccall.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: funccall,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.funcexpr.is_some() {
                     let funcexpr = NodeEnum::FuncExpr(n.funcexpr.to_owned().unwrap());
-                    stack.push((funcexpr.to_owned(), current_depth));
+                    let location = get_location(&funcexpr);
+                    stack.push_back((funcexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: funcexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.outargs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AlterStatsStmt(n) => {
                 n.defnames.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AExpr(n) => {
                 n.name.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.lexpr.is_some() {
                     let lexpr = n.lexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((lexpr.to_owned(), current_depth));
+                    let location = get_location(&lexpr);
+                    stack.push_back((lexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: lexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.rexpr.is_some() {
                     let rexpr = n.rexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((rexpr.to_owned(), current_depth));
+                    let location = get_location(&rexpr);
+                    stack.push_back((rexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: rexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::ColumnRef(n) => {
                 n.fields.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ParamRef(n) => (),
             NodeEnum::FuncCall(n) => {
                 n.funcname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.agg_order.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.agg_filter.is_some() {
                     let agg_filter = n.agg_filter.to_owned().unwrap().node.unwrap();
-                    stack.push((agg_filter.to_owned(), current_depth));
+                    let location = get_location(&agg_filter);
+                    stack.push_back((agg_filter.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: agg_filter,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.over.is_some() {
                     let over = NodeEnum::WindowDef(n.over.to_owned().unwrap());
-                    stack.push((over.to_owned(), current_depth));
+                    let location = get_location(&over);
+                    stack.push_back((over.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: over,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
@@ -3958,550 +5207,736 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::AIndices(n) => {
                 if n.lidx.is_some() {
                     let lidx = n.lidx.to_owned().unwrap().node.unwrap();
-                    stack.push((lidx.to_owned(), current_depth));
+                    let location = get_location(&lidx);
+                    stack.push_back((lidx.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: lidx,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.uidx.is_some() {
                     let uidx = n.uidx.to_owned().unwrap().node.unwrap();
-                    stack.push((uidx.to_owned(), current_depth));
+                    let location = get_location(&uidx);
+                    stack.push_back((uidx.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: uidx,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::AIndirection(n) => {
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.indirection.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AArrayExpr(n) => {
                 n.elements.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ResTarget(n) => {
                 n.indirection.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.val.is_some() {
                     let val = n.val.to_owned().unwrap().node.unwrap();
-                    stack.push((val.to_owned(), current_depth));
+                    let location = get_location(&val);
+                    stack.push_back((val.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: val,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::MultiAssignRef(n) => {
                 if n.source.is_some() {
                     let source = n.source.to_owned().unwrap().node.unwrap();
-                    stack.push((source.to_owned(), current_depth));
+                    let location = get_location(&source);
+                    stack.push_back((source.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: source,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::TypeCast(n) => {
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.type_name.is_some() {
                     let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    stack.push((type_name.to_owned(), current_depth));
+                    let location = get_location(&type_name);
+                    stack.push_back((type_name.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: type_name,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CollateClause(n) => {
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.collname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::SortBy(n) => {
                 if n.node.is_some() {
                     let node = n.node.to_owned().unwrap().node.unwrap();
-                    stack.push((node.to_owned(), current_depth));
+                    let location = get_location(&node);
+                    stack.push_back((node.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: node,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.use_op.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::WindowDef(n) => {
                 n.partition_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.order_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.start_offset.is_some() {
                     let start_offset = n.start_offset.to_owned().unwrap().node.unwrap();
-                    stack.push((start_offset.to_owned(), current_depth));
+                    let location = get_location(&start_offset);
+                    stack.push_back((start_offset.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: start_offset,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.end_offset.is_some() {
                     let end_offset = n.end_offset.to_owned().unwrap().node.unwrap();
-                    stack.push((end_offset.to_owned(), current_depth));
+                    let location = get_location(&end_offset);
+                    stack.push_back((end_offset.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: end_offset,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::RangeSubselect(n) => {
                 if n.subquery.is_some() {
                     let subquery = n.subquery.to_owned().unwrap().node.unwrap();
-                    stack.push((subquery.to_owned(), current_depth));
+                    let location = get_location(&subquery);
+                    stack.push_back((subquery.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: subquery,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.alias.is_some() {
                     let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    stack.push((alias.to_owned(), current_depth));
+                    let location = get_location(&alias);
+                    stack.push_back((alias.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: alias,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::RangeFunction(n) => {
                 n.functions.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.alias.is_some() {
                     let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    stack.push((alias.to_owned(), current_depth));
+                    let location = get_location(&alias);
+                    stack.push_back((alias.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: alias,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.coldeflist.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::RangeTableSample(n) => {
                 if n.relation.is_some() {
                     let relation = n.relation.to_owned().unwrap().node.unwrap();
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.method.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.repeatable.is_some() {
                     let repeatable = n.repeatable.to_owned().unwrap().node.unwrap();
-                    stack.push((repeatable.to_owned(), current_depth));
+                    let location = get_location(&repeatable);
+                    stack.push_back((repeatable.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: repeatable,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::RangeTableFunc(n) => {
                 if n.docexpr.is_some() {
                     let docexpr = n.docexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((docexpr.to_owned(), current_depth));
+                    let location = get_location(&docexpr);
+                    stack.push_back((docexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: docexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.rowexpr.is_some() {
                     let rowexpr = n.rowexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((rowexpr.to_owned(), current_depth));
+                    let location = get_location(&rowexpr);
+                    stack.push_back((rowexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: rowexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.namespaces.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.columns.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.alias.is_some() {
                     let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    stack.push((alias.to_owned(), current_depth));
+                    let location = get_location(&alias);
+                    stack.push_back((alias.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: alias,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::RangeTableFuncCol(n) => {
                 if n.type_name.is_some() {
                     let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    stack.push((type_name.to_owned(), current_depth));
+                    let location = get_location(&type_name);
+                    stack.push_back((type_name.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: type_name,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.colexpr.is_some() {
                     let colexpr = n.colexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((colexpr.to_owned(), current_depth));
+                    let location = get_location(&colexpr);
+                    stack.push_back((colexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: colexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.coldefexpr.is_some() {
                     let coldefexpr = n.coldefexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((coldefexpr.to_owned(), current_depth));
+                    let location = get_location(&coldefexpr);
+                    stack.push_back((coldefexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: coldefexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::TypeName(n) => {
                 n.names.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.typmods.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.array_bounds.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ColumnDef(n) => {
                 if n.type_name.is_some() {
                     let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    stack.push((type_name.to_owned(), current_depth));
+                    let location = get_location(&type_name);
+                    stack.push_back((type_name.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: type_name,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.raw_default.is_some() {
                     let raw_default = n.raw_default.to_owned().unwrap().node.unwrap();
-                    stack.push((raw_default.to_owned(), current_depth));
+                    let location = get_location(&raw_default);
+                    stack.push_back((raw_default.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: raw_default,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.cooked_default.is_some() {
                     let cooked_default = n.cooked_default.to_owned().unwrap().node.unwrap();
-                    stack.push((cooked_default.to_owned(), current_depth));
+                    let location = get_location(&cooked_default);
+                    stack.push_back((cooked_default.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: cooked_default,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.identity_sequence.is_some() {
                     let identity_sequence =
                         NodeEnum::RangeVar(n.identity_sequence.to_owned().unwrap());
-                    stack.push((identity_sequence.to_owned(), current_depth));
+                    let location = get_location(&identity_sequence);
+                    stack.push_back((identity_sequence.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: identity_sequence,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.coll_clause.is_some() {
                     let coll_clause = NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap());
-                    stack.push((coll_clause.to_owned(), current_depth));
+                    let location = get_location(&coll_clause);
+                    stack.push_back((coll_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: coll_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.constraints.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.fdwoptions.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::IndexElem(n) => {
                 if n.expr.is_some() {
                     let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    stack.push((expr.to_owned(), current_depth));
+                    let location = get_location(&expr);
+                    stack.push_back((expr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: expr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.collation.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.opclass.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.opclassopts.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::StatsElem(n) => {
                 if n.expr.is_some() {
                     let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    stack.push((expr.to_owned(), current_depth));
+                    let location = get_location(&expr);
+                    stack.push_back((expr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: expr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::Constraint(n) => {
                 if n.raw_expr.is_some() {
                     let raw_expr = n.raw_expr.to_owned().unwrap().node.unwrap();
-                    stack.push((raw_expr.to_owned(), current_depth));
+                    let location = get_location(&raw_expr);
+                    stack.push_back((raw_expr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: raw_expr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.keys.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.including.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.exclusions.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.options.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.pktable.is_some() {
                     let pktable = NodeEnum::RangeVar(n.pktable.to_owned().unwrap());
-                    stack.push((pktable.to_owned(), current_depth));
+                    let location = get_location(&pktable);
+                    stack.push_back((pktable.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: pktable,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.fk_attrs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.pk_attrs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.fk_del_set_cols.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.old_conpfeqop.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::DefElem(n) => {
                 if n.arg.is_some() {
                     let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    stack.push((arg.to_owned(), current_depth));
+                    let location = get_location(&arg);
+                    stack.push_back((arg.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
@@ -4509,357 +5944,480 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                 if n.tablesample.is_some() {
                     let tablesample =
                         NodeEnum::TableSampleClause(n.tablesample.to_owned().unwrap());
-                    stack.push((tablesample.to_owned(), current_depth));
+                    let location = get_location(&tablesample);
+                    stack.push_back((tablesample.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: tablesample,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.subquery.is_some() {
                     let subquery = NodeEnum::Query(n.subquery.to_owned().unwrap());
-                    stack.push((subquery.to_owned(), current_depth));
+                    let location = get_location(&subquery);
+                    stack.push_back((subquery.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: subquery,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.joinaliasvars.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.joinleftcols.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.joinrightcols.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.join_using_alias.is_some() {
                     let join_using_alias = NodeEnum::Alias(n.join_using_alias.to_owned().unwrap());
-                    stack.push((join_using_alias.to_owned(), current_depth));
+                    let location = get_location(&join_using_alias);
+                    stack.push_back((join_using_alias.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: join_using_alias,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.functions.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.tablefunc.is_some() {
                     let tablefunc = NodeEnum::TableFunc(n.tablefunc.to_owned().unwrap());
-                    stack.push((tablefunc.to_owned(), current_depth));
+                    let location = get_location(&tablefunc);
+                    stack.push_back((tablefunc.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: tablefunc,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.values_lists.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.coltypes.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.coltypmods.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.colcollations.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.alias.is_some() {
                     let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    stack.push((alias.to_owned(), current_depth));
+                    let location = get_location(&alias);
+                    stack.push_back((alias.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: alias,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.eref.is_some() {
                     let eref = NodeEnum::Alias(n.eref.to_owned().unwrap());
-                    stack.push((eref.to_owned(), current_depth));
+                    let location = get_location(&eref);
+                    stack.push_back((eref.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: eref,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.security_quals.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::RangeTblFunction(n) => {
                 if n.funcexpr.is_some() {
                     let funcexpr = n.funcexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((funcexpr.to_owned(), current_depth));
+                    let location = get_location(&funcexpr);
+                    stack.push_back((funcexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: funcexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.funccolnames.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.funccoltypes.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.funccoltypmods.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.funccolcollations.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::TableSampleClause(n) => {
                 n.args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.repeatable.is_some() {
                     let repeatable = n.repeatable.to_owned().unwrap().node.unwrap();
-                    stack.push((repeatable.to_owned(), current_depth));
+                    let location = get_location(&repeatable);
+                    stack.push_back((repeatable.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: repeatable,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::WithCheckOption(n) => {
                 if n.qual.is_some() {
                     let qual = n.qual.to_owned().unwrap().node.unwrap();
-                    stack.push((qual.to_owned(), current_depth));
+                    let location = get_location(&qual);
+                    stack.push_back((qual.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: qual,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::SortGroupClause(n) => (),
             NodeEnum::GroupingSet(n) => {
                 n.content.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::WindowClause(n) => {
                 n.partition_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.order_clause.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.start_offset.is_some() {
                     let start_offset = n.start_offset.to_owned().unwrap().node.unwrap();
-                    stack.push((start_offset.to_owned(), current_depth));
+                    let location = get_location(&start_offset);
+                    stack.push_back((start_offset.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: start_offset,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.end_offset.is_some() {
                     let end_offset = n.end_offset.to_owned().unwrap().node.unwrap();
-                    stack.push((end_offset.to_owned(), current_depth));
+                    let location = get_location(&end_offset);
+                    stack.push_back((end_offset.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: end_offset,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.run_condition.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::ObjectWithArgs(n) => {
                 n.objname.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.objargs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.objfuncargs.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::AccessPriv(n) => {
                 n.cols.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CreateOpClassItem(n) => {
                 if n.name.is_some() {
                     let name = NodeEnum::ObjectWithArgs(n.name.to_owned().unwrap());
-                    stack.push((name.to_owned(), current_depth));
+                    let location = get_location(&name);
+                    stack.push_back((name.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: name,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.order_family.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.class_args.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.storedtype.is_some() {
                     let storedtype = NodeEnum::TypeName(n.storedtype.to_owned().unwrap());
-                    stack.push((storedtype.to_owned(), current_depth));
+                    let location = get_location(&storedtype);
+                    stack.push_back((storedtype.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: storedtype,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::TableLikeClause(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::FunctionParameter(n) => {
                 if n.arg_type.is_some() {
                     let arg_type = NodeEnum::TypeName(n.arg_type.to_owned().unwrap());
-                    stack.push((arg_type.to_owned(), current_depth));
+                    let location = get_location(&arg_type);
+                    stack.push_back((arg_type.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: arg_type,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.defexpr.is_some() {
                     let defexpr = n.defexpr.to_owned().unwrap().node.unwrap();
-                    stack.push((defexpr.to_owned(), current_depth));
+                    let location = get_location(&defexpr);
+                    stack.push_back((defexpr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: defexpr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::LockingClause(n) => {
                 n.locked_rels.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -4867,204 +6425,273 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::XmlSerialize(n) => {
                 if n.expr.is_some() {
                     let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    stack.push((expr.to_owned(), current_depth));
+                    let location = get_location(&expr);
+                    stack.push_back((expr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: expr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.type_name.is_some() {
                     let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    stack.push((type_name.to_owned(), current_depth));
+                    let location = get_location(&type_name);
+                    stack.push_back((type_name.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: type_name,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::WithClause(n) => {
                 n.ctes.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::InferClause(n) => {
                 n.index_elems.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::OnConflictClause(n) => {
                 if n.infer.is_some() {
                     let infer = NodeEnum::InferClause(n.infer.to_owned().unwrap());
-                    stack.push((infer.to_owned(), current_depth));
+                    let location = get_location(&infer);
+                    stack.push_back((infer.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: infer,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.target_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CtesearchClause(n) => {
                 n.search_col_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::CtecycleClause(n) => {
                 n.cycle_col_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.cycle_mark_value.is_some() {
                     let cycle_mark_value = n.cycle_mark_value.to_owned().unwrap().node.unwrap();
-                    stack.push((cycle_mark_value.to_owned(), current_depth));
+                    let location = get_location(&cycle_mark_value);
+                    stack.push_back((cycle_mark_value.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: cycle_mark_value,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.cycle_mark_default.is_some() {
                     let cycle_mark_default = n.cycle_mark_default.to_owned().unwrap().node.unwrap();
-                    stack.push((cycle_mark_default.to_owned(), current_depth));
+                    let location = get_location(&cycle_mark_default);
+                    stack.push_back((cycle_mark_default.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: cycle_mark_default,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::CommonTableExpr(n) => {
                 n.aliascolnames.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 if n.ctequery.is_some() {
                     let ctequery = n.ctequery.to_owned().unwrap().node.unwrap();
-                    stack.push((ctequery.to_owned(), current_depth));
+                    let location = get_location(&ctequery);
+                    stack.push_back((ctequery.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: ctequery,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.search_clause.is_some() {
                     let search_clause =
                         NodeEnum::CtesearchClause(n.search_clause.to_owned().unwrap());
-                    stack.push((search_clause.to_owned(), current_depth));
+                    let location = get_location(&search_clause);
+                    stack.push_back((search_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: search_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.cycle_clause.is_some() {
                     let cycle_clause = NodeEnum::CtecycleClause(n.cycle_clause.to_owned().unwrap());
-                    stack.push((cycle_clause.to_owned(), current_depth));
+                    let location = get_location(&cycle_clause);
+                    stack.push_back((cycle_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: cycle_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.ctecolnames.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.ctecoltypes.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.ctecoltypmods.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.ctecolcollations.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::MergeWhenClause(n) => {
                 if n.condition.is_some() {
                     let condition = n.condition.to_owned().unwrap().node.unwrap();
-                    stack.push((condition.to_owned(), current_depth));
+                    let location = get_location(&condition);
+                    stack.push_back((condition.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: condition,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.target_list.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.values.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -5073,144 +6700,192 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::PartitionElem(n) => {
                 if n.expr.is_some() {
                     let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    stack.push((expr.to_owned(), current_depth));
+                    let location = get_location(&expr);
+                    stack.push_back((expr.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: expr,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.collation.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.opclass.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::PartitionSpec(n) => {
                 n.part_params.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::PartitionBoundSpec(n) => {
                 n.listdatums.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.lowerdatums.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
 
                 n.upperdatums.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::PartitionRangeDatum(n) => {
                 if n.value.is_some() {
                     let value = n.value.to_owned().unwrap().node.unwrap();
-                    stack.push((value.to_owned(), current_depth));
+                    let location = get_location(&value);
+                    stack.push_back((value.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: value,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::PartitionCmd(n) => {
                 if n.name.is_some() {
                     let name = NodeEnum::RangeVar(n.name.to_owned().unwrap());
-                    stack.push((name.to_owned(), current_depth));
+                    let location = get_location(&name);
+                    stack.push_back((name.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: name,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.bound.is_some() {
                     let bound = NodeEnum::PartitionBoundSpec(n.bound.to_owned().unwrap());
-                    stack.push((bound.to_owned(), current_depth));
+                    let location = get_location(&bound);
+                    stack.push_back((bound.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: bound,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::VacuumRelation(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.va_cols.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::PublicationObjSpec(n) => {
                 if n.pubtable.is_some() {
                     let pubtable = NodeEnum::PublicationTable(n.pubtable.to_owned().unwrap());
-                    stack.push((pubtable.to_owned(), current_depth));
+                    let location = get_location(&pubtable);
+                    stack.push_back((pubtable.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: pubtable,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
             }
             NodeEnum::PublicationTable(n) => {
                 if n.relation.is_some() {
                     let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    stack.push((relation.to_owned(), current_depth));
+                    let location = get_location(&relation);
+                    stack.push_back((relation.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: relation,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 if n.where_clause.is_some() {
                     let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    stack.push((where_clause.to_owned(), current_depth));
+                    let location = get_location(&where_clause);
+                    stack.push_back((where_clause.to_owned(), current_depth, location));
                     nodes.push(NestedNode {
                         node: where_clause,
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 }
 
                 n.columns.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -5223,28 +6898,37 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
             NodeEnum::BitString(n) => (),
             NodeEnum::List(n) => {
                 n.items.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::IntList(n) => {
                 n.items.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
             NodeEnum::OidList(n) => {
                 n.items.iter().for_each(|x| {
-                    stack.push((x.node.to_owned().unwrap(), current_depth));
+                    let location = get_location(&x.node.as_ref().unwrap());
+                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
                     nodes.push(NestedNode {
                         node: x.node.to_owned().unwrap(),
                         depth: current_depth,
+                        location,
+                        parent_location,
                     });
                 });
             }
@@ -5261,10 +6945,14 @@ pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
                     nodes.push(NestedNode {
                         node: value,
                         depth: current_depth,
+                        // this is always the parent location
+                        location: parent_location,
+                        parent_location,
                     });
                 }
             }
         };
     }
+    nodes.sort_by_key(|n| n.location);
     nodes
 }
diff --git a/crates/parser/src/pg_query_utils_generated_test.rs b/crates/parser/src/pg_query_utils_generated_test.rs
index b3d256ed..5883f357 100644
--- a/crates/parser/src/pg_query_utils_generated_test.rs
+++ b/crates/parser/src/pg_query_utils_generated_test.rs
@@ -1,67 +1,129 @@
-use pg_query::NodeEnum;
+use std::collections::VecDeque;
 
-use crate::pg_query_utils_generated::NestedNode;
+use pg_query::{Node, NodeEnum};
 
-pub trait RemoveFirst<T> {
-    fn remove_first(&mut self) -> Option<T>;
-}
+use crate::{pg_query_utils_generated::get_location, pg_query_utils_manual::derive_location};
 
-impl<T> RemoveFirst<T> for Vec<T> {
-    fn remove_first(&mut self) -> Option<T> {
-        if self.is_empty() {
-            return None;
-        }
-        Some(self.remove(0))
-    }
+#[derive(Debug, Clone)]
+struct NestedNode {
+    node: NodeEnum,
+    depth: i32,
+    location: i32,
+    path: String,
 }
 
-// pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
-//     let mut nodes: Vec<NestedNode> = vec![];
-//
-//     // Node, depth, location
-//     let mut stack: Vec<(NodeEnum, i32)> = vec![(node.to_owned(), current_depth)];
-//
-//     while stack.len() > 0 {
-//         let (node, depth) = stack.remove_first().unwrap();
+// some nodes that do not have a loc property, but have the same loc as their only child, eg AConst
+// some nodes do not have a loc property, but have the same loc as their parent, e.g. AStar
+
+// Problem: we need to get the location of a node, but many do not have a location property.
+// 1. get children with location Option<i32>
+// 2. if get_location returns None
+//   a. call get children for node
+//   b. apply regexp on input after get location of parent
+//   c. if just one match, return its location. if more than one, return the one that is the first before the earliest child location.
 //
-//         let current_depth = depth + 1;
+// start with parent location 0. for this to work, we have to resolve the location of the parent
+// first.
 //
-//         match &node {
-//             NodeEnum::Alias(n) => {
-//                 n.colnames.iter().for_each(|x| {
-//                     stack.push((x.node.to_owned().unwrap(), current_depth));
-//                     nodes.push(NestedNode {
-//                         node: x.node.to_owned().unwrap(),
-//                         depth: current_depth,
-//                     });
-//                 });
-//             }
-//             NodeEnum::RangeVar(n) => {
-//                 if n.alias.is_some() {
-//                     let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-//                     stack.push((alias.to_owned(), current_depth));
-//                     nodes.push(NestedNode {
-//                         node: alias,
-//                         depth: current_depth,
-//                     });
-//                 }
-//             }
-//             NodeEnum::Param(n) => {
-//                 if n.xpr.is_some() {
-//                     let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-//                     stack.push((xpr.to_owned(), current_depth));
-//                     nodes.push(NestedNode {
-//                         node: xpr,
-//                         depth: current_depth,
-//                     });
-//                 }
-//             }
-//             _ => panic!("Not implemented"),
-//         };
-//     }
+// if select with list.
+// - select has parent, so i can get its location via regexp and parent location. --> wrong: we
+// dont have the children locations at this point
+// - then for children, i have parent, so both location and parent location are never None.
 //
-//     nodes
-// }
+// add location_stack:
+// - if no location prop, add to location stack with an id / path. the stack must be lifo.
+// - nodes in stack have parent id / path. the id could be something like "1.2", where 1 is the parent of parent id,
+// and 2 is the direct parent id.
+// - when nodes are resolved, work on location stack before starting with nodes again
+// - get location of parent node
+// - get childs from nodes list (if i am id 1.2, get all nodes that start with 1.2) and get earliest location from them
+
+pub fn get_children_test(node: &NodeEnum, text: String, current_depth: i32) -> Vec<NestedNode> {
+    let mut nodes: Vec<NestedNode> = vec![];
+
+    // node, depth, parent_location, path
+    let mut stack: VecDeque<(NodeEnum, i32, String)> =
+        VecDeque::from(vec![(node.to_owned(), current_depth, "0".to_string())]);
+
+    // node, depth, path
+    let mut location_stack: VecDeque<(NodeEnum, i32, String)> = VecDeque::new();
+
+    while !stack.is_empty() || !location_stack.is_empty() {
+        if !stack.is_empty() {
+            let (node, depth, path) = stack.pop_front().unwrap();
+            let current_depth = depth + 1;
+            let mut child_ctr: i32 = 0;
+
+            let mut handle_child = |c: NodeEnum| {
+                let location = get_location(&c);
+                let path = path.clone() + "." + child_ctr.to_string().as_str();
+                child_ctr = child_ctr + 1;
+                stack.push_back((c.to_owned(), current_depth, path.clone()));
+                if location.is_some() {
+                    nodes.push(NestedNode {
+                        node: c,
+                        depth: current_depth,
+                        location: location.unwrap(),
+                        path: path.clone(),
+                    });
+                } else {
+                    location_stack.push_back((c, current_depth, path));
+                }
+            };
+
+            match &node {
+                NodeEnum::Alias(n) => {
+                    n.colnames
+                        .iter()
+                        .for_each(|n| handle_child(n.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RangeVar(n) => {
+                    if n.alias.is_some() {
+                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
+                    }
+                }
+                n => {
+                    println!("{:?}", n);
+                    todo!();
+                }
+            }
+        } else if !location_stack.is_empty() {
+            // then, start with the beginning. we now always have a location for a parent, and SHOULD HAVE at least one child location. to get childs, use "starts_with(my_path)".
+            // if no child, pass earliest_child_location = None
+            let (node, depth, path) = location_stack.pop_front().unwrap();
+            let parent_location = nodes
+                .iter()
+                .find(|n| {
+                    let mut path_elements = path.split(".").collect::<Vec<&str>>();
+                    path_elements.pop();
+                    let parent_path = path_elements.join(".");
+                    n.path == parent_path
+                })
+                .unwrap()
+                .location;
+            // get earliest child
+            let earliest_child_location = nodes
+                .iter()
+                .filter(|n| n.path.starts_with(path.as_str()))
+                .min_by(|a, b| a.location.cmp(&b.location))
+                .map(|n| n.location);
+            let location = derive_location(
+                &node,
+                text.clone(),
+                parent_location,
+                earliest_child_location,
+            );
+            nodes.push(NestedNode {
+                node,
+                depth,
+                location,
+                path: path.clone(),
+            });
+        }
+    }
+
+    nodes
+}
 
 #[cfg(test)]
 mod tests {
@@ -70,13 +132,13 @@ mod tests {
     use std::path::Path;
 
     use crate::pg_query_utils_generated::get_children;
+    // use crate::pg_query_utils_generated_test::get_children_test;
 
     const VALID_STATEMENTS_PATH: &str = "test_data/statements/valid/";
 
     #[test]
     fn test_get_children() {
-        let input =
-            "with t as (insert into contact (id) values ('id') returning *) select id from t;";
+        let input = "with c as (insert into contact (id) values ('id') select * from c;";
 
         let pg_query_root = match pg_query::parse(input) {
             Ok(parsed) => {
diff --git a/crates/parser/src/pg_query_utils_manual.rs b/crates/parser/src/pg_query_utils_manual.rs
new file mode 100644
index 00000000..60c2b8eb
--- /dev/null
+++ b/crates/parser/src/pg_query_utils_manual.rs
@@ -0,0 +1,361 @@
+use pg_query::NodeEnum;
+use regex::Regex;
+
+use crate::pg_query_utils_generated::NestedNode;
+
+fn get_location_via_regexp(
+    r: Regex,
+    text: String,
+    parent_location: i32,
+    earliest_child_location: Option<i32>,
+) -> i32 {
+    struct Location {
+        location: i32,
+        distance: i32,
+    }
+
+    let l = r
+        .find_iter(text.as_str())
+        .filter_map(|x| {
+            if x.start() as i32 > parent_location {
+                Some({
+                    Location {
+                        location: x.start() as i32,
+                        distance: earliest_child_location.unwrap() - x.start() as i32,
+                    }
+                })
+            } else {
+                None
+            }
+        })
+        .min_by(|a, b| a.distance.cmp(&b.distance));
+    l.unwrap().location
+}
+
+/// This is the only manual implementation required for the parser
+/// The problem this functions is attempting to solve is that not all nodes have a location property
+/// As of now, I have found three different cases:
+/// - The node location is easily derivable from the text, e.g. `delete from`
+/// - The node location is the same as its immediate parent node, e.g. `AStar`
+/// - The node location is the same as their only child, e.g. `AConst`
+///
+/// Some nodes such as will be more complex `Alias` will require a special implementation
+///
+/// if no location, always append to location stack (no parent location, append to location stack children with no location need to be appended too)
+/// then, work on all other nodes
+/// then, start with the beginning. we now always have a location for a parent, and SHOULD HAVE at least one child location. to get childs, use "starts_with(my_path)".
+/// if no child, pass earliest_child_location = None
+///
+/// NOTE: to get path, just count on children of match arm in get_childen
+pub fn derive_location(
+    node: &NodeEnum,
+    text: String,
+    parent_location: i32,
+    // not given if node does not have any children
+    earliest_child_location: Option<i32>,
+) -> i32 {
+    match node {
+        NodeEnum::Alias(_) => todo!(),
+        NodeEnum::RangeVar(_) => panic!("Node has location property."),
+        NodeEnum::TableFunc(_) => panic!("Node has location property."),
+        NodeEnum::Var(_) => panic!("Node has location property."),
+        NodeEnum::Param(_) => panic!("Node has location property."),
+        NodeEnum::Aggref(_) => panic!("Node has location property."),
+        NodeEnum::GroupingFunc(_) => panic!("Node has location property."),
+        NodeEnum::WindowFunc(_) => panic!("Node has location property."),
+        NodeEnum::SubscriptingRef(_) => todo!(),
+        NodeEnum::FuncExpr(_) => panic!("Node has location property."),
+        NodeEnum::NamedArgExpr(_) => panic!("Node has location property."),
+        NodeEnum::OpExpr(_) => panic!("Node has location property."),
+        NodeEnum::DistinctExpr(_) => panic!("Node has location property."),
+        NodeEnum::NullIfExpr(_) => panic!("Node has location property."),
+        NodeEnum::ScalarArrayOpExpr(_) => panic!("Node has location property."),
+        NodeEnum::BoolExpr(_) => panic!("Node has location property."),
+        NodeEnum::SubLink(_) => panic!("Node has location property."),
+        NodeEnum::SubPlan(_) => todo!(),
+        NodeEnum::AlternativeSubPlan(_) => todo!(),
+        NodeEnum::FieldSelect(_) => todo!(),
+        NodeEnum::FieldStore(_) => todo!(),
+        NodeEnum::RelabelType(_) => panic!("Node has location property."),
+        NodeEnum::CoerceViaIo(_) => panic!("Node has location property."),
+        NodeEnum::ArrayCoerceExpr(_) => panic!("Node has location property."),
+        NodeEnum::ConvertRowtypeExpr(_) => panic!("Node has location property."),
+        NodeEnum::CollateExpr(_) => panic!("Node has location property."),
+        NodeEnum::CaseExpr(_) => panic!("Node has location property."),
+        NodeEnum::CaseWhen(_) => panic!("Node has location property."),
+        NodeEnum::CaseTestExpr(_) => todo!(),
+        NodeEnum::ArrayExpr(_) => panic!("Node has location property."),
+        NodeEnum::RowExpr(_) => panic!("Node has location property."),
+        NodeEnum::RowCompareExpr(_) => todo!(),
+        NodeEnum::CoalesceExpr(_) => panic!("Node has location property."),
+        NodeEnum::MinMaxExpr(_) => panic!("Node has location property."),
+        NodeEnum::SqlvalueFunction(_) => panic!("Node has location property."),
+        NodeEnum::XmlExpr(_) => panic!("Node has location property."),
+        NodeEnum::NullTest(_) => panic!("Node has location property."),
+        NodeEnum::BooleanTest(_) => panic!("Node has location property."),
+        NodeEnum::CoerceToDomain(_) => panic!("Node has location property."),
+        NodeEnum::CoerceToDomainValue(_) => panic!("Node has location property."),
+        NodeEnum::SetToDefault(_) => panic!("Node has location property."),
+        NodeEnum::CurrentOfExpr(_) => todo!(),
+        NodeEnum::NextValueExpr(_) => todo!(),
+        NodeEnum::InferenceElem(_) => todo!(),
+        NodeEnum::TargetEntry(_) => todo!(),
+        NodeEnum::RangeTblRef(_) => todo!(),
+        NodeEnum::JoinExpr(_) => todo!(),
+        NodeEnum::FromExpr(_) => todo!(),
+        NodeEnum::OnConflictExpr(_) => todo!(),
+        NodeEnum::IntoClause(_) => todo!(),
+        NodeEnum::MergeAction(_) => todo!(),
+        NodeEnum::RawStmt(_) => todo!(),
+        NodeEnum::Query(_) => todo!(),
+        NodeEnum::InsertStmt(_) => get_location_via_regexp(
+            Regex::new(r"(?mi)insert into").unwrap(),
+            text,
+            parent_location,
+            earliest_child_location,
+        ),
+        NodeEnum::DeleteStmt(_) => get_location_via_regexp(
+            Regex::new(r"(?mi)delete from").unwrap(),
+            text,
+            parent_location,
+            earliest_child_location,
+        ),
+        NodeEnum::UpdateStmt(_) => todo!(),
+        NodeEnum::MergeStmt(_) => todo!(),
+        NodeEnum::SelectStmt(_) => todo!(),
+        NodeEnum::ReturnStmt(_) => todo!(),
+        NodeEnum::PlassignStmt(_) => panic!("Node has location property."),
+        NodeEnum::AlterTableStmt(_) => todo!(),
+        NodeEnum::AlterTableCmd(_) => todo!(),
+        NodeEnum::AlterDomainStmt(_) => todo!(),
+        NodeEnum::SetOperationStmt(_) => todo!(),
+        NodeEnum::GrantStmt(_) => todo!(),
+        NodeEnum::GrantRoleStmt(_) => todo!(),
+        NodeEnum::AlterDefaultPrivilegesStmt(_) => todo!(),
+        NodeEnum::ClosePortalStmt(_) => todo!(),
+        NodeEnum::ClusterStmt(_) => todo!(),
+        NodeEnum::CopyStmt(_) => todo!(),
+        NodeEnum::CreateStmt(_) => todo!(),
+        NodeEnum::DefineStmt(_) => todo!(),
+        NodeEnum::DropStmt(_) => todo!(),
+        NodeEnum::TruncateStmt(_) => todo!(),
+        NodeEnum::CommentStmt(_) => todo!(),
+        NodeEnum::FetchStmt(_) => todo!(),
+        NodeEnum::IndexStmt(_) => todo!(),
+        NodeEnum::CreateFunctionStmt(_) => todo!(),
+        NodeEnum::AlterFunctionStmt(_) => todo!(),
+        NodeEnum::DoStmt(_) => todo!(),
+        NodeEnum::RenameStmt(_) => todo!(),
+        NodeEnum::RuleStmt(_) => todo!(),
+        NodeEnum::NotifyStmt(_) => todo!(),
+        NodeEnum::ListenStmt(_) => todo!(),
+        NodeEnum::UnlistenStmt(_) => todo!(),
+        NodeEnum::TransactionStmt(_) => todo!(),
+        NodeEnum::ViewStmt(_) => todo!(),
+        NodeEnum::LoadStmt(_) => todo!(),
+        NodeEnum::CreateDomainStmt(_) => todo!(),
+        NodeEnum::CreatedbStmt(_) => todo!(),
+        NodeEnum::DropdbStmt(_) => todo!(),
+        NodeEnum::VacuumStmt(_) => todo!(),
+        NodeEnum::ExplainStmt(_) => todo!(),
+        NodeEnum::CreateTableAsStmt(_) => todo!(),
+        NodeEnum::CreateSeqStmt(_) => todo!(),
+        NodeEnum::AlterSeqStmt(_) => todo!(),
+        NodeEnum::VariableSetStmt(_) => todo!(),
+        NodeEnum::VariableShowStmt(_) => todo!(),
+        NodeEnum::DiscardStmt(_) => todo!(),
+        NodeEnum::CreateTrigStmt(_) => todo!(),
+        NodeEnum::CreatePlangStmt(_) => todo!(),
+        NodeEnum::CreateRoleStmt(_) => todo!(),
+        NodeEnum::AlterRoleStmt(_) => todo!(),
+        NodeEnum::DropRoleStmt(_) => todo!(),
+        NodeEnum::LockStmt(_) => todo!(),
+        NodeEnum::ConstraintsSetStmt(_) => todo!(),
+        NodeEnum::ReindexStmt(_) => todo!(),
+        NodeEnum::CheckPointStmt(_) => todo!(),
+        NodeEnum::CreateSchemaStmt(_) => todo!(),
+        NodeEnum::AlterDatabaseStmt(_) => todo!(),
+        NodeEnum::AlterDatabaseRefreshCollStmt(_) => todo!(),
+        NodeEnum::AlterDatabaseSetStmt(_) => todo!(),
+        NodeEnum::AlterRoleSetStmt(_) => todo!(),
+        NodeEnum::CreateConversionStmt(_) => todo!(),
+        NodeEnum::CreateCastStmt(_) => todo!(),
+        NodeEnum::CreateOpClassStmt(_) => todo!(),
+        NodeEnum::CreateOpFamilyStmt(_) => todo!(),
+        NodeEnum::AlterOpFamilyStmt(_) => todo!(),
+        NodeEnum::PrepareStmt(_) => todo!(),
+        NodeEnum::ExecuteStmt(_) => todo!(),
+        NodeEnum::DeallocateStmt(_) => todo!(),
+        NodeEnum::DeclareCursorStmt(_) => todo!(),
+        NodeEnum::CreateTableSpaceStmt(_) => todo!(),
+        NodeEnum::DropTableSpaceStmt(_) => todo!(),
+        NodeEnum::AlterObjectDependsStmt(_) => todo!(),
+        NodeEnum::AlterObjectSchemaStmt(_) => todo!(),
+        NodeEnum::AlterOwnerStmt(_) => todo!(),
+        NodeEnum::AlterOperatorStmt(_) => todo!(),
+        NodeEnum::AlterTypeStmt(_) => todo!(),
+        NodeEnum::DropOwnedStmt(_) => todo!(),
+        NodeEnum::ReassignOwnedStmt(_) => todo!(),
+        NodeEnum::CompositeTypeStmt(_) => todo!(),
+        NodeEnum::CreateEnumStmt(_) => todo!(),
+        NodeEnum::CreateRangeStmt(_) => todo!(),
+        NodeEnum::AlterEnumStmt(_) => todo!(),
+        NodeEnum::AlterTsdictionaryStmt(_) => todo!(),
+        NodeEnum::AlterTsconfigurationStmt(_) => todo!(),
+        NodeEnum::CreateFdwStmt(_) => todo!(),
+        NodeEnum::AlterFdwStmt(_) => todo!(),
+        NodeEnum::CreateForeignServerStmt(_) => todo!(),
+        NodeEnum::AlterForeignServerStmt(_) => todo!(),
+        NodeEnum::CreateUserMappingStmt(_) => todo!(),
+        NodeEnum::AlterUserMappingStmt(_) => todo!(),
+        NodeEnum::DropUserMappingStmt(_) => todo!(),
+        NodeEnum::AlterTableSpaceOptionsStmt(_) => todo!(),
+        NodeEnum::AlterTableMoveAllStmt(_) => todo!(),
+        NodeEnum::SecLabelStmt(_) => todo!(),
+        NodeEnum::CreateForeignTableStmt(_) => todo!(),
+        NodeEnum::ImportForeignSchemaStmt(_) => todo!(),
+        NodeEnum::CreateExtensionStmt(_) => todo!(),
+        NodeEnum::AlterExtensionStmt(_) => todo!(),
+        NodeEnum::AlterExtensionContentsStmt(_) => todo!(),
+        NodeEnum::CreateEventTrigStmt(_) => todo!(),
+        NodeEnum::AlterEventTrigStmt(_) => todo!(),
+        NodeEnum::RefreshMatViewStmt(_) => todo!(),
+        NodeEnum::ReplicaIdentityStmt(_) => todo!(),
+        NodeEnum::AlterSystemStmt(_) => todo!(),
+        NodeEnum::CreatePolicyStmt(_) => todo!(),
+        NodeEnum::AlterPolicyStmt(_) => todo!(),
+        NodeEnum::CreateTransformStmt(_) => todo!(),
+        NodeEnum::CreateAmStmt(_) => todo!(),
+        NodeEnum::CreatePublicationStmt(_) => todo!(),
+        NodeEnum::AlterPublicationStmt(_) => todo!(),
+        NodeEnum::CreateSubscriptionStmt(_) => todo!(),
+        NodeEnum::AlterSubscriptionStmt(_) => todo!(),
+        NodeEnum::DropSubscriptionStmt(_) => todo!(),
+        NodeEnum::CreateStatsStmt(_) => todo!(),
+        NodeEnum::AlterCollationStmt(_) => todo!(),
+        NodeEnum::CallStmt(_) => todo!(),
+        NodeEnum::AlterStatsStmt(_) => todo!(),
+        NodeEnum::AExpr(_) => panic!("Node has location property."),
+        NodeEnum::ColumnRef(_) => panic!("Node has location property."),
+        NodeEnum::ParamRef(_) => panic!("Node has location property."),
+        NodeEnum::FuncCall(_) => panic!("Node has location property."),
+        NodeEnum::AStar(_) => todo!(),
+        NodeEnum::AIndices(_) => todo!(),
+        NodeEnum::AIndirection(_) => todo!(),
+        NodeEnum::AArrayExpr(_) => panic!("Node has location property."),
+        NodeEnum::ResTarget(_) => panic!("Node has location property."),
+        NodeEnum::MultiAssignRef(_) => todo!(),
+        NodeEnum::TypeCast(_) => panic!("Node has location property."),
+        NodeEnum::CollateClause(_) => panic!("Node has location property."),
+        NodeEnum::SortBy(_) => panic!("Node has location property."),
+        NodeEnum::WindowDef(_) => panic!("Node has location property."),
+        NodeEnum::RangeSubselect(_) => todo!(),
+        NodeEnum::RangeFunction(_) => todo!(),
+        NodeEnum::RangeTableSample(_) => panic!("Node has location property."),
+        NodeEnum::RangeTableFunc(_) => panic!("Node has location property."),
+        NodeEnum::RangeTableFuncCol(_) => panic!("Node has location property."),
+        NodeEnum::TypeName(_) => panic!("Node has location property."),
+        NodeEnum::ColumnDef(_) => panic!("Node has location property."),
+        NodeEnum::IndexElem(_) => todo!(),
+        NodeEnum::StatsElem(_) => todo!(),
+        NodeEnum::Constraint(_) => panic!("Node has location property."),
+        NodeEnum::DefElem(_) => panic!("Node has location property."),
+        NodeEnum::RangeTblEntry(_) => todo!(),
+        NodeEnum::RangeTblFunction(_) => todo!(),
+        NodeEnum::TableSampleClause(_) => todo!(),
+        NodeEnum::WithCheckOption(_) => todo!(),
+        NodeEnum::SortGroupClause(_) => todo!(),
+        NodeEnum::GroupingSet(_) => panic!("Node has location property."),
+        NodeEnum::WindowClause(_) => todo!(),
+        NodeEnum::ObjectWithArgs(_) => todo!(),
+        NodeEnum::AccessPriv(_) => todo!(),
+        NodeEnum::CreateOpClassItem(_) => todo!(),
+        NodeEnum::TableLikeClause(_) => todo!(),
+        NodeEnum::FunctionParameter(_) => todo!(),
+        NodeEnum::LockingClause(_) => todo!(),
+        NodeEnum::RowMarkClause(_) => todo!(),
+        NodeEnum::XmlSerialize(_) => panic!("Node has location property."),
+        NodeEnum::WithClause(_) => panic!("Node has location property."),
+        NodeEnum::InferClause(_) => panic!("Node has location property."),
+        NodeEnum::OnConflictClause(_) => panic!("Node has location property."),
+        NodeEnum::CtesearchClause(_) => panic!("Node has location property."),
+        NodeEnum::CtecycleClause(_) => panic!("Node has location property."),
+        NodeEnum::CommonTableExpr(_) => panic!("Node has location property."),
+        NodeEnum::MergeWhenClause(_) => todo!(),
+        NodeEnum::RoleSpec(_) => panic!("Node has location property."),
+        NodeEnum::TriggerTransition(_) => todo!(),
+        NodeEnum::PartitionElem(_) => panic!("Node has location property."),
+        NodeEnum::PartitionSpec(_) => panic!("Node has location property."),
+        NodeEnum::PartitionBoundSpec(_) => panic!("Node has location property."),
+        NodeEnum::PartitionRangeDatum(_) => panic!("Node has location property."),
+        NodeEnum::PartitionCmd(_) => todo!(),
+        NodeEnum::VacuumRelation(_) => todo!(),
+        NodeEnum::PublicationObjSpec(_) => panic!("Node has location property."),
+        NodeEnum::PublicationTable(_) => todo!(),
+        NodeEnum::InlineCodeBlock(_) => todo!(),
+        NodeEnum::CallContext(_) => todo!(),
+        NodeEnum::Integer(_) => parent_location,
+        NodeEnum::Float(_) => parent_location,
+        NodeEnum::Boolean(_) => parent_location,
+        NodeEnum::String(_) => parent_location,
+        NodeEnum::BitString(_) => parent_location,
+        NodeEnum::List(_) => todo!(),
+        NodeEnum::IntList(_) => todo!(),
+        NodeEnum::OidList(_) => todo!(),
+        NodeEnum::AConst(_) => panic!("Node has location property."),
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::assert_eq;
+
+    use pg_query::NodeEnum;
+
+    use crate::pg_query_utils_manual::derive_location;
+
+    #[test]
+    fn test_derive_location() {
+        let input = "with c as (insert into contact (id) values ('id')) select * from c;";
+
+        let insert_node = match pg_query::parse(input) {
+            Ok(parsed) => Some(
+                parsed
+                    .protobuf
+                    .nodes()
+                    .iter()
+                    .find(|n| match n.0.to_enum() {
+                        NodeEnum::InsertStmt(_) => true,
+                        _ => false,
+                    })
+                    .unwrap()
+                    .0
+                    .to_enum(),
+            ),
+            Err(_) => None,
+        };
+        let cte_location = match pg_query::parse(input) {
+            Ok(parsed) => Some(
+                parsed
+                    .protobuf
+                    .nodes()
+                    .iter()
+                    .find_map(|n| match n.0.to_enum() {
+                        NodeEnum::CommonTableExpr(n) => Some(n.location),
+                        _ => None,
+                    })
+                    .unwrap(),
+            ),
+            Err(_) => None,
+        };
+
+        let l = derive_location(
+            &insert_node.unwrap(),
+            input.to_string(),
+            cte_location.unwrap(),
+            Some(23),
+        );
+
+        assert_eq!(l, 11);
+    }
+}

From d6adb3b873141f3b7d26a78a57c94221c3c29946 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Wed, 16 Aug 2023 19:37:20 +0200
Subject: [PATCH 07/23] feat: reverse engineering for locations

---
 crates/parser/src/bin/generate.rs             |  120 +-
 crates/parser/src/lib.rs                      |    1 -
 crates/parser/src/pg_query_utils.rs           |  304 -
 crates/parser/src/pg_query_utils_generated.rs | 9259 +++++------------
 .../src/pg_query_utils_generated_test.rs      |  165 +-
 crates/parser/src/pg_query_utils_manual.rs    |   64 +-
 crates/sourcegen/src/struct_.rs               |   15 +-
 7 files changed, 2672 insertions(+), 7256 deletions(-)
 delete mode 100644 crates/parser/src/pg_query_utils.rs

diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
index bf5c2996..2e65f634 100644
--- a/crates/parser/src/bin/generate.rs
+++ b/crates/parser/src/bin/generate.rs
@@ -32,6 +32,7 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                     vec!["NodeEnum".to_string()],
                 )
                 .with_import("std::collections".to_string(), vec!["VecDeque".to_string()])
+                .with_import("crate".to_string(), vec!["pg_query_utils_manual::derive_location".to_string()])
                 .finish(),
         )
         .add_block(
@@ -74,10 +75,10 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                 .with_argument("Clone".to_string(), None)
                 .finish()
             )
-            .with_field("node".to_string(), "NodeEnum".to_string())
-            .with_field("depth".to_string(), "i32".to_string())
-            .with_field("location".to_string(), "i32".to_string())
-            .with_field("path".to_string(), "String".to_string())
+            .with_field("node".to_string(), "NodeEnum".to_string(), true)
+            .with_field("depth".to_string(), "i32".to_string(), true)
+            .with_field("location".to_string(), "i32".to_string(), true)
+            .with_field("path".to_string(), "String".to_string(), true)
             .finish()
         )
         .add_block(
@@ -85,15 +86,36 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                 .public()
                 .with_comment("Returns all children of the node, recursively".to_string())
                 .with_parameter("node".to_string(), Some("&NodeEnum".to_string()))
+                .with_parameter("text".to_string(), Some("String".to_string()))
                 .with_parameter("current_depth".to_string(), Some("i32".to_string()))
                 .with_return_type("Vec<NestedNode>".to_string())
                 .with(|b| {
                     let mut content = "let mut nodes: Vec<NestedNode> = vec![];\n".to_string();
-                    content.push_str("// Node, depth, location\n");
-                    content.push_str("let mut stack: VecDeque<(NodeEnum, i32, Option<i32>)> = VecDeque::from(vec![(node.to_owned(), current_depth, Some(0))]);\n");
-                    content.push_str("while stack.len() > 0 {\n");
-                    content.push_str("let (node, depth, parent_location) = stack.pop_front().unwrap();\n");
+                    content.push_str("// Node, depth, path\n");
+                    content.push_str("let mut stack: VecDeque<(NodeEnum, i32, String)> = VecDeque::from(vec![(node.to_owned(), current_depth, \"0\".to_string())]);");
+                    content.push_str("// Node, depth, path\n");
+                    content.push_str("let mut location_stack: VecDeque<(NodeEnum, i32, String)> = VecDeque::new();");
+                    content.push_str("while !stack.is_empty() || !location_stack.is_empty() {\n");
+                    content.push_str("if !stack.is_empty() {");
+                    content.push_str("let (node, depth, path) = stack.pop_front().unwrap();\n");
                     content.push_str("let current_depth = depth + 1;\n");
+                    content.push_str("let mut child_ctr: i32 = 0;\n");
+                    content.push_str("let mut handle_child = |c: NodeEnum| {\n");
+                    content.push_str("let location = get_location(&c);\n");
+                    content.push_str("let path = path.clone() + \".\" + child_ctr.to_string().as_str();\n");
+                    content.push_str("child_ctr = child_ctr + 1;\n");
+                    content.push_str("stack.push_back((c.to_owned(), current_depth, path.clone()));\n");
+                    content.push_str("if location.is_some() {\n");
+                    content.push_str("nodes.push(NestedNode {\n");
+                    content.push_str("node: c,\n");
+                    content.push_str("depth: current_depth,\n");
+                    content.push_str("location: location.unwrap(),\n");
+                    content.push_str("path: path.clone(),\n");
+                    content.push_str("});\n");
+                    content.push_str("} else {\n");
+                    content.push_str("location_stack.push_back((c, current_depth, path));\n");
+                    content.push_str("}\n");
+                    content.push_str("};\n");
 
                     let match_ = Match::new("&node".to_string())
                         .with(|b| {
@@ -103,20 +125,12 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                     // manually
                                     let content = "{
             if n.val.is_some() {
-                let value = match n.val.to_owned().unwrap() {
+                handle_child(match n.val.to_owned().unwrap() {
                     pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
                     pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
                     pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
                     pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
                     pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
-                };
-
-                nodes.push(NestedNode {
-                    node: value,
-                    depth: current_depth,
-                    // this is always the parent location
-                    location: parent_location,
-                    parent_location
                 });
             }
         }";
@@ -131,11 +145,7 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                         if field.field_type == FieldType::Node && field.repeated {
                                             field_content.push(
                                                 format!(
-                                                    "n.{}.iter().for_each(|x| {{
-                                                        let location = get_location(&x.node.as_ref().unwrap());
-                                                        stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                                                        nodes.push(NestedNode {{ node: x.node.to_owned().unwrap(), depth: current_depth, location, parent_location }});
-                                                    }});\n",
+                                                    "n.{}.iter().for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));\n",
                                                     field.name.to_string()
                                                 )
                                             );
@@ -145,31 +155,7 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                                 node_content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
                                                 node_content.push_str(
                                                     format!(
-                                                        "let {} = n.{}.to_owned().unwrap().node.unwrap();\n",
-                                                        field.name.to_string(),
-                                                        field.name.to_string(),
-                                                    ).as_str(),
-                                                );
-                                                node_content.push_str(
-                                                    format!(
-                                                        "let location = get_location(&{});\n",
-                                                        field.name.to_string()
-                                                    ).as_str(),
-                                                );
-                                                node_content.push_str(
-                                                    format!(
-                                                        "stack.push_back(({}.to_owned(), current_depth, location));\n",
-                                                        field.name.to_string()
-                                                    ).as_str(),
-                                                );
-                                                node_content.push_str(
-                                                    format!(
-                                                        "nodes.push(NestedNode {{
-                                                            node: {},
-                                                            depth: current_depth,
-                                                            location,
-                                                            parent_location
-                                                        }});\n",
+                                                        "handle_child(n.{}.to_owned().unwrap().node.unwrap());\n",
                                                         field.name.to_string()
                                                     ).as_str(),
                                                 );
@@ -180,36 +166,12 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                                                 node_content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
                                                 node_content.push_str(
                                                     format!(
-                                                        "let {} = NodeEnum::{}(n.{}.to_owned().unwrap());\n",
-                                                        field.name.to_string(),
+                                                        "handle_child(NodeEnum::{}(n.{}.to_owned().unwrap()));\n",
                                                         field.enum_variant_name.as_ref().unwrap(),
                                                         field.name.to_string()
                                                     )
                                                     .as_str()
                                                 );
-                                                node_content.push_str(
-                                                    format!(
-                                                        "let location = get_location(&{});\n",
-                                                        field.name.to_string()
-                                                    ).as_str(),
-                                                );
-                                                node_content.push_str(
-                                                    format!(
-                                                        "stack.push_back(({}.to_owned(), current_depth, location));\n",
-                                                        field.name.to_string()
-                                                    ).as_str()
-                                                );
-                                                node_content.push_str(
-                                                    format!(
-                                                        "nodes.push(NestedNode {{
-                                                            node: {},
-                                                            depth: current_depth,
-                                                            location,
-                                                            parent_location
-                                                        }});\n",
-                                                        field.name.to_string()
-                                                    ).as_str()
-                                                );
                                                 node_content.push_str("}\n");
                                                 field_content.push(node_content);
                                             }
@@ -236,7 +198,21 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                     content.push_str(match_.to_string().as_str());
                     content.push_str(";\n");
 
+                    content.push_str("} else if !location_stack.is_empty() {\n");
+                    content.push_str("let (node, depth, path) = location_stack.pop_front().unwrap();\n");
+                    content.push_str("let parent_location = nodes.iter().find(|n| {\n");
+                    content.push_str("let mut path_elements = path.split(\".\").collect::<Vec<&str>>();\n");
+                    content.push_str("path_elements.pop();\n");
+                    content.push_str("let parent_path = path_elements.join(\".\");\n");
+                    content.push_str("n.path == parent_path\n");
+                    content.push_str("}).unwrap().location;\n");
+                    content.push_str("let earliest_child_location = nodes.iter().filter(|n| n.path.starts_with(path.as_str())).min_by(|a, b| a.location.cmp(&b.location)).map(|n| n.location);\n");
+                    content.push_str("let location = derive_location(&node, text.clone(), parent_location, earliest_child_location);\n");
+                    content.push_str("nodes.push(NestedNode { node, depth, location, path: path.clone() });\n");
+                    content.push_str("}\n");
                     content.push_str("}\n");
+
+
                     content.push_str("nodes.sort_by_key(|n| n.location);\n");
                     content.push_str("nodes");
 
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 5bba8887..83bd6795 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -24,7 +24,6 @@ mod pg_query_utils_manual;
 mod source_file;
 mod statement;
 mod syntax_error;
-// mod syntax_kind;
 mod syntax_kind_generated;
 mod syntax_node;
 
diff --git a/crates/parser/src/pg_query_utils.rs b/crates/parser/src/pg_query_utils.rs
deleted file mode 100644
index a229ba84..00000000
--- a/crates/parser/src/pg_query_utils.rs
+++ /dev/null
@@ -1,304 +0,0 @@
-use pg_query::{NodeEnum, NodeRef};
-
-/// Returns the array children nodes
-pub fn get_children(node: NodeEnum) -> Vec<NodeEnum> {
-    match &node {
-        NodeEnum::CreateStmt(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_children(NodeEnum::RangeVar(
-                n.relation.as_ref().unwrap().to_owned(),
-            )));
-            nodes.append(
-                &mut n
-                    .table_elts
-                    .iter()
-                    .flat_map(|x| get_children(x.node.as_ref().unwrap().to_owned()))
-                    .collect(),
-            );
-            nodes.append(
-                &mut n
-                    .options
-                    .iter()
-                    .flat_map(|x| get_children(x.node.as_ref().unwrap().to_owned()))
-                    .collect(),
-            );
-            nodes
-        }
-        NodeEnum::Var(n) => {
-            let mut nodes: Vec<NodeEnum> = vec![node.clone()];
-            nodes.append(&mut get_children(
-                n.xpr.as_ref().unwrap().to_owned().node.unwrap(),
-            ));
-            nodes
-        }
-        n => vec![n.clone()],
-    }
-}
-
-// TODO: we need two functions, one to return Option<i32> for every node enum,
-// and one to get all childrens, the Option<i32> position for each, and the smallest one from it
-
-/// Gets the position value for a pg_query node
-///
-/// This can mostly be generated by just returning `node.location` if the type has the property,
-/// but there are some exceptions where the location on the node itself is not leftmost position, e.g. for `AExpr`.
-pub fn get_position_for_pg_query_node(node: &NodeRef) -> i32 {
-    match node {
-        // NodeEnum::ResTarget(n) => get_children(n).iter().min_by(|x, y| x.lo).n.location,
-        // NodeRef::AExpr(n) => get_position_for_pg_query_node(
-        //     &n.lexpr.as_ref().unwrap().node.as_ref().unwrap().to_ref(),
-        // ),
-        // NodeRef::RangeVar(n) => n.location,
-        // NodeRef::ColumnRef(n) => n.location,
-        // NodeRef::AConst(n) => n.location,
-        // NodeRef::Alias(n) => todo!("Alias"),
-        // NodeRef::TableFunc(n) => n.location,
-        // NodeRef::Expr(n) => todo!("Expr"),
-        // NodeRef::Var(n) => n.location,
-        // NodeRef::Param(n) => n.location,
-        // NodeRef::Aggref(n) => n.location,
-        // NodeRef::GroupingFunc(n) => n.location,
-        // NodeRef::WindowFunc(n) => n.location,
-        // NodeRef::SubscriptingRef(n) => todo!("SubscriptingRef"),
-        // NodeRef::FuncExpr(n) => n.location,
-        // NodeRef::NamedArgExpr(n) => n.location,
-        // NodeRef::OpExpr(n) => n.location,
-        // NodeRef::DistinctExpr(n) => n.location,
-        // NodeRef::NullIfExpr(n) => n.location,
-        // NodeRef::ScalarArrayOpExpr(n) => n.location,
-        // NodeRef::BoolExpr(n) => n.location,
-        // NodeRef::SubLink(n) => n.location,
-        // NodeRef::SubPlan(n) => {
-        //     get_position_for_pg_query_node(&n.xpr.as_ref().unwrap().node.as_ref().unwrap().to_ref())
-        // }
-        // NodeRef::AlternativeSubPlan(n) => todo!("AlternativeSubPlan"),
-        // NodeRef::FieldSelect(n) => todo!("FieldSelect"),
-        // NodeRef::FieldStore(n) => todo!("FieldStore"),
-        // NodeRef::RelabelType(n) => n.location,
-        // NodeRef::CoerceViaIo(n) => n.location,
-        // NodeRef::ArrayCoerceExpr(n) => n.location,
-        // NodeRef::ConvertRowtypeExpr(n) => n.location,
-        // NodeRef::CollateExpr(n) => n.location,
-        // NodeRef::CaseExpr(n) => n.location,
-        // NodeRef::CaseWhen(n) => n.location,
-        // NodeRef::CaseTestExpr(n) => todo!("CaseTestExpr"),
-        // NodeRef::ArrayExpr(n) => n.location,
-        // NodeRef::RowExpr(n) => n.location,
-        // NodeRef::RowCompareExpr(n) => todo!("RowCompareExpr"),
-        // NodeRef::CoalesceExpr(n) => n.location,
-        // NodeRef::MinMaxExpr(n) => n.location,
-        // NodeRef::SqlvalueFunction(n) => n.location,
-        // NodeRef::XmlExpr(n) => n.location,
-        // NodeRef::NullTest(n) => n.location,
-        // NodeRef::BooleanTest(n) => n.location,
-        // NodeRef::CoerceToDomain(n) => n.location,
-        // NodeRef::CoerceToDomainValue(n) => n.location,
-        // NodeRef::SetToDefault(n) => n.location,
-        // NodeRef::CurrentOfExpr(n) => todo!("CurrentOfExpr"),
-        // NodeRef::NextValueExpr(_) => todo!("NextValueExpr"),
-        // NodeRef::InferenceElem(_) => todo!("InferenceElem"),
-        // NodeRef::TargetEntry(_) => todo!("TargetEntry"),
-        // NodeRef::RangeTblRef(_) => todo!("RangeTblRef"),
-        // NodeRef::JoinExpr(_) => todo!("JoinExpr"),
-        // NodeRef::FromExpr(_) => todo!("FromExpr"),
-        // NodeRef::OnConflictExpr(_) => todo!("OnConflictExpr"),
-        // NodeRef::IntoClause(_) => todo!("IntoClause"),
-        // NodeRef::RawStmt(_) => todo!("RawStmt"),
-        // NodeRef::Query(_) => todo!("Query"),
-        // NodeRef::InsertStmt(_) => todo!("InsertStmt"),
-        // NodeRef::DeleteStmt(_) => todo!("DeleteStmt"),
-        // NodeRef::UpdateStmt(_) => todo!("UpdateStmt"),
-        // NodeRef::SelectStmt(_) => todo!("SelectStmt"),
-        // NodeRef::AlterTableStmt(_) => -1,
-        // NodeRef::AlterTableCmd(_) => todo!("AlterTableCmd"),
-        // NodeRef::AlterDomainStmt(_) => todo!("AlterDomainStmt"),
-        // NodeRef::SetOperationStmt(_) => todo!("SetOperationStmt"),
-        // NodeRef::GrantStmt(_) => -1,
-        // NodeRef::GrantRoleStmt(_) => todo!("GrantRoleStmt"),
-        // NodeRef::AlterDefaultPrivilegesStmt(_) => todo!("AlterDefaultPrivilegesStmt"),
-        // NodeRef::ClosePortalStmt(_) => todo!("ClosePortalStmt"),
-        // NodeRef::ClusterStmt(_) => todo!("ClusterStmt"),
-        // NodeRef::CopyStmt(_) => todo!("CopyStmt"),
-        // NodeRef::CreateStmt(_) => -1,
-        // NodeRef::DefineStmt(_) => todo!("DefineStmt"),
-        // NodeRef::DropStmt(_) => todo!("DropStmt"),
-        // NodeRef::TruncateStmt(_) => todo!("TruncateStmt"),
-        // NodeRef::CommentStmt(_) => todo!("CommentStmt"),
-        // NodeRef::FetchStmt(_) => todo!("FetchStmt"),
-        // NodeRef::IndexStmt(_) => todo!("IndexStmt"),
-        // NodeRef::CreateFunctionStmt(_) => todo!("CreateFunctionStmt"),
-        // NodeRef::AlterFunctionStmt(_) => todo!("AlterFunctionStmt"),
-        // NodeRef::DoStmt(_) => todo!("DoStmt"),
-        // NodeRef::RenameStmt(_) => todo!("RenameStmt"),
-        // NodeRef::RuleStmt(_) => todo!("RuleStmt"),
-        // NodeRef::NotifyStmt(_) => todo!("NotifyStmt"),
-        // NodeRef::ListenStmt(_) => todo!("ListenStmt"),
-        // NodeRef::UnlistenStmt(_) => todo!("UnlistenStmt"),
-        // NodeRef::TransactionStmt(_) => todo!("TransactionStmt"),
-        // NodeRef::ViewStmt(_) => todo!("ViewStmt"),
-        // NodeRef::LoadStmt(_) => todo!("LoadStmt"),
-        // NodeRef::CreateDomainStmt(_) => todo!("CreateDomainStmt"),
-        // NodeRef::CreatedbStmt(_) => todo!("CreatedbStmt"),
-        // NodeRef::DropdbStmt(_) => todo!("DropdbStmt"),
-        // NodeRef::VacuumStmt(_) => todo!("VacuumStmt"),
-        // NodeRef::ExplainStmt(_) => todo!("ExplainStmt"),
-        // NodeRef::CreateTableAsStmt(_) => todo!("CreateTableAsStmt"),
-        // NodeRef::CreateSeqStmt(_) => todo!("CreateSeqStmt"),
-        // NodeRef::AlterSeqStmt(_) => todo!("AlterSeqStmt"),
-        // NodeRef::VariableSetStmt(_) => todo!("VariableSetStmt"),
-        // NodeRef::VariableShowStmt(_) => todo!("VariableShowStmt"),
-        // NodeRef::DiscardStmt(_) => todo!("DiscardStmt"),
-        // NodeRef::CreateTrigStmt(_) => todo!("CreateTrigStmt"),
-        // NodeRef::CreatePlangStmt(_) => todo!("CreatePlangStmt"),
-        // NodeRef::CreateRoleStmt(_) => todo!("CreateRoleStmt"),
-        // NodeRef::AlterRoleStmt(_) => todo!("AlterRoleStmt"),
-        // NodeRef::DropRoleStmt(_) => todo!("DropRoleStmt"),
-        // NodeRef::LockStmt(_) => todo!("LockStmt"),
-        // NodeRef::ConstraintsSetStmt(_) => todo!("ConstraintsSetStmt"),
-        // NodeRef::ReindexStmt(_) => todo!("ReindexStmt"),
-        // NodeRef::CheckPointStmt(_) => todo!("CheckPointStmt"),
-        // NodeRef::CreateSchemaStmt(_) => todo!("CreateSchemaStmt"),
-        // NodeRef::AlterDatabaseStmt(_) => todo!("AlterDatabaseStmt"),
-        // NodeRef::AlterDatabaseSetStmt(_) => todo!("AlterDatabaseSetStmt"),
-        // NodeRef::AlterRoleSetStmt(_) => todo!("AlterRoleSetStmt"),
-        // NodeRef::CreateConversionStmt(_) => todo!("CreateConversionStmt"),
-        // NodeRef::CreateCastStmt(_) => todo!("CreateCastStmt"),
-        // NodeRef::CreateOpClassStmt(_) => todo!("CreateOpClassStmt"),
-        // NodeRef::CreateOpFamilyStmt(_) => todo!("CreateOpFamilyStmt"),
-        // NodeRef::AlterOpFamilyStmt(_) => todo!("AlterOpFamilyStmt"),
-        // NodeRef::PrepareStmt(_) => todo!("PrepareStmt"),
-        // NodeRef::ExecuteStmt(_) => todo!("ExecuteStmt"),
-        // NodeRef::DeallocateStmt(_) => todo!("DeallocateStmt"),
-        // NodeRef::DeclareCursorStmt(_) => todo!("DeclareCursorStmt"),
-        // NodeRef::CreateTableSpaceStmt(_) => todo!("CreateTableSpaceStmt"),
-        // NodeRef::DropTableSpaceStmt(_) => todo!("DropTableSpaceStmt"),
-        // NodeRef::AlterObjectDependsStmt(_) => todo!("AlterObjectDependsStmt"),
-        // NodeRef::AlterObjectSchemaStmt(_) => todo!("AlterObjectSchemaStmt"),
-        // NodeRef::AlterOwnerStmt(_) => todo!("AlterOwnerStmt"),
-        // NodeRef::AlterOperatorStmt(_) => todo!("AlterOperatorStmt"),
-        // NodeRef::AlterTypeStmt(_) => todo!("AlterTypeStmt"),
-        // NodeRef::DropOwnedStmt(_) => todo!("DropOwnedStmt"),
-        // NodeRef::ReassignOwnedStmt(_) => todo!("ReassignOwnedStmt"),
-        // NodeRef::CompositeTypeStmt(_) => todo!("CompositeTypeStmt"),
-        // NodeRef::CreateEnumStmt(_) => todo!("CreateEnumStmt"),
-        // NodeRef::CreateRangeStmt(_) => todo!("CreateRangeStmt"),
-        // NodeRef::AlterEnumStmt(_) => todo!("AlterEnumStmt"),
-        // NodeRef::AlterTsdictionaryStmt(_) => todo!("AlterTsdictionaryStmt"),
-        // NodeRef::AlterTsconfigurationStmt(_) => todo!("AlterTsconfigurationStmt"),
-        // NodeRef::CreateFdwStmt(_) => todo!("CreateFdwStmt"),
-        // NodeRef::AlterFdwStmt(_) => todo!("AlterFdwStmt"),
-        // NodeRef::CreateForeignServerStmt(_) => todo!("CreateForeignServerStmt"),
-        // NodeRef::AlterForeignServerStmt(_) => todo!("AlterForeignServerStmt"),
-        // NodeRef::CreateUserMappingStmt(_) => todo!("CreateUserMappingStmt"),
-        // NodeRef::AlterUserMappingStmt(_) => todo!("AlterUserMappingStmt"),
-        // NodeRef::DropUserMappingStmt(_) => todo!("DropUserMappingStmt"),
-        // NodeRef::AlterTableSpaceOptionsStmt(_) => todo!("AlterTableSpaceOptionsStmt"),
-        // NodeRef::AlterTableMoveAllStmt(_) => todo!("AlterTableMoveAllStmt"),
-        // NodeRef::SecLabelStmt(_) => todo!("SecLabelStmt"),
-        // NodeRef::CreateForeignTableStmt(_) => todo!("CreateForeignTableStmt"),
-        // NodeRef::ImportForeignSchemaStmt(_) => todo!("ImportForeignSchemaStmt"),
-        // NodeRef::CreateExtensionStmt(_) => todo!("CreateExtensionStmt"),
-        // NodeRef::AlterExtensionStmt(_) => todo!("AlterExtensionStmt"),
-        // NodeRef::AlterExtensionContentsStmt(_) => todo!("AlterExtensionContentsStmt"),
-        // NodeRef::CreateEventTrigStmt(_) => todo!("CreateEventTrigStmt"),
-        // NodeRef::AlterEventTrigStmt(_) => todo!("AlterEventTrigStmt"),
-        // NodeRef::RefreshMatViewStmt(_) => todo!("RefreshMatViewStmt"),
-        // NodeRef::ReplicaIdentityStmt(_) => todo!("ReplicaIdentityStmt"),
-        // NodeRef::AlterSystemStmt(_) => todo!("AlterSystemStmt"),
-        // NodeRef::CreatePolicyStmt(_) => todo!("CreatePolicyStmt"),
-        // NodeRef::AlterPolicyStmt(_) => todo!("AlterPolicyStmt"),
-        // NodeRef::CreateTransformStmt(_) => todo!("CreateTransformStmt"),
-        // NodeRef::CreateAmStmt(_) => todo!("CreateAmStmt"),
-        // NodeRef::CreatePublicationStmt(_) => todo!("CreatePublicationStmt"),
-        // NodeRef::AlterPublicationStmt(_) => todo!("AlterPublicationStmt"),
-        // NodeRef::CreateSubscriptionStmt(_) => todo!("CreateSubscriptionStmt"),
-        // NodeRef::AlterSubscriptionStmt(_) => todo!("AlterSubscriptionStmt"),
-        // NodeRef::DropSubscriptionStmt(_) => todo!("DropSubscriptionStmt"),
-        // NodeRef::CreateStatsStmt(_) => todo!("CreateStatsStmt"),
-        // NodeRef::AlterCollationStmt(_) => todo!("AlterCollationStmt"),
-        // NodeRef::CallStmt(_) => todo!("CallStmt"),
-        // NodeRef::AlterStatsStmt(_) => todo!("AlterStatsStmt"),
-        // NodeRef::ParamRef(n) => n.location,
-        // NodeRef::FuncCall(n) => n.location,
-        // NodeRef::AStar(n) => todo!("AStar"),
-        // NodeRef::AIndices(n) => todo!("AIndices"),
-        // NodeRef::AIndirection(n) => todo!("AIndirection"),
-        // NodeRef::AArrayExpr(n) => n.location,
-        // NodeRef::MultiAssignRef(n) => todo!("MultiAssignRef"),
-        // NodeRef::TypeCast(n) => n.location,
-        // NodeRef::CollateClause(n) => n.location,
-        // NodeRef::SortBy(n) => n.location,
-        // NodeRef::WindowDef(n) => n.location,
-        // NodeRef::RangeSubselect(n) => todo!("RangeSubselect"),
-        // NodeRef::RangeFunction(n) => todo!("RangeFunction"),
-        // NodeRef::RangeTableSample(n) => n.location,
-        // NodeRef::RangeTableFunc(n) => n.location,
-        // NodeRef::RangeTableFuncCol(n) => n.location,
-        // NodeRef::TypeName(n) => n.location,
-        // NodeRef::ColumnDef(n) => n.location,
-        // NodeRef::IndexElem(n) => todo!("IndexElem"),
-        // NodeRef::Constraint(n) => n.location,
-        // NodeRef::DefElem(n) => n.location,
-        // NodeRef::RangeTblEntry(n) => todo!("RangeTblEntry"),
-        // NodeRef::RangeTblFunction(n) => todo!("RangeTblFunction"),
-        // NodeRef::TableSampleClause(n) => todo!("TableSampleClause"),
-        // NodeRef::WithCheckOption(n) => todo!("WithCheckOption"),
-        // NodeRef::SortGroupClause(n) => todo!("SortGroupClause"),
-        // NodeRef::GroupingSet(n) => n.location,
-        // NodeRef::WindowClause(n) => todo!("WindowClause"),
-        // NodeRef::ObjectWithArgs(n) => todo!("ObjectWithArgs"),
-        // NodeRef::AccessPriv(n) => todo!("AccessPriv"),
-        // NodeRef::CreateOpClassItem(n) => todo!("CreateOpClassItem"),
-        // NodeRef::TableLikeClause(n) => todo!("TableLikeClause"),
-        // NodeRef::FunctionParameter(n) => todo!("FunctionParameter"),
-        // NodeRef::LockingClause(n) => todo!("LockingClause"),
-        // NodeRef::RowMarkClause(n) => todo!("RowMarkClause"),
-        // NodeRef::XmlSerialize(n) => n.location,
-        // NodeRef::WithClause(n) => n.location,
-        // NodeRef::InferClause(n) => n.location,
-        // NodeRef::OnConflictClause(n) => n.location,
-        // NodeRef::CommonTableExpr(n) => n.location,
-        // NodeRef::RoleSpec(n) => n.location,
-        // NodeRef::TriggerTransition(n) => todo!("TriggerTransition"),
-        // NodeRef::PartitionElem(n) => n.location,
-        // NodeRef::PartitionSpec(n) => n.location,
-        // NodeRef::PartitionBoundSpec(n) => n.location,
-        // NodeRef::PartitionRangeDatum(n) => n.location,
-        // NodeRef::PartitionCmd(n) => todo!("PartitionCmd"),
-        // NodeRef::VacuumRelation(n) => todo!("VacuumRelation"),
-        // NodeRef::InlineCodeBlock(n) => todo!("InlineCodeBlock"),
-        // NodeRef::CallContext(n) => todo!("CallContext"),
-        // NodeRef::Integer(n) => todo!("Integer"),
-        // NodeRef::Float(n) => todo!("Float"),
-        // NodeRef::String(n) => todo!("String"),
-        // NodeRef::BitString(n) => todo!("BitString"),
-        // NodeRef::Null(n) => todo!("Null"),
-        // NodeRef::List(n) => todo!("List"),
-        // NodeRef::IntList(n) => todo!("IntList"),
-        // NodeRef::OidList(n) => todo!("OidList"),
-        _ => -1,
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-    use std::fs;
-    use std::path::Path;
-
-    use super::*;
-
-    #[test]
-    fn test_get_flat_nodes() {
-        let input = "CREATE TABLE products (
-    product_no integer,
-    name text,
-    price numeric CHECK (price > 0),
-    discounted_price numeric CHECK (discounted_price > 0),
-    CHECK (price > discounted_price)
-);";
-
-        let parsed = pg_query::parse(input);
-        parsed.unwrap().protobuf.nodes().iter().for_each(|n| {});
-    }
-}
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index e4eb8d84..d47a1341 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -1,5 +1,6 @@
 //! Utilities for working with pg_query.rs
 //! This file is generated from the libg_query proto
+use crate::pg_query_utils_manual::derive_location;
 use pg_query::NodeEnum;
 use std::collections::VecDeque;
 
@@ -250,6708 +251,2570 @@ pub fn get_location(node: &NodeEnum) -> Option<i32> {
 pub struct NestedNode {
     pub node: NodeEnum,
     pub depth: i32,
-    pub location: Option<i32>,
-    pub parent_location: Option<i32>,
+    pub location: i32,
+    pub path: String,
 }
 
 /// Returns all children of the node, recursively
-pub fn get_children(node: &NodeEnum, current_depth: i32) -> Vec<NestedNode> {
+pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<NestedNode> {
     let mut nodes: Vec<NestedNode> = vec![];
-    // Node, depth, location
-    let mut stack: VecDeque<(NodeEnum, i32, Option<i32>)> =
-        VecDeque::from(vec![(node.to_owned(), current_depth, Some(0))]);
-    while stack.len() > 0 {
-        let (node, depth, parent_location) = stack.pop_front().unwrap();
-        let current_depth = depth + 1;
-        match &node {
-            NodeEnum::Alias(n) => {
-                n.colnames.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RangeVar(n) => {
-                if n.alias.is_some() {
-                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    let location = get_location(&alias);
-                    stack.push_back((alias.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: alias,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::TableFunc(n) => {
-                n.ns_uris.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.ns_names.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.docexpr.is_some() {
-                    let docexpr = n.docexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&docexpr);
-                    stack.push_back((docexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: docexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.rowexpr.is_some() {
-                    let rowexpr = n.rowexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&rowexpr);
-                    stack.push_back((rowexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: rowexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.colnames.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.coltypes.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.coltypmods.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.colcollations.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.colexprs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.coldefexprs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::Var(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::Param(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::Aggref(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.aggargtypes.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.aggdirectargs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.aggorder.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.aggdistinct.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.aggfilter.is_some() {
-                    let aggfilter = n.aggfilter.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&aggfilter);
-                    stack.push_back((aggfilter.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: aggfilter,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::GroupingFunc(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.refs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.cols.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::WindowFunc(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.aggfilter.is_some() {
-                    let aggfilter = n.aggfilter.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&aggfilter);
-                    stack.push_back((aggfilter.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: aggfilter,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::SubscriptingRef(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.refupperindexpr.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.reflowerindexpr.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.refexpr.is_some() {
-                    let refexpr = n.refexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&refexpr);
-                    stack.push_back((refexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: refexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.refassgnexpr.is_some() {
-                    let refassgnexpr = n.refassgnexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&refassgnexpr);
-                    stack.push_back((refassgnexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: refassgnexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::FuncExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::NamedArgExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::OpExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DistinctExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::NullIfExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ScalarArrayOpExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::BoolExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::SubLink(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.testexpr.is_some() {
-                    let testexpr = n.testexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&testexpr);
-                    stack.push_back((testexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: testexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.oper_name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.subselect.is_some() {
-                    let subselect = n.subselect.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&subselect);
-                    stack.push_back((subselect.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: subselect,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::SubPlan(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.testexpr.is_some() {
-                    let testexpr = n.testexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&testexpr);
-                    stack.push_back((testexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: testexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.param_ids.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.set_param.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.par_param.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlternativeSubPlan(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.subplans.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::FieldSelect(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::FieldStore(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.newvals.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.fieldnums.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RelabelType(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CoerceViaIo(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::ArrayCoerceExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.elemexpr.is_some() {
-                    let elemexpr = n.elemexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&elemexpr);
-                    stack.push_back((elemexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: elemexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::ConvertRowtypeExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CollateExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CaseExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.defresult.is_some() {
-                    let defresult = n.defresult.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&defresult);
-                    stack.push_back((defresult.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: defresult,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CaseWhen(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.expr.is_some() {
-                    let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&expr);
-                    stack.push_back((expr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: expr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.result.is_some() {
-                    let result = n.result.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&result);
-                    stack.push_back((result.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: result,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CaseTestExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::ArrayExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.elements.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RowExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.colnames.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RowCompareExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.opnos.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.opfamilies.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.inputcollids.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.largs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.rargs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CoalesceExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::MinMaxExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::SqlvalueFunction(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::XmlExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.named_args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.arg_names.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::NullTest(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::BooleanTest(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CoerceToDomain(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CoerceToDomainValue(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::SetToDefault(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CurrentOfExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::NextValueExpr(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::InferenceElem(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.expr.is_some() {
-                    let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&expr);
-                    stack.push_back((expr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: expr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::TargetEntry(n) => {
-                if n.xpr.is_some() {
-                    let xpr = n.xpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&xpr);
-                    stack.push_back((xpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: xpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.expr.is_some() {
-                    let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&expr);
-                    stack.push_back((expr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: expr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::RangeTblRef(n) => (),
-            NodeEnum::JoinExpr(n) => {
-                if n.larg.is_some() {
-                    let larg = n.larg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&larg);
-                    stack.push_back((larg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: larg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.rarg.is_some() {
-                    let rarg = n.rarg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&rarg);
-                    stack.push_back((rarg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: rarg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.using_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.join_using_alias.is_some() {
-                    let join_using_alias = NodeEnum::Alias(n.join_using_alias.to_owned().unwrap());
-                    let location = get_location(&join_using_alias);
-                    stack.push_back((join_using_alias.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: join_using_alias,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.quals.is_some() {
-                    let quals = n.quals.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&quals);
-                    stack.push_back((quals.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: quals,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.alias.is_some() {
-                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    let location = get_location(&alias);
-                    stack.push_back((alias.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: alias,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::FromExpr(n) => {
-                n.fromlist.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.quals.is_some() {
-                    let quals = n.quals.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&quals);
-                    stack.push_back((quals.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: quals,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::OnConflictExpr(n) => {
-                n.arbiter_elems.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.arbiter_where.is_some() {
-                    let arbiter_where = n.arbiter_where.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arbiter_where);
-                    stack.push_back((arbiter_where.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arbiter_where,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.on_conflict_set.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.on_conflict_where.is_some() {
-                    let on_conflict_where = n.on_conflict_where.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&on_conflict_where);
-                    stack.push_back((on_conflict_where.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: on_conflict_where,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.excl_rel_tlist.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::IntoClause(n) => {
-                if n.rel.is_some() {
-                    let rel = NodeEnum::RangeVar(n.rel.to_owned().unwrap());
-                    let location = get_location(&rel);
-                    stack.push_back((rel.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: rel,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.col_names.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.view_query.is_some() {
-                    let view_query = n.view_query.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&view_query);
-                    stack.push_back((view_query.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: view_query,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::MergeAction(n) => {
-                if n.qual.is_some() {
-                    let qual = n.qual.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&qual);
-                    stack.push_back((qual.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: qual,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.target_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.update_colnos.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RawStmt(n) => {
-                if n.stmt.is_some() {
-                    let stmt = n.stmt.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&stmt);
-                    stack.push_back((stmt.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: stmt,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::Query(n) => {
-                if n.utility_stmt.is_some() {
-                    let utility_stmt = n.utility_stmt.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&utility_stmt);
-                    stack.push_back((utility_stmt.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: utility_stmt,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.cte_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.rtable.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.jointree.is_some() {
-                    let jointree = NodeEnum::FromExpr(n.jointree.to_owned().unwrap());
-                    let location = get_location(&jointree);
-                    stack.push_back((jointree.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: jointree,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.merge_action_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.target_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.on_conflict.is_some() {
-                    let on_conflict = NodeEnum::OnConflictExpr(n.on_conflict.to_owned().unwrap());
-                    let location = get_location(&on_conflict);
-                    stack.push_back((on_conflict.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: on_conflict,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.returning_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.group_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.grouping_sets.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.having_qual.is_some() {
-                    let having_qual = n.having_qual.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&having_qual);
-                    stack.push_back((having_qual.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: having_qual,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.window_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.distinct_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.sort_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.limit_offset.is_some() {
-                    let limit_offset = n.limit_offset.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&limit_offset);
-                    stack.push_back((limit_offset.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: limit_offset,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.limit_count.is_some() {
-                    let limit_count = n.limit_count.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&limit_count);
-                    stack.push_back((limit_count.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: limit_count,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.row_marks.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.set_operations.is_some() {
-                    let set_operations = n.set_operations.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&set_operations);
-                    stack.push_back((set_operations.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: set_operations,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.constraint_deps.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.with_check_options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::InsertStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.cols.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.select_stmt.is_some() {
-                    let select_stmt = n.select_stmt.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&select_stmt);
-                    stack.push_back((select_stmt.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: select_stmt,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.on_conflict_clause.is_some() {
-                    let on_conflict_clause =
-                        NodeEnum::OnConflictClause(n.on_conflict_clause.to_owned().unwrap());
-                    let location = get_location(&on_conflict_clause);
-                    stack.push_back((on_conflict_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: on_conflict_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.returning_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.with_clause.is_some() {
-                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    let location = get_location(&with_clause);
-                    stack.push_back((with_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: with_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::DeleteStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.using_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.returning_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.with_clause.is_some() {
-                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    let location = get_location(&with_clause);
-                    stack.push_back((with_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: with_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::UpdateStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.target_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.from_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.returning_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.with_clause.is_some() {
-                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    let location = get_location(&with_clause);
-                    stack.push_back((with_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: with_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::MergeStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.source_relation.is_some() {
-                    let source_relation = n.source_relation.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&source_relation);
-                    stack.push_back((source_relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: source_relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.join_condition.is_some() {
-                    let join_condition = n.join_condition.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&join_condition);
-                    stack.push_back((join_condition.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: join_condition,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.merge_when_clauses.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.with_clause.is_some() {
-                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    let location = get_location(&with_clause);
-                    stack.push_back((with_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: with_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::SelectStmt(n) => {
-                n.distinct_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.into_clause.is_some() {
-                    let into_clause = NodeEnum::IntoClause(n.into_clause.to_owned().unwrap());
-                    let location = get_location(&into_clause);
-                    stack.push_back((into_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: into_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.target_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.from_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.group_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.having_clause.is_some() {
-                    let having_clause = n.having_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&having_clause);
-                    stack.push_back((having_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: having_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.window_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.values_lists.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.sort_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.limit_offset.is_some() {
-                    let limit_offset = n.limit_offset.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&limit_offset);
-                    stack.push_back((limit_offset.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: limit_offset,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.limit_count.is_some() {
-                    let limit_count = n.limit_count.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&limit_count);
-                    stack.push_back((limit_count.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: limit_count,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.locking_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.with_clause.is_some() {
-                    let with_clause = NodeEnum::WithClause(n.with_clause.to_owned().unwrap());
-                    let location = get_location(&with_clause);
-                    stack.push_back((with_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: with_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.larg.is_some() {
-                    let larg = NodeEnum::SelectStmt(n.larg.to_owned().unwrap());
-                    let location = get_location(&larg);
-                    stack.push_back((larg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: larg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.rarg.is_some() {
-                    let rarg = NodeEnum::SelectStmt(n.rarg.to_owned().unwrap());
-                    let location = get_location(&rarg);
-                    stack.push_back((rarg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: rarg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::ReturnStmt(n) => {
-                if n.returnval.is_some() {
-                    let returnval = n.returnval.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&returnval);
-                    stack.push_back((returnval.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: returnval,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::PlassignStmt(n) => {
-                n.indirection.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.val.is_some() {
-                    let val = NodeEnum::SelectStmt(n.val.to_owned().unwrap());
-                    let location = get_location(&val);
-                    stack.push_back((val.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: val,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterTableStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.cmds.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterTableCmd(n) => {
-                if n.newowner.is_some() {
-                    let newowner = NodeEnum::RoleSpec(n.newowner.to_owned().unwrap());
-                    let location = get_location(&newowner);
-                    stack.push_back((newowner.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: newowner,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.def.is_some() {
-                    let def = n.def.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&def);
-                    stack.push_back((def.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: def,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterDomainStmt(n) => {
-                n.type_name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.def.is_some() {
-                    let def = n.def.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&def);
-                    stack.push_back((def.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: def,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::SetOperationStmt(n) => {
-                if n.larg.is_some() {
-                    let larg = n.larg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&larg);
-                    stack.push_back((larg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: larg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.rarg.is_some() {
-                    let rarg = n.rarg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&rarg);
-                    stack.push_back((rarg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: rarg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.col_types.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.col_typmods.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.col_collations.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.group_clauses.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::GrantStmt(n) => {
-                n.objects.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.privileges.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.grantees.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.grantor.is_some() {
-                    let grantor = NodeEnum::RoleSpec(n.grantor.to_owned().unwrap());
-                    let location = get_location(&grantor);
-                    stack.push_back((grantor.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: grantor,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::GrantRoleStmt(n) => {
-                n.granted_roles.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.grantee_roles.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.grantor.is_some() {
-                    let grantor = NodeEnum::RoleSpec(n.grantor.to_owned().unwrap());
-                    let location = get_location(&grantor);
-                    stack.push_back((grantor.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: grantor,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterDefaultPrivilegesStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.action.is_some() {
-                    let action = NodeEnum::GrantStmt(n.action.to_owned().unwrap());
-                    let location = get_location(&action);
-                    stack.push_back((action.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: action,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::ClosePortalStmt(n) => (),
-            NodeEnum::ClusterStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.params.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CopyStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.query.is_some() {
-                    let query = n.query.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&query);
-                    stack.push_back((query.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: query,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.attlist.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreateStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.table_elts.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.inh_relations.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.partbound.is_some() {
-                    let partbound = NodeEnum::PartitionBoundSpec(n.partbound.to_owned().unwrap());
-                    let location = get_location(&partbound);
-                    stack.push_back((partbound.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: partbound,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.partspec.is_some() {
-                    let partspec = NodeEnum::PartitionSpec(n.partspec.to_owned().unwrap());
-                    let location = get_location(&partspec);
-                    stack.push_back((partspec.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: partspec,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.of_typename.is_some() {
-                    let of_typename = NodeEnum::TypeName(n.of_typename.to_owned().unwrap());
-                    let location = get_location(&of_typename);
-                    stack.push_back((of_typename.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: of_typename,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.constraints.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DefineStmt(n) => {
-                n.defnames.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.definition.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DropStmt(n) => {
-                n.objects.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::TruncateStmt(n) => {
-                n.relations.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CommentStmt(n) => {
-                if n.object.is_some() {
-                    let object = n.object.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&object);
-                    stack.push_back((object.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: object,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::FetchStmt(n) => (),
-            NodeEnum::IndexStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.index_params.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.index_including_params.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.exclude_op_names.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateFunctionStmt(n) => {
-                n.funcname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.parameters.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.return_type.is_some() {
-                    let return_type = NodeEnum::TypeName(n.return_type.to_owned().unwrap());
-                    let location = get_location(&return_type);
-                    stack.push_back((return_type.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: return_type,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.sql_body.is_some() {
-                    let sql_body = n.sql_body.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&sql_body);
-                    stack.push_back((sql_body.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: sql_body,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterFunctionStmt(n) => {
-                if n.func.is_some() {
-                    let func = NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap());
-                    let location = get_location(&func);
-                    stack.push_back((func.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: func,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.actions.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DoStmt(n) => {
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RenameStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.object.is_some() {
-                    let object = n.object.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&object);
-                    stack.push_back((object.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: object,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::RuleStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.actions.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::NotifyStmt(n) => (),
-            NodeEnum::ListenStmt(n) => (),
-            NodeEnum::UnlistenStmt(n) => (),
-            NodeEnum::TransactionStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ViewStmt(n) => {
-                if n.view.is_some() {
-                    let view = NodeEnum::RangeVar(n.view.to_owned().unwrap());
-                    let location = get_location(&view);
-                    stack.push_back((view.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: view,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.aliases.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.query.is_some() {
-                    let query = n.query.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&query);
-                    stack.push_back((query.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: query,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::LoadStmt(n) => (),
-            NodeEnum::CreateDomainStmt(n) => {
-                n.domainname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.type_name.is_some() {
-                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    let location = get_location(&type_name);
-                    stack.push_back((type_name.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: type_name,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.coll_clause.is_some() {
-                    let coll_clause = NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap());
-                    let location = get_location(&coll_clause);
-                    stack.push_back((coll_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: coll_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.constraints.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreatedbStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DropdbStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::VacuumStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.rels.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ExplainStmt(n) => {
-                if n.query.is_some() {
-                    let query = n.query.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&query);
-                    stack.push_back((query.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: query,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateTableAsStmt(n) => {
-                if n.query.is_some() {
-                    let query = n.query.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&query);
-                    stack.push_back((query.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: query,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.into.is_some() {
-                    let into = NodeEnum::IntoClause(n.into.to_owned().unwrap());
-                    let location = get_location(&into);
-                    stack.push_back((into.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: into,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreateSeqStmt(n) => {
-                if n.sequence.is_some() {
-                    let sequence = NodeEnum::RangeVar(n.sequence.to_owned().unwrap());
-                    let location = get_location(&sequence);
-                    stack.push_back((sequence.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: sequence,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterSeqStmt(n) => {
-                if n.sequence.is_some() {
-                    let sequence = NodeEnum::RangeVar(n.sequence.to_owned().unwrap());
-                    let location = get_location(&sequence);
-                    stack.push_back((sequence.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: sequence,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::VariableSetStmt(n) => {
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::VariableShowStmt(n) => (),
-            NodeEnum::DiscardStmt(n) => (),
-            NodeEnum::CreateTrigStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.funcname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.columns.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.when_clause.is_some() {
-                    let when_clause = n.when_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&when_clause);
-                    stack.push_back((when_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: when_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.transition_rels.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.constrrel.is_some() {
-                    let constrrel = NodeEnum::RangeVar(n.constrrel.to_owned().unwrap());
-                    let location = get_location(&constrrel);
-                    stack.push_back((constrrel.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: constrrel,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreatePlangStmt(n) => {
-                n.plhandler.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.plinline.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.plvalidator.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateRoleStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterRoleStmt(n) => {
-                if n.role.is_some() {
-                    let role = NodeEnum::RoleSpec(n.role.to_owned().unwrap());
-                    let location = get_location(&role);
-                    stack.push_back((role.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: role,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DropRoleStmt(n) => {
-                n.roles.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::LockStmt(n) => {
-                n.relations.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ConstraintsSetStmt(n) => {
-                n.constraints.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ReindexStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.params.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CheckPointStmt(n) => (),
-            NodeEnum::CreateSchemaStmt(n) => {
-                if n.authrole.is_some() {
-                    let authrole = NodeEnum::RoleSpec(n.authrole.to_owned().unwrap());
-                    let location = get_location(&authrole);
-                    stack.push_back((authrole.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: authrole,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.schema_elts.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterDatabaseStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterDatabaseRefreshCollStmt(n) => (),
-            NodeEnum::AlterDatabaseSetStmt(n) => {
-                if n.setstmt.is_some() {
-                    let setstmt = NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap());
-                    let location = get_location(&setstmt);
-                    stack.push_back((setstmt.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: setstmt,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterRoleSetStmt(n) => {
-                if n.role.is_some() {
-                    let role = NodeEnum::RoleSpec(n.role.to_owned().unwrap());
-                    let location = get_location(&role);
-                    stack.push_back((role.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: role,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.setstmt.is_some() {
-                    let setstmt = NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap());
-                    let location = get_location(&setstmt);
-                    stack.push_back((setstmt.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: setstmt,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreateConversionStmt(n) => {
-                n.conversion_name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.func_name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateCastStmt(n) => {
-                if n.sourcetype.is_some() {
-                    let sourcetype = NodeEnum::TypeName(n.sourcetype.to_owned().unwrap());
-                    let location = get_location(&sourcetype);
-                    stack.push_back((sourcetype.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: sourcetype,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.targettype.is_some() {
-                    let targettype = NodeEnum::TypeName(n.targettype.to_owned().unwrap());
-                    let location = get_location(&targettype);
-                    stack.push_back((targettype.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: targettype,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.func.is_some() {
-                    let func = NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap());
-                    let location = get_location(&func);
-                    stack.push_back((func.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: func,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreateOpClassStmt(n) => {
-                n.opclassname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.opfamilyname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.datatype.is_some() {
-                    let datatype = NodeEnum::TypeName(n.datatype.to_owned().unwrap());
-                    let location = get_location(&datatype);
-                    stack.push_back((datatype.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: datatype,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.items.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateOpFamilyStmt(n) => {
-                n.opfamilyname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterOpFamilyStmt(n) => {
-                n.opfamilyname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.items.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::PrepareStmt(n) => {
-                n.argtypes.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.query.is_some() {
-                    let query = n.query.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&query);
-                    stack.push_back((query.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: query,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::ExecuteStmt(n) => {
-                n.params.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DeallocateStmt(n) => (),
-            NodeEnum::DeclareCursorStmt(n) => {
-                if n.query.is_some() {
-                    let query = n.query.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&query);
-                    stack.push_back((query.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: query,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreateTableSpaceStmt(n) => {
-                if n.owner.is_some() {
-                    let owner = NodeEnum::RoleSpec(n.owner.to_owned().unwrap());
-                    let location = get_location(&owner);
-                    stack.push_back((owner.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: owner,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DropTableSpaceStmt(n) => (),
-            NodeEnum::AlterObjectDependsStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.object.is_some() {
-                    let object = n.object.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&object);
-                    stack.push_back((object.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: object,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.extname.is_some() {
-                    let extname = NodeEnum::String(n.extname.to_owned().unwrap());
-                    let location = get_location(&extname);
-                    stack.push_back((extname.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: extname,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterObjectSchemaStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.object.is_some() {
-                    let object = n.object.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&object);
-                    stack.push_back((object.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: object,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterOwnerStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.object.is_some() {
-                    let object = n.object.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&object);
-                    stack.push_back((object.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: object,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.newowner.is_some() {
-                    let newowner = NodeEnum::RoleSpec(n.newowner.to_owned().unwrap());
-                    let location = get_location(&newowner);
-                    stack.push_back((newowner.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: newowner,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterOperatorStmt(n) => {
-                if n.opername.is_some() {
-                    let opername = NodeEnum::ObjectWithArgs(n.opername.to_owned().unwrap());
-                    let location = get_location(&opername);
-                    stack.push_back((opername.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: opername,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterTypeStmt(n) => {
-                n.type_name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DropOwnedStmt(n) => {
-                n.roles.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ReassignOwnedStmt(n) => {
-                n.roles.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.newrole.is_some() {
-                    let newrole = NodeEnum::RoleSpec(n.newrole.to_owned().unwrap());
-                    let location = get_location(&newrole);
-                    stack.push_back((newrole.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: newrole,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CompositeTypeStmt(n) => {
-                if n.typevar.is_some() {
-                    let typevar = NodeEnum::RangeVar(n.typevar.to_owned().unwrap());
-                    let location = get_location(&typevar);
-                    stack.push_back((typevar.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: typevar,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.coldeflist.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateEnumStmt(n) => {
-                n.type_name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.vals.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateRangeStmt(n) => {
-                n.type_name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.params.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterEnumStmt(n) => {
-                n.type_name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterTsdictionaryStmt(n) => {
-                n.dictname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterTsconfigurationStmt(n) => {
-                n.cfgname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.tokentype.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.dicts.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateFdwStmt(n) => {
-                n.func_options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterFdwStmt(n) => {
-                n.func_options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateForeignServerStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterForeignServerStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateUserMappingStmt(n) => {
-                if n.user.is_some() {
-                    let user = NodeEnum::RoleSpec(n.user.to_owned().unwrap());
-                    let location = get_location(&user);
-                    stack.push_back((user.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: user,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterUserMappingStmt(n) => {
-                if n.user.is_some() {
-                    let user = NodeEnum::RoleSpec(n.user.to_owned().unwrap());
-                    let location = get_location(&user);
-                    stack.push_back((user.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: user,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DropUserMappingStmt(n) => {
-                if n.user.is_some() {
-                    let user = NodeEnum::RoleSpec(n.user.to_owned().unwrap());
-                    let location = get_location(&user);
-                    stack.push_back((user.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: user,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterTableSpaceOptionsStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterTableMoveAllStmt(n) => {
-                n.roles.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::SecLabelStmt(n) => {
-                if n.object.is_some() {
-                    let object = n.object.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&object);
-                    stack.push_back((object.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: object,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreateForeignTableStmt(n) => {
-                if n.base_stmt.is_some() {
-                    let base_stmt = NodeEnum::CreateStmt(n.base_stmt.to_owned().unwrap());
-                    let location = get_location(&base_stmt);
-                    stack.push_back((base_stmt.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: base_stmt,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ImportForeignSchemaStmt(n) => {
-                n.table_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateExtensionStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterExtensionStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterExtensionContentsStmt(n) => {
-                if n.object.is_some() {
-                    let object = n.object.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&object);
-                    stack.push_back((object.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: object,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreateEventTrigStmt(n) => {
-                n.whenclause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.funcname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterEventTrigStmt(n) => (),
-            NodeEnum::RefreshMatViewStmt(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::ReplicaIdentityStmt(n) => (),
-            NodeEnum::AlterSystemStmt(n) => {
-                if n.setstmt.is_some() {
-                    let setstmt = NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap());
-                    let location = get_location(&setstmt);
-                    stack.push_back((setstmt.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: setstmt,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreatePolicyStmt(n) => {
-                if n.table.is_some() {
-                    let table = NodeEnum::RangeVar(n.table.to_owned().unwrap());
-                    let location = get_location(&table);
-                    stack.push_back((table.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: table,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.roles.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.qual.is_some() {
-                    let qual = n.qual.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&qual);
-                    stack.push_back((qual.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: qual,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.with_check.is_some() {
-                    let with_check = n.with_check.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&with_check);
-                    stack.push_back((with_check.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: with_check,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AlterPolicyStmt(n) => {
-                if n.table.is_some() {
-                    let table = NodeEnum::RangeVar(n.table.to_owned().unwrap());
-                    let location = get_location(&table);
-                    stack.push_back((table.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: table,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.roles.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.qual.is_some() {
-                    let qual = n.qual.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&qual);
-                    stack.push_back((qual.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: qual,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.with_check.is_some() {
-                    let with_check = n.with_check.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&with_check);
-                    stack.push_back((with_check.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: with_check,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreateTransformStmt(n) => {
-                if n.type_name.is_some() {
-                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    let location = get_location(&type_name);
-                    stack.push_back((type_name.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: type_name,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.fromsql.is_some() {
-                    let fromsql = NodeEnum::ObjectWithArgs(n.fromsql.to_owned().unwrap());
-                    let location = get_location(&fromsql);
-                    stack.push_back((fromsql.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: fromsql,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.tosql.is_some() {
-                    let tosql = NodeEnum::ObjectWithArgs(n.tosql.to_owned().unwrap());
-                    let location = get_location(&tosql);
-                    stack.push_back((tosql.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: tosql,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CreateAmStmt(n) => {
-                n.handler_name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreatePublicationStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.pubobjects.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterPublicationStmt(n) => {
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.pubobjects.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateSubscriptionStmt(n) => {
-                n.publication.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterSubscriptionStmt(n) => {
-                n.publication.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DropSubscriptionStmt(n) => (),
-            NodeEnum::CreateStatsStmt(n) => {
-                n.defnames.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.stat_types.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.exprs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.relations.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterCollationStmt(n) => {
-                n.collname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CallStmt(n) => {
-                if n.funccall.is_some() {
-                    let funccall = NodeEnum::FuncCall(n.funccall.to_owned().unwrap());
-                    let location = get_location(&funccall);
-                    stack.push_back((funccall.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: funccall,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.funcexpr.is_some() {
-                    let funcexpr = NodeEnum::FuncExpr(n.funcexpr.to_owned().unwrap());
-                    let location = get_location(&funcexpr);
-                    stack.push_back((funcexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: funcexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.outargs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AlterStatsStmt(n) => {
-                n.defnames.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AExpr(n) => {
-                n.name.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.lexpr.is_some() {
-                    let lexpr = n.lexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&lexpr);
-                    stack.push_back((lexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: lexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.rexpr.is_some() {
-                    let rexpr = n.rexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&rexpr);
-                    stack.push_back((rexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: rexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::ColumnRef(n) => {
-                n.fields.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ParamRef(n) => (),
-            NodeEnum::FuncCall(n) => {
-                n.funcname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.agg_order.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.agg_filter.is_some() {
-                    let agg_filter = n.agg_filter.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&agg_filter);
-                    stack.push_back((agg_filter.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: agg_filter,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.over.is_some() {
-                    let over = NodeEnum::WindowDef(n.over.to_owned().unwrap());
-                    let location = get_location(&over);
-                    stack.push_back((over.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: over,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AStar(n) => (),
-            NodeEnum::AIndices(n) => {
-                if n.lidx.is_some() {
-                    let lidx = n.lidx.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&lidx);
-                    stack.push_back((lidx.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: lidx,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.uidx.is_some() {
-                    let uidx = n.uidx.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&uidx);
-                    stack.push_back((uidx.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: uidx,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::AIndirection(n) => {
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.indirection.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AArrayExpr(n) => {
-                n.elements.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ResTarget(n) => {
-                n.indirection.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.val.is_some() {
-                    let val = n.val.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&val);
-                    stack.push_back((val.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: val,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::MultiAssignRef(n) => {
-                if n.source.is_some() {
-                    let source = n.source.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&source);
-                    stack.push_back((source.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: source,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::TypeCast(n) => {
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.type_name.is_some() {
-                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    let location = get_location(&type_name);
-                    stack.push_back((type_name.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: type_name,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CollateClause(n) => {
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.collname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::SortBy(n) => {
-                if n.node.is_some() {
-                    let node = n.node.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&node);
-                    stack.push_back((node.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: node,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.use_op.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::WindowDef(n) => {
-                n.partition_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.order_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.start_offset.is_some() {
-                    let start_offset = n.start_offset.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&start_offset);
-                    stack.push_back((start_offset.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: start_offset,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.end_offset.is_some() {
-                    let end_offset = n.end_offset.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&end_offset);
-                    stack.push_back((end_offset.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: end_offset,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::RangeSubselect(n) => {
-                if n.subquery.is_some() {
-                    let subquery = n.subquery.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&subquery);
-                    stack.push_back((subquery.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: subquery,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.alias.is_some() {
-                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    let location = get_location(&alias);
-                    stack.push_back((alias.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: alias,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::RangeFunction(n) => {
-                n.functions.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.alias.is_some() {
-                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    let location = get_location(&alias);
-                    stack.push_back((alias.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: alias,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.coldeflist.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RangeTableSample(n) => {
-                if n.relation.is_some() {
-                    let relation = n.relation.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.method.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.repeatable.is_some() {
-                    let repeatable = n.repeatable.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&repeatable);
-                    stack.push_back((repeatable.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: repeatable,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::RangeTableFunc(n) => {
-                if n.docexpr.is_some() {
-                    let docexpr = n.docexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&docexpr);
-                    stack.push_back((docexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: docexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.rowexpr.is_some() {
-                    let rowexpr = n.rowexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&rowexpr);
-                    stack.push_back((rowexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: rowexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.namespaces.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.columns.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.alias.is_some() {
-                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    let location = get_location(&alias);
-                    stack.push_back((alias.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: alias,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::RangeTableFuncCol(n) => {
-                if n.type_name.is_some() {
-                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    let location = get_location(&type_name);
-                    stack.push_back((type_name.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: type_name,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.colexpr.is_some() {
-                    let colexpr = n.colexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&colexpr);
-                    stack.push_back((colexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: colexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.coldefexpr.is_some() {
-                    let coldefexpr = n.coldefexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&coldefexpr);
-                    stack.push_back((coldefexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: coldefexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::TypeName(n) => {
-                n.names.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.typmods.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.array_bounds.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ColumnDef(n) => {
-                if n.type_name.is_some() {
-                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    let location = get_location(&type_name);
-                    stack.push_back((type_name.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: type_name,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.raw_default.is_some() {
-                    let raw_default = n.raw_default.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&raw_default);
-                    stack.push_back((raw_default.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: raw_default,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.cooked_default.is_some() {
-                    let cooked_default = n.cooked_default.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&cooked_default);
-                    stack.push_back((cooked_default.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: cooked_default,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.identity_sequence.is_some() {
-                    let identity_sequence =
-                        NodeEnum::RangeVar(n.identity_sequence.to_owned().unwrap());
-                    let location = get_location(&identity_sequence);
-                    stack.push_back((identity_sequence.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: identity_sequence,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.coll_clause.is_some() {
-                    let coll_clause = NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap());
-                    let location = get_location(&coll_clause);
-                    stack.push_back((coll_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: coll_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.constraints.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.fdwoptions.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::IndexElem(n) => {
-                if n.expr.is_some() {
-                    let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&expr);
-                    stack.push_back((expr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: expr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.collation.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.opclass.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.opclassopts.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::StatsElem(n) => {
-                if n.expr.is_some() {
-                    let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&expr);
-                    stack.push_back((expr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: expr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::Constraint(n) => {
-                if n.raw_expr.is_some() {
-                    let raw_expr = n.raw_expr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&raw_expr);
-                    stack.push_back((raw_expr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: raw_expr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.keys.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.including.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.exclusions.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.options.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.pktable.is_some() {
-                    let pktable = NodeEnum::RangeVar(n.pktable.to_owned().unwrap());
-                    let location = get_location(&pktable);
-                    stack.push_back((pktable.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: pktable,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.fk_attrs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.pk_attrs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.fk_del_set_cols.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.old_conpfeqop.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::DefElem(n) => {
-                if n.arg.is_some() {
-                    let arg = n.arg.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&arg);
-                    stack.push_back((arg.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::RangeTblEntry(n) => {
-                if n.tablesample.is_some() {
-                    let tablesample =
-                        NodeEnum::TableSampleClause(n.tablesample.to_owned().unwrap());
-                    let location = get_location(&tablesample);
-                    stack.push_back((tablesample.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: tablesample,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.subquery.is_some() {
-                    let subquery = NodeEnum::Query(n.subquery.to_owned().unwrap());
-                    let location = get_location(&subquery);
-                    stack.push_back((subquery.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: subquery,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.joinaliasvars.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.joinleftcols.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.joinrightcols.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.join_using_alias.is_some() {
-                    let join_using_alias = NodeEnum::Alias(n.join_using_alias.to_owned().unwrap());
-                    let location = get_location(&join_using_alias);
-                    stack.push_back((join_using_alias.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: join_using_alias,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.functions.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.tablefunc.is_some() {
-                    let tablefunc = NodeEnum::TableFunc(n.tablefunc.to_owned().unwrap());
-                    let location = get_location(&tablefunc);
-                    stack.push_back((tablefunc.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: tablefunc,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.values_lists.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.coltypes.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.coltypmods.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.colcollations.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.alias.is_some() {
-                    let alias = NodeEnum::Alias(n.alias.to_owned().unwrap());
-                    let location = get_location(&alias);
-                    stack.push_back((alias.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: alias,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.eref.is_some() {
-                    let eref = NodeEnum::Alias(n.eref.to_owned().unwrap());
-                    let location = get_location(&eref);
-                    stack.push_back((eref.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: eref,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.security_quals.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RangeTblFunction(n) => {
-                if n.funcexpr.is_some() {
-                    let funcexpr = n.funcexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&funcexpr);
-                    stack.push_back((funcexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: funcexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.funccolnames.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.funccoltypes.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.funccoltypmods.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.funccolcollations.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::TableSampleClause(n) => {
-                n.args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.repeatable.is_some() {
-                    let repeatable = n.repeatable.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&repeatable);
-                    stack.push_back((repeatable.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: repeatable,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::WithCheckOption(n) => {
-                if n.qual.is_some() {
-                    let qual = n.qual.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&qual);
-                    stack.push_back((qual.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: qual,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::SortGroupClause(n) => (),
-            NodeEnum::GroupingSet(n) => {
-                n.content.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::WindowClause(n) => {
-                n.partition_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.order_clause.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.start_offset.is_some() {
-                    let start_offset = n.start_offset.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&start_offset);
-                    stack.push_back((start_offset.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: start_offset,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.end_offset.is_some() {
-                    let end_offset = n.end_offset.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&end_offset);
-                    stack.push_back((end_offset.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: end_offset,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.run_condition.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::ObjectWithArgs(n) => {
-                n.objname.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.objargs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.objfuncargs.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AccessPriv(n) => {
-                n.cols.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CreateOpClassItem(n) => {
-                if n.name.is_some() {
-                    let name = NodeEnum::ObjectWithArgs(n.name.to_owned().unwrap());
-                    let location = get_location(&name);
-                    stack.push_back((name.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: name,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.order_family.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.class_args.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.storedtype.is_some() {
-                    let storedtype = NodeEnum::TypeName(n.storedtype.to_owned().unwrap());
-                    let location = get_location(&storedtype);
-                    stack.push_back((storedtype.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: storedtype,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::TableLikeClause(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::FunctionParameter(n) => {
-                if n.arg_type.is_some() {
-                    let arg_type = NodeEnum::TypeName(n.arg_type.to_owned().unwrap());
-                    let location = get_location(&arg_type);
-                    stack.push_back((arg_type.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: arg_type,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.defexpr.is_some() {
-                    let defexpr = n.defexpr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&defexpr);
-                    stack.push_back((defexpr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: defexpr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::LockingClause(n) => {
-                n.locked_rels.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RowMarkClause(n) => (),
-            NodeEnum::XmlSerialize(n) => {
-                if n.expr.is_some() {
-                    let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&expr);
-                    stack.push_back((expr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: expr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.type_name.is_some() {
-                    let type_name = NodeEnum::TypeName(n.type_name.to_owned().unwrap());
-                    let location = get_location(&type_name);
-                    stack.push_back((type_name.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: type_name,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::WithClause(n) => {
-                n.ctes.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::InferClause(n) => {
-                n.index_elems.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::OnConflictClause(n) => {
-                if n.infer.is_some() {
-                    let infer = NodeEnum::InferClause(n.infer.to_owned().unwrap());
-                    let location = get_location(&infer);
-                    stack.push_back((infer.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: infer,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.target_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CtesearchClause(n) => {
-                n.search_col_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::CtecycleClause(n) => {
-                n.cycle_col_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.cycle_mark_value.is_some() {
-                    let cycle_mark_value = n.cycle_mark_value.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&cycle_mark_value);
-                    stack.push_back((cycle_mark_value.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: cycle_mark_value,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.cycle_mark_default.is_some() {
-                    let cycle_mark_default = n.cycle_mark_default.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&cycle_mark_default);
-                    stack.push_back((cycle_mark_default.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: cycle_mark_default,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::CommonTableExpr(n) => {
-                n.aliascolnames.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                if n.ctequery.is_some() {
-                    let ctequery = n.ctequery.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&ctequery);
-                    stack.push_back((ctequery.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: ctequery,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.search_clause.is_some() {
-                    let search_clause =
-                        NodeEnum::CtesearchClause(n.search_clause.to_owned().unwrap());
-                    let location = get_location(&search_clause);
-                    stack.push_back((search_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: search_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.cycle_clause.is_some() {
-                    let cycle_clause = NodeEnum::CtecycleClause(n.cycle_clause.to_owned().unwrap());
-                    let location = get_location(&cycle_clause);
-                    stack.push_back((cycle_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: cycle_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.ctecolnames.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.ctecoltypes.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.ctecoltypmods.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.ctecolcollations.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::MergeWhenClause(n) => {
-                if n.condition.is_some() {
-                    let condition = n.condition.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&condition);
-                    stack.push_back((condition.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: condition,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.target_list.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.values.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::RoleSpec(n) => (),
-            NodeEnum::TriggerTransition(n) => (),
-            NodeEnum::PartitionElem(n) => {
-                if n.expr.is_some() {
-                    let expr = n.expr.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&expr);
-                    stack.push_back((expr.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: expr,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.collation.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.opclass.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::PartitionSpec(n) => {
-                n.part_params.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::PartitionBoundSpec(n) => {
-                n.listdatums.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.lowerdatums.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-
-                n.upperdatums.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::PartitionRangeDatum(n) => {
-                if n.value.is_some() {
-                    let value = n.value.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&value);
-                    stack.push_back((value.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: value,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::PartitionCmd(n) => {
-                if n.name.is_some() {
-                    let name = NodeEnum::RangeVar(n.name.to_owned().unwrap());
-                    let location = get_location(&name);
-                    stack.push_back((name.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: name,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.bound.is_some() {
-                    let bound = NodeEnum::PartitionBoundSpec(n.bound.to_owned().unwrap());
-                    let location = get_location(&bound);
-                    stack.push_back((bound.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: bound,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::VacuumRelation(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.va_cols.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::PublicationObjSpec(n) => {
-                if n.pubtable.is_some() {
-                    let pubtable = NodeEnum::PublicationTable(n.pubtable.to_owned().unwrap());
-                    let location = get_location(&pubtable);
-                    stack.push_back((pubtable.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: pubtable,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-            }
-            NodeEnum::PublicationTable(n) => {
-                if n.relation.is_some() {
-                    let relation = NodeEnum::RangeVar(n.relation.to_owned().unwrap());
-                    let location = get_location(&relation);
-                    stack.push_back((relation.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: relation,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                if n.where_clause.is_some() {
-                    let where_clause = n.where_clause.to_owned().unwrap().node.unwrap();
-                    let location = get_location(&where_clause);
-                    stack.push_back((where_clause.to_owned(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: where_clause,
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                }
-
-                n.columns.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::InlineCodeBlock(n) => (),
-            NodeEnum::CallContext(n) => (),
-            NodeEnum::Integer(n) => (),
-            NodeEnum::Float(n) => (),
-            NodeEnum::Boolean(n) => (),
-            NodeEnum::String(n) => (),
-            NodeEnum::BitString(n) => (),
-            NodeEnum::List(n) => {
-                n.items.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::IntList(n) => {
-                n.items.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::OidList(n) => {
-                n.items.iter().for_each(|x| {
-                    let location = get_location(&x.node.as_ref().unwrap());
-                    stack.push_back((x.node.to_owned().unwrap(), current_depth, location));
-                    nodes.push(NestedNode {
-                        node: x.node.to_owned().unwrap(),
-                        depth: current_depth,
-                        location,
-                        parent_location,
-                    });
-                });
-            }
-            NodeEnum::AConst(n) => {
-                if n.val.is_some() {
-                    let value = match n.val.to_owned().unwrap() {
-                        pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
-                        pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
-                        pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
-                        pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
-                        pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
-                    };
-
-                    nodes.push(NestedNode {
-                        node: value,
-                        depth: current_depth,
-                        // this is always the parent location
-                        location: parent_location,
-                        parent_location,
-                    });
-                }
-            }
-        };
+    // Node, depth, path
+    let mut stack: VecDeque<(NodeEnum, i32, String)> =
+        VecDeque::from(vec![(node.to_owned(), current_depth, "0".to_string())]); // Node, depth, path
+    let mut location_stack: VecDeque<(NodeEnum, i32, String)> = VecDeque::new();
+    while !stack.is_empty() || !location_stack.is_empty() {
+        if !stack.is_empty() {
+            let (node, depth, path) = stack.pop_front().unwrap();
+            let current_depth = depth + 1;
+            let mut child_ctr: i32 = 0;
+            let mut handle_child = |c: NodeEnum| {
+                let location = get_location(&c);
+                let path = path.clone() + "." + child_ctr.to_string().as_str();
+                child_ctr = child_ctr + 1;
+                stack.push_back((c.to_owned(), current_depth, path.clone()));
+                if location.is_some() {
+                    nodes.push(NestedNode {
+                        node: c,
+                        depth: current_depth,
+                        location: location.unwrap(),
+                        path: path.clone(),
+                    });
+                } else {
+                    location_stack.push_back((c, current_depth, path));
+                }
+            };
+            match &node {
+                NodeEnum::Alias(n) => {
+                    n.colnames
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RangeVar(n) => {
+                    if n.alias.is_some() {
+                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::TableFunc(n) => {
+                    n.ns_uris
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.ns_names
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.docexpr.is_some() {
+                        handle_child(n.docexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.rowexpr.is_some() {
+                        handle_child(n.rowexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.colnames
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.coltypes
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.coltypmods
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.colcollations
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.colexprs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.coldefexprs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::Var(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::Param(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::Aggref(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.aggargtypes
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.aggdirectargs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.aggorder
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.aggdistinct
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.aggfilter.is_some() {
+                        handle_child(n.aggfilter.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::GroupingFunc(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.refs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.cols
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::WindowFunc(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.aggfilter.is_some() {
+                        handle_child(n.aggfilter.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::SubscriptingRef(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.refupperindexpr
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.reflowerindexpr
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.refexpr.is_some() {
+                        handle_child(n.refexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.refassgnexpr.is_some() {
+                        handle_child(n.refassgnexpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::FuncExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::NamedArgExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::OpExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DistinctExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::NullIfExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ScalarArrayOpExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::BoolExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::SubLink(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.testexpr.is_some() {
+                        handle_child(n.testexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.oper_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.subselect.is_some() {
+                        handle_child(n.subselect.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::SubPlan(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.testexpr.is_some() {
+                        handle_child(n.testexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.param_ids
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.set_param
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.par_param
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlternativeSubPlan(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.subplans
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::FieldSelect(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::FieldStore(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.newvals
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.fieldnums
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RelabelType(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CoerceViaIo(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::ArrayCoerceExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.elemexpr.is_some() {
+                        handle_child(n.elemexpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::ConvertRowtypeExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CollateExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CaseExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.defresult.is_some() {
+                        handle_child(n.defresult.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CaseWhen(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.expr.is_some() {
+                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.result.is_some() {
+                        handle_child(n.result.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CaseTestExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::ArrayExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.elements
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RowExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.colnames
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RowCompareExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.opnos
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.opfamilies
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.inputcollids
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.largs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.rargs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CoalesceExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::MinMaxExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::SqlvalueFunction(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::XmlExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.named_args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.arg_names
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::NullTest(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::BooleanTest(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CoerceToDomain(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CoerceToDomainValue(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::SetToDefault(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CurrentOfExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::NextValueExpr(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::InferenceElem(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.expr.is_some() {
+                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::TargetEntry(n) => {
+                    if n.xpr.is_some() {
+                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.expr.is_some() {
+                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::RangeTblRef(n) => (),
+                NodeEnum::JoinExpr(n) => {
+                    if n.larg.is_some() {
+                        handle_child(n.larg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.rarg.is_some() {
+                        handle_child(n.rarg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.using_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.join_using_alias.is_some() {
+                        handle_child(NodeEnum::Alias(n.join_using_alias.to_owned().unwrap()));
+                    }
+
+                    if n.quals.is_some() {
+                        handle_child(n.quals.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.alias.is_some() {
+                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::FromExpr(n) => {
+                    n.fromlist
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.quals.is_some() {
+                        handle_child(n.quals.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::OnConflictExpr(n) => {
+                    n.arbiter_elems
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.arbiter_where.is_some() {
+                        handle_child(n.arbiter_where.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.on_conflict_set
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.on_conflict_where.is_some() {
+                        handle_child(n.on_conflict_where.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.excl_rel_tlist
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::IntoClause(n) => {
+                    if n.rel.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.rel.to_owned().unwrap()));
+                    }
+
+                    n.col_names
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.view_query.is_some() {
+                        handle_child(n.view_query.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::MergeAction(n) => {
+                    if n.qual.is_some() {
+                        handle_child(n.qual.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.target_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.update_colnos
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RawStmt(n) => {
+                    if n.stmt.is_some() {
+                        handle_child(n.stmt.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::Query(n) => {
+                    if n.utility_stmt.is_some() {
+                        handle_child(n.utility_stmt.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.cte_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.rtable
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.jointree.is_some() {
+                        handle_child(NodeEnum::FromExpr(n.jointree.to_owned().unwrap()));
+                    }
+
+                    n.merge_action_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.target_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.on_conflict.is_some() {
+                        handle_child(NodeEnum::OnConflictExpr(n.on_conflict.to_owned().unwrap()));
+                    }
+
+                    n.returning_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.group_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.grouping_sets
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.having_qual.is_some() {
+                        handle_child(n.having_qual.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.window_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.distinct_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.sort_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.limit_offset.is_some() {
+                        handle_child(n.limit_offset.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.limit_count.is_some() {
+                        handle_child(n.limit_count.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.row_marks
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.set_operations.is_some() {
+                        handle_child(n.set_operations.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.constraint_deps
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.with_check_options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::InsertStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.cols
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.select_stmt.is_some() {
+                        handle_child(n.select_stmt.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.on_conflict_clause.is_some() {
+                        handle_child(NodeEnum::OnConflictClause(
+                            n.on_conflict_clause.to_owned().unwrap(),
+                        ));
+                    }
+
+                    n.returning_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.with_clause.is_some() {
+                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::DeleteStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.using_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.returning_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.with_clause.is_some() {
+                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::UpdateStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.target_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.from_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.returning_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.with_clause.is_some() {
+                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::MergeStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    if n.source_relation.is_some() {
+                        handle_child(n.source_relation.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.join_condition.is_some() {
+                        handle_child(n.join_condition.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.merge_when_clauses
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.with_clause.is_some() {
+                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::SelectStmt(n) => {
+                    n.distinct_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.into_clause.is_some() {
+                        handle_child(NodeEnum::IntoClause(n.into_clause.to_owned().unwrap()));
+                    }
+
+                    n.target_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.from_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.group_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.having_clause.is_some() {
+                        handle_child(n.having_clause.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.window_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.values_lists
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.sort_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.limit_offset.is_some() {
+                        handle_child(n.limit_offset.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.limit_count.is_some() {
+                        handle_child(n.limit_count.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.locking_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.with_clause.is_some() {
+                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
+                    }
+
+                    if n.larg.is_some() {
+                        handle_child(NodeEnum::SelectStmt(n.larg.to_owned().unwrap()));
+                    }
+
+                    if n.rarg.is_some() {
+                        handle_child(NodeEnum::SelectStmt(n.rarg.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::ReturnStmt(n) => {
+                    if n.returnval.is_some() {
+                        handle_child(n.returnval.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::PlassignStmt(n) => {
+                    n.indirection
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.val.is_some() {
+                        handle_child(NodeEnum::SelectStmt(n.val.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::AlterTableStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.cmds
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterTableCmd(n) => {
+                    if n.newowner.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.newowner.to_owned().unwrap()));
+                    }
+
+                    if n.def.is_some() {
+                        handle_child(n.def.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::AlterDomainStmt(n) => {
+                    n.type_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.def.is_some() {
+                        handle_child(n.def.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::SetOperationStmt(n) => {
+                    if n.larg.is_some() {
+                        handle_child(n.larg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.rarg.is_some() {
+                        handle_child(n.rarg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.col_types
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.col_typmods
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.col_collations
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.group_clauses
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::GrantStmt(n) => {
+                    n.objects
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.privileges
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.grantees
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.grantor.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.grantor.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::GrantRoleStmt(n) => {
+                    n.granted_roles
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.grantee_roles
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.grantor.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.grantor.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::AlterDefaultPrivilegesStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.action.is_some() {
+                        handle_child(NodeEnum::GrantStmt(n.action.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::ClosePortalStmt(n) => (),
+                NodeEnum::ClusterStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.params
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CopyStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    if n.query.is_some() {
+                        handle_child(n.query.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.attlist
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CreateStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.table_elts
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.inh_relations
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.partbound.is_some() {
+                        handle_child(NodeEnum::PartitionBoundSpec(
+                            n.partbound.to_owned().unwrap(),
+                        ));
+                    }
+
+                    if n.partspec.is_some() {
+                        handle_child(NodeEnum::PartitionSpec(n.partspec.to_owned().unwrap()));
+                    }
+
+                    if n.of_typename.is_some() {
+                        handle_child(NodeEnum::TypeName(n.of_typename.to_owned().unwrap()));
+                    }
+
+                    n.constraints
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DefineStmt(n) => {
+                    n.defnames
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.definition
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DropStmt(n) => {
+                    n.objects
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::TruncateStmt(n) => {
+                    n.relations
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CommentStmt(n) => {
+                    if n.object.is_some() {
+                        handle_child(n.object.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::FetchStmt(n) => (),
+                NodeEnum::IndexStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.index_params
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.index_including_params
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.exclude_op_names
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateFunctionStmt(n) => {
+                    n.funcname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.parameters
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.return_type.is_some() {
+                        handle_child(NodeEnum::TypeName(n.return_type.to_owned().unwrap()));
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.sql_body.is_some() {
+                        handle_child(n.sql_body.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::AlterFunctionStmt(n) => {
+                    if n.func.is_some() {
+                        handle_child(NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap()));
+                    }
+
+                    n.actions
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DoStmt(n) => {
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RenameStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    if n.object.is_some() {
+                        handle_child(n.object.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::RuleStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.actions
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::NotifyStmt(n) => (),
+                NodeEnum::ListenStmt(n) => (),
+                NodeEnum::UnlistenStmt(n) => (),
+                NodeEnum::TransactionStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ViewStmt(n) => {
+                    if n.view.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.view.to_owned().unwrap()));
+                    }
+
+                    n.aliases
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.query.is_some() {
+                        handle_child(n.query.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::LoadStmt(n) => (),
+                NodeEnum::CreateDomainStmt(n) => {
+                    n.domainname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.type_name.is_some() {
+                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
+                    }
+
+                    if n.coll_clause.is_some() {
+                        handle_child(NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap()));
+                    }
+
+                    n.constraints
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreatedbStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DropdbStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::VacuumStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.rels
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ExplainStmt(n) => {
+                    if n.query.is_some() {
+                        handle_child(n.query.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateTableAsStmt(n) => {
+                    if n.query.is_some() {
+                        handle_child(n.query.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.into.is_some() {
+                        handle_child(NodeEnum::IntoClause(n.into.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::CreateSeqStmt(n) => {
+                    if n.sequence.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.sequence.to_owned().unwrap()));
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterSeqStmt(n) => {
+                    if n.sequence.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.sequence.to_owned().unwrap()));
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::VariableSetStmt(n) => {
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::VariableShowStmt(n) => (),
+                NodeEnum::DiscardStmt(n) => (),
+                NodeEnum::CreateTrigStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.funcname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.columns
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.when_clause.is_some() {
+                        handle_child(n.when_clause.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.transition_rels
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.constrrel.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.constrrel.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::CreatePlangStmt(n) => {
+                    n.plhandler
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.plinline
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.plvalidator
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateRoleStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterRoleStmt(n) => {
+                    if n.role.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.role.to_owned().unwrap()));
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DropRoleStmt(n) => {
+                    n.roles
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::LockStmt(n) => {
+                    n.relations
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ConstraintsSetStmt(n) => {
+                    n.constraints
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ReindexStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.params
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CheckPointStmt(n) => (),
+                NodeEnum::CreateSchemaStmt(n) => {
+                    if n.authrole.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.authrole.to_owned().unwrap()));
+                    }
+
+                    n.schema_elts
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterDatabaseStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterDatabaseRefreshCollStmt(n) => (),
+                NodeEnum::AlterDatabaseSetStmt(n) => {
+                    if n.setstmt.is_some() {
+                        handle_child(NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::AlterRoleSetStmt(n) => {
+                    if n.role.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.role.to_owned().unwrap()));
+                    }
+
+                    if n.setstmt.is_some() {
+                        handle_child(NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::CreateConversionStmt(n) => {
+                    n.conversion_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.func_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateCastStmt(n) => {
+                    if n.sourcetype.is_some() {
+                        handle_child(NodeEnum::TypeName(n.sourcetype.to_owned().unwrap()));
+                    }
+
+                    if n.targettype.is_some() {
+                        handle_child(NodeEnum::TypeName(n.targettype.to_owned().unwrap()));
+                    }
+
+                    if n.func.is_some() {
+                        handle_child(NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::CreateOpClassStmt(n) => {
+                    n.opclassname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.opfamilyname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.datatype.is_some() {
+                        handle_child(NodeEnum::TypeName(n.datatype.to_owned().unwrap()));
+                    }
+
+                    n.items
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateOpFamilyStmt(n) => {
+                    n.opfamilyname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterOpFamilyStmt(n) => {
+                    n.opfamilyname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.items
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::PrepareStmt(n) => {
+                    n.argtypes
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.query.is_some() {
+                        handle_child(n.query.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::ExecuteStmt(n) => {
+                    n.params
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DeallocateStmt(n) => (),
+                NodeEnum::DeclareCursorStmt(n) => {
+                    if n.query.is_some() {
+                        handle_child(n.query.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CreateTableSpaceStmt(n) => {
+                    if n.owner.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.owner.to_owned().unwrap()));
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DropTableSpaceStmt(n) => (),
+                NodeEnum::AlterObjectDependsStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    if n.object.is_some() {
+                        handle_child(n.object.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.extname.is_some() {
+                        handle_child(NodeEnum::String(n.extname.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::AlterObjectSchemaStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    if n.object.is_some() {
+                        handle_child(n.object.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::AlterOwnerStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    if n.object.is_some() {
+                        handle_child(n.object.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.newowner.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.newowner.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::AlterOperatorStmt(n) => {
+                    if n.opername.is_some() {
+                        handle_child(NodeEnum::ObjectWithArgs(n.opername.to_owned().unwrap()));
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterTypeStmt(n) => {
+                    n.type_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DropOwnedStmt(n) => {
+                    n.roles
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ReassignOwnedStmt(n) => {
+                    n.roles
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.newrole.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.newrole.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::CompositeTypeStmt(n) => {
+                    if n.typevar.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.typevar.to_owned().unwrap()));
+                    }
+
+                    n.coldeflist
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateEnumStmt(n) => {
+                    n.type_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.vals
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateRangeStmt(n) => {
+                    n.type_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.params
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterEnumStmt(n) => {
+                    n.type_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterTsdictionaryStmt(n) => {
+                    n.dictname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterTsconfigurationStmt(n) => {
+                    n.cfgname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.tokentype
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.dicts
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateFdwStmt(n) => {
+                    n.func_options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterFdwStmt(n) => {
+                    n.func_options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateForeignServerStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterForeignServerStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateUserMappingStmt(n) => {
+                    if n.user.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.user.to_owned().unwrap()));
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterUserMappingStmt(n) => {
+                    if n.user.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.user.to_owned().unwrap()));
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DropUserMappingStmt(n) => {
+                    if n.user.is_some() {
+                        handle_child(NodeEnum::RoleSpec(n.user.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::AlterTableSpaceOptionsStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterTableMoveAllStmt(n) => {
+                    n.roles
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::SecLabelStmt(n) => {
+                    if n.object.is_some() {
+                        handle_child(n.object.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CreateForeignTableStmt(n) => {
+                    if n.base_stmt.is_some() {
+                        handle_child(NodeEnum::CreateStmt(n.base_stmt.to_owned().unwrap()));
+                    }
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ImportForeignSchemaStmt(n) => {
+                    n.table_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateExtensionStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterExtensionStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterExtensionContentsStmt(n) => {
+                    if n.object.is_some() {
+                        handle_child(n.object.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CreateEventTrigStmt(n) => {
+                    n.whenclause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.funcname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterEventTrigStmt(n) => (),
+                NodeEnum::RefreshMatViewStmt(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::ReplicaIdentityStmt(n) => (),
+                NodeEnum::AlterSystemStmt(n) => {
+                    if n.setstmt.is_some() {
+                        handle_child(NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::CreatePolicyStmt(n) => {
+                    if n.table.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.table.to_owned().unwrap()));
+                    }
+
+                    n.roles
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.qual.is_some() {
+                        handle_child(n.qual.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.with_check.is_some() {
+                        handle_child(n.with_check.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::AlterPolicyStmt(n) => {
+                    if n.table.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.table.to_owned().unwrap()));
+                    }
+
+                    n.roles
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.qual.is_some() {
+                        handle_child(n.qual.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.with_check.is_some() {
+                        handle_child(n.with_check.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CreateTransformStmt(n) => {
+                    if n.type_name.is_some() {
+                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
+                    }
+
+                    if n.fromsql.is_some() {
+                        handle_child(NodeEnum::ObjectWithArgs(n.fromsql.to_owned().unwrap()));
+                    }
+
+                    if n.tosql.is_some() {
+                        handle_child(NodeEnum::ObjectWithArgs(n.tosql.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::CreateAmStmt(n) => {
+                    n.handler_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreatePublicationStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.pubobjects
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterPublicationStmt(n) => {
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.pubobjects
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateSubscriptionStmt(n) => {
+                    n.publication
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterSubscriptionStmt(n) => {
+                    n.publication
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DropSubscriptionStmt(n) => (),
+                NodeEnum::CreateStatsStmt(n) => {
+                    n.defnames
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.stat_types
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.exprs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.relations
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterCollationStmt(n) => {
+                    n.collname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CallStmt(n) => {
+                    if n.funccall.is_some() {
+                        handle_child(NodeEnum::FuncCall(n.funccall.to_owned().unwrap()));
+                    }
+
+                    if n.funcexpr.is_some() {
+                        handle_child(NodeEnum::FuncExpr(n.funcexpr.to_owned().unwrap()));
+                    }
+
+                    n.outargs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AlterStatsStmt(n) => {
+                    n.defnames
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AExpr(n) => {
+                    n.name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.lexpr.is_some() {
+                        handle_child(n.lexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.rexpr.is_some() {
+                        handle_child(n.rexpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::ColumnRef(n) => {
+                    n.fields
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ParamRef(n) => (),
+                NodeEnum::FuncCall(n) => {
+                    n.funcname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.agg_order
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.agg_filter.is_some() {
+                        handle_child(n.agg_filter.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.over.is_some() {
+                        handle_child(NodeEnum::WindowDef(n.over.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::AStar(n) => (),
+                NodeEnum::AIndices(n) => {
+                    if n.lidx.is_some() {
+                        handle_child(n.lidx.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.uidx.is_some() {
+                        handle_child(n.uidx.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::AIndirection(n) => {
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.indirection
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AArrayExpr(n) => {
+                    n.elements
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ResTarget(n) => {
+                    n.indirection
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.val.is_some() {
+                        handle_child(n.val.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::MultiAssignRef(n) => {
+                    if n.source.is_some() {
+                        handle_child(n.source.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::TypeCast(n) => {
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.type_name.is_some() {
+                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::CollateClause(n) => {
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.collname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::SortBy(n) => {
+                    if n.node.is_some() {
+                        handle_child(n.node.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.use_op
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::WindowDef(n) => {
+                    n.partition_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.order_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.start_offset.is_some() {
+                        handle_child(n.start_offset.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.end_offset.is_some() {
+                        handle_child(n.end_offset.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::RangeSubselect(n) => {
+                    if n.subquery.is_some() {
+                        handle_child(n.subquery.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.alias.is_some() {
+                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::RangeFunction(n) => {
+                    n.functions
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.alias.is_some() {
+                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
+                    }
+
+                    n.coldeflist
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RangeTableSample(n) => {
+                    if n.relation.is_some() {
+                        handle_child(n.relation.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.method
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.repeatable.is_some() {
+                        handle_child(n.repeatable.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::RangeTableFunc(n) => {
+                    if n.docexpr.is_some() {
+                        handle_child(n.docexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.rowexpr.is_some() {
+                        handle_child(n.rowexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.namespaces
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.columns
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.alias.is_some() {
+                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::RangeTableFuncCol(n) => {
+                    if n.type_name.is_some() {
+                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
+                    }
+
+                    if n.colexpr.is_some() {
+                        handle_child(n.colexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.coldefexpr.is_some() {
+                        handle_child(n.coldefexpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::TypeName(n) => {
+                    n.names
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.typmods
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.array_bounds
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ColumnDef(n) => {
+                    if n.type_name.is_some() {
+                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
+                    }
+
+                    if n.raw_default.is_some() {
+                        handle_child(n.raw_default.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.cooked_default.is_some() {
+                        handle_child(n.cooked_default.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.identity_sequence.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.identity_sequence.to_owned().unwrap()));
+                    }
+
+                    if n.coll_clause.is_some() {
+                        handle_child(NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap()));
+                    }
+
+                    n.constraints
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.fdwoptions
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::IndexElem(n) => {
+                    if n.expr.is_some() {
+                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.collation
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.opclass
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.opclassopts
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::StatsElem(n) => {
+                    if n.expr.is_some() {
+                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::Constraint(n) => {
+                    if n.raw_expr.is_some() {
+                        handle_child(n.raw_expr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.keys
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.including
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.exclusions
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.options
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.pktable.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.pktable.to_owned().unwrap()));
+                    }
+
+                    n.fk_attrs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.pk_attrs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.fk_del_set_cols
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.old_conpfeqop
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::DefElem(n) => {
+                    if n.arg.is_some() {
+                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::RangeTblEntry(n) => {
+                    if n.tablesample.is_some() {
+                        handle_child(NodeEnum::TableSampleClause(
+                            n.tablesample.to_owned().unwrap(),
+                        ));
+                    }
+
+                    if n.subquery.is_some() {
+                        handle_child(NodeEnum::Query(n.subquery.to_owned().unwrap()));
+                    }
+
+                    n.joinaliasvars
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.joinleftcols
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.joinrightcols
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.join_using_alias.is_some() {
+                        handle_child(NodeEnum::Alias(n.join_using_alias.to_owned().unwrap()));
+                    }
+
+                    n.functions
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.tablefunc.is_some() {
+                        handle_child(NodeEnum::TableFunc(n.tablefunc.to_owned().unwrap()));
+                    }
+
+                    n.values_lists
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.coltypes
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.coltypmods
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.colcollations
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.alias.is_some() {
+                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
+                    }
+
+                    if n.eref.is_some() {
+                        handle_child(NodeEnum::Alias(n.eref.to_owned().unwrap()));
+                    }
+
+                    n.security_quals
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RangeTblFunction(n) => {
+                    if n.funcexpr.is_some() {
+                        handle_child(n.funcexpr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.funccolnames
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.funccoltypes
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.funccoltypmods
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.funccolcollations
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::TableSampleClause(n) => {
+                    n.args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.repeatable.is_some() {
+                        handle_child(n.repeatable.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::WithCheckOption(n) => {
+                    if n.qual.is_some() {
+                        handle_child(n.qual.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::SortGroupClause(n) => (),
+                NodeEnum::GroupingSet(n) => {
+                    n.content
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::WindowClause(n) => {
+                    n.partition_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.order_clause
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.start_offset.is_some() {
+                        handle_child(n.start_offset.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.end_offset.is_some() {
+                        handle_child(n.end_offset.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.run_condition
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::ObjectWithArgs(n) => {
+                    n.objname
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.objargs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.objfuncargs
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AccessPriv(n) => {
+                    n.cols
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CreateOpClassItem(n) => {
+                    if n.name.is_some() {
+                        handle_child(NodeEnum::ObjectWithArgs(n.name.to_owned().unwrap()));
+                    }
+
+                    n.order_family
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.class_args
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.storedtype.is_some() {
+                        handle_child(NodeEnum::TypeName(n.storedtype.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::TableLikeClause(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::FunctionParameter(n) => {
+                    if n.arg_type.is_some() {
+                        handle_child(NodeEnum::TypeName(n.arg_type.to_owned().unwrap()));
+                    }
+
+                    if n.defexpr.is_some() {
+                        handle_child(n.defexpr.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::LockingClause(n) => {
+                    n.locked_rels
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RowMarkClause(n) => (),
+                NodeEnum::XmlSerialize(n) => {
+                    if n.expr.is_some() {
+                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.type_name.is_some() {
+                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::WithClause(n) => {
+                    n.ctes
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::InferClause(n) => {
+                    n.index_elems
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::OnConflictClause(n) => {
+                    if n.infer.is_some() {
+                        handle_child(NodeEnum::InferClause(n.infer.to_owned().unwrap()));
+                    }
+
+                    n.target_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CtesearchClause(n) => {
+                    n.search_col_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::CtecycleClause(n) => {
+                    n.cycle_col_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.cycle_mark_value.is_some() {
+                        handle_child(n.cycle_mark_value.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.cycle_mark_default.is_some() {
+                        handle_child(n.cycle_mark_default.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::CommonTableExpr(n) => {
+                    n.aliascolnames
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    if n.ctequery.is_some() {
+                        handle_child(n.ctequery.to_owned().unwrap().node.unwrap());
+                    }
+
+                    if n.search_clause.is_some() {
+                        handle_child(NodeEnum::CtesearchClause(
+                            n.search_clause.to_owned().unwrap(),
+                        ));
+                    }
+
+                    if n.cycle_clause.is_some() {
+                        handle_child(NodeEnum::CtecycleClause(n.cycle_clause.to_owned().unwrap()));
+                    }
+
+                    n.ctecolnames
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.ctecoltypes
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.ctecoltypmods
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.ctecolcollations
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::MergeWhenClause(n) => {
+                    if n.condition.is_some() {
+                        handle_child(n.condition.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.target_list
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.values
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::RoleSpec(n) => (),
+                NodeEnum::TriggerTransition(n) => (),
+                NodeEnum::PartitionElem(n) => {
+                    if n.expr.is_some() {
+                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.collation
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.opclass
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::PartitionSpec(n) => {
+                    n.part_params
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::PartitionBoundSpec(n) => {
+                    n.listdatums
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.lowerdatums
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                    n.upperdatums
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::PartitionRangeDatum(n) => {
+                    if n.value.is_some() {
+                        handle_child(n.value.to_owned().unwrap().node.unwrap());
+                    }
+                }
+                NodeEnum::PartitionCmd(n) => {
+                    if n.name.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.name.to_owned().unwrap()));
+                    }
+
+                    if n.bound.is_some() {
+                        handle_child(NodeEnum::PartitionBoundSpec(n.bound.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::VacuumRelation(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    n.va_cols
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::PublicationObjSpec(n) => {
+                    if n.pubtable.is_some() {
+                        handle_child(NodeEnum::PublicationTable(n.pubtable.to_owned().unwrap()));
+                    }
+                }
+                NodeEnum::PublicationTable(n) => {
+                    if n.relation.is_some() {
+                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
+                    }
+
+                    if n.where_clause.is_some() {
+                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
+                    }
+
+                    n.columns
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::InlineCodeBlock(n) => (),
+                NodeEnum::CallContext(n) => (),
+                NodeEnum::Integer(n) => (),
+                NodeEnum::Float(n) => (),
+                NodeEnum::Boolean(n) => (),
+                NodeEnum::String(n) => (),
+                NodeEnum::BitString(n) => (),
+                NodeEnum::List(n) => {
+                    n.items
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::IntList(n) => {
+                    n.items
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::OidList(n) => {
+                    n.items
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+                }
+                NodeEnum::AConst(n) => {
+                    if n.val.is_some() {
+                        handle_child(match n.val.to_owned().unwrap() {
+                            pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
+                            pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
+                            pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
+                            pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
+                            pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
+                        });
+                    }
+                }
+            };
+        } else if !location_stack.is_empty() {
+            let (node, depth, path) = location_stack.pop_front().unwrap();
+            let parent_location = nodes
+                .iter()
+                .find(|n| {
+                    let mut path_elements = path.split(".").collect::<Vec<&str>>();
+                    path_elements.pop();
+                    let parent_path = path_elements.join(".");
+                    n.path == parent_path
+                })
+                .unwrap()
+                .location;
+            let earliest_child_location = nodes
+                .iter()
+                .filter(|n| n.path.starts_with(path.as_str()))
+                .min_by(|a, b| a.location.cmp(&b.location))
+                .map(|n| n.location);
+            let location = derive_location(
+                &node,
+                text.clone(),
+                parent_location,
+                earliest_child_location,
+            );
+            println!(
+                "node: {:?}, depth: {}, path: {}, location: {}",
+                node, depth, path, location
+            );
+            nodes.push(NestedNode {
+                node,
+                depth,
+                location,
+                path: path.clone(),
+            });
+        }
     }
     nodes.sort_by_key(|n| n.location);
     nodes
diff --git a/crates/parser/src/pg_query_utils_generated_test.rs b/crates/parser/src/pg_query_utils_generated_test.rs
index 5883f357..d5270652 100644
--- a/crates/parser/src/pg_query_utils_generated_test.rs
+++ b/crates/parser/src/pg_query_utils_generated_test.rs
@@ -1,173 +1,26 @@
-use std::collections::VecDeque;
-
-use pg_query::{Node, NodeEnum};
-
-use crate::{pg_query_utils_generated::get_location, pg_query_utils_manual::derive_location};
-
-#[derive(Debug, Clone)]
-struct NestedNode {
-    node: NodeEnum,
-    depth: i32,
-    location: i32,
-    path: String,
-}
-
-// some nodes that do not have a loc property, but have the same loc as their only child, eg AConst
-// some nodes do not have a loc property, but have the same loc as their parent, e.g. AStar
-
-// Problem: we need to get the location of a node, but many do not have a location property.
-// 1. get children with location Option<i32>
-// 2. if get_location returns None
-//   a. call get children for node
-//   b. apply regexp on input after get location of parent
-//   c. if just one match, return its location. if more than one, return the one that is the first before the earliest child location.
-//
-// start with parent location 0. for this to work, we have to resolve the location of the parent
-// first.
-//
-// if select with list.
-// - select has parent, so i can get its location via regexp and parent location. --> wrong: we
-// dont have the children locations at this point
-// - then for children, i have parent, so both location and parent location are never None.
-//
-// add location_stack:
-// - if no location prop, add to location stack with an id / path. the stack must be lifo.
-// - nodes in stack have parent id / path. the id could be something like "1.2", where 1 is the parent of parent id,
-// and 2 is the direct parent id.
-// - when nodes are resolved, work on location stack before starting with nodes again
-// - get location of parent node
-// - get childs from nodes list (if i am id 1.2, get all nodes that start with 1.2) and get earliest location from them
-
-pub fn get_children_test(node: &NodeEnum, text: String, current_depth: i32) -> Vec<NestedNode> {
-    let mut nodes: Vec<NestedNode> = vec![];
-
-    // node, depth, parent_location, path
-    let mut stack: VecDeque<(NodeEnum, i32, String)> =
-        VecDeque::from(vec![(node.to_owned(), current_depth, "0".to_string())]);
-
-    // node, depth, path
-    let mut location_stack: VecDeque<(NodeEnum, i32, String)> = VecDeque::new();
-
-    while !stack.is_empty() || !location_stack.is_empty() {
-        if !stack.is_empty() {
-            let (node, depth, path) = stack.pop_front().unwrap();
-            let current_depth = depth + 1;
-            let mut child_ctr: i32 = 0;
-
-            let mut handle_child = |c: NodeEnum| {
-                let location = get_location(&c);
-                let path = path.clone() + "." + child_ctr.to_string().as_str();
-                child_ctr = child_ctr + 1;
-                stack.push_back((c.to_owned(), current_depth, path.clone()));
-                if location.is_some() {
-                    nodes.push(NestedNode {
-                        node: c,
-                        depth: current_depth,
-                        location: location.unwrap(),
-                        path: path.clone(),
-                    });
-                } else {
-                    location_stack.push_back((c, current_depth, path));
-                }
-            };
-
-            match &node {
-                NodeEnum::Alias(n) => {
-                    n.colnames
-                        .iter()
-                        .for_each(|n| handle_child(n.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RangeVar(n) => {
-                    if n.alias.is_some() {
-                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
-                    }
-                }
-                n => {
-                    println!("{:?}", n);
-                    todo!();
-                }
-            }
-        } else if !location_stack.is_empty() {
-            // then, start with the beginning. we now always have a location for a parent, and SHOULD HAVE at least one child location. to get childs, use "starts_with(my_path)".
-            // if no child, pass earliest_child_location = None
-            let (node, depth, path) = location_stack.pop_front().unwrap();
-            let parent_location = nodes
-                .iter()
-                .find(|n| {
-                    let mut path_elements = path.split(".").collect::<Vec<&str>>();
-                    path_elements.pop();
-                    let parent_path = path_elements.join(".");
-                    n.path == parent_path
-                })
-                .unwrap()
-                .location;
-            // get earliest child
-            let earliest_child_location = nodes
-                .iter()
-                .filter(|n| n.path.starts_with(path.as_str()))
-                .min_by(|a, b| a.location.cmp(&b.location))
-                .map(|n| n.location);
-            let location = derive_location(
-                &node,
-                text.clone(),
-                parent_location,
-                earliest_child_location,
-            );
-            nodes.push(NestedNode {
-                node,
-                depth,
-                location,
-                path: path.clone(),
-            });
-        }
-    }
-
-    nodes
-}
-
 #[cfg(test)]
 mod tests {
-    use std::assert_eq;
-    use std::fs;
-    use std::path::Path;
-
     use crate::pg_query_utils_generated::get_children;
-    // use crate::pg_query_utils_generated_test::get_children_test;
-
-    const VALID_STATEMENTS_PATH: &str = "test_data/statements/valid/";
 
     #[test]
     fn test_get_children() {
-        let input = "with c as (insert into contact (id) values ('id') select * from c;";
+        let input = "with c as (insert into contact (id) values ('id')) select * from c;";
 
         let pg_query_root = match pg_query::parse(input) {
-            Ok(parsed) => {
+            Ok(parsed) => Some(
                 parsed
                     .protobuf
                     .nodes()
                     .iter()
-                    .for_each(|n| println!("{:?}", n));
-                Some(
-                    parsed
-                        .protobuf
-                        .nodes()
-                        .iter()
-                        .find(|n| n.1 == 1)
-                        .unwrap()
-                        .0
-                        .to_enum(),
-                )
-            }
+                    .find(|n| n.1 == 1)
+                    .unwrap()
+                    .0
+                    .to_enum(),
+            ),
             Err(_) => None,
         };
 
-        println!("{:?}", pg_query_root);
-
-        let result = get_children(&pg_query_root.unwrap(), 1);
-        println!("NUMBER OF CHILDREN: {:?}", result.len());
-        result.iter().for_each(|n| {
-            println!("##");
-            println!("{:?}", n)
-        });
+        let children = get_children(&pg_query_root.unwrap(), input.to_string(), 1);
+        assert_eq!(children.len(), 13);
     }
 }
diff --git a/crates/parser/src/pg_query_utils_manual.rs b/crates/parser/src/pg_query_utils_manual.rs
index 60c2b8eb..bdf4a116 100644
--- a/crates/parser/src/pg_query_utils_manual.rs
+++ b/crates/parser/src/pg_query_utils_manual.rs
@@ -1,8 +1,8 @@
+use std::println;
+
 use pg_query::NodeEnum;
 use regex::Regex;
 
-use crate::pg_query_utils_generated::NestedNode;
-
 fn get_location_via_regexp(
     r: Regex,
     text: String,
@@ -14,42 +14,46 @@ fn get_location_via_regexp(
         distance: i32,
     }
 
-    let l = r
+    let location = r
         .find_iter(text.as_str())
         .filter_map(|x| {
-            if x.start() as i32 > parent_location {
+            if x.start() as i32 >= parent_location {
                 Some({
                     Location {
                         location: x.start() as i32,
-                        distance: earliest_child_location.unwrap() - x.start() as i32,
+                        distance: if earliest_child_location.is_some() {
+                            earliest_child_location.unwrap() - x.start() as i32
+                        } else {
+                            x.start() as i32 - parent_location
+                        },
                     }
                 })
             } else {
                 None
             }
         })
-        .min_by(|a, b| a.distance.cmp(&b.distance));
-    l.unwrap().location
+        .min_by_key(|x| x.distance.abs())
+        .unwrap()
+        .location;
+
+    // Sanity check to ensure that the location is valid
+    if earliest_child_location.is_some() && earliest_child_location.unwrap() < location {
+        panic!("Regex returned invalid location: Node cannot have a location < its children");
+    }
+
+    location
 }
 
 /// This is the only manual implementation required for the parser
 /// The problem this functions is attempting to solve is that not all nodes have a location property
-/// As of now, I have found three different cases:
-/// - The node location is easily derivable from the text, e.g. `delete from`
-/// - The node location is the same as its immediate parent node, e.g. `AStar`
-/// - The node location is the same as their only child, e.g. `AConst`
 ///
-/// Some nodes such as will be more complex `Alias` will require a special implementation
-///
-/// if no location, always append to location stack (no parent location, append to location stack children with no location need to be appended too)
-/// then, work on all other nodes
-/// then, start with the beginning. we now always have a location for a parent, and SHOULD HAVE at least one child location. to get childs, use "starts_with(my_path)".
-/// if no child, pass earliest_child_location = None
-///
-/// NOTE: to get path, just count on children of match arm in get_childen
+/// I suspect for most of the nodes, a simple regular expression will be sufficient
 pub fn derive_location(
+    // The node to derive the location for
     node: &NodeEnum,
+    // The full text of the query
     text: String,
+    // The location of the parent node
     parent_location: i32,
     // not given if node does not have any children
     earliest_child_location: Option<i32>,
@@ -122,7 +126,13 @@ pub fn derive_location(
         ),
         NodeEnum::UpdateStmt(_) => todo!(),
         NodeEnum::MergeStmt(_) => todo!(),
-        NodeEnum::SelectStmt(_) => todo!(),
+        NodeEnum::SelectStmt(_) => get_location_via_regexp(
+            // in "insert into contact (id) values (1)" the "values (1)" is a select statement
+            Regex::new(r"(?mi)select|values").unwrap(),
+            text,
+            parent_location,
+            earliest_child_location,
+        ),
         NodeEnum::ReturnStmt(_) => todo!(),
         NodeEnum::PlassignStmt(_) => panic!("Node has location property."),
         NodeEnum::AlterTableStmt(_) => todo!(),
@@ -239,7 +249,12 @@ pub fn derive_location(
         NodeEnum::ColumnRef(_) => panic!("Node has location property."),
         NodeEnum::ParamRef(_) => panic!("Node has location property."),
         NodeEnum::FuncCall(_) => panic!("Node has location property."),
-        NodeEnum::AStar(_) => todo!(),
+        NodeEnum::AStar(_) => get_location_via_regexp(
+            Regex::new(r"(?mi)\*").unwrap(),
+            text,
+            parent_location,
+            earliest_child_location,
+        ),
         NodeEnum::AIndices(_) => todo!(),
         NodeEnum::AIndirection(_) => todo!(),
         NodeEnum::AArrayExpr(_) => panic!("Node has location property."),
@@ -299,7 +314,12 @@ pub fn derive_location(
         NodeEnum::Boolean(_) => parent_location,
         NodeEnum::String(_) => parent_location,
         NodeEnum::BitString(_) => parent_location,
-        NodeEnum::List(_) => todo!(),
+        NodeEnum::List(_) => get_location_via_regexp(
+            Regex::new(r"(?mi)\((.*?)\)").unwrap(),
+            text,
+            parent_location,
+            earliest_child_location,
+        ),
         NodeEnum::IntList(_) => todo!(),
         NodeEnum::OidList(_) => todo!(),
         NodeEnum::AConst(_) => panic!("Node has location property."),
diff --git a/crates/sourcegen/src/struct_.rs b/crates/sourcegen/src/struct_.rs
index 382d5953..7a9700f6 100644
--- a/crates/sourcegen/src/struct_.rs
+++ b/crates/sourcegen/src/struct_.rs
@@ -4,6 +4,7 @@ use crate::builder::Builder;
 pub struct StructField {
     name: String,
     type_: String,
+    public: bool,
 }
 
 /// A builder for a rust Struct
@@ -31,7 +32,11 @@ impl Builder for Struct {
                 .iter()
                 .map(|field| {
                     let mut result = String::new();
-                    result.push_str("    ");
+                    if field.public {
+                        result.push_str("pub ");
+                    } else {
+                        result.push_str("    ");
+                    }
                     result.push_str(&field.name);
                     result.push_str(": ");
                     result.push_str(&field.type_);
@@ -61,8 +66,12 @@ impl Struct {
         self
     }
 
-    pub fn with_field(&mut self, name: String, type_: String) -> &mut Self {
-        self.fields.push(StructField { name, type_ });
+    pub fn with_field(&mut self, name: String, type_: String, public: bool) -> &mut Self {
+        self.fields.push(StructField {
+            name,
+            type_,
+            public,
+        });
         self
     }
 

From 321e9ea7c5edd06080fff66c4dad78f8b329ae1f Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Thu, 17 Aug 2023 18:26:38 +0200
Subject: [PATCH 08/23] fix: rewrite statement parser

---
 crates/parser/Cargo.toml                      |   2 +
 crates/parser/src/bin/generate.rs             |  13 +-
 crates/parser/src/lib.rs                      |   1 -
 crates/parser/src/pg_query_utils_generated.rs |   4 -
 crates/parser/src/statement.rs                | 303 ++++++++----------
 crates/parser/src/syntax_kind_generated.rs    |   4 +-
 6 files changed, 145 insertions(+), 182 deletions(-)

diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml
index 8b7b94a0..7aa76290 100644
--- a/crates/parser/Cargo.toml
+++ b/crates/parser/Cargo.toml
@@ -12,6 +12,8 @@ logos = "0.13.0"
 serde_json = "1.0"
 regex = "1.9.1"
 serde = { version = "1.0", features = ["derive"] }
+env_logger = { version = "0.9.1" }
+log = { version = "0.4.20" }
 
 sourcegen.workspace = true
 pg_query_proto_parser.workspace = true
diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
index 2e65f634..8255d118 100644
--- a/crates/parser/src/bin/generate.rs
+++ b/crates/parser/src/bin/generate.rs
@@ -268,7 +268,6 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
                 "Whitespace".to_string(),
                 "Newline".to_string(),
                 "Tab".to_string(),
-                "Word".to_string(),
                 "Stmt".to_string(),
             ].iter().for_each(|kind| {
                 b.with_value(kind.to_string(), None);
@@ -388,6 +387,18 @@ fn generate_syntax_kind(f: &ProtoFile) -> String {
                            value.to_string(),
                         );
                    });
+
+                    vec![
+                        "Whitespace".to_string(),
+                        "Newline".to_string(),
+                        "Tab".to_string(),
+                    ].iter().for_each(|kind| {
+                        b.with_arm(
+                            format!("SyntaxKind::{}", kind.to_string()),
+                            "Some(SyntaxKindType::Follow)".to_string()
+                        );
+                    });
+
                    b.with_arm(
                        "_".to_string(),
                        "None".to_string(),
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 83bd6795..2a9003e8 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -17,7 +17,6 @@
 
 mod ast_node;
 mod parser;
-mod pg_query_utils;
 mod pg_query_utils_generated;
 mod pg_query_utils_generated_test;
 mod pg_query_utils_manual;
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index d47a1341..01641441 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -2804,10 +2804,6 @@ pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<Ne
                 parent_location,
                 earliest_child_location,
             );
-            println!(
-                "node: {:?}, depth: {}, path: {}, location: {}",
-                node, depth, path, location
-            );
             nodes.push(NestedNode {
                 node,
                 depth,
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 31f2b854..51722252 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -1,5 +1,5 @@
 use cstree::text::{TextRange, TextSize};
-use logos::Logos;
+use logos::{Logos, Span};
 use regex::Regex;
 
 use crate::{
@@ -55,12 +55,7 @@ pub enum StatementToken {
     Ascii93,
     #[token("^")]
     Ascii94,
-    // comments, whitespaces and keywords
-    // FIXME: nexted and named dollar quoted strings do not work yet
-    #[regex("'([^']+)'|\\$(\\w)?\\$.*\\$(\\w)?\\$")]
-    Sconst,
-    #[regex("(\\w+)"gm)]
-    Word,
+    // comments and whitespaces
     #[regex(" +"gm)]
     Whitespace,
     #[regex("\n+"gm)]
@@ -95,11 +90,9 @@ impl StatementToken {
             StatementToken::Ascii92 => SyntaxKind::Ascii92,
             StatementToken::Ascii93 => SyntaxKind::Ascii93,
             StatementToken::Ascii94 => SyntaxKind::Ascii94,
-            StatementToken::Word => SyntaxKind::Word,
             StatementToken::Whitespace => SyntaxKind::Whitespace,
             StatementToken::Newline => SyntaxKind::Newline,
             StatementToken::Tab => SyntaxKind::Tab,
-            StatementToken::Sconst => SyntaxKind::Sconst,
             StatementToken::Comment => SyntaxKind::Comment,
             _ => panic!("Unknown StatementToken: {:?}", self),
         }
@@ -157,170 +150,153 @@ impl Parser {
             }
         };
 
-        // let pg_query_children;
-        // if pg_query_root.is_some() {
-        //     let children = get_children(&pg_query_root.unwrap(), 1);
-        //     children.sort_by(|a, b| get_location(a).cmp(get_children(b)));
-        // } else {
-        //     pg_query_children = Vec::new().iter().peekable();
-        // };
-
-        //
-        //     // let mut pg_query_nodes = match parsed {
-        //     //     Ok(parsed) => {
-        //     //         proto = parsed.protobuf;
-        //     //
-        //     //         nodes = proto.nodes();
-        //     //
-        //     //         nodes.sort_by(|a, b| {
-        //     //             get_position_for_pg_query_node(&a.0).cmp(&get_position_for_pg_query_node(&b.0))
-        //     //         });
-        //     //
-        //     //         nodes.into_iter().peekable()
-        //     //     }
-        //     //     Err(e) => {
-        //     //         self.error(e.to_string(), range);
-        //     //         Vec::new().into_iter().peekable()
-        //     //     }
-        //     // };
-        //
-        //     TOD: return depth from get_children()
-        //
-        //     let mut lexer = StatementToken::lexer(&text);
-        //
-        //     // parse root node if no syntax errors
-        //     if pg_query_root.is_some() {
-        //         let root_node = pg_query_root.unwrap();
-        //         self.stmt(root_node, range);
-        //         self.start_node_at(SyntaxKind::new_from_pg_query_node(&root_node), Some(1));
-        //         // if there is only one node, there are no children, and we do not need to buffer the
-        //         // tokens. this happens for example with create or alter function statements.
-        //         self.set_checkpoint(pg_query_children.len() == 0);
-        //     } else {
-        //         // fallback to generic node as root
-        //         self.start_node_at(SyntaxKind::Stmt, None);
-        //         self.set_checkpoint(true);
-        //     }
-        //
-        //     // FIXME: the lexer, for some reason, does not parse dollar quoted string
-        //     // so we check if the error is one
-        //     while let Some(token) = lexer.next() {
-        //         let t: Option<StatementToken> = match token {
-        //             Ok(token) => Some(token),
-        //             Err(_) => {
-        //                 if Regex::new("'([^']+)'|\\$(\\w)?\\$.*\\$(\\w)?\\$")
-        //                     .unwrap()
-        //                     .is_match_at(lexer.slice(), 0)
-        //                 {
-        //                     Some(StatementToken::Sconst)
-        //                 } else {
-        //                     None
-        //                 }
-        //             }
-        //         };
-        //
-        //         match t {
-        //             Some(token) => {
-        //                 let span = lexer.span();
-        //
-        //                 // consume pg_query nodes until there is none, or the node is outside of the current text span
-        //                 while let Some(node) = pg_query_children.peek() {
-        //                     let pos = get_location(&node);
-        //                     if span.contains(&usize::try_from(pos.unwrap()).unwrap()) == false {
-        //                         break;
-        //                     } else {
-        //                         // node is within span
-        //                         // let (node, depth, _) = pg_query_children.next().unwrap();
-        //                         // self.start_node_at(SyntaxKind::from_pg_query_node(&node), Some(depth));
-        //                     }
-        //                 }
-        //
-        //                 // consume pg_query token if it is within the current text span
-        //                 let next_pg_query_token = pg_query_tokens.peek();
-        //                 if next_pg_query_token.is_some()
-        //                     && (span.contains(
-        //                         &usize::try_from(next_pg_query_token.unwrap().start).unwrap(),
-        //                     ) || span
-        //                         .contains(&usize::try_from(next_pg_query_token.unwrap().end).unwrap()))
-        //                 {
-        //                     // TODO: if within function declaration and current token is Sconst, its
-        //                     // the function body. it should be passed into parse_source_file.
-        //                     // self.token(
-        //                     //     SyntaxKind::from_pg_query_token(&pg_query_tokens.next().unwrap()),
-        //                     //     lexer.slice(),
-        //                     // );
-        //                 } else {
-        //                     // fallback to statement token
-        //                     self.token(token.syntax_kind(), lexer.slice());
-        //                 }
-        //             }
-        //             None => panic!("Unknown StatementToken: {:?}", lexer.slice()),
-        //         }
-        //     }
-        //
-        //     // close up nodes
-        //     self.close_checkpoint();
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-    use std::fs;
-    use std::path::Path;
-
-    use super::*;
+        let mut pg_query_nodes = match &pg_query_root {
+            Some(root) => get_children(root, text.to_string(), 1)
+                .into_iter()
+                .peekable(),
+            None => Vec::new().into_iter().peekable(),
+        };
 
-    const VALID_STATEMENTS_PATH: &str = "test_data/statements/valid/";
+        let mut lexer = StatementToken::lexer(&text);
+
+        // parse root node if no syntax errors
+        if pg_query_root.is_some() {
+            let root_node = pg_query_root.unwrap();
+            self.stmt(root_node.to_owned(), range);
+            self.start_node_at(SyntaxKind::new_from_pg_query_node(&root_node), Some(1));
+            // if there is only one node, there are no children, and we do not need to buffer the tokens.
+            self.set_checkpoint(pg_query_nodes.len() == 0);
+        } else {
+            // fallback to generic node as root
+            self.start_node_at(SyntaxKind::Stmt, None);
+            self.set_checkpoint(true);
+        }
 
-    #[test]
-    fn test_statement_lexer() {
-        let input = "select * from contact where id = '123 4 5';";
+        // todo: change this to manually moving along
+        // start at 0, and increment by the length of the token
 
-        let mut lex = StatementToken::lexer(&input);
+        let mut pointer: i32 = 0;
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Word)));
-        assert_eq!(lex.slice(), "select");
+        #[derive(Debug)]
+        struct Token {
+            syntax_kind: SyntaxKind,
+            span: Span,
+        }
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Whitespace)));
+        while pointer < text.len() as i32 {
+            // first get token WITHOUT applying it
+            // then consume pg_query nodes until there is none, or the node is outside of the current tokens' span
+
+            // Check if the pointer is within a pg_query token
+            let next_pg_query_token = pg_query_tokens.peek();
+            let token = if next_pg_query_token.is_some()
+                && next_pg_query_token.unwrap().start <= pointer
+                && pointer <= next_pg_query_token.unwrap().end
+            {
+                let token = pg_query_tokens.next().unwrap();
+                Token {
+                    syntax_kind: SyntaxKind::new_from_pg_query_token(&token),
+                    span: Span {
+                        start: token.start as usize,
+                        end: token.end as usize,
+                    },
+                }
+            } else {
+                // fallback to statement token
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Ascii42)));
+                // move statement token lexer to before pointer
+                while (lexer.span().end as i32) < pointer {
+                    lexer.next();
+                }
+                let token = lexer.next();
+                if token.is_none() || (lexer.span().start as i32) != pointer {
+                    // if the token is not at the pointer, we have a syntax error
+                    panic!(
+                        "Expected token for '{}' at offset {}",
+                        lexer.slice(),
+                        lexer.span().start
+                    );
+                }
+                Token {
+                    syntax_kind: token.unwrap().unwrap().syntax_kind(),
+                    span: lexer.span(),
+                }
+            };
+
+            // consume pg_query nodes until there is none, or the node is outside of the current text span
+            while let Some(node) = pg_query_nodes.peek() {
+                if token
+                    .span
+                    .contains(&usize::try_from(node.location).unwrap())
+                    == false
+                {
+                    break;
+                } else {
+                    // node is within span
+                    let nested_node = pg_query_nodes.next().unwrap();
+                    self.start_node_at(
+                        SyntaxKind::new_from_pg_query_node(&nested_node.node),
+                        Some(nested_node.depth),
+                    );
+                }
+            }
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Whitespace)));
+            self.token(
+                token.syntax_kind,
+                text.chars()
+                    .skip(token.span.start)
+                    .take(token.span.end - token.span.start)
+                    .collect::<String>()
+                    .as_str(),
+            );
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Word)));
-        assert_eq!(lex.slice(), "from");
+            pointer = pointer + (token.span.end - token.span.start) as i32;
+        }
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Whitespace)));
+        // close up nodes
+        self.close_checkpoint();
+    }
+}
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Word)));
-        assert_eq!(lex.slice(), "contact");
+#[cfg(test)]
+mod tests {
+    use log::info;
+    use std::assert_eq;
+    use std::fs;
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Whitespace)));
+    use super::*;
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Word)));
-        assert_eq!(lex.slice(), "where");
+    const VALID_STATEMENTS_PATH: &str = "test_data/statements/valid/";
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Whitespace)));
+    fn init() {
+        let _ = env_logger::builder().is_test(true).try_init();
+    }
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Word)));
-        assert_eq!(lex.slice(), "id");
+    fn test_valid_stmt(input: String) {
+        info!("Testing: {}", input);
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Whitespace)));
+        let mut parser = Parser::new();
+        parser.parse_statement(&input, None);
+        let parsed = parser.finish();
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Ascii61)));
+        let fail = parsed.cst.text() != input.as_str();
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Whitespace)));
+        if fail == true {
+            dbg!(&parsed.cst);
+        }
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Sconst)));
+        assert_eq!(parsed.cst.text(), input.as_str())
+    }
 
-        assert_eq!(lex.next(), Some(Ok(StatementToken::Ascii59)));
+    #[test]
+    fn test_simple_statement() {
+        init();
+        test_valid_stmt("select 1;".to_string());
     }
 
     #[test]
     fn test_valid_statements() {
-        let p = Path::new(VALID_STATEMENTS_PATH);
-        println!("path: {:?}", p.display());
+        init();
         fs::read_dir(VALID_STATEMENTS_PATH)
             .unwrap()
             .into_iter()
@@ -329,32 +305,9 @@ mod tests {
 
                 let contents = fs::read_to_string(&path).unwrap();
 
-                println!("testing {}:\n'{}'", path.display(), contents);
-
-                let mut parser = Parser::new();
-                parser.parse_statement(&contents, None);
-                let parsed = parser.finish();
-
-                let fail = parsed.cst.text() != contents.as_str();
-
-                if fail == true {
-                    dbg!(&parsed.cst);
-                    let parsed = pg_query::parse(contents.as_str());
-                    match parsed {
-                        Ok(n) => {
-                            let proto = n.protobuf;
-                            proto.nodes().iter().for_each(|node| {
-                                println!("####");
-                                println!("{:?}", node);
-                            });
-                        }
-                        Err(e) => {
-                            dbg!(e);
-                        }
-                    }
-                }
+                info!("Testing {}:\n'{}'", path.display(), contents);
 
-                assert_eq!(parsed.cst.text(), contents.as_str())
+                test_valid_stmt(contents);
             });
     }
 
diff --git a/crates/parser/src/syntax_kind_generated.rs b/crates/parser/src/syntax_kind_generated.rs
index 58cc8494..028a59c8 100644
--- a/crates/parser/src/syntax_kind_generated.rs
+++ b/crates/parser/src/syntax_kind_generated.rs
@@ -16,7 +16,6 @@ pub enum SyntaxKind {
     Whitespace,
     Newline,
     Tab,
-    Word,
     Stmt,
     Alias,
     RangeVar,
@@ -2066,6 +2065,9 @@ impl SyntaxKind {
             SyntaxKind::ModePlpgsqlAssign2 => Some(SyntaxKindType::Follow),
             SyntaxKind::ModePlpgsqlAssign3 => Some(SyntaxKindType::Follow),
             SyntaxKind::Uminus => Some(SyntaxKindType::Follow),
+            SyntaxKind::Whitespace => Some(SyntaxKindType::Follow),
+            SyntaxKind::Newline => Some(SyntaxKindType::Follow),
+            SyntaxKind::Tab => Some(SyntaxKindType::Follow),
             _ => None,
         }
     }

From f52bf354b63c94d62f609e471e18fdf7ed62a2e4 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Thu, 17 Aug 2023 18:37:24 +0200
Subject: [PATCH 09/23] fix: fallback to parent_location 0 if no parent

---
 crates/parser/src/bin/generate.rs             |  9 ++++++--
 crates/parser/src/pg_query_utils_generated.rs | 21 ++++++++++---------
 crates/parser/src/statement.rs                |  9 ++++----
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
index 8255d118..8ab6f8ac 100644
--- a/crates/parser/src/bin/generate.rs
+++ b/crates/parser/src/bin/generate.rs
@@ -200,12 +200,17 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
 
                     content.push_str("} else if !location_stack.is_empty() {\n");
                     content.push_str("let (node, depth, path) = location_stack.pop_front().unwrap();\n");
-                    content.push_str("let parent_location = nodes.iter().find(|n| {\n");
+                    content.push_str("let parent_node = nodes.iter().find(|n| {\n");
                     content.push_str("let mut path_elements = path.split(\".\").collect::<Vec<&str>>();\n");
                     content.push_str("path_elements.pop();\n");
                     content.push_str("let parent_path = path_elements.join(\".\");\n");
                     content.push_str("n.path == parent_path\n");
-                    content.push_str("}).unwrap().location;\n");
+                    content.push_str("});\n");
+                    content.push_str("let parent_location = if parent_node.is_some() {\n");
+                    content.push_str("parent_node.unwrap().location\n");
+                    content.push_str("} else {\n");
+                    content.push_str("0\n");
+                    content.push_str("};\n");
                     content.push_str("let earliest_child_location = nodes.iter().filter(|n| n.path.starts_with(path.as_str())).min_by(|a, b| a.location.cmp(&b.location)).map(|n| n.location);\n");
                     content.push_str("let location = derive_location(&node, text.clone(), parent_location, earliest_child_location);\n");
                     content.push_str("nodes.push(NestedNode { node, depth, location, path: path.clone() });\n");
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index 01641441..f86a2dde 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -2783,16 +2783,17 @@ pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<Ne
             };
         } else if !location_stack.is_empty() {
             let (node, depth, path) = location_stack.pop_front().unwrap();
-            let parent_location = nodes
-                .iter()
-                .find(|n| {
-                    let mut path_elements = path.split(".").collect::<Vec<&str>>();
-                    path_elements.pop();
-                    let parent_path = path_elements.join(".");
-                    n.path == parent_path
-                })
-                .unwrap()
-                .location;
+            let parent_node = nodes.iter().find(|n| {
+                let mut path_elements = path.split(".").collect::<Vec<&str>>();
+                path_elements.pop();
+                let parent_path = path_elements.join(".");
+                n.path == parent_path
+            });
+            let parent_location = if parent_node.is_some() {
+                parent_node.unwrap().location
+            } else {
+                0
+            };
             let earliest_child_location = nodes
                 .iter()
                 .filter(|n| n.path.starts_with(path.as_str()))
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 51722252..2486d42f 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -260,7 +260,8 @@ impl Parser {
 
 #[cfg(test)]
 mod tests {
-    use log::info;
+    use log::log_enabled;
+    use log::{debug, info};
     use std::assert_eq;
     use std::fs;
 
@@ -279,9 +280,9 @@ mod tests {
         parser.parse_statement(&input, None);
         let parsed = parser.finish();
 
-        let fail = parsed.cst.text() != input.as_str();
+        debug!("parsed: {}", parsed.cst.text());
 
-        if fail == true {
+        if log_enabled!(log::Level::Debug) {
             dbg!(&parsed.cst);
         }
 
@@ -305,8 +306,6 @@ mod tests {
 
                 let contents = fs::read_to_string(&path).unwrap();
 
-                info!("Testing {}:\n'{}'", path.display(), contents);
-
                 test_valid_stmt(contents);
             });
     }

From 7ac68a0eb343cb58d1e09b06cc9097235dabcee5 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Thu, 24 Aug 2023 21:30:49 +0200
Subject: [PATCH 10/23] fix: add more control mechnisms to parser and fix more
 statement tests - token type is now manual - added sibling token to control
 opening / closing tokens

---
 crates/parser/src/bin/generate.rs             |    4 +-
 crates/parser/src/lib.rs                      |    2 +
 crates/parser/src/parser.rs                   |  149 +-
 crates/parser/src/pg_query_utils_generated.rs |   16 +-
 crates/parser/src/pg_query_utils_manual.rs    |   65 +-
 crates/parser/src/sibling_token.rs            |   31 +
 crates/parser/src/source_file.rs              |    6 +-
 crates/parser/src/statement.rs                |  105 +-
 crates/parser/src/syntax_kind.rs              | 2038 -----------------
 crates/parser/src/syntax_kind_generated.rs    |  551 -----
 crates/parser/src/token_type.rs               |   91 +
 11 files changed, 339 insertions(+), 2719 deletions(-)
 create mode 100644 crates/parser/src/sibling_token.rs
 delete mode 100644 crates/parser/src/syntax_kind.rs
 create mode 100644 crates/parser/src/token_type.rs

diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
index 8ab6f8ac..7badaa0f 100644
--- a/crates/parser/src/bin/generate.rs
+++ b/crates/parser/src/bin/generate.rs
@@ -213,7 +213,9 @@ fn generate_pg_query_utils(f: &ProtoFile) -> String {
                     content.push_str("};\n");
                     content.push_str("let earliest_child_location = nodes.iter().filter(|n| n.path.starts_with(path.as_str())).min_by(|a, b| a.location.cmp(&b.location)).map(|n| n.location);\n");
                     content.push_str("let location = derive_location(&node, text.clone(), parent_location, earliest_child_location);\n");
-                    content.push_str("nodes.push(NestedNode { node, depth, location, path: path.clone() });\n");
+                    content.push_str("if location.is_some() {\n");
+                    content.push_str("nodes.push(NestedNode { node, depth, location: location.unwrap(), path: path.clone() });\n");
+                    content.push_str("}\n");
                     content.push_str("}\n");
                     content.push_str("}\n");
 
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 2a9003e8..2ceaf8cd 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -20,11 +20,13 @@ mod parser;
 mod pg_query_utils_generated;
 mod pg_query_utils_generated_test;
 mod pg_query_utils_manual;
+mod sibling_token;
 mod source_file;
 mod statement;
 mod syntax_error;
 mod syntax_kind_generated;
 mod syntax_node;
+mod token_type;
 
 pub use crate::parser::{Parse, Parser};
 pub use crate::syntax_kind_generated::SyntaxKind;
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index 1902eacb..88c2bf34 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -1,11 +1,16 @@
+use std::collections::{HashMap, VecDeque};
+use std::ops::RangeBounds;
+
 use cstree::syntax::ResolvedNode;
 use cstree::{build::GreenNodeBuilder, text::TextRange};
+use log::debug;
 use pg_query::NodeEnum;
 
 use crate::ast_node::RawStmt;
 use crate::syntax_error::SyntaxError;
-use crate::syntax_kind_generated::{SyntaxKind, SyntaxKindType};
+use crate::syntax_kind_generated::SyntaxKind;
 use crate::syntax_node::SyntaxNode;
+use crate::token_type::TokenType;
 
 /// Main parser that controls the cst building process, and collects errors and statements
 #[derive(Debug)]
@@ -13,9 +18,7 @@ pub struct Parser {
     /// The cst builder
     inner: GreenNodeBuilder<'static, 'static, SyntaxKind>,
     /// A buffer for tokens that are not yet applied to the cst
-    token_buffer: Vec<(SyntaxKind, String)>,
-    /// The current depth of the cst
-    curr_depth: i32,
+    token_buffer: VecDeque<(SyntaxKind, String)>,
     /// The syntax errors accumulated during parsing
     errors: Vec<SyntaxError>,
     /// The pg_query statements representing the abtract syntax tree
@@ -24,6 +27,12 @@ pub struct Parser {
     checkpoint: Option<i32>,
     /// Whether the parser is currently parsing a flat node
     is_parsing_flat_node: bool,
+    /// Keeps track of currently open nodes
+    /// Latest opened is last
+    open_nodes: Vec<(SyntaxKind, i32)>,
+    /// Keeps track of currently open tokens (e.g. "(")
+    /// Latest opened is last
+    open_tokens: Vec<(SyntaxKind, String, i32)>,
 }
 
 /// Result of parsing
@@ -40,24 +49,39 @@ pub struct Parse {
 impl Parser {
     pub fn new() -> Self {
         Self {
-            curr_depth: -1,
             inner: GreenNodeBuilder::new(),
-            token_buffer: Vec::new(),
+            token_buffer: VecDeque::new(),
             errors: Vec::new(),
             stmts: Vec::new(),
             checkpoint: None,
             is_parsing_flat_node: false,
+            open_nodes: Vec::new(),
+            open_tokens: Vec::new(),
         }
     }
 
     /// close all nodes until the specified depth is reached
     pub fn close_until_depth(&mut self, depth: i32) {
-        while self.curr_depth >= depth {
+        if self.open_nodes.is_empty() || self.get_current_depth() < depth {
+            return;
+        }
+        debug!(
+            "close from depth {:?} until {:?}",
+            self.get_current_depth(),
+            depth
+        );
+        loop {
+            if self.open_nodes.is_empty() || self.get_current_depth() < depth {
+                break;
+            }
             self.finish_node();
-            self.curr_depth -= 1;
         }
     }
 
+    fn get_current_depth(&self) -> i32 {
+        self.open_nodes[self.open_nodes.len() - 1].1
+    }
+
     /// set a checkpoint at current depth
     ///
     /// if `is_parsing_flat_node` is true, all tokens parsed until this checkpoint is closed will be applied immediately
@@ -70,13 +94,13 @@ impl Parser {
             self.token_buffer.is_empty(),
             "Token buffer must be empty before setting a checkpoint"
         );
-        self.checkpoint = Some(self.curr_depth);
+        self.checkpoint = Some(self.get_current_depth());
         self.is_parsing_flat_node = is_parsing_flat_node;
     }
 
     /// close all nodes until checkpoint depth is reached
     pub fn close_checkpoint(&mut self) {
-        self.consume_token_buffer();
+        self.consume_token_buffer(None);
         if self.checkpoint.is_some() {
             self.close_until_depth(self.checkpoint.unwrap());
         }
@@ -84,62 +108,125 @@ impl Parser {
         self.is_parsing_flat_node = false;
     }
 
-    /// start a new node of `SyntaxKind`
-    pub fn start_node(&mut self, kind: SyntaxKind) {
-        self.inner.start_node(kind);
-    }
-
     /// start a new node of `SyntaxKind` at `depth`
     /// handles closing previous nodes if necessary
     /// and consumes token buffer before starting new node
-    pub fn start_node_at(&mut self, kind: SyntaxKind, depth: Option<i32>) {
-        let depth = depth.unwrap_or(self.curr_depth + 1);
+    pub fn start_node_at(&mut self, kind: SyntaxKind, depth: i32) {
+        debug!("start node {:?} at depth: {:?}", kind, depth);
         // close until target depth
         self.close_until_depth(depth);
 
-        self.consume_token_buffer();
+        self.consume_token_buffer(None);
+
+        self.open_nodes.push((kind, depth));
+        self.inner.start_node(kind);
+    }
+
+    /// Applies closing sibling for open tokens at current depth
+    ///
+    /// FIXME: find closing token in token buffer, instead of just comparing with the first one
+    fn consume_open_tokens(&mut self) {
+        if self.open_tokens.is_empty() || self.token_buffer.is_empty() {
+            return;
+        }
+        let depth = self.get_current_depth();
+        debug!("close open tokens at depth: {:?}", depth);
+        loop {
+            if self.open_tokens.is_empty() || self.token_buffer.is_empty() {
+                break;
+            }
+            let (token, _, token_depth) = self.open_tokens[self.open_tokens.len() - 1];
+            if token_depth != depth {
+                break;
+            }
+            println!("token: {:?}", token);
+            println!("token_depth: {:?}", token_depth);
+            // find closing token in token buffer
+            let closing_token_pos = self
+                .token_buffer
+                .iter()
+                .position(|t| t.0 == token.sibling().unwrap());
+            if closing_token_pos.is_none() {
+                break;
+            }
+            let closing_token_pos = closing_token_pos.unwrap();
 
-        self.curr_depth = depth;
-        self.start_node(kind);
+            // drain token buffer until closing token inclusively
+            self.open_tokens.pop();
+            self.consume_token_buffer(Some((closing_token_pos + 1) as u32));
+        }
     }
 
     /// finish current node
+    /// applies all open tokens of current depth before
     pub fn finish_node(&mut self) {
+        self.consume_open_tokens();
+
+        let n = self.open_nodes.pop();
+        if n.is_none() {
+            panic!("No node to finish");
+        }
+
+        let (node, depth) = n.unwrap();
+        debug!("finish node {:?} at {:?}", node, depth);
         self.inner.finish_node();
     }
 
     /// Drains the token buffer and applies all tokens
-    pub fn consume_token_buffer(&mut self) {
-        for (kind, text) in self.token_buffer.drain(..) {
-            self.inner.token(kind, &text);
+    pub fn consume_token_buffer(&mut self, until: Option<u32>) {
+        if self.token_buffer.is_empty() {
+            return;
+        }
+        let range = match until {
+            Some(u) => 0..u as usize,
+            None => 0..self.token_buffer.len(),
+        };
+        debug!("consume token buffer {:?}", range);
+        for (kind, text) in self.token_buffer.drain(range).collect::<VecDeque<_>>() {
+            debug!("consuming token: {:?} {:?}", kind, text);
+            self.apply_token(kind, text.as_str());
+        }
+    }
+
+    /// Applies token immediately
+    /// if token is opening sibling, adds it to open tokens
+    fn apply_token(&mut self, kind: SyntaxKind, text: &str) {
+        self.inner.token(kind, text);
+        if kind.is_opening_sibling() {
+            let depth = self.get_current_depth();
+            debug!("open token {:?} at depth {:?}", kind, depth);
+            self.open_tokens.push((kind, text.to_string(), depth));
         }
     }
 
     /// applies token based on its `SyntaxKindType`
     /// if `SyntaxKindType::Close`, closes all nodes until depth 1
-    /// if `SyntaxKindType::Follow`, add token to buffer and wait until next node to apply token at same depth
+    /// if `SyntaxKindType::Follow`, add token to buffer and wait until next node or non-Follow token to apply token at same depth
     /// otherwise, applies token immediately
     ///
     /// if `is_parsing_flat_node` is true, applies token immediately
-    pub fn token(&mut self, kind: SyntaxKind, text: &str) {
+    pub fn token(&mut self, kind: SyntaxKind, text: &str, token_type: Option<TokenType>) {
         if self.is_parsing_flat_node {
             self.inner.token(kind, text);
             return;
         }
 
-        match kind.get_type() {
-            Some(SyntaxKindType::Close) => {
+        match token_type {
+            Some(TokenType::Close) => {
                 // move up to depth 2 and consume buffered tokens before applying closing token
                 self.close_until_depth(2);
-                self.consume_token_buffer();
+                self.consume_token_buffer(None);
                 self.inner.token(kind, text);
             }
-            Some(SyntaxKindType::Follow) => {
+            Some(TokenType::Follow) => {
+                debug!("push to buffer token {:?} {:?}", kind, text);
                 // wait until next node, and apply token at same depth
-                self.token_buffer.push((kind, text.to_string()));
+                self.token_buffer.push_back((kind, text.to_string()));
             }
             _ => {
-                self.inner.token(kind, text);
+                self.consume_token_buffer(None);
+                debug!("apply token {:?} {:?}", kind, text);
+                self.apply_token(kind, text);
             }
         }
     }
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index f86a2dde..a719be6e 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -176,7 +176,7 @@ pub fn get_location(node: &NodeEnum) -> Option<i32> {
         NodeEnum::AlterCollationStmt(_) => None,
         NodeEnum::CallStmt(_) => None,
         NodeEnum::AlterStatsStmt(_) => None,
-        NodeEnum::AExpr(n) => Some(n.location),
+        NodeEnum::AExpr(n) => get_location(&n.lexpr.as_ref().unwrap().node.as_ref().unwrap()),
         NodeEnum::ColumnRef(n) => Some(n.location),
         NodeEnum::ParamRef(n) => Some(n.location),
         NodeEnum::FuncCall(n) => Some(n.location),
@@ -2805,12 +2805,14 @@ pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<Ne
                 parent_location,
                 earliest_child_location,
             );
-            nodes.push(NestedNode {
-                node,
-                depth,
-                location,
-                path: path.clone(),
-            });
+            if location.is_some() {
+                nodes.push(NestedNode {
+                    node,
+                    depth,
+                    location: location.unwrap(),
+                    path: path.clone(),
+                });
+            }
         }
     }
     nodes.sort_by_key(|n| n.location);
diff --git a/crates/parser/src/pg_query_utils_manual.rs b/crates/parser/src/pg_query_utils_manual.rs
index bdf4a116..d86f1d2c 100644
--- a/crates/parser/src/pg_query_utils_manual.rs
+++ b/crates/parser/src/pg_query_utils_manual.rs
@@ -14,9 +14,15 @@ fn get_location_via_regexp(
         distance: i32,
     }
 
+    println!("regex: {:?}", r);
+    println!("earliest_child_location: {:?}", earliest_child_location);
+    println!("parent_location: {}", parent_location);
+    println!("text: {}", text);
+
     let location = r
         .find_iter(text.as_str())
         .filter_map(|x| {
+            println!("{:?}", x);
             if x.start() as i32 >= parent_location {
                 Some({
                     Location {
@@ -57,7 +63,7 @@ pub fn derive_location(
     parent_location: i32,
     // not given if node does not have any children
     earliest_child_location: Option<i32>,
-) -> i32 {
+) -> Option<i32> {
     match node {
         NodeEnum::Alias(_) => todo!(),
         NodeEnum::RangeVar(_) => panic!("Node has location property."),
@@ -112,31 +118,41 @@ pub fn derive_location(
         NodeEnum::MergeAction(_) => todo!(),
         NodeEnum::RawStmt(_) => todo!(),
         NodeEnum::Query(_) => todo!(),
-        NodeEnum::InsertStmt(_) => get_location_via_regexp(
-            Regex::new(r"(?mi)insert into").unwrap(),
+        NodeEnum::InsertStmt(_) => Some(get_location_via_regexp(
+            Regex::new(r"(?mi)insert\s+into").unwrap(),
             text,
             parent_location,
             earliest_child_location,
-        ),
-        NodeEnum::DeleteStmt(_) => get_location_via_regexp(
-            Regex::new(r"(?mi)delete from").unwrap(),
+        )),
+        NodeEnum::DeleteStmt(_) => Some(get_location_via_regexp(
+            Regex::new(r"(?mi)delete\s+from").unwrap(),
             text,
             parent_location,
             earliest_child_location,
-        ),
+        )),
         NodeEnum::UpdateStmt(_) => todo!(),
         NodeEnum::MergeStmt(_) => todo!(),
-        NodeEnum::SelectStmt(_) => get_location_via_regexp(
+        NodeEnum::SelectStmt(_) => Some(get_location_via_regexp(
             // in "insert into contact (id) values (1)" the "values (1)" is a select statement
             Regex::new(r"(?mi)select|values").unwrap(),
             text,
             parent_location,
             earliest_child_location,
-        ),
+        )),
         NodeEnum::ReturnStmt(_) => todo!(),
         NodeEnum::PlassignStmt(_) => panic!("Node has location property."),
-        NodeEnum::AlterTableStmt(_) => todo!(),
-        NodeEnum::AlterTableCmd(_) => todo!(),
+        NodeEnum::AlterTableStmt(_) => Some(get_location_via_regexp(
+            Regex::new(r"(?mi)alter\s+table").unwrap(),
+            text,
+            parent_location,
+            earliest_child_location,
+        )),
+        NodeEnum::AlterTableCmd(n) => Some(get_location_via_regexp(
+            Regex::new(format!("(?mi)alter.*{}", n.name).as_str()).unwrap(),
+            text,
+            parent_location,
+            earliest_child_location,
+        )),
         NodeEnum::AlterDomainStmt(_) => todo!(),
         NodeEnum::SetOperationStmt(_) => todo!(),
         NodeEnum::GrantStmt(_) => todo!(),
@@ -249,12 +265,12 @@ pub fn derive_location(
         NodeEnum::ColumnRef(_) => panic!("Node has location property."),
         NodeEnum::ParamRef(_) => panic!("Node has location property."),
         NodeEnum::FuncCall(_) => panic!("Node has location property."),
-        NodeEnum::AStar(_) => get_location_via_regexp(
+        NodeEnum::AStar(_) => Some(get_location_via_regexp(
             Regex::new(r"(?mi)\*").unwrap(),
             text,
             parent_location,
             earliest_child_location,
-        ),
+        )),
         NodeEnum::AIndices(_) => todo!(),
         NodeEnum::AIndirection(_) => todo!(),
         NodeEnum::AArrayExpr(_) => panic!("Node has location property."),
@@ -283,7 +299,12 @@ pub fn derive_location(
         NodeEnum::GroupingSet(_) => panic!("Node has location property."),
         NodeEnum::WindowClause(_) => todo!(),
         NodeEnum::ObjectWithArgs(_) => todo!(),
-        NodeEnum::AccessPriv(_) => todo!(),
+        NodeEnum::AccessPriv(n) => Some(get_location_via_regexp(
+            Regex::new(format!("(?mi){}", n.priv_name).as_str()).unwrap(),
+            text,
+            parent_location,
+            earliest_child_location,
+        )),
         NodeEnum::CreateOpClassItem(_) => todo!(),
         NodeEnum::TableLikeClause(_) => todo!(),
         NodeEnum::FunctionParameter(_) => todo!(),
@@ -309,17 +330,17 @@ pub fn derive_location(
         NodeEnum::PublicationTable(_) => todo!(),
         NodeEnum::InlineCodeBlock(_) => todo!(),
         NodeEnum::CallContext(_) => todo!(),
-        NodeEnum::Integer(_) => parent_location,
-        NodeEnum::Float(_) => parent_location,
-        NodeEnum::Boolean(_) => parent_location,
-        NodeEnum::String(_) => parent_location,
-        NodeEnum::BitString(_) => parent_location,
-        NodeEnum::List(_) => get_location_via_regexp(
+        NodeEnum::Integer(_) => None,
+        NodeEnum::Float(_) => None,
+        NodeEnum::Boolean(_) => None,
+        NodeEnum::String(n) => None,
+        NodeEnum::BitString(_) => None,
+        NodeEnum::List(_) => Some(get_location_via_regexp(
             Regex::new(r"(?mi)\((.*?)\)").unwrap(),
             text,
             parent_location,
             earliest_child_location,
-        ),
+        )),
         NodeEnum::IntList(_) => todo!(),
         NodeEnum::OidList(_) => todo!(),
         NodeEnum::AConst(_) => panic!("Node has location property."),
@@ -376,6 +397,6 @@ mod tests {
             Some(23),
         );
 
-        assert_eq!(l, 11);
+        assert_eq!(l, Some(11));
     }
 }
diff --git a/crates/parser/src/sibling_token.rs b/crates/parser/src/sibling_token.rs
new file mode 100644
index 00000000..e1875534
--- /dev/null
+++ b/crates/parser/src/sibling_token.rs
@@ -0,0 +1,31 @@
+use crate::SyntaxKind;
+
+impl SyntaxKind {
+    pub fn is_opening_sibling(&self) -> bool {
+        match self {
+            SyntaxKind::Ascii40 => true,
+            SyntaxKind::Ascii91 => true,
+            SyntaxKind::Case => true,
+            _ => false,
+        }
+    }
+    pub fn is_closing_sibling(&self) -> bool {
+        match self {
+            SyntaxKind::Ascii41 => true,
+            SyntaxKind::Ascii93 => true,
+            SyntaxKind::EndP => true,
+            _ => false,
+        }
+    }
+    pub fn sibling(&self) -> Option<SyntaxKind> {
+        match self {
+            SyntaxKind::Case => Some(SyntaxKind::EndP),
+            SyntaxKind::EndP => Some(SyntaxKind::Case),
+            SyntaxKind::Ascii40 => Some(SyntaxKind::Ascii41),
+            SyntaxKind::Ascii41 => Some(SyntaxKind::Ascii40),
+            SyntaxKind::Ascii91 => Some(SyntaxKind::Ascii93),
+            SyntaxKind::Ascii93 => Some(SyntaxKind::Ascii91),
+            _ => None,
+        }
+    }
+}
diff --git a/crates/parser/src/source_file.rs b/crates/parser/src/source_file.rs
index 16827eaf..556c43e6 100644
--- a/crates/parser/src/source_file.rs
+++ b/crates/parser/src/source_file.rs
@@ -28,16 +28,16 @@ impl Parser {
     pub fn parse_source_file(&mut self, text: &str) {
         let mut lexer = SourceFileToken::lexer(text);
 
-        self.start_node_at(SyntaxKind::SourceFile, Some(0));
+        self.start_node_at(SyntaxKind::SourceFile, 0);
         while let Some(token) = lexer.next() {
             match token {
                 Ok(token) => {
                     match token {
                         SourceFileToken::Comment => {
-                            self.token(SyntaxKind::Comment, lexer.slice());
+                            self.token(SyntaxKind::Comment, lexer.slice(), None);
                         }
                         SourceFileToken::Newline => {
-                            self.token(SyntaxKind::Newline, lexer.slice());
+                            self.token(SyntaxKind::Newline, lexer.slice(), None);
                         }
                         SourceFileToken::Statement => {
                             self.parse_statement(lexer.slice(), Some(lexer.span().start as u32));
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 2486d42f..afd5392b 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -1,12 +1,14 @@
 use cstree::text::{TextRange, TextSize};
+use log::{debug, log_enabled};
 use logos::{Logos, Span};
-use regex::Regex;
 
 use crate::{
     parser::Parser,
-    pg_query_utils_generated::{get_children, get_location},
-    // pg_query_utils::{get_location, get_nested_nodes},
+    pg_query_utils_generated::get_children,
     syntax_kind_generated::SyntaxKind,
+    token_type::{
+        get_token_type_from_pg_query_token, get_token_type_from_statement_token, TokenType,
+    },
 };
 
 /// A super simple lexer for sql statements.
@@ -16,45 +18,6 @@ use crate::{
 /// does not know anything about postgres syntax or keywords. For example, all words such as `select` and `from` are put into the `Word` type.
 #[derive(Logos, Debug, PartialEq)]
 pub enum StatementToken {
-    // copied from protobuf::Token. can be generated later
-    #[token("%")]
-    Ascii37,
-    #[token("(")]
-    Ascii40,
-    #[token(")")]
-    Ascii41,
-    #[token("*")]
-    Ascii42,
-    #[token("+")]
-    Ascii43,
-    #[token(",")]
-    Ascii44,
-    #[token("-")]
-    Ascii45,
-    #[token(".")]
-    Ascii46,
-    #[token("/")]
-    Ascii47,
-    #[token(":")]
-    Ascii58,
-    #[token(";")]
-    Ascii59,
-    #[token("<")]
-    Ascii60,
-    #[token("=")]
-    Ascii61,
-    #[token(">")]
-    Ascii62,
-    #[token("?")]
-    Ascii63,
-    #[token("[")]
-    Ascii91,
-    #[token("\\")]
-    Ascii92,
-    #[token("]")]
-    Ascii93,
-    #[token("^")]
-    Ascii94,
     // comments and whitespaces
     #[regex(" +"gm)]
     Whitespace,
@@ -71,25 +34,6 @@ impl StatementToken {
     /// can be generated.
     pub fn syntax_kind(&self) -> SyntaxKind {
         match self {
-            StatementToken::Ascii37 => SyntaxKind::Ascii37,
-            StatementToken::Ascii40 => SyntaxKind::Ascii40,
-            StatementToken::Ascii41 => SyntaxKind::Ascii41,
-            StatementToken::Ascii42 => SyntaxKind::Ascii42,
-            StatementToken::Ascii43 => SyntaxKind::Ascii43,
-            StatementToken::Ascii44 => SyntaxKind::Ascii44,
-            StatementToken::Ascii45 => SyntaxKind::Ascii45,
-            StatementToken::Ascii46 => SyntaxKind::Ascii46,
-            StatementToken::Ascii47 => SyntaxKind::Ascii47,
-            StatementToken::Ascii58 => SyntaxKind::Ascii58,
-            StatementToken::Ascii59 => SyntaxKind::Ascii59,
-            StatementToken::Ascii60 => SyntaxKind::Ascii60,
-            StatementToken::Ascii61 => SyntaxKind::Ascii61,
-            StatementToken::Ascii62 => SyntaxKind::Ascii62,
-            StatementToken::Ascii63 => SyntaxKind::Ascii63,
-            StatementToken::Ascii91 => SyntaxKind::Ascii91,
-            StatementToken::Ascii92 => SyntaxKind::Ascii92,
-            StatementToken::Ascii93 => SyntaxKind::Ascii93,
-            StatementToken::Ascii94 => SyntaxKind::Ascii94,
             StatementToken::Whitespace => SyntaxKind::Whitespace,
             StatementToken::Newline => SyntaxKind::Newline,
             StatementToken::Tab => SyntaxKind::Tab,
@@ -150,6 +94,10 @@ impl Parser {
             }
         };
 
+        if log_enabled!(log::Level::Debug) {
+            debug!("pg_query_root: {:?}", pg_query_root);
+        }
+
         let mut pg_query_nodes = match &pg_query_root {
             Some(root) => get_children(root, text.to_string(), 1)
                 .into_iter()
@@ -157,30 +105,38 @@ impl Parser {
             None => Vec::new().into_iter().peekable(),
         };
 
+        if log_enabled!(log::Level::Debug) {
+            println!("# Children:\n");
+            &pg_query_nodes.to_owned().for_each(|n| {
+                debug!("{:?}\n", n);
+                // let s = text.split_at(n.location as usize);
+                // debug!("Text: {:?}\npg_query_node: {:?}\n", s.1, n)
+            });
+        }
+
         let mut lexer = StatementToken::lexer(&text);
 
         // parse root node if no syntax errors
         if pg_query_root.is_some() {
             let root_node = pg_query_root.unwrap();
             self.stmt(root_node.to_owned(), range);
-            self.start_node_at(SyntaxKind::new_from_pg_query_node(&root_node), Some(1));
+            self.start_node_at(SyntaxKind::new_from_pg_query_node(&root_node), 1);
             // if there is only one node, there are no children, and we do not need to buffer the tokens.
             self.set_checkpoint(pg_query_nodes.len() == 0);
         } else {
             // fallback to generic node as root
-            self.start_node_at(SyntaxKind::Stmt, None);
+            self.start_node_at(SyntaxKind::Stmt, 1);
             self.set_checkpoint(true);
         }
 
-        // todo: change this to manually moving along
         // start at 0, and increment by the length of the token
-
         let mut pointer: i32 = 0;
 
         #[derive(Debug)]
         struct Token {
             syntax_kind: SyntaxKind,
             span: Span,
+            token_type: Option<TokenType>,
         }
 
         while pointer < text.len() as i32 {
@@ -195,6 +151,7 @@ impl Parser {
             {
                 let token = pg_query_tokens.next().unwrap();
                 Token {
+                    token_type: get_token_type_from_pg_query_token(&token),
                     syntax_kind: SyntaxKind::new_from_pg_query_token(&token),
                     span: Span {
                         start: token.start as usize,
@@ -218,6 +175,9 @@ impl Parser {
                     );
                 }
                 Token {
+                    token_type: get_token_type_from_statement_token(
+                        &token.as_ref().unwrap().as_ref().unwrap(),
+                    ),
                     syntax_kind: token.unwrap().unwrap().syntax_kind(),
                     span: lexer.span(),
                 }
@@ -236,7 +196,7 @@ impl Parser {
                     let nested_node = pg_query_nodes.next().unwrap();
                     self.start_node_at(
                         SyntaxKind::new_from_pg_query_node(&nested_node.node),
-                        Some(nested_node.depth),
+                        nested_node.depth,
                     );
                 }
             }
@@ -248,6 +208,7 @@ impl Parser {
                     .take(token.span.end - token.span.start)
                     .collect::<String>()
                     .as_str(),
+                token.token_type,
             );
 
             pointer = pointer + (token.span.end - token.span.start) as i32;
@@ -295,6 +256,18 @@ mod tests {
         test_valid_stmt("select 1;".to_string());
     }
 
+    #[test]
+    fn test_temp() {
+        init();
+        let token = pg_query::scan(
+            "select coalesce(id, two) as id from contact;"
+                .to_string()
+                .as_str(),
+        )
+        .unwrap();
+        dbg!(token);
+    }
+
     #[test]
     fn test_valid_statements() {
         init();
diff --git a/crates/parser/src/syntax_kind.rs b/crates/parser/src/syntax_kind.rs
deleted file mode 100644
index 90b87503..00000000
--- a/crates/parser/src/syntax_kind.rs
+++ /dev/null
@@ -1,2038 +0,0 @@
-//! This module bridges the gap between pg_query.rs nodes, and the `SyntaxKind` cstree requires.
-//! Most of the code here can be generated.
-
-use cstree::Syntax;
-use pg_query::{protobuf::ScanToken, NodeEnum, NodeRef};
-
-/// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres sql dialect, and a few custom ones
-/// that are not parsed by pg_query.rs, such as `Whitespace`.
-///
-/// Copied from pg_query.rs source code. Can be generated.
-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Syntax)]
-#[repr(u32)]
-pub enum SyntaxKind {
-    // custom nodes, which are not parsed by pg_query.rs
-    SourceFile,
-    Comment,
-    Whitespace,
-    Newline,
-    Tab,
-    /// common value for all keywords (select, from, ...)
-    Word,
-    /// node for unknown statements (e.g. when parsing fails)
-    Stmt,
-    // from here copyied from NodeEnum
-    Alias,
-    RangeVar,
-    TableFunc,
-    Expr,
-    Var,
-    Param,
-    Aggref,
-    GroupingFunc,
-    WindowFunc,
-    SubscriptingRef,
-    FuncExpr,
-    NamedArgExpr,
-    OpExpr,
-    DistinctExpr,
-    NullIfExpr,
-    ScalarArrayOpExpr,
-    BoolExpr,
-    SubLink,
-    SubPlan,
-    AlternativeSubPlan,
-    FieldSelect,
-    FieldStore,
-    RelabelType,
-    CoerceViaIo,
-    ArrayCoerceExpr,
-    ConvertRowtypeExpr,
-    CollateExpr,
-    CaseExpr,
-    CaseWhen,
-    CaseTestExpr,
-    ArrayExpr,
-    RowExpr,
-    RowCompareExpr,
-    CoalesceExpr,
-    MinMaxExpr,
-    SqlvalueFunction,
-    XmlExpr,
-    NullTest,
-    BooleanTest,
-    CoerceToDomain,
-    CoerceToDomainValue,
-    SetToDefault,
-    CurrentOfExpr,
-    NextValueExpr,
-    InferenceElem,
-    TargetEntry,
-    RangeTblRef,
-    JoinExpr,
-    FromExpr,
-    OnConflictExpr,
-    IntoClause,
-    RawStmt,
-    Query,
-    InsertStmt,
-    DeleteStmt,
-    UpdateStmt,
-    SelectStmt,
-    AlterTableStmt,
-    AlterTableCmd,
-    AlterDomainStmt,
-    SetOperationStmt,
-    GrantStmt,
-    GrantRoleStmt,
-    AlterDefaultPrivilegesStmt,
-    ClosePortalStmt,
-    ClusterStmt,
-    CopyStmt,
-    CreateStmt,
-    DefineStmt,
-    DropStmt,
-    TruncateStmt,
-    CommentStmt,
-    FetchStmt,
-    IndexStmt,
-    CreateFunctionStmt,
-    AlterFunctionStmt,
-    DoStmt,
-    RenameStmt,
-    RuleStmt,
-    NotifyStmt,
-    ListenStmt,
-    UnlistenStmt,
-    TransactionStmt,
-    ViewStmt,
-    LoadStmt,
-    CreateDomainStmt,
-    CreatedbStmt,
-    DropdbStmt,
-    VacuumStmt,
-    ExplainStmt,
-    CreateTableAsStmt,
-    CreateSeqStmt,
-    AlterSeqStmt,
-    VariableSetStmt,
-    VariableShowStmt,
-    DiscardStmt,
-    CreateTrigStmt,
-    CreatePlangStmt,
-    CreateRoleStmt,
-    AlterRoleStmt,
-    DropRoleStmt,
-    LockStmt,
-    ConstraintsSetStmt,
-    ReindexStmt,
-    CheckPointStmt,
-    CreateSchemaStmt,
-    AlterDatabaseStmt,
-    AlterDatabaseSetStmt,
-    AlterRoleSetStmt,
-    CreateConversionStmt,
-    CreateCastStmt,
-    CreateOpClassStmt,
-    CreateOpFamilyStmt,
-    AlterOpFamilyStmt,
-    PrepareStmt,
-    ExecuteStmt,
-    DeallocateStmt,
-    DeclareCursorStmt,
-    CreateTableSpaceStmt,
-    DropTableSpaceStmt,
-    AlterObjectDependsStmt,
-    AlterObjectSchemaStmt,
-    AlterOwnerStmt,
-    AlterOperatorStmt,
-    AlterTypeStmt,
-    DropOwnedStmt,
-    ReassignOwnedStmt,
-    CompositeTypeStmt,
-    CreateEnumStmt,
-    CreateRangeStmt,
-    AlterEnumStmt,
-    AlterTsdictionaryStmt,
-    AlterTsconfigurationStmt,
-    CreateFdwStmt,
-    AlterFdwStmt,
-    CreateForeignServerStmt,
-    AlterForeignServerStmt,
-    CreateUserMappingStmt,
-    AlterUserMappingStmt,
-    DropUserMappingStmt,
-    AlterTableSpaceOptionsStmt,
-    AlterTableMoveAllStmt,
-    SecLabelStmt,
-    CreateForeignTableStmt,
-    ImportForeignSchemaStmt,
-    CreateExtensionStmt,
-    AlterExtensionStmt,
-    AlterExtensionContentsStmt,
-    CreateEventTrigStmt,
-    AlterEventTrigStmt,
-    RefreshMatViewStmt,
-    ReplicaIdentityStmt,
-    AlterSystemStmt,
-    CreatePolicyStmt,
-    AlterPolicyStmt,
-    CreateTransformStmt,
-    CreateAmStmt,
-    CreatePublicationStmt,
-    AlterPublicationStmt,
-    CreateSubscriptionStmt,
-    AlterSubscriptionStmt,
-    DropSubscriptionStmt,
-    CreateStatsStmt,
-    AlterCollationStmt,
-    CallStmt,
-    AlterStatsStmt,
-    AExpr,
-    ColumnRef,
-    ParamRef,
-    AConst,
-    FuncCall,
-    AStar,
-    AIndices,
-    AIndirection,
-    AArrayExpr,
-    ResTarget,
-    MultiAssignRef,
-    TypeCast,
-    CollateClause,
-    SortBy,
-    WindowDef,
-    RangeSubselect,
-    RangeFunction,
-    RangeTableSample,
-    RangeTableFunc,
-    RangeTableFuncCol,
-    TypeName,
-    ColumnDef,
-    IndexElem,
-    Constraint,
-    DefElem,
-    RangeTblEntry,
-    RangeTblFunction,
-    TableSampleClause,
-    WithCheckOption,
-    SortGroupClause,
-    GroupingSet,
-    WindowClause,
-    ObjectWithArgs,
-    AccessPriv,
-    CreateOpClassItem,
-    TableLikeClause,
-    FunctionParameter,
-    LockingClause,
-    RowMarkClause,
-    XmlSerialize,
-    WithClause,
-    InferClause,
-    OnConflictClause,
-    CommonTableExpr,
-    RoleSpec,
-    TriggerTransition,
-    PartitionElem,
-    PartitionSpec,
-    PartitionBoundSpec,
-    PartitionRangeDatum,
-    PartitionCmd,
-    VacuumRelation,
-    InlineCodeBlock,
-    CallContext,
-    // Integer,
-    Float,
-    String,
-    BitString,
-    Null,
-    List,
-    IntList,
-    OidList,
-    // from here copied from protobuf::Token
-    Nul,
-    /// Single-character tokens that are returned 1:1 (identical with "self" list in scan.l)
-    /// Either supporting syntax, or single-character operators (some can be both)
-    /// Also see <https://www.postgresql.org/docs/12/sql-syntax-lexical.html#SQL-SYNTAX-SPECIAL-CHARS>
-    ///
-    /// "%"
-    Ascii37,
-    /// "("
-    Ascii40,
-    /// ")"
-    Ascii41,
-    /// "*"
-    Ascii42,
-    /// "+"
-    Ascii43,
-    /// ","
-    Ascii44,
-    /// "-"
-    Ascii45,
-    /// "."
-    Ascii46,
-    /// "/"
-    Ascii47,
-    /// ":"
-    Ascii58,
-    /// ";"
-    Ascii59,
-    /// "<"
-    Ascii60,
-    /// ",
-    Ascii61,
-    /// ">"
-    Ascii62,
-    /// "?"
-    Ascii63,
-    /// "["
-    Ascii91,
-    /// "\"
-    Ascii92,
-    /// "]"
-    Ascii93,
-    /// "^"
-    Ascii94,
-    /// Named tokens in scan.l
-    Ident,
-    Uident,
-    Fconst,
-    Sconst,
-    Usconst,
-    Bconst,
-    Xconst,
-    Op,
-    Iconst,
-    // Param,
-    Typecast,
-    DotDot,
-    ColonEquals,
-    EqualsGreater,
-    LessEquals,
-    GreaterEquals,
-    NotEquals,
-    SqlComment,
-    CComment,
-    AbortP,
-    AbsoluteP,
-    Access,
-    Action,
-    AddP,
-    Admin,
-    After,
-    Aggregate,
-    All,
-    Also,
-    Alter,
-    Always,
-    Analyse,
-    Analyze,
-    And,
-    Any,
-    Array,
-    As,
-    Asc,
-    Assertion,
-    Assignment,
-    Asymmetric,
-    At,
-    Attach,
-    Attribute,
-    Authorization,
-    Backward,
-    Before,
-    BeginP,
-    Between,
-    Bigint,
-    Binary,
-    Bit,
-    BooleanP,
-    Both,
-    By,
-    Cache,
-    Call,
-    Called,
-    Cascade,
-    Cascaded,
-    Case,
-    Cast,
-    CatalogP,
-    Chain,
-    CharP,
-    Character,
-    Characteristics,
-    Check,
-    Checkpoint,
-    Class,
-    Close,
-    Cluster,
-    Coalesce,
-    Collate,
-    Collation,
-    Column,
-    Columns,
-    // Comment,
-    Comments,
-    Commit,
-    Committed,
-    Concurrently,
-    Configuration,
-    Conflict,
-    Connection,
-    // Constraint,
-    Constraints,
-    ContentP,
-    ContinueP,
-    ConversionP,
-    Copy,
-    Cost,
-    Create,
-    Cross,
-    Csv,
-    Cube,
-    CurrentP,
-    CurrentCatalog,
-    CurrentDate,
-    CurrentRole,
-    CurrentSchema,
-    CurrentTime,
-    CurrentTimestamp,
-    CurrentUser,
-    Cursor,
-    Cycle,
-    DataP,
-    Database,
-    DayP,
-    Deallocate,
-    Dec,
-    DecimalP,
-    Declare,
-    Default,
-    Defaults,
-    Deferrable,
-    Deferred,
-    Definer,
-    DeleteP,
-    Delimiter,
-    Delimiters,
-    Depends,
-    Desc,
-    Detach,
-    Dictionary,
-    DisableP,
-    Discard,
-    Distinct,
-    Do,
-    DocumentP,
-    DomainP,
-    DoubleP,
-    Drop,
-    Each,
-    Else,
-    EnableP,
-    Encoding,
-    Encrypted,
-    EndP,
-    EnumP,
-    Escape,
-    Event,
-    Except,
-    Exclude,
-    Excluding,
-    Exclusive,
-    Execute,
-    Exists,
-    Explain,
-    Expression,
-    Extension,
-    External,
-    Extract,
-    FalseP,
-    Family,
-    Fetch,
-    Filter,
-    FirstP,
-    FloatP,
-    Following,
-    For,
-    Force,
-    Foreign,
-    Forward,
-    Freeze,
-    From,
-    Full,
-    Function,
-    Functions,
-    Generated,
-    Global,
-    Grant,
-    Granted,
-    Greatest,
-    GroupP,
-    Grouping,
-    Groups,
-    Handler,
-    Having,
-    HeaderP,
-    Hold,
-    HourP,
-    IdentityP,
-    IfP,
-    Ilike,
-    Immediate,
-    Immutable,
-    ImplicitP,
-    ImportP,
-    InP,
-    Include,
-    Including,
-    Increment,
-    Index,
-    Indexes,
-    Inherit,
-    Inherits,
-    Initially,
-    InlineP,
-    InnerP,
-    Inout,
-    InputP,
-    Insensitive,
-    Insert,
-    Instead,
-    IntP,
-    Integer,
-    Intersect,
-    Interval,
-    Into,
-    Invoker,
-    Is,
-    Isnull,
-    Isolation,
-    Join,
-    Key,
-    Label,
-    Language,
-    LargeP,
-    LastP,
-    LateralP,
-    Leading,
-    Leakproof,
-    Least,
-    Left,
-    Level,
-    Like,
-    Limit,
-    Listen,
-    Load,
-    Local,
-    Localtime,
-    Localtimestamp,
-    Location,
-    LockP,
-    Locked,
-    Logged,
-    Mapping,
-    Match,
-    Materialized,
-    Maxvalue,
-    Method,
-    MinuteP,
-    Minvalue,
-    Mode,
-    MonthP,
-    Move,
-    NameP,
-    Names,
-    National,
-    Natural,
-    Nchar,
-    New,
-    Next,
-    Nfc,
-    Nfd,
-    Nfkc,
-    Nfkd,
-    No,
-    None,
-    Normalize,
-    Normalized,
-    Not,
-    Nothing,
-    Notify,
-    Notnull,
-    Nowait,
-    NullP,
-    Nullif,
-    NullsP,
-    Numeric,
-    ObjectP,
-    Of,
-    Off,
-    Offset,
-    Oids,
-    Old,
-    On,
-    Only,
-    Operator,
-    Option,
-    Options,
-    Or,
-    Order,
-    Ordinality,
-    Others,
-    OutP,
-    OuterP,
-    Over,
-    Overlaps,
-    Overlay,
-    Overriding,
-    Owned,
-    Owner,
-    Parallel,
-    Parser,
-    Partial,
-    Partition,
-    Passing,
-    Password,
-    Placing,
-    Plans,
-    Policy,
-    Position,
-    Preceding,
-    Precision,
-    Preserve,
-    Prepare,
-    Prepared,
-    Primary,
-    Prior,
-    Privileges,
-    Procedural,
-    Procedure,
-    Procedures,
-    Program,
-    Publication,
-    Quote,
-    Range,
-    Read,
-    Real,
-    Reassign,
-    Recheck,
-    Recursive,
-    Ref,
-    References,
-    Referencing,
-    Refresh,
-    Reindex,
-    RelativeP,
-    Release,
-    Rename,
-    Repeatable,
-    Replace,
-    Replica,
-    Reset,
-    Restart,
-    Restrict,
-    Returning,
-    Returns,
-    Revoke,
-    Right,
-    Role,
-    Rollback,
-    Rollup,
-    Routine,
-    Routines,
-    Row,
-    Rows,
-    Rule,
-    Savepoint,
-    Schema,
-    Schemas,
-    Scroll,
-    Search,
-    SecondP,
-    Security,
-    Select,
-    Sequence,
-    Sequences,
-    Serializable,
-    Server,
-    Session,
-    SessionUser,
-    Set,
-    Sets,
-    Setof,
-    Share,
-    Show,
-    Similar,
-    Simple,
-    Skip,
-    Smallint,
-    Snapshot,
-    Some,
-    SqlP,
-    Stable,
-    StandaloneP,
-    Start,
-    Statement,
-    Statistics,
-    Stdin,
-    Stdout,
-    Storage,
-    Stored,
-    StrictP,
-    StripP,
-    Subscription,
-    Substring,
-    Support,
-    Symmetric,
-    Sysid,
-    SystemP,
-    Table,
-    Tables,
-    Tablesample,
-    Tablespace,
-    Temp,
-    Template,
-    Temporary,
-    TextP,
-    Then,
-    Ties,
-    Time,
-    Timestamp,
-    To,
-    Trailing,
-    Transaction,
-    Transform,
-    Treat,
-    Trigger,
-    Trim,
-    TrueP,
-    Truncate,
-    Trusted,
-    TypeP,
-    TypesP,
-    Uescape,
-    Unbounded,
-    Uncommitted,
-    Unencrypted,
-    Union,
-    Unique,
-    Unknown,
-    Unlisten,
-    Unlogged,
-    Until,
-    Update,
-    User,
-    Using,
-    Vacuum,
-    Valid,
-    Validate,
-    Validator,
-    ValueP,
-    Values,
-    Varchar,
-    Variadic,
-    Varying,
-    Verbose,
-    VersionP,
-    View,
-    Views,
-    Volatile,
-    When,
-    Where,
-    WhitespaceP,
-    Window,
-    With,
-    Within,
-    Without,
-    Work,
-    Wrapper,
-    Write,
-    XmlP,
-    Xmlattributes,
-    Xmlconcat,
-    Xmlelement,
-    Xmlexists,
-    Xmlforest,
-    Xmlnamespaces,
-    Xmlparse,
-    Xmlpi,
-    Xmlroot,
-    Xmlserialize,
-    Xmltable,
-    YearP,
-    YesP,
-    Zone,
-    NotLa,
-    NullsLa,
-    WithLa,
-    Postfixop,
-    Uminus,
-}
-
-/// Kind of a `SyntaxKind`
-/// This is the only manual definition required for properly creating a concrete syntax tree.
-/// If a token is of type `Follow`, it is not immediately applied to the syntax tree, but put into
-/// a buffer. Before the next node is started, all buffered tokens are applied to the syntax tree
-/// at the depth of the node that is opened next.
-///
-/// For example, in `select * from contact;`, the whitespace between `*` and `from` should be a direct
-/// child of the `SelectStmt` node. Without this concept, it would be put into the `ColumnRef`
-/// node.
-///
-/// SelectStmt@0..22
-///   Select@0..6 "select"
-///   Whitespace@6..7 " "
-///   ResTarget@7..8
-///     ColumnRef@7..8
-///       Ascii42@7..8 "*"
-///   Whitespace@8..9 " "
-///   From@9..13 "from"
-///   Whitespace@13..14 " "
-///   RangeVar@14..21
-///     Ident@14..21 "contact"
-///   Ascii59@21..22 ";"
-pub enum SyntaxKindType {
-    Follow,
-    Close,
-}
-
-impl SyntaxKind {
-    /// Converts a `pg_query` node to a `SyntaxKind`
-    /// Can be generated
-    pub fn from_pg_query_node(node: &NodeRef) -> Self {
-        match node {
-            NodeRef::SelectStmt(_) => SyntaxKind::SelectStmt,
-            NodeRef::Alias(_) => SyntaxKind::Alias,
-            NodeRef::RangeVar(_) => SyntaxKind::RangeVar,
-            NodeRef::TableFunc(_) => SyntaxKind::TableFunc,
-            // NodeRef::Expr(_) => SyntaxKind::Expr,
-            NodeRef::Var(_) => SyntaxKind::Var,
-            NodeRef::Param(_) => SyntaxKind::Param,
-            NodeRef::Aggref(_) => SyntaxKind::Aggref,
-            NodeRef::GroupingFunc(_) => SyntaxKind::GroupingFunc,
-            NodeRef::WindowFunc(_) => SyntaxKind::WindowFunc,
-            NodeRef::SubscriptingRef(_) => SyntaxKind::SubscriptingRef,
-            NodeRef::FuncExpr(_) => SyntaxKind::FuncExpr,
-            NodeRef::NamedArgExpr(_) => SyntaxKind::NamedArgExpr,
-            NodeRef::OpExpr(_) => SyntaxKind::OpExpr,
-            NodeRef::DistinctExpr(_) => SyntaxKind::DistinctExpr,
-            NodeRef::NullIfExpr(_) => SyntaxKind::NullIfExpr,
-            NodeRef::ScalarArrayOpExpr(_) => SyntaxKind::ScalarArrayOpExpr,
-            NodeRef::BoolExpr(_) => SyntaxKind::BoolExpr,
-            NodeRef::SubLink(_) => SyntaxKind::SubLink,
-            NodeRef::SubPlan(_) => SyntaxKind::SubPlan,
-            NodeRef::AlternativeSubPlan(_) => SyntaxKind::AlternativeSubPlan,
-            NodeRef::FieldSelect(_) => SyntaxKind::FieldSelect,
-            NodeRef::FieldStore(_) => SyntaxKind::FieldStore,
-            NodeRef::RelabelType(_) => SyntaxKind::RelabelType,
-            NodeRef::CoerceViaIo(_) => SyntaxKind::CoerceViaIo,
-            NodeRef::ArrayCoerceExpr(_) => SyntaxKind::ArrayCoerceExpr,
-            NodeRef::ConvertRowtypeExpr(_) => SyntaxKind::ConvertRowtypeExpr,
-            NodeRef::CollateExpr(_) => SyntaxKind::CollateExpr,
-            NodeRef::CaseExpr(_) => SyntaxKind::CaseExpr,
-            NodeRef::CaseWhen(_) => SyntaxKind::CaseWhen,
-            NodeRef::CaseTestExpr(_) => SyntaxKind::CaseTestExpr,
-            NodeRef::ArrayExpr(_) => SyntaxKind::ArrayExpr,
-            NodeRef::RowExpr(_) => SyntaxKind::RowExpr,
-            NodeRef::RowCompareExpr(_) => SyntaxKind::RowCompareExpr,
-            NodeRef::CoalesceExpr(_) => SyntaxKind::CoalesceExpr,
-            NodeRef::MinMaxExpr(_) => SyntaxKind::MinMaxExpr,
-            NodeRef::SqlvalueFunction(_) => SyntaxKind::SqlvalueFunction,
-            NodeRef::XmlExpr(_) => SyntaxKind::XmlExpr,
-            NodeRef::NullTest(_) => SyntaxKind::NullTest,
-            NodeRef::BooleanTest(_) => SyntaxKind::BooleanTest,
-            NodeRef::CoerceToDomain(_) => SyntaxKind::CoerceToDomain,
-            NodeRef::CoerceToDomainValue(_) => SyntaxKind::CoerceToDomainValue,
-            NodeRef::SetToDefault(_) => SyntaxKind::SetToDefault,
-            NodeRef::CurrentOfExpr(_) => SyntaxKind::CurrentOfExpr,
-            NodeRef::NextValueExpr(_) => SyntaxKind::NextValueExpr,
-            NodeRef::InferenceElem(_) => SyntaxKind::InferenceElem,
-            NodeRef::TargetEntry(_) => SyntaxKind::TargetEntry,
-            NodeRef::RangeTblRef(_) => SyntaxKind::RangeTblRef,
-            NodeRef::JoinExpr(_) => SyntaxKind::JoinExpr,
-            NodeRef::FromExpr(_) => SyntaxKind::FromExpr,
-            NodeRef::OnConflictExpr(_) => SyntaxKind::OnConflictExpr,
-            NodeRef::IntoClause(_) => SyntaxKind::IntoClause,
-            NodeRef::RawStmt(_) => SyntaxKind::RawStmt,
-            NodeRef::Query(_) => SyntaxKind::Query,
-            NodeRef::InsertStmt(_) => SyntaxKind::InsertStmt,
-            NodeRef::DeleteStmt(_) => SyntaxKind::DeleteStmt,
-            NodeRef::UpdateStmt(_) => SyntaxKind::UpdateStmt,
-            NodeRef::AlterTableStmt(_) => SyntaxKind::AlterTableStmt,
-            NodeRef::AlterTableCmd(_) => SyntaxKind::AlterTableCmd,
-            NodeRef::AlterDomainStmt(_) => SyntaxKind::AlterDomainStmt,
-            NodeRef::SetOperationStmt(_) => SyntaxKind::SetOperationStmt,
-            NodeRef::GrantStmt(_) => SyntaxKind::GrantStmt,
-            NodeRef::GrantRoleStmt(_) => SyntaxKind::GrantRoleStmt,
-            NodeRef::AlterDefaultPrivilegesStmt(_) => SyntaxKind::AlterDefaultPrivilegesStmt,
-            NodeRef::ClosePortalStmt(_) => SyntaxKind::ClosePortalStmt,
-            NodeRef::ClusterStmt(_) => SyntaxKind::ClusterStmt,
-            NodeRef::CopyStmt(_) => SyntaxKind::CopyStmt,
-            NodeRef::CreateStmt(_) => SyntaxKind::CreateStmt,
-            NodeRef::DefineStmt(_) => SyntaxKind::DefineStmt,
-            NodeRef::DropStmt(_) => SyntaxKind::DropStmt,
-            NodeRef::TruncateStmt(_) => SyntaxKind::TruncateStmt,
-            NodeRef::CommentStmt(_) => SyntaxKind::CommentStmt,
-            NodeRef::FetchStmt(_) => SyntaxKind::FetchStmt,
-            NodeRef::IndexStmt(_) => SyntaxKind::IndexStmt,
-            NodeRef::CreateFunctionStmt(_) => SyntaxKind::CreateFunctionStmt,
-            NodeRef::AlterFunctionStmt(_) => SyntaxKind::AlterFunctionStmt,
-            NodeRef::DoStmt(_) => SyntaxKind::DoStmt,
-            NodeRef::RenameStmt(_) => SyntaxKind::RenameStmt,
-            NodeRef::RuleStmt(_) => SyntaxKind::RuleStmt,
-            NodeRef::NotifyStmt(_) => SyntaxKind::NotifyStmt,
-            NodeRef::ListenStmt(_) => SyntaxKind::ListenStmt,
-            NodeRef::UnlistenStmt(_) => SyntaxKind::UnlistenStmt,
-            NodeRef::TransactionStmt(_) => SyntaxKind::TransactionStmt,
-            NodeRef::ViewStmt(_) => SyntaxKind::ViewStmt,
-            NodeRef::LoadStmt(_) => SyntaxKind::LoadStmt,
-            NodeRef::CreateDomainStmt(_) => SyntaxKind::CreateDomainStmt,
-            NodeRef::CreatedbStmt(_) => SyntaxKind::CreatedbStmt,
-            NodeRef::DropdbStmt(_) => SyntaxKind::DropdbStmt,
-            NodeRef::VacuumStmt(_) => SyntaxKind::VacuumStmt,
-            NodeRef::ExplainStmt(_) => SyntaxKind::ExplainStmt,
-            NodeRef::CreateTableAsStmt(_) => SyntaxKind::CreateTableAsStmt,
-            NodeRef::CreateSeqStmt(_) => SyntaxKind::CreateSeqStmt,
-            NodeRef::AlterSeqStmt(_) => SyntaxKind::AlterSeqStmt,
-            NodeRef::VariableSetStmt(_) => SyntaxKind::VariableSetStmt,
-            NodeRef::VariableShowStmt(_) => SyntaxKind::VariableShowStmt,
-            NodeRef::DiscardStmt(_) => SyntaxKind::DiscardStmt,
-            NodeRef::CreateTrigStmt(_) => SyntaxKind::CreateTrigStmt,
-            NodeRef::CreatePlangStmt(_) => SyntaxKind::CreatePlangStmt,
-            NodeRef::CreateRoleStmt(_) => SyntaxKind::CreateRoleStmt,
-            NodeRef::AlterRoleStmt(_) => SyntaxKind::AlterRoleStmt,
-            NodeRef::DropRoleStmt(_) => SyntaxKind::DropRoleStmt,
-            NodeRef::LockStmt(_) => SyntaxKind::LockStmt,
-            NodeRef::ConstraintsSetStmt(_) => SyntaxKind::ConstraintsSetStmt,
-            NodeRef::ReindexStmt(_) => SyntaxKind::ReindexStmt,
-            NodeRef::CheckPointStmt(_) => SyntaxKind::CheckPointStmt,
-            NodeRef::CreateSchemaStmt(_) => SyntaxKind::CreateSchemaStmt,
-            NodeRef::AlterDatabaseStmt(_) => SyntaxKind::AlterDatabaseStmt,
-            NodeRef::AlterDatabaseSetStmt(_) => SyntaxKind::AlterDatabaseSetStmt,
-            NodeRef::AlterRoleSetStmt(_) => SyntaxKind::AlterRoleSetStmt,
-            NodeRef::CreateConversionStmt(_) => SyntaxKind::CreateConversionStmt,
-            NodeRef::CreateCastStmt(_) => SyntaxKind::CreateCastStmt,
-            NodeRef::CreateOpClassStmt(_) => SyntaxKind::CreateOpClassStmt,
-            NodeRef::CreateOpFamilyStmt(_) => SyntaxKind::CreateOpFamilyStmt,
-            NodeRef::AlterOpFamilyStmt(_) => SyntaxKind::AlterOpFamilyStmt,
-            NodeRef::PrepareStmt(_) => SyntaxKind::PrepareStmt,
-            NodeRef::ExecuteStmt(_) => SyntaxKind::ExecuteStmt,
-            NodeRef::DeallocateStmt(_) => SyntaxKind::DeallocateStmt,
-            NodeRef::DeclareCursorStmt(_) => SyntaxKind::DeclareCursorStmt,
-            NodeRef::CreateTableSpaceStmt(_) => SyntaxKind::CreateTableSpaceStmt,
-            NodeRef::DropTableSpaceStmt(_) => SyntaxKind::DropTableSpaceStmt,
-            NodeRef::AlterObjectDependsStmt(_) => SyntaxKind::AlterObjectDependsStmt,
-            NodeRef::AlterObjectSchemaStmt(_) => SyntaxKind::AlterObjectSchemaStmt,
-            NodeRef::AlterOwnerStmt(_) => SyntaxKind::AlterOwnerStmt,
-            NodeRef::AlterOperatorStmt(_) => SyntaxKind::AlterOperatorStmt,
-            NodeRef::AlterTypeStmt(_) => SyntaxKind::AlterTypeStmt,
-            NodeRef::DropOwnedStmt(_) => SyntaxKind::DropOwnedStmt,
-            NodeRef::ReassignOwnedStmt(_) => SyntaxKind::ReassignOwnedStmt,
-            NodeRef::CompositeTypeStmt(_) => SyntaxKind::CompositeTypeStmt,
-            NodeRef::CreateEnumStmt(_) => SyntaxKind::CreateEnumStmt,
-            NodeRef::CreateRangeStmt(_) => SyntaxKind::CreateRangeStmt,
-            NodeRef::AlterEnumStmt(_) => SyntaxKind::AlterEnumStmt,
-            NodeRef::AlterTsdictionaryStmt(_) => SyntaxKind::AlterTsdictionaryStmt,
-            NodeRef::AlterTsconfigurationStmt(_) => SyntaxKind::AlterTsconfigurationStmt,
-            NodeRef::CreateFdwStmt(_) => SyntaxKind::CreateFdwStmt,
-            NodeRef::AlterFdwStmt(_) => SyntaxKind::AlterFdwStmt,
-            NodeRef::CreateForeignServerStmt(_) => SyntaxKind::CreateForeignServerStmt,
-            NodeRef::AlterForeignServerStmt(_) => SyntaxKind::AlterForeignServerStmt,
-            NodeRef::CreateUserMappingStmt(_) => SyntaxKind::CreateUserMappingStmt,
-            NodeRef::AlterUserMappingStmt(_) => SyntaxKind::AlterUserMappingStmt,
-            NodeRef::DropUserMappingStmt(_) => SyntaxKind::DropUserMappingStmt,
-            NodeRef::AlterTableSpaceOptionsStmt(_) => SyntaxKind::AlterTableSpaceOptionsStmt,
-            NodeRef::AlterTableMoveAllStmt(_) => SyntaxKind::AlterTableMoveAllStmt,
-            NodeRef::SecLabelStmt(_) => SyntaxKind::SecLabelStmt,
-            NodeRef::CreateForeignTableStmt(_) => SyntaxKind::CreateForeignTableStmt,
-            NodeRef::ImportForeignSchemaStmt(_) => SyntaxKind::ImportForeignSchemaStmt,
-            NodeRef::CreateExtensionStmt(_) => SyntaxKind::CreateExtensionStmt,
-            NodeRef::AlterExtensionStmt(_) => SyntaxKind::AlterExtensionStmt,
-            NodeRef::AlterExtensionContentsStmt(_) => SyntaxKind::AlterExtensionContentsStmt,
-            NodeRef::CreateEventTrigStmt(_) => SyntaxKind::CreateEventTrigStmt,
-            NodeRef::AlterEventTrigStmt(_) => SyntaxKind::AlterEventTrigStmt,
-            NodeRef::RefreshMatViewStmt(_) => SyntaxKind::RefreshMatViewStmt,
-            NodeRef::ReplicaIdentityStmt(_) => SyntaxKind::ReplicaIdentityStmt,
-            NodeRef::AlterSystemStmt(_) => SyntaxKind::AlterSystemStmt,
-            NodeRef::CreatePolicyStmt(_) => SyntaxKind::CreatePolicyStmt,
-            NodeRef::AlterPolicyStmt(_) => SyntaxKind::AlterPolicyStmt,
-            NodeRef::CreateTransformStmt(_) => SyntaxKind::CreateTransformStmt,
-            NodeRef::CreateAmStmt(_) => SyntaxKind::CreateAmStmt,
-            NodeRef::CreatePublicationStmt(_) => SyntaxKind::CreatePublicationStmt,
-            NodeRef::AlterPublicationStmt(_) => SyntaxKind::AlterPublicationStmt,
-            NodeRef::CreateSubscriptionStmt(_) => SyntaxKind::CreateSubscriptionStmt,
-            NodeRef::AlterSubscriptionStmt(_) => SyntaxKind::AlterSubscriptionStmt,
-            NodeRef::DropSubscriptionStmt(_) => SyntaxKind::DropSubscriptionStmt,
-            NodeRef::CreateStatsStmt(_) => SyntaxKind::CreateStatsStmt,
-            NodeRef::AlterCollationStmt(_) => SyntaxKind::AlterCollationStmt,
-            NodeRef::CallStmt(_) => SyntaxKind::CallStmt,
-            NodeRef::AlterStatsStmt(_) => SyntaxKind::AlterStatsStmt,
-            NodeRef::AExpr(_) => SyntaxKind::AExpr,
-            NodeRef::ColumnRef(_) => SyntaxKind::ColumnRef,
-            NodeRef::ParamRef(_) => SyntaxKind::ParamRef,
-            NodeRef::AConst(_) => SyntaxKind::AConst,
-            NodeRef::FuncCall(_) => SyntaxKind::FuncCall,
-            NodeRef::AStar(_) => SyntaxKind::AStar,
-            NodeRef::AIndices(_) => SyntaxKind::AIndices,
-            NodeRef::AIndirection(_) => SyntaxKind::AIndirection,
-            NodeRef::AArrayExpr(_) => SyntaxKind::AArrayExpr,
-            NodeRef::ResTarget(_) => SyntaxKind::ResTarget,
-            NodeRef::MultiAssignRef(_) => SyntaxKind::MultiAssignRef,
-            NodeRef::TypeCast(_) => SyntaxKind::TypeCast,
-            NodeRef::CollateClause(_) => SyntaxKind::CollateClause,
-            NodeRef::SortBy(_) => SyntaxKind::SortBy,
-            NodeRef::WindowDef(_) => SyntaxKind::WindowDef,
-            NodeRef::RangeSubselect(_) => SyntaxKind::RangeSubselect,
-            NodeRef::RangeFunction(_) => SyntaxKind::RangeFunction,
-            NodeRef::RangeTableSample(_) => SyntaxKind::RangeTableSample,
-            NodeRef::RangeTableFunc(_) => SyntaxKind::RangeTableFunc,
-            NodeRef::RangeTableFuncCol(_) => SyntaxKind::RangeTableFuncCol,
-            NodeRef::TypeName(_) => SyntaxKind::TypeName,
-            NodeRef::ColumnDef(_) => SyntaxKind::ColumnDef,
-            NodeRef::IndexElem(_) => SyntaxKind::IndexElem,
-            NodeRef::Constraint(_) => SyntaxKind::Constraint,
-            NodeRef::DefElem(_) => SyntaxKind::DefElem,
-            NodeRef::RangeTblEntry(_) => SyntaxKind::RangeTblEntry,
-            NodeRef::RangeTblFunction(_) => SyntaxKind::RangeTblFunction,
-            NodeRef::TableSampleClause(_) => SyntaxKind::TableSampleClause,
-            NodeRef::WithCheckOption(_) => SyntaxKind::WithCheckOption,
-            NodeRef::SortGroupClause(_) => SyntaxKind::SortGroupClause,
-            NodeRef::GroupingSet(_) => SyntaxKind::GroupingSet,
-            NodeRef::WindowClause(_) => SyntaxKind::WindowClause,
-            NodeRef::ObjectWithArgs(_) => SyntaxKind::ObjectWithArgs,
-            NodeRef::AccessPriv(_) => SyntaxKind::AccessPriv,
-            NodeRef::CreateOpClassItem(_) => SyntaxKind::CreateOpClassItem,
-            NodeRef::TableLikeClause(_) => SyntaxKind::TableLikeClause,
-            NodeRef::FunctionParameter(_) => SyntaxKind::FunctionParameter,
-            NodeRef::LockingClause(_) => SyntaxKind::LockingClause,
-            NodeRef::RowMarkClause(_) => SyntaxKind::RowMarkClause,
-            NodeRef::XmlSerialize(_) => SyntaxKind::XmlSerialize,
-            NodeRef::WithClause(_) => SyntaxKind::WithClause,
-            NodeRef::InferClause(_) => SyntaxKind::InferClause,
-            NodeRef::OnConflictClause(_) => SyntaxKind::OnConflictClause,
-            NodeRef::CommonTableExpr(_) => SyntaxKind::CommonTableExpr,
-            NodeRef::RoleSpec(_) => SyntaxKind::RoleSpec,
-            NodeRef::TriggerTransition(_) => SyntaxKind::TriggerTransition,
-            NodeRef::PartitionElem(_) => SyntaxKind::PartitionElem,
-            NodeRef::PartitionSpec(_) => SyntaxKind::PartitionSpec,
-            NodeRef::PartitionBoundSpec(_) => SyntaxKind::PartitionBoundSpec,
-            NodeRef::PartitionRangeDatum(_) => SyntaxKind::PartitionRangeDatum,
-            NodeRef::PartitionCmd(_) => SyntaxKind::PartitionCmd,
-            NodeRef::VacuumRelation(_) => SyntaxKind::VacuumRelation,
-            NodeRef::InlineCodeBlock(_) => SyntaxKind::InlineCodeBlock,
-            NodeRef::CallContext(_) => SyntaxKind::CallContext,
-            NodeRef::Integer(_) => SyntaxKind::Integer,
-            NodeRef::Float(_) => SyntaxKind::Float,
-            NodeRef::String(_) => SyntaxKind::String,
-            NodeRef::BitString(_) => SyntaxKind::BitString,
-            // NodeRef::Null(_) => SyntaxKind::Null,
-            NodeRef::List(_) => SyntaxKind::List,
-            NodeRef::IntList(_) => SyntaxKind::IntList,
-            NodeRef::OidList(_) => SyntaxKind::OidList,
-            _ => panic!("Unknown node type: {:?}", node),
-        }
-    }
-
-    /// Converts a `pg_query` ScanToken to a `SyntaxKind`
-    /// Can be generated
-    pub fn from_pg_query_token(token: &ScanToken) -> Self {
-        match token.token {
-            0 => SyntaxKind::Nul,
-            37 => SyntaxKind::Ascii37,
-            40 => SyntaxKind::Ascii40,
-            41 => SyntaxKind::Ascii41,
-            42 => SyntaxKind::Ascii42,
-            43 => SyntaxKind::Ascii43,
-            44 => SyntaxKind::Ascii44,
-            45 => SyntaxKind::Ascii45,
-            46 => SyntaxKind::Ascii46,
-            47 => SyntaxKind::Ascii47,
-            58 => SyntaxKind::Ascii58,
-            59 => SyntaxKind::Ascii59,
-            60 => SyntaxKind::Ascii60,
-            61 => SyntaxKind::Ascii61,
-            62 => SyntaxKind::Ascii62,
-            63 => SyntaxKind::Ascii63,
-            91 => SyntaxKind::Ascii91,
-            92 => SyntaxKind::Ascii92,
-            93 => SyntaxKind::Ascii93,
-            94 => SyntaxKind::Ascii94,
-            258 => SyntaxKind::Ident,
-            259 => SyntaxKind::Uident,
-            260 => SyntaxKind::Fconst,
-            261 => SyntaxKind::Sconst,
-            262 => SyntaxKind::Usconst,
-            263 => SyntaxKind::Bconst,
-            264 => SyntaxKind::Xconst,
-            265 => SyntaxKind::Op,
-            266 => SyntaxKind::Iconst,
-            267 => SyntaxKind::Param,
-            268 => SyntaxKind::Typecast,
-            269 => SyntaxKind::DotDot,
-            270 => SyntaxKind::ColonEquals,
-            271 => SyntaxKind::EqualsGreater,
-            272 => SyntaxKind::LessEquals,
-            273 => SyntaxKind::GreaterEquals,
-            274 => SyntaxKind::NotEquals,
-            275 => SyntaxKind::SqlComment,
-            276 => SyntaxKind::CComment,
-            277 => SyntaxKind::AbortP,
-            278 => SyntaxKind::AbsoluteP,
-            279 => SyntaxKind::Access,
-            280 => SyntaxKind::Action,
-            281 => SyntaxKind::AddP,
-            282 => SyntaxKind::Admin,
-            283 => SyntaxKind::After,
-            284 => SyntaxKind::Aggregate,
-            285 => SyntaxKind::All,
-            286 => SyntaxKind::Also,
-            287 => SyntaxKind::Alter,
-            288 => SyntaxKind::Always,
-            289 => SyntaxKind::Analyse,
-            290 => SyntaxKind::Analyze,
-            291 => SyntaxKind::And,
-            292 => SyntaxKind::Any,
-            293 => SyntaxKind::Array,
-            294 => SyntaxKind::As,
-            295 => SyntaxKind::Asc,
-            296 => SyntaxKind::Assertion,
-            297 => SyntaxKind::Assignment,
-            298 => SyntaxKind::Asymmetric,
-            299 => SyntaxKind::At,
-            300 => SyntaxKind::Attach,
-            301 => SyntaxKind::Attribute,
-            302 => SyntaxKind::Authorization,
-            303 => SyntaxKind::Backward,
-            305 => SyntaxKind::BeginP,
-            306 => SyntaxKind::Between,
-            307 => SyntaxKind::Bigint,
-            308 => SyntaxKind::Binary,
-            309 => SyntaxKind::Bit,
-            310 => SyntaxKind::BooleanP,
-            311 => SyntaxKind::Both,
-            312 => SyntaxKind::By,
-            313 => SyntaxKind::Cache,
-            314 => SyntaxKind::Call,
-            315 => SyntaxKind::Called,
-            316 => SyntaxKind::Cascade,
-            317 => SyntaxKind::Cascaded,
-            318 => SyntaxKind::Case,
-            319 => SyntaxKind::Cast,
-            320 => SyntaxKind::CatalogP,
-            321 => SyntaxKind::Chain,
-            322 => SyntaxKind::CharP,
-            323 => SyntaxKind::Character,
-            324 => SyntaxKind::Characteristics,
-            325 => SyntaxKind::Check,
-            326 => SyntaxKind::Checkpoint,
-            327 => SyntaxKind::Class,
-            328 => SyntaxKind::Close,
-            329 => SyntaxKind::Cluster,
-            330 => SyntaxKind::Coalesce,
-            331 => SyntaxKind::Collate,
-            332 => SyntaxKind::Collation,
-            333 => SyntaxKind::Column,
-            334 => SyntaxKind::Columns,
-            335 => SyntaxKind::Comment,
-            336 => SyntaxKind::Comments,
-            337 => SyntaxKind::Commit,
-            338 => SyntaxKind::Committed,
-            339 => SyntaxKind::Concurrently,
-            340 => SyntaxKind::Configuration,
-            341 => SyntaxKind::Conflict,
-            342 => SyntaxKind::Connection,
-            343 => SyntaxKind::Constraint,
-            344 => SyntaxKind::Constraints,
-            345 => SyntaxKind::ContentP,
-            346 => SyntaxKind::ContinueP,
-            347 => SyntaxKind::ConversionP,
-            348 => SyntaxKind::Copy,
-            349 => SyntaxKind::Cost,
-            350 => SyntaxKind::Create,
-            351 => SyntaxKind::Cross,
-            352 => SyntaxKind::Csv,
-            353 => SyntaxKind::Cube,
-            354 => SyntaxKind::CurrentP,
-            355 => SyntaxKind::CurrentCatalog,
-            356 => SyntaxKind::CurrentDate,
-            357 => SyntaxKind::CurrentRole,
-            358 => SyntaxKind::CurrentSchema,
-            359 => SyntaxKind::CurrentTime,
-            360 => SyntaxKind::CurrentTimestamp,
-            361 => SyntaxKind::CurrentUser,
-            362 => SyntaxKind::Cursor,
-            363 => SyntaxKind::Cycle,
-            364 => SyntaxKind::DataP,
-            365 => SyntaxKind::Database,
-            366 => SyntaxKind::DayP,
-            367 => SyntaxKind::Deallocate,
-            368 => SyntaxKind::Dec,
-            369 => SyntaxKind::DecimalP,
-            370 => SyntaxKind::Declare,
-            371 => SyntaxKind::Default,
-            372 => SyntaxKind::Defaults,
-            373 => SyntaxKind::Deferrable,
-            374 => SyntaxKind::Deferred,
-            375 => SyntaxKind::Definer,
-            376 => SyntaxKind::DeleteP,
-            377 => SyntaxKind::Delimiter,
-            378 => SyntaxKind::Delimiters,
-            379 => SyntaxKind::Depends,
-            380 => SyntaxKind::Desc,
-            381 => SyntaxKind::Detach,
-            382 => SyntaxKind::Dictionary,
-            383 => SyntaxKind::DisableP,
-            384 => SyntaxKind::Discard,
-            385 => SyntaxKind::Distinct,
-            386 => SyntaxKind::Do,
-            387 => SyntaxKind::DocumentP,
-            388 => SyntaxKind::DomainP,
-            389 => SyntaxKind::DoubleP,
-            390 => SyntaxKind::Drop,
-            391 => SyntaxKind::Each,
-            392 => SyntaxKind::Else,
-            393 => SyntaxKind::EnableP,
-            394 => SyntaxKind::Encoding,
-            395 => SyntaxKind::Encrypted,
-            396 => SyntaxKind::EndP,
-            397 => SyntaxKind::EnumP,
-            398 => SyntaxKind::Escape,
-            399 => SyntaxKind::Event,
-            400 => SyntaxKind::Except,
-            401 => SyntaxKind::Exclude,
-            402 => SyntaxKind::Excluding,
-            403 => SyntaxKind::Exclusive,
-            404 => SyntaxKind::Execute,
-            405 => SyntaxKind::Exists,
-            406 => SyntaxKind::Explain,
-            407 => SyntaxKind::Expression,
-            408 => SyntaxKind::Extension,
-            409 => SyntaxKind::External,
-            410 => SyntaxKind::Extract,
-            411 => SyntaxKind::FalseP,
-            412 => SyntaxKind::Family,
-            413 => SyntaxKind::Fetch,
-            414 => SyntaxKind::Filter,
-            415 => SyntaxKind::FirstP,
-            416 => SyntaxKind::FloatP,
-            417 => SyntaxKind::Following,
-            418 => SyntaxKind::For,
-            419 => SyntaxKind::Force,
-            420 => SyntaxKind::Foreign,
-            421 => SyntaxKind::Forward,
-            422 => SyntaxKind::Freeze,
-            423 => SyntaxKind::From,
-            424 => SyntaxKind::Full,
-            425 => SyntaxKind::Function,
-            426 => SyntaxKind::Functions,
-            427 => SyntaxKind::Generated,
-            428 => SyntaxKind::Global,
-            429 => SyntaxKind::Grant,
-            430 => SyntaxKind::Granted,
-            431 => SyntaxKind::Greatest,
-            432 => SyntaxKind::GroupP,
-            433 => SyntaxKind::Grouping,
-            434 => SyntaxKind::Groups,
-            435 => SyntaxKind::Handler,
-            436 => SyntaxKind::Having,
-            437 => SyntaxKind::HeaderP,
-            438 => SyntaxKind::Hold,
-            439 => SyntaxKind::HourP,
-            440 => SyntaxKind::IdentityP,
-            441 => SyntaxKind::IfP,
-            442 => SyntaxKind::Ilike,
-            443 => SyntaxKind::Immediate,
-            444 => SyntaxKind::Immutable,
-            445 => SyntaxKind::ImplicitP,
-            446 => SyntaxKind::ImportP,
-            447 => SyntaxKind::InP,
-            448 => SyntaxKind::Include,
-            449 => SyntaxKind::Including,
-            450 => SyntaxKind::Increment,
-            451 => SyntaxKind::Index,
-            452 => SyntaxKind::Indexes,
-            453 => SyntaxKind::Inherit,
-            454 => SyntaxKind::Inherits,
-            455 => SyntaxKind::Initially,
-            456 => SyntaxKind::InlineP,
-            457 => SyntaxKind::InnerP,
-            458 => SyntaxKind::Inout,
-            459 => SyntaxKind::InputP,
-            460 => SyntaxKind::Insensitive,
-            461 => SyntaxKind::Insert,
-            462 => SyntaxKind::Instead,
-            463 => SyntaxKind::IntP,
-            464 => SyntaxKind::Integer,
-            465 => SyntaxKind::Intersect,
-            466 => SyntaxKind::Interval,
-            467 => SyntaxKind::Into,
-            468 => SyntaxKind::Invoker,
-            469 => SyntaxKind::Is,
-            470 => SyntaxKind::Isnull,
-            471 => SyntaxKind::Isolation,
-            472 => SyntaxKind::Join,
-            473 => SyntaxKind::Key,
-            474 => SyntaxKind::Label,
-            475 => SyntaxKind::Language,
-            476 => SyntaxKind::LargeP,
-            477 => SyntaxKind::LastP,
-            478 => SyntaxKind::LateralP,
-            479 => SyntaxKind::Leading,
-            480 => SyntaxKind::Leakproof,
-            481 => SyntaxKind::Least,
-            482 => SyntaxKind::Left,
-            483 => SyntaxKind::Level,
-            484 => SyntaxKind::Like,
-            485 => SyntaxKind::Limit,
-            486 => SyntaxKind::Listen,
-            487 => SyntaxKind::Load,
-            488 => SyntaxKind::Local,
-            489 => SyntaxKind::Localtime,
-            490 => SyntaxKind::Localtimestamp,
-            491 => SyntaxKind::Location,
-            492 => SyntaxKind::LockP,
-            493 => SyntaxKind::Locked,
-            494 => SyntaxKind::Logged,
-            495 => SyntaxKind::Mapping,
-            496 => SyntaxKind::Match,
-            497 => SyntaxKind::Materialized,
-            498 => SyntaxKind::Maxvalue,
-            499 => SyntaxKind::Method,
-            500 => SyntaxKind::MinuteP,
-            501 => SyntaxKind::Minvalue,
-            502 => SyntaxKind::Mode,
-            503 => SyntaxKind::MonthP,
-            504 => SyntaxKind::Move,
-            505 => SyntaxKind::NameP,
-            506 => SyntaxKind::Names,
-            507 => SyntaxKind::National,
-            508 => SyntaxKind::Natural,
-            509 => SyntaxKind::Nchar,
-            510 => SyntaxKind::New,
-            511 => SyntaxKind::Next,
-            512 => SyntaxKind::Nfc,
-            513 => SyntaxKind::Nfd,
-            514 => SyntaxKind::Nfkc,
-            515 => SyntaxKind::Nfkd,
-            516 => SyntaxKind::No,
-            517 => SyntaxKind::None,
-            518 => SyntaxKind::Normalize,
-            519 => SyntaxKind::Normalized,
-            520 => SyntaxKind::Not,
-            521 => SyntaxKind::Nothing,
-            522 => SyntaxKind::Notify,
-            523 => SyntaxKind::Notnull,
-            524 => SyntaxKind::Nowait,
-            525 => SyntaxKind::NullP,
-            526 => SyntaxKind::Nullif,
-            527 => SyntaxKind::NullsP,
-            528 => SyntaxKind::Numeric,
-            529 => SyntaxKind::ObjectP,
-            530 => SyntaxKind::Of,
-            531 => SyntaxKind::Off,
-            532 => SyntaxKind::Offset,
-            533 => SyntaxKind::Oids,
-            534 => SyntaxKind::Old,
-            535 => SyntaxKind::On,
-            536 => SyntaxKind::Only,
-            537 => SyntaxKind::Operator,
-            538 => SyntaxKind::Option,
-            539 => SyntaxKind::Options,
-            540 => SyntaxKind::Or,
-            541 => SyntaxKind::Order,
-            542 => SyntaxKind::Ordinality,
-            543 => SyntaxKind::Others,
-            544 => SyntaxKind::OutP,
-            545 => SyntaxKind::OuterP,
-            546 => SyntaxKind::Over,
-            547 => SyntaxKind::Overlaps,
-            548 => SyntaxKind::Overlay,
-            549 => SyntaxKind::Overriding,
-            550 => SyntaxKind::Owned,
-            551 => SyntaxKind::Owner,
-            552 => SyntaxKind::Parallel,
-            553 => SyntaxKind::Parser,
-            554 => SyntaxKind::Partial,
-            555 => SyntaxKind::Partition,
-            556 => SyntaxKind::Passing,
-            557 => SyntaxKind::Password,
-            558 => SyntaxKind::Placing,
-            559 => SyntaxKind::Plans,
-            560 => SyntaxKind::Policy,
-            561 => SyntaxKind::Position,
-            562 => SyntaxKind::Preceding,
-            563 => SyntaxKind::Precision,
-            564 => SyntaxKind::Preserve,
-            565 => SyntaxKind::Prepare,
-            566 => SyntaxKind::Prepared,
-            567 => SyntaxKind::Primary,
-            568 => SyntaxKind::Prior,
-            569 => SyntaxKind::Privileges,
-            570 => SyntaxKind::Procedural,
-            571 => SyntaxKind::Procedure,
-            572 => SyntaxKind::Procedures,
-            573 => SyntaxKind::Program,
-            574 => SyntaxKind::Publication,
-            575 => SyntaxKind::Quote,
-            576 => SyntaxKind::Range,
-            577 => SyntaxKind::Read,
-            578 => SyntaxKind::Real,
-            579 => SyntaxKind::Reassign,
-            580 => SyntaxKind::Recheck,
-            581 => SyntaxKind::Recursive,
-            582 => SyntaxKind::Ref,
-            583 => SyntaxKind::References,
-            584 => SyntaxKind::Referencing,
-            585 => SyntaxKind::Refresh,
-            586 => SyntaxKind::Reindex,
-            587 => SyntaxKind::RelativeP,
-            588 => SyntaxKind::Release,
-            589 => SyntaxKind::Rename,
-            590 => SyntaxKind::Repeatable,
-            591 => SyntaxKind::Replace,
-            592 => SyntaxKind::Replica,
-            593 => SyntaxKind::Reset,
-            594 => SyntaxKind::Restart,
-            595 => SyntaxKind::Restrict,
-            596 => SyntaxKind::Returning,
-            597 => SyntaxKind::Returns,
-            598 => SyntaxKind::Revoke,
-            599 => SyntaxKind::Right,
-            600 => SyntaxKind::Role,
-            601 => SyntaxKind::Rollback,
-            602 => SyntaxKind::Rollup,
-            603 => SyntaxKind::Routine,
-            604 => SyntaxKind::Routines,
-            605 => SyntaxKind::Row,
-            606 => SyntaxKind::Rows,
-            607 => SyntaxKind::Rule,
-            608 => SyntaxKind::Savepoint,
-            609 => SyntaxKind::Schema,
-            610 => SyntaxKind::Schemas,
-            611 => SyntaxKind::Scroll,
-            612 => SyntaxKind::Search,
-            613 => SyntaxKind::SecondP,
-            614 => SyntaxKind::Security,
-            615 => SyntaxKind::Select,
-            616 => SyntaxKind::Sequence,
-            617 => SyntaxKind::Sequences,
-            618 => SyntaxKind::Serializable,
-            619 => SyntaxKind::Server,
-            620 => SyntaxKind::Session,
-            621 => SyntaxKind::SessionUser,
-            622 => SyntaxKind::Set,
-            623 => SyntaxKind::Sets,
-            624 => SyntaxKind::Setof,
-            625 => SyntaxKind::Share,
-            626 => SyntaxKind::Show,
-            627 => SyntaxKind::Similar,
-            628 => SyntaxKind::Simple,
-            629 => SyntaxKind::Skip,
-            630 => SyntaxKind::Smallint,
-            631 => SyntaxKind::Snapshot,
-            632 => SyntaxKind::Some,
-            633 => SyntaxKind::SqlP,
-            634 => SyntaxKind::Stable,
-            635 => SyntaxKind::StandaloneP,
-            636 => SyntaxKind::Start,
-            637 => SyntaxKind::Statement,
-            638 => SyntaxKind::Statistics,
-            639 => SyntaxKind::Stdin,
-            640 => SyntaxKind::Stdout,
-            641 => SyntaxKind::Storage,
-            642 => SyntaxKind::Stored,
-            643 => SyntaxKind::StrictP,
-            644 => SyntaxKind::StripP,
-            645 => SyntaxKind::Subscription,
-            646 => SyntaxKind::Substring,
-            647 => SyntaxKind::Support,
-            648 => SyntaxKind::Symmetric,
-            649 => SyntaxKind::Sysid,
-            650 => SyntaxKind::SystemP,
-            651 => SyntaxKind::Table,
-            652 => SyntaxKind::Tables,
-            653 => SyntaxKind::Tablesample,
-            654 => SyntaxKind::Tablespace,
-            655 => SyntaxKind::Temp,
-            656 => SyntaxKind::Template,
-            657 => SyntaxKind::Temporary,
-            658 => SyntaxKind::TextP,
-            659 => SyntaxKind::Then,
-            660 => SyntaxKind::Ties,
-            661 => SyntaxKind::Time,
-            662 => SyntaxKind::Timestamp,
-            663 => SyntaxKind::To,
-            664 => SyntaxKind::Trailing,
-            665 => SyntaxKind::Transaction,
-            666 => SyntaxKind::Transform,
-            667 => SyntaxKind::Treat,
-            668 => SyntaxKind::Trigger,
-            669 => SyntaxKind::Trim,
-            670 => SyntaxKind::TrueP,
-            671 => SyntaxKind::Truncate,
-            672 => SyntaxKind::Trusted,
-            673 => SyntaxKind::TypeP,
-            674 => SyntaxKind::TypesP,
-            675 => SyntaxKind::Uescape,
-            676 => SyntaxKind::Unbounded,
-            677 => SyntaxKind::Uncommitted,
-            678 => SyntaxKind::Unencrypted,
-            679 => SyntaxKind::Union,
-            680 => SyntaxKind::Unique,
-            681 => SyntaxKind::Unknown,
-            682 => SyntaxKind::Unlisten,
-            683 => SyntaxKind::Unlogged,
-            684 => SyntaxKind::Until,
-            685 => SyntaxKind::Update,
-            686 => SyntaxKind::User,
-            687 => SyntaxKind::Using,
-            688 => SyntaxKind::Vacuum,
-            689 => SyntaxKind::Valid,
-            690 => SyntaxKind::Validate,
-            691 => SyntaxKind::Validator,
-            692 => SyntaxKind::ValueP,
-            693 => SyntaxKind::Values,
-            694 => SyntaxKind::Varchar,
-            695 => SyntaxKind::Variadic,
-            696 => SyntaxKind::Varying,
-            697 => SyntaxKind::Verbose,
-            698 => SyntaxKind::VersionP,
-            699 => SyntaxKind::View,
-            700 => SyntaxKind::Views,
-            701 => SyntaxKind::Volatile,
-            702 => SyntaxKind::When,
-            703 => SyntaxKind::Where,
-            704 => SyntaxKind::WhitespaceP,
-            705 => SyntaxKind::Window,
-            706 => SyntaxKind::With,
-            707 => SyntaxKind::Within,
-            708 => SyntaxKind::Without,
-            709 => SyntaxKind::Work,
-            710 => SyntaxKind::Wrapper,
-            711 => SyntaxKind::Write,
-            712 => SyntaxKind::XmlP,
-            713 => SyntaxKind::Xmlattributes,
-            714 => SyntaxKind::Xmlconcat,
-            715 => SyntaxKind::Xmlelement,
-            716 => SyntaxKind::Xmlexists,
-            717 => SyntaxKind::Xmlforest,
-            718 => SyntaxKind::Xmlnamespaces,
-            719 => SyntaxKind::Xmlparse,
-            720 => SyntaxKind::Xmlpi,
-            721 => SyntaxKind::Xmlroot,
-            722 => SyntaxKind::Xmlserialize,
-            723 => SyntaxKind::Xmltable,
-            724 => SyntaxKind::YearP,
-            725 => SyntaxKind::YesP,
-            726 => SyntaxKind::Zone,
-            727 => SyntaxKind::NotLa,
-            728 => SyntaxKind::NullsLa,
-            729 => SyntaxKind::WithLa,
-            730 => SyntaxKind::Postfixop,
-            731 => SyntaxKind::Uminus,
-            _ => panic!("Unknown StatementToken: {:?}", token),
-        }
-    }
-
-    /// Returns the `SyntaxKindType` of a `SyntaxKind`
-    /// Maybe this can be generated from the ScanToken type in pg_query.rs
-    pub fn get_type(&self) -> Option<SyntaxKindType> {
-        match self {
-            SyntaxKind::Newline => Some(SyntaxKindType::Follow),
-            SyntaxKind::Whitespace => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nul => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii37 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii40 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii41 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii42 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii43 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii44 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii45 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii46 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii47 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii58 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii59 => Some(SyntaxKindType::Close),
-            SyntaxKind::Ascii60 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii61 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii62 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii63 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii91 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii92 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii93 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii94 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Uident => Some(SyntaxKindType::Follow),
-            SyntaxKind::Fconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Usconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Bconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Op => Some(SyntaxKindType::Follow),
-            SyntaxKind::Iconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Typecast => Some(SyntaxKindType::Follow),
-            SyntaxKind::DotDot => Some(SyntaxKindType::Follow),
-            SyntaxKind::ColonEquals => Some(SyntaxKindType::Follow),
-            SyntaxKind::EqualsGreater => Some(SyntaxKindType::Follow),
-            SyntaxKind::LessEquals => Some(SyntaxKindType::Follow),
-            SyntaxKind::GreaterEquals => Some(SyntaxKindType::Follow),
-            SyntaxKind::NotEquals => Some(SyntaxKindType::Follow),
-            SyntaxKind::SqlComment => Some(SyntaxKindType::Follow),
-            SyntaxKind::CComment => Some(SyntaxKindType::Follow),
-            SyntaxKind::AbortP => Some(SyntaxKindType::Follow),
-            SyntaxKind::AbsoluteP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Access => Some(SyntaxKindType::Follow),
-            SyntaxKind::Action => Some(SyntaxKindType::Follow),
-            SyntaxKind::AddP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Admin => Some(SyntaxKindType::Follow),
-            SyntaxKind::After => Some(SyntaxKindType::Follow),
-            SyntaxKind::Aggregate => Some(SyntaxKindType::Follow),
-            SyntaxKind::All => Some(SyntaxKindType::Follow),
-            SyntaxKind::Also => Some(SyntaxKindType::Follow),
-            SyntaxKind::Alter => Some(SyntaxKindType::Follow),
-            SyntaxKind::Always => Some(SyntaxKindType::Follow),
-            SyntaxKind::Analyse => Some(SyntaxKindType::Follow),
-            SyntaxKind::Analyze => Some(SyntaxKindType::Follow),
-            SyntaxKind::And => Some(SyntaxKindType::Follow),
-            SyntaxKind::Any => Some(SyntaxKindType::Follow),
-            SyntaxKind::Array => Some(SyntaxKindType::Follow),
-            SyntaxKind::As => Some(SyntaxKindType::Follow),
-            SyntaxKind::Asc => Some(SyntaxKindType::Follow),
-            SyntaxKind::Assertion => Some(SyntaxKindType::Follow),
-            SyntaxKind::Assignment => Some(SyntaxKindType::Follow),
-            SyntaxKind::Asymmetric => Some(SyntaxKindType::Follow),
-            SyntaxKind::At => Some(SyntaxKindType::Follow),
-            SyntaxKind::Attach => Some(SyntaxKindType::Follow),
-            SyntaxKind::Attribute => Some(SyntaxKindType::Follow),
-            SyntaxKind::Authorization => Some(SyntaxKindType::Follow),
-            SyntaxKind::Backward => Some(SyntaxKindType::Follow),
-            SyntaxKind::Before => Some(SyntaxKindType::Follow),
-            SyntaxKind::BeginP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Between => Some(SyntaxKindType::Follow),
-            SyntaxKind::Bigint => Some(SyntaxKindType::Follow),
-            SyntaxKind::Binary => Some(SyntaxKindType::Follow),
-            SyntaxKind::Bit => Some(SyntaxKindType::Follow),
-            SyntaxKind::BooleanP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Both => Some(SyntaxKindType::Follow),
-            SyntaxKind::By => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cache => Some(SyntaxKindType::Follow),
-            SyntaxKind::Call => Some(SyntaxKindType::Follow),
-            SyntaxKind::Called => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cascade => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cascaded => Some(SyntaxKindType::Follow),
-            SyntaxKind::Case => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cast => Some(SyntaxKindType::Follow),
-            SyntaxKind::CatalogP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Chain => Some(SyntaxKindType::Follow),
-            SyntaxKind::CharP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Character => Some(SyntaxKindType::Follow),
-            SyntaxKind::Characteristics => Some(SyntaxKindType::Follow),
-            SyntaxKind::Check => Some(SyntaxKindType::Follow),
-            SyntaxKind::Checkpoint => Some(SyntaxKindType::Follow),
-            SyntaxKind::Class => Some(SyntaxKindType::Follow),
-            SyntaxKind::Close => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cluster => Some(SyntaxKindType::Follow),
-            SyntaxKind::Coalesce => Some(SyntaxKindType::Follow),
-            SyntaxKind::Collate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Collation => Some(SyntaxKindType::Follow),
-            SyntaxKind::Column => Some(SyntaxKindType::Follow),
-            SyntaxKind::Columns => Some(SyntaxKindType::Follow),
-            SyntaxKind::Comments => Some(SyntaxKindType::Follow),
-            SyntaxKind::Commit => Some(SyntaxKindType::Follow),
-            SyntaxKind::Committed => Some(SyntaxKindType::Follow),
-            SyntaxKind::Concurrently => Some(SyntaxKindType::Follow),
-            SyntaxKind::Configuration => Some(SyntaxKindType::Follow),
-            SyntaxKind::Conflict => Some(SyntaxKindType::Follow),
-            SyntaxKind::Connection => Some(SyntaxKindType::Follow),
-            SyntaxKind::Constraints => Some(SyntaxKindType::Follow),
-            SyntaxKind::ContentP => Some(SyntaxKindType::Follow),
-            SyntaxKind::ContinueP => Some(SyntaxKindType::Follow),
-            SyntaxKind::ConversionP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Copy => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cost => Some(SyntaxKindType::Follow),
-            SyntaxKind::Create => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cross => Some(SyntaxKindType::Follow),
-            SyntaxKind::Csv => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cube => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentP => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentCatalog => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentDate => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentRole => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentSchema => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentTime => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentTimestamp => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentUser => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cursor => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cycle => Some(SyntaxKindType::Follow),
-            SyntaxKind::DataP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Database => Some(SyntaxKindType::Follow),
-            SyntaxKind::DayP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Deallocate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Dec => Some(SyntaxKindType::Follow),
-            SyntaxKind::DecimalP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Declare => Some(SyntaxKindType::Follow),
-            SyntaxKind::Default => Some(SyntaxKindType::Follow),
-            SyntaxKind::Defaults => Some(SyntaxKindType::Follow),
-            SyntaxKind::Deferrable => Some(SyntaxKindType::Follow),
-            SyntaxKind::Deferred => Some(SyntaxKindType::Follow),
-            SyntaxKind::Definer => Some(SyntaxKindType::Follow),
-            SyntaxKind::DeleteP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Delimiter => Some(SyntaxKindType::Follow),
-            SyntaxKind::Delimiters => Some(SyntaxKindType::Follow),
-            SyntaxKind::Depends => Some(SyntaxKindType::Follow),
-            SyntaxKind::Desc => Some(SyntaxKindType::Follow),
-            SyntaxKind::Detach => Some(SyntaxKindType::Follow),
-            SyntaxKind::Dictionary => Some(SyntaxKindType::Follow),
-            SyntaxKind::DisableP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Discard => Some(SyntaxKindType::Follow),
-            SyntaxKind::Distinct => Some(SyntaxKindType::Follow),
-            SyntaxKind::Do => Some(SyntaxKindType::Follow),
-            SyntaxKind::DocumentP => Some(SyntaxKindType::Follow),
-            SyntaxKind::DomainP => Some(SyntaxKindType::Follow),
-            SyntaxKind::DoubleP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Drop => Some(SyntaxKindType::Follow),
-            SyntaxKind::Each => Some(SyntaxKindType::Follow),
-            SyntaxKind::Else => Some(SyntaxKindType::Follow),
-            SyntaxKind::EnableP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Encoding => Some(SyntaxKindType::Follow),
-            SyntaxKind::Encrypted => Some(SyntaxKindType::Follow),
-            SyntaxKind::EndP => Some(SyntaxKindType::Follow),
-            SyntaxKind::EnumP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Escape => Some(SyntaxKindType::Follow),
-            SyntaxKind::Event => Some(SyntaxKindType::Follow),
-            SyntaxKind::Except => Some(SyntaxKindType::Follow),
-            SyntaxKind::Exclude => Some(SyntaxKindType::Follow),
-            SyntaxKind::Excluding => Some(SyntaxKindType::Follow),
-            SyntaxKind::Exclusive => Some(SyntaxKindType::Follow),
-            SyntaxKind::Execute => Some(SyntaxKindType::Follow),
-            SyntaxKind::Exists => Some(SyntaxKindType::Follow),
-            SyntaxKind::Explain => Some(SyntaxKindType::Follow),
-            SyntaxKind::Expression => Some(SyntaxKindType::Follow),
-            SyntaxKind::Extension => Some(SyntaxKindType::Follow),
-            SyntaxKind::External => Some(SyntaxKindType::Follow),
-            SyntaxKind::Extract => Some(SyntaxKindType::Follow),
-            SyntaxKind::FalseP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Family => Some(SyntaxKindType::Follow),
-            SyntaxKind::Fetch => Some(SyntaxKindType::Follow),
-            SyntaxKind::Filter => Some(SyntaxKindType::Follow),
-            SyntaxKind::FirstP => Some(SyntaxKindType::Follow),
-            SyntaxKind::FloatP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Following => Some(SyntaxKindType::Follow),
-            SyntaxKind::For => Some(SyntaxKindType::Follow),
-            SyntaxKind::Force => Some(SyntaxKindType::Follow),
-            SyntaxKind::Foreign => Some(SyntaxKindType::Follow),
-            SyntaxKind::Forward => Some(SyntaxKindType::Follow),
-            SyntaxKind::Freeze => Some(SyntaxKindType::Follow),
-            SyntaxKind::From => Some(SyntaxKindType::Follow),
-            SyntaxKind::Full => Some(SyntaxKindType::Follow),
-            SyntaxKind::Function => Some(SyntaxKindType::Follow),
-            SyntaxKind::Functions => Some(SyntaxKindType::Follow),
-            SyntaxKind::Generated => Some(SyntaxKindType::Follow),
-            SyntaxKind::Global => Some(SyntaxKindType::Follow),
-            SyntaxKind::Grant => Some(SyntaxKindType::Follow),
-            SyntaxKind::Granted => Some(SyntaxKindType::Follow),
-            SyntaxKind::Greatest => Some(SyntaxKindType::Follow),
-            SyntaxKind::GroupP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Grouping => Some(SyntaxKindType::Follow),
-            SyntaxKind::Groups => Some(SyntaxKindType::Follow),
-            SyntaxKind::Handler => Some(SyntaxKindType::Follow),
-            SyntaxKind::Having => Some(SyntaxKindType::Follow),
-            SyntaxKind::HeaderP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Hold => Some(SyntaxKindType::Follow),
-            SyntaxKind::HourP => Some(SyntaxKindType::Follow),
-            SyntaxKind::IdentityP => Some(SyntaxKindType::Follow),
-            SyntaxKind::IfP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ilike => Some(SyntaxKindType::Follow),
-            SyntaxKind::Immediate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Immutable => Some(SyntaxKindType::Follow),
-            SyntaxKind::ImplicitP => Some(SyntaxKindType::Follow),
-            SyntaxKind::ImportP => Some(SyntaxKindType::Follow),
-            SyntaxKind::InP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Include => Some(SyntaxKindType::Follow),
-            SyntaxKind::Including => Some(SyntaxKindType::Follow),
-            SyntaxKind::Increment => Some(SyntaxKindType::Follow),
-            SyntaxKind::Index => Some(SyntaxKindType::Follow),
-            SyntaxKind::Indexes => Some(SyntaxKindType::Follow),
-            SyntaxKind::Inherit => Some(SyntaxKindType::Follow),
-            SyntaxKind::Inherits => Some(SyntaxKindType::Follow),
-            SyntaxKind::Initially => Some(SyntaxKindType::Follow),
-            SyntaxKind::InlineP => Some(SyntaxKindType::Follow),
-            SyntaxKind::InnerP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Inout => Some(SyntaxKindType::Follow),
-            SyntaxKind::InputP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Insensitive => Some(SyntaxKindType::Follow),
-            SyntaxKind::Insert => Some(SyntaxKindType::Follow),
-            SyntaxKind::Instead => Some(SyntaxKindType::Follow),
-            SyntaxKind::IntP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Integer => Some(SyntaxKindType::Follow),
-            SyntaxKind::Intersect => Some(SyntaxKindType::Follow),
-            SyntaxKind::Interval => Some(SyntaxKindType::Follow),
-            SyntaxKind::Into => Some(SyntaxKindType::Follow),
-            SyntaxKind::Invoker => Some(SyntaxKindType::Follow),
-            SyntaxKind::Is => Some(SyntaxKindType::Follow),
-            SyntaxKind::Isnull => Some(SyntaxKindType::Follow),
-            SyntaxKind::Isolation => Some(SyntaxKindType::Follow),
-            SyntaxKind::Join => Some(SyntaxKindType::Follow),
-            SyntaxKind::Key => Some(SyntaxKindType::Follow),
-            SyntaxKind::Label => Some(SyntaxKindType::Follow),
-            SyntaxKind::Language => Some(SyntaxKindType::Follow),
-            SyntaxKind::LargeP => Some(SyntaxKindType::Follow),
-            SyntaxKind::LastP => Some(SyntaxKindType::Follow),
-            SyntaxKind::LateralP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Leading => Some(SyntaxKindType::Follow),
-            SyntaxKind::Leakproof => Some(SyntaxKindType::Follow),
-            SyntaxKind::Least => Some(SyntaxKindType::Follow),
-            SyntaxKind::Left => Some(SyntaxKindType::Follow),
-            SyntaxKind::Level => Some(SyntaxKindType::Follow),
-            SyntaxKind::Like => Some(SyntaxKindType::Follow),
-            SyntaxKind::Limit => Some(SyntaxKindType::Follow),
-            SyntaxKind::Listen => Some(SyntaxKindType::Follow),
-            SyntaxKind::Load => Some(SyntaxKindType::Follow),
-            SyntaxKind::Local => Some(SyntaxKindType::Follow),
-            SyntaxKind::Localtime => Some(SyntaxKindType::Follow),
-            SyntaxKind::Localtimestamp => Some(SyntaxKindType::Follow),
-            SyntaxKind::Location => Some(SyntaxKindType::Follow),
-            SyntaxKind::LockP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Locked => Some(SyntaxKindType::Follow),
-            SyntaxKind::Logged => Some(SyntaxKindType::Follow),
-            SyntaxKind::Mapping => Some(SyntaxKindType::Follow),
-            SyntaxKind::Match => Some(SyntaxKindType::Follow),
-            SyntaxKind::Materialized => Some(SyntaxKindType::Follow),
-            SyntaxKind::Maxvalue => Some(SyntaxKindType::Follow),
-            SyntaxKind::Method => Some(SyntaxKindType::Follow),
-            SyntaxKind::MinuteP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Minvalue => Some(SyntaxKindType::Follow),
-            SyntaxKind::Mode => Some(SyntaxKindType::Follow),
-            SyntaxKind::MonthP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Move => Some(SyntaxKindType::Follow),
-            SyntaxKind::NameP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Names => Some(SyntaxKindType::Follow),
-            SyntaxKind::National => Some(SyntaxKindType::Follow),
-            SyntaxKind::Natural => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nchar => Some(SyntaxKindType::Follow),
-            SyntaxKind::New => Some(SyntaxKindType::Follow),
-            SyntaxKind::Next => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nfc => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nfd => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nfkc => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nfkd => Some(SyntaxKindType::Follow),
-            SyntaxKind::No => Some(SyntaxKindType::Follow),
-            SyntaxKind::None => Some(SyntaxKindType::Follow),
-            SyntaxKind::Normalize => Some(SyntaxKindType::Follow),
-            SyntaxKind::Normalized => Some(SyntaxKindType::Follow),
-            SyntaxKind::Not => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nothing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Notify => Some(SyntaxKindType::Follow),
-            SyntaxKind::Notnull => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nowait => Some(SyntaxKindType::Follow),
-            SyntaxKind::NullP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nullif => Some(SyntaxKindType::Follow),
-            SyntaxKind::NullsP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Numeric => Some(SyntaxKindType::Follow),
-            SyntaxKind::ObjectP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Of => Some(SyntaxKindType::Follow),
-            SyntaxKind::Off => Some(SyntaxKindType::Follow),
-            SyntaxKind::Offset => Some(SyntaxKindType::Follow),
-            SyntaxKind::Oids => Some(SyntaxKindType::Follow),
-            SyntaxKind::Old => Some(SyntaxKindType::Follow),
-            SyntaxKind::On => Some(SyntaxKindType::Follow),
-            SyntaxKind::Only => Some(SyntaxKindType::Follow),
-            SyntaxKind::Operator => Some(SyntaxKindType::Follow),
-            SyntaxKind::Option => Some(SyntaxKindType::Follow),
-            SyntaxKind::Options => Some(SyntaxKindType::Follow),
-            SyntaxKind::Or => Some(SyntaxKindType::Follow),
-            SyntaxKind::Order => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ordinality => Some(SyntaxKindType::Follow),
-            SyntaxKind::Others => Some(SyntaxKindType::Follow),
-            SyntaxKind::OutP => Some(SyntaxKindType::Follow),
-            SyntaxKind::OuterP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Over => Some(SyntaxKindType::Follow),
-            SyntaxKind::Overlaps => Some(SyntaxKindType::Follow),
-            SyntaxKind::Overlay => Some(SyntaxKindType::Follow),
-            SyntaxKind::Overriding => Some(SyntaxKindType::Follow),
-            SyntaxKind::Owned => Some(SyntaxKindType::Follow),
-            SyntaxKind::Owner => Some(SyntaxKindType::Follow),
-            SyntaxKind::Parallel => Some(SyntaxKindType::Follow),
-            SyntaxKind::Parser => Some(SyntaxKindType::Follow),
-            SyntaxKind::Partial => Some(SyntaxKindType::Follow),
-            SyntaxKind::Partition => Some(SyntaxKindType::Follow),
-            SyntaxKind::Passing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Password => Some(SyntaxKindType::Follow),
-            SyntaxKind::Placing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Plans => Some(SyntaxKindType::Follow),
-            SyntaxKind::Policy => Some(SyntaxKindType::Follow),
-            SyntaxKind::Position => Some(SyntaxKindType::Follow),
-            SyntaxKind::Preceding => Some(SyntaxKindType::Follow),
-            SyntaxKind::Precision => Some(SyntaxKindType::Follow),
-            SyntaxKind::Preserve => Some(SyntaxKindType::Follow),
-            SyntaxKind::Prepare => Some(SyntaxKindType::Follow),
-            SyntaxKind::Prepared => Some(SyntaxKindType::Follow),
-            SyntaxKind::Primary => Some(SyntaxKindType::Follow),
-            SyntaxKind::Prior => Some(SyntaxKindType::Follow),
-            SyntaxKind::Privileges => Some(SyntaxKindType::Follow),
-            SyntaxKind::Procedural => Some(SyntaxKindType::Follow),
-            SyntaxKind::Procedure => Some(SyntaxKindType::Follow),
-            SyntaxKind::Procedures => Some(SyntaxKindType::Follow),
-            SyntaxKind::Program => Some(SyntaxKindType::Follow),
-            SyntaxKind::Publication => Some(SyntaxKindType::Follow),
-            SyntaxKind::Quote => Some(SyntaxKindType::Follow),
-            SyntaxKind::Range => Some(SyntaxKindType::Follow),
-            SyntaxKind::Read => Some(SyntaxKindType::Follow),
-            SyntaxKind::Real => Some(SyntaxKindType::Follow),
-            SyntaxKind::Reassign => Some(SyntaxKindType::Follow),
-            SyntaxKind::Recheck => Some(SyntaxKindType::Follow),
-            SyntaxKind::Recursive => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ref => Some(SyntaxKindType::Follow),
-            SyntaxKind::References => Some(SyntaxKindType::Follow),
-            SyntaxKind::Referencing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Refresh => Some(SyntaxKindType::Follow),
-            SyntaxKind::Reindex => Some(SyntaxKindType::Follow),
-            SyntaxKind::RelativeP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Release => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rename => Some(SyntaxKindType::Follow),
-            SyntaxKind::Repeatable => Some(SyntaxKindType::Follow),
-            SyntaxKind::Replace => Some(SyntaxKindType::Follow),
-            SyntaxKind::Replica => Some(SyntaxKindType::Follow),
-            SyntaxKind::Reset => Some(SyntaxKindType::Follow),
-            SyntaxKind::Restart => Some(SyntaxKindType::Follow),
-            SyntaxKind::Restrict => Some(SyntaxKindType::Follow),
-            SyntaxKind::Returning => Some(SyntaxKindType::Follow),
-            SyntaxKind::Returns => Some(SyntaxKindType::Follow),
-            SyntaxKind::Revoke => Some(SyntaxKindType::Follow),
-            SyntaxKind::Right => Some(SyntaxKindType::Follow),
-            SyntaxKind::Role => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rollback => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rollup => Some(SyntaxKindType::Follow),
-            SyntaxKind::Routine => Some(SyntaxKindType::Follow),
-            SyntaxKind::Routines => Some(SyntaxKindType::Follow),
-            SyntaxKind::Row => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rows => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rule => Some(SyntaxKindType::Follow),
-            SyntaxKind::Savepoint => Some(SyntaxKindType::Follow),
-            SyntaxKind::Schema => Some(SyntaxKindType::Follow),
-            SyntaxKind::Schemas => Some(SyntaxKindType::Follow),
-            SyntaxKind::Scroll => Some(SyntaxKindType::Follow),
-            SyntaxKind::Search => Some(SyntaxKindType::Follow),
-            SyntaxKind::SecondP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Security => Some(SyntaxKindType::Follow),
-            SyntaxKind::Select => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sequence => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sequences => Some(SyntaxKindType::Follow),
-            SyntaxKind::Serializable => Some(SyntaxKindType::Follow),
-            SyntaxKind::Server => Some(SyntaxKindType::Follow),
-            SyntaxKind::Session => Some(SyntaxKindType::Follow),
-            SyntaxKind::SessionUser => Some(SyntaxKindType::Follow),
-            SyntaxKind::Set => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sets => Some(SyntaxKindType::Follow),
-            SyntaxKind::Setof => Some(SyntaxKindType::Follow),
-            SyntaxKind::Share => Some(SyntaxKindType::Follow),
-            SyntaxKind::Show => Some(SyntaxKindType::Follow),
-            SyntaxKind::Similar => Some(SyntaxKindType::Follow),
-            SyntaxKind::Simple => Some(SyntaxKindType::Follow),
-            SyntaxKind::Skip => Some(SyntaxKindType::Follow),
-            SyntaxKind::Smallint => Some(SyntaxKindType::Follow),
-            SyntaxKind::Snapshot => Some(SyntaxKindType::Follow),
-            SyntaxKind::Some => Some(SyntaxKindType::Follow),
-            SyntaxKind::SqlP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Stable => Some(SyntaxKindType::Follow),
-            SyntaxKind::StandaloneP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Start => Some(SyntaxKindType::Follow),
-            SyntaxKind::Statement => Some(SyntaxKindType::Follow),
-            SyntaxKind::Statistics => Some(SyntaxKindType::Follow),
-            SyntaxKind::Stdin => Some(SyntaxKindType::Follow),
-            SyntaxKind::Stdout => Some(SyntaxKindType::Follow),
-            SyntaxKind::Storage => Some(SyntaxKindType::Follow),
-            SyntaxKind::Stored => Some(SyntaxKindType::Follow),
-            SyntaxKind::StrictP => Some(SyntaxKindType::Follow),
-            SyntaxKind::StripP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Subscription => Some(SyntaxKindType::Follow),
-            SyntaxKind::Substring => Some(SyntaxKindType::Follow),
-            SyntaxKind::Support => Some(SyntaxKindType::Follow),
-            SyntaxKind::Symmetric => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sysid => Some(SyntaxKindType::Follow),
-            SyntaxKind::SystemP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Table => Some(SyntaxKindType::Follow),
-            SyntaxKind::Tables => Some(SyntaxKindType::Follow),
-            SyntaxKind::Tablesample => Some(SyntaxKindType::Follow),
-            SyntaxKind::Tablespace => Some(SyntaxKindType::Follow),
-            SyntaxKind::Temp => Some(SyntaxKindType::Follow),
-            SyntaxKind::Template => Some(SyntaxKindType::Follow),
-            SyntaxKind::Temporary => Some(SyntaxKindType::Follow),
-            SyntaxKind::TextP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Then => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ties => Some(SyntaxKindType::Follow),
-            SyntaxKind::Time => Some(SyntaxKindType::Follow),
-            SyntaxKind::Timestamp => Some(SyntaxKindType::Follow),
-            SyntaxKind::To => Some(SyntaxKindType::Follow),
-            SyntaxKind::Trailing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Transaction => Some(SyntaxKindType::Follow),
-            SyntaxKind::Transform => Some(SyntaxKindType::Follow),
-            SyntaxKind::Treat => Some(SyntaxKindType::Follow),
-            SyntaxKind::Trigger => Some(SyntaxKindType::Follow),
-            SyntaxKind::Trim => Some(SyntaxKindType::Follow),
-            SyntaxKind::TrueP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Truncate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Trusted => Some(SyntaxKindType::Follow),
-            SyntaxKind::TypeP => Some(SyntaxKindType::Follow),
-            SyntaxKind::TypesP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Uescape => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unbounded => Some(SyntaxKindType::Follow),
-            SyntaxKind::Uncommitted => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unencrypted => Some(SyntaxKindType::Follow),
-            SyntaxKind::Union => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unique => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unknown => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unlisten => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unlogged => Some(SyntaxKindType::Follow),
-            SyntaxKind::Until => Some(SyntaxKindType::Follow),
-            SyntaxKind::Update => Some(SyntaxKindType::Follow),
-            SyntaxKind::User => Some(SyntaxKindType::Follow),
-            SyntaxKind::Using => Some(SyntaxKindType::Follow),
-            SyntaxKind::Vacuum => Some(SyntaxKindType::Follow),
-            SyntaxKind::Valid => Some(SyntaxKindType::Follow),
-            SyntaxKind::Validate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Validator => Some(SyntaxKindType::Follow),
-            SyntaxKind::ValueP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Values => Some(SyntaxKindType::Follow),
-            SyntaxKind::Varchar => Some(SyntaxKindType::Follow),
-            SyntaxKind::Variadic => Some(SyntaxKindType::Follow),
-            SyntaxKind::Varying => Some(SyntaxKindType::Follow),
-            SyntaxKind::Verbose => Some(SyntaxKindType::Follow),
-            SyntaxKind::VersionP => Some(SyntaxKindType::Follow),
-            SyntaxKind::View => Some(SyntaxKindType::Follow),
-            SyntaxKind::Views => Some(SyntaxKindType::Follow),
-            SyntaxKind::Volatile => Some(SyntaxKindType::Follow),
-            SyntaxKind::When => Some(SyntaxKindType::Follow),
-            SyntaxKind::Where => Some(SyntaxKindType::Follow),
-            SyntaxKind::WhitespaceP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Window => Some(SyntaxKindType::Follow),
-            SyntaxKind::With => Some(SyntaxKindType::Follow),
-            SyntaxKind::Within => Some(SyntaxKindType::Follow),
-            SyntaxKind::Without => Some(SyntaxKindType::Follow),
-            SyntaxKind::Work => Some(SyntaxKindType::Follow),
-            SyntaxKind::Wrapper => Some(SyntaxKindType::Follow),
-            SyntaxKind::Write => Some(SyntaxKindType::Follow),
-            SyntaxKind::XmlP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlattributes => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlconcat => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlelement => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlexists => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlforest => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlnamespaces => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlparse => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlpi => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlroot => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlserialize => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmltable => Some(SyntaxKindType::Follow),
-            SyntaxKind::YearP => Some(SyntaxKindType::Follow),
-            SyntaxKind::YesP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Zone => Some(SyntaxKindType::Follow),
-            SyntaxKind::NotLa => Some(SyntaxKindType::Follow),
-            SyntaxKind::NullsLa => Some(SyntaxKindType::Follow),
-            SyntaxKind::WithLa => Some(SyntaxKindType::Follow),
-            SyntaxKind::Postfixop => Some(SyntaxKindType::Follow),
-            SyntaxKind::Uminus => Some(SyntaxKindType::Follow),
-            _ => None,
-        }
-    }
-}
diff --git a/crates/parser/src/syntax_kind_generated.rs b/crates/parser/src/syntax_kind_generated.rs
index 028a59c8..e03a3130 100644
--- a/crates/parser/src/syntax_kind_generated.rs
+++ b/crates/parser/src/syntax_kind_generated.rs
@@ -761,39 +761,6 @@ pub enum SyntaxKind {
     Uminus,
 }
 
-///
-///  Kind of a `SyntaxKind`
-///  This is the only manual definition required for properly creating a concrete
-/// syntax tree.
-///  If a token is of type `Follow`, it is not immediately applied to the syntax
-/// tree, but put into
-///  a buffer. Before the next node is started, all buffered tokens are applied
-/// to the syntax tree
-///  at the depth of the node that is opened next.
-///
-///  For example, in `select * from contact;`, the whitespace between `*` and
-/// `from` should be a direct
-///  child of the `SelectStmt` node. Without this concept, it would be put into
-/// the `ColumnRef`
-///  node.
-///
-///  SelectStmt@0..22
-///    Select@0..6 "select"
-///    Whitespace@6..7 " "
-///    ResTarget@7..8
-///      ColumnRef@7..8
-///        Ascii42@7..8 "*"
-///    Whitespace@8..9 " "
-///    From@9..13 "from"
-///   Whitespace@13..14 " "
-///    RangeVar@14..21
-///      Ident@14..21 "contact"
-///    Ascii59@21..22 ";"
-pub enum SyntaxKindType {
-    Follow,
-    Close,
-}
-
 impl SyntaxKind {
     /// Converts a `pg_query` node to a `SyntaxKind`
     pub fn new_from_pg_query_node(node: &NodeEnum) -> Self {
@@ -1553,522 +1520,4 @@ impl SyntaxKind {
             _ => panic!("Unknown token"),
         }
     }
-
-    /// Returns the `SyntaxKindType` of a `SyntaxKind`
-    pub fn get_type(&self) -> Option<SyntaxKindType> {
-        match self {
-            SyntaxKind::Nul => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii37 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii40 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii41 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii42 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii43 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii44 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii45 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii46 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii47 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii58 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii59 => Some(SyntaxKindType::Close),
-            SyntaxKind::Ascii60 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii61 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii62 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii63 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii91 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii92 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii93 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ascii94 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ident => Some(SyntaxKindType::Follow),
-            SyntaxKind::Uident => Some(SyntaxKindType::Follow),
-            SyntaxKind::Fconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Usconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Bconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Op => Some(SyntaxKindType::Follow),
-            SyntaxKind::Iconst => Some(SyntaxKindType::Follow),
-            SyntaxKind::Param => Some(SyntaxKindType::Follow),
-            SyntaxKind::Typecast => Some(SyntaxKindType::Follow),
-            SyntaxKind::DotDot => Some(SyntaxKindType::Follow),
-            SyntaxKind::ColonEquals => Some(SyntaxKindType::Follow),
-            SyntaxKind::EqualsGreater => Some(SyntaxKindType::Follow),
-            SyntaxKind::LessEquals => Some(SyntaxKindType::Follow),
-            SyntaxKind::GreaterEquals => Some(SyntaxKindType::Follow),
-            SyntaxKind::NotEquals => Some(SyntaxKindType::Follow),
-            SyntaxKind::SqlComment => Some(SyntaxKindType::Follow),
-            SyntaxKind::CComment => Some(SyntaxKindType::Follow),
-            SyntaxKind::AbortP => Some(SyntaxKindType::Follow),
-            SyntaxKind::AbsoluteP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Access => Some(SyntaxKindType::Follow),
-            SyntaxKind::Action => Some(SyntaxKindType::Follow),
-            SyntaxKind::AddP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Admin => Some(SyntaxKindType::Follow),
-            SyntaxKind::After => Some(SyntaxKindType::Follow),
-            SyntaxKind::Aggregate => Some(SyntaxKindType::Follow),
-            SyntaxKind::All => Some(SyntaxKindType::Follow),
-            SyntaxKind::Also => Some(SyntaxKindType::Follow),
-            SyntaxKind::Alter => Some(SyntaxKindType::Follow),
-            SyntaxKind::Always => Some(SyntaxKindType::Follow),
-            SyntaxKind::Analyse => Some(SyntaxKindType::Follow),
-            SyntaxKind::Analyze => Some(SyntaxKindType::Follow),
-            SyntaxKind::And => Some(SyntaxKindType::Follow),
-            SyntaxKind::Any => Some(SyntaxKindType::Follow),
-            SyntaxKind::Array => Some(SyntaxKindType::Follow),
-            SyntaxKind::As => Some(SyntaxKindType::Follow),
-            SyntaxKind::Asc => Some(SyntaxKindType::Follow),
-            SyntaxKind::Asensitive => Some(SyntaxKindType::Follow),
-            SyntaxKind::Assertion => Some(SyntaxKindType::Follow),
-            SyntaxKind::Assignment => Some(SyntaxKindType::Follow),
-            SyntaxKind::Asymmetric => Some(SyntaxKindType::Follow),
-            SyntaxKind::Atomic => Some(SyntaxKindType::Follow),
-            SyntaxKind::At => Some(SyntaxKindType::Follow),
-            SyntaxKind::Attach => Some(SyntaxKindType::Follow),
-            SyntaxKind::Attribute => Some(SyntaxKindType::Follow),
-            SyntaxKind::Authorization => Some(SyntaxKindType::Follow),
-            SyntaxKind::Backward => Some(SyntaxKindType::Follow),
-            SyntaxKind::Before => Some(SyntaxKindType::Follow),
-            SyntaxKind::BeginP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Between => Some(SyntaxKindType::Follow),
-            SyntaxKind::Bigint => Some(SyntaxKindType::Follow),
-            SyntaxKind::Binary => Some(SyntaxKindType::Follow),
-            SyntaxKind::Bit => Some(SyntaxKindType::Follow),
-            SyntaxKind::BooleanP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Both => Some(SyntaxKindType::Follow),
-            SyntaxKind::Breadth => Some(SyntaxKindType::Follow),
-            SyntaxKind::By => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cache => Some(SyntaxKindType::Follow),
-            SyntaxKind::Call => Some(SyntaxKindType::Follow),
-            SyntaxKind::Called => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cascade => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cascaded => Some(SyntaxKindType::Follow),
-            SyntaxKind::Case => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cast => Some(SyntaxKindType::Follow),
-            SyntaxKind::CatalogP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Chain => Some(SyntaxKindType::Follow),
-            SyntaxKind::CharP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Character => Some(SyntaxKindType::Follow),
-            SyntaxKind::Characteristics => Some(SyntaxKindType::Follow),
-            SyntaxKind::Check => Some(SyntaxKindType::Follow),
-            SyntaxKind::Checkpoint => Some(SyntaxKindType::Follow),
-            SyntaxKind::Class => Some(SyntaxKindType::Follow),
-            SyntaxKind::Close => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cluster => Some(SyntaxKindType::Follow),
-            SyntaxKind::Coalesce => Some(SyntaxKindType::Follow),
-            SyntaxKind::Collate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Collation => Some(SyntaxKindType::Follow),
-            SyntaxKind::Column => Some(SyntaxKindType::Follow),
-            SyntaxKind::Columns => Some(SyntaxKindType::Follow),
-            SyntaxKind::Comment => Some(SyntaxKindType::Follow),
-            SyntaxKind::Comments => Some(SyntaxKindType::Follow),
-            SyntaxKind::Commit => Some(SyntaxKindType::Follow),
-            SyntaxKind::Committed => Some(SyntaxKindType::Follow),
-            SyntaxKind::Compression => Some(SyntaxKindType::Follow),
-            SyntaxKind::Concurrently => Some(SyntaxKindType::Follow),
-            SyntaxKind::Configuration => Some(SyntaxKindType::Follow),
-            SyntaxKind::Conflict => Some(SyntaxKindType::Follow),
-            SyntaxKind::Connection => Some(SyntaxKindType::Follow),
-            SyntaxKind::Constraint => Some(SyntaxKindType::Follow),
-            SyntaxKind::Constraints => Some(SyntaxKindType::Follow),
-            SyntaxKind::ContentP => Some(SyntaxKindType::Follow),
-            SyntaxKind::ContinueP => Some(SyntaxKindType::Follow),
-            SyntaxKind::ConversionP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Copy => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cost => Some(SyntaxKindType::Follow),
-            SyntaxKind::Create => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cross => Some(SyntaxKindType::Follow),
-            SyntaxKind::Csv => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cube => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentP => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentCatalog => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentDate => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentRole => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentSchema => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentTime => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentTimestamp => Some(SyntaxKindType::Follow),
-            SyntaxKind::CurrentUser => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cursor => Some(SyntaxKindType::Follow),
-            SyntaxKind::Cycle => Some(SyntaxKindType::Follow),
-            SyntaxKind::DataP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Database => Some(SyntaxKindType::Follow),
-            SyntaxKind::DayP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Deallocate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Dec => Some(SyntaxKindType::Follow),
-            SyntaxKind::DecimalP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Declare => Some(SyntaxKindType::Follow),
-            SyntaxKind::Default => Some(SyntaxKindType::Follow),
-            SyntaxKind::Defaults => Some(SyntaxKindType::Follow),
-            SyntaxKind::Deferrable => Some(SyntaxKindType::Follow),
-            SyntaxKind::Deferred => Some(SyntaxKindType::Follow),
-            SyntaxKind::Definer => Some(SyntaxKindType::Follow),
-            SyntaxKind::DeleteP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Delimiter => Some(SyntaxKindType::Follow),
-            SyntaxKind::Delimiters => Some(SyntaxKindType::Follow),
-            SyntaxKind::Depends => Some(SyntaxKindType::Follow),
-            SyntaxKind::Depth => Some(SyntaxKindType::Follow),
-            SyntaxKind::Desc => Some(SyntaxKindType::Follow),
-            SyntaxKind::Detach => Some(SyntaxKindType::Follow),
-            SyntaxKind::Dictionary => Some(SyntaxKindType::Follow),
-            SyntaxKind::DisableP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Discard => Some(SyntaxKindType::Follow),
-            SyntaxKind::Distinct => Some(SyntaxKindType::Follow),
-            SyntaxKind::Do => Some(SyntaxKindType::Follow),
-            SyntaxKind::DocumentP => Some(SyntaxKindType::Follow),
-            SyntaxKind::DomainP => Some(SyntaxKindType::Follow),
-            SyntaxKind::DoubleP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Drop => Some(SyntaxKindType::Follow),
-            SyntaxKind::Each => Some(SyntaxKindType::Follow),
-            SyntaxKind::Else => Some(SyntaxKindType::Follow),
-            SyntaxKind::EnableP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Encoding => Some(SyntaxKindType::Follow),
-            SyntaxKind::Encrypted => Some(SyntaxKindType::Follow),
-            SyntaxKind::EndP => Some(SyntaxKindType::Follow),
-            SyntaxKind::EnumP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Escape => Some(SyntaxKindType::Follow),
-            SyntaxKind::Event => Some(SyntaxKindType::Follow),
-            SyntaxKind::Except => Some(SyntaxKindType::Follow),
-            SyntaxKind::Exclude => Some(SyntaxKindType::Follow),
-            SyntaxKind::Excluding => Some(SyntaxKindType::Follow),
-            SyntaxKind::Exclusive => Some(SyntaxKindType::Follow),
-            SyntaxKind::Execute => Some(SyntaxKindType::Follow),
-            SyntaxKind::Exists => Some(SyntaxKindType::Follow),
-            SyntaxKind::Explain => Some(SyntaxKindType::Follow),
-            SyntaxKind::Expression => Some(SyntaxKindType::Follow),
-            SyntaxKind::Extension => Some(SyntaxKindType::Follow),
-            SyntaxKind::External => Some(SyntaxKindType::Follow),
-            SyntaxKind::Extract => Some(SyntaxKindType::Follow),
-            SyntaxKind::FalseP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Family => Some(SyntaxKindType::Follow),
-            SyntaxKind::Fetch => Some(SyntaxKindType::Follow),
-            SyntaxKind::Filter => Some(SyntaxKindType::Follow),
-            SyntaxKind::Finalize => Some(SyntaxKindType::Follow),
-            SyntaxKind::FirstP => Some(SyntaxKindType::Follow),
-            SyntaxKind::FloatP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Following => Some(SyntaxKindType::Follow),
-            SyntaxKind::For => Some(SyntaxKindType::Follow),
-            SyntaxKind::Force => Some(SyntaxKindType::Follow),
-            SyntaxKind::Foreign => Some(SyntaxKindType::Follow),
-            SyntaxKind::Forward => Some(SyntaxKindType::Follow),
-            SyntaxKind::Freeze => Some(SyntaxKindType::Follow),
-            SyntaxKind::From => Some(SyntaxKindType::Follow),
-            SyntaxKind::Full => Some(SyntaxKindType::Follow),
-            SyntaxKind::Function => Some(SyntaxKindType::Follow),
-            SyntaxKind::Functions => Some(SyntaxKindType::Follow),
-            SyntaxKind::Generated => Some(SyntaxKindType::Follow),
-            SyntaxKind::Global => Some(SyntaxKindType::Follow),
-            SyntaxKind::Grant => Some(SyntaxKindType::Follow),
-            SyntaxKind::Granted => Some(SyntaxKindType::Follow),
-            SyntaxKind::Greatest => Some(SyntaxKindType::Follow),
-            SyntaxKind::GroupP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Grouping => Some(SyntaxKindType::Follow),
-            SyntaxKind::Groups => Some(SyntaxKindType::Follow),
-            SyntaxKind::Handler => Some(SyntaxKindType::Follow),
-            SyntaxKind::Having => Some(SyntaxKindType::Follow),
-            SyntaxKind::HeaderP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Hold => Some(SyntaxKindType::Follow),
-            SyntaxKind::HourP => Some(SyntaxKindType::Follow),
-            SyntaxKind::IdentityP => Some(SyntaxKindType::Follow),
-            SyntaxKind::IfP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ilike => Some(SyntaxKindType::Follow),
-            SyntaxKind::Immediate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Immutable => Some(SyntaxKindType::Follow),
-            SyntaxKind::ImplicitP => Some(SyntaxKindType::Follow),
-            SyntaxKind::ImportP => Some(SyntaxKindType::Follow),
-            SyntaxKind::InP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Include => Some(SyntaxKindType::Follow),
-            SyntaxKind::Including => Some(SyntaxKindType::Follow),
-            SyntaxKind::Increment => Some(SyntaxKindType::Follow),
-            SyntaxKind::Index => Some(SyntaxKindType::Follow),
-            SyntaxKind::Indexes => Some(SyntaxKindType::Follow),
-            SyntaxKind::Inherit => Some(SyntaxKindType::Follow),
-            SyntaxKind::Inherits => Some(SyntaxKindType::Follow),
-            SyntaxKind::Initially => Some(SyntaxKindType::Follow),
-            SyntaxKind::InlineP => Some(SyntaxKindType::Follow),
-            SyntaxKind::InnerP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Inout => Some(SyntaxKindType::Follow),
-            SyntaxKind::InputP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Insensitive => Some(SyntaxKindType::Follow),
-            SyntaxKind::Insert => Some(SyntaxKindType::Follow),
-            SyntaxKind::Instead => Some(SyntaxKindType::Follow),
-            SyntaxKind::IntP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Integer => Some(SyntaxKindType::Follow),
-            SyntaxKind::Intersect => Some(SyntaxKindType::Follow),
-            SyntaxKind::Interval => Some(SyntaxKindType::Follow),
-            SyntaxKind::Into => Some(SyntaxKindType::Follow),
-            SyntaxKind::Invoker => Some(SyntaxKindType::Follow),
-            SyntaxKind::Is => Some(SyntaxKindType::Follow),
-            SyntaxKind::Isnull => Some(SyntaxKindType::Follow),
-            SyntaxKind::Isolation => Some(SyntaxKindType::Follow),
-            SyntaxKind::Join => Some(SyntaxKindType::Follow),
-            SyntaxKind::Key => Some(SyntaxKindType::Follow),
-            SyntaxKind::Label => Some(SyntaxKindType::Follow),
-            SyntaxKind::Language => Some(SyntaxKindType::Follow),
-            SyntaxKind::LargeP => Some(SyntaxKindType::Follow),
-            SyntaxKind::LastP => Some(SyntaxKindType::Follow),
-            SyntaxKind::LateralP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Leading => Some(SyntaxKindType::Follow),
-            SyntaxKind::Leakproof => Some(SyntaxKindType::Follow),
-            SyntaxKind::Least => Some(SyntaxKindType::Follow),
-            SyntaxKind::Left => Some(SyntaxKindType::Follow),
-            SyntaxKind::Level => Some(SyntaxKindType::Follow),
-            SyntaxKind::Like => Some(SyntaxKindType::Follow),
-            SyntaxKind::Limit => Some(SyntaxKindType::Follow),
-            SyntaxKind::Listen => Some(SyntaxKindType::Follow),
-            SyntaxKind::Load => Some(SyntaxKindType::Follow),
-            SyntaxKind::Local => Some(SyntaxKindType::Follow),
-            SyntaxKind::Localtime => Some(SyntaxKindType::Follow),
-            SyntaxKind::Localtimestamp => Some(SyntaxKindType::Follow),
-            SyntaxKind::Location => Some(SyntaxKindType::Follow),
-            SyntaxKind::LockP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Locked => Some(SyntaxKindType::Follow),
-            SyntaxKind::Logged => Some(SyntaxKindType::Follow),
-            SyntaxKind::Mapping => Some(SyntaxKindType::Follow),
-            SyntaxKind::Match => Some(SyntaxKindType::Follow),
-            SyntaxKind::Matched => Some(SyntaxKindType::Follow),
-            SyntaxKind::Materialized => Some(SyntaxKindType::Follow),
-            SyntaxKind::Maxvalue => Some(SyntaxKindType::Follow),
-            SyntaxKind::Merge => Some(SyntaxKindType::Follow),
-            SyntaxKind::Method => Some(SyntaxKindType::Follow),
-            SyntaxKind::MinuteP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Minvalue => Some(SyntaxKindType::Follow),
-            SyntaxKind::Mode => Some(SyntaxKindType::Follow),
-            SyntaxKind::MonthP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Move => Some(SyntaxKindType::Follow),
-            SyntaxKind::NameP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Names => Some(SyntaxKindType::Follow),
-            SyntaxKind::National => Some(SyntaxKindType::Follow),
-            SyntaxKind::Natural => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nchar => Some(SyntaxKindType::Follow),
-            SyntaxKind::New => Some(SyntaxKindType::Follow),
-            SyntaxKind::Next => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nfc => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nfd => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nfkc => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nfkd => Some(SyntaxKindType::Follow),
-            SyntaxKind::No => Some(SyntaxKindType::Follow),
-            SyntaxKind::None => Some(SyntaxKindType::Follow),
-            SyntaxKind::Normalize => Some(SyntaxKindType::Follow),
-            SyntaxKind::Normalized => Some(SyntaxKindType::Follow),
-            SyntaxKind::Not => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nothing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Notify => Some(SyntaxKindType::Follow),
-            SyntaxKind::Notnull => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nowait => Some(SyntaxKindType::Follow),
-            SyntaxKind::NullP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Nullif => Some(SyntaxKindType::Follow),
-            SyntaxKind::NullsP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Numeric => Some(SyntaxKindType::Follow),
-            SyntaxKind::ObjectP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Of => Some(SyntaxKindType::Follow),
-            SyntaxKind::Off => Some(SyntaxKindType::Follow),
-            SyntaxKind::Offset => Some(SyntaxKindType::Follow),
-            SyntaxKind::Oids => Some(SyntaxKindType::Follow),
-            SyntaxKind::Old => Some(SyntaxKindType::Follow),
-            SyntaxKind::On => Some(SyntaxKindType::Follow),
-            SyntaxKind::Only => Some(SyntaxKindType::Follow),
-            SyntaxKind::Operator => Some(SyntaxKindType::Follow),
-            SyntaxKind::Option => Some(SyntaxKindType::Follow),
-            SyntaxKind::Options => Some(SyntaxKindType::Follow),
-            SyntaxKind::Or => Some(SyntaxKindType::Follow),
-            SyntaxKind::Order => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ordinality => Some(SyntaxKindType::Follow),
-            SyntaxKind::Others => Some(SyntaxKindType::Follow),
-            SyntaxKind::OutP => Some(SyntaxKindType::Follow),
-            SyntaxKind::OuterP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Over => Some(SyntaxKindType::Follow),
-            SyntaxKind::Overlaps => Some(SyntaxKindType::Follow),
-            SyntaxKind::Overlay => Some(SyntaxKindType::Follow),
-            SyntaxKind::Overriding => Some(SyntaxKindType::Follow),
-            SyntaxKind::Owned => Some(SyntaxKindType::Follow),
-            SyntaxKind::Owner => Some(SyntaxKindType::Follow),
-            SyntaxKind::Parallel => Some(SyntaxKindType::Follow),
-            SyntaxKind::Parameter => Some(SyntaxKindType::Follow),
-            SyntaxKind::Parser => Some(SyntaxKindType::Follow),
-            SyntaxKind::Partial => Some(SyntaxKindType::Follow),
-            SyntaxKind::Partition => Some(SyntaxKindType::Follow),
-            SyntaxKind::Passing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Password => Some(SyntaxKindType::Follow),
-            SyntaxKind::Placing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Plans => Some(SyntaxKindType::Follow),
-            SyntaxKind::Policy => Some(SyntaxKindType::Follow),
-            SyntaxKind::Position => Some(SyntaxKindType::Follow),
-            SyntaxKind::Preceding => Some(SyntaxKindType::Follow),
-            SyntaxKind::Precision => Some(SyntaxKindType::Follow),
-            SyntaxKind::Preserve => Some(SyntaxKindType::Follow),
-            SyntaxKind::Prepare => Some(SyntaxKindType::Follow),
-            SyntaxKind::Prepared => Some(SyntaxKindType::Follow),
-            SyntaxKind::Primary => Some(SyntaxKindType::Follow),
-            SyntaxKind::Prior => Some(SyntaxKindType::Follow),
-            SyntaxKind::Privileges => Some(SyntaxKindType::Follow),
-            SyntaxKind::Procedural => Some(SyntaxKindType::Follow),
-            SyntaxKind::Procedure => Some(SyntaxKindType::Follow),
-            SyntaxKind::Procedures => Some(SyntaxKindType::Follow),
-            SyntaxKind::Program => Some(SyntaxKindType::Follow),
-            SyntaxKind::Publication => Some(SyntaxKindType::Follow),
-            SyntaxKind::Quote => Some(SyntaxKindType::Follow),
-            SyntaxKind::Range => Some(SyntaxKindType::Follow),
-            SyntaxKind::Read => Some(SyntaxKindType::Follow),
-            SyntaxKind::Real => Some(SyntaxKindType::Follow),
-            SyntaxKind::Reassign => Some(SyntaxKindType::Follow),
-            SyntaxKind::Recheck => Some(SyntaxKindType::Follow),
-            SyntaxKind::Recursive => Some(SyntaxKindType::Follow),
-            SyntaxKind::RefP => Some(SyntaxKindType::Follow),
-            SyntaxKind::References => Some(SyntaxKindType::Follow),
-            SyntaxKind::Referencing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Refresh => Some(SyntaxKindType::Follow),
-            SyntaxKind::Reindex => Some(SyntaxKindType::Follow),
-            SyntaxKind::RelativeP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Release => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rename => Some(SyntaxKindType::Follow),
-            SyntaxKind::Repeatable => Some(SyntaxKindType::Follow),
-            SyntaxKind::Replace => Some(SyntaxKindType::Follow),
-            SyntaxKind::Replica => Some(SyntaxKindType::Follow),
-            SyntaxKind::Reset => Some(SyntaxKindType::Follow),
-            SyntaxKind::Restart => Some(SyntaxKindType::Follow),
-            SyntaxKind::Restrict => Some(SyntaxKindType::Follow),
-            SyntaxKind::Return => Some(SyntaxKindType::Follow),
-            SyntaxKind::Returning => Some(SyntaxKindType::Follow),
-            SyntaxKind::Returns => Some(SyntaxKindType::Follow),
-            SyntaxKind::Revoke => Some(SyntaxKindType::Follow),
-            SyntaxKind::Right => Some(SyntaxKindType::Follow),
-            SyntaxKind::Role => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rollback => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rollup => Some(SyntaxKindType::Follow),
-            SyntaxKind::Routine => Some(SyntaxKindType::Follow),
-            SyntaxKind::Routines => Some(SyntaxKindType::Follow),
-            SyntaxKind::Row => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rows => Some(SyntaxKindType::Follow),
-            SyntaxKind::Rule => Some(SyntaxKindType::Follow),
-            SyntaxKind::Savepoint => Some(SyntaxKindType::Follow),
-            SyntaxKind::Schema => Some(SyntaxKindType::Follow),
-            SyntaxKind::Schemas => Some(SyntaxKindType::Follow),
-            SyntaxKind::Scroll => Some(SyntaxKindType::Follow),
-            SyntaxKind::Search => Some(SyntaxKindType::Follow),
-            SyntaxKind::SecondP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Security => Some(SyntaxKindType::Follow),
-            SyntaxKind::Select => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sequence => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sequences => Some(SyntaxKindType::Follow),
-            SyntaxKind::Serializable => Some(SyntaxKindType::Follow),
-            SyntaxKind::Server => Some(SyntaxKindType::Follow),
-            SyntaxKind::Session => Some(SyntaxKindType::Follow),
-            SyntaxKind::SessionUser => Some(SyntaxKindType::Follow),
-            SyntaxKind::Set => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sets => Some(SyntaxKindType::Follow),
-            SyntaxKind::Setof => Some(SyntaxKindType::Follow),
-            SyntaxKind::Share => Some(SyntaxKindType::Follow),
-            SyntaxKind::Show => Some(SyntaxKindType::Follow),
-            SyntaxKind::Similar => Some(SyntaxKindType::Follow),
-            SyntaxKind::Simple => Some(SyntaxKindType::Follow),
-            SyntaxKind::Skip => Some(SyntaxKindType::Follow),
-            SyntaxKind::Smallint => Some(SyntaxKindType::Follow),
-            SyntaxKind::Snapshot => Some(SyntaxKindType::Follow),
-            SyntaxKind::Some => Some(SyntaxKindType::Follow),
-            SyntaxKind::SqlP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Stable => Some(SyntaxKindType::Follow),
-            SyntaxKind::StandaloneP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Start => Some(SyntaxKindType::Follow),
-            SyntaxKind::Statement => Some(SyntaxKindType::Follow),
-            SyntaxKind::Statistics => Some(SyntaxKindType::Follow),
-            SyntaxKind::Stdin => Some(SyntaxKindType::Follow),
-            SyntaxKind::Stdout => Some(SyntaxKindType::Follow),
-            SyntaxKind::Storage => Some(SyntaxKindType::Follow),
-            SyntaxKind::Stored => Some(SyntaxKindType::Follow),
-            SyntaxKind::StrictP => Some(SyntaxKindType::Follow),
-            SyntaxKind::StripP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Subscription => Some(SyntaxKindType::Follow),
-            SyntaxKind::Substring => Some(SyntaxKindType::Follow),
-            SyntaxKind::Support => Some(SyntaxKindType::Follow),
-            SyntaxKind::Symmetric => Some(SyntaxKindType::Follow),
-            SyntaxKind::Sysid => Some(SyntaxKindType::Follow),
-            SyntaxKind::SystemP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Table => Some(SyntaxKindType::Follow),
-            SyntaxKind::Tables => Some(SyntaxKindType::Follow),
-            SyntaxKind::Tablesample => Some(SyntaxKindType::Follow),
-            SyntaxKind::Tablespace => Some(SyntaxKindType::Follow),
-            SyntaxKind::Temp => Some(SyntaxKindType::Follow),
-            SyntaxKind::Template => Some(SyntaxKindType::Follow),
-            SyntaxKind::Temporary => Some(SyntaxKindType::Follow),
-            SyntaxKind::TextP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Then => Some(SyntaxKindType::Follow),
-            SyntaxKind::Ties => Some(SyntaxKindType::Follow),
-            SyntaxKind::Time => Some(SyntaxKindType::Follow),
-            SyntaxKind::Timestamp => Some(SyntaxKindType::Follow),
-            SyntaxKind::To => Some(SyntaxKindType::Follow),
-            SyntaxKind::Trailing => Some(SyntaxKindType::Follow),
-            SyntaxKind::Transaction => Some(SyntaxKindType::Follow),
-            SyntaxKind::Transform => Some(SyntaxKindType::Follow),
-            SyntaxKind::Treat => Some(SyntaxKindType::Follow),
-            SyntaxKind::Trigger => Some(SyntaxKindType::Follow),
-            SyntaxKind::Trim => Some(SyntaxKindType::Follow),
-            SyntaxKind::TrueP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Truncate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Trusted => Some(SyntaxKindType::Follow),
-            SyntaxKind::TypeP => Some(SyntaxKindType::Follow),
-            SyntaxKind::TypesP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Uescape => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unbounded => Some(SyntaxKindType::Follow),
-            SyntaxKind::Uncommitted => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unencrypted => Some(SyntaxKindType::Follow),
-            SyntaxKind::Union => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unique => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unknown => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unlisten => Some(SyntaxKindType::Follow),
-            SyntaxKind::Unlogged => Some(SyntaxKindType::Follow),
-            SyntaxKind::Until => Some(SyntaxKindType::Follow),
-            SyntaxKind::Update => Some(SyntaxKindType::Follow),
-            SyntaxKind::User => Some(SyntaxKindType::Follow),
-            SyntaxKind::Using => Some(SyntaxKindType::Follow),
-            SyntaxKind::Vacuum => Some(SyntaxKindType::Follow),
-            SyntaxKind::Valid => Some(SyntaxKindType::Follow),
-            SyntaxKind::Validate => Some(SyntaxKindType::Follow),
-            SyntaxKind::Validator => Some(SyntaxKindType::Follow),
-            SyntaxKind::ValueP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Values => Some(SyntaxKindType::Follow),
-            SyntaxKind::Varchar => Some(SyntaxKindType::Follow),
-            SyntaxKind::Variadic => Some(SyntaxKindType::Follow),
-            SyntaxKind::Varying => Some(SyntaxKindType::Follow),
-            SyntaxKind::Verbose => Some(SyntaxKindType::Follow),
-            SyntaxKind::VersionP => Some(SyntaxKindType::Follow),
-            SyntaxKind::View => Some(SyntaxKindType::Follow),
-            SyntaxKind::Views => Some(SyntaxKindType::Follow),
-            SyntaxKind::Volatile => Some(SyntaxKindType::Follow),
-            SyntaxKind::When => Some(SyntaxKindType::Follow),
-            SyntaxKind::Where => Some(SyntaxKindType::Follow),
-            SyntaxKind::WhitespaceP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Window => Some(SyntaxKindType::Follow),
-            SyntaxKind::With => Some(SyntaxKindType::Follow),
-            SyntaxKind::Within => Some(SyntaxKindType::Follow),
-            SyntaxKind::Without => Some(SyntaxKindType::Follow),
-            SyntaxKind::Work => Some(SyntaxKindType::Follow),
-            SyntaxKind::Wrapper => Some(SyntaxKindType::Follow),
-            SyntaxKind::Write => Some(SyntaxKindType::Follow),
-            SyntaxKind::XmlP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlattributes => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlconcat => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlelement => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlexists => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlforest => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlnamespaces => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlparse => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlpi => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlroot => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmlserialize => Some(SyntaxKindType::Follow),
-            SyntaxKind::Xmltable => Some(SyntaxKindType::Follow),
-            SyntaxKind::YearP => Some(SyntaxKindType::Follow),
-            SyntaxKind::YesP => Some(SyntaxKindType::Follow),
-            SyntaxKind::Zone => Some(SyntaxKindType::Follow),
-            SyntaxKind::NotLa => Some(SyntaxKindType::Follow),
-            SyntaxKind::NullsLa => Some(SyntaxKindType::Follow),
-            SyntaxKind::WithLa => Some(SyntaxKindType::Follow),
-            SyntaxKind::ModeTypeName => Some(SyntaxKindType::Follow),
-            SyntaxKind::ModePlpgsqlExpr => Some(SyntaxKindType::Follow),
-            SyntaxKind::ModePlpgsqlAssign1 => Some(SyntaxKindType::Follow),
-            SyntaxKind::ModePlpgsqlAssign2 => Some(SyntaxKindType::Follow),
-            SyntaxKind::ModePlpgsqlAssign3 => Some(SyntaxKindType::Follow),
-            SyntaxKind::Uminus => Some(SyntaxKindType::Follow),
-            SyntaxKind::Whitespace => Some(SyntaxKindType::Follow),
-            SyntaxKind::Newline => Some(SyntaxKindType::Follow),
-            SyntaxKind::Tab => Some(SyntaxKindType::Follow),
-            _ => None,
-        }
-    }
 }
diff --git a/crates/parser/src/token_type.rs b/crates/parser/src/token_type.rs
new file mode 100644
index 00000000..bd76b286
--- /dev/null
+++ b/crates/parser/src/token_type.rs
@@ -0,0 +1,91 @@
+use log::debug;
+use pg_query::protobuf::ScanToken;
+
+use crate::{statement::StatementToken, SyntaxKind};
+
+///
+///  Kind of a `SyntaxKind`
+///  This is the only manual definition required for properly creating a concrete
+/// syntax tree.
+///  If a token is of type `Follow`, it is not immediately applied to the syntax
+/// tree, but put into
+///  a buffer. Before the next node is started, all buffered tokens are applied
+/// to the syntax tree
+///  at the depth of the node that is opened next.
+///
+///  For example, in `select * from contact;`, the whitespace between `*` and
+/// `from` should be a direct
+///  child of the `SelectStmt` node. Without this concept, it would be put into
+/// the `ColumnRef`
+///  node.
+///
+///  SelectStmt@0..22
+///    Select@0..6 "select"
+///    Whitespace@6..7 " "
+///    ResTarget@7..8
+///      ColumnRef@7..8
+///        Ascii42@7..8 "*"
+///    Whitespace@8..9 " "
+///    From@9..13 "from"
+///   Whitespace@13..14 " "
+///    RangeVar@14..21
+///      Ident@14..21 "contact"
+///    Ascii59@21..22 ";"
+#[derive(Debug)]
+pub enum TokenType {
+    Follow,
+    Close,
+}
+
+pub fn get_token_type_from_statement_token(token: &StatementToken) -> Option<TokenType> {
+    match token {
+        StatementToken::Whitespace => Some(TokenType::Follow),
+        StatementToken::Newline => Some(TokenType::Follow),
+        _ => None,
+    }
+}
+
+pub fn get_token_type_from_pg_query_token(token: &ScanToken) -> Option<TokenType> {
+    let r = match token.keyword_kind() {
+        pg_query::protobuf::KeywordKind::NoKeyword => match token.token {
+            37 => Some(TokenType::Follow),
+            40 => Some(TokenType::Follow),
+            41 => Some(TokenType::Follow),
+            42 => Some(TokenType::Follow),
+            43 => Some(TokenType::Follow),
+            44 => Some(TokenType::Follow),
+            45 => Some(TokenType::Follow),
+            46 => Some(TokenType::Follow),
+            47 => Some(TokenType::Follow),
+            58 => Some(TokenType::Follow),
+            // ";"
+            59 => Some(TokenType::Close),
+            60 => Some(TokenType::Follow),
+            61 => Some(TokenType::Follow),
+            62 => Some(TokenType::Follow),
+            63 => Some(TokenType::Follow),
+            // 91 => Some(TokenType::Follow),
+            92 => Some(TokenType::Follow),
+            93 => Some(TokenType::Follow),
+            94 => Some(TokenType::Follow),
+            _ => None,
+        },
+        pg_query::protobuf::KeywordKind::UnreservedKeyword => None,
+        pg_query::protobuf::KeywordKind::ColNameKeyword => None,
+        pg_query::protobuf::KeywordKind::TypeFuncNameKeyword => None,
+        pg_query::protobuf::KeywordKind::ReservedKeyword => match token.token {
+            // End
+            401 => Some(TokenType::Follow),
+            // From
+            429 => Some(TokenType::Follow),
+            543 => Some(TokenType::Follow),
+            // Then
+            669 => Some(TokenType::Follow),
+            673 => Some(TokenType::Follow),
+            697 => Some(TokenType::Follow),
+            _ => None,
+        },
+    };
+    debug!("token: {:?}, token_type: {:?}", token, r);
+    r
+}

From 6825150f48ed367b4daa08bc65837d4c25094828 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Sat, 26 Aug 2023 16:06:49 +0200
Subject: [PATCH 11/23] chore: housekeeping

---
 crates/parser/src/bin/generate.rs             | 422 ------------------
 crates/parser/src/parser.rs                   |  20 +-
 crates/parser/src/pg_query_utils_generated.rs |  29 +-
 crates/parser/src/pg_query_utils_manual.rs    |  77 +++-
 crates/parser/src/source_file.rs              |   1 -
 crates/parser/src/statement.rs                |  41 +-
 crates/parser/src/token_type.rs               |  26 +-
 crates/postgres_lsp/src/main.rs               |   6 -
 8 files changed, 121 insertions(+), 501 deletions(-)
 delete mode 100644 crates/parser/src/bin/generate.rs

diff --git a/crates/parser/src/bin/generate.rs b/crates/parser/src/bin/generate.rs
deleted file mode 100644
index 7badaa0f..00000000
--- a/crates/parser/src/bin/generate.rs
+++ /dev/null
@@ -1,422 +0,0 @@
-use pg_query_proto_parser::{FieldType, ProtoFile, ProtoParser};
-use sourcegen::{
-    Attribute, Builder, Comment, Enum, Function, Implementation, Imports, Match, SourceFile, Struct,
-};
-use std::fs;
-
-fn main() {
-    let parser = ProtoParser::new("./proto/source.proto");
-    let file = parser.parse();
-
-    fs::write(
-        "./src/syntax_kind_generated.rs",
-        generate_syntax_kind(&file),
-    )
-    .unwrap();
-
-    fs::write(
-        "./src/pg_query_utils_generated.rs",
-        generate_pg_query_utils(&file),
-    )
-    .unwrap();
-}
-
-fn generate_pg_query_utils(f: &ProtoFile) -> String {
-    SourceFile::new()
-        .add_comment("Utilities for working with pg_query.rs".to_string())
-        .add_comment("This file is generated from the libg_query proto".to_string())
-        .add_block(
-            Imports::new()
-                .with_import(
-                    "pg_query".to_string(),
-                    vec!["NodeEnum".to_string()],
-                )
-                .with_import("std::collections".to_string(), vec!["VecDeque".to_string()])
-                .with_import("crate".to_string(), vec!["pg_query_utils_manual::derive_location".to_string()])
-                .finish(),
-        )
-        .add_block(
-            Function::new("get_location".to_string())
-                .public()
-                .with_parameter("node".to_string(), Some("&NodeEnum".to_string()))
-                .with_return_type("Option<i32>".to_string())
-                .with_body(
-                    Match::new("node".to_string())
-                        .with(|b| {
-                            f.nodes.iter().for_each(|node| {
-                                let mut right = "None";
-                                let mut left = format!("NodeEnum::{}(_)", node.name.to_string());
-                                if node
-                                    .fields
-                                    .iter()
-                                    .find(|n| {
-                                        n.name == "location" && n.field_type == FieldType::Int32
-                                    })
-                                    .is_some()
-                                {
-                                    right = "Some(n.location)";
-                                    left = format!("NodeEnum::{}(n)", node.name.to_string());
-                                }
-
-                                b.with_arm(left.to_string(), right.to_string());
-                            });
-                            b
-                        })
-                        .finish(),
-                )
-                .finish(),
-        )
-        .add_block(
-            Struct::new("NestedNode".to_string())
-            .public()
-            .with_attribute(
-                Attribute::new("derive".to_string())
-                .with_argument("Debug".to_string(), None)
-                .with_argument("Clone".to_string(), None)
-                .finish()
-            )
-            .with_field("node".to_string(), "NodeEnum".to_string(), true)
-            .with_field("depth".to_string(), "i32".to_string(), true)
-            .with_field("location".to_string(), "i32".to_string(), true)
-            .with_field("path".to_string(), "String".to_string(), true)
-            .finish()
-        )
-        .add_block(
-            Function::new("get_children".to_string())
-                .public()
-                .with_comment("Returns all children of the node, recursively".to_string())
-                .with_parameter("node".to_string(), Some("&NodeEnum".to_string()))
-                .with_parameter("text".to_string(), Some("String".to_string()))
-                .with_parameter("current_depth".to_string(), Some("i32".to_string()))
-                .with_return_type("Vec<NestedNode>".to_string())
-                .with(|b| {
-                    let mut content = "let mut nodes: Vec<NestedNode> = vec![];\n".to_string();
-                    content.push_str("// Node, depth, path\n");
-                    content.push_str("let mut stack: VecDeque<(NodeEnum, i32, String)> = VecDeque::from(vec![(node.to_owned(), current_depth, \"0\".to_string())]);");
-                    content.push_str("// Node, depth, path\n");
-                    content.push_str("let mut location_stack: VecDeque<(NodeEnum, i32, String)> = VecDeque::new();");
-                    content.push_str("while !stack.is_empty() || !location_stack.is_empty() {\n");
-                    content.push_str("if !stack.is_empty() {");
-                    content.push_str("let (node, depth, path) = stack.pop_front().unwrap();\n");
-                    content.push_str("let current_depth = depth + 1;\n");
-                    content.push_str("let mut child_ctr: i32 = 0;\n");
-                    content.push_str("let mut handle_child = |c: NodeEnum| {\n");
-                    content.push_str("let location = get_location(&c);\n");
-                    content.push_str("let path = path.clone() + \".\" + child_ctr.to_string().as_str();\n");
-                    content.push_str("child_ctr = child_ctr + 1;\n");
-                    content.push_str("stack.push_back((c.to_owned(), current_depth, path.clone()));\n");
-                    content.push_str("if location.is_some() {\n");
-                    content.push_str("nodes.push(NestedNode {\n");
-                    content.push_str("node: c,\n");
-                    content.push_str("depth: current_depth,\n");
-                    content.push_str("location: location.unwrap(),\n");
-                    content.push_str("path: path.clone(),\n");
-                    content.push_str("});\n");
-                    content.push_str("} else {\n");
-                    content.push_str("location_stack.push_back((c, current_depth, path));\n");
-                    content.push_str("}\n");
-                    content.push_str("};\n");
-
-                    let match_ = Match::new("&node".to_string())
-                        .with(|b| {
-                            f.nodes.iter().for_each(|node| {
-                                if node.name == "AConst" {
-                                    // AConst is the only node with one of, so we handle it
-                                    // manually
-                                    let content = "{
-            if n.val.is_some() {
-                handle_child(match n.val.to_owned().unwrap() {
-                    pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
-                    pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
-                    pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
-                    pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
-                    pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
-                });
-            }
-        }";
-
-                                    b.with_arm(
-                                        format!("NodeEnum::{}(n)", node.name.to_string()),
-                                        format!("{}", content),
-                                    );
-                                } else {
-                                    let mut field_content: Vec<String> = vec![];
-                                    node.fields.iter().for_each(|field| {
-                                        if field.field_type == FieldType::Node && field.repeated {
-                                            field_content.push(
-                                                format!(
-                                                    "n.{}.iter().for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));\n",
-                                                    field.name.to_string()
-                                                )
-                                            );
-                                        } else if field.field_type == FieldType::Node && field.is_one_of == false {
-                                            if field.node_name == Some("Node".to_owned()) {
-                                                let mut node_content = "".to_string();
-                                                node_content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
-                                                node_content.push_str(
-                                                    format!(
-                                                        "handle_child(n.{}.to_owned().unwrap().node.unwrap());\n",
-                                                        field.name.to_string()
-                                                    ).as_str(),
-                                                );
-                                                node_content.push_str("}\n");
-                                                field_content.push(node_content);
-                                            } else {
-                                                let mut node_content = "".to_string();
-                                                node_content.push_str(format!("if n.{}.is_some() {{\n", field.name.to_string()).as_str());
-                                                node_content.push_str(
-                                                    format!(
-                                                        "handle_child(NodeEnum::{}(n.{}.to_owned().unwrap()));\n",
-                                                        field.enum_variant_name.as_ref().unwrap(),
-                                                        field.name.to_string()
-                                                    )
-                                                    .as_str()
-                                                );
-                                                node_content.push_str("}\n");
-                                                field_content.push(node_content);
-                                            }
-                                        }
-                                    });
-
-                                    let content = if field_content.len() > 0 {
-                                        format!("{{\n{}\n}}", field_content.join("\n"))
-                                    } else {
-                                        "()".to_string()
-                                    };
-
-                                    b.with_arm(
-                                        format!("NodeEnum::{}(n)", node.name.to_string()),
-                                        format!("{}", content),
-                                    );
-                                }
-                            });
-
-                            b
-                        })
-                        .finish();
-
-                    content.push_str(match_.to_string().as_str());
-                    content.push_str(";\n");
-
-                    content.push_str("} else if !location_stack.is_empty() {\n");
-                    content.push_str("let (node, depth, path) = location_stack.pop_front().unwrap();\n");
-                    content.push_str("let parent_node = nodes.iter().find(|n| {\n");
-                    content.push_str("let mut path_elements = path.split(\".\").collect::<Vec<&str>>();\n");
-                    content.push_str("path_elements.pop();\n");
-                    content.push_str("let parent_path = path_elements.join(\".\");\n");
-                    content.push_str("n.path == parent_path\n");
-                    content.push_str("});\n");
-                    content.push_str("let parent_location = if parent_node.is_some() {\n");
-                    content.push_str("parent_node.unwrap().location\n");
-                    content.push_str("} else {\n");
-                    content.push_str("0\n");
-                    content.push_str("};\n");
-                    content.push_str("let earliest_child_location = nodes.iter().filter(|n| n.path.starts_with(path.as_str())).min_by(|a, b| a.location.cmp(&b.location)).map(|n| n.location);\n");
-                    content.push_str("let location = derive_location(&node, text.clone(), parent_location, earliest_child_location);\n");
-                    content.push_str("if location.is_some() {\n");
-                    content.push_str("nodes.push(NestedNode { node, depth, location: location.unwrap(), path: path.clone() });\n");
-                    content.push_str("}\n");
-                    content.push_str("}\n");
-                    content.push_str("}\n");
-
-
-                    content.push_str("nodes.sort_by_key(|n| n.location);\n");
-                    content.push_str("nodes");
-
-                    b.with_body(content);
-
-                    b
-                })
-                .finish(),
-        )
-        .finish()
-}
-
-fn generate_syntax_kind(f: &ProtoFile) -> String {
-    SourceFile::new()
-    .add_comment(
-        Comment::new("//!".to_string())
-        .with_text("This module bridges the gap between pg_query.rs nodes, and the `SyntaxKind` cstree requires.".to_string())
-        .with_text("The file is generated from the libg_query proto".to_string())
-        .finish()
-    )
-    .add_block(
-        Imports::new()
-        .with_import("cstree".to_string(), vec!["Syntax".to_string()])
-        .with_import("pg_query".to_string(), vec!["protobuf::ScanToken".to_string(), "NodeEnum".to_string()])
-        .finish()
-    )
-    .add_block(
-        Enum::new("SyntaxKind".to_string())
-        .public()
-        .with_comment("An u32 enum of all valid syntax elements (nodes and tokens) of the postgres sql dialect, and a few custom ones that are not parsed by pg_query.rs, such as `Whitespace`.".to_string())
-        .with_attribute(
-            Attribute::new("derive".to_string())
-            .with_argument("Copy".to_string(), None)
-            .with_argument("Clone".to_string(), None)
-            .with_argument("PartialEq".to_string(), None)
-            .with_argument("Eq".to_string(), None)
-            .with_argument("PartialOrd".to_string(), None)
-            .with_argument("Ord".to_string(), None)
-            .with_argument("Hash".to_string(), None)
-            .with_argument("Debug".to_string(), None)
-            .with_argument("Syntax".to_string(), None)
-            .finish()
-        )
-        .with_attribute(
-             Attribute::new("repr".to_string())
-            .with_argument("u32".to_string(), None)
-            .finish(),
-        )
-        .with(|b| {
-            vec![
-                "SourceFile".to_string(),
-                "Comment".to_string(),
-                "Whitespace".to_string(),
-                "Newline".to_string(),
-                "Tab".to_string(),
-                "Stmt".to_string(),
-            ].iter().for_each(|kind| {
-                b.with_value(kind.to_string(), None);
-            });
-
-            f.nodes.iter().for_each(|node| {
-                b.with_value(node.name.to_string(), None);
-            });
-
-            f.tokens.iter().for_each(|token| {
-                b.with_value(token.name.to_string(), None);
-            });
-
-            b
-        })
-        .finish()
-    )
-    .add_block(
-        Enum::new("SyntaxKindType".to_string())
-        .with_comment("
- Kind of a `SyntaxKind`
- This is the only manual definition required for properly creating a concrete syntax tree.
- If a token is of type `Follow`, it is not immediately applied to the syntax tree, but put into
- a buffer. Before the next node is started, all buffered tokens are applied to the syntax tree
- at the depth of the node that is opened next.
-
- For example, in `select * from contact;`, the whitespace between `*` and `from` should be a direct
- child of the `SelectStmt` node. Without this concept, it would be put into the `ColumnRef`
- node.
-
- SelectStmt@0..22
-   Select@0..6 \"select\"
-   Whitespace@6..7 \" \"
-   ResTarget@7..8
-     ColumnRef@7..8
-       Ascii42@7..8 \"*\"
-   Whitespace@8..9 \" \"
-   From@9..13 \"from\"
-  Whitespace@13..14 \" \"
-   RangeVar@14..21
-     Ident@14..21 \"contact\"
-   Ascii59@21..22 \";\"".to_string()
-   )
-        .public()
-        .with_value("Follow".to_string(), None)
-        .with_value("Close".to_string(), None)
-        .finish()
-    )
-    .add_block(
-        Implementation::new("SyntaxKind".to_string())
-        .add_block(
-            Function::new("new_from_pg_query_node".to_string())
-            .public()
-            .with_comment(
-                "Converts a `pg_query` node to a `SyntaxKind`".to_string()
-            )
-            .with_return_type("Self".to_string())
-            .with_parameter("node".to_string(), Some("&NodeEnum".to_string()))
-            .with_body(
-                Match::new("node".to_string())
-                .with(|b| {
-                    f.nodes.iter().for_each(|node| {
-                        b.with_arm(
-                            format!("NodeEnum::{}(_)", node.name.to_string()),
-                            format!("SyntaxKind::{}", node.name.to_string()),
-                        );
-                    });
-                    b
-                })
-                .finish()
-            )
-            .finish()
-        )
-        .add_block(
-            Function::new("new_from_pg_query_token".to_string())
-            .public()
-            .with_comment(
-                "Converts a `pg_query` token to a `SyntaxKind`".to_string()
-            )
-            .with_return_type("Self".to_string())
-            .with_parameter("token".to_string(), Some("&ScanToken".to_string()))
-            .with_body(
-                Match::new("token.token".to_string())
-               .with(|b| {
-                   f.tokens.iter().for_each(|token| {
-                       b.with_arm(
-                           token.value.to_string(),
-                           format!("SyntaxKind::{}", token.name.to_string()),
-                       );
-                   });
-                   b.with_arm("_".to_string(), "panic!(\"Unknown token\")".to_string());
-                   b
-               })
-               .finish()
-            )
-            .finish()
-        )
-        .add_block(
-            Function::new("get_type".to_string())
-            .public()
-            .with_comment(
-                "Returns the `SyntaxKindType` of a `SyntaxKind`".to_string()
-            )
-            .with_return_type("Option<SyntaxKindType>".to_string())
-            .with_parameter("&self".to_string(), None)
-            .with_body(
-                Match::new("self".to_string())
-               .with(|b| {
-                   f.tokens.iter().for_each(|token| {
-                       // Ascii59 (";") closes a statement
-                       let value = match token.name.to_string().as_str() {
-                            "Ascii59" => "Some(SyntaxKindType::Close)",
-                            _ => "Some(SyntaxKindType::Follow)",
-                       };
-                       b.with_arm(
-                           format!("SyntaxKind::{}", token.name.to_string()),
-                           value.to_string(),
-                        );
-                   });
-
-                    vec![
-                        "Whitespace".to_string(),
-                        "Newline".to_string(),
-                        "Tab".to_string(),
-                    ].iter().for_each(|kind| {
-                        b.with_arm(
-                            format!("SyntaxKind::{}", kind.to_string()),
-                            "Some(SyntaxKindType::Follow)".to_string()
-                        );
-                    });
-
-                   b.with_arm(
-                       "_".to_string(),
-                       "None".to_string(),
-                   );
-                   b
-               })
-               .finish()
-            )
-        .finish()
-    )
-    .finish()
-    )
-    .finish()
-}
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index 88c2bf34..e59d9878 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -1,9 +1,7 @@
-use std::collections::{HashMap, VecDeque};
-use std::ops::RangeBounds;
+use std::collections::VecDeque;
 
 use cstree::syntax::ResolvedNode;
 use cstree::{build::GreenNodeBuilder, text::TextRange};
-use log::debug;
 use pg_query::NodeEnum;
 
 use crate::ast_node::RawStmt;
@@ -65,11 +63,6 @@ impl Parser {
         if self.open_nodes.is_empty() || self.get_current_depth() < depth {
             return;
         }
-        debug!(
-            "close from depth {:?} until {:?}",
-            self.get_current_depth(),
-            depth
-        );
         loop {
             if self.open_nodes.is_empty() || self.get_current_depth() < depth {
                 break;
@@ -112,7 +105,6 @@ impl Parser {
     /// handles closing previous nodes if necessary
     /// and consumes token buffer before starting new node
     pub fn start_node_at(&mut self, kind: SyntaxKind, depth: i32) {
-        debug!("start node {:?} at depth: {:?}", kind, depth);
         // close until target depth
         self.close_until_depth(depth);
 
@@ -130,7 +122,6 @@ impl Parser {
             return;
         }
         let depth = self.get_current_depth();
-        debug!("close open tokens at depth: {:?}", depth);
         loop {
             if self.open_tokens.is_empty() || self.token_buffer.is_empty() {
                 break;
@@ -139,8 +130,6 @@ impl Parser {
             if token_depth != depth {
                 break;
             }
-            println!("token: {:?}", token);
-            println!("token_depth: {:?}", token_depth);
             // find closing token in token buffer
             let closing_token_pos = self
                 .token_buffer
@@ -167,8 +156,6 @@ impl Parser {
             panic!("No node to finish");
         }
 
-        let (node, depth) = n.unwrap();
-        debug!("finish node {:?} at {:?}", node, depth);
         self.inner.finish_node();
     }
 
@@ -181,9 +168,7 @@ impl Parser {
             Some(u) => 0..u as usize,
             None => 0..self.token_buffer.len(),
         };
-        debug!("consume token buffer {:?}", range);
         for (kind, text) in self.token_buffer.drain(range).collect::<VecDeque<_>>() {
-            debug!("consuming token: {:?} {:?}", kind, text);
             self.apply_token(kind, text.as_str());
         }
     }
@@ -194,7 +179,6 @@ impl Parser {
         self.inner.token(kind, text);
         if kind.is_opening_sibling() {
             let depth = self.get_current_depth();
-            debug!("open token {:?} at depth {:?}", kind, depth);
             self.open_tokens.push((kind, text.to_string(), depth));
         }
     }
@@ -219,13 +203,11 @@ impl Parser {
                 self.inner.token(kind, text);
             }
             Some(TokenType::Follow) => {
-                debug!("push to buffer token {:?} {:?}", kind, text);
                 // wait until next node, and apply token at same depth
                 self.token_buffer.push_back((kind, text.to_string()));
             }
             _ => {
                 self.consume_token_buffer(None);
-                debug!("apply token {:?} {:?}", kind, text);
                 self.apply_token(kind, text);
             }
         }
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index a719be6e..ce56722d 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -5,7 +5,7 @@ use pg_query::NodeEnum;
 use std::collections::VecDeque;
 
 pub fn get_location(node: &NodeEnum) -> Option<i32> {
-    match node {
+    let l = match node {
         NodeEnum::Alias(_) => None,
         NodeEnum::RangeVar(n) => Some(n.location),
         NodeEnum::TableFunc(n) => Some(n.location),
@@ -21,7 +21,14 @@ pub fn get_location(node: &NodeEnum) -> Option<i32> {
         NodeEnum::DistinctExpr(n) => Some(n.location),
         NodeEnum::NullIfExpr(n) => Some(n.location),
         NodeEnum::ScalarArrayOpExpr(n) => Some(n.location),
-        NodeEnum::BoolExpr(n) => Some(n.location),
+        NodeEnum::BoolExpr(n) => {
+            let a = n.args.iter().min_by(|a, b| {
+                let loc_a = get_location(&a.node.as_ref().unwrap());
+                let loc_b = get_location(&b.node.as_ref().unwrap());
+                loc_a.cmp(&loc_b)
+            });
+            get_location(&a.unwrap().node.as_ref().unwrap())
+        }
         NodeEnum::SubLink(n) => Some(n.location),
         NodeEnum::SubPlan(_) => None,
         NodeEnum::AlternativeSubPlan(_) => None,
@@ -244,6 +251,11 @@ pub fn get_location(node: &NodeEnum) -> Option<i32> {
         NodeEnum::IntList(_) => None,
         NodeEnum::OidList(_) => None,
         NodeEnum::AConst(n) => Some(n.location),
+    };
+    if l.is_some() && l.unwrap() < 0 {
+        None
+    } else {
+        l
     }
 }
 
@@ -2794,6 +2806,11 @@ pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<Ne
             } else {
                 0
             };
+            // FISME: we assume that at least one (nested) child location is known.
+            // this is not true for all nodes, e.g.
+            // `DROP TABLE tablename;`, where the location of the `List` node that wraps the String node `tablename` is not known
+            // in this case, we could try to "recover" by putting it back into the stack and trying
+            // again after all children are processed
             let earliest_child_location = nodes
                 .iter()
                 .filter(|n| n.path.starts_with(path.as_str()))
@@ -2812,9 +2829,15 @@ pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<Ne
                     location: location.unwrap(),
                     path: path.clone(),
                 });
+            } else if location_stack
+                .iter()
+                .find(|x| x.2.starts_with(path.as_str()))
+                .is_some()
+            {
+                location_stack.push_back((node, depth, path));
             }
         }
     }
-    nodes.sort_by_key(|n| n.location);
+    nodes.sort_by_key(|n| (n.location, n.depth));
     nodes
 }
diff --git a/crates/parser/src/pg_query_utils_manual.rs b/crates/parser/src/pg_query_utils_manual.rs
index d86f1d2c..9eafaa8f 100644
--- a/crates/parser/src/pg_query_utils_manual.rs
+++ b/crates/parser/src/pg_query_utils_manual.rs
@@ -1,28 +1,20 @@
-use std::println;
-
 use pg_query::NodeEnum;
 use regex::Regex;
 
-fn get_location_via_regexp(
+fn find_location_via_regexp(
     r: Regex,
     text: String,
     parent_location: i32,
     earliest_child_location: Option<i32>,
-) -> i32 {
+) -> Option<i32> {
     struct Location {
         location: i32,
         distance: i32,
     }
 
-    println!("regex: {:?}", r);
-    println!("earliest_child_location: {:?}", earliest_child_location);
-    println!("parent_location: {}", parent_location);
-    println!("text: {}", text);
-
     let location = r
         .find_iter(text.as_str())
         .filter_map(|x| {
-            println!("{:?}", x);
             if x.start() as i32 >= parent_location {
                 Some({
                     Location {
@@ -38,16 +30,29 @@ fn get_location_via_regexp(
                 None
             }
         })
-        .min_by_key(|x| x.distance.abs())
-        .unwrap()
-        .location;
+        .min_by_key(|x| x.distance.abs());
+
+    if location.is_none() {
+        return None;
+    }
+
+    let location = location.unwrap().location;
 
     // Sanity check to ensure that the location is valid
     if earliest_child_location.is_some() && earliest_child_location.unwrap() < location {
         panic!("Regex returned invalid location: Node cannot have a location < its children");
     }
 
-    location
+    Some(location)
+}
+
+fn get_location_via_regexp(
+    r: Regex,
+    text: String,
+    parent_location: i32,
+    earliest_child_location: Option<i32>,
+) -> i32 {
+    return find_location_via_regexp(r, text, parent_location, earliest_child_location).unwrap();
 }
 
 /// This is the only manual implementation required for the parser
@@ -111,7 +116,26 @@ pub fn derive_location(
         NodeEnum::InferenceElem(_) => todo!(),
         NodeEnum::TargetEntry(_) => todo!(),
         NodeEnum::RangeTblRef(_) => todo!(),
-        NodeEnum::JoinExpr(_) => todo!(),
+        NodeEnum::JoinExpr(n) => {
+            let keyword_regexp = match n.jointype() {
+                pg_query::protobuf::JoinType::Undefined => todo!(),
+                pg_query::protobuf::JoinType::JoinInner => "join|inner",
+                pg_query::protobuf::JoinType::JoinLeft => "join",
+                pg_query::protobuf::JoinType::JoinFull => "full",
+                pg_query::protobuf::JoinType::JoinRight => "join",
+                pg_query::protobuf::JoinType::JoinSemi => todo!(),
+                pg_query::protobuf::JoinType::JoinAnti => todo!(),
+                pg_query::protobuf::JoinType::JoinUniqueOuter => todo!(),
+                pg_query::protobuf::JoinType::JoinUniqueInner => todo!(),
+            };
+
+            Some(get_location_via_regexp(
+                Regex::new(format!("(?mi){}", keyword_regexp).as_str()).unwrap(),
+                text,
+                parent_location,
+                earliest_child_location,
+            ))
+        }
         NodeEnum::FromExpr(_) => todo!(),
         NodeEnum::OnConflictExpr(_) => todo!(),
         NodeEnum::IntoClause(_) => todo!(),
@@ -318,7 +342,13 @@ pub fn derive_location(
         NodeEnum::CtecycleClause(_) => panic!("Node has location property."),
         NodeEnum::CommonTableExpr(_) => panic!("Node has location property."),
         NodeEnum::MergeWhenClause(_) => todo!(),
-        NodeEnum::RoleSpec(_) => panic!("Node has location property."),
+        NodeEnum::RoleSpec(n) => {
+            if n.location == -1 {
+                None
+            } else {
+                todo!()
+            }
+        }
         NodeEnum::TriggerTransition(_) => todo!(),
         NodeEnum::PartitionElem(_) => panic!("Node has location property."),
         NodeEnum::PartitionSpec(_) => panic!("Node has location property."),
@@ -333,14 +363,23 @@ pub fn derive_location(
         NodeEnum::Integer(_) => None,
         NodeEnum::Float(_) => None,
         NodeEnum::Boolean(_) => None,
-        NodeEnum::String(n) => None,
+        NodeEnum::String(n) => find_location_via_regexp(
+            Regex::new(format!("(?mi){}", n.sval).as_str()).unwrap(),
+            text,
+            parent_location,
+            earliest_child_location,
+        ),
         NodeEnum::BitString(_) => None,
-        NodeEnum::List(_) => Some(get_location_via_regexp(
+        NodeEnum::List(_) => find_location_via_regexp(
             Regex::new(r"(?mi)\((.*?)\)").unwrap(),
             text,
             parent_location,
             earliest_child_location,
-        )),
+        )
+        // sometimes, a list is not enclosed by parentheses, but starts at the earliest child
+        // location, e.g. `DROP TABLE tablename`, where `tablename` is enclosed by an invisible
+        // `List`
+        .or(earliest_child_location),
         NodeEnum::IntList(_) => todo!(),
         NodeEnum::OidList(_) => todo!(),
         NodeEnum::AConst(_) => panic!("Node has location property."),
diff --git a/crates/parser/src/source_file.rs b/crates/parser/src/source_file.rs
index 556c43e6..a923baf1 100644
--- a/crates/parser/src/source_file.rs
+++ b/crates/parser/src/source_file.rs
@@ -95,7 +95,6 @@ select 1;
 ";
 
         let mut parser = Parser::new();
-        println!("input {:?}", input);
         parser.parse_source_file(input);
         let parsed = parser.finish();
 
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index afd5392b..4ee6db31 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -1,5 +1,4 @@
 use cstree::text::{TextRange, TextSize};
-use log::{debug, log_enabled};
 use logos::{Logos, Span};
 
 use crate::{
@@ -94,10 +93,6 @@ impl Parser {
             }
         };
 
-        if log_enabled!(log::Level::Debug) {
-            debug!("pg_query_root: {:?}", pg_query_root);
-        }
-
         let mut pg_query_nodes = match &pg_query_root {
             Some(root) => get_children(root, text.to_string(), 1)
                 .into_iter()
@@ -105,15 +100,6 @@ impl Parser {
             None => Vec::new().into_iter().peekable(),
         };
 
-        if log_enabled!(log::Level::Debug) {
-            println!("# Children:\n");
-            &pg_query_nodes.to_owned().for_each(|n| {
-                debug!("{:?}\n", n);
-                // let s = text.split_at(n.location as usize);
-                // debug!("Text: {:?}\npg_query_node: {:?}\n", s.1, n)
-            });
-        }
-
         let mut lexer = StatementToken::lexer(&text);
 
         // parse root node if no syntax errors
@@ -221,8 +207,8 @@ impl Parser {
 
 #[cfg(test)]
 mod tests {
+    use log::info;
     use log::log_enabled;
-    use log::{debug, info};
     use std::assert_eq;
     use std::fs;
 
@@ -234,15 +220,13 @@ mod tests {
         let _ = env_logger::builder().is_test(true).try_init();
     }
 
-    fn test_valid_stmt(input: String) {
-        info!("Testing: {}", input);
+    fn test_valid_stmt(name: String, input: String) {
+        info!("[{}]: {}", name, input);
 
         let mut parser = Parser::new();
         parser.parse_statement(&input, None);
         let parsed = parser.finish();
 
-        debug!("parsed: {}", parsed.cst.text());
-
         if log_enabled!(log::Level::Debug) {
             dbg!(&parsed.cst);
         }
@@ -253,7 +237,7 @@ mod tests {
     #[test]
     fn test_simple_statement() {
         init();
-        test_valid_stmt("select 1;".to_string());
+        test_valid_stmt("simple_statement".to_string(), "select 1;".to_string());
     }
 
     #[test]
@@ -271,16 +255,19 @@ mod tests {
     #[test]
     fn test_valid_statements() {
         init();
-        fs::read_dir(VALID_STATEMENTS_PATH)
+        let mut paths: Vec<_> = fs::read_dir(VALID_STATEMENTS_PATH)
             .unwrap()
-            .into_iter()
-            .for_each(|f| {
-                let path = f.unwrap().path();
+            .map(|r| r.unwrap())
+            .collect();
+        paths.sort_by_key(|dir| dir.path());
+
+        paths.iter().for_each(|f| {
+            let path = f.path();
 
-                let contents = fs::read_to_string(&path).unwrap();
+            let contents = fs::read_to_string(&path).unwrap();
 
-                test_valid_stmt(contents);
-            });
+            test_valid_stmt(path.to_str().unwrap().to_string(), contents);
+        });
     }
 
     #[test]
diff --git a/crates/parser/src/token_type.rs b/crates/parser/src/token_type.rs
index bd76b286..66a1ce2e 100644
--- a/crates/parser/src/token_type.rs
+++ b/crates/parser/src/token_type.rs
@@ -1,7 +1,6 @@
-use log::debug;
 use pg_query::protobuf::ScanToken;
 
-use crate::{statement::StatementToken, SyntaxKind};
+use crate::statement::StatementToken;
 
 ///
 ///  Kind of a `SyntaxKind`
@@ -68,24 +67,43 @@ pub fn get_token_type_from_pg_query_token(token: &ScanToken) -> Option<TokenType
             92 => Some(TokenType::Follow),
             93 => Some(TokenType::Follow),
             94 => Some(TokenType::Follow),
+            // NotEquals
+            274 => Some(TokenType::Follow),
+            _ => None,
+        },
+        pg_query::protobuf::KeywordKind::UnreservedKeyword => match token.token {
+            // AddP
+            281 => Some(TokenType::Follow),
+            // Update
+            695 => Some(TokenType::Follow),
             _ => None,
         },
-        pg_query::protobuf::KeywordKind::UnreservedKeyword => None,
         pg_query::protobuf::KeywordKind::ColNameKeyword => None,
         pg_query::protobuf::KeywordKind::TypeFuncNameKeyword => None,
         pg_query::protobuf::KeywordKind::ReservedKeyword => match token.token {
+            // And
+            291 => Some(TokenType::Follow),
+            // Check
+            328 => Some(TokenType::Follow),
             // End
             401 => Some(TokenType::Follow),
+            // For
+            424 => Some(TokenType::Follow),
             // From
             429 => Some(TokenType::Follow),
+            // InP
+            453 => Some(TokenType::Follow),
             543 => Some(TokenType::Follow),
             // Then
             669 => Some(TokenType::Follow),
             673 => Some(TokenType::Follow),
             697 => Some(TokenType::Follow),
+            // Where
+            713 => Some(TokenType::Follow),
+            // With
+            716 => Some(TokenType::Follow),
             _ => None,
         },
     };
-    debug!("token: {:?}, token_type: {:?}", token, r);
     r
 }
diff --git a/crates/postgres_lsp/src/main.rs b/crates/postgres_lsp/src/main.rs
index 7bd288ff..11019ddb 100644
--- a/crates/postgres_lsp/src/main.rs
+++ b/crates/postgres_lsp/src/main.rs
@@ -89,7 +89,6 @@ impl LanguageServer for Backend {
     }
 
     async fn initialized(&self, _: InitializedParams) {
-        debug!("initialized");
         self.client
             .log_message(MessageType::INFO, "initialized!")
             .await;
@@ -193,7 +192,6 @@ impl LanguageServer for Backend {
         &self,
         params: SemanticTokensRangeParams,
     ) -> Result<Option<SemanticTokensRangeResult>> {
-        println!("semantic_tokens_range");
         return Ok(None);
     }
 
@@ -298,8 +296,6 @@ impl Backend {
 async fn main() {
     env_logger::init();
 
-    debug!("starting up");
-
     let stdin = tokio::io::stdin();
     let stdout = tokio::io::stdout();
 
@@ -312,7 +308,5 @@ async fn main() {
     })
     .finish();
 
-    debug!("built service and created backend");
-
     Server::new(stdin, stdout, socket).serve(service).await;
 }

From 576bab2e12ff41d0f94f27780b766210406cddc8 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Sat, 26 Aug 2023 16:36:27 +0200
Subject: [PATCH 12/23] refactor: migrate syntax kind to codegen

---
 .gitmodules                                |    3 +
 Cargo.toml                                 |    1 +
 crates/codegen/Cargo.toml                  |   14 +
 crates/codegen/src/lib.rs                  |    8 +
 crates/codegen/src/syntax_kind.rs          |  136 ++
 crates/parser/Cargo.toml                   |    2 +-
 crates/parser/src/lib.rs                   |    4 +-
 crates/parser/src/parser.rs                |    2 +-
 crates/parser/src/sibling_token.rs         |    2 +-
 crates/parser/src/source_file.rs           |    2 +-
 crates/parser/src/statement.rs             |    2 +-
 crates/parser/src/syntax_kind_codegen.rs   |    3 +
 crates/parser/src/syntax_kind_generated.rs | 1523 --------------------
 crates/parser/src/syntax_node.rs           |    2 +-
 libpg_query                                |    1 +
 15 files changed, 174 insertions(+), 1531 deletions(-)
 create mode 100644 .gitmodules
 create mode 100644 crates/codegen/Cargo.toml
 create mode 100644 crates/codegen/src/lib.rs
 create mode 100644 crates/codegen/src/syntax_kind.rs
 create mode 100644 crates/parser/src/syntax_kind_codegen.rs
 delete mode 100644 crates/parser/src/syntax_kind_generated.rs
 create mode 160000 libpg_query

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..e3989614
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "libpg_query"]
+	path = libpg_query
+	url = git@github.com:pganalyze/libpg_query.git
diff --git a/Cargo.toml b/Cargo.toml
index 4e6bb4f1..7d0341f8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,7 @@ members = [
 
 [workspace.dependencies]
 parser = { path = "./crates/parser", version = "0.0.0" }
+codegen = { path = "./crates/codegen", version = "0.0.0" }
 sourcegen = { path = "./crates/sourcegen", version = "0.0.0" }
 pg_query_proto_parser = { path = "./crates/pg_query_proto_parser", version = "0.0.0" }
 triomphe = { version = "0.1.8", default-features = false, features = ["std"] }
diff --git a/crates/codegen/Cargo.toml b/crates/codegen/Cargo.toml
new file mode 100644
index 00000000..78776067
--- /dev/null
+++ b/crates/codegen/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "codegen"
+version = "0.0.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+proc-macro2 = "1.0.66"
+quote = "1.0.33"
+pg_query_proto_parser.workspace = true
+
+[lib]
+proc-macro = true
diff --git a/crates/codegen/src/lib.rs b/crates/codegen/src/lib.rs
new file mode 100644
index 00000000..9390ded2
--- /dev/null
+++ b/crates/codegen/src/lib.rs
@@ -0,0 +1,8 @@
+mod syntax_kind;
+
+use syntax_kind::syntax_kind_mod;
+
+#[proc_macro]
+pub fn syntax_kind(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
+    syntax_kind_mod(item.into()).into()
+}
diff --git a/crates/codegen/src/syntax_kind.rs b/crates/codegen/src/syntax_kind.rs
new file mode 100644
index 00000000..a01fb28a
--- /dev/null
+++ b/crates/codegen/src/syntax_kind.rs
@@ -0,0 +1,136 @@
+use std::collections::HashSet;
+
+use pg_query_proto_parser::{Node, ProtoParser, Token};
+use proc_macro2::{Ident, Literal};
+use quote::{format_ident, quote};
+
+pub fn syntax_kind_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
+    // let parser = ProtoParser::new(
+    //     "/Users/raminder.singh/src/rust/postgres_lsp/crates/parser/proto/source.proto",
+    // );
+    let parser = ProtoParser::new("./crates/parser/proto/source.proto");
+    let proto_file = parser.parse();
+
+    let mut current_enum_names: HashSet<&str> = HashSet::new();
+
+    let custom_node_names = custom_node_names();
+    let custom_node_identifiers = custom_node_identifiers(&custom_node_names);
+    current_enum_names.extend(&custom_node_names);
+
+    let node_identifiers = node_identifiers(&proto_file.nodes, &current_enum_names);
+    current_enum_names.extend(node_names(&proto_file.nodes));
+
+    let token_identifiers = token_identifiers(&proto_file.tokens, &current_enum_names);
+    let token_value_literals = token_value_literals(&proto_file.tokens, &current_enum_names);
+
+    let syntax_kind_impl =
+        syntax_kind_impl(&node_identifiers, &token_identifiers, &token_value_literals);
+
+    quote! {
+        use cstree::Syntax;
+        use pg_query::{protobuf::ScanToken, NodeEnum, NodeRef};
+
+        /// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres
+        /// sql dialect, and a few custom ones that are not parsed by pg_query.rs, such
+        /// as `Whitespace`.
+        #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Syntax)]
+        #[repr(u32)]
+        pub enum SyntaxKind {
+            // custom nodes, which are not parsed by pg_query.rs
+            #(#custom_node_identifiers),*,
+            #(#node_identifiers),*,
+            #(#token_identifiers),*,
+        }
+
+        #syntax_kind_impl
+    }
+}
+
+fn custom_node_names() -> Vec<&'static str> {
+    vec![
+        "SourceFile",
+        "Comment",
+        "Whitespace",
+        "Newline",
+        "Tab",
+        "Stmt",
+    ]
+}
+
+fn node_names(nodes: &[Node]) -> impl Iterator<Item = &str> {
+    nodes.iter().map(|node| node.name.as_str())
+}
+
+fn custom_node_identifiers(custom_node_names: &[&str]) -> Vec<Ident> {
+    custom_node_names
+        .iter()
+        .map(|&node_name| format_ident!("{}", node_name))
+        .collect()
+}
+
+fn node_identifiers(nodes: &[Node], existing_enum_names: &HashSet<&str>) -> Vec<Ident> {
+    nodes
+        .iter()
+        .filter(|&token| !existing_enum_names.contains(token.name.as_str()))
+        .map(|node| format_ident!("{}", &node.name))
+        .collect()
+}
+
+fn token_identifiers(tokens: &[Token], existing_enum_names: &HashSet<&str>) -> Vec<Ident> {
+    tokens
+        .iter()
+        .filter(|&token| !existing_enum_names.contains(token.name.as_str()))
+        .map(|token| format_ident!("{}", &token.name))
+        .collect()
+}
+
+fn token_value_literals(tokens: &[Token], existing_enum_names: &HashSet<&str>) -> Vec<Literal> {
+    tokens
+        .iter()
+        .filter(|&token| !existing_enum_names.contains(token.name.as_str()))
+        .map(|token| Literal::i32_unsuffixed(token.value))
+        .collect()
+}
+
+fn syntax_kind_impl(
+    node_identifiers: &[Ident],
+    token_identifiers: &[Ident],
+    token_value_literals: &[Literal],
+) -> proc_macro2::TokenStream {
+    let new_from_pg_query_node_fn = new_from_pg_query_node_fn(node_identifiers);
+    let new_from_pg_query_token_fn =
+        new_from_pg_query_token_fn(token_identifiers, token_value_literals);
+    quote! {
+        impl SyntaxKind {
+            #new_from_pg_query_node_fn
+
+            #new_from_pg_query_token_fn
+        }
+    }
+}
+
+fn new_from_pg_query_node_fn(node_identifiers: &[Ident]) -> proc_macro2::TokenStream {
+    quote! {
+        /// Converts a `pg_query` node to a `SyntaxKind`
+        pub fn new_from_pg_query_node(node: &NodeEnum) -> Self {
+            match node {
+                #(NodeEnum::#node_identifiers(_) => SyntaxKind::#node_identifiers),*
+            }
+        }
+    }
+}
+
+fn new_from_pg_query_token_fn(
+    token_identifiers: &[Ident],
+    token_value_literals: &[Literal],
+) -> proc_macro2::TokenStream {
+    quote! {
+        /// Converts a `pg_query` token to a `SyntaxKind`
+        pub fn new_from_pg_query_token(token: &ScanToken) -> Self {
+            match token.token {
+                #(#token_value_literals => SyntaxKind::#token_identifiers),*,
+                _ => panic!("Unknown token"),
+            }
+        }
+    }
+}
diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml
index 7aa76290..5ff79d95 100644
--- a/crates/parser/Cargo.toml
+++ b/crates/parser/Cargo.toml
@@ -15,5 +15,5 @@ serde = { version = "1.0", features = ["derive"] }
 env_logger = { version = "0.9.1" }
 log = { version = "0.4.20" }
 
-sourcegen.workspace = true
+codegen.workspace = true
 pg_query_proto_parser.workspace = true
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 2ceaf8cd..66d83a6b 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -24,10 +24,10 @@ mod sibling_token;
 mod source_file;
 mod statement;
 mod syntax_error;
-mod syntax_kind_generated;
+mod syntax_kind_codegen;
 mod syntax_node;
 mod token_type;
 
 pub use crate::parser::{Parse, Parser};
-pub use crate::syntax_kind_generated::SyntaxKind;
+pub use crate::syntax_kind_codegen::SyntaxKind;
 pub use crate::syntax_node::{SyntaxElement, SyntaxNode, SyntaxToken};
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index e59d9878..ab0425ae 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -6,7 +6,7 @@ use pg_query::NodeEnum;
 
 use crate::ast_node::RawStmt;
 use crate::syntax_error::SyntaxError;
-use crate::syntax_kind_generated::SyntaxKind;
+use crate::syntax_kind_codegen::SyntaxKind;
 use crate::syntax_node::SyntaxNode;
 use crate::token_type::TokenType;
 
diff --git a/crates/parser/src/sibling_token.rs b/crates/parser/src/sibling_token.rs
index e1875534..6a42dd0d 100644
--- a/crates/parser/src/sibling_token.rs
+++ b/crates/parser/src/sibling_token.rs
@@ -1,4 +1,4 @@
-use crate::SyntaxKind;
+use crate::syntax_kind_codegen::SyntaxKind;
 
 impl SyntaxKind {
     pub fn is_opening_sibling(&self) -> bool {
diff --git a/crates/parser/src/source_file.rs b/crates/parser/src/source_file.rs
index a923baf1..d258ee58 100644
--- a/crates/parser/src/source_file.rs
+++ b/crates/parser/src/source_file.rs
@@ -1,6 +1,6 @@
 use logos::Logos;
 
-use crate::{parser::Parser, syntax_kind_generated::SyntaxKind};
+use crate::{parser::Parser, syntax_kind_codegen::SyntaxKind};
 
 /// A super simple lexer for sql files that splits the input into indivudual statements and
 /// comments.
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 4ee6db31..3c1e24f8 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -4,7 +4,7 @@ use logos::{Logos, Span};
 use crate::{
     parser::Parser,
     pg_query_utils_generated::get_children,
-    syntax_kind_generated::SyntaxKind,
+    syntax_kind_codegen::SyntaxKind,
     token_type::{
         get_token_type_from_pg_query_token, get_token_type_from_statement_token, TokenType,
     },
diff --git a/crates/parser/src/syntax_kind_codegen.rs b/crates/parser/src/syntax_kind_codegen.rs
new file mode 100644
index 00000000..b50dd1a8
--- /dev/null
+++ b/crates/parser/src/syntax_kind_codegen.rs
@@ -0,0 +1,3 @@
+use codegen::syntax_kind;
+
+syntax_kind!();
diff --git a/crates/parser/src/syntax_kind_generated.rs b/crates/parser/src/syntax_kind_generated.rs
deleted file mode 100644
index e03a3130..00000000
--- a/crates/parser/src/syntax_kind_generated.rs
+++ /dev/null
@@ -1,1523 +0,0 @@
-//! //! This module bridges the gap between pg_query.rs nodes, and the
-//! `SyntaxKind`
-//! //! cstree requires.
-//! //! The file is generated from the libg_query proto
-use cstree::Syntax;
-use pg_query::{protobuf::ScanToken, NodeEnum};
-
-/// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres
-/// sql dialect, and a few custom ones that are not parsed by pg_query.rs, such
-/// as `Whitespace`.
-#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Syntax)]
-#[repr(u32)]
-pub enum SyntaxKind {
-    SourceFile,
-    Comment,
-    Whitespace,
-    Newline,
-    Tab,
-    Stmt,
-    Alias,
-    RangeVar,
-    TableFunc,
-    Var,
-    Param,
-    Aggref,
-    GroupingFunc,
-    WindowFunc,
-    SubscriptingRef,
-    FuncExpr,
-    NamedArgExpr,
-    OpExpr,
-    DistinctExpr,
-    NullIfExpr,
-    ScalarArrayOpExpr,
-    BoolExpr,
-    SubLink,
-    SubPlan,
-    AlternativeSubPlan,
-    FieldSelect,
-    FieldStore,
-    RelabelType,
-    CoerceViaIo,
-    ArrayCoerceExpr,
-    ConvertRowtypeExpr,
-    CollateExpr,
-    CaseExpr,
-    CaseWhen,
-    CaseTestExpr,
-    ArrayExpr,
-    RowExpr,
-    RowCompareExpr,
-    CoalesceExpr,
-    MinMaxExpr,
-    SqlvalueFunction,
-    XmlExpr,
-    NullTest,
-    BooleanTest,
-    CoerceToDomain,
-    CoerceToDomainValue,
-    SetToDefault,
-    CurrentOfExpr,
-    NextValueExpr,
-    InferenceElem,
-    TargetEntry,
-    RangeTblRef,
-    JoinExpr,
-    FromExpr,
-    OnConflictExpr,
-    IntoClause,
-    MergeAction,
-    RawStmt,
-    Query,
-    InsertStmt,
-    DeleteStmt,
-    UpdateStmt,
-    MergeStmt,
-    SelectStmt,
-    ReturnStmt,
-    PlassignStmt,
-    AlterTableStmt,
-    AlterTableCmd,
-    AlterDomainStmt,
-    SetOperationStmt,
-    GrantStmt,
-    GrantRoleStmt,
-    AlterDefaultPrivilegesStmt,
-    ClosePortalStmt,
-    ClusterStmt,
-    CopyStmt,
-    CreateStmt,
-    DefineStmt,
-    DropStmt,
-    TruncateStmt,
-    CommentStmt,
-    FetchStmt,
-    IndexStmt,
-    CreateFunctionStmt,
-    AlterFunctionStmt,
-    DoStmt,
-    RenameStmt,
-    RuleStmt,
-    NotifyStmt,
-    ListenStmt,
-    UnlistenStmt,
-    TransactionStmt,
-    ViewStmt,
-    LoadStmt,
-    CreateDomainStmt,
-    CreatedbStmt,
-    DropdbStmt,
-    VacuumStmt,
-    ExplainStmt,
-    CreateTableAsStmt,
-    CreateSeqStmt,
-    AlterSeqStmt,
-    VariableSetStmt,
-    VariableShowStmt,
-    DiscardStmt,
-    CreateTrigStmt,
-    CreatePlangStmt,
-    CreateRoleStmt,
-    AlterRoleStmt,
-    DropRoleStmt,
-    LockStmt,
-    ConstraintsSetStmt,
-    ReindexStmt,
-    CheckPointStmt,
-    CreateSchemaStmt,
-    AlterDatabaseStmt,
-    AlterDatabaseRefreshCollStmt,
-    AlterDatabaseSetStmt,
-    AlterRoleSetStmt,
-    CreateConversionStmt,
-    CreateCastStmt,
-    CreateOpClassStmt,
-    CreateOpFamilyStmt,
-    AlterOpFamilyStmt,
-    PrepareStmt,
-    ExecuteStmt,
-    DeallocateStmt,
-    DeclareCursorStmt,
-    CreateTableSpaceStmt,
-    DropTableSpaceStmt,
-    AlterObjectDependsStmt,
-    AlterObjectSchemaStmt,
-    AlterOwnerStmt,
-    AlterOperatorStmt,
-    AlterTypeStmt,
-    DropOwnedStmt,
-    ReassignOwnedStmt,
-    CompositeTypeStmt,
-    CreateEnumStmt,
-    CreateRangeStmt,
-    AlterEnumStmt,
-    AlterTsdictionaryStmt,
-    AlterTsconfigurationStmt,
-    CreateFdwStmt,
-    AlterFdwStmt,
-    CreateForeignServerStmt,
-    AlterForeignServerStmt,
-    CreateUserMappingStmt,
-    AlterUserMappingStmt,
-    DropUserMappingStmt,
-    AlterTableSpaceOptionsStmt,
-    AlterTableMoveAllStmt,
-    SecLabelStmt,
-    CreateForeignTableStmt,
-    ImportForeignSchemaStmt,
-    CreateExtensionStmt,
-    AlterExtensionStmt,
-    AlterExtensionContentsStmt,
-    CreateEventTrigStmt,
-    AlterEventTrigStmt,
-    RefreshMatViewStmt,
-    ReplicaIdentityStmt,
-    AlterSystemStmt,
-    CreatePolicyStmt,
-    AlterPolicyStmt,
-    CreateTransformStmt,
-    CreateAmStmt,
-    CreatePublicationStmt,
-    AlterPublicationStmt,
-    CreateSubscriptionStmt,
-    AlterSubscriptionStmt,
-    DropSubscriptionStmt,
-    CreateStatsStmt,
-    AlterCollationStmt,
-    CallStmt,
-    AlterStatsStmt,
-    AExpr,
-    ColumnRef,
-    ParamRef,
-    FuncCall,
-    AStar,
-    AIndices,
-    AIndirection,
-    AArrayExpr,
-    ResTarget,
-    MultiAssignRef,
-    TypeCast,
-    CollateClause,
-    SortBy,
-    WindowDef,
-    RangeSubselect,
-    RangeFunction,
-    RangeTableSample,
-    RangeTableFunc,
-    RangeTableFuncCol,
-    TypeName,
-    ColumnDef,
-    IndexElem,
-    StatsElem,
-    Constraint,
-    DefElem,
-    RangeTblEntry,
-    RangeTblFunction,
-    TableSampleClause,
-    WithCheckOption,
-    SortGroupClause,
-    GroupingSet,
-    WindowClause,
-    ObjectWithArgs,
-    AccessPriv,
-    CreateOpClassItem,
-    TableLikeClause,
-    FunctionParameter,
-    LockingClause,
-    RowMarkClause,
-    XmlSerialize,
-    WithClause,
-    InferClause,
-    OnConflictClause,
-    CtesearchClause,
-    CtecycleClause,
-    CommonTableExpr,
-    MergeWhenClause,
-    RoleSpec,
-    TriggerTransition,
-    PartitionElem,
-    PartitionSpec,
-    PartitionBoundSpec,
-    PartitionRangeDatum,
-    PartitionCmd,
-    VacuumRelation,
-    PublicationObjSpec,
-    PublicationTable,
-    InlineCodeBlock,
-    CallContext,
-    Integer,
-    Float,
-    Boolean,
-    String,
-    BitString,
-    List,
-    IntList,
-    OidList,
-    AConst,
-    Nul,
-    Ascii37,
-    Ascii40,
-    Ascii41,
-    Ascii42,
-    Ascii43,
-    Ascii44,
-    Ascii45,
-    Ascii46,
-    Ascii47,
-    Ascii58,
-    Ascii59,
-    Ascii60,
-    Ascii61,
-    Ascii62,
-    Ascii63,
-    Ascii91,
-    Ascii92,
-    Ascii93,
-    Ascii94,
-    Ident,
-    Uident,
-    Fconst,
-    Sconst,
-    Usconst,
-    Bconst,
-    Xconst,
-    Op,
-    Iconst,
-    Typecast,
-    DotDot,
-    ColonEquals,
-    EqualsGreater,
-    LessEquals,
-    GreaterEquals,
-    NotEquals,
-    SqlComment,
-    CComment,
-    AbortP,
-    AbsoluteP,
-    Access,
-    Action,
-    AddP,
-    Admin,
-    After,
-    Aggregate,
-    All,
-    Also,
-    Alter,
-    Always,
-    Analyse,
-    Analyze,
-    And,
-    Any,
-    Array,
-    As,
-    Asc,
-    Asensitive,
-    Assertion,
-    Assignment,
-    Asymmetric,
-    Atomic,
-    At,
-    Attach,
-    Attribute,
-    Authorization,
-    Backward,
-    Before,
-    BeginP,
-    Between,
-    Bigint,
-    Binary,
-    Bit,
-    BooleanP,
-    Both,
-    Breadth,
-    By,
-    Cache,
-    Call,
-    Called,
-    Cascade,
-    Cascaded,
-    Case,
-    Cast,
-    CatalogP,
-    Chain,
-    CharP,
-    Character,
-    Characteristics,
-    Check,
-    Checkpoint,
-    Class,
-    Close,
-    Cluster,
-    Coalesce,
-    Collate,
-    Collation,
-    Column,
-    Columns,
-    Comments,
-    Commit,
-    Committed,
-    Compression,
-    Concurrently,
-    Configuration,
-    Conflict,
-    Connection,
-    Constraints,
-    ContentP,
-    ContinueP,
-    ConversionP,
-    Copy,
-    Cost,
-    Create,
-    Cross,
-    Csv,
-    Cube,
-    CurrentP,
-    CurrentCatalog,
-    CurrentDate,
-    CurrentRole,
-    CurrentSchema,
-    CurrentTime,
-    CurrentTimestamp,
-    CurrentUser,
-    Cursor,
-    Cycle,
-    DataP,
-    Database,
-    DayP,
-    Deallocate,
-    Dec,
-    DecimalP,
-    Declare,
-    Default,
-    Defaults,
-    Deferrable,
-    Deferred,
-    Definer,
-    DeleteP,
-    Delimiter,
-    Delimiters,
-    Depends,
-    Depth,
-    Desc,
-    Detach,
-    Dictionary,
-    DisableP,
-    Discard,
-    Distinct,
-    Do,
-    DocumentP,
-    DomainP,
-    DoubleP,
-    Drop,
-    Each,
-    Else,
-    EnableP,
-    Encoding,
-    Encrypted,
-    EndP,
-    EnumP,
-    Escape,
-    Event,
-    Except,
-    Exclude,
-    Excluding,
-    Exclusive,
-    Execute,
-    Exists,
-    Explain,
-    Expression,
-    Extension,
-    External,
-    Extract,
-    FalseP,
-    Family,
-    Fetch,
-    Filter,
-    Finalize,
-    FirstP,
-    FloatP,
-    Following,
-    For,
-    Force,
-    Foreign,
-    Forward,
-    Freeze,
-    From,
-    Full,
-    Function,
-    Functions,
-    Generated,
-    Global,
-    Grant,
-    Granted,
-    Greatest,
-    GroupP,
-    Grouping,
-    Groups,
-    Handler,
-    Having,
-    HeaderP,
-    Hold,
-    HourP,
-    IdentityP,
-    IfP,
-    Ilike,
-    Immediate,
-    Immutable,
-    ImplicitP,
-    ImportP,
-    InP,
-    Include,
-    Including,
-    Increment,
-    Index,
-    Indexes,
-    Inherit,
-    Inherits,
-    Initially,
-    InlineP,
-    InnerP,
-    Inout,
-    InputP,
-    Insensitive,
-    Insert,
-    Instead,
-    IntP,
-    Intersect,
-    Interval,
-    Into,
-    Invoker,
-    Is,
-    Isnull,
-    Isolation,
-    Join,
-    Key,
-    Label,
-    Language,
-    LargeP,
-    LastP,
-    LateralP,
-    Leading,
-    Leakproof,
-    Least,
-    Left,
-    Level,
-    Like,
-    Limit,
-    Listen,
-    Load,
-    Local,
-    Localtime,
-    Localtimestamp,
-    Location,
-    LockP,
-    Locked,
-    Logged,
-    Mapping,
-    Match,
-    Matched,
-    Materialized,
-    Maxvalue,
-    Merge,
-    Method,
-    MinuteP,
-    Minvalue,
-    Mode,
-    MonthP,
-    Move,
-    NameP,
-    Names,
-    National,
-    Natural,
-    Nchar,
-    New,
-    Next,
-    Nfc,
-    Nfd,
-    Nfkc,
-    Nfkd,
-    No,
-    None,
-    Normalize,
-    Normalized,
-    Not,
-    Nothing,
-    Notify,
-    Notnull,
-    Nowait,
-    NullP,
-    Nullif,
-    NullsP,
-    Numeric,
-    ObjectP,
-    Of,
-    Off,
-    Offset,
-    Oids,
-    Old,
-    On,
-    Only,
-    Operator,
-    Option,
-    Options,
-    Or,
-    Order,
-    Ordinality,
-    Others,
-    OutP,
-    OuterP,
-    Over,
-    Overlaps,
-    Overlay,
-    Overriding,
-    Owned,
-    Owner,
-    Parallel,
-    Parameter,
-    Parser,
-    Partial,
-    Partition,
-    Passing,
-    Password,
-    Placing,
-    Plans,
-    Policy,
-    Position,
-    Preceding,
-    Precision,
-    Preserve,
-    Prepare,
-    Prepared,
-    Primary,
-    Prior,
-    Privileges,
-    Procedural,
-    Procedure,
-    Procedures,
-    Program,
-    Publication,
-    Quote,
-    Range,
-    Read,
-    Real,
-    Reassign,
-    Recheck,
-    Recursive,
-    RefP,
-    References,
-    Referencing,
-    Refresh,
-    Reindex,
-    RelativeP,
-    Release,
-    Rename,
-    Repeatable,
-    Replace,
-    Replica,
-    Reset,
-    Restart,
-    Restrict,
-    Return,
-    Returning,
-    Returns,
-    Revoke,
-    Right,
-    Role,
-    Rollback,
-    Rollup,
-    Routine,
-    Routines,
-    Row,
-    Rows,
-    Rule,
-    Savepoint,
-    Schema,
-    Schemas,
-    Scroll,
-    Search,
-    SecondP,
-    Security,
-    Select,
-    Sequence,
-    Sequences,
-    Serializable,
-    Server,
-    Session,
-    SessionUser,
-    Set,
-    Sets,
-    Setof,
-    Share,
-    Show,
-    Similar,
-    Simple,
-    Skip,
-    Smallint,
-    Snapshot,
-    Some,
-    SqlP,
-    Stable,
-    StandaloneP,
-    Start,
-    Statement,
-    Statistics,
-    Stdin,
-    Stdout,
-    Storage,
-    Stored,
-    StrictP,
-    StripP,
-    Subscription,
-    Substring,
-    Support,
-    Symmetric,
-    Sysid,
-    SystemP,
-    Table,
-    Tables,
-    Tablesample,
-    Tablespace,
-    Temp,
-    Template,
-    Temporary,
-    TextP,
-    Then,
-    Ties,
-    Time,
-    Timestamp,
-    To,
-    Trailing,
-    Transaction,
-    Transform,
-    Treat,
-    Trigger,
-    Trim,
-    TrueP,
-    Truncate,
-    Trusted,
-    TypeP,
-    TypesP,
-    Uescape,
-    Unbounded,
-    Uncommitted,
-    Unencrypted,
-    Union,
-    Unique,
-    Unknown,
-    Unlisten,
-    Unlogged,
-    Until,
-    Update,
-    User,
-    Using,
-    Vacuum,
-    Valid,
-    Validate,
-    Validator,
-    ValueP,
-    Values,
-    Varchar,
-    Variadic,
-    Varying,
-    Verbose,
-    VersionP,
-    View,
-    Views,
-    Volatile,
-    When,
-    Where,
-    WhitespaceP,
-    Window,
-    With,
-    Within,
-    Without,
-    Work,
-    Wrapper,
-    Write,
-    XmlP,
-    Xmlattributes,
-    Xmlconcat,
-    Xmlelement,
-    Xmlexists,
-    Xmlforest,
-    Xmlnamespaces,
-    Xmlparse,
-    Xmlpi,
-    Xmlroot,
-    Xmlserialize,
-    Xmltable,
-    YearP,
-    YesP,
-    Zone,
-    NotLa,
-    NullsLa,
-    WithLa,
-    ModeTypeName,
-    ModePlpgsqlExpr,
-    ModePlpgsqlAssign1,
-    ModePlpgsqlAssign2,
-    ModePlpgsqlAssign3,
-    Uminus,
-}
-
-impl SyntaxKind {
-    /// Converts a `pg_query` node to a `SyntaxKind`
-    pub fn new_from_pg_query_node(node: &NodeEnum) -> Self {
-        match node {
-            NodeEnum::Alias(_) => SyntaxKind::Alias,
-            NodeEnum::RangeVar(_) => SyntaxKind::RangeVar,
-            NodeEnum::TableFunc(_) => SyntaxKind::TableFunc,
-            NodeEnum::Var(_) => SyntaxKind::Var,
-            NodeEnum::Param(_) => SyntaxKind::Param,
-            NodeEnum::Aggref(_) => SyntaxKind::Aggref,
-            NodeEnum::GroupingFunc(_) => SyntaxKind::GroupingFunc,
-            NodeEnum::WindowFunc(_) => SyntaxKind::WindowFunc,
-            NodeEnum::SubscriptingRef(_) => SyntaxKind::SubscriptingRef,
-            NodeEnum::FuncExpr(_) => SyntaxKind::FuncExpr,
-            NodeEnum::NamedArgExpr(_) => SyntaxKind::NamedArgExpr,
-            NodeEnum::OpExpr(_) => SyntaxKind::OpExpr,
-            NodeEnum::DistinctExpr(_) => SyntaxKind::DistinctExpr,
-            NodeEnum::NullIfExpr(_) => SyntaxKind::NullIfExpr,
-            NodeEnum::ScalarArrayOpExpr(_) => SyntaxKind::ScalarArrayOpExpr,
-            NodeEnum::BoolExpr(_) => SyntaxKind::BoolExpr,
-            NodeEnum::SubLink(_) => SyntaxKind::SubLink,
-            NodeEnum::SubPlan(_) => SyntaxKind::SubPlan,
-            NodeEnum::AlternativeSubPlan(_) => SyntaxKind::AlternativeSubPlan,
-            NodeEnum::FieldSelect(_) => SyntaxKind::FieldSelect,
-            NodeEnum::FieldStore(_) => SyntaxKind::FieldStore,
-            NodeEnum::RelabelType(_) => SyntaxKind::RelabelType,
-            NodeEnum::CoerceViaIo(_) => SyntaxKind::CoerceViaIo,
-            NodeEnum::ArrayCoerceExpr(_) => SyntaxKind::ArrayCoerceExpr,
-            NodeEnum::ConvertRowtypeExpr(_) => SyntaxKind::ConvertRowtypeExpr,
-            NodeEnum::CollateExpr(_) => SyntaxKind::CollateExpr,
-            NodeEnum::CaseExpr(_) => SyntaxKind::CaseExpr,
-            NodeEnum::CaseWhen(_) => SyntaxKind::CaseWhen,
-            NodeEnum::CaseTestExpr(_) => SyntaxKind::CaseTestExpr,
-            NodeEnum::ArrayExpr(_) => SyntaxKind::ArrayExpr,
-            NodeEnum::RowExpr(_) => SyntaxKind::RowExpr,
-            NodeEnum::RowCompareExpr(_) => SyntaxKind::RowCompareExpr,
-            NodeEnum::CoalesceExpr(_) => SyntaxKind::CoalesceExpr,
-            NodeEnum::MinMaxExpr(_) => SyntaxKind::MinMaxExpr,
-            NodeEnum::SqlvalueFunction(_) => SyntaxKind::SqlvalueFunction,
-            NodeEnum::XmlExpr(_) => SyntaxKind::XmlExpr,
-            NodeEnum::NullTest(_) => SyntaxKind::NullTest,
-            NodeEnum::BooleanTest(_) => SyntaxKind::BooleanTest,
-            NodeEnum::CoerceToDomain(_) => SyntaxKind::CoerceToDomain,
-            NodeEnum::CoerceToDomainValue(_) => SyntaxKind::CoerceToDomainValue,
-            NodeEnum::SetToDefault(_) => SyntaxKind::SetToDefault,
-            NodeEnum::CurrentOfExpr(_) => SyntaxKind::CurrentOfExpr,
-            NodeEnum::NextValueExpr(_) => SyntaxKind::NextValueExpr,
-            NodeEnum::InferenceElem(_) => SyntaxKind::InferenceElem,
-            NodeEnum::TargetEntry(_) => SyntaxKind::TargetEntry,
-            NodeEnum::RangeTblRef(_) => SyntaxKind::RangeTblRef,
-            NodeEnum::JoinExpr(_) => SyntaxKind::JoinExpr,
-            NodeEnum::FromExpr(_) => SyntaxKind::FromExpr,
-            NodeEnum::OnConflictExpr(_) => SyntaxKind::OnConflictExpr,
-            NodeEnum::IntoClause(_) => SyntaxKind::IntoClause,
-            NodeEnum::MergeAction(_) => SyntaxKind::MergeAction,
-            NodeEnum::RawStmt(_) => SyntaxKind::RawStmt,
-            NodeEnum::Query(_) => SyntaxKind::Query,
-            NodeEnum::InsertStmt(_) => SyntaxKind::InsertStmt,
-            NodeEnum::DeleteStmt(_) => SyntaxKind::DeleteStmt,
-            NodeEnum::UpdateStmt(_) => SyntaxKind::UpdateStmt,
-            NodeEnum::MergeStmt(_) => SyntaxKind::MergeStmt,
-            NodeEnum::SelectStmt(_) => SyntaxKind::SelectStmt,
-            NodeEnum::ReturnStmt(_) => SyntaxKind::ReturnStmt,
-            NodeEnum::PlassignStmt(_) => SyntaxKind::PlassignStmt,
-            NodeEnum::AlterTableStmt(_) => SyntaxKind::AlterTableStmt,
-            NodeEnum::AlterTableCmd(_) => SyntaxKind::AlterTableCmd,
-            NodeEnum::AlterDomainStmt(_) => SyntaxKind::AlterDomainStmt,
-            NodeEnum::SetOperationStmt(_) => SyntaxKind::SetOperationStmt,
-            NodeEnum::GrantStmt(_) => SyntaxKind::GrantStmt,
-            NodeEnum::GrantRoleStmt(_) => SyntaxKind::GrantRoleStmt,
-            NodeEnum::AlterDefaultPrivilegesStmt(_) => SyntaxKind::AlterDefaultPrivilegesStmt,
-            NodeEnum::ClosePortalStmt(_) => SyntaxKind::ClosePortalStmt,
-            NodeEnum::ClusterStmt(_) => SyntaxKind::ClusterStmt,
-            NodeEnum::CopyStmt(_) => SyntaxKind::CopyStmt,
-            NodeEnum::CreateStmt(_) => SyntaxKind::CreateStmt,
-            NodeEnum::DefineStmt(_) => SyntaxKind::DefineStmt,
-            NodeEnum::DropStmt(_) => SyntaxKind::DropStmt,
-            NodeEnum::TruncateStmt(_) => SyntaxKind::TruncateStmt,
-            NodeEnum::CommentStmt(_) => SyntaxKind::CommentStmt,
-            NodeEnum::FetchStmt(_) => SyntaxKind::FetchStmt,
-            NodeEnum::IndexStmt(_) => SyntaxKind::IndexStmt,
-            NodeEnum::CreateFunctionStmt(_) => SyntaxKind::CreateFunctionStmt,
-            NodeEnum::AlterFunctionStmt(_) => SyntaxKind::AlterFunctionStmt,
-            NodeEnum::DoStmt(_) => SyntaxKind::DoStmt,
-            NodeEnum::RenameStmt(_) => SyntaxKind::RenameStmt,
-            NodeEnum::RuleStmt(_) => SyntaxKind::RuleStmt,
-            NodeEnum::NotifyStmt(_) => SyntaxKind::NotifyStmt,
-            NodeEnum::ListenStmt(_) => SyntaxKind::ListenStmt,
-            NodeEnum::UnlistenStmt(_) => SyntaxKind::UnlistenStmt,
-            NodeEnum::TransactionStmt(_) => SyntaxKind::TransactionStmt,
-            NodeEnum::ViewStmt(_) => SyntaxKind::ViewStmt,
-            NodeEnum::LoadStmt(_) => SyntaxKind::LoadStmt,
-            NodeEnum::CreateDomainStmt(_) => SyntaxKind::CreateDomainStmt,
-            NodeEnum::CreatedbStmt(_) => SyntaxKind::CreatedbStmt,
-            NodeEnum::DropdbStmt(_) => SyntaxKind::DropdbStmt,
-            NodeEnum::VacuumStmt(_) => SyntaxKind::VacuumStmt,
-            NodeEnum::ExplainStmt(_) => SyntaxKind::ExplainStmt,
-            NodeEnum::CreateTableAsStmt(_) => SyntaxKind::CreateTableAsStmt,
-            NodeEnum::CreateSeqStmt(_) => SyntaxKind::CreateSeqStmt,
-            NodeEnum::AlterSeqStmt(_) => SyntaxKind::AlterSeqStmt,
-            NodeEnum::VariableSetStmt(_) => SyntaxKind::VariableSetStmt,
-            NodeEnum::VariableShowStmt(_) => SyntaxKind::VariableShowStmt,
-            NodeEnum::DiscardStmt(_) => SyntaxKind::DiscardStmt,
-            NodeEnum::CreateTrigStmt(_) => SyntaxKind::CreateTrigStmt,
-            NodeEnum::CreatePlangStmt(_) => SyntaxKind::CreatePlangStmt,
-            NodeEnum::CreateRoleStmt(_) => SyntaxKind::CreateRoleStmt,
-            NodeEnum::AlterRoleStmt(_) => SyntaxKind::AlterRoleStmt,
-            NodeEnum::DropRoleStmt(_) => SyntaxKind::DropRoleStmt,
-            NodeEnum::LockStmt(_) => SyntaxKind::LockStmt,
-            NodeEnum::ConstraintsSetStmt(_) => SyntaxKind::ConstraintsSetStmt,
-            NodeEnum::ReindexStmt(_) => SyntaxKind::ReindexStmt,
-            NodeEnum::CheckPointStmt(_) => SyntaxKind::CheckPointStmt,
-            NodeEnum::CreateSchemaStmt(_) => SyntaxKind::CreateSchemaStmt,
-            NodeEnum::AlterDatabaseStmt(_) => SyntaxKind::AlterDatabaseStmt,
-            NodeEnum::AlterDatabaseRefreshCollStmt(_) => SyntaxKind::AlterDatabaseRefreshCollStmt,
-            NodeEnum::AlterDatabaseSetStmt(_) => SyntaxKind::AlterDatabaseSetStmt,
-            NodeEnum::AlterRoleSetStmt(_) => SyntaxKind::AlterRoleSetStmt,
-            NodeEnum::CreateConversionStmt(_) => SyntaxKind::CreateConversionStmt,
-            NodeEnum::CreateCastStmt(_) => SyntaxKind::CreateCastStmt,
-            NodeEnum::CreateOpClassStmt(_) => SyntaxKind::CreateOpClassStmt,
-            NodeEnum::CreateOpFamilyStmt(_) => SyntaxKind::CreateOpFamilyStmt,
-            NodeEnum::AlterOpFamilyStmt(_) => SyntaxKind::AlterOpFamilyStmt,
-            NodeEnum::PrepareStmt(_) => SyntaxKind::PrepareStmt,
-            NodeEnum::ExecuteStmt(_) => SyntaxKind::ExecuteStmt,
-            NodeEnum::DeallocateStmt(_) => SyntaxKind::DeallocateStmt,
-            NodeEnum::DeclareCursorStmt(_) => SyntaxKind::DeclareCursorStmt,
-            NodeEnum::CreateTableSpaceStmt(_) => SyntaxKind::CreateTableSpaceStmt,
-            NodeEnum::DropTableSpaceStmt(_) => SyntaxKind::DropTableSpaceStmt,
-            NodeEnum::AlterObjectDependsStmt(_) => SyntaxKind::AlterObjectDependsStmt,
-            NodeEnum::AlterObjectSchemaStmt(_) => SyntaxKind::AlterObjectSchemaStmt,
-            NodeEnum::AlterOwnerStmt(_) => SyntaxKind::AlterOwnerStmt,
-            NodeEnum::AlterOperatorStmt(_) => SyntaxKind::AlterOperatorStmt,
-            NodeEnum::AlterTypeStmt(_) => SyntaxKind::AlterTypeStmt,
-            NodeEnum::DropOwnedStmt(_) => SyntaxKind::DropOwnedStmt,
-            NodeEnum::ReassignOwnedStmt(_) => SyntaxKind::ReassignOwnedStmt,
-            NodeEnum::CompositeTypeStmt(_) => SyntaxKind::CompositeTypeStmt,
-            NodeEnum::CreateEnumStmt(_) => SyntaxKind::CreateEnumStmt,
-            NodeEnum::CreateRangeStmt(_) => SyntaxKind::CreateRangeStmt,
-            NodeEnum::AlterEnumStmt(_) => SyntaxKind::AlterEnumStmt,
-            NodeEnum::AlterTsdictionaryStmt(_) => SyntaxKind::AlterTsdictionaryStmt,
-            NodeEnum::AlterTsconfigurationStmt(_) => SyntaxKind::AlterTsconfigurationStmt,
-            NodeEnum::CreateFdwStmt(_) => SyntaxKind::CreateFdwStmt,
-            NodeEnum::AlterFdwStmt(_) => SyntaxKind::AlterFdwStmt,
-            NodeEnum::CreateForeignServerStmt(_) => SyntaxKind::CreateForeignServerStmt,
-            NodeEnum::AlterForeignServerStmt(_) => SyntaxKind::AlterForeignServerStmt,
-            NodeEnum::CreateUserMappingStmt(_) => SyntaxKind::CreateUserMappingStmt,
-            NodeEnum::AlterUserMappingStmt(_) => SyntaxKind::AlterUserMappingStmt,
-            NodeEnum::DropUserMappingStmt(_) => SyntaxKind::DropUserMappingStmt,
-            NodeEnum::AlterTableSpaceOptionsStmt(_) => SyntaxKind::AlterTableSpaceOptionsStmt,
-            NodeEnum::AlterTableMoveAllStmt(_) => SyntaxKind::AlterTableMoveAllStmt,
-            NodeEnum::SecLabelStmt(_) => SyntaxKind::SecLabelStmt,
-            NodeEnum::CreateForeignTableStmt(_) => SyntaxKind::CreateForeignTableStmt,
-            NodeEnum::ImportForeignSchemaStmt(_) => SyntaxKind::ImportForeignSchemaStmt,
-            NodeEnum::CreateExtensionStmt(_) => SyntaxKind::CreateExtensionStmt,
-            NodeEnum::AlterExtensionStmt(_) => SyntaxKind::AlterExtensionStmt,
-            NodeEnum::AlterExtensionContentsStmt(_) => SyntaxKind::AlterExtensionContentsStmt,
-            NodeEnum::CreateEventTrigStmt(_) => SyntaxKind::CreateEventTrigStmt,
-            NodeEnum::AlterEventTrigStmt(_) => SyntaxKind::AlterEventTrigStmt,
-            NodeEnum::RefreshMatViewStmt(_) => SyntaxKind::RefreshMatViewStmt,
-            NodeEnum::ReplicaIdentityStmt(_) => SyntaxKind::ReplicaIdentityStmt,
-            NodeEnum::AlterSystemStmt(_) => SyntaxKind::AlterSystemStmt,
-            NodeEnum::CreatePolicyStmt(_) => SyntaxKind::CreatePolicyStmt,
-            NodeEnum::AlterPolicyStmt(_) => SyntaxKind::AlterPolicyStmt,
-            NodeEnum::CreateTransformStmt(_) => SyntaxKind::CreateTransformStmt,
-            NodeEnum::CreateAmStmt(_) => SyntaxKind::CreateAmStmt,
-            NodeEnum::CreatePublicationStmt(_) => SyntaxKind::CreatePublicationStmt,
-            NodeEnum::AlterPublicationStmt(_) => SyntaxKind::AlterPublicationStmt,
-            NodeEnum::CreateSubscriptionStmt(_) => SyntaxKind::CreateSubscriptionStmt,
-            NodeEnum::AlterSubscriptionStmt(_) => SyntaxKind::AlterSubscriptionStmt,
-            NodeEnum::DropSubscriptionStmt(_) => SyntaxKind::DropSubscriptionStmt,
-            NodeEnum::CreateStatsStmt(_) => SyntaxKind::CreateStatsStmt,
-            NodeEnum::AlterCollationStmt(_) => SyntaxKind::AlterCollationStmt,
-            NodeEnum::CallStmt(_) => SyntaxKind::CallStmt,
-            NodeEnum::AlterStatsStmt(_) => SyntaxKind::AlterStatsStmt,
-            NodeEnum::AExpr(_) => SyntaxKind::AExpr,
-            NodeEnum::ColumnRef(_) => SyntaxKind::ColumnRef,
-            NodeEnum::ParamRef(_) => SyntaxKind::ParamRef,
-            NodeEnum::FuncCall(_) => SyntaxKind::FuncCall,
-            NodeEnum::AStar(_) => SyntaxKind::AStar,
-            NodeEnum::AIndices(_) => SyntaxKind::AIndices,
-            NodeEnum::AIndirection(_) => SyntaxKind::AIndirection,
-            NodeEnum::AArrayExpr(_) => SyntaxKind::AArrayExpr,
-            NodeEnum::ResTarget(_) => SyntaxKind::ResTarget,
-            NodeEnum::MultiAssignRef(_) => SyntaxKind::MultiAssignRef,
-            NodeEnum::TypeCast(_) => SyntaxKind::TypeCast,
-            NodeEnum::CollateClause(_) => SyntaxKind::CollateClause,
-            NodeEnum::SortBy(_) => SyntaxKind::SortBy,
-            NodeEnum::WindowDef(_) => SyntaxKind::WindowDef,
-            NodeEnum::RangeSubselect(_) => SyntaxKind::RangeSubselect,
-            NodeEnum::RangeFunction(_) => SyntaxKind::RangeFunction,
-            NodeEnum::RangeTableSample(_) => SyntaxKind::RangeTableSample,
-            NodeEnum::RangeTableFunc(_) => SyntaxKind::RangeTableFunc,
-            NodeEnum::RangeTableFuncCol(_) => SyntaxKind::RangeTableFuncCol,
-            NodeEnum::TypeName(_) => SyntaxKind::TypeName,
-            NodeEnum::ColumnDef(_) => SyntaxKind::ColumnDef,
-            NodeEnum::IndexElem(_) => SyntaxKind::IndexElem,
-            NodeEnum::StatsElem(_) => SyntaxKind::StatsElem,
-            NodeEnum::Constraint(_) => SyntaxKind::Constraint,
-            NodeEnum::DefElem(_) => SyntaxKind::DefElem,
-            NodeEnum::RangeTblEntry(_) => SyntaxKind::RangeTblEntry,
-            NodeEnum::RangeTblFunction(_) => SyntaxKind::RangeTblFunction,
-            NodeEnum::TableSampleClause(_) => SyntaxKind::TableSampleClause,
-            NodeEnum::WithCheckOption(_) => SyntaxKind::WithCheckOption,
-            NodeEnum::SortGroupClause(_) => SyntaxKind::SortGroupClause,
-            NodeEnum::GroupingSet(_) => SyntaxKind::GroupingSet,
-            NodeEnum::WindowClause(_) => SyntaxKind::WindowClause,
-            NodeEnum::ObjectWithArgs(_) => SyntaxKind::ObjectWithArgs,
-            NodeEnum::AccessPriv(_) => SyntaxKind::AccessPriv,
-            NodeEnum::CreateOpClassItem(_) => SyntaxKind::CreateOpClassItem,
-            NodeEnum::TableLikeClause(_) => SyntaxKind::TableLikeClause,
-            NodeEnum::FunctionParameter(_) => SyntaxKind::FunctionParameter,
-            NodeEnum::LockingClause(_) => SyntaxKind::LockingClause,
-            NodeEnum::RowMarkClause(_) => SyntaxKind::RowMarkClause,
-            NodeEnum::XmlSerialize(_) => SyntaxKind::XmlSerialize,
-            NodeEnum::WithClause(_) => SyntaxKind::WithClause,
-            NodeEnum::InferClause(_) => SyntaxKind::InferClause,
-            NodeEnum::OnConflictClause(_) => SyntaxKind::OnConflictClause,
-            NodeEnum::CtesearchClause(_) => SyntaxKind::CtesearchClause,
-            NodeEnum::CtecycleClause(_) => SyntaxKind::CtecycleClause,
-            NodeEnum::CommonTableExpr(_) => SyntaxKind::CommonTableExpr,
-            NodeEnum::MergeWhenClause(_) => SyntaxKind::MergeWhenClause,
-            NodeEnum::RoleSpec(_) => SyntaxKind::RoleSpec,
-            NodeEnum::TriggerTransition(_) => SyntaxKind::TriggerTransition,
-            NodeEnum::PartitionElem(_) => SyntaxKind::PartitionElem,
-            NodeEnum::PartitionSpec(_) => SyntaxKind::PartitionSpec,
-            NodeEnum::PartitionBoundSpec(_) => SyntaxKind::PartitionBoundSpec,
-            NodeEnum::PartitionRangeDatum(_) => SyntaxKind::PartitionRangeDatum,
-            NodeEnum::PartitionCmd(_) => SyntaxKind::PartitionCmd,
-            NodeEnum::VacuumRelation(_) => SyntaxKind::VacuumRelation,
-            NodeEnum::PublicationObjSpec(_) => SyntaxKind::PublicationObjSpec,
-            NodeEnum::PublicationTable(_) => SyntaxKind::PublicationTable,
-            NodeEnum::InlineCodeBlock(_) => SyntaxKind::InlineCodeBlock,
-            NodeEnum::CallContext(_) => SyntaxKind::CallContext,
-            NodeEnum::Integer(_) => SyntaxKind::Integer,
-            NodeEnum::Float(_) => SyntaxKind::Float,
-            NodeEnum::Boolean(_) => SyntaxKind::Boolean,
-            NodeEnum::String(_) => SyntaxKind::String,
-            NodeEnum::BitString(_) => SyntaxKind::BitString,
-            NodeEnum::List(_) => SyntaxKind::List,
-            NodeEnum::IntList(_) => SyntaxKind::IntList,
-            NodeEnum::OidList(_) => SyntaxKind::OidList,
-            NodeEnum::AConst(_) => SyntaxKind::AConst,
-        }
-    }
-
-    /// Converts a `pg_query` token to a `SyntaxKind`
-    pub fn new_from_pg_query_token(token: &ScanToken) -> Self {
-        match token.token {
-            0 => SyntaxKind::Nul,
-            37 => SyntaxKind::Ascii37,
-            40 => SyntaxKind::Ascii40,
-            41 => SyntaxKind::Ascii41,
-            42 => SyntaxKind::Ascii42,
-            43 => SyntaxKind::Ascii43,
-            44 => SyntaxKind::Ascii44,
-            45 => SyntaxKind::Ascii45,
-            46 => SyntaxKind::Ascii46,
-            47 => SyntaxKind::Ascii47,
-            58 => SyntaxKind::Ascii58,
-            59 => SyntaxKind::Ascii59,
-            60 => SyntaxKind::Ascii60,
-            61 => SyntaxKind::Ascii61,
-            62 => SyntaxKind::Ascii62,
-            63 => SyntaxKind::Ascii63,
-            91 => SyntaxKind::Ascii91,
-            92 => SyntaxKind::Ascii92,
-            93 => SyntaxKind::Ascii93,
-            94 => SyntaxKind::Ascii94,
-            258 => SyntaxKind::Ident,
-            259 => SyntaxKind::Uident,
-            260 => SyntaxKind::Fconst,
-            261 => SyntaxKind::Sconst,
-            262 => SyntaxKind::Usconst,
-            263 => SyntaxKind::Bconst,
-            264 => SyntaxKind::Xconst,
-            265 => SyntaxKind::Op,
-            266 => SyntaxKind::Iconst,
-            267 => SyntaxKind::Param,
-            268 => SyntaxKind::Typecast,
-            269 => SyntaxKind::DotDot,
-            270 => SyntaxKind::ColonEquals,
-            271 => SyntaxKind::EqualsGreater,
-            272 => SyntaxKind::LessEquals,
-            273 => SyntaxKind::GreaterEquals,
-            274 => SyntaxKind::NotEquals,
-            275 => SyntaxKind::SqlComment,
-            276 => SyntaxKind::CComment,
-            277 => SyntaxKind::AbortP,
-            278 => SyntaxKind::AbsoluteP,
-            279 => SyntaxKind::Access,
-            280 => SyntaxKind::Action,
-            281 => SyntaxKind::AddP,
-            282 => SyntaxKind::Admin,
-            283 => SyntaxKind::After,
-            284 => SyntaxKind::Aggregate,
-            285 => SyntaxKind::All,
-            286 => SyntaxKind::Also,
-            287 => SyntaxKind::Alter,
-            288 => SyntaxKind::Always,
-            289 => SyntaxKind::Analyse,
-            290 => SyntaxKind::Analyze,
-            291 => SyntaxKind::And,
-            292 => SyntaxKind::Any,
-            293 => SyntaxKind::Array,
-            294 => SyntaxKind::As,
-            295 => SyntaxKind::Asc,
-            296 => SyntaxKind::Asensitive,
-            297 => SyntaxKind::Assertion,
-            298 => SyntaxKind::Assignment,
-            299 => SyntaxKind::Asymmetric,
-            300 => SyntaxKind::Atomic,
-            301 => SyntaxKind::At,
-            302 => SyntaxKind::Attach,
-            303 => SyntaxKind::Attribute,
-            304 => SyntaxKind::Authorization,
-            305 => SyntaxKind::Backward,
-            306 => SyntaxKind::Before,
-            307 => SyntaxKind::BeginP,
-            308 => SyntaxKind::Between,
-            309 => SyntaxKind::Bigint,
-            310 => SyntaxKind::Binary,
-            311 => SyntaxKind::Bit,
-            312 => SyntaxKind::BooleanP,
-            313 => SyntaxKind::Both,
-            314 => SyntaxKind::Breadth,
-            315 => SyntaxKind::By,
-            316 => SyntaxKind::Cache,
-            317 => SyntaxKind::Call,
-            318 => SyntaxKind::Called,
-            319 => SyntaxKind::Cascade,
-            320 => SyntaxKind::Cascaded,
-            321 => SyntaxKind::Case,
-            322 => SyntaxKind::Cast,
-            323 => SyntaxKind::CatalogP,
-            324 => SyntaxKind::Chain,
-            325 => SyntaxKind::CharP,
-            326 => SyntaxKind::Character,
-            327 => SyntaxKind::Characteristics,
-            328 => SyntaxKind::Check,
-            329 => SyntaxKind::Checkpoint,
-            330 => SyntaxKind::Class,
-            331 => SyntaxKind::Close,
-            332 => SyntaxKind::Cluster,
-            333 => SyntaxKind::Coalesce,
-            334 => SyntaxKind::Collate,
-            335 => SyntaxKind::Collation,
-            336 => SyntaxKind::Column,
-            337 => SyntaxKind::Columns,
-            338 => SyntaxKind::Comment,
-            339 => SyntaxKind::Comments,
-            340 => SyntaxKind::Commit,
-            341 => SyntaxKind::Committed,
-            342 => SyntaxKind::Compression,
-            343 => SyntaxKind::Concurrently,
-            344 => SyntaxKind::Configuration,
-            345 => SyntaxKind::Conflict,
-            346 => SyntaxKind::Connection,
-            347 => SyntaxKind::Constraint,
-            348 => SyntaxKind::Constraints,
-            349 => SyntaxKind::ContentP,
-            350 => SyntaxKind::ContinueP,
-            351 => SyntaxKind::ConversionP,
-            352 => SyntaxKind::Copy,
-            353 => SyntaxKind::Cost,
-            354 => SyntaxKind::Create,
-            355 => SyntaxKind::Cross,
-            356 => SyntaxKind::Csv,
-            357 => SyntaxKind::Cube,
-            358 => SyntaxKind::CurrentP,
-            359 => SyntaxKind::CurrentCatalog,
-            360 => SyntaxKind::CurrentDate,
-            361 => SyntaxKind::CurrentRole,
-            362 => SyntaxKind::CurrentSchema,
-            363 => SyntaxKind::CurrentTime,
-            364 => SyntaxKind::CurrentTimestamp,
-            365 => SyntaxKind::CurrentUser,
-            366 => SyntaxKind::Cursor,
-            367 => SyntaxKind::Cycle,
-            368 => SyntaxKind::DataP,
-            369 => SyntaxKind::Database,
-            370 => SyntaxKind::DayP,
-            371 => SyntaxKind::Deallocate,
-            372 => SyntaxKind::Dec,
-            373 => SyntaxKind::DecimalP,
-            374 => SyntaxKind::Declare,
-            375 => SyntaxKind::Default,
-            376 => SyntaxKind::Defaults,
-            377 => SyntaxKind::Deferrable,
-            378 => SyntaxKind::Deferred,
-            379 => SyntaxKind::Definer,
-            380 => SyntaxKind::DeleteP,
-            381 => SyntaxKind::Delimiter,
-            382 => SyntaxKind::Delimiters,
-            383 => SyntaxKind::Depends,
-            384 => SyntaxKind::Depth,
-            385 => SyntaxKind::Desc,
-            386 => SyntaxKind::Detach,
-            387 => SyntaxKind::Dictionary,
-            388 => SyntaxKind::DisableP,
-            389 => SyntaxKind::Discard,
-            390 => SyntaxKind::Distinct,
-            391 => SyntaxKind::Do,
-            392 => SyntaxKind::DocumentP,
-            393 => SyntaxKind::DomainP,
-            394 => SyntaxKind::DoubleP,
-            395 => SyntaxKind::Drop,
-            396 => SyntaxKind::Each,
-            397 => SyntaxKind::Else,
-            398 => SyntaxKind::EnableP,
-            399 => SyntaxKind::Encoding,
-            400 => SyntaxKind::Encrypted,
-            401 => SyntaxKind::EndP,
-            402 => SyntaxKind::EnumP,
-            403 => SyntaxKind::Escape,
-            404 => SyntaxKind::Event,
-            405 => SyntaxKind::Except,
-            406 => SyntaxKind::Exclude,
-            407 => SyntaxKind::Excluding,
-            408 => SyntaxKind::Exclusive,
-            409 => SyntaxKind::Execute,
-            410 => SyntaxKind::Exists,
-            411 => SyntaxKind::Explain,
-            412 => SyntaxKind::Expression,
-            413 => SyntaxKind::Extension,
-            414 => SyntaxKind::External,
-            415 => SyntaxKind::Extract,
-            416 => SyntaxKind::FalseP,
-            417 => SyntaxKind::Family,
-            418 => SyntaxKind::Fetch,
-            419 => SyntaxKind::Filter,
-            420 => SyntaxKind::Finalize,
-            421 => SyntaxKind::FirstP,
-            422 => SyntaxKind::FloatP,
-            423 => SyntaxKind::Following,
-            424 => SyntaxKind::For,
-            425 => SyntaxKind::Force,
-            426 => SyntaxKind::Foreign,
-            427 => SyntaxKind::Forward,
-            428 => SyntaxKind::Freeze,
-            429 => SyntaxKind::From,
-            430 => SyntaxKind::Full,
-            431 => SyntaxKind::Function,
-            432 => SyntaxKind::Functions,
-            433 => SyntaxKind::Generated,
-            434 => SyntaxKind::Global,
-            435 => SyntaxKind::Grant,
-            436 => SyntaxKind::Granted,
-            437 => SyntaxKind::Greatest,
-            438 => SyntaxKind::GroupP,
-            439 => SyntaxKind::Grouping,
-            440 => SyntaxKind::Groups,
-            441 => SyntaxKind::Handler,
-            442 => SyntaxKind::Having,
-            443 => SyntaxKind::HeaderP,
-            444 => SyntaxKind::Hold,
-            445 => SyntaxKind::HourP,
-            446 => SyntaxKind::IdentityP,
-            447 => SyntaxKind::IfP,
-            448 => SyntaxKind::Ilike,
-            449 => SyntaxKind::Immediate,
-            450 => SyntaxKind::Immutable,
-            451 => SyntaxKind::ImplicitP,
-            452 => SyntaxKind::ImportP,
-            453 => SyntaxKind::InP,
-            454 => SyntaxKind::Include,
-            455 => SyntaxKind::Including,
-            456 => SyntaxKind::Increment,
-            457 => SyntaxKind::Index,
-            458 => SyntaxKind::Indexes,
-            459 => SyntaxKind::Inherit,
-            460 => SyntaxKind::Inherits,
-            461 => SyntaxKind::Initially,
-            462 => SyntaxKind::InlineP,
-            463 => SyntaxKind::InnerP,
-            464 => SyntaxKind::Inout,
-            465 => SyntaxKind::InputP,
-            466 => SyntaxKind::Insensitive,
-            467 => SyntaxKind::Insert,
-            468 => SyntaxKind::Instead,
-            469 => SyntaxKind::IntP,
-            470 => SyntaxKind::Integer,
-            471 => SyntaxKind::Intersect,
-            472 => SyntaxKind::Interval,
-            473 => SyntaxKind::Into,
-            474 => SyntaxKind::Invoker,
-            475 => SyntaxKind::Is,
-            476 => SyntaxKind::Isnull,
-            477 => SyntaxKind::Isolation,
-            478 => SyntaxKind::Join,
-            479 => SyntaxKind::Key,
-            480 => SyntaxKind::Label,
-            481 => SyntaxKind::Language,
-            482 => SyntaxKind::LargeP,
-            483 => SyntaxKind::LastP,
-            484 => SyntaxKind::LateralP,
-            485 => SyntaxKind::Leading,
-            486 => SyntaxKind::Leakproof,
-            487 => SyntaxKind::Least,
-            488 => SyntaxKind::Left,
-            489 => SyntaxKind::Level,
-            490 => SyntaxKind::Like,
-            491 => SyntaxKind::Limit,
-            492 => SyntaxKind::Listen,
-            493 => SyntaxKind::Load,
-            494 => SyntaxKind::Local,
-            495 => SyntaxKind::Localtime,
-            496 => SyntaxKind::Localtimestamp,
-            497 => SyntaxKind::Location,
-            498 => SyntaxKind::LockP,
-            499 => SyntaxKind::Locked,
-            500 => SyntaxKind::Logged,
-            501 => SyntaxKind::Mapping,
-            502 => SyntaxKind::Match,
-            503 => SyntaxKind::Matched,
-            504 => SyntaxKind::Materialized,
-            505 => SyntaxKind::Maxvalue,
-            506 => SyntaxKind::Merge,
-            507 => SyntaxKind::Method,
-            508 => SyntaxKind::MinuteP,
-            509 => SyntaxKind::Minvalue,
-            510 => SyntaxKind::Mode,
-            511 => SyntaxKind::MonthP,
-            512 => SyntaxKind::Move,
-            513 => SyntaxKind::NameP,
-            514 => SyntaxKind::Names,
-            515 => SyntaxKind::National,
-            516 => SyntaxKind::Natural,
-            517 => SyntaxKind::Nchar,
-            518 => SyntaxKind::New,
-            519 => SyntaxKind::Next,
-            520 => SyntaxKind::Nfc,
-            521 => SyntaxKind::Nfd,
-            522 => SyntaxKind::Nfkc,
-            523 => SyntaxKind::Nfkd,
-            524 => SyntaxKind::No,
-            525 => SyntaxKind::None,
-            526 => SyntaxKind::Normalize,
-            527 => SyntaxKind::Normalized,
-            528 => SyntaxKind::Not,
-            529 => SyntaxKind::Nothing,
-            530 => SyntaxKind::Notify,
-            531 => SyntaxKind::Notnull,
-            532 => SyntaxKind::Nowait,
-            533 => SyntaxKind::NullP,
-            534 => SyntaxKind::Nullif,
-            535 => SyntaxKind::NullsP,
-            536 => SyntaxKind::Numeric,
-            537 => SyntaxKind::ObjectP,
-            538 => SyntaxKind::Of,
-            539 => SyntaxKind::Off,
-            540 => SyntaxKind::Offset,
-            541 => SyntaxKind::Oids,
-            542 => SyntaxKind::Old,
-            543 => SyntaxKind::On,
-            544 => SyntaxKind::Only,
-            545 => SyntaxKind::Operator,
-            546 => SyntaxKind::Option,
-            547 => SyntaxKind::Options,
-            548 => SyntaxKind::Or,
-            549 => SyntaxKind::Order,
-            550 => SyntaxKind::Ordinality,
-            551 => SyntaxKind::Others,
-            552 => SyntaxKind::OutP,
-            553 => SyntaxKind::OuterP,
-            554 => SyntaxKind::Over,
-            555 => SyntaxKind::Overlaps,
-            556 => SyntaxKind::Overlay,
-            557 => SyntaxKind::Overriding,
-            558 => SyntaxKind::Owned,
-            559 => SyntaxKind::Owner,
-            560 => SyntaxKind::Parallel,
-            561 => SyntaxKind::Parameter,
-            562 => SyntaxKind::Parser,
-            563 => SyntaxKind::Partial,
-            564 => SyntaxKind::Partition,
-            565 => SyntaxKind::Passing,
-            566 => SyntaxKind::Password,
-            567 => SyntaxKind::Placing,
-            568 => SyntaxKind::Plans,
-            569 => SyntaxKind::Policy,
-            570 => SyntaxKind::Position,
-            571 => SyntaxKind::Preceding,
-            572 => SyntaxKind::Precision,
-            573 => SyntaxKind::Preserve,
-            574 => SyntaxKind::Prepare,
-            575 => SyntaxKind::Prepared,
-            576 => SyntaxKind::Primary,
-            577 => SyntaxKind::Prior,
-            578 => SyntaxKind::Privileges,
-            579 => SyntaxKind::Procedural,
-            580 => SyntaxKind::Procedure,
-            581 => SyntaxKind::Procedures,
-            582 => SyntaxKind::Program,
-            583 => SyntaxKind::Publication,
-            584 => SyntaxKind::Quote,
-            585 => SyntaxKind::Range,
-            586 => SyntaxKind::Read,
-            587 => SyntaxKind::Real,
-            588 => SyntaxKind::Reassign,
-            589 => SyntaxKind::Recheck,
-            590 => SyntaxKind::Recursive,
-            591 => SyntaxKind::RefP,
-            592 => SyntaxKind::References,
-            593 => SyntaxKind::Referencing,
-            594 => SyntaxKind::Refresh,
-            595 => SyntaxKind::Reindex,
-            596 => SyntaxKind::RelativeP,
-            597 => SyntaxKind::Release,
-            598 => SyntaxKind::Rename,
-            599 => SyntaxKind::Repeatable,
-            600 => SyntaxKind::Replace,
-            601 => SyntaxKind::Replica,
-            602 => SyntaxKind::Reset,
-            603 => SyntaxKind::Restart,
-            604 => SyntaxKind::Restrict,
-            605 => SyntaxKind::Return,
-            606 => SyntaxKind::Returning,
-            607 => SyntaxKind::Returns,
-            608 => SyntaxKind::Revoke,
-            609 => SyntaxKind::Right,
-            610 => SyntaxKind::Role,
-            611 => SyntaxKind::Rollback,
-            612 => SyntaxKind::Rollup,
-            613 => SyntaxKind::Routine,
-            614 => SyntaxKind::Routines,
-            615 => SyntaxKind::Row,
-            616 => SyntaxKind::Rows,
-            617 => SyntaxKind::Rule,
-            618 => SyntaxKind::Savepoint,
-            619 => SyntaxKind::Schema,
-            620 => SyntaxKind::Schemas,
-            621 => SyntaxKind::Scroll,
-            622 => SyntaxKind::Search,
-            623 => SyntaxKind::SecondP,
-            624 => SyntaxKind::Security,
-            625 => SyntaxKind::Select,
-            626 => SyntaxKind::Sequence,
-            627 => SyntaxKind::Sequences,
-            628 => SyntaxKind::Serializable,
-            629 => SyntaxKind::Server,
-            630 => SyntaxKind::Session,
-            631 => SyntaxKind::SessionUser,
-            632 => SyntaxKind::Set,
-            633 => SyntaxKind::Sets,
-            634 => SyntaxKind::Setof,
-            635 => SyntaxKind::Share,
-            636 => SyntaxKind::Show,
-            637 => SyntaxKind::Similar,
-            638 => SyntaxKind::Simple,
-            639 => SyntaxKind::Skip,
-            640 => SyntaxKind::Smallint,
-            641 => SyntaxKind::Snapshot,
-            642 => SyntaxKind::Some,
-            643 => SyntaxKind::SqlP,
-            644 => SyntaxKind::Stable,
-            645 => SyntaxKind::StandaloneP,
-            646 => SyntaxKind::Start,
-            647 => SyntaxKind::Statement,
-            648 => SyntaxKind::Statistics,
-            649 => SyntaxKind::Stdin,
-            650 => SyntaxKind::Stdout,
-            651 => SyntaxKind::Storage,
-            652 => SyntaxKind::Stored,
-            653 => SyntaxKind::StrictP,
-            654 => SyntaxKind::StripP,
-            655 => SyntaxKind::Subscription,
-            656 => SyntaxKind::Substring,
-            657 => SyntaxKind::Support,
-            658 => SyntaxKind::Symmetric,
-            659 => SyntaxKind::Sysid,
-            660 => SyntaxKind::SystemP,
-            661 => SyntaxKind::Table,
-            662 => SyntaxKind::Tables,
-            663 => SyntaxKind::Tablesample,
-            664 => SyntaxKind::Tablespace,
-            665 => SyntaxKind::Temp,
-            666 => SyntaxKind::Template,
-            667 => SyntaxKind::Temporary,
-            668 => SyntaxKind::TextP,
-            669 => SyntaxKind::Then,
-            670 => SyntaxKind::Ties,
-            671 => SyntaxKind::Time,
-            672 => SyntaxKind::Timestamp,
-            673 => SyntaxKind::To,
-            674 => SyntaxKind::Trailing,
-            675 => SyntaxKind::Transaction,
-            676 => SyntaxKind::Transform,
-            677 => SyntaxKind::Treat,
-            678 => SyntaxKind::Trigger,
-            679 => SyntaxKind::Trim,
-            680 => SyntaxKind::TrueP,
-            681 => SyntaxKind::Truncate,
-            682 => SyntaxKind::Trusted,
-            683 => SyntaxKind::TypeP,
-            684 => SyntaxKind::TypesP,
-            685 => SyntaxKind::Uescape,
-            686 => SyntaxKind::Unbounded,
-            687 => SyntaxKind::Uncommitted,
-            688 => SyntaxKind::Unencrypted,
-            689 => SyntaxKind::Union,
-            690 => SyntaxKind::Unique,
-            691 => SyntaxKind::Unknown,
-            692 => SyntaxKind::Unlisten,
-            693 => SyntaxKind::Unlogged,
-            694 => SyntaxKind::Until,
-            695 => SyntaxKind::Update,
-            696 => SyntaxKind::User,
-            697 => SyntaxKind::Using,
-            698 => SyntaxKind::Vacuum,
-            699 => SyntaxKind::Valid,
-            700 => SyntaxKind::Validate,
-            701 => SyntaxKind::Validator,
-            702 => SyntaxKind::ValueP,
-            703 => SyntaxKind::Values,
-            704 => SyntaxKind::Varchar,
-            705 => SyntaxKind::Variadic,
-            706 => SyntaxKind::Varying,
-            707 => SyntaxKind::Verbose,
-            708 => SyntaxKind::VersionP,
-            709 => SyntaxKind::View,
-            710 => SyntaxKind::Views,
-            711 => SyntaxKind::Volatile,
-            712 => SyntaxKind::When,
-            713 => SyntaxKind::Where,
-            714 => SyntaxKind::WhitespaceP,
-            715 => SyntaxKind::Window,
-            716 => SyntaxKind::With,
-            717 => SyntaxKind::Within,
-            718 => SyntaxKind::Without,
-            719 => SyntaxKind::Work,
-            720 => SyntaxKind::Wrapper,
-            721 => SyntaxKind::Write,
-            722 => SyntaxKind::XmlP,
-            723 => SyntaxKind::Xmlattributes,
-            724 => SyntaxKind::Xmlconcat,
-            725 => SyntaxKind::Xmlelement,
-            726 => SyntaxKind::Xmlexists,
-            727 => SyntaxKind::Xmlforest,
-            728 => SyntaxKind::Xmlnamespaces,
-            729 => SyntaxKind::Xmlparse,
-            730 => SyntaxKind::Xmlpi,
-            731 => SyntaxKind::Xmlroot,
-            732 => SyntaxKind::Xmlserialize,
-            733 => SyntaxKind::Xmltable,
-            734 => SyntaxKind::YearP,
-            735 => SyntaxKind::YesP,
-            736 => SyntaxKind::Zone,
-            737 => SyntaxKind::NotLa,
-            738 => SyntaxKind::NullsLa,
-            739 => SyntaxKind::WithLa,
-            740 => SyntaxKind::ModeTypeName,
-            741 => SyntaxKind::ModePlpgsqlExpr,
-            742 => SyntaxKind::ModePlpgsqlAssign1,
-            743 => SyntaxKind::ModePlpgsqlAssign2,
-            744 => SyntaxKind::ModePlpgsqlAssign3,
-            745 => SyntaxKind::Uminus,
-            _ => panic!("Unknown token"),
-        }
-    }
-}
diff --git a/crates/parser/src/syntax_node.rs b/crates/parser/src/syntax_node.rs
index 95a9c5b5..d962427e 100644
--- a/crates/parser/src/syntax_node.rs
+++ b/crates/parser/src/syntax_node.rs
@@ -6,7 +6,7 @@
 //! The *real* implementation is in the (language-agnostic) `cstree` crate, this
 //! module just wraps its API.
 
-use crate::syntax_kind_generated::SyntaxKind;
+use crate::syntax_kind_codegen::SyntaxKind;
 
 pub type SyntaxNode = cstree::syntax::SyntaxNode<SyntaxKind>;
 pub type SyntaxToken = cstree::syntax::SyntaxToken<SyntaxKind>;
diff --git a/libpg_query b/libpg_query
new file mode 160000
index 00000000..9b21e329
--- /dev/null
+++ b/libpg_query
@@ -0,0 +1 @@
+Subproject commit 9b21e3295402a0d0ee9a50c468d426c2dbb73ee6

From 502c79c13cb4effa50fa8c2336bd8e5923aadc35 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Sat, 26 Aug 2023 16:44:14 +0200
Subject: [PATCH 13/23] chore: housekeeping

---
 crates/parser/proto/source.proto       | 3673 ------------------------
 crates/sourcegen/Cargo.toml            |   10 -
 crates/sourcegen/src/attribute.rs      |   76 -
 crates/sourcegen/src/builder.rs        |   10 -
 crates/sourcegen/src/comment.rs        |   58 -
 crates/sourcegen/src/enum_.rs          |  100 -
 crates/sourcegen/src/function.rs       |  101 -
 crates/sourcegen/src/implementation.rs |   54 -
 crates/sourcegen/src/imports.rs        |   64 -
 crates/sourcegen/src/lib.rs            |   62 -
 crates/sourcegen/src/match_.rs         |   65 -
 crates/sourcegen/src/source_file.rs    |   63 -
 crates/sourcegen/src/struct_.rs        |  100 -
 13 files changed, 4436 deletions(-)
 delete mode 100644 crates/parser/proto/source.proto
 delete mode 100644 crates/sourcegen/Cargo.toml
 delete mode 100644 crates/sourcegen/src/attribute.rs
 delete mode 100644 crates/sourcegen/src/builder.rs
 delete mode 100644 crates/sourcegen/src/comment.rs
 delete mode 100644 crates/sourcegen/src/enum_.rs
 delete mode 100644 crates/sourcegen/src/function.rs
 delete mode 100644 crates/sourcegen/src/implementation.rs
 delete mode 100644 crates/sourcegen/src/imports.rs
 delete mode 100644 crates/sourcegen/src/lib.rs
 delete mode 100644 crates/sourcegen/src/match_.rs
 delete mode 100644 crates/sourcegen/src/source_file.rs
 delete mode 100644 crates/sourcegen/src/struct_.rs

diff --git a/crates/parser/proto/source.proto b/crates/parser/proto/source.proto
deleted file mode 100644
index e34f5869..00000000
--- a/crates/parser/proto/source.proto
+++ /dev/null
@@ -1,3673 +0,0 @@
-// This file is copied from https://github.com/pganalyze/libpg_query/blob/fc5775e0622955f9e5d887dfaf0b7bbf7f9046f9/protobuf/pg_query.proto
-// This file is autogenerated by ./scripts/generate_protobuf_and_funcs.rb
-
-syntax = "proto3";
-
-package pg_query;
-
-message ParseResult {
-  int32 version = 1;
-  repeated RawStmt stmts = 2;
-}
-
-message ScanResult {
-  int32 version = 1;
-  repeated ScanToken tokens = 2;
-}
-
-message Node {
-  oneof node {
-		Alias alias = 1 [json_name="Alias"];
-    RangeVar range_var = 2 [json_name="RangeVar"];
-    TableFunc table_func = 3 [json_name="TableFunc"];
-    Var var = 4 [json_name="Var"];
-    Param param = 5 [json_name="Param"];
-    Aggref aggref = 6 [json_name="Aggref"];
-    GroupingFunc grouping_func = 7 [json_name="GroupingFunc"];
-    WindowFunc window_func = 8 [json_name="WindowFunc"];
-    SubscriptingRef subscripting_ref = 9 [json_name="SubscriptingRef"];
-    FuncExpr func_expr = 10 [json_name="FuncExpr"];
-    NamedArgExpr named_arg_expr = 11 [json_name="NamedArgExpr"];
-    OpExpr op_expr = 12 [json_name="OpExpr"];
-    DistinctExpr distinct_expr = 13 [json_name="DistinctExpr"];
-    NullIfExpr null_if_expr = 14 [json_name="NullIfExpr"];
-    ScalarArrayOpExpr scalar_array_op_expr = 15 [json_name="ScalarArrayOpExpr"];
-    BoolExpr bool_expr = 16 [json_name="BoolExpr"];
-    SubLink sub_link = 17 [json_name="SubLink"];
-    SubPlan sub_plan = 18 [json_name="SubPlan"];
-    AlternativeSubPlan alternative_sub_plan = 19 [json_name="AlternativeSubPlan"];
-    FieldSelect field_select = 20 [json_name="FieldSelect"];
-    FieldStore field_store = 21 [json_name="FieldStore"];
-    RelabelType relabel_type = 22 [json_name="RelabelType"];
-    CoerceViaIO coerce_via_io = 23 [json_name="CoerceViaIO"];
-    ArrayCoerceExpr array_coerce_expr = 24 [json_name="ArrayCoerceExpr"];
-    ConvertRowtypeExpr convert_rowtype_expr = 25 [json_name="ConvertRowtypeExpr"];
-    CollateExpr collate_expr = 26 [json_name="CollateExpr"];
-    CaseExpr case_expr = 27 [json_name="CaseExpr"];
-    CaseWhen case_when = 28 [json_name="CaseWhen"];
-    CaseTestExpr case_test_expr = 29 [json_name="CaseTestExpr"];
-    ArrayExpr array_expr = 30 [json_name="ArrayExpr"];
-    RowExpr row_expr = 31 [json_name="RowExpr"];
-    RowCompareExpr row_compare_expr = 32 [json_name="RowCompareExpr"];
-    CoalesceExpr coalesce_expr = 33 [json_name="CoalesceExpr"];
-    MinMaxExpr min_max_expr = 34 [json_name="MinMaxExpr"];
-    SQLValueFunction sqlvalue_function = 35 [json_name="SQLValueFunction"];
-    XmlExpr xml_expr = 36 [json_name="XmlExpr"];
-    NullTest null_test = 37 [json_name="NullTest"];
-    BooleanTest boolean_test = 38 [json_name="BooleanTest"];
-    CoerceToDomain coerce_to_domain = 39 [json_name="CoerceToDomain"];
-    CoerceToDomainValue coerce_to_domain_value = 40 [json_name="CoerceToDomainValue"];
-    SetToDefault set_to_default = 41 [json_name="SetToDefault"];
-    CurrentOfExpr current_of_expr = 42 [json_name="CurrentOfExpr"];
-    NextValueExpr next_value_expr = 43 [json_name="NextValueExpr"];
-    InferenceElem inference_elem = 44 [json_name="InferenceElem"];
-    TargetEntry target_entry = 45 [json_name="TargetEntry"];
-    RangeTblRef range_tbl_ref = 46 [json_name="RangeTblRef"];
-    JoinExpr join_expr = 47 [json_name="JoinExpr"];
-    FromExpr from_expr = 48 [json_name="FromExpr"];
-    OnConflictExpr on_conflict_expr = 49 [json_name="OnConflictExpr"];
-    IntoClause into_clause = 50 [json_name="IntoClause"];
-    MergeAction merge_action = 51 [json_name="MergeAction"];
-    RawStmt raw_stmt = 52 [json_name="RawStmt"];
-    Query query = 53 [json_name="Query"];
-    InsertStmt insert_stmt = 54 [json_name="InsertStmt"];
-    DeleteStmt delete_stmt = 55 [json_name="DeleteStmt"];
-    UpdateStmt update_stmt = 56 [json_name="UpdateStmt"];
-    MergeStmt merge_stmt = 57 [json_name="MergeStmt"];
-    SelectStmt select_stmt = 58 [json_name="SelectStmt"];
-    ReturnStmt return_stmt = 59 [json_name="ReturnStmt"];
-    PLAssignStmt plassign_stmt = 60 [json_name="PLAssignStmt"];
-    AlterTableStmt alter_table_stmt = 61 [json_name="AlterTableStmt"];
-    AlterTableCmd alter_table_cmd = 62 [json_name="AlterTableCmd"];
-    AlterDomainStmt alter_domain_stmt = 63 [json_name="AlterDomainStmt"];
-    SetOperationStmt set_operation_stmt = 64 [json_name="SetOperationStmt"];
-    GrantStmt grant_stmt = 65 [json_name="GrantStmt"];
-    GrantRoleStmt grant_role_stmt = 66 [json_name="GrantRoleStmt"];
-    AlterDefaultPrivilegesStmt alter_default_privileges_stmt = 67 [json_name="AlterDefaultPrivilegesStmt"];
-    ClosePortalStmt close_portal_stmt = 68 [json_name="ClosePortalStmt"];
-    ClusterStmt cluster_stmt = 69 [json_name="ClusterStmt"];
-    CopyStmt copy_stmt = 70 [json_name="CopyStmt"];
-    CreateStmt create_stmt = 71 [json_name="CreateStmt"];
-    DefineStmt define_stmt = 72 [json_name="DefineStmt"];
-    DropStmt drop_stmt = 73 [json_name="DropStmt"];
-    TruncateStmt truncate_stmt = 74 [json_name="TruncateStmt"];
-    CommentStmt comment_stmt = 75 [json_name="CommentStmt"];
-    FetchStmt fetch_stmt = 76 [json_name="FetchStmt"];
-    IndexStmt index_stmt = 77 [json_name="IndexStmt"];
-    CreateFunctionStmt create_function_stmt = 78 [json_name="CreateFunctionStmt"];
-    AlterFunctionStmt alter_function_stmt = 79 [json_name="AlterFunctionStmt"];
-    DoStmt do_stmt = 80 [json_name="DoStmt"];
-    RenameStmt rename_stmt = 81 [json_name="RenameStmt"];
-    RuleStmt rule_stmt = 82 [json_name="RuleStmt"];
-    NotifyStmt notify_stmt = 83 [json_name="NotifyStmt"];
-    ListenStmt listen_stmt = 84 [json_name="ListenStmt"];
-    UnlistenStmt unlisten_stmt = 85 [json_name="UnlistenStmt"];
-    TransactionStmt transaction_stmt = 86 [json_name="TransactionStmt"];
-    ViewStmt view_stmt = 87 [json_name="ViewStmt"];
-    LoadStmt load_stmt = 88 [json_name="LoadStmt"];
-    CreateDomainStmt create_domain_stmt = 89 [json_name="CreateDomainStmt"];
-    CreatedbStmt createdb_stmt = 90 [json_name="CreatedbStmt"];
-    DropdbStmt dropdb_stmt = 91 [json_name="DropdbStmt"];
-    VacuumStmt vacuum_stmt = 92 [json_name="VacuumStmt"];
-    ExplainStmt explain_stmt = 93 [json_name="ExplainStmt"];
-    CreateTableAsStmt create_table_as_stmt = 94 [json_name="CreateTableAsStmt"];
-    CreateSeqStmt create_seq_stmt = 95 [json_name="CreateSeqStmt"];
-    AlterSeqStmt alter_seq_stmt = 96 [json_name="AlterSeqStmt"];
-    VariableSetStmt variable_set_stmt = 97 [json_name="VariableSetStmt"];
-    VariableShowStmt variable_show_stmt = 98 [json_name="VariableShowStmt"];
-    DiscardStmt discard_stmt = 99 [json_name="DiscardStmt"];
-    CreateTrigStmt create_trig_stmt = 100 [json_name="CreateTrigStmt"];
-    CreatePLangStmt create_plang_stmt = 101 [json_name="CreatePLangStmt"];
-    CreateRoleStmt create_role_stmt = 102 [json_name="CreateRoleStmt"];
-    AlterRoleStmt alter_role_stmt = 103 [json_name="AlterRoleStmt"];
-    DropRoleStmt drop_role_stmt = 104 [json_name="DropRoleStmt"];
-    LockStmt lock_stmt = 105 [json_name="LockStmt"];
-    ConstraintsSetStmt constraints_set_stmt = 106 [json_name="ConstraintsSetStmt"];
-    ReindexStmt reindex_stmt = 107 [json_name="ReindexStmt"];
-    CheckPointStmt check_point_stmt = 108 [json_name="CheckPointStmt"];
-    CreateSchemaStmt create_schema_stmt = 109 [json_name="CreateSchemaStmt"];
-    AlterDatabaseStmt alter_database_stmt = 110 [json_name="AlterDatabaseStmt"];
-    AlterDatabaseRefreshCollStmt alter_database_refresh_coll_stmt = 111 [json_name="AlterDatabaseRefreshCollStmt"];
-    AlterDatabaseSetStmt alter_database_set_stmt = 112 [json_name="AlterDatabaseSetStmt"];
-    AlterRoleSetStmt alter_role_set_stmt = 113 [json_name="AlterRoleSetStmt"];
-    CreateConversionStmt create_conversion_stmt = 114 [json_name="CreateConversionStmt"];
-    CreateCastStmt create_cast_stmt = 115 [json_name="CreateCastStmt"];
-    CreateOpClassStmt create_op_class_stmt = 116 [json_name="CreateOpClassStmt"];
-    CreateOpFamilyStmt create_op_family_stmt = 117 [json_name="CreateOpFamilyStmt"];
-    AlterOpFamilyStmt alter_op_family_stmt = 118 [json_name="AlterOpFamilyStmt"];
-    PrepareStmt prepare_stmt = 119 [json_name="PrepareStmt"];
-    ExecuteStmt execute_stmt = 120 [json_name="ExecuteStmt"];
-    DeallocateStmt deallocate_stmt = 121 [json_name="DeallocateStmt"];
-    DeclareCursorStmt declare_cursor_stmt = 122 [json_name="DeclareCursorStmt"];
-    CreateTableSpaceStmt create_table_space_stmt = 123 [json_name="CreateTableSpaceStmt"];
-    DropTableSpaceStmt drop_table_space_stmt = 124 [json_name="DropTableSpaceStmt"];
-    AlterObjectDependsStmt alter_object_depends_stmt = 125 [json_name="AlterObjectDependsStmt"];
-    AlterObjectSchemaStmt alter_object_schema_stmt = 126 [json_name="AlterObjectSchemaStmt"];
-    AlterOwnerStmt alter_owner_stmt = 127 [json_name="AlterOwnerStmt"];
-    AlterOperatorStmt alter_operator_stmt = 128 [json_name="AlterOperatorStmt"];
-    AlterTypeStmt alter_type_stmt = 129 [json_name="AlterTypeStmt"];
-    DropOwnedStmt drop_owned_stmt = 130 [json_name="DropOwnedStmt"];
-    ReassignOwnedStmt reassign_owned_stmt = 131 [json_name="ReassignOwnedStmt"];
-    CompositeTypeStmt composite_type_stmt = 132 [json_name="CompositeTypeStmt"];
-    CreateEnumStmt create_enum_stmt = 133 [json_name="CreateEnumStmt"];
-    CreateRangeStmt create_range_stmt = 134 [json_name="CreateRangeStmt"];
-    AlterEnumStmt alter_enum_stmt = 135 [json_name="AlterEnumStmt"];
-    AlterTSDictionaryStmt alter_tsdictionary_stmt = 136 [json_name="AlterTSDictionaryStmt"];
-    AlterTSConfigurationStmt alter_tsconfiguration_stmt = 137 [json_name="AlterTSConfigurationStmt"];
-    CreateFdwStmt create_fdw_stmt = 138 [json_name="CreateFdwStmt"];
-    AlterFdwStmt alter_fdw_stmt = 139 [json_name="AlterFdwStmt"];
-    CreateForeignServerStmt create_foreign_server_stmt = 140 [json_name="CreateForeignServerStmt"];
-    AlterForeignServerStmt alter_foreign_server_stmt = 141 [json_name="AlterForeignServerStmt"];
-    CreateUserMappingStmt create_user_mapping_stmt = 142 [json_name="CreateUserMappingStmt"];
-    AlterUserMappingStmt alter_user_mapping_stmt = 143 [json_name="AlterUserMappingStmt"];
-    DropUserMappingStmt drop_user_mapping_stmt = 144 [json_name="DropUserMappingStmt"];
-    AlterTableSpaceOptionsStmt alter_table_space_options_stmt = 145 [json_name="AlterTableSpaceOptionsStmt"];
-    AlterTableMoveAllStmt alter_table_move_all_stmt = 146 [json_name="AlterTableMoveAllStmt"];
-    SecLabelStmt sec_label_stmt = 147 [json_name="SecLabelStmt"];
-    CreateForeignTableStmt create_foreign_table_stmt = 148 [json_name="CreateForeignTableStmt"];
-    ImportForeignSchemaStmt import_foreign_schema_stmt = 149 [json_name="ImportForeignSchemaStmt"];
-    CreateExtensionStmt create_extension_stmt = 150 [json_name="CreateExtensionStmt"];
-    AlterExtensionStmt alter_extension_stmt = 151 [json_name="AlterExtensionStmt"];
-    AlterExtensionContentsStmt alter_extension_contents_stmt = 152 [json_name="AlterExtensionContentsStmt"];
-    CreateEventTrigStmt create_event_trig_stmt = 153 [json_name="CreateEventTrigStmt"];
-    AlterEventTrigStmt alter_event_trig_stmt = 154 [json_name="AlterEventTrigStmt"];
-    RefreshMatViewStmt refresh_mat_view_stmt = 155 [json_name="RefreshMatViewStmt"];
-    ReplicaIdentityStmt replica_identity_stmt = 156 [json_name="ReplicaIdentityStmt"];
-    AlterSystemStmt alter_system_stmt = 157 [json_name="AlterSystemStmt"];
-    CreatePolicyStmt create_policy_stmt = 158 [json_name="CreatePolicyStmt"];
-    AlterPolicyStmt alter_policy_stmt = 159 [json_name="AlterPolicyStmt"];
-    CreateTransformStmt create_transform_stmt = 160 [json_name="CreateTransformStmt"];
-    CreateAmStmt create_am_stmt = 161 [json_name="CreateAmStmt"];
-    CreatePublicationStmt create_publication_stmt = 162 [json_name="CreatePublicationStmt"];
-    AlterPublicationStmt alter_publication_stmt = 163 [json_name="AlterPublicationStmt"];
-    CreateSubscriptionStmt create_subscription_stmt = 164 [json_name="CreateSubscriptionStmt"];
-    AlterSubscriptionStmt alter_subscription_stmt = 165 [json_name="AlterSubscriptionStmt"];
-    DropSubscriptionStmt drop_subscription_stmt = 166 [json_name="DropSubscriptionStmt"];
-    CreateStatsStmt create_stats_stmt = 167 [json_name="CreateStatsStmt"];
-    AlterCollationStmt alter_collation_stmt = 168 [json_name="AlterCollationStmt"];
-    CallStmt call_stmt = 169 [json_name="CallStmt"];
-    AlterStatsStmt alter_stats_stmt = 170 [json_name="AlterStatsStmt"];
-    A_Expr a_expr = 171 [json_name="A_Expr"];
-    ColumnRef column_ref = 172 [json_name="ColumnRef"];
-    ParamRef param_ref = 173 [json_name="ParamRef"];
-    FuncCall func_call = 174 [json_name="FuncCall"];
-    A_Star a_star = 175 [json_name="A_Star"];
-    A_Indices a_indices = 176 [json_name="A_Indices"];
-    A_Indirection a_indirection = 177 [json_name="A_Indirection"];
-    A_ArrayExpr a_array_expr = 178 [json_name="A_ArrayExpr"];
-    ResTarget res_target = 179 [json_name="ResTarget"];
-    MultiAssignRef multi_assign_ref = 180 [json_name="MultiAssignRef"];
-    TypeCast type_cast = 181 [json_name="TypeCast"];
-    CollateClause collate_clause = 182 [json_name="CollateClause"];
-    SortBy sort_by = 183 [json_name="SortBy"];
-    WindowDef window_def = 184 [json_name="WindowDef"];
-    RangeSubselect range_subselect = 185 [json_name="RangeSubselect"];
-    RangeFunction range_function = 186 [json_name="RangeFunction"];
-    RangeTableSample range_table_sample = 187 [json_name="RangeTableSample"];
-    RangeTableFunc range_table_func = 188 [json_name="RangeTableFunc"];
-    RangeTableFuncCol range_table_func_col = 189 [json_name="RangeTableFuncCol"];
-    TypeName type_name = 190 [json_name="TypeName"];
-    ColumnDef column_def = 191 [json_name="ColumnDef"];
-    IndexElem index_elem = 192 [json_name="IndexElem"];
-    StatsElem stats_elem = 193 [json_name="StatsElem"];
-    Constraint constraint = 194 [json_name="Constraint"];
-    DefElem def_elem = 195 [json_name="DefElem"];
-    RangeTblEntry range_tbl_entry = 196 [json_name="RangeTblEntry"];
-    RangeTblFunction range_tbl_function = 197 [json_name="RangeTblFunction"];
-    TableSampleClause table_sample_clause = 198 [json_name="TableSampleClause"];
-    WithCheckOption with_check_option = 199 [json_name="WithCheckOption"];
-    SortGroupClause sort_group_clause = 200 [json_name="SortGroupClause"];
-    GroupingSet grouping_set = 201 [json_name="GroupingSet"];
-    WindowClause window_clause = 202 [json_name="WindowClause"];
-    ObjectWithArgs object_with_args = 203 [json_name="ObjectWithArgs"];
-    AccessPriv access_priv = 204 [json_name="AccessPriv"];
-    CreateOpClassItem create_op_class_item = 205 [json_name="CreateOpClassItem"];
-    TableLikeClause table_like_clause = 206 [json_name="TableLikeClause"];
-    FunctionParameter function_parameter = 207 [json_name="FunctionParameter"];
-    LockingClause locking_clause = 208 [json_name="LockingClause"];
-    RowMarkClause row_mark_clause = 209 [json_name="RowMarkClause"];
-    XmlSerialize xml_serialize = 210 [json_name="XmlSerialize"];
-    WithClause with_clause = 211 [json_name="WithClause"];
-    InferClause infer_clause = 212 [json_name="InferClause"];
-    OnConflictClause on_conflict_clause = 213 [json_name="OnConflictClause"];
-    CTESearchClause ctesearch_clause = 214 [json_name="CTESearchClause"];
-    CTECycleClause ctecycle_clause = 215 [json_name="CTECycleClause"];
-    CommonTableExpr common_table_expr = 216 [json_name="CommonTableExpr"];
-    MergeWhenClause merge_when_clause = 217 [json_name="MergeWhenClause"];
-    RoleSpec role_spec = 218 [json_name="RoleSpec"];
-    TriggerTransition trigger_transition = 219 [json_name="TriggerTransition"];
-    PartitionElem partition_elem = 220 [json_name="PartitionElem"];
-    PartitionSpec partition_spec = 221 [json_name="PartitionSpec"];
-    PartitionBoundSpec partition_bound_spec = 222 [json_name="PartitionBoundSpec"];
-    PartitionRangeDatum partition_range_datum = 223 [json_name="PartitionRangeDatum"];
-    PartitionCmd partition_cmd = 224 [json_name="PartitionCmd"];
-    VacuumRelation vacuum_relation = 225 [json_name="VacuumRelation"];
-    PublicationObjSpec publication_obj_spec = 226 [json_name="PublicationObjSpec"];
-    PublicationTable publication_table = 227 [json_name="PublicationTable"];
-    InlineCodeBlock inline_code_block = 228 [json_name="InlineCodeBlock"];
-    CallContext call_context = 229 [json_name="CallContext"];
-    Integer integer = 230 [json_name="Integer"];
-    Float float = 231 [json_name="Float"];
-    Boolean boolean = 232 [json_name="Boolean"];
-    String string = 233 [json_name="String"];
-    BitString bit_string = 234 [json_name="BitString"];
-    List list = 235 [json_name="List"];
-    IntList int_list = 236 [json_name="IntList"];
-    OidList oid_list = 237 [json_name="OidList"];
-    A_Const a_const = 238 [json_name="A_Const"];
-  }
-}
-
-message Integer
-{
-  int32 ival = 1; /* machine integer */
-}
-
-message Float
-{
-  string fval = 1; /* string */
-}
-
-message Boolean
-{
-  bool boolval = 1;
-}
-
-message String
-{
-  string sval = 1; /* string */
-}
-
-message BitString
-{
-  string bsval = 1; /* string */
-}
-
-message List
-{
-  repeated Node items = 1;
-}
-
-message OidList
-{
-  repeated Node items = 1;
-}
-
-message IntList
-{
-  repeated Node items = 1;
-}
-
-message A_Const
-{
-  oneof val {
-    Integer ival = 1;
-    Float fval = 2;
-    Boolean boolval = 3;
-    String sval = 4;
-    BitString bsval = 5;
-  }
-  bool isnull = 10;
-  int32 location = 11;
-}
-
-message Alias
-{
-  string aliasname = 1 [json_name="aliasname"];
-  repeated Node colnames = 2 [json_name="colnames"];
-}
-
-message RangeVar
-{
-  string catalogname = 1 [json_name="catalogname"];
-  string schemaname = 2 [json_name="schemaname"];
-  string relname = 3 [json_name="relname"];
-  bool inh = 4 [json_name="inh"];
-  string relpersistence = 5 [json_name="relpersistence"];
-  Alias alias = 6 [json_name="alias"];
-  int32 location = 7 [json_name="location"];
-}
-
-message TableFunc
-{
-  repeated Node ns_uris = 1 [json_name="ns_uris"];
-  repeated Node ns_names = 2 [json_name="ns_names"];
-  Node docexpr = 3 [json_name="docexpr"];
-  Node rowexpr = 4 [json_name="rowexpr"];
-  repeated Node colnames = 5 [json_name="colnames"];
-  repeated Node coltypes = 6 [json_name="coltypes"];
-  repeated Node coltypmods = 7 [json_name="coltypmods"];
-  repeated Node colcollations = 8 [json_name="colcollations"];
-  repeated Node colexprs = 9 [json_name="colexprs"];
-  repeated Node coldefexprs = 10 [json_name="coldefexprs"];
-  repeated uint64 notnulls = 11 [json_name="notnulls"];
-  int32 ordinalitycol = 12 [json_name="ordinalitycol"];
-  int32 location = 13 [json_name="location"];
-}
-
-message Var
-{
-  Node xpr = 1 [json_name="xpr"];
-  int32 varno = 2 [json_name="varno"];
-  int32 varattno = 3 [json_name="varattno"];
-  uint32 vartype = 4 [json_name="vartype"];
-  int32 vartypmod = 5 [json_name="vartypmod"];
-  uint32 varcollid = 6 [json_name="varcollid"];
-  uint32 varlevelsup = 7 [json_name="varlevelsup"];
-  uint32 varnosyn = 8 [json_name="varnosyn"];
-  int32 varattnosyn = 9 [json_name="varattnosyn"];
-  int32 location = 10 [json_name="location"];
-}
-
-message Param
-{
-  Node xpr = 1 [json_name="xpr"];
-  ParamKind paramkind = 2 [json_name="paramkind"];
-  int32 paramid = 3 [json_name="paramid"];
-  uint32 paramtype = 4 [json_name="paramtype"];
-  int32 paramtypmod = 5 [json_name="paramtypmod"];
-  uint32 paramcollid = 6 [json_name="paramcollid"];
-  int32 location = 7 [json_name="location"];
-}
-
-message Aggref
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 aggfnoid = 2 [json_name="aggfnoid"];
-  uint32 aggtype = 3 [json_name="aggtype"];
-  uint32 aggcollid = 4 [json_name="aggcollid"];
-  uint32 inputcollid = 5 [json_name="inputcollid"];
-  uint32 aggtranstype = 6 [json_name="aggtranstype"];
-  repeated Node aggargtypes = 7 [json_name="aggargtypes"];
-  repeated Node aggdirectargs = 8 [json_name="aggdirectargs"];
-  repeated Node args = 9 [json_name="args"];
-  repeated Node aggorder = 10 [json_name="aggorder"];
-  repeated Node aggdistinct = 11 [json_name="aggdistinct"];
-  Node aggfilter = 12 [json_name="aggfilter"];
-  bool aggstar = 13 [json_name="aggstar"];
-  bool aggvariadic = 14 [json_name="aggvariadic"];
-  string aggkind = 15 [json_name="aggkind"];
-  uint32 agglevelsup = 16 [json_name="agglevelsup"];
-  AggSplit aggsplit = 17 [json_name="aggsplit"];
-  int32 aggno = 18 [json_name="aggno"];
-  int32 aggtransno = 19 [json_name="aggtransno"];
-  int32 location = 20 [json_name="location"];
-}
-
-message GroupingFunc
-{
-  Node xpr = 1 [json_name="xpr"];
-  repeated Node args = 2 [json_name="args"];
-  repeated Node refs = 3 [json_name="refs"];
-  repeated Node cols = 4 [json_name="cols"];
-  uint32 agglevelsup = 5 [json_name="agglevelsup"];
-  int32 location = 6 [json_name="location"];
-}
-
-message WindowFunc
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 winfnoid = 2 [json_name="winfnoid"];
-  uint32 wintype = 3 [json_name="wintype"];
-  uint32 wincollid = 4 [json_name="wincollid"];
-  uint32 inputcollid = 5 [json_name="inputcollid"];
-  repeated Node args = 6 [json_name="args"];
-  Node aggfilter = 7 [json_name="aggfilter"];
-  uint32 winref = 8 [json_name="winref"];
-  bool winstar = 9 [json_name="winstar"];
-  bool winagg = 10 [json_name="winagg"];
-  int32 location = 11 [json_name="location"];
-}
-
-message SubscriptingRef
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 refcontainertype = 2 [json_name="refcontainertype"];
-  uint32 refelemtype = 3 [json_name="refelemtype"];
-  uint32 refrestype = 4 [json_name="refrestype"];
-  int32 reftypmod = 5 [json_name="reftypmod"];
-  uint32 refcollid = 6 [json_name="refcollid"];
-  repeated Node refupperindexpr = 7 [json_name="refupperindexpr"];
-  repeated Node reflowerindexpr = 8 [json_name="reflowerindexpr"];
-  Node refexpr = 9 [json_name="refexpr"];
-  Node refassgnexpr = 10 [json_name="refassgnexpr"];
-}
-
-message FuncExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 funcid = 2 [json_name="funcid"];
-  uint32 funcresulttype = 3 [json_name="funcresulttype"];
-  bool funcretset = 4 [json_name="funcretset"];
-  bool funcvariadic = 5 [json_name="funcvariadic"];
-  CoercionForm funcformat = 6 [json_name="funcformat"];
-  uint32 funccollid = 7 [json_name="funccollid"];
-  uint32 inputcollid = 8 [json_name="inputcollid"];
-  repeated Node args = 9 [json_name="args"];
-  int32 location = 10 [json_name="location"];
-}
-
-message NamedArgExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  string name = 3 [json_name="name"];
-  int32 argnumber = 4 [json_name="argnumber"];
-  int32 location = 5 [json_name="location"];
-}
-
-message OpExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 opno = 2 [json_name="opno"];
-  uint32 opfuncid = 3 [json_name="opfuncid"];
-  uint32 opresulttype = 4 [json_name="opresulttype"];
-  bool opretset = 5 [json_name="opretset"];
-  uint32 opcollid = 6 [json_name="opcollid"];
-  uint32 inputcollid = 7 [json_name="inputcollid"];
-  repeated Node args = 8 [json_name="args"];
-  int32 location = 9 [json_name="location"];
-}
-
-message DistinctExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 opno = 2 [json_name="opno"];
-  uint32 opfuncid = 3 [json_name="opfuncid"];
-  uint32 opresulttype = 4 [json_name="opresulttype"];
-  bool opretset = 5 [json_name="opretset"];
-  uint32 opcollid = 6 [json_name="opcollid"];
-  uint32 inputcollid = 7 [json_name="inputcollid"];
-  repeated Node args = 8 [json_name="args"];
-  int32 location = 9 [json_name="location"];
-}
-
-message NullIfExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 opno = 2 [json_name="opno"];
-  uint32 opfuncid = 3 [json_name="opfuncid"];
-  uint32 opresulttype = 4 [json_name="opresulttype"];
-  bool opretset = 5 [json_name="opretset"];
-  uint32 opcollid = 6 [json_name="opcollid"];
-  uint32 inputcollid = 7 [json_name="inputcollid"];
-  repeated Node args = 8 [json_name="args"];
-  int32 location = 9 [json_name="location"];
-}
-
-message ScalarArrayOpExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 opno = 2 [json_name="opno"];
-  uint32 opfuncid = 3 [json_name="opfuncid"];
-  uint32 hashfuncid = 4 [json_name="hashfuncid"];
-  uint32 negfuncid = 5 [json_name="negfuncid"];
-  bool use_or = 6 [json_name="useOr"];
-  uint32 inputcollid = 7 [json_name="inputcollid"];
-  repeated Node args = 8 [json_name="args"];
-  int32 location = 9 [json_name="location"];
-}
-
-message BoolExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  BoolExprType boolop = 2 [json_name="boolop"];
-  repeated Node args = 3 [json_name="args"];
-  int32 location = 4 [json_name="location"];
-}
-
-message SubLink
-{
-  Node xpr = 1 [json_name="xpr"];
-  SubLinkType sub_link_type = 2 [json_name="subLinkType"];
-  int32 sub_link_id = 3 [json_name="subLinkId"];
-  Node testexpr = 4 [json_name="testexpr"];
-  repeated Node oper_name = 5 [json_name="operName"];
-  Node subselect = 6 [json_name="subselect"];
-  int32 location = 7 [json_name="location"];
-}
-
-message SubPlan
-{
-  Node xpr = 1 [json_name="xpr"];
-  SubLinkType sub_link_type = 2 [json_name="subLinkType"];
-  Node testexpr = 3 [json_name="testexpr"];
-  repeated Node param_ids = 4 [json_name="paramIds"];
-  int32 plan_id = 5 [json_name="plan_id"];
-  string plan_name = 6 [json_name="plan_name"];
-  uint32 first_col_type = 7 [json_name="firstColType"];
-  int32 first_col_typmod = 8 [json_name="firstColTypmod"];
-  uint32 first_col_collation = 9 [json_name="firstColCollation"];
-  bool use_hash_table = 10 [json_name="useHashTable"];
-  bool unknown_eq_false = 11 [json_name="unknownEqFalse"];
-  bool parallel_safe = 12 [json_name="parallel_safe"];
-  repeated Node set_param = 13 [json_name="setParam"];
-  repeated Node par_param = 14 [json_name="parParam"];
-  repeated Node args = 15 [json_name="args"];
-  double startup_cost = 16 [json_name="startup_cost"];
-  double per_call_cost = 17 [json_name="per_call_cost"];
-}
-
-message AlternativeSubPlan
-{
-  Node xpr = 1 [json_name="xpr"];
-  repeated Node subplans = 2 [json_name="subplans"];
-}
-
-message FieldSelect
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  int32 fieldnum = 3 [json_name="fieldnum"];
-  uint32 resulttype = 4 [json_name="resulttype"];
-  int32 resulttypmod = 5 [json_name="resulttypmod"];
-  uint32 resultcollid = 6 [json_name="resultcollid"];
-}
-
-message FieldStore
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  repeated Node newvals = 3 [json_name="newvals"];
-  repeated Node fieldnums = 4 [json_name="fieldnums"];
-  uint32 resulttype = 5 [json_name="resulttype"];
-}
-
-message RelabelType
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  uint32 resulttype = 3 [json_name="resulttype"];
-  int32 resulttypmod = 4 [json_name="resulttypmod"];
-  uint32 resultcollid = 5 [json_name="resultcollid"];
-  CoercionForm relabelformat = 6 [json_name="relabelformat"];
-  int32 location = 7 [json_name="location"];
-}
-
-message CoerceViaIO
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  uint32 resulttype = 3 [json_name="resulttype"];
-  uint32 resultcollid = 4 [json_name="resultcollid"];
-  CoercionForm coerceformat = 5 [json_name="coerceformat"];
-  int32 location = 6 [json_name="location"];
-}
-
-message ArrayCoerceExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  Node elemexpr = 3 [json_name="elemexpr"];
-  uint32 resulttype = 4 [json_name="resulttype"];
-  int32 resulttypmod = 5 [json_name="resulttypmod"];
-  uint32 resultcollid = 6 [json_name="resultcollid"];
-  CoercionForm coerceformat = 7 [json_name="coerceformat"];
-  int32 location = 8 [json_name="location"];
-}
-
-message ConvertRowtypeExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  uint32 resulttype = 3 [json_name="resulttype"];
-  CoercionForm convertformat = 4 [json_name="convertformat"];
-  int32 location = 5 [json_name="location"];
-}
-
-message CollateExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  uint32 coll_oid = 3 [json_name="collOid"];
-  int32 location = 4 [json_name="location"];
-}
-
-message CaseExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 casetype = 2 [json_name="casetype"];
-  uint32 casecollid = 3 [json_name="casecollid"];
-  Node arg = 4 [json_name="arg"];
-  repeated Node args = 5 [json_name="args"];
-  Node defresult = 6 [json_name="defresult"];
-  int32 location = 7 [json_name="location"];
-}
-
-message CaseWhen
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node expr = 2 [json_name="expr"];
-  Node result = 3 [json_name="result"];
-  int32 location = 4 [json_name="location"];
-}
-
-message CaseTestExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 type_id = 2 [json_name="typeId"];
-  int32 type_mod = 3 [json_name="typeMod"];
-  uint32 collation = 4 [json_name="collation"];
-}
-
-message ArrayExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 array_typeid = 2 [json_name="array_typeid"];
-  uint32 array_collid = 3 [json_name="array_collid"];
-  uint32 element_typeid = 4 [json_name="element_typeid"];
-  repeated Node elements = 5 [json_name="elements"];
-  bool multidims = 6 [json_name="multidims"];
-  int32 location = 7 [json_name="location"];
-}
-
-message RowExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  repeated Node args = 2 [json_name="args"];
-  uint32 row_typeid = 3 [json_name="row_typeid"];
-  CoercionForm row_format = 4 [json_name="row_format"];
-  repeated Node colnames = 5 [json_name="colnames"];
-  int32 location = 6 [json_name="location"];
-}
-
-message RowCompareExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  RowCompareType rctype = 2 [json_name="rctype"];
-  repeated Node opnos = 3 [json_name="opnos"];
-  repeated Node opfamilies = 4 [json_name="opfamilies"];
-  repeated Node inputcollids = 5 [json_name="inputcollids"];
-  repeated Node largs = 6 [json_name="largs"];
-  repeated Node rargs = 7 [json_name="rargs"];
-}
-
-message CoalesceExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 coalescetype = 2 [json_name="coalescetype"];
-  uint32 coalescecollid = 3 [json_name="coalescecollid"];
-  repeated Node args = 4 [json_name="args"];
-  int32 location = 5 [json_name="location"];
-}
-
-message MinMaxExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 minmaxtype = 2 [json_name="minmaxtype"];
-  uint32 minmaxcollid = 3 [json_name="minmaxcollid"];
-  uint32 inputcollid = 4 [json_name="inputcollid"];
-  MinMaxOp op = 5 [json_name="op"];
-  repeated Node args = 6 [json_name="args"];
-  int32 location = 7 [json_name="location"];
-}
-
-message SQLValueFunction
-{
-  Node xpr = 1 [json_name="xpr"];
-  SQLValueFunctionOp op = 2 [json_name="op"];
-  uint32 type = 3 [json_name="type"];
-  int32 typmod = 4 [json_name="typmod"];
-  int32 location = 5 [json_name="location"];
-}
-
-message XmlExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  XmlExprOp op = 2 [json_name="op"];
-  string name = 3 [json_name="name"];
-  repeated Node named_args = 4 [json_name="named_args"];
-  repeated Node arg_names = 5 [json_name="arg_names"];
-  repeated Node args = 6 [json_name="args"];
-  XmlOptionType xmloption = 7 [json_name="xmloption"];
-  uint32 type = 8 [json_name="type"];
-  int32 typmod = 9 [json_name="typmod"];
-  int32 location = 10 [json_name="location"];
-}
-
-message NullTest
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  NullTestType nulltesttype = 3 [json_name="nulltesttype"];
-  bool argisrow = 4 [json_name="argisrow"];
-  int32 location = 5 [json_name="location"];
-}
-
-message BooleanTest
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  BoolTestType booltesttype = 3 [json_name="booltesttype"];
-  int32 location = 4 [json_name="location"];
-}
-
-message CoerceToDomain
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node arg = 2 [json_name="arg"];
-  uint32 resulttype = 3 [json_name="resulttype"];
-  int32 resulttypmod = 4 [json_name="resulttypmod"];
-  uint32 resultcollid = 5 [json_name="resultcollid"];
-  CoercionForm coercionformat = 6 [json_name="coercionformat"];
-  int32 location = 7 [json_name="location"];
-}
-
-message CoerceToDomainValue
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 type_id = 2 [json_name="typeId"];
-  int32 type_mod = 3 [json_name="typeMod"];
-  uint32 collation = 4 [json_name="collation"];
-  int32 location = 5 [json_name="location"];
-}
-
-message SetToDefault
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 type_id = 2 [json_name="typeId"];
-  int32 type_mod = 3 [json_name="typeMod"];
-  uint32 collation = 4 [json_name="collation"];
-  int32 location = 5 [json_name="location"];
-}
-
-message CurrentOfExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 cvarno = 2 [json_name="cvarno"];
-  string cursor_name = 3 [json_name="cursor_name"];
-  int32 cursor_param = 4 [json_name="cursor_param"];
-}
-
-message NextValueExpr
-{
-  Node xpr = 1 [json_name="xpr"];
-  uint32 seqid = 2 [json_name="seqid"];
-  uint32 type_id = 3 [json_name="typeId"];
-}
-
-message InferenceElem
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node expr = 2 [json_name="expr"];
-  uint32 infercollid = 3 [json_name="infercollid"];
-  uint32 inferopclass = 4 [json_name="inferopclass"];
-}
-
-message TargetEntry
-{
-  Node xpr = 1 [json_name="xpr"];
-  Node expr = 2 [json_name="expr"];
-  int32 resno = 3 [json_name="resno"];
-  string resname = 4 [json_name="resname"];
-  uint32 ressortgroupref = 5 [json_name="ressortgroupref"];
-  uint32 resorigtbl = 6 [json_name="resorigtbl"];
-  int32 resorigcol = 7 [json_name="resorigcol"];
-  bool resjunk = 8 [json_name="resjunk"];
-}
-
-message RangeTblRef
-{
-  int32 rtindex = 1 [json_name="rtindex"];
-}
-
-message JoinExpr
-{
-  JoinType jointype = 1 [json_name="jointype"];
-  bool is_natural = 2 [json_name="isNatural"];
-  Node larg = 3 [json_name="larg"];
-  Node rarg = 4 [json_name="rarg"];
-  repeated Node using_clause = 5 [json_name="usingClause"];
-  Alias join_using_alias = 6 [json_name="join_using_alias"];
-  Node quals = 7 [json_name="quals"];
-  Alias alias = 8 [json_name="alias"];
-  int32 rtindex = 9 [json_name="rtindex"];
-}
-
-message FromExpr
-{
-  repeated Node fromlist = 1 [json_name="fromlist"];
-  Node quals = 2 [json_name="quals"];
-}
-
-message OnConflictExpr
-{
-  OnConflictAction action = 1 [json_name="action"];
-  repeated Node arbiter_elems = 2 [json_name="arbiterElems"];
-  Node arbiter_where = 3 [json_name="arbiterWhere"];
-  uint32 constraint = 4 [json_name="constraint"];
-  repeated Node on_conflict_set = 5 [json_name="onConflictSet"];
-  Node on_conflict_where = 6 [json_name="onConflictWhere"];
-  int32 excl_rel_index = 7 [json_name="exclRelIndex"];
-  repeated Node excl_rel_tlist = 8 [json_name="exclRelTlist"];
-}
-
-message IntoClause
-{
-  RangeVar rel = 1 [json_name="rel"];
-  repeated Node col_names = 2 [json_name="colNames"];
-  string access_method = 3 [json_name="accessMethod"];
-  repeated Node options = 4 [json_name="options"];
-  OnCommitAction on_commit = 5 [json_name="onCommit"];
-  string table_space_name = 6 [json_name="tableSpaceName"];
-  Node view_query = 7 [json_name="viewQuery"];
-  bool skip_data = 8 [json_name="skipData"];
-}
-
-message MergeAction
-{
-  bool matched = 1 [json_name="matched"];
-  CmdType command_type = 2 [json_name="commandType"];
-  OverridingKind override = 3 [json_name="override"];
-  Node qual = 4 [json_name="qual"];
-  repeated Node target_list = 5 [json_name="targetList"];
-  repeated Node update_colnos = 6 [json_name="updateColnos"];
-}
-
-message RawStmt
-{
-  Node stmt = 1 [json_name="stmt"];
-  int32 stmt_location = 2 [json_name="stmt_location"];
-  int32 stmt_len = 3 [json_name="stmt_len"];
-}
-
-message Query
-{
-  CmdType command_type = 1 [json_name="commandType"];
-  QuerySource query_source = 2 [json_name="querySource"];
-  bool can_set_tag = 3 [json_name="canSetTag"];
-  Node utility_stmt = 4 [json_name="utilityStmt"];
-  int32 result_relation = 5 [json_name="resultRelation"];
-  bool has_aggs = 6 [json_name="hasAggs"];
-  bool has_window_funcs = 7 [json_name="hasWindowFuncs"];
-  bool has_target_srfs = 8 [json_name="hasTargetSRFs"];
-  bool has_sub_links = 9 [json_name="hasSubLinks"];
-  bool has_distinct_on = 10 [json_name="hasDistinctOn"];
-  bool has_recursive = 11 [json_name="hasRecursive"];
-  bool has_modifying_cte = 12 [json_name="hasModifyingCTE"];
-  bool has_for_update = 13 [json_name="hasForUpdate"];
-  bool has_row_security = 14 [json_name="hasRowSecurity"];
-  bool is_return = 15 [json_name="isReturn"];
-  repeated Node cte_list = 16 [json_name="cteList"];
-  repeated Node rtable = 17 [json_name="rtable"];
-  FromExpr jointree = 18 [json_name="jointree"];
-  repeated Node merge_action_list = 19 [json_name="mergeActionList"];
-  bool merge_use_outer_join = 20 [json_name="mergeUseOuterJoin"];
-  repeated Node target_list = 21 [json_name="targetList"];
-  OverridingKind override = 22 [json_name="override"];
-  OnConflictExpr on_conflict = 23 [json_name="onConflict"];
-  repeated Node returning_list = 24 [json_name="returningList"];
-  repeated Node group_clause = 25 [json_name="groupClause"];
-  bool group_distinct = 26 [json_name="groupDistinct"];
-  repeated Node grouping_sets = 27 [json_name="groupingSets"];
-  Node having_qual = 28 [json_name="havingQual"];
-  repeated Node window_clause = 29 [json_name="windowClause"];
-  repeated Node distinct_clause = 30 [json_name="distinctClause"];
-  repeated Node sort_clause = 31 [json_name="sortClause"];
-  Node limit_offset = 32 [json_name="limitOffset"];
-  Node limit_count = 33 [json_name="limitCount"];
-  LimitOption limit_option = 34 [json_name="limitOption"];
-  repeated Node row_marks = 35 [json_name="rowMarks"];
-  Node set_operations = 36 [json_name="setOperations"];
-  repeated Node constraint_deps = 37 [json_name="constraintDeps"];
-  repeated Node with_check_options = 38 [json_name="withCheckOptions"];
-  int32 stmt_location = 39 [json_name="stmt_location"];
-  int32 stmt_len = 40 [json_name="stmt_len"];
-}
-
-message InsertStmt
-{
-  RangeVar relation = 1 [json_name="relation"];
-  repeated Node cols = 2 [json_name="cols"];
-  Node select_stmt = 3 [json_name="selectStmt"];
-  OnConflictClause on_conflict_clause = 4 [json_name="onConflictClause"];
-  repeated Node returning_list = 5 [json_name="returningList"];
-  WithClause with_clause = 6 [json_name="withClause"];
-  OverridingKind override = 7 [json_name="override"];
-}
-
-message DeleteStmt
-{
-  RangeVar relation = 1 [json_name="relation"];
-  repeated Node using_clause = 2 [json_name="usingClause"];
-  Node where_clause = 3 [json_name="whereClause"];
-  repeated Node returning_list = 4 [json_name="returningList"];
-  WithClause with_clause = 5 [json_name="withClause"];
-}
-
-message UpdateStmt
-{
-  RangeVar relation = 1 [json_name="relation"];
-  repeated Node target_list = 2 [json_name="targetList"];
-  Node where_clause = 3 [json_name="whereClause"];
-  repeated Node from_clause = 4 [json_name="fromClause"];
-  repeated Node returning_list = 5 [json_name="returningList"];
-  WithClause with_clause = 6 [json_name="withClause"];
-}
-
-message MergeStmt
-{
-  RangeVar relation = 1 [json_name="relation"];
-  Node source_relation = 2 [json_name="sourceRelation"];
-  Node join_condition = 3 [json_name="joinCondition"];
-  repeated Node merge_when_clauses = 4 [json_name="mergeWhenClauses"];
-  WithClause with_clause = 5 [json_name="withClause"];
-}
-
-message SelectStmt
-{
-  repeated Node distinct_clause = 1 [json_name="distinctClause"];
-  IntoClause into_clause = 2 [json_name="intoClause"];
-  repeated Node target_list = 3 [json_name="targetList"];
-  repeated Node from_clause = 4 [json_name="fromClause"];
-  Node where_clause = 5 [json_name="whereClause"];
-  repeated Node group_clause = 6 [json_name="groupClause"];
-  bool group_distinct = 7 [json_name="groupDistinct"];
-  Node having_clause = 8 [json_name="havingClause"];
-  repeated Node window_clause = 9 [json_name="windowClause"];
-  repeated Node values_lists = 10 [json_name="valuesLists"];
-  repeated Node sort_clause = 11 [json_name="sortClause"];
-  Node limit_offset = 12 [json_name="limitOffset"];
-  Node limit_count = 13 [json_name="limitCount"];
-  LimitOption limit_option = 14 [json_name="limitOption"];
-  repeated Node locking_clause = 15 [json_name="lockingClause"];
-  WithClause with_clause = 16 [json_name="withClause"];
-  SetOperation op = 17 [json_name="op"];
-  bool all = 18 [json_name="all"];
-  SelectStmt larg = 19 [json_name="larg"];
-  SelectStmt rarg = 20 [json_name="rarg"];
-}
-
-message ReturnStmt
-{
-  Node returnval = 1 [json_name="returnval"];
-}
-
-message PLAssignStmt
-{
-  string name = 1 [json_name="name"];
-  repeated Node indirection = 2 [json_name="indirection"];
-  int32 nnames = 3 [json_name="nnames"];
-  SelectStmt val = 4 [json_name="val"];
-  int32 location = 5 [json_name="location"];
-}
-
-message AlterTableStmt
-{
-  RangeVar relation = 1 [json_name="relation"];
-  repeated Node cmds = 2 [json_name="cmds"];
-  ObjectType objtype = 3 [json_name="objtype"];
-  bool missing_ok = 4 [json_name="missing_ok"];
-}
-
-message AlterTableCmd
-{
-  AlterTableType subtype = 1 [json_name="subtype"];
-  string name = 2 [json_name="name"];
-  int32 num = 3 [json_name="num"];
-  RoleSpec newowner = 4 [json_name="newowner"];
-  Node def = 5 [json_name="def"];
-  DropBehavior behavior = 6 [json_name="behavior"];
-  bool missing_ok = 7 [json_name="missing_ok"];
-  bool recurse = 8 [json_name="recurse"];
-}
-
-message AlterDomainStmt
-{
-  string subtype = 1 [json_name="subtype"];
-  repeated Node type_name = 2 [json_name="typeName"];
-  string name = 3 [json_name="name"];
-  Node def = 4 [json_name="def"];
-  DropBehavior behavior = 5 [json_name="behavior"];
-  bool missing_ok = 6 [json_name="missing_ok"];
-}
-
-message SetOperationStmt
-{
-  SetOperation op = 1 [json_name="op"];
-  bool all = 2 [json_name="all"];
-  Node larg = 3 [json_name="larg"];
-  Node rarg = 4 [json_name="rarg"];
-  repeated Node col_types = 5 [json_name="colTypes"];
-  repeated Node col_typmods = 6 [json_name="colTypmods"];
-  repeated Node col_collations = 7 [json_name="colCollations"];
-  repeated Node group_clauses = 8 [json_name="groupClauses"];
-}
-
-message GrantStmt
-{
-  bool is_grant = 1 [json_name="is_grant"];
-  GrantTargetType targtype = 2 [json_name="targtype"];
-  ObjectType objtype = 3 [json_name="objtype"];
-  repeated Node objects = 4 [json_name="objects"];
-  repeated Node privileges = 5 [json_name="privileges"];
-  repeated Node grantees = 6 [json_name="grantees"];
-  bool grant_option = 7 [json_name="grant_option"];
-  RoleSpec grantor = 8 [json_name="grantor"];
-  DropBehavior behavior = 9 [json_name="behavior"];
-}
-
-message GrantRoleStmt
-{
-  repeated Node granted_roles = 1 [json_name="granted_roles"];
-  repeated Node grantee_roles = 2 [json_name="grantee_roles"];
-  bool is_grant = 3 [json_name="is_grant"];
-  bool admin_opt = 4 [json_name="admin_opt"];
-  RoleSpec grantor = 5 [json_name="grantor"];
-  DropBehavior behavior = 6 [json_name="behavior"];
-}
-
-message AlterDefaultPrivilegesStmt
-{
-  repeated Node options = 1 [json_name="options"];
-  GrantStmt action = 2 [json_name="action"];
-}
-
-message ClosePortalStmt
-{
-  string portalname = 1 [json_name="portalname"];
-}
-
-message ClusterStmt
-{
-  RangeVar relation = 1 [json_name="relation"];
-  string indexname = 2 [json_name="indexname"];
-  repeated Node params = 3 [json_name="params"];
-}
-
-message CopyStmt
-{
-  RangeVar relation = 1 [json_name="relation"];
-  Node query = 2 [json_name="query"];
-  repeated Node attlist = 3 [json_name="attlist"];
-  bool is_from = 4 [json_name="is_from"];
-  bool is_program = 5 [json_name="is_program"];
-  string filename = 6 [json_name="filename"];
-  repeated Node options = 7 [json_name="options"];
-  Node where_clause = 8 [json_name="whereClause"];
-}
-
-message CreateStmt
-{
-  RangeVar relation = 1 [json_name="relation"];
-  repeated Node table_elts = 2 [json_name="tableElts"];
-  repeated Node inh_relations = 3 [json_name="inhRelations"];
-  PartitionBoundSpec partbound = 4 [json_name="partbound"];
-  PartitionSpec partspec = 5 [json_name="partspec"];
-  TypeName of_typename = 6 [json_name="ofTypename"];
-  repeated Node constraints = 7 [json_name="constraints"];
-  repeated Node options = 8 [json_name="options"];
-  OnCommitAction oncommit = 9 [json_name="oncommit"];
-  string tablespacename = 10 [json_name="tablespacename"];
-  string access_method = 11 [json_name="accessMethod"];
-  bool if_not_exists = 12 [json_name="if_not_exists"];
-}
-
-message DefineStmt
-{
-  ObjectType kind = 1 [json_name="kind"];
-  bool oldstyle = 2 [json_name="oldstyle"];
-  repeated Node defnames = 3 [json_name="defnames"];
-  repeated Node args = 4 [json_name="args"];
-  repeated Node definition = 5 [json_name="definition"];
-  bool if_not_exists = 6 [json_name="if_not_exists"];
-  bool replace = 7 [json_name="replace"];
-}
-
-message DropStmt
-{
-  repeated Node objects = 1 [json_name="objects"];
-  ObjectType remove_type = 2 [json_name="removeType"];
-  DropBehavior behavior = 3 [json_name="behavior"];
-  bool missing_ok = 4 [json_name="missing_ok"];
-  bool concurrent = 5 [json_name="concurrent"];
-}
-
-message TruncateStmt
-{
-  repeated Node relations = 1 [json_name="relations"];
-  bool restart_seqs = 2 [json_name="restart_seqs"];
-  DropBehavior behavior = 3 [json_name="behavior"];
-}
-
-message CommentStmt
-{
-  ObjectType objtype = 1 [json_name="objtype"];
-  Node object = 2 [json_name="object"];
-  string comment = 3 [json_name="comment"];
-}
-
-message FetchStmt
-{
-  FetchDirection direction = 1 [json_name="direction"];
-  int64 how_many = 2 [json_name="howMany"];
-  string portalname = 3 [json_name="portalname"];
-  bool ismove = 4 [json_name="ismove"];
-}
-
-message IndexStmt
-{
-  string idxname = 1 [json_name="idxname"];
-  RangeVar relation = 2 [json_name="relation"];
-  string access_method = 3 [json_name="accessMethod"];
-  string table_space = 4 [json_name="tableSpace"];
-  repeated Node index_params = 5 [json_name="indexParams"];
-  repeated Node index_including_params = 6 [json_name="indexIncludingParams"];
-  repeated Node options = 7 [json_name="options"];
-  Node where_clause = 8 [json_name="whereClause"];
-  repeated Node exclude_op_names = 9 [json_name="excludeOpNames"];
-  string idxcomment = 10 [json_name="idxcomment"];
-  uint32 index_oid = 11 [json_name="indexOid"];
-  uint32 old_node = 12 [json_name="oldNode"];
-  uint32 old_create_subid = 13 [json_name="oldCreateSubid"];
-  uint32 old_first_relfilenode_subid = 14 [json_name="oldFirstRelfilenodeSubid"];
-  bool unique = 15 [json_name="unique"];
-  bool nulls_not_distinct = 16 [json_name="nulls_not_distinct"];
-  bool primary = 17 [json_name="primary"];
-  bool isconstraint = 18 [json_name="isconstraint"];
-  bool deferrable = 19 [json_name="deferrable"];
-  bool initdeferred = 20 [json_name="initdeferred"];
-  bool transformed = 21 [json_name="transformed"];
-  bool concurrent = 22 [json_name="concurrent"];
-  bool if_not_exists = 23 [json_name="if_not_exists"];
-  bool reset_default_tblspc = 24 [json_name="reset_default_tblspc"];
-}
-
-message CreateFunctionStmt
-{
-  bool is_procedure = 1 [json_name="is_procedure"];
-  bool replace = 2 [json_name="replace"];
-  repeated Node funcname = 3 [json_name="funcname"];
-  repeated Node parameters = 4 [json_name="parameters"];
-  TypeName return_type = 5 [json_name="returnType"];
-  repeated Node options = 6 [json_name="options"];
-  Node sql_body = 7 [json_name="sql_body"];
-}
-
-message AlterFunctionStmt
-{
-  ObjectType objtype = 1 [json_name="objtype"];
-  ObjectWithArgs func = 2 [json_name="func"];
-  repeated Node actions = 3 [json_name="actions"];
-}
-
-message DoStmt
-{
-  repeated Node args = 1 [json_name="args"];
-}
-
-message RenameStmt
-{
-  ObjectType rename_type = 1 [json_name="renameType"];
-  ObjectType relation_type = 2 [json_name="relationType"];
-  RangeVar relation = 3 [json_name="relation"];
-  Node object = 4 [json_name="object"];
-  string subname = 5 [json_name="subname"];
-  string newname = 6 [json_name="newname"];
-  DropBehavior behavior = 7 [json_name="behavior"];
-  bool missing_ok = 8 [json_name="missing_ok"];
-}
-
-message RuleStmt
-{
-  RangeVar relation = 1 [json_name="relation"];
-  string rulename = 2 [json_name="rulename"];
-  Node where_clause = 3 [json_name="whereClause"];
-  CmdType event = 4 [json_name="event"];
-  bool instead = 5 [json_name="instead"];
-  repeated Node actions = 6 [json_name="actions"];
-  bool replace = 7 [json_name="replace"];
-}
-
-message NotifyStmt
-{
-  string conditionname = 1 [json_name="conditionname"];
-  string payload = 2 [json_name="payload"];
-}
-
-message ListenStmt
-{
-  string conditionname = 1 [json_name="conditionname"];
-}
-
-message UnlistenStmt
-{
-  string conditionname = 1 [json_name="conditionname"];
-}
-
-message TransactionStmt
-{
-  TransactionStmtKind kind = 1 [json_name="kind"];
-  repeated Node options = 2 [json_name="options"];
-  string savepoint_name = 3 [json_name="savepoint_name"];
-  string gid = 4 [json_name="gid"];
-  bool chain = 5 [json_name="chain"];
-}
-
-message ViewStmt
-{
-  RangeVar view = 1 [json_name="view"];
-  repeated Node aliases = 2 [json_name="aliases"];
-  Node query = 3 [json_name="query"];
-  bool replace = 4 [json_name="replace"];
-  repeated Node options = 5 [json_name="options"];
-  ViewCheckOption with_check_option = 6 [json_name="withCheckOption"];
-}
-
-message LoadStmt
-{
-  string filename = 1 [json_name="filename"];
-}
-
-message CreateDomainStmt
-{
-  repeated Node domainname = 1 [json_name="domainname"];
-  TypeName type_name = 2 [json_name="typeName"];
-  CollateClause coll_clause = 3 [json_name="collClause"];
-  repeated Node constraints = 4 [json_name="constraints"];
-}
-
-message CreatedbStmt
-{
-  string dbname = 1 [json_name="dbname"];
-  repeated Node options = 2 [json_name="options"];
-}
-
-message DropdbStmt
-{
-  string dbname = 1 [json_name="dbname"];
-  bool missing_ok = 2 [json_name="missing_ok"];
-  repeated Node options = 3 [json_name="options"];
-}
-
-message VacuumStmt
-{
-  repeated Node options = 1 [json_name="options"];
-  repeated Node rels = 2 [json_name="rels"];
-  bool is_vacuumcmd = 3 [json_name="is_vacuumcmd"];
-}
-
-message ExplainStmt
-{
-  Node query = 1 [json_name="query"];
-  repeated Node options = 2 [json_name="options"];
-}
-
-message CreateTableAsStmt
-{
-  Node query = 1 [json_name="query"];
-  IntoClause into = 2 [json_name="into"];
-  ObjectType objtype = 3 [json_name="objtype"];
-  bool is_select_into = 4 [json_name="is_select_into"];
-  bool if_not_exists = 5 [json_name="if_not_exists"];
-}
-
-message CreateSeqStmt
-{
-  RangeVar sequence = 1 [json_name="sequence"];
-  repeated Node options = 2 [json_name="options"];
-  uint32 owner_id = 3 [json_name="ownerId"];
-  bool for_identity = 4 [json_name="for_identity"];
-  bool if_not_exists = 5 [json_name="if_not_exists"];
-}
-
-message AlterSeqStmt
-{
-  RangeVar sequence = 1 [json_name="sequence"];
-  repeated Node options = 2 [json_name="options"];
-  bool for_identity = 3 [json_name="for_identity"];
-  bool missing_ok = 4 [json_name="missing_ok"];
-}
-
-message VariableSetStmt
-{
-  VariableSetKind kind = 1 [json_name="kind"];
-  string name = 2 [json_name="name"];
-  repeated Node args = 3 [json_name="args"];
-  bool is_local = 4 [json_name="is_local"];
-}
-
-message VariableShowStmt
-{
-  string name = 1 [json_name="name"];
-}
-
-message DiscardStmt
-{
-  DiscardMode target = 1 [json_name="target"];
-}
-
-message CreateTrigStmt
-{
-  bool replace = 1 [json_name="replace"];
-  bool isconstraint = 2 [json_name="isconstraint"];
-  string trigname = 3 [json_name="trigname"];
-  RangeVar relation = 4 [json_name="relation"];
-  repeated Node funcname = 5 [json_name="funcname"];
-  repeated Node args = 6 [json_name="args"];
-  bool row = 7 [json_name="row"];
-  int32 timing = 8 [json_name="timing"];
-  int32 events = 9 [json_name="events"];
-  repeated Node columns = 10 [json_name="columns"];
-  Node when_clause = 11 [json_name="whenClause"];
-  repeated Node transition_rels = 12 [json_name="transitionRels"];
-  bool deferrable = 13 [json_name="deferrable"];
-  bool initdeferred = 14 [json_name="initdeferred"];
-  RangeVar constrrel = 15 [json_name="constrrel"];
-}
-
-message CreatePLangStmt
-{
-  bool replace = 1 [json_name="replace"];
-  string plname = 2 [json_name="plname"];
-  repeated Node plhandler = 3 [json_name="plhandler"];
-  repeated Node plinline = 4 [json_name="plinline"];
-  repeated Node plvalidator = 5 [json_name="plvalidator"];
-  bool pltrusted = 6 [json_name="pltrusted"];
-}
-
-message CreateRoleStmt
-{
-  RoleStmtType stmt_type = 1 [json_name="stmt_type"];
-  string role = 2 [json_name="role"];
-  repeated Node options = 3 [json_name="options"];
-}
-
-message AlterRoleStmt
-{
-  RoleSpec role = 1 [json_name="role"];
-  repeated Node options = 2 [json_name="options"];
-  int32 action = 3 [json_name="action"];
-}
-
-message DropRoleStmt
-{
-  repeated Node roles = 1 [json_name="roles"];
-  bool missing_ok = 2 [json_name="missing_ok"];
-}
-
-message LockStmt
-{
-  repeated Node relations = 1 [json_name="relations"];
-  int32 mode = 2 [json_name="mode"];
-  bool nowait = 3 [json_name="nowait"];
-}
-
-message ConstraintsSetStmt
-{
-  repeated Node constraints = 1 [json_name="constraints"];
-  bool deferred = 2 [json_name="deferred"];
-}
-
-message ReindexStmt
-{
-  ReindexObjectType kind = 1 [json_name="kind"];
-  RangeVar relation = 2 [json_name="relation"];
-  string name = 3 [json_name="name"];
-  repeated Node params = 4 [json_name="params"];
-}
-
-message CheckPointStmt
-{
-}
-
-message CreateSchemaStmt
-{
-  string schemaname = 1 [json_name="schemaname"];
-  RoleSpec authrole = 2 [json_name="authrole"];
-  repeated Node schema_elts = 3 [json_name="schemaElts"];
-  bool if_not_exists = 4 [json_name="if_not_exists"];
-}
-
-message AlterDatabaseStmt
-{
-  string dbname = 1 [json_name="dbname"];
-  repeated Node options = 2 [json_name="options"];
-}
-
-message AlterDatabaseRefreshCollStmt
-{
-  string dbname = 1 [json_name="dbname"];
-}
-
-message AlterDatabaseSetStmt
-{
-  string dbname = 1 [json_name="dbname"];
-  VariableSetStmt setstmt = 2 [json_name="setstmt"];
-}
-
-message AlterRoleSetStmt
-{
-  RoleSpec role = 1 [json_name="role"];
-  string database = 2 [json_name="database"];
-  VariableSetStmt setstmt = 3 [json_name="setstmt"];
-}
-
-message CreateConversionStmt
-{
-  repeated Node conversion_name = 1 [json_name="conversion_name"];
-  string for_encoding_name = 2 [json_name="for_encoding_name"];
-  string to_encoding_name = 3 [json_name="to_encoding_name"];
-  repeated Node func_name = 4 [json_name="func_name"];
-  bool def = 5 [json_name="def"];
-}
-
-message CreateCastStmt
-{
-  TypeName sourcetype = 1 [json_name="sourcetype"];
-  TypeName targettype = 2 [json_name="targettype"];
-  ObjectWithArgs func = 3 [json_name="func"];
-  CoercionContext context = 4 [json_name="context"];
-  bool inout = 5 [json_name="inout"];
-}
-
-message CreateOpClassStmt
-{
-  repeated Node opclassname = 1 [json_name="opclassname"];
-  repeated Node opfamilyname = 2 [json_name="opfamilyname"];
-  string amname = 3 [json_name="amname"];
-  TypeName datatype = 4 [json_name="datatype"];
-  repeated Node items = 5 [json_name="items"];
-  bool is_default = 6 [json_name="isDefault"];
-}
-
-message CreateOpFamilyStmt
-{
-  repeated Node opfamilyname = 1 [json_name="opfamilyname"];
-  string amname = 2 [json_name="amname"];
-}
-
-message AlterOpFamilyStmt
-{
-  repeated Node opfamilyname = 1 [json_name="opfamilyname"];
-  string amname = 2 [json_name="amname"];
-  bool is_drop = 3 [json_name="isDrop"];
-  repeated Node items = 4 [json_name="items"];
-}
-
-message PrepareStmt
-{
-  string name = 1 [json_name="name"];
-  repeated Node argtypes = 2 [json_name="argtypes"];
-  Node query = 3 [json_name="query"];
-}
-
-message ExecuteStmt
-{
-  string name = 1 [json_name="name"];
-  repeated Node params = 2 [json_name="params"];
-}
-
-message DeallocateStmt
-{
-  string name = 1 [json_name="name"];
-}
-
-message DeclareCursorStmt
-{
-  string portalname = 1 [json_name="portalname"];
-  int32 options = 2 [json_name="options"];
-  Node query = 3 [json_name="query"];
-}
-
-message CreateTableSpaceStmt
-{
-  string tablespacename = 1 [json_name="tablespacename"];
-  RoleSpec owner = 2 [json_name="owner"];
-  string location = 3 [json_name="location"];
-  repeated Node options = 4 [json_name="options"];
-}
-
-message DropTableSpaceStmt
-{
-  string tablespacename = 1 [json_name="tablespacename"];
-  bool missing_ok = 2 [json_name="missing_ok"];
-}
-
-message AlterObjectDependsStmt
-{
-  ObjectType object_type = 1 [json_name="objectType"];
-  RangeVar relation = 2 [json_name="relation"];
-  Node object = 3 [json_name="object"];
-  String extname = 4 [json_name="extname"];
-  bool remove = 5 [json_name="remove"];
-}
-
-message AlterObjectSchemaStmt
-{
-  ObjectType object_type = 1 [json_name="objectType"];
-  RangeVar relation = 2 [json_name="relation"];
-  Node object = 3 [json_name="object"];
-  string newschema = 4 [json_name="newschema"];
-  bool missing_ok = 5 [json_name="missing_ok"];
-}
-
-message AlterOwnerStmt
-{
-  ObjectType object_type = 1 [json_name="objectType"];
-  RangeVar relation = 2 [json_name="relation"];
-  Node object = 3 [json_name="object"];
-  RoleSpec newowner = 4 [json_name="newowner"];
-}
-
-message AlterOperatorStmt
-{
-  ObjectWithArgs opername = 1 [json_name="opername"];
-  repeated Node options = 2 [json_name="options"];
-}
-
-message AlterTypeStmt
-{
-  repeated Node type_name = 1 [json_name="typeName"];
-  repeated Node options = 2 [json_name="options"];
-}
-
-message DropOwnedStmt
-{
-  repeated Node roles = 1 [json_name="roles"];
-  DropBehavior behavior = 2 [json_name="behavior"];
-}
-
-message ReassignOwnedStmt
-{
-  repeated Node roles = 1 [json_name="roles"];
-  RoleSpec newrole = 2 [json_name="newrole"];
-}
-
-message CompositeTypeStmt
-{
-  RangeVar typevar = 1 [json_name="typevar"];
-  repeated Node coldeflist = 2 [json_name="coldeflist"];
-}
-
-message CreateEnumStmt
-{
-  repeated Node type_name = 1 [json_name="typeName"];
-  repeated Node vals = 2 [json_name="vals"];
-}
-
-message CreateRangeStmt
-{
-  repeated Node type_name = 1 [json_name="typeName"];
-  repeated Node params = 2 [json_name="params"];
-}
-
-message AlterEnumStmt
-{
-  repeated Node type_name = 1 [json_name="typeName"];
-  string old_val = 2 [json_name="oldVal"];
-  string new_val = 3 [json_name="newVal"];
-  string new_val_neighbor = 4 [json_name="newValNeighbor"];
-  bool new_val_is_after = 5 [json_name="newValIsAfter"];
-  bool skip_if_new_val_exists = 6 [json_name="skipIfNewValExists"];
-}
-
-message AlterTSDictionaryStmt
-{
-  repeated Node dictname = 1 [json_name="dictname"];
-  repeated Node options = 2 [json_name="options"];
-}
-
-message AlterTSConfigurationStmt
-{
-  AlterTSConfigType kind = 1 [json_name="kind"];
-  repeated Node cfgname = 2 [json_name="cfgname"];
-  repeated Node tokentype = 3 [json_name="tokentype"];
-  repeated Node dicts = 4 [json_name="dicts"];
-  bool override = 5 [json_name="override"];
-  bool replace = 6 [json_name="replace"];
-  bool missing_ok = 7 [json_name="missing_ok"];
-}
-
-message CreateFdwStmt
-{
-  string fdwname = 1 [json_name="fdwname"];
-  repeated Node func_options = 2 [json_name="func_options"];
-  repeated Node options = 3 [json_name="options"];
-}
-
-message AlterFdwStmt
-{
-  string fdwname = 1 [json_name="fdwname"];
-  repeated Node func_options = 2 [json_name="func_options"];
-  repeated Node options = 3 [json_name="options"];
-}
-
-message CreateForeignServerStmt
-{
-  string servername = 1 [json_name="servername"];
-  string servertype = 2 [json_name="servertype"];
-  string version = 3 [json_name="version"];
-  string fdwname = 4 [json_name="fdwname"];
-  bool if_not_exists = 5 [json_name="if_not_exists"];
-  repeated Node options = 6 [json_name="options"];
-}
-
-message AlterForeignServerStmt
-{
-  string servername = 1 [json_name="servername"];
-  string version = 2 [json_name="version"];
-  repeated Node options = 3 [json_name="options"];
-  bool has_version = 4 [json_name="has_version"];
-}
-
-message CreateUserMappingStmt
-{
-  RoleSpec user = 1 [json_name="user"];
-  string servername = 2 [json_name="servername"];
-  bool if_not_exists = 3 [json_name="if_not_exists"];
-  repeated Node options = 4 [json_name="options"];
-}
-
-message AlterUserMappingStmt
-{
-  RoleSpec user = 1 [json_name="user"];
-  string servername = 2 [json_name="servername"];
-  repeated Node options = 3 [json_name="options"];
-}
-
-message DropUserMappingStmt
-{
-  RoleSpec user = 1 [json_name="user"];
-  string servername = 2 [json_name="servername"];
-  bool missing_ok = 3 [json_name="missing_ok"];
-}
-
-message AlterTableSpaceOptionsStmt
-{
-  string tablespacename = 1 [json_name="tablespacename"];
-  repeated Node options = 2 [json_name="options"];
-  bool is_reset = 3 [json_name="isReset"];
-}
-
-message AlterTableMoveAllStmt
-{
-  string orig_tablespacename = 1 [json_name="orig_tablespacename"];
-  ObjectType objtype = 2 [json_name="objtype"];
-  repeated Node roles = 3 [json_name="roles"];
-  string new_tablespacename = 4 [json_name="new_tablespacename"];
-  bool nowait = 5 [json_name="nowait"];
-}
-
-message SecLabelStmt
-{
-  ObjectType objtype = 1 [json_name="objtype"];
-  Node object = 2 [json_name="object"];
-  string provider = 3 [json_name="provider"];
-  string label = 4 [json_name="label"];
-}
-
-message CreateForeignTableStmt
-{
-  CreateStmt base_stmt = 1 [json_name="base"];
-  string servername = 2 [json_name="servername"];
-  repeated Node options = 3 [json_name="options"];
-}
-
-message ImportForeignSchemaStmt
-{
-  string server_name = 1 [json_name="server_name"];
-  string remote_schema = 2 [json_name="remote_schema"];
-  string local_schema = 3 [json_name="local_schema"];
-  ImportForeignSchemaType list_type = 4 [json_name="list_type"];
-  repeated Node table_list = 5 [json_name="table_list"];
-  repeated Node options = 6 [json_name="options"];
-}
-
-message CreateExtensionStmt
-{
-  string extname = 1 [json_name="extname"];
-  bool if_not_exists = 2 [json_name="if_not_exists"];
-  repeated Node options = 3 [json_name="options"];
-}
-
-message AlterExtensionStmt
-{
-  string extname = 1 [json_name="extname"];
-  repeated Node options = 2 [json_name="options"];
-}
-
-message AlterExtensionContentsStmt
-{
-  string extname = 1 [json_name="extname"];
-  int32 action = 2 [json_name="action"];
-  ObjectType objtype = 3 [json_name="objtype"];
-  Node object = 4 [json_name="object"];
-}
-
-message CreateEventTrigStmt
-{
-  string trigname = 1 [json_name="trigname"];
-  string eventname = 2 [json_name="eventname"];
-  repeated Node whenclause = 3 [json_name="whenclause"];
-  repeated Node funcname = 4 [json_name="funcname"];
-}
-
-message AlterEventTrigStmt
-{
-  string trigname = 1 [json_name="trigname"];
-  string tgenabled = 2 [json_name="tgenabled"];
-}
-
-message RefreshMatViewStmt
-{
-  bool concurrent = 1 [json_name="concurrent"];
-  bool skip_data = 2 [json_name="skipData"];
-  RangeVar relation = 3 [json_name="relation"];
-}
-
-message ReplicaIdentityStmt
-{
-  string identity_type = 1 [json_name="identity_type"];
-  string name = 2 [json_name="name"];
-}
-
-message AlterSystemStmt
-{
-  VariableSetStmt setstmt = 1 [json_name="setstmt"];
-}
-
-message CreatePolicyStmt
-{
-  string policy_name = 1 [json_name="policy_name"];
-  RangeVar table = 2 [json_name="table"];
-  string cmd_name = 3 [json_name="cmd_name"];
-  bool permissive = 4 [json_name="permissive"];
-  repeated Node roles = 5 [json_name="roles"];
-  Node qual = 6 [json_name="qual"];
-  Node with_check = 7 [json_name="with_check"];
-}
-
-message AlterPolicyStmt
-{
-  string policy_name = 1 [json_name="policy_name"];
-  RangeVar table = 2 [json_name="table"];
-  repeated Node roles = 3 [json_name="roles"];
-  Node qual = 4 [json_name="qual"];
-  Node with_check = 5 [json_name="with_check"];
-}
-
-message CreateTransformStmt
-{
-  bool replace = 1 [json_name="replace"];
-  TypeName type_name = 2 [json_name="type_name"];
-  string lang = 3 [json_name="lang"];
-  ObjectWithArgs fromsql = 4 [json_name="fromsql"];
-  ObjectWithArgs tosql = 5 [json_name="tosql"];
-}
-
-message CreateAmStmt
-{
-  string amname = 1 [json_name="amname"];
-  repeated Node handler_name = 2 [json_name="handler_name"];
-  string amtype = 3 [json_name="amtype"];
-}
-
-message CreatePublicationStmt
-{
-  string pubname = 1 [json_name="pubname"];
-  repeated Node options = 2 [json_name="options"];
-  repeated Node pubobjects = 3 [json_name="pubobjects"];
-  bool for_all_tables = 4 [json_name="for_all_tables"];
-}
-
-message AlterPublicationStmt
-{
-  string pubname = 1 [json_name="pubname"];
-  repeated Node options = 2 [json_name="options"];
-  repeated Node pubobjects = 3 [json_name="pubobjects"];
-  bool for_all_tables = 4 [json_name="for_all_tables"];
-  AlterPublicationAction action = 5 [json_name="action"];
-}
-
-message CreateSubscriptionStmt
-{
-  string subname = 1 [json_name="subname"];
-  string conninfo = 2 [json_name="conninfo"];
-  repeated Node publication = 3 [json_name="publication"];
-  repeated Node options = 4 [json_name="options"];
-}
-
-message AlterSubscriptionStmt
-{
-  AlterSubscriptionType kind = 1 [json_name="kind"];
-  string subname = 2 [json_name="subname"];
-  string conninfo = 3 [json_name="conninfo"];
-  repeated Node publication = 4 [json_name="publication"];
-  repeated Node options = 5 [json_name="options"];
-}
-
-message DropSubscriptionStmt
-{
-  string subname = 1 [json_name="subname"];
-  bool missing_ok = 2 [json_name="missing_ok"];
-  DropBehavior behavior = 3 [json_name="behavior"];
-}
-
-message CreateStatsStmt
-{
-  repeated Node defnames = 1 [json_name="defnames"];
-  repeated Node stat_types = 2 [json_name="stat_types"];
-  repeated Node exprs = 3 [json_name="exprs"];
-  repeated Node relations = 4 [json_name="relations"];
-  string stxcomment = 5 [json_name="stxcomment"];
-  bool transformed = 6 [json_name="transformed"];
-  bool if_not_exists = 7 [json_name="if_not_exists"];
-}
-
-message AlterCollationStmt
-{
-  repeated Node collname = 1 [json_name="collname"];
-}
-
-message CallStmt
-{
-  FuncCall funccall = 1 [json_name="funccall"];
-  FuncExpr funcexpr = 2 [json_name="funcexpr"];
-  repeated Node outargs = 3 [json_name="outargs"];
-}
-
-message AlterStatsStmt
-{
-  repeated Node defnames = 1 [json_name="defnames"];
-  int32 stxstattarget = 2 [json_name="stxstattarget"];
-  bool missing_ok = 3 [json_name="missing_ok"];
-}
-
-message A_Expr
-{
-  A_Expr_Kind kind = 1 [json_name="kind"];
-  repeated Node name = 2 [json_name="name"];
-  Node lexpr = 3 [json_name="lexpr"];
-  Node rexpr = 4 [json_name="rexpr"];
-  int32 location = 5 [json_name="location"];
-}
-
-message ColumnRef
-{
-  repeated Node fields = 1 [json_name="fields"];
-  int32 location = 2 [json_name="location"];
-}
-
-message ParamRef
-{
-  int32 number = 1 [json_name="number"];
-  int32 location = 2 [json_name="location"];
-}
-
-message FuncCall
-{
-  repeated Node funcname = 1 [json_name="funcname"];
-  repeated Node args = 2 [json_name="args"];
-  repeated Node agg_order = 3 [json_name="agg_order"];
-  Node agg_filter = 4 [json_name="agg_filter"];
-  WindowDef over = 5 [json_name="over"];
-  bool agg_within_group = 6 [json_name="agg_within_group"];
-  bool agg_star = 7 [json_name="agg_star"];
-  bool agg_distinct = 8 [json_name="agg_distinct"];
-  bool func_variadic = 9 [json_name="func_variadic"];
-  CoercionForm funcformat = 10 [json_name="funcformat"];
-  int32 location = 11 [json_name="location"];
-}
-
-message A_Star
-{
-}
-
-message A_Indices
-{
-  bool is_slice = 1 [json_name="is_slice"];
-  Node lidx = 2 [json_name="lidx"];
-  Node uidx = 3 [json_name="uidx"];
-}
-
-message A_Indirection
-{
-  Node arg = 1 [json_name="arg"];
-  repeated Node indirection = 2 [json_name="indirection"];
-}
-
-message A_ArrayExpr
-{
-  repeated Node elements = 1 [json_name="elements"];
-  int32 location = 2 [json_name="location"];
-}
-
-message ResTarget
-{
-  string name = 1 [json_name="name"];
-  repeated Node indirection = 2 [json_name="indirection"];
-  Node val = 3 [json_name="val"];
-  int32 location = 4 [json_name="location"];
-}
-
-message MultiAssignRef
-{
-  Node source = 1 [json_name="source"];
-  int32 colno = 2 [json_name="colno"];
-  int32 ncolumns = 3 [json_name="ncolumns"];
-}
-
-message TypeCast
-{
-  Node arg = 1 [json_name="arg"];
-  TypeName type_name = 2 [json_name="typeName"];
-  int32 location = 3 [json_name="location"];
-}
-
-message CollateClause
-{
-  Node arg = 1 [json_name="arg"];
-  repeated Node collname = 2 [json_name="collname"];
-  int32 location = 3 [json_name="location"];
-}
-
-message SortBy
-{
-  Node node = 1 [json_name="node"];
-  SortByDir sortby_dir = 2 [json_name="sortby_dir"];
-  SortByNulls sortby_nulls = 3 [json_name="sortby_nulls"];
-  repeated Node use_op = 4 [json_name="useOp"];
-  int32 location = 5 [json_name="location"];
-}
-
-message WindowDef
-{
-  string name = 1 [json_name="name"];
-  string refname = 2 [json_name="refname"];
-  repeated Node partition_clause = 3 [json_name="partitionClause"];
-  repeated Node order_clause = 4 [json_name="orderClause"];
-  int32 frame_options = 5 [json_name="frameOptions"];
-  Node start_offset = 6 [json_name="startOffset"];
-  Node end_offset = 7 [json_name="endOffset"];
-  int32 location = 8 [json_name="location"];
-}
-
-message RangeSubselect
-{
-  bool lateral = 1 [json_name="lateral"];
-  Node subquery = 2 [json_name="subquery"];
-  Alias alias = 3 [json_name="alias"];
-}
-
-message RangeFunction
-{
-  bool lateral = 1 [json_name="lateral"];
-  bool ordinality = 2 [json_name="ordinality"];
-  bool is_rowsfrom = 3 [json_name="is_rowsfrom"];
-  repeated Node functions = 4 [json_name="functions"];
-  Alias alias = 5 [json_name="alias"];
-  repeated Node coldeflist = 6 [json_name="coldeflist"];
-}
-
-message RangeTableSample
-{
-  Node relation = 1 [json_name="relation"];
-  repeated Node method = 2 [json_name="method"];
-  repeated Node args = 3 [json_name="args"];
-  Node repeatable = 4 [json_name="repeatable"];
-  int32 location = 5 [json_name="location"];
-}
-
-message RangeTableFunc
-{
-  bool lateral = 1 [json_name="lateral"];
-  Node docexpr = 2 [json_name="docexpr"];
-  Node rowexpr = 3 [json_name="rowexpr"];
-  repeated Node namespaces = 4 [json_name="namespaces"];
-  repeated Node columns = 5 [json_name="columns"];
-  Alias alias = 6 [json_name="alias"];
-  int32 location = 7 [json_name="location"];
-}
-
-message RangeTableFuncCol
-{
-  string colname = 1 [json_name="colname"];
-  TypeName type_name = 2 [json_name="typeName"];
-  bool for_ordinality = 3 [json_name="for_ordinality"];
-  bool is_not_null = 4 [json_name="is_not_null"];
-  Node colexpr = 5 [json_name="colexpr"];
-  Node coldefexpr = 6 [json_name="coldefexpr"];
-  int32 location = 7 [json_name="location"];
-}
-
-message TypeName
-{
-  repeated Node names = 1 [json_name="names"];
-  uint32 type_oid = 2 [json_name="typeOid"];
-  bool setof = 3 [json_name="setof"];
-  bool pct_type = 4 [json_name="pct_type"];
-  repeated Node typmods = 5 [json_name="typmods"];
-  int32 typemod = 6 [json_name="typemod"];
-  repeated Node array_bounds = 7 [json_name="arrayBounds"];
-  int32 location = 8 [json_name="location"];
-}
-
-message ColumnDef
-{
-  string colname = 1 [json_name="colname"];
-  TypeName type_name = 2 [json_name="typeName"];
-  string compression = 3 [json_name="compression"];
-  int32 inhcount = 4 [json_name="inhcount"];
-  bool is_local = 5 [json_name="is_local"];
-  bool is_not_null = 6 [json_name="is_not_null"];
-  bool is_from_type = 7 [json_name="is_from_type"];
-  string storage = 8 [json_name="storage"];
-  Node raw_default = 9 [json_name="raw_default"];
-  Node cooked_default = 10 [json_name="cooked_default"];
-  string identity = 11 [json_name="identity"];
-  RangeVar identity_sequence = 12 [json_name="identitySequence"];
-  string generated = 13 [json_name="generated"];
-  CollateClause coll_clause = 14 [json_name="collClause"];
-  uint32 coll_oid = 15 [json_name="collOid"];
-  repeated Node constraints = 16 [json_name="constraints"];
-  repeated Node fdwoptions = 17 [json_name="fdwoptions"];
-  int32 location = 18 [json_name="location"];
-}
-
-message IndexElem
-{
-  string name = 1 [json_name="name"];
-  Node expr = 2 [json_name="expr"];
-  string indexcolname = 3 [json_name="indexcolname"];
-  repeated Node collation = 4 [json_name="collation"];
-  repeated Node opclass = 5 [json_name="opclass"];
-  repeated Node opclassopts = 6 [json_name="opclassopts"];
-  SortByDir ordering = 7 [json_name="ordering"];
-  SortByNulls nulls_ordering = 8 [json_name="nulls_ordering"];
-}
-
-message StatsElem
-{
-  string name = 1 [json_name="name"];
-  Node expr = 2 [json_name="expr"];
-}
-
-message Constraint
-{
-  ConstrType contype = 1 [json_name="contype"];
-  string conname = 2 [json_name="conname"];
-  bool deferrable = 3 [json_name="deferrable"];
-  bool initdeferred = 4 [json_name="initdeferred"];
-  int32 location = 5 [json_name="location"];
-  bool is_no_inherit = 6 [json_name="is_no_inherit"];
-  Node raw_expr = 7 [json_name="raw_expr"];
-  string cooked_expr = 8 [json_name="cooked_expr"];
-  string generated_when = 9 [json_name="generated_when"];
-  bool nulls_not_distinct = 10 [json_name="nulls_not_distinct"];
-  repeated Node keys = 11 [json_name="keys"];
-  repeated Node including = 12 [json_name="including"];
-  repeated Node exclusions = 13 [json_name="exclusions"];
-  repeated Node options = 14 [json_name="options"];
-  string indexname = 15 [json_name="indexname"];
-  string indexspace = 16 [json_name="indexspace"];
-  bool reset_default_tblspc = 17 [json_name="reset_default_tblspc"];
-  string access_method = 18 [json_name="access_method"];
-  Node where_clause = 19 [json_name="where_clause"];
-  RangeVar pktable = 20 [json_name="pktable"];
-  repeated Node fk_attrs = 21 [json_name="fk_attrs"];
-  repeated Node pk_attrs = 22 [json_name="pk_attrs"];
-  string fk_matchtype = 23 [json_name="fk_matchtype"];
-  string fk_upd_action = 24 [json_name="fk_upd_action"];
-  string fk_del_action = 25 [json_name="fk_del_action"];
-  repeated Node fk_del_set_cols = 26 [json_name="fk_del_set_cols"];
-  repeated Node old_conpfeqop = 27 [json_name="old_conpfeqop"];
-  uint32 old_pktable_oid = 28 [json_name="old_pktable_oid"];
-  bool skip_validation = 29 [json_name="skip_validation"];
-  bool initially_valid = 30 [json_name="initially_valid"];
-}
-
-message DefElem
-{
-  string defnamespace = 1 [json_name="defnamespace"];
-  string defname = 2 [json_name="defname"];
-  Node arg = 3 [json_name="arg"];
-  DefElemAction defaction = 4 [json_name="defaction"];
-  int32 location = 5 [json_name="location"];
-}
-
-message RangeTblEntry
-{
-  RTEKind rtekind = 1 [json_name="rtekind"];
-  uint32 relid = 2 [json_name="relid"];
-  string relkind = 3 [json_name="relkind"];
-  int32 rellockmode = 4 [json_name="rellockmode"];
-  TableSampleClause tablesample = 5 [json_name="tablesample"];
-  Query subquery = 6 [json_name="subquery"];
-  bool security_barrier = 7 [json_name="security_barrier"];
-  JoinType jointype = 8 [json_name="jointype"];
-  int32 joinmergedcols = 9 [json_name="joinmergedcols"];
-  repeated Node joinaliasvars = 10 [json_name="joinaliasvars"];
-  repeated Node joinleftcols = 11 [json_name="joinleftcols"];
-  repeated Node joinrightcols = 12 [json_name="joinrightcols"];
-  Alias join_using_alias = 13 [json_name="join_using_alias"];
-  repeated Node functions = 14 [json_name="functions"];
-  bool funcordinality = 15 [json_name="funcordinality"];
-  TableFunc tablefunc = 16 [json_name="tablefunc"];
-  repeated Node values_lists = 17 [json_name="values_lists"];
-  string ctename = 18 [json_name="ctename"];
-  uint32 ctelevelsup = 19 [json_name="ctelevelsup"];
-  bool self_reference = 20 [json_name="self_reference"];
-  repeated Node coltypes = 21 [json_name="coltypes"];
-  repeated Node coltypmods = 22 [json_name="coltypmods"];
-  repeated Node colcollations = 23 [json_name="colcollations"];
-  string enrname = 24 [json_name="enrname"];
-  double enrtuples = 25 [json_name="enrtuples"];
-  Alias alias = 26 [json_name="alias"];
-  Alias eref = 27 [json_name="eref"];
-  bool lateral = 28 [json_name="lateral"];
-  bool inh = 29 [json_name="inh"];
-  bool in_from_cl = 30 [json_name="inFromCl"];
-  uint32 required_perms = 31 [json_name="requiredPerms"];
-  uint32 check_as_user = 32 [json_name="checkAsUser"];
-  repeated uint64 selected_cols = 33 [json_name="selectedCols"];
-  repeated uint64 inserted_cols = 34 [json_name="insertedCols"];
-  repeated uint64 updated_cols = 35 [json_name="updatedCols"];
-  repeated uint64 extra_updated_cols = 36 [json_name="extraUpdatedCols"];
-  repeated Node security_quals = 37 [json_name="securityQuals"];
-}
-
-message RangeTblFunction
-{
-  Node funcexpr = 1 [json_name="funcexpr"];
-  int32 funccolcount = 2 [json_name="funccolcount"];
-  repeated Node funccolnames = 3 [json_name="funccolnames"];
-  repeated Node funccoltypes = 4 [json_name="funccoltypes"];
-  repeated Node funccoltypmods = 5 [json_name="funccoltypmods"];
-  repeated Node funccolcollations = 6 [json_name="funccolcollations"];
-  repeated uint64 funcparams = 7 [json_name="funcparams"];
-}
-
-message TableSampleClause
-{
-  uint32 tsmhandler = 1 [json_name="tsmhandler"];
-  repeated Node args = 2 [json_name="args"];
-  Node repeatable = 3 [json_name="repeatable"];
-}
-
-message WithCheckOption
-{
-  WCOKind kind = 1 [json_name="kind"];
-  string relname = 2 [json_name="relname"];
-  string polname = 3 [json_name="polname"];
-  Node qual = 4 [json_name="qual"];
-  bool cascaded = 5 [json_name="cascaded"];
-}
-
-message SortGroupClause
-{
-  uint32 tle_sort_group_ref = 1 [json_name="tleSortGroupRef"];
-  uint32 eqop = 2 [json_name="eqop"];
-  uint32 sortop = 3 [json_name="sortop"];
-  bool nulls_first = 4 [json_name="nulls_first"];
-  bool hashable = 5 [json_name="hashable"];
-}
-
-message GroupingSet
-{
-  GroupingSetKind kind = 1 [json_name="kind"];
-  repeated Node content = 2 [json_name="content"];
-  int32 location = 3 [json_name="location"];
-}
-
-message WindowClause
-{
-  string name = 1 [json_name="name"];
-  string refname = 2 [json_name="refname"];
-  repeated Node partition_clause = 3 [json_name="partitionClause"];
-  repeated Node order_clause = 4 [json_name="orderClause"];
-  int32 frame_options = 5 [json_name="frameOptions"];
-  Node start_offset = 6 [json_name="startOffset"];
-  Node end_offset = 7 [json_name="endOffset"];
-  repeated Node run_condition = 8 [json_name="runCondition"];
-  uint32 start_in_range_func = 9 [json_name="startInRangeFunc"];
-  uint32 end_in_range_func = 10 [json_name="endInRangeFunc"];
-  uint32 in_range_coll = 11 [json_name="inRangeColl"];
-  bool in_range_asc = 12 [json_name="inRangeAsc"];
-  bool in_range_nulls_first = 13 [json_name="inRangeNullsFirst"];
-  uint32 winref = 14 [json_name="winref"];
-  bool copied_order = 15 [json_name="copiedOrder"];
-}
-
-message ObjectWithArgs
-{
-  repeated Node objname = 1 [json_name="objname"];
-  repeated Node objargs = 2 [json_name="objargs"];
-  repeated Node objfuncargs = 3 [json_name="objfuncargs"];
-  bool args_unspecified = 4 [json_name="args_unspecified"];
-}
-
-message AccessPriv
-{
-  string priv_name = 1 [json_name="priv_name"];
-  repeated Node cols = 2 [json_name="cols"];
-}
-
-message CreateOpClassItem
-{
-  int32 itemtype = 1 [json_name="itemtype"];
-  ObjectWithArgs name = 2 [json_name="name"];
-  int32 number = 3 [json_name="number"];
-  repeated Node order_family = 4 [json_name="order_family"];
-  repeated Node class_args = 5 [json_name="class_args"];
-  TypeName storedtype = 6 [json_name="storedtype"];
-}
-
-message TableLikeClause
-{
-  RangeVar relation = 1 [json_name="relation"];
-  uint32 options = 2 [json_name="options"];
-  uint32 relation_oid = 3 [json_name="relationOid"];
-}
-
-message FunctionParameter
-{
-  string name = 1 [json_name="name"];
-  TypeName arg_type = 2 [json_name="argType"];
-  FunctionParameterMode mode = 3 [json_name="mode"];
-  Node defexpr = 4 [json_name="defexpr"];
-}
-
-message LockingClause
-{
-  repeated Node locked_rels = 1 [json_name="lockedRels"];
-  LockClauseStrength strength = 2 [json_name="strength"];
-  LockWaitPolicy wait_policy = 3 [json_name="waitPolicy"];
-}
-
-message RowMarkClause
-{
-  uint32 rti = 1 [json_name="rti"];
-  LockClauseStrength strength = 2 [json_name="strength"];
-  LockWaitPolicy wait_policy = 3 [json_name="waitPolicy"];
-  bool pushed_down = 4 [json_name="pushedDown"];
-}
-
-message XmlSerialize
-{
-  XmlOptionType xmloption = 1 [json_name="xmloption"];
-  Node expr = 2 [json_name="expr"];
-  TypeName type_name = 3 [json_name="typeName"];
-  int32 location = 4 [json_name="location"];
-}
-
-message WithClause
-{
-  repeated Node ctes = 1 [json_name="ctes"];
-  bool recursive = 2 [json_name="recursive"];
-  int32 location = 3 [json_name="location"];
-}
-
-message InferClause
-{
-  repeated Node index_elems = 1 [json_name="indexElems"];
-  Node where_clause = 2 [json_name="whereClause"];
-  string conname = 3 [json_name="conname"];
-  int32 location = 4 [json_name="location"];
-}
-
-message OnConflictClause
-{
-  OnConflictAction action = 1 [json_name="action"];
-  InferClause infer = 2 [json_name="infer"];
-  repeated Node target_list = 3 [json_name="targetList"];
-  Node where_clause = 4 [json_name="whereClause"];
-  int32 location = 5 [json_name="location"];
-}
-
-message CTESearchClause
-{
-  repeated Node search_col_list = 1 [json_name="search_col_list"];
-  bool search_breadth_first = 2 [json_name="search_breadth_first"];
-  string search_seq_column = 3 [json_name="search_seq_column"];
-  int32 location = 4 [json_name="location"];
-}
-
-message CTECycleClause
-{
-  repeated Node cycle_col_list = 1 [json_name="cycle_col_list"];
-  string cycle_mark_column = 2 [json_name="cycle_mark_column"];
-  Node cycle_mark_value = 3 [json_name="cycle_mark_value"];
-  Node cycle_mark_default = 4 [json_name="cycle_mark_default"];
-  string cycle_path_column = 5 [json_name="cycle_path_column"];
-  int32 location = 6 [json_name="location"];
-  uint32 cycle_mark_type = 7 [json_name="cycle_mark_type"];
-  int32 cycle_mark_typmod = 8 [json_name="cycle_mark_typmod"];
-  uint32 cycle_mark_collation = 9 [json_name="cycle_mark_collation"];
-  uint32 cycle_mark_neop = 10 [json_name="cycle_mark_neop"];
-}
-
-message CommonTableExpr
-{
-  string ctename = 1 [json_name="ctename"];
-  repeated Node aliascolnames = 2 [json_name="aliascolnames"];
-  CTEMaterialize ctematerialized = 3 [json_name="ctematerialized"];
-  Node ctequery = 4 [json_name="ctequery"];
-  CTESearchClause search_clause = 5 [json_name="search_clause"];
-  CTECycleClause cycle_clause = 6 [json_name="cycle_clause"];
-  int32 location = 7 [json_name="location"];
-  bool cterecursive = 8 [json_name="cterecursive"];
-  int32 cterefcount = 9 [json_name="cterefcount"];
-  repeated Node ctecolnames = 10 [json_name="ctecolnames"];
-  repeated Node ctecoltypes = 11 [json_name="ctecoltypes"];
-  repeated Node ctecoltypmods = 12 [json_name="ctecoltypmods"];
-  repeated Node ctecolcollations = 13 [json_name="ctecolcollations"];
-}
-
-message MergeWhenClause
-{
-  bool matched = 1 [json_name="matched"];
-  CmdType command_type = 2 [json_name="commandType"];
-  OverridingKind override = 3 [json_name="override"];
-  Node condition = 4 [json_name="condition"];
-  repeated Node target_list = 5 [json_name="targetList"];
-  repeated Node values = 6 [json_name="values"];
-}
-
-message RoleSpec
-{
-  RoleSpecType roletype = 1 [json_name="roletype"];
-  string rolename = 2 [json_name="rolename"];
-  int32 location = 3 [json_name="location"];
-}
-
-message TriggerTransition
-{
-  string name = 1 [json_name="name"];
-  bool is_new = 2 [json_name="isNew"];
-  bool is_table = 3 [json_name="isTable"];
-}
-
-message PartitionElem
-{
-  string name = 1 [json_name="name"];
-  Node expr = 2 [json_name="expr"];
-  repeated Node collation = 3 [json_name="collation"];
-  repeated Node opclass = 4 [json_name="opclass"];
-  int32 location = 5 [json_name="location"];
-}
-
-message PartitionSpec
-{
-  string strategy = 1 [json_name="strategy"];
-  repeated Node part_params = 2 [json_name="partParams"];
-  int32 location = 3 [json_name="location"];
-}
-
-message PartitionBoundSpec
-{
-  string strategy = 1 [json_name="strategy"];
-  bool is_default = 2 [json_name="is_default"];
-  int32 modulus = 3 [json_name="modulus"];
-  int32 remainder = 4 [json_name="remainder"];
-  repeated Node listdatums = 5 [json_name="listdatums"];
-  repeated Node lowerdatums = 6 [json_name="lowerdatums"];
-  repeated Node upperdatums = 7 [json_name="upperdatums"];
-  int32 location = 8 [json_name="location"];
-}
-
-message PartitionRangeDatum
-{
-  PartitionRangeDatumKind kind = 1 [json_name="kind"];
-  Node value = 2 [json_name="value"];
-  int32 location = 3 [json_name="location"];
-}
-
-message PartitionCmd
-{
-  RangeVar name = 1 [json_name="name"];
-  PartitionBoundSpec bound = 2 [json_name="bound"];
-  bool concurrent = 3 [json_name="concurrent"];
-}
-
-message VacuumRelation
-{
-  RangeVar relation = 1 [json_name="relation"];
-  uint32 oid = 2 [json_name="oid"];
-  repeated Node va_cols = 3 [json_name="va_cols"];
-}
-
-message PublicationObjSpec
-{
-  PublicationObjSpecType pubobjtype = 1 [json_name="pubobjtype"];
-  string name = 2 [json_name="name"];
-  PublicationTable pubtable = 3 [json_name="pubtable"];
-  int32 location = 4 [json_name="location"];
-}
-
-message PublicationTable
-{
-  RangeVar relation = 1 [json_name="relation"];
-  Node where_clause = 2 [json_name="whereClause"];
-  repeated Node columns = 3 [json_name="columns"];
-}
-
-message InlineCodeBlock
-{
-  string source_text = 1 [json_name="source_text"];
-  uint32 lang_oid = 2 [json_name="langOid"];
-  bool lang_is_trusted = 3 [json_name="langIsTrusted"];
-  bool atomic = 4 [json_name="atomic"];
-}
-
-message CallContext
-{
-  bool atomic = 1 [json_name="atomic"];
-}
-
-enum OverridingKind
-{
-  OVERRIDING_KIND_UNDEFINED = 0;
-  OVERRIDING_NOT_SET = 1;
-  OVERRIDING_USER_VALUE = 2;
-  OVERRIDING_SYSTEM_VALUE = 3;
-}
-
-enum QuerySource
-{
-  QUERY_SOURCE_UNDEFINED = 0;
-  QSRC_ORIGINAL = 1;
-  QSRC_PARSER = 2;
-  QSRC_INSTEAD_RULE = 3;
-  QSRC_QUAL_INSTEAD_RULE = 4;
-  QSRC_NON_INSTEAD_RULE = 5;
-}
-
-enum SortByDir
-{
-  SORT_BY_DIR_UNDEFINED = 0;
-  SORTBY_DEFAULT = 1;
-  SORTBY_ASC = 2;
-  SORTBY_DESC = 3;
-  SORTBY_USING = 4;
-}
-
-enum SortByNulls
-{
-  SORT_BY_NULLS_UNDEFINED = 0;
-  SORTBY_NULLS_DEFAULT = 1;
-  SORTBY_NULLS_FIRST = 2;
-  SORTBY_NULLS_LAST = 3;
-}
-
-enum SetQuantifier
-{
-  SET_QUANTIFIER_UNDEFINED = 0;
-  SET_QUANTIFIER_DEFAULT = 1;
-  SET_QUANTIFIER_ALL = 2;
-  SET_QUANTIFIER_DISTINCT = 3;
-}
-
-enum A_Expr_Kind
-{
-  A_EXPR_KIND_UNDEFINED = 0;
-  AEXPR_OP = 1;
-  AEXPR_OP_ANY = 2;
-  AEXPR_OP_ALL = 3;
-  AEXPR_DISTINCT = 4;
-  AEXPR_NOT_DISTINCT = 5;
-  AEXPR_NULLIF = 6;
-  AEXPR_IN = 7;
-  AEXPR_LIKE = 8;
-  AEXPR_ILIKE = 9;
-  AEXPR_SIMILAR = 10;
-  AEXPR_BETWEEN = 11;
-  AEXPR_NOT_BETWEEN = 12;
-  AEXPR_BETWEEN_SYM = 13;
-  AEXPR_NOT_BETWEEN_SYM = 14;
-}
-
-enum RoleSpecType
-{
-  ROLE_SPEC_TYPE_UNDEFINED = 0;
-  ROLESPEC_CSTRING = 1;
-  ROLESPEC_CURRENT_ROLE = 2;
-  ROLESPEC_CURRENT_USER = 3;
-  ROLESPEC_SESSION_USER = 4;
-  ROLESPEC_PUBLIC = 5;
-}
-
-enum TableLikeOption
-{
-  TABLE_LIKE_OPTION_UNDEFINED = 0;
-  CREATE_TABLE_LIKE_COMMENTS = 1;
-  CREATE_TABLE_LIKE_COMPRESSION = 2;
-  CREATE_TABLE_LIKE_CONSTRAINTS = 3;
-  CREATE_TABLE_LIKE_DEFAULTS = 4;
-  CREATE_TABLE_LIKE_GENERATED = 5;
-  CREATE_TABLE_LIKE_IDENTITY = 6;
-  CREATE_TABLE_LIKE_INDEXES = 7;
-  CREATE_TABLE_LIKE_STATISTICS = 8;
-  CREATE_TABLE_LIKE_STORAGE = 9;
-  CREATE_TABLE_LIKE_ALL = 10;
-}
-
-enum DefElemAction
-{
-  DEF_ELEM_ACTION_UNDEFINED = 0;
-  DEFELEM_UNSPEC = 1;
-  DEFELEM_SET = 2;
-  DEFELEM_ADD = 3;
-  DEFELEM_DROP = 4;
-}
-
-enum PartitionRangeDatumKind
-{
-  PARTITION_RANGE_DATUM_KIND_UNDEFINED = 0;
-  PARTITION_RANGE_DATUM_MINVALUE = 1;
-  PARTITION_RANGE_DATUM_VALUE = 2;
-  PARTITION_RANGE_DATUM_MAXVALUE = 3;
-}
-
-enum RTEKind
-{
-  RTEKIND_UNDEFINED = 0;
-  RTE_RELATION = 1;
-  RTE_SUBQUERY = 2;
-  RTE_JOIN = 3;
-  RTE_FUNCTION = 4;
-  RTE_TABLEFUNC = 5;
-  RTE_VALUES = 6;
-  RTE_CTE = 7;
-  RTE_NAMEDTUPLESTORE = 8;
-  RTE_RESULT = 9;
-}
-
-enum WCOKind
-{
-  WCOKIND_UNDEFINED = 0;
-  WCO_VIEW_CHECK = 1;
-  WCO_RLS_INSERT_CHECK = 2;
-  WCO_RLS_UPDATE_CHECK = 3;
-  WCO_RLS_CONFLICT_CHECK = 4;
-  WCO_RLS_MERGE_UPDATE_CHECK = 5;
-  WCO_RLS_MERGE_DELETE_CHECK = 6;
-}
-
-enum GroupingSetKind
-{
-  GROUPING_SET_KIND_UNDEFINED = 0;
-  GROUPING_SET_EMPTY = 1;
-  GROUPING_SET_SIMPLE = 2;
-  GROUPING_SET_ROLLUP = 3;
-  GROUPING_SET_CUBE = 4;
-  GROUPING_SET_SETS = 5;
-}
-
-enum CTEMaterialize
-{
-  CTEMATERIALIZE_UNDEFINED = 0;
-  CTEMaterializeDefault = 1;
-  CTEMaterializeAlways = 2;
-  CTEMaterializeNever = 3;
-}
-
-enum SetOperation
-{
-  SET_OPERATION_UNDEFINED = 0;
-  SETOP_NONE = 1;
-  SETOP_UNION = 2;
-  SETOP_INTERSECT = 3;
-  SETOP_EXCEPT = 4;
-}
-
-enum ObjectType
-{
-  OBJECT_TYPE_UNDEFINED = 0;
-  OBJECT_ACCESS_METHOD = 1;
-  OBJECT_AGGREGATE = 2;
-  OBJECT_AMOP = 3;
-  OBJECT_AMPROC = 4;
-  OBJECT_ATTRIBUTE = 5;
-  OBJECT_CAST = 6;
-  OBJECT_COLUMN = 7;
-  OBJECT_COLLATION = 8;
-  OBJECT_CONVERSION = 9;
-  OBJECT_DATABASE = 10;
-  OBJECT_DEFAULT = 11;
-  OBJECT_DEFACL = 12;
-  OBJECT_DOMAIN = 13;
-  OBJECT_DOMCONSTRAINT = 14;
-  OBJECT_EVENT_TRIGGER = 15;
-  OBJECT_EXTENSION = 16;
-  OBJECT_FDW = 17;
-  OBJECT_FOREIGN_SERVER = 18;
-  OBJECT_FOREIGN_TABLE = 19;
-  OBJECT_FUNCTION = 20;
-  OBJECT_INDEX = 21;
-  OBJECT_LANGUAGE = 22;
-  OBJECT_LARGEOBJECT = 23;
-  OBJECT_MATVIEW = 24;
-  OBJECT_OPCLASS = 25;
-  OBJECT_OPERATOR = 26;
-  OBJECT_OPFAMILY = 27;
-  OBJECT_PARAMETER_ACL = 28;
-  OBJECT_POLICY = 29;
-  OBJECT_PROCEDURE = 30;
-  OBJECT_PUBLICATION = 31;
-  OBJECT_PUBLICATION_NAMESPACE = 32;
-  OBJECT_PUBLICATION_REL = 33;
-  OBJECT_ROLE = 34;
-  OBJECT_ROUTINE = 35;
-  OBJECT_RULE = 36;
-  OBJECT_SCHEMA = 37;
-  OBJECT_SEQUENCE = 38;
-  OBJECT_SUBSCRIPTION = 39;
-  OBJECT_STATISTIC_EXT = 40;
-  OBJECT_TABCONSTRAINT = 41;
-  OBJECT_TABLE = 42;
-  OBJECT_TABLESPACE = 43;
-  OBJECT_TRANSFORM = 44;
-  OBJECT_TRIGGER = 45;
-  OBJECT_TSCONFIGURATION = 46;
-  OBJECT_TSDICTIONARY = 47;
-  OBJECT_TSPARSER = 48;
-  OBJECT_TSTEMPLATE = 49;
-  OBJECT_TYPE = 50;
-  OBJECT_USER_MAPPING = 51;
-  OBJECT_VIEW = 52;
-}
-
-enum DropBehavior
-{
-  DROP_BEHAVIOR_UNDEFINED = 0;
-  DROP_RESTRICT = 1;
-  DROP_CASCADE = 2;
-}
-
-enum AlterTableType
-{
-  ALTER_TABLE_TYPE_UNDEFINED = 0;
-  AT_AddColumn = 1;
-  AT_AddColumnRecurse = 2;
-  AT_AddColumnToView = 3;
-  AT_ColumnDefault = 4;
-  AT_CookedColumnDefault = 5;
-  AT_DropNotNull = 6;
-  AT_SetNotNull = 7;
-  AT_DropExpression = 8;
-  AT_CheckNotNull = 9;
-  AT_SetStatistics = 10;
-  AT_SetOptions = 11;
-  AT_ResetOptions = 12;
-  AT_SetStorage = 13;
-  AT_SetCompression = 14;
-  AT_DropColumn = 15;
-  AT_DropColumnRecurse = 16;
-  AT_AddIndex = 17;
-  AT_ReAddIndex = 18;
-  AT_AddConstraint = 19;
-  AT_AddConstraintRecurse = 20;
-  AT_ReAddConstraint = 21;
-  AT_ReAddDomainConstraint = 22;
-  AT_AlterConstraint = 23;
-  AT_ValidateConstraint = 24;
-  AT_ValidateConstraintRecurse = 25;
-  AT_AddIndexConstraint = 26;
-  AT_DropConstraint = 27;
-  AT_DropConstraintRecurse = 28;
-  AT_ReAddComment = 29;
-  AT_AlterColumnType = 30;
-  AT_AlterColumnGenericOptions = 31;
-  AT_ChangeOwner = 32;
-  AT_ClusterOn = 33;
-  AT_DropCluster = 34;
-  AT_SetLogged = 35;
-  AT_SetUnLogged = 36;
-  AT_DropOids = 37;
-  AT_SetAccessMethod = 38;
-  AT_SetTableSpace = 39;
-  AT_SetRelOptions = 40;
-  AT_ResetRelOptions = 41;
-  AT_ReplaceRelOptions = 42;
-  AT_EnableTrig = 43;
-  AT_EnableAlwaysTrig = 44;
-  AT_EnableReplicaTrig = 45;
-  AT_DisableTrig = 46;
-  AT_EnableTrigAll = 47;
-  AT_DisableTrigAll = 48;
-  AT_EnableTrigUser = 49;
-  AT_DisableTrigUser = 50;
-  AT_EnableRule = 51;
-  AT_EnableAlwaysRule = 52;
-  AT_EnableReplicaRule = 53;
-  AT_DisableRule = 54;
-  AT_AddInherit = 55;
-  AT_DropInherit = 56;
-  AT_AddOf = 57;
-  AT_DropOf = 58;
-  AT_ReplicaIdentity = 59;
-  AT_EnableRowSecurity = 60;
-  AT_DisableRowSecurity = 61;
-  AT_ForceRowSecurity = 62;
-  AT_NoForceRowSecurity = 63;
-  AT_GenericOptions = 64;
-  AT_AttachPartition = 65;
-  AT_DetachPartition = 66;
-  AT_DetachPartitionFinalize = 67;
-  AT_AddIdentity = 68;
-  AT_SetIdentity = 69;
-  AT_DropIdentity = 70;
-  AT_ReAddStatistics = 71;
-}
-
-enum GrantTargetType
-{
-  GRANT_TARGET_TYPE_UNDEFINED = 0;
-  ACL_TARGET_OBJECT = 1;
-  ACL_TARGET_ALL_IN_SCHEMA = 2;
-  ACL_TARGET_DEFAULTS = 3;
-}
-
-enum VariableSetKind
-{
-  VARIABLE_SET_KIND_UNDEFINED = 0;
-  VAR_SET_VALUE = 1;
-  VAR_SET_DEFAULT = 2;
-  VAR_SET_CURRENT = 3;
-  VAR_SET_MULTI = 4;
-  VAR_RESET = 5;
-  VAR_RESET_ALL = 6;
-}
-
-enum ConstrType
-{
-  CONSTR_TYPE_UNDEFINED = 0;
-  CONSTR_NULL = 1;
-  CONSTR_NOTNULL = 2;
-  CONSTR_DEFAULT = 3;
-  CONSTR_IDENTITY = 4;
-  CONSTR_GENERATED = 5;
-  CONSTR_CHECK = 6;
-  CONSTR_PRIMARY = 7;
-  CONSTR_UNIQUE = 8;
-  CONSTR_EXCLUSION = 9;
-  CONSTR_FOREIGN = 10;
-  CONSTR_ATTR_DEFERRABLE = 11;
-  CONSTR_ATTR_NOT_DEFERRABLE = 12;
-  CONSTR_ATTR_DEFERRED = 13;
-  CONSTR_ATTR_IMMEDIATE = 14;
-}
-
-enum ImportForeignSchemaType
-{
-  IMPORT_FOREIGN_SCHEMA_TYPE_UNDEFINED = 0;
-  FDW_IMPORT_SCHEMA_ALL = 1;
-  FDW_IMPORT_SCHEMA_LIMIT_TO = 2;
-  FDW_IMPORT_SCHEMA_EXCEPT = 3;
-}
-
-enum RoleStmtType
-{
-  ROLE_STMT_TYPE_UNDEFINED = 0;
-  ROLESTMT_ROLE = 1;
-  ROLESTMT_USER = 2;
-  ROLESTMT_GROUP = 3;
-}
-
-enum FetchDirection
-{
-  FETCH_DIRECTION_UNDEFINED = 0;
-  FETCH_FORWARD = 1;
-  FETCH_BACKWARD = 2;
-  FETCH_ABSOLUTE = 3;
-  FETCH_RELATIVE = 4;
-}
-
-enum FunctionParameterMode
-{
-  FUNCTION_PARAMETER_MODE_UNDEFINED = 0;
-  FUNC_PARAM_IN = 1;
-  FUNC_PARAM_OUT = 2;
-  FUNC_PARAM_INOUT = 3;
-  FUNC_PARAM_VARIADIC = 4;
-  FUNC_PARAM_TABLE = 5;
-  FUNC_PARAM_DEFAULT = 6;
-}
-
-enum TransactionStmtKind
-{
-  TRANSACTION_STMT_KIND_UNDEFINED = 0;
-  TRANS_STMT_BEGIN = 1;
-  TRANS_STMT_START = 2;
-  TRANS_STMT_COMMIT = 3;
-  TRANS_STMT_ROLLBACK = 4;
-  TRANS_STMT_SAVEPOINT = 5;
-  TRANS_STMT_RELEASE = 6;
-  TRANS_STMT_ROLLBACK_TO = 7;
-  TRANS_STMT_PREPARE = 8;
-  TRANS_STMT_COMMIT_PREPARED = 9;
-  TRANS_STMT_ROLLBACK_PREPARED = 10;
-}
-
-enum ViewCheckOption
-{
-  VIEW_CHECK_OPTION_UNDEFINED = 0;
-  NO_CHECK_OPTION = 1;
-  LOCAL_CHECK_OPTION = 2;
-  CASCADED_CHECK_OPTION = 3;
-}
-
-enum DiscardMode
-{
-  DISCARD_MODE_UNDEFINED = 0;
-  DISCARD_ALL = 1;
-  DISCARD_PLANS = 2;
-  DISCARD_SEQUENCES = 3;
-  DISCARD_TEMP = 4;
-}
-
-enum ReindexObjectType
-{
-  REINDEX_OBJECT_TYPE_UNDEFINED = 0;
-  REINDEX_OBJECT_INDEX = 1;
-  REINDEX_OBJECT_TABLE = 2;
-  REINDEX_OBJECT_SCHEMA = 3;
-  REINDEX_OBJECT_SYSTEM = 4;
-  REINDEX_OBJECT_DATABASE = 5;
-}
-
-enum AlterTSConfigType
-{
-  ALTER_TSCONFIG_TYPE_UNDEFINED = 0;
-  ALTER_TSCONFIG_ADD_MAPPING = 1;
-  ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN = 2;
-  ALTER_TSCONFIG_REPLACE_DICT = 3;
-  ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN = 4;
-  ALTER_TSCONFIG_DROP_MAPPING = 5;
-}
-
-enum PublicationObjSpecType
-{
-  PUBLICATION_OBJ_SPEC_TYPE_UNDEFINED = 0;
-  PUBLICATIONOBJ_TABLE = 1;
-  PUBLICATIONOBJ_TABLES_IN_SCHEMA = 2;
-  PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA = 3;
-  PUBLICATIONOBJ_CONTINUATION = 4;
-}
-
-enum AlterPublicationAction
-{
-  ALTER_PUBLICATION_ACTION_UNDEFINED = 0;
-  AP_AddObjects = 1;
-  AP_DropObjects = 2;
-  AP_SetObjects = 3;
-}
-
-enum AlterSubscriptionType
-{
-  ALTER_SUBSCRIPTION_TYPE_UNDEFINED = 0;
-  ALTER_SUBSCRIPTION_OPTIONS = 1;
-  ALTER_SUBSCRIPTION_CONNECTION = 2;
-  ALTER_SUBSCRIPTION_SET_PUBLICATION = 3;
-  ALTER_SUBSCRIPTION_ADD_PUBLICATION = 4;
-  ALTER_SUBSCRIPTION_DROP_PUBLICATION = 5;
-  ALTER_SUBSCRIPTION_REFRESH = 6;
-  ALTER_SUBSCRIPTION_ENABLED = 7;
-  ALTER_SUBSCRIPTION_SKIP = 8;
-}
-
-enum OnCommitAction
-{
-  ON_COMMIT_ACTION_UNDEFINED = 0;
-  ONCOMMIT_NOOP = 1;
-  ONCOMMIT_PRESERVE_ROWS = 2;
-  ONCOMMIT_DELETE_ROWS = 3;
-  ONCOMMIT_DROP = 4;
-}
-
-enum ParamKind
-{
-  PARAM_KIND_UNDEFINED = 0;
-  PARAM_EXTERN = 1;
-  PARAM_EXEC = 2;
-  PARAM_SUBLINK = 3;
-  PARAM_MULTIEXPR = 4;
-}
-
-enum CoercionContext
-{
-  COERCION_CONTEXT_UNDEFINED = 0;
-  COERCION_IMPLICIT = 1;
-  COERCION_ASSIGNMENT = 2;
-  COERCION_PLPGSQL = 3;
-  COERCION_EXPLICIT = 4;
-}
-
-enum CoercionForm
-{
-  COERCION_FORM_UNDEFINED = 0;
-  COERCE_EXPLICIT_CALL = 1;
-  COERCE_EXPLICIT_CAST = 2;
-  COERCE_IMPLICIT_CAST = 3;
-  COERCE_SQL_SYNTAX = 4;
-}
-
-enum BoolExprType
-{
-  BOOL_EXPR_TYPE_UNDEFINED = 0;
-  AND_EXPR = 1;
-  OR_EXPR = 2;
-  NOT_EXPR = 3;
-}
-
-enum SubLinkType
-{
-  SUB_LINK_TYPE_UNDEFINED = 0;
-  EXISTS_SUBLINK = 1;
-  ALL_SUBLINK = 2;
-  ANY_SUBLINK = 3;
-  ROWCOMPARE_SUBLINK = 4;
-  EXPR_SUBLINK = 5;
-  MULTIEXPR_SUBLINK = 6;
-  ARRAY_SUBLINK = 7;
-  CTE_SUBLINK = 8;
-}
-
-enum RowCompareType
-{
-  ROW_COMPARE_TYPE_UNDEFINED = 0;
-  ROWCOMPARE_LT = 1;
-  ROWCOMPARE_LE = 2;
-  ROWCOMPARE_EQ = 3;
-  ROWCOMPARE_GE = 4;
-  ROWCOMPARE_GT = 5;
-  ROWCOMPARE_NE = 6;
-}
-
-enum MinMaxOp
-{
-  MIN_MAX_OP_UNDEFINED = 0;
-  IS_GREATEST = 1;
-  IS_LEAST = 2;
-}
-
-enum SQLValueFunctionOp
-{
-  SQLVALUE_FUNCTION_OP_UNDEFINED = 0;
-  SVFOP_CURRENT_DATE = 1;
-  SVFOP_CURRENT_TIME = 2;
-  SVFOP_CURRENT_TIME_N = 3;
-  SVFOP_CURRENT_TIMESTAMP = 4;
-  SVFOP_CURRENT_TIMESTAMP_N = 5;
-  SVFOP_LOCALTIME = 6;
-  SVFOP_LOCALTIME_N = 7;
-  SVFOP_LOCALTIMESTAMP = 8;
-  SVFOP_LOCALTIMESTAMP_N = 9;
-  SVFOP_CURRENT_ROLE = 10;
-  SVFOP_CURRENT_USER = 11;
-  SVFOP_USER = 12;
-  SVFOP_SESSION_USER = 13;
-  SVFOP_CURRENT_CATALOG = 14;
-  SVFOP_CURRENT_SCHEMA = 15;
-}
-
-enum XmlExprOp
-{
-  XML_EXPR_OP_UNDEFINED = 0;
-  IS_XMLCONCAT = 1;
-  IS_XMLELEMENT = 2;
-  IS_XMLFOREST = 3;
-  IS_XMLPARSE = 4;
-  IS_XMLPI = 5;
-  IS_XMLROOT = 6;
-  IS_XMLSERIALIZE = 7;
-  IS_DOCUMENT = 8;
-}
-
-enum XmlOptionType
-{
-  XML_OPTION_TYPE_UNDEFINED = 0;
-  XMLOPTION_DOCUMENT = 1;
-  XMLOPTION_CONTENT = 2;
-}
-
-enum NullTestType
-{
-  NULL_TEST_TYPE_UNDEFINED = 0;
-  IS_NULL = 1;
-  IS_NOT_NULL = 2;
-}
-
-enum BoolTestType
-{
-  BOOL_TEST_TYPE_UNDEFINED = 0;
-  IS_TRUE = 1;
-  IS_NOT_TRUE = 2;
-  IS_FALSE = 3;
-  IS_NOT_FALSE = 4;
-  IS_UNKNOWN = 5;
-  IS_NOT_UNKNOWN = 6;
-}
-
-enum CmdType
-{
-  CMD_TYPE_UNDEFINED = 0;
-  CMD_UNKNOWN = 1;
-  CMD_SELECT = 2;
-  CMD_UPDATE = 3;
-  CMD_INSERT = 4;
-  CMD_DELETE = 5;
-  CMD_MERGE = 6;
-  CMD_UTILITY = 7;
-  CMD_NOTHING = 8;
-}
-
-enum JoinType
-{
-  JOIN_TYPE_UNDEFINED = 0;
-  JOIN_INNER = 1;
-  JOIN_LEFT = 2;
-  JOIN_FULL = 3;
-  JOIN_RIGHT = 4;
-  JOIN_SEMI = 5;
-  JOIN_ANTI = 6;
-  JOIN_UNIQUE_OUTER = 7;
-  JOIN_UNIQUE_INNER = 8;
-}
-
-enum AggStrategy
-{
-  AGG_STRATEGY_UNDEFINED = 0;
-  AGG_PLAIN = 1;
-  AGG_SORTED = 2;
-  AGG_HASHED = 3;
-  AGG_MIXED = 4;
-}
-
-enum AggSplit
-{
-  AGG_SPLIT_UNDEFINED = 0;
-  AGGSPLIT_SIMPLE = 1;
-  AGGSPLIT_INITIAL_SERIAL = 2;
-  AGGSPLIT_FINAL_DESERIAL = 3;
-}
-
-enum SetOpCmd
-{
-  SET_OP_CMD_UNDEFINED = 0;
-  SETOPCMD_INTERSECT = 1;
-  SETOPCMD_INTERSECT_ALL = 2;
-  SETOPCMD_EXCEPT = 3;
-  SETOPCMD_EXCEPT_ALL = 4;
-}
-
-enum SetOpStrategy
-{
-  SET_OP_STRATEGY_UNDEFINED = 0;
-  SETOP_SORTED = 1;
-  SETOP_HASHED = 2;
-}
-
-enum OnConflictAction
-{
-  ON_CONFLICT_ACTION_UNDEFINED = 0;
-  ONCONFLICT_NONE = 1;
-  ONCONFLICT_NOTHING = 2;
-  ONCONFLICT_UPDATE = 3;
-}
-
-enum LimitOption
-{
-  LIMIT_OPTION_UNDEFINED = 0;
-  LIMIT_OPTION_DEFAULT = 1;
-  LIMIT_OPTION_COUNT = 2;
-  LIMIT_OPTION_WITH_TIES = 3;
-}
-
-enum LockClauseStrength
-{
-  LOCK_CLAUSE_STRENGTH_UNDEFINED = 0;
-  LCS_NONE = 1;
-  LCS_FORKEYSHARE = 2;
-  LCS_FORSHARE = 3;
-  LCS_FORNOKEYUPDATE = 4;
-  LCS_FORUPDATE = 5;
-}
-
-enum LockWaitPolicy
-{
-  LOCK_WAIT_POLICY_UNDEFINED = 0;
-  LockWaitBlock = 1;
-  LockWaitSkip = 2;
-  LockWaitError = 3;
-}
-
-enum LockTupleMode
-{
-  LOCK_TUPLE_MODE_UNDEFINED = 0;
-  LockTupleKeyShare = 1;
-  LockTupleShare = 2;
-  LockTupleNoKeyExclusive = 3;
-  LockTupleExclusive = 4;
-}
-
-message ScanToken {
-  int32 start = 1;
-  int32 end = 2;
-  Token token = 4;
-  KeywordKind keyword_kind = 5;
-}
-
-enum KeywordKind {
-  NO_KEYWORD = 0;
-  UNRESERVED_KEYWORD = 1;
-  COL_NAME_KEYWORD = 2;
-  TYPE_FUNC_NAME_KEYWORD = 3;
-  RESERVED_KEYWORD = 4;
-}
-
-enum Token {
-  NUL = 0;
-  // Single-character tokens that are returned 1:1 (identical with "self" list in scan.l)
-  // Either supporting syntax, or single-character operators (some can be both)
-  // Also see https://www.postgresql.org/docs/12/sql-syntax-lexical.html#SQL-SYNTAX-SPECIAL-CHARS
-  ASCII_37 = 37; // "%"
-  ASCII_40 = 40; // "("
-  ASCII_41 = 41; // ")"
-  ASCII_42 = 42; // "*"
-  ASCII_43 = 43; // "+"
-  ASCII_44 = 44; // ","
-  ASCII_45 = 45; // "-"
-  ASCII_46 = 46; // "."
-  ASCII_47 = 47; // "/"
-  ASCII_58 = 58; // ":"
-  ASCII_59 = 59; // ";"
-  ASCII_60 = 60; // "<"
-  ASCII_61 = 61; // "="
-  ASCII_62 = 62; // ">"
-  ASCII_63 = 63; // "?"
-  ASCII_91 = 91; // "["
-  ASCII_92 = 92; // "\"
-  ASCII_93 = 93; // "]"
-  ASCII_94 = 94; // "^"
-  // Named tokens in scan.l
-  IDENT = 258;
-  UIDENT = 259;
-  FCONST = 260;
-  SCONST = 261;
-  USCONST = 262;
-  BCONST = 263;
-  XCONST = 264;
-  Op = 265;
-  ICONST = 266;
-  PARAM = 267;
-  TYPECAST = 268;
-  DOT_DOT = 269;
-  COLON_EQUALS = 270;
-  EQUALS_GREATER = 271;
-  LESS_EQUALS = 272;
-  GREATER_EQUALS = 273;
-  NOT_EQUALS = 274;
-  SQL_COMMENT = 275;
-  C_COMMENT = 276;
-  ABORT_P = 277;
-  ABSOLUTE_P = 278;
-  ACCESS = 279;
-  ACTION = 280;
-  ADD_P = 281;
-  ADMIN = 282;
-  AFTER = 283;
-  AGGREGATE = 284;
-  ALL = 285;
-  ALSO = 286;
-  ALTER = 287;
-  ALWAYS = 288;
-  ANALYSE = 289;
-  ANALYZE = 290;
-  AND = 291;
-  ANY = 292;
-  ARRAY = 293;
-  AS = 294;
-  ASC = 295;
-  ASENSITIVE = 296;
-  ASSERTION = 297;
-  ASSIGNMENT = 298;
-  ASYMMETRIC = 299;
-  ATOMIC = 300;
-  AT = 301;
-  ATTACH = 302;
-  ATTRIBUTE = 303;
-  AUTHORIZATION = 304;
-  BACKWARD = 305;
-  BEFORE = 306;
-  BEGIN_P = 307;
-  BETWEEN = 308;
-  BIGINT = 309;
-  BINARY = 310;
-  BIT = 311;
-  BOOLEAN_P = 312;
-  BOTH = 313;
-  BREADTH = 314;
-  BY = 315;
-  CACHE = 316;
-  CALL = 317;
-  CALLED = 318;
-  CASCADE = 319;
-  CASCADED = 320;
-  CASE = 321;
-  CAST = 322;
-  CATALOG_P = 323;
-  CHAIN = 324;
-  CHAR_P = 325;
-  CHARACTER = 326;
-  CHARACTERISTICS = 327;
-  CHECK = 328;
-  CHECKPOINT = 329;
-  CLASS = 330;
-  CLOSE = 331;
-  CLUSTER = 332;
-  COALESCE = 333;
-  COLLATE = 334;
-  COLLATION = 335;
-  COLUMN = 336;
-  COLUMNS = 337;
-  COMMENT = 338;
-  COMMENTS = 339;
-  COMMIT = 340;
-  COMMITTED = 341;
-  COMPRESSION = 342;
-  CONCURRENTLY = 343;
-  CONFIGURATION = 344;
-  CONFLICT = 345;
-  CONNECTION = 346;
-  CONSTRAINT = 347;
-  CONSTRAINTS = 348;
-  CONTENT_P = 349;
-  CONTINUE_P = 350;
-  CONVERSION_P = 351;
-  COPY = 352;
-  COST = 353;
-  CREATE = 354;
-  CROSS = 355;
-  CSV = 356;
-  CUBE = 357;
-  CURRENT_P = 358;
-  CURRENT_CATALOG = 359;
-  CURRENT_DATE = 360;
-  CURRENT_ROLE = 361;
-  CURRENT_SCHEMA = 362;
-  CURRENT_TIME = 363;
-  CURRENT_TIMESTAMP = 364;
-  CURRENT_USER = 365;
-  CURSOR = 366;
-  CYCLE = 367;
-  DATA_P = 368;
-  DATABASE = 369;
-  DAY_P = 370;
-  DEALLOCATE = 371;
-  DEC = 372;
-  DECIMAL_P = 373;
-  DECLARE = 374;
-  DEFAULT = 375;
-  DEFAULTS = 376;
-  DEFERRABLE = 377;
-  DEFERRED = 378;
-  DEFINER = 379;
-  DELETE_P = 380;
-  DELIMITER = 381;
-  DELIMITERS = 382;
-  DEPENDS = 383;
-  DEPTH = 384;
-  DESC = 385;
-  DETACH = 386;
-  DICTIONARY = 387;
-  DISABLE_P = 388;
-  DISCARD = 389;
-  DISTINCT = 390;
-  DO = 391;
-  DOCUMENT_P = 392;
-  DOMAIN_P = 393;
-  DOUBLE_P = 394;
-  DROP = 395;
-  EACH = 396;
-  ELSE = 397;
-  ENABLE_P = 398;
-  ENCODING = 399;
-  ENCRYPTED = 400;
-  END_P = 401;
-  ENUM_P = 402;
-  ESCAPE = 403;
-  EVENT = 404;
-  EXCEPT = 405;
-  EXCLUDE = 406;
-  EXCLUDING = 407;
-  EXCLUSIVE = 408;
-  EXECUTE = 409;
-  EXISTS = 410;
-  EXPLAIN = 411;
-  EXPRESSION = 412;
-  EXTENSION = 413;
-  EXTERNAL = 414;
-  EXTRACT = 415;
-  FALSE_P = 416;
-  FAMILY = 417;
-  FETCH = 418;
-  FILTER = 419;
-  FINALIZE = 420;
-  FIRST_P = 421;
-  FLOAT_P = 422;
-  FOLLOWING = 423;
-  FOR = 424;
-  FORCE = 425;
-  FOREIGN = 426;
-  FORWARD = 427;
-  FREEZE = 428;
-  FROM = 429;
-  FULL = 430;
-  FUNCTION = 431;
-  FUNCTIONS = 432;
-  GENERATED = 433;
-  GLOBAL = 434;
-  GRANT = 435;
-  GRANTED = 436;
-  GREATEST = 437;
-  GROUP_P = 438;
-  GROUPING = 439;
-  GROUPS = 440;
-  HANDLER = 441;
-  HAVING = 442;
-  HEADER_P = 443;
-  HOLD = 444;
-  HOUR_P = 445;
-  IDENTITY_P = 446;
-  IF_P = 447;
-  ILIKE = 448;
-  IMMEDIATE = 449;
-  IMMUTABLE = 450;
-  IMPLICIT_P = 451;
-  IMPORT_P = 452;
-  IN_P = 453;
-  INCLUDE = 454;
-  INCLUDING = 455;
-  INCREMENT = 456;
-  INDEX = 457;
-  INDEXES = 458;
-  INHERIT = 459;
-  INHERITS = 460;
-  INITIALLY = 461;
-  INLINE_P = 462;
-  INNER_P = 463;
-  INOUT = 464;
-  INPUT_P = 465;
-  INSENSITIVE = 466;
-  INSERT = 467;
-  INSTEAD = 468;
-  INT_P = 469;
-  INTEGER = 470;
-  INTERSECT = 471;
-  INTERVAL = 472;
-  INTO = 473;
-  INVOKER = 474;
-  IS = 475;
-  ISNULL = 476;
-  ISOLATION = 477;
-  JOIN = 478;
-  KEY = 479;
-  LABEL = 480;
-  LANGUAGE = 481;
-  LARGE_P = 482;
-  LAST_P = 483;
-  LATERAL_P = 484;
-  LEADING = 485;
-  LEAKPROOF = 486;
-  LEAST = 487;
-  LEFT = 488;
-  LEVEL = 489;
-  LIKE = 490;
-  LIMIT = 491;
-  LISTEN = 492;
-  LOAD = 493;
-  LOCAL = 494;
-  LOCALTIME = 495;
-  LOCALTIMESTAMP = 496;
-  LOCATION = 497;
-  LOCK_P = 498;
-  LOCKED = 499;
-  LOGGED = 500;
-  MAPPING = 501;
-  MATCH = 502;
-  MATCHED = 503;
-  MATERIALIZED = 504;
-  MAXVALUE = 505;
-  MERGE = 506;
-  METHOD = 507;
-  MINUTE_P = 508;
-  MINVALUE = 509;
-  MODE = 510;
-  MONTH_P = 511;
-  MOVE = 512;
-  NAME_P = 513;
-  NAMES = 514;
-  NATIONAL = 515;
-  NATURAL = 516;
-  NCHAR = 517;
-  NEW = 518;
-  NEXT = 519;
-  NFC = 520;
-  NFD = 521;
-  NFKC = 522;
-  NFKD = 523;
-  NO = 524;
-  NONE = 525;
-  NORMALIZE = 526;
-  NORMALIZED = 527;
-  NOT = 528;
-  NOTHING = 529;
-  NOTIFY = 530;
-  NOTNULL = 531;
-  NOWAIT = 532;
-  NULL_P = 533;
-  NULLIF = 534;
-  NULLS_P = 535;
-  NUMERIC = 536;
-  OBJECT_P = 537;
-  OF = 538;
-  OFF = 539;
-  OFFSET = 540;
-  OIDS = 541;
-  OLD = 542;
-  ON = 543;
-  ONLY = 544;
-  OPERATOR = 545;
-  OPTION = 546;
-  OPTIONS = 547;
-  OR = 548;
-  ORDER = 549;
-  ORDINALITY = 550;
-  OTHERS = 551;
-  OUT_P = 552;
-  OUTER_P = 553;
-  OVER = 554;
-  OVERLAPS = 555;
-  OVERLAY = 556;
-  OVERRIDING = 557;
-  OWNED = 558;
-  OWNER = 559;
-  PARALLEL = 560;
-  PARAMETER = 561;
-  PARSER = 562;
-  PARTIAL = 563;
-  PARTITION = 564;
-  PASSING = 565;
-  PASSWORD = 566;
-  PLACING = 567;
-  PLANS = 568;
-  POLICY = 569;
-  POSITION = 570;
-  PRECEDING = 571;
-  PRECISION = 572;
-  PRESERVE = 573;
-  PREPARE = 574;
-  PREPARED = 575;
-  PRIMARY = 576;
-  PRIOR = 577;
-  PRIVILEGES = 578;
-  PROCEDURAL = 579;
-  PROCEDURE = 580;
-  PROCEDURES = 581;
-  PROGRAM = 582;
-  PUBLICATION = 583;
-  QUOTE = 584;
-  RANGE = 585;
-  READ = 586;
-  REAL = 587;
-  REASSIGN = 588;
-  RECHECK = 589;
-  RECURSIVE = 590;
-  REF_P = 591;
-  REFERENCES = 592;
-  REFERENCING = 593;
-  REFRESH = 594;
-  REINDEX = 595;
-  RELATIVE_P = 596;
-  RELEASE = 597;
-  RENAME = 598;
-  REPEATABLE = 599;
-  REPLACE = 600;
-  REPLICA = 601;
-  RESET = 602;
-  RESTART = 603;
-  RESTRICT = 604;
-  RETURN = 605;
-  RETURNING = 606;
-  RETURNS = 607;
-  REVOKE = 608;
-  RIGHT = 609;
-  ROLE = 610;
-  ROLLBACK = 611;
-  ROLLUP = 612;
-  ROUTINE = 613;
-  ROUTINES = 614;
-  ROW = 615;
-  ROWS = 616;
-  RULE = 617;
-  SAVEPOINT = 618;
-  SCHEMA = 619;
-  SCHEMAS = 620;
-  SCROLL = 621;
-  SEARCH = 622;
-  SECOND_P = 623;
-  SECURITY = 624;
-  SELECT = 625;
-  SEQUENCE = 626;
-  SEQUENCES = 627;
-  SERIALIZABLE = 628;
-  SERVER = 629;
-  SESSION = 630;
-  SESSION_USER = 631;
-  SET = 632;
-  SETS = 633;
-  SETOF = 634;
-  SHARE = 635;
-  SHOW = 636;
-  SIMILAR = 637;
-  SIMPLE = 638;
-  SKIP = 639;
-  SMALLINT = 640;
-  SNAPSHOT = 641;
-  SOME = 642;
-  SQL_P = 643;
-  STABLE = 644;
-  STANDALONE_P = 645;
-  START = 646;
-  STATEMENT = 647;
-  STATISTICS = 648;
-  STDIN = 649;
-  STDOUT = 650;
-  STORAGE = 651;
-  STORED = 652;
-  STRICT_P = 653;
-  STRIP_P = 654;
-  SUBSCRIPTION = 655;
-  SUBSTRING = 656;
-  SUPPORT = 657;
-  SYMMETRIC = 658;
-  SYSID = 659;
-  SYSTEM_P = 660;
-  TABLE = 661;
-  TABLES = 662;
-  TABLESAMPLE = 663;
-  TABLESPACE = 664;
-  TEMP = 665;
-  TEMPLATE = 666;
-  TEMPORARY = 667;
-  TEXT_P = 668;
-  THEN = 669;
-  TIES = 670;
-  TIME = 671;
-  TIMESTAMP = 672;
-  TO = 673;
-  TRAILING = 674;
-  TRANSACTION = 675;
-  TRANSFORM = 676;
-  TREAT = 677;
-  TRIGGER = 678;
-  TRIM = 679;
-  TRUE_P = 680;
-  TRUNCATE = 681;
-  TRUSTED = 682;
-  TYPE_P = 683;
-  TYPES_P = 684;
-  UESCAPE = 685;
-  UNBOUNDED = 686;
-  UNCOMMITTED = 687;
-  UNENCRYPTED = 688;
-  UNION = 689;
-  UNIQUE = 690;
-  UNKNOWN = 691;
-  UNLISTEN = 692;
-  UNLOGGED = 693;
-  UNTIL = 694;
-  UPDATE = 695;
-  USER = 696;
-  USING = 697;
-  VACUUM = 698;
-  VALID = 699;
-  VALIDATE = 700;
-  VALIDATOR = 701;
-  VALUE_P = 702;
-  VALUES = 703;
-  VARCHAR = 704;
-  VARIADIC = 705;
-  VARYING = 706;
-  VERBOSE = 707;
-  VERSION_P = 708;
-  VIEW = 709;
-  VIEWS = 710;
-  VOLATILE = 711;
-  WHEN = 712;
-  WHERE = 713;
-  WHITESPACE_P = 714;
-  WINDOW = 715;
-  WITH = 716;
-  WITHIN = 717;
-  WITHOUT = 718;
-  WORK = 719;
-  WRAPPER = 720;
-  WRITE = 721;
-  XML_P = 722;
-  XMLATTRIBUTES = 723;
-  XMLCONCAT = 724;
-  XMLELEMENT = 725;
-  XMLEXISTS = 726;
-  XMLFOREST = 727;
-  XMLNAMESPACES = 728;
-  XMLPARSE = 729;
-  XMLPI = 730;
-  XMLROOT = 731;
-  XMLSERIALIZE = 732;
-  XMLTABLE = 733;
-  YEAR_P = 734;
-  YES_P = 735;
-  ZONE = 736;
-  NOT_LA = 737;
-  NULLS_LA = 738;
-  WITH_LA = 739;
-  MODE_TYPE_NAME = 740;
-  MODE_PLPGSQL_EXPR = 741;
-  MODE_PLPGSQL_ASSIGN1 = 742;
-  MODE_PLPGSQL_ASSIGN2 = 743;
-  MODE_PLPGSQL_ASSIGN3 = 744;
-  UMINUS = 745;
-}
diff --git a/crates/sourcegen/Cargo.toml b/crates/sourcegen/Cargo.toml
deleted file mode 100644
index e5cfb4a5..00000000
--- a/crates/sourcegen/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "sourcegen"
-version = "0.0.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-textwrap = "0.16.0"
-rustfmt-wrapper = "0.2.0"
diff --git a/crates/sourcegen/src/attribute.rs b/crates/sourcegen/src/attribute.rs
deleted file mode 100644
index 0a05a6a8..00000000
--- a/crates/sourcegen/src/attribute.rs
+++ /dev/null
@@ -1,76 +0,0 @@
-use crate::builder::Builder;
-
-#[derive(Debug, Clone)]
-pub struct AttributeArgument {
-    name: String,
-    value: Option<String>,
-}
-
-/// A builder for a rust Attribute
-#[derive(Debug, Clone)]
-pub struct Attribute {
-    name: String,
-    arguments: Vec<AttributeArgument>,
-}
-
-impl Builder for Attribute {
-    fn finish(&mut self) -> String {
-        let mut result = String::new();
-        result.push_str("#[");
-        result.push_str(&self.name);
-        if !self.arguments.is_empty() {
-            result.push_str("(");
-            result.push_str(
-                &self
-                    .arguments
-                    .iter()
-                    .map(|arg| {
-                        let mut result = String::new();
-                        result.push_str(&arg.name);
-                        if let Some(value) = &arg.value {
-                            result.push_str(" = ");
-                            result.push_str(&value);
-                        }
-                        result
-                    })
-                    .collect::<Vec<String>>()
-                    .join(", "),
-            );
-            result.push_str(")");
-        }
-        result.push_str("]\n");
-        result
-    }
-}
-
-impl Attribute {
-    pub fn new(name: String) -> Self {
-        Attribute {
-            name,
-            arguments: Vec::new(),
-        }
-    }
-
-    pub fn with_argument(&mut self, name: String, value: Option<String>) -> &mut Self {
-        self.arguments.push(AttributeArgument { name, value });
-        self
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::{attribute::Attribute, builder::Builder};
-
-    #[test]
-    fn test_attribute() {
-        assert_eq!(
-            Attribute::new("derive".into())
-                .with_argument("Debug".to_string(), None)
-                .with_argument("Copy".to_string(), Some("value".to_string()))
-                .finish(),
-            "#[derive(Debug, Copy = value)]\n"
-        )
-    }
-}
diff --git a/crates/sourcegen/src/builder.rs b/crates/sourcegen/src/builder.rs
deleted file mode 100644
index 6ec942b9..00000000
--- a/crates/sourcegen/src/builder.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-pub trait Builder {
-    fn with<F>(&mut self, mut f: F) -> &mut Self
-    where
-        F: FnMut(&mut Self) -> &mut Self,
-    {
-        f(self)
-    }
-
-    fn finish(&mut self) -> String;
-}
diff --git a/crates/sourcegen/src/comment.rs b/crates/sourcegen/src/comment.rs
deleted file mode 100644
index b9dff806..00000000
--- a/crates/sourcegen/src/comment.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-use textwrap::wrap;
-
-use crate::builder::Builder;
-
-#[derive(Debug, Clone)]
-pub struct Comment {
-    prefix: String,
-    parts: Vec<String>,
-}
-
-impl Builder for Comment {
-    fn finish(&mut self) -> String {
-        wrap(
-            self.parts.join('\n'.to_string().as_str()).as_str(),
-            80 - self.prefix.len(),
-        )
-        .iter()
-        .map(|line| format!("{} {}", self.prefix, line))
-        .collect::<Vec<String>>()
-        .join("\n")
-    }
-}
-
-/// A builder for a rust function
-impl Comment {
-    pub fn new(prefix: String) -> Self {
-        Comment {
-            prefix,
-            parts: Vec::new(),
-        }
-    }
-
-    pub fn with_text(&mut self, text: String) -> &mut Self {
-        self.parts.push(text);
-        self
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::{builder::Builder, comment::Comment};
-
-    #[test]
-    fn test_comment() {
-        assert_eq!(
-            Comment::new("//".into())
-                .with_text(
-                    "one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three"
-                        .to_string()
-                )
-                .with_text("three two one".to_string())
-                .finish(),
-            "// one two three one two three one two three one two three one two three one two\n// three one two three one two three one two three one two three one two three\n// one two three one two three one two three one two three\n// three two one"
-        )
-    }
-}
diff --git a/crates/sourcegen/src/enum_.rs b/crates/sourcegen/src/enum_.rs
deleted file mode 100644
index 5f150cf4..00000000
--- a/crates/sourcegen/src/enum_.rs
+++ /dev/null
@@ -1,100 +0,0 @@
-use crate::{builder::Builder, Comment};
-
-#[derive(Debug, Clone)]
-pub struct EnumValue {
-    name: String,
-    value: Option<String>,
-}
-
-/// Generate a rust enum
-#[derive(Debug, Clone)]
-pub struct Enum {
-    name: String,
-    comments: Comment,
-    public: bool,
-    values: Vec<EnumValue>,
-    attributes: Vec<String>,
-}
-
-impl Builder for Enum {
-    fn finish(&mut self) -> String {
-        let mut result = String::new();
-        result.push_str(self.comments.finish().as_str());
-        result.push_str("\n");
-        for attribute in &self.attributes {
-            result.push_str(&attribute);
-        }
-        if self.public {
-            result.push_str("pub ");
-        }
-        result.push_str("enum ");
-        result.push_str(&self.name);
-        result.push_str(" {\n");
-        for value in &self.values {
-            result.push_str("    ");
-            result.push_str(&value.name);
-            if let Some(value) = &value.value {
-                result.push_str(" = ");
-                result.push_str(&value);
-            }
-            result.push_str(",\n");
-        }
-        result.push_str("}\n");
-        result
-    }
-}
-
-impl Enum {
-    pub fn new(name: String) -> Self {
-        Enum {
-            name,
-            comments: Comment::new("///".to_string()),
-            public: false,
-            values: Vec::new(),
-            attributes: Vec::new(),
-        }
-    }
-
-    pub fn public(&mut self) -> &mut Self {
-        self.public = true;
-        self
-    }
-
-    pub fn with_comment(&mut self, comment: String) -> &mut Self {
-        self.comments.with_text(comment);
-        self
-    }
-
-    pub fn with_value(&mut self, name: String, value: Option<String>) -> &mut Self {
-        if self.values.iter().find(|v| v.name == name).is_some() {
-            return self;
-        }
-        self.values.push(EnumValue { name, value });
-        self
-    }
-
-    pub fn with_attribute(&mut self, attribute: String) -> &mut Self {
-        self.attributes.push(attribute);
-        self
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::{builder::Builder, enum_::Enum};
-
-    #[test]
-    fn test_enum() {
-        assert_eq!(
-            Enum::new("my_enum".into())
-                .public()
-                .with_value("A".into(), None)
-                .with_attribute("#[derive(Copy)]\n".to_string())
-                .with_value("".into(), Some("5".into()))
-                .finish(),
-            "#[derive(Copy)]\npub enum my_enum {\n    A,\n    B = 5,\n}\n"
-        )
-    }
-}
diff --git a/crates/sourcegen/src/function.rs b/crates/sourcegen/src/function.rs
deleted file mode 100644
index cbb7daa5..00000000
--- a/crates/sourcegen/src/function.rs
+++ /dev/null
@@ -1,101 +0,0 @@
-use crate::builder::Builder;
-
-#[derive(Debug, Clone)]
-pub struct Function {
-    body: String,
-    name: String,
-    public: bool,
-    return_type: Option<String>,
-    parameters: Vec<String>,
-    comments: Vec<String>,
-}
-
-impl Builder for Function {
-    fn finish(&mut self) -> String {
-        let mut result = String::new();
-        for comment in &self.comments {
-            result.push_str("/// ");
-            result.push_str(&comment);
-            result.push_str("\n");
-        }
-        if self.public {
-            result.push_str("pub ");
-        }
-        result.push_str("fn ");
-        result.push_str(&self.name);
-        result.push_str("(");
-        result.push_str(&self.parameters.join(", "));
-        result.push_str(")");
-        if let Some(return_type) = &self.return_type {
-            result.push_str(" -> ");
-            result.push_str(&return_type);
-        }
-        result.push_str("{\n\t");
-        result.push_str(&self.body);
-        result.push_str("\n}\n");
-        result
-    }
-}
-
-/// A builder for a rust function
-impl Function {
-    pub fn new(name: String) -> Self {
-        Function {
-            body: "".into(),
-            public: false,
-            name,
-            return_type: None,
-            parameters: Vec::new(),
-            comments: Vec::new(),
-        }
-    }
-
-    pub fn public(&mut self) -> &mut Self {
-        self.public = true;
-        self
-    }
-
-    pub fn with_return_type(&mut self, return_type: String) -> &mut Self {
-        self.return_type = Some(return_type);
-        self
-    }
-
-    pub fn with_parameter(&mut self, name: String, type_: Option<String>) -> &mut Self {
-        let mut parameter = name;
-        if let Some(type_) = type_ {
-            parameter.push_str(": ");
-            parameter.push_str(&type_);
-        }
-        self.parameters.push(parameter);
-        self
-    }
-
-    pub fn with_comment(&mut self, comment: String) -> &mut Self {
-        self.comments.push(comment);
-        self
-    }
-
-    pub fn with_body(&mut self, body: String) -> &mut Self {
-        self.body = body;
-        self
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::{builder::Builder, function::Function};
-
-    #[test]
-    fn test_function() {
-        assert_eq!(
-            Function::new("my_function".into())
-                .public()
-                .with_return_type("String".to_string())
-                .with_body("println!(\"Hello, world!\");".into())
-                .finish(),
-            "pub fn my_function() -> String{\nprintln!(\"Hello, world!\");\n}\n"
-        )
-    }
-}
diff --git a/crates/sourcegen/src/implementation.rs b/crates/sourcegen/src/implementation.rs
deleted file mode 100644
index f7a5ac21..00000000
--- a/crates/sourcegen/src/implementation.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-use crate::builder::Builder;
-
-/// Generate a rust implementation
-#[derive(Debug, Clone)]
-pub struct Implementation {
-    for_: String,
-    blocks: Vec<String>,
-}
-
-impl Builder for Implementation {
-    fn finish(&mut self) -> String {
-        let mut result = String::new();
-        result.push_str("impl ");
-        result.push_str(&self.for_);
-        result.push_str(" {\n");
-        for block in &self.blocks {
-            result.push_str(&block);
-            result.push_str("\n");
-        }
-        result.push_str("}\n");
-        result
-    }
-}
-
-impl Implementation {
-    pub fn new(for_: String) -> Self {
-        Implementation {
-            for_,
-            blocks: Vec::new(),
-        }
-    }
-
-    pub fn add_block(&mut self, block: String) -> &mut Self {
-        self.blocks.push(block);
-        self
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::{builder::Builder, implementation::Implementation};
-
-    #[test]
-    fn test_implementation() {
-        assert_eq!(
-            Implementation::new("my_enum".into())
-                .add_block("test".to_string())
-                .finish(),
-            "impl my_enum {\ntest}\n"
-        )
-    }
-}
diff --git a/crates/sourcegen/src/imports.rs b/crates/sourcegen/src/imports.rs
deleted file mode 100644
index 79666460..00000000
--- a/crates/sourcegen/src/imports.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-use crate::builder::Builder;
-
-#[derive(Debug, Clone)]
-pub struct Import {
-    path: String,
-    items: Vec<String>,
-}
-
-#[derive(Debug, Clone)]
-pub struct Imports {
-    imports: Vec<Import>,
-}
-
-impl Builder for Imports {
-    fn finish(&mut self) -> String {
-        let mut result = String::new();
-        for import in &self.imports {
-            result.push_str("use ");
-            result.push_str(&import.path);
-            if !import.items.is_empty() {
-                result.push_str("::{");
-                result.push_str(&import.items.join(", "));
-                result.push_str("}");
-            }
-            result.push_str(";\n");
-        }
-        result
-    }
-}
-
-/// A builder for a rust function
-impl Imports {
-    pub fn new() -> Self {
-        Imports {
-            imports: Vec::new(),
-        }
-    }
-
-    pub fn with_import(&mut self, path: String, items: Vec<String>) -> &mut Self {
-        self.imports.push(Import { path, items });
-        self
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::{builder::Builder, imports::Imports};
-
-    #[test]
-    fn test_imports() {
-        assert_eq!(
-            Imports::new()
-                .with_import("deeply::nested".to_string(), vec!["function".to_string()])
-                .with_import(
-                    "another::deeply::nested".to_string(),
-                    vec!["function".to_string(), "another_item".to_string()]
-                )
-                .finish(),
-            "use deeply::nested::{function};\nuse another::deeply::nested::{function, another_item};\n"
-        )
-    }
-}
diff --git a/crates/sourcegen/src/lib.rs b/crates/sourcegen/src/lib.rs
deleted file mode 100644
index f974fc41..00000000
--- a/crates/sourcegen/src/lib.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-//! Helpers to generate rust code
-//!
-//! This crate provides utilities to generate rust source code.
-
-mod attribute;
-mod builder;
-mod comment;
-mod enum_;
-mod function;
-mod implementation;
-mod imports;
-mod match_;
-mod source_file;
-mod struct_;
-
-pub use attribute::Attribute;
-pub use builder::Builder;
-pub use comment::Comment;
-pub use enum_::Enum;
-pub use function::Function;
-pub use implementation::Implementation;
-pub use imports::Imports;
-pub use match_::Match;
-pub use source_file::SourceFile;
-pub use struct_::Struct;
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::builder::Builder;
-    use crate::enum_::Enum;
-    use crate::function::Function;
-    use crate::match_::Match;
-    use crate::source_file::SourceFile;
-
-    #[test]
-    fn test_sourcegen() {
-        let test_enum = Enum::new("TestEnum".into())
-            .with_value("A".into(), None)
-            .with_value("B".into(), Some("Test".into()))
-            .finish();
-
-        let test_match = Match::new("value".into())
-            .with_arm("A".into(), "1".into())
-            .with_arm("B".into(), "2".into())
-            .finish();
-
-        let test_fn = Function::new("TestEnum".into())
-            .public()
-            .with_body(test_match)
-            .finish();
-
-        assert_eq!(
-            SourceFile::new()
-                .add_block(test_enum)
-                .add_block(test_fn)
-                .finish(),
-            "enum TestEnum {\n    A,\n    B = Test,\n}\n\npub fn TestEnum(){\nmatch value {\n    A => 1,\n    B => 2,\n}\n\n}\n\n"
-        )
-    }
-}
diff --git a/crates/sourcegen/src/match_.rs b/crates/sourcegen/src/match_.rs
deleted file mode 100644
index 2d644c05..00000000
--- a/crates/sourcegen/src/match_.rs
+++ /dev/null
@@ -1,65 +0,0 @@
-use crate::builder::Builder;
-
-#[derive(Debug, Clone)]
-pub struct MatchArm {
-    pattern: String,
-    body: String,
-}
-
-#[derive(Debug, Clone)]
-pub struct Match {
-    variable: String,
-    arms: Vec<MatchArm>,
-}
-
-impl Builder for Match {
-    fn finish(&mut self) -> String {
-        let mut result = String::new();
-        result.push_str("match ");
-        result.push_str(&self.variable);
-        result.push_str(" {\n");
-        for arm in &self.arms {
-            result.push_str("    ");
-            result.push_str(&arm.pattern);
-            result.push_str(" => ");
-            result.push_str(&arm.body);
-            result.push_str(",\n");
-        }
-        result.push_str("}\n");
-        result
-    }
-}
-
-/// A builder for a Rust match expression.
-impl Match {
-    pub fn new(variable: String) -> Self {
-        Match {
-            variable,
-            arms: Vec::new(),
-        }
-    }
-
-    pub fn with_arm(&mut self, pattern: String, body: String) -> &mut Self {
-        self.arms.push(MatchArm { pattern, body });
-        self
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::{builder::Builder, match_::Match};
-
-    #[test]
-    fn test_match() {
-        assert_eq!(
-            Match::new("variable".into())
-                .with_arm("one".into(), "result one".into())
-                .with_arm("two".into(), "result two".into())
-                .with_arm("_".into(), "result catch all".into())
-                .finish(),
-            "match variable {\n    one => result one,\n    two => result two,\n    _ => result catch all,\n}\n"
-        )
-    }
-}
diff --git a/crates/sourcegen/src/source_file.rs b/crates/sourcegen/src/source_file.rs
deleted file mode 100644
index 727f4fe9..00000000
--- a/crates/sourcegen/src/source_file.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-use crate::{builder::Builder, Comment};
-use rustfmt_wrapper::rustfmt;
-
-#[derive(Debug, Clone)]
-pub struct SourceFile {
-    content: String,
-    comments: Comment,
-}
-
-impl Builder for SourceFile {
-    fn finish(&mut self) -> String {
-        let mut result = String::new();
-        result.push_str(self.comments.finish().as_str());
-        result.push_str("\n");
-        result.push_str(&self.content);
-        match rustfmt(&result) {
-            Ok(formatted) => formatted,
-            Err(e) => {
-                println!("rustfmt error: {:?}", e);
-                result
-            }
-        }
-    }
-}
-
-/// Generate a rust source file
-impl SourceFile {
-    pub fn new() -> Self {
-        SourceFile {
-            content: "".to_string(),
-            comments: Comment::new("//!".to_string()),
-        }
-    }
-
-    pub fn add_comment(&mut self, comment: String) -> &mut SourceFile {
-        self.comments.with_text(comment);
-        self
-    }
-
-    pub fn add_block(&mut self, block: String) -> &mut SourceFile {
-        self.content.push_str(block.as_str());
-        self.content.push_str("\n");
-        self
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::{builder::Builder, source_file::SourceFile};
-
-    #[test]
-    fn test_source_file() {
-        assert_eq!(
-            SourceFile::new()
-                .add_block("block 1".into())
-                .add_block("block 2".into())
-                .finish(),
-            "block 1\nblock 2\n"
-        )
-    }
-}
diff --git a/crates/sourcegen/src/struct_.rs b/crates/sourcegen/src/struct_.rs
deleted file mode 100644
index 7a9700f6..00000000
--- a/crates/sourcegen/src/struct_.rs
+++ /dev/null
@@ -1,100 +0,0 @@
-use crate::builder::Builder;
-
-#[derive(Debug, Clone)]
-pub struct StructField {
-    name: String,
-    type_: String,
-    public: bool,
-}
-
-/// A builder for a rust Struct
-#[derive(Debug, Clone)]
-pub struct Struct {
-    name: String,
-    fields: Vec<StructField>,
-    public: bool,
-    attributes: Vec<String>,
-}
-
-impl Builder for Struct {
-    fn finish(&mut self) -> String {
-        let mut result = String::new();
-        result.push_str(&self.attributes.join("\n"));
-        if self.public {
-            result.push_str("pub ");
-        }
-        result.push_str("struct ");
-        result.push_str(&self.name);
-        result.push_str(" {\n");
-        result.push_str(
-            &self
-                .fields
-                .iter()
-                .map(|field| {
-                    let mut result = String::new();
-                    if field.public {
-                        result.push_str("pub ");
-                    } else {
-                        result.push_str("    ");
-                    }
-                    result.push_str(&field.name);
-                    result.push_str(": ");
-                    result.push_str(&field.type_);
-                    result.push_str(",\n");
-                    result
-                })
-                .collect::<Vec<String>>()
-                .join(""),
-        );
-        result.push_str("}\n");
-        result
-    }
-}
-
-impl Struct {
-    pub fn new(name: String) -> Self {
-        Struct {
-            name,
-            fields: Vec::new(),
-            public: false,
-            attributes: Vec::new(),
-        }
-    }
-
-    pub fn public(&mut self) -> &mut Self {
-        self.public = true;
-        self
-    }
-
-    pub fn with_field(&mut self, name: String, type_: String, public: bool) -> &mut Self {
-        self.fields.push(StructField {
-            name,
-            type_,
-            public,
-        });
-        self
-    }
-
-    pub fn with_attribute(&mut self, attribute: String) -> &mut Self {
-        self.attributes.push(attribute);
-        self
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use crate::{attribute::Attribute, builder::Builder};
-
-    #[test]
-    fn test_struct() {
-        assert_eq!(
-            Attribute::new("derive".into())
-                .with_argument("Debug".to_string(), None)
-                .with_argument("Copy".to_string(), Some("value".to_string()))
-                .finish(),
-            "#[derive(Debug, Copy = value)]\n"
-        )
-    }
-}

From 49ccaa0f8391a655275a2497ee2defde580a1e04 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Sat, 26 Aug 2023 16:47:42 +0200
Subject: [PATCH 14/23] fix: codegen

---
 crates/codegen/src/syntax_kind.rs | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/crates/codegen/src/syntax_kind.rs b/crates/codegen/src/syntax_kind.rs
index a01fb28a..3ae6738b 100644
--- a/crates/codegen/src/syntax_kind.rs
+++ b/crates/codegen/src/syntax_kind.rs
@@ -5,10 +5,7 @@ use proc_macro2::{Ident, Literal};
 use quote::{format_ident, quote};
 
 pub fn syntax_kind_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
-    // let parser = ProtoParser::new(
-    //     "/Users/raminder.singh/src/rust/postgres_lsp/crates/parser/proto/source.proto",
-    // );
-    let parser = ProtoParser::new("./crates/parser/proto/source.proto");
+    let parser = ProtoParser::new("./libpg_query/protobuf/pg_query.proto");
     let proto_file = parser.parse();
 
     let mut current_enum_names: HashSet<&str> = HashSet::new();

From 1fa340bcfd0b5372df5cd63832604c2d75ce9c8a Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Wed, 30 Aug 2023 10:04:54 +0200
Subject: [PATCH 15/23] refactor: migrate get_location to codegen (not working
 yet)

---
 SomeFile.txt                                  | 3137 +++++++++++++++++
 crates/codegen/src/get_children.rs            |  133 +
 crates/codegen/src/get_location.rs            |   72 +
 crates/codegen/src/lib.rs                     |   14 +
 crates/parser/src/get_location_codegen.rs     |    3 +
 crates/parser/src/lib.rs                      |    1 +
 crates/parser/src/pg_query_utils_generated.rs |  256 +-
 expanded.rs                                   | 3121 ++++++++++++++++
 8 files changed, 6482 insertions(+), 255 deletions(-)
 create mode 100644 SomeFile.txt
 create mode 100644 crates/codegen/src/get_children.rs
 create mode 100644 crates/codegen/src/get_location.rs
 create mode 100644 crates/parser/src/get_location_codegen.rs
 create mode 100644 expanded.rs

diff --git a/SomeFile.txt b/SomeFile.txt
new file mode 100644
index 00000000..5097dbc5
--- /dev/null
+++ b/SomeFile.txt
@@ -0,0 +1,3137 @@
+    Checking parser v0.0.0 (/Users/psteinroe/Developer/postgres_lsp/crates/parser)
+error: an inner attribute is not permitted in this context
+ --> crates/parser/src/get_location_codegen.rs:3:1
+  |
+3 | get_location!();
+  | ^^^^^^^^^^^^^^^ the inner attribute doesn't annotate this function
+  |
+  = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
+  = note: this error originates in the macro `get_location` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: to annotate the function, change the attribute from inner to outer style
+  |
+3 - get_location!();
+3 + gt_location!();
+  |
+error: could not compile `parser` (lib) due to previous error
+
+mod syntax_kind_codegen {
+    use codegen::syntax_kind;
+    use cstree::Syntax;
+    use pg_query::{protobuf::ScanToken, NodeEnum, NodeRef};
+    /// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres
+    /// sql dialect, and a few custom ones that are not parsed by pg_query.rs, such
+    /// as `Whitespace`.
+    #[repr(u32)]
+    pub enum SyntaxKind {
+        SourceFile,
+        Comment,
+        Whitespace,
+        Newline,
+        Tab,
+        Stmt,
+        Alias,
+        RangeVar,
+        TableFunc,
+        Var,
+        Param,
+        Aggref,
+        GroupingFunc,
+        WindowFunc,
+        SubscriptingRef,
+        FuncExpr,
+        NamedArgExpr,
+        OpExpr,
+        DistinctExpr,
+        NullIfExpr,
+        ScalarArrayOpExpr,
+        BoolExpr,
+        SubLink,
+        SubPlan,
+        AlternativeSubPlan,
+        FieldSelect,
+        FieldStore,
+        RelabelType,
+        CoerceViaIo,
+        ArrayCoerceExpr,
+        ConvertRowtypeExpr,
+        CollateExpr,
+        CaseExpr,
+        CaseWhen,
+        CaseTestExpr,
+        ArrayExpr,
+        RowExpr,
+        RowCompareExpr,
+        CoalesceExpr,
+        MinMaxExpr,
+        SqlvalueFunction,
+        XmlExpr,
+        NullTest,
+        BooleanTest,
+        CoerceToDomain,
+        CoerceToDomainValue,
+        SetToDefault,
+        CurrentOfExpr,
+        NextValueExpr,
+        InferenceElem,
+        TargetEntry,
+        RangeTblRef,
+        JoinExpr,
+        FromExpr,
+        OnConflictExpr,
+        IntoClause,
+        MergeAction,
+        RawStmt,
+        Query,
+        InsertStmt,
+        DeleteStmt,
+        UpdateStmt,
+        MergeStmt,
+        SelectStmt,
+        ReturnStmt,
+        PlassignStmt,
+        AlterTableStmt,
+        AlterTableCmd,
+        AlterDomainStmt,
+        SetOperationStmt,
+        GrantStmt,
+        GrantRoleStmt,
+        AlterDefaultPrivilegesStmt,
+        ClosePortalStmt,
+        ClusterStmt,
+        CopyStmt,
+        CreateStmt,
+        DefineStmt,
+        DropStmt,
+        TruncateStmt,
+        CommentStmt,
+        FetchStmt,
+        IndexStmt,
+        CreateFunctionStmt,
+        AlterFunctionStmt,
+        DoStmt,
+        RenameStmt,
+        RuleStmt,
+        NotifyStmt,
+        ListenStmt,
+        UnlistenStmt,
+        TransactionStmt,
+        ViewStmt,
+        LoadStmt,
+        CreateDomainStmt,
+        CreatedbStmt,
+        DropdbStmt,
+        VacuumStmt,
+        ExplainStmt,
+        CreateTableAsStmt,
+        CreateSeqStmt,
+        AlterSeqStmt,
+        VariableSetStmt,
+        VariableShowStmt,
+        DiscardStmt,
+        CreateTrigStmt,
+        CreatePlangStmt,
+        CreateRoleStmt,
+        AlterRoleStmt,
+        DropRoleStmt,
+        LockStmt,
+        ConstraintsSetStmt,
+        ReindexStmt,
+        CheckPointStmt,
+        CreateSchemaStmt,
+        AlterDatabaseStmt,
+        AlterDatabaseRefreshCollStmt,
+        AlterDatabaseSetStmt,
+        AlterRoleSetStmt,
+        CreateConversionStmt,
+        CreateCastStmt,
+        CreateOpClassStmt,
+        CreateOpFamilyStmt,
+        AlterOpFamilyStmt,
+        PrepareStmt,
+        ExecuteStmt,
+        DeallocateStmt,
+        DeclareCursorStmt,
+        CreateTableSpaceStmt,
+        DropTableSpaceStmt,
+        AlterObjectDependsStmt,
+        AlterObjectSchemaStmt,
+        AlterOwnerStmt,
+        AlterOperatorStmt,
+        AlterTypeStmt,
+        DropOwnedStmt,
+        ReassignOwnedStmt,
+        CompositeTypeStmt,
+        CreateEnumStmt,
+        CreateRangeStmt,
+        AlterEnumStmt,
+        AlterTsdictionaryStmt,
+        AlterTsconfigurationStmt,
+        CreateFdwStmt,
+        AlterFdwStmt,
+        CreateForeignServerStmt,
+        AlterForeignServerStmt,
+        CreateUserMappingStmt,
+        AlterUserMappingStmt,
+        DropUserMappingStmt,
+        AlterTableSpaceOptionsStmt,
+        AlterTableMoveAllStmt,
+        SecLabelStmt,
+        CreateForeignTableStmt,
+        ImportForeignSchemaStmt,
+        CreateExtensionStmt,
+        AlterExtensionStmt,
+        AlterExtensionContentsStmt,
+        CreateEventTrigStmt,
+        AlterEventTrigStmt,
+        RefreshMatViewStmt,
+        ReplicaIdentityStmt,
+        AlterSystemStmt,
+        CreatePolicyStmt,
+        AlterPolicyStmt,
+        CreateTransformStmt,
+        CreateAmStmt,
+        CreatePublicationStmt,
+        AlterPublicationStmt,
+        CreateSubscriptionStmt,
+        AlterSubscriptionStmt,
+        DropSubscriptionStmt,
+        CreateStatsStmt,
+        AlterCollationStmt,
+        CallStmt,
+        AlterStatsStmt,
+        AExpr,
+        ColumnRef,
+        ParamRef,
+        FuncCall,
+        AStar,
+        AIndices,
+        AIndirection,
+        AArrayExpr,
+        ResTarget,
+        MultiAssignRef,
+        TypeCast,
+        CollateClause,
+        SortBy,
+        WindowDef,
+        RangeSubselect,
+        RangeFunction,
+        RangeTableSample,
+        RangeTableFunc,
+        RangeTableFuncCol,
+        TypeName,
+        ColumnDef,
+        IndexElem,
+        StatsElem,
+        Constraint,
+        DefElem,
+        RangeTblEntry,
+        RangeTblFunction,
+        TableSampleClause,
+        WithCheckOption,
+        SortGroupClause,
+        GroupingSet,
+        WindowClause,
+        ObjectWithArgs,
+        AccessPriv,
+        CreateOpClassItem,
+        TableLikeClause,
+        FunctionParameter,
+        LockingClause,
+        RowMarkClause,
+        XmlSerialize,
+        WithClause,
+        InferClause,
+        OnConflictClause,
+        CtesearchClause,
+        CtecycleClause,
+        CommonTableExpr,
+        MergeWhenClause,
+        RoleSpec,
+        TriggerTransition,
+        PartitionElem,
+        PartitionSpec,
+        PartitionBoundSpec,
+        PartitionRangeDatum,
+        PartitionCmd,
+        VacuumRelation,
+        PublicationObjSpec,
+        PublicationTable,
+        InlineCodeBlock,
+        CallContext,
+        Integer,
+        Float,
+        Boolean,
+        String,
+        BitString,
+        List,
+        IntList,
+        OidList,
+        AConst,
+        Nul,
+        Ascii37,
+        Ascii40,
+        Ascii41,
+        Ascii42,
+        Ascii43,
+        Ascii44,
+        Ascii45,
+        Ascii46,
+        Ascii47,
+        Ascii58,
+        Ascii59,
+        Ascii60,
+        Ascii61,
+        Ascii62,
+        Ascii63,
+        Ascii91,
+        Ascii92,
+        Ascii93,
+        Ascii94,
+        Ident,
+        Uident,
+        Fconst,
+        Sconst,
+        Usconst,
+        Bconst,
+        Xconst,
+        Op,
+        Iconst,
+        Typecast,
+        DotDot,
+        ColonEquals,
+        EqualsGreater,
+        LessEquals,
+        GreaterEquals,
+        NotEquals,
+        SqlComment,
+        CComment,
+        AbortP,
+        AbsoluteP,
+        Access,
+        Action,
+        AddP,
+        Admin,
+        After,
+        Aggregate,
+        All,
+        Also,
+        Alter,
+        Always,
+        Analyse,
+        Analyze,
+        And,
+        Any,
+        Array,
+        As,
+        Asc,
+        Asensitive,
+        Assertion,
+        Assignment,
+        Asymmetric,
+        Atomic,
+        At,
+        Attach,
+        Attribute,
+        Authorization,
+        Backward,
+        Before,
+        BeginP,
+        Between,
+        Bigint,
+        Binary,
+        Bit,
+        BooleanP,
+        Both,
+        Breadth,
+        By,
+        Cache,
+        Call,
+        Called,
+        Cascade,
+        Cascaded,
+        Case,
+        Cast,
+        CatalogP,
+        Chain,
+        CharP,
+        Character,
+        Characteristics,
+        Check,
+        Checkpoint,
+        Class,
+        Close,
+        Cluster,
+        Coalesce,
+        Collate,
+        Collation,
+        Column,
+        Columns,
+        Comments,
+        Commit,
+        Committed,
+        Compression,
+        Concurrently,
+        Configuration,
+        Conflict,
+        Connection,
+        Constraints,
+        ContentP,
+        ContinueP,
+        ConversionP,
+        Copy,
+        Cost,
+        Create,
+        Cross,
+        Csv,
+        Cube,
+        CurrentP,
+        CurrentCatalog,
+        CurrentDate,
+        CurrentRole,
+        CurrentSchema,
+        CurrentTime,
+        CurrentTimestamp,
+        CurrentUser,
+        Cursor,
+        Cycle,
+        DataP,
+        Database,
+        DayP,
+        Deallocate,
+        Dec,
+        DecimalP,
+        Declare,
+        Default,
+        Defaults,
+        Deferrable,
+        Deferred,
+        Definer,
+        DeleteP,
+        Delimiter,
+        Delimiters,
+        Depends,
+        Depth,
+        Desc,
+        Detach,
+        Dictionary,
+        DisableP,
+        Discard,
+        Distinct,
+        Do,
+        DocumentP,
+        DomainP,
+        DoubleP,
+        Drop,
+        Each,
+        Else,
+        EnableP,
+        Encoding,
+        Encrypted,
+        EndP,
+        EnumP,
+        Escape,
+        Event,
+        Except,
+        Exclude,
+        Excluding,
+        Exclusive,
+        Execute,
+        Exists,
+        Explain,
+        Expression,
+        Extension,
+        External,
+        Extract,
+        FalseP,
+        Family,
+        Fetch,
+        Filter,
+        Finalize,
+        FirstP,
+        FloatP,
+        Following,
+        For,
+        Force,
+        Foreign,
+        Forward,
+        Freeze,
+        From,
+        Full,
+        Function,
+        Functions,
+        Generated,
+        Global,
+        Grant,
+        Granted,
+        Greatest,
+        GroupP,
+        Grouping,
+        Groups,
+        Handler,
+        Having,
+        HeaderP,
+        Hold,
+        HourP,
+        IdentityP,
+        IfP,
+        Ilike,
+        Immediate,
+        Immutable,
+        ImplicitP,
+        ImportP,
+        InP,
+        Include,
+        Including,
+        Increment,
+        Index,
+        Indexes,
+        Inherit,
+        Inherits,
+        Initially,
+        InlineP,
+        InnerP,
+        Inout,
+        InputP,
+        Insensitive,
+        Insert,
+        Instead,
+        IntP,
+        Intersect,
+        Interval,
+        Into,
+        Invoker,
+        Is,
+        Isnull,
+        Isolation,
+        Join,
+        Key,
+        Label,
+        Language,
+        LargeP,
+        LastP,
+        LateralP,
+        Leading,
+        Leakproof,
+        Least,
+        Left,
+        Level,
+        Like,
+        Limit,
+        Listen,
+        Load,
+        Local,
+        Localtime,
+        Localtimestamp,
+        Location,
+        LockP,
+        Locked,
+        Logged,
+        Mapping,
+        Match,
+        Matched,
+        Materialized,
+        Maxvalue,
+        Merge,
+        Method,
+        MinuteP,
+        Minvalue,
+        Mode,
+        MonthP,
+        Move,
+        NameP,
+        Names,
+        National,
+        Natural,
+        Nchar,
+        New,
+        Next,
+        Nfc,
+        Nfd,
+        Nfkc,
+        Nfkd,
+        No,
+        None,
+        Normalize,
+        Normalized,
+        Not,
+        Nothing,
+        Notify,
+        Notnull,
+        Nowait,
+        NullP,
+        Nullif,
+        NullsP,
+        Numeric,
+        ObjectP,
+        Of,
+        Off,
+        Offset,
+        Oids,
+        Old,
+        On,
+        Only,
+        Operator,
+        Option,
+        Options,
+        Or,
+        Order,
+        Ordinality,
+        Others,
+        OutP,
+        OuterP,
+        Over,
+        Overlaps,
+        Overlay,
+        Overriding,
+        Owned,
+        Owner,
+        Parallel,
+        Parameter,
+        Parser,
+        Partial,
+        Partition,
+        Passing,
+        Password,
+        Placing,
+        Plans,
+        Policy,
+        Position,
+        Preceding,
+        Precision,
+        Preserve,
+        Prepare,
+        Prepared,
+        Primary,
+        Prior,
+        Privileges,
+        Procedural,
+        Procedure,
+        Procedures,
+        Program,
+        Publication,
+        Quote,
+        Range,
+        Read,
+        Real,
+        Reassign,
+        Recheck,
+        Recursive,
+        RefP,
+        References,
+        Referencing,
+        Refresh,
+        Reindex,
+        RelativeP,
+        Release,
+        Rename,
+        Repeatable,
+        Replace,
+        Replica,
+        Reset,
+        Restart,
+        Restrict,
+        Return,
+        Returning,
+        Returns,
+        Revoke,
+        Right,
+        Role,
+        Rollback,
+        Rollup,
+        Routine,
+        Routines,
+        Row,
+        Rows,
+        Rule,
+        Savepoint,
+        Schema,
+        Schemas,
+        Scroll,
+        Search,
+        SecondP,
+        Security,
+        Select,
+        Sequence,
+        Sequences,
+        Serializable,
+        Server,
+        Session,
+        SessionUser,
+        Set,
+        Sets,
+        Setof,
+        Share,
+        Show,
+        Similar,
+        Simple,
+        Skip,
+        Smallint,
+        Snapshot,
+        Some,
+        SqlP,
+        Stable,
+        StandaloneP,
+        Start,
+        Statement,
+        Statistics,
+        Stdin,
+        Stdout,
+        Storage,
+        Stored,
+        StrictP,
+        StripP,
+        Subscription,
+        Substring,
+        Support,
+        Symmetric,
+        Sysid,
+        SystemP,
+        Table,
+        Tables,
+        Tablesample,
+        Tablespace,
+        Temp,
+        Template,
+        Temporary,
+        TextP,
+        Then,
+        Ties,
+        Time,
+        Timestamp,
+        To,
+        Trailing,
+        Transaction,
+        Transform,
+        Treat,
+        Trigger,
+        Trim,
+        TrueP,
+        Truncate,
+        Trusted,
+        TypeP,
+        TypesP,
+        Uescape,
+        Unbounded,
+        Uncommitted,
+        Unencrypted,
+        Union,
+        Unique,
+        Unknown,
+        Unlisten,
+        Unlogged,
+        Until,
+        Update,
+        User,
+        Using,
+        Vacuum,
+        Valid,
+        Validate,
+        Validator,
+        ValueP,
+        Values,
+        Varchar,
+        Variadic,
+        Varying,
+        Verbose,
+        VersionP,
+        View,
+        Views,
+        Volatile,
+        When,
+        Where,
+        WhitespaceP,
+        Window,
+        With,
+        Within,
+        Without,
+        Work,
+        Wrapper,
+        Write,
+        XmlP,
+        Xmlattributes,
+        Xmlconcat,
+        Xmlelement,
+        Xmlexists,
+        Xmlforest,
+        Xmlnamespaces,
+        Xmlparse,
+        Xmlpi,
+        Xmlroot,
+        Xmlserialize,
+        Xmltable,
+        YearP,
+        YesP,
+        Zone,
+        NotLa,
+        NullsLa,
+        WithLa,
+        ModeTypeName,
+        ModePlpgsqlExpr,
+        ModePlpgsqlAssign1,
+        ModePlpgsqlAssign2,
+        ModePlpgsqlAssign3,
+        Uminus,
+    }
+    #[automatically_derived]
+    impl ::core::clone::Clone for SyntaxKind {
+        #[inline]
+        fn clone(&self) -> SyntaxKind {
+            *self
+        }
+    }
+    #[automatically_derived]
+    impl ::core::marker::Copy for SyntaxKind {}
+    #[automatically_derived]
+    impl ::core::marker::StructuralPartialEq for SyntaxKind {}
+    #[automatically_derived]
+    impl ::core::cmp::PartialEq for SyntaxKind {
+        #[inline]
+        fn eq(&self, other: &SyntaxKind) -> bool {
+            let __self_tag = ::core::intrinsics::discriminant_value(self);
+            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
+            __self_tag == __arg1_tag
+        }
+    }
+    #[automatically_derived]
+    impl ::core::marker::StructuralEq for SyntaxKind {}
+    #[automatically_derived]
+    impl ::core::cmp::Eq for SyntaxKind {
+        #[inline]
+        #[doc(hidden)]
+        #[no_coverage]
+        fn assert_receiver_is_total_eq(&self) -> () {}
+    }
+    #[automatically_derived]
+    impl ::core::cmp::PartialOrd for SyntaxKind {
+        #[inline]
+        fn partial_cmp(
+            &self,
+            other: &SyntaxKind,
+        ) -> ::core::option::Option<::core::cmp::Ordering> {
+            let __self_tag = ::core::intrinsics::discriminant_value(self);
+            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
+            ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
+        }
+    }
+    #[automatically_derived]
+    impl ::core::cmp::Ord for SyntaxKind {
+        #[inline]
+        fn cmp(&self, other: &SyntaxKind) -> ::core::cmp::Ordering {
+            let __self_tag = ::core::intrinsics::discriminant_value(self);
+            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
+            ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
+        }
+    }
+    #[automatically_derived]
+    impl ::core::hash::Hash for SyntaxKind {
+        fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
+            let __self_tag = ::core::intrinsics::discriminant_value(self);
+            ::core::hash::Hash::hash(&__self_tag, state)
+        }
+    }
+    #[automatically_derived]
+    impl ::core::fmt::Debug for SyntaxKind {
+        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+            ::core::fmt::Formatter::write_str(
+                f,
+                match self {
+                    SyntaxKind::SourceFile => "SourceFile",
+                    SyntaxKind::Comment => "Comment",
+                    SyntaxKind::Whitespace => "Whitespace",
+                    SyntaxKind::Newline => "Newline",
+                    SyntaxKind::Tab => "Tab",
+                    SyntaxKind::Stmt => "Stmt",
+                    SyntaxKind::Alias => "Alias",
+                    SyntaxKind::RangeVar => "RangeVar",
+                    SyntaxKind::TableFunc => "TableFunc",
+                    SyntaxKind::Var => "Var",
+                    SyntaxKind::Param => "Param",
+                    SyntaxKind::Aggref => "Aggref",
+                    SyntaxKind::GroupingFunc => "GroupingFunc",
+                    SyntaxKind::WindowFunc => "WindowFunc",
+                    SyntaxKind::SubscriptingRef => "SubscriptingRef",
+                    SyntaxKind::FuncExpr => "FuncExpr",
+                    SyntaxKind::NamedArgExpr => "NamedArgExpr",
+                    SyntaxKind::OpExpr => "OpExpr",
+                    SyntaxKind::DistinctExpr => "DistinctExpr",
+                    SyntaxKind::NullIfExpr => "NullIfExpr",
+                    SyntaxKind::ScalarArrayOpExpr => "ScalarArrayOpExpr",
+                    SyntaxKind::BoolExpr => "BoolExpr",
+                    SyntaxKind::SubLink => "SubLink",
+                    SyntaxKind::SubPlan => "SubPlan",
+                    SyntaxKind::AlternativeSubPlan => "AlternativeSubPlan",
+                    SyntaxKind::FieldSelect => "FieldSelect",
+                    SyntaxKind::FieldStore => "FieldStore",
+                    SyntaxKind::RelabelType => "RelabelType",
+                    SyntaxKind::CoerceViaIo => "CoerceViaIo",
+                    SyntaxKind::ArrayCoerceExpr => "ArrayCoerceExpr",
+                    SyntaxKind::ConvertRowtypeExpr => "ConvertRowtypeExpr",
+                    SyntaxKind::CollateExpr => "CollateExpr",
+                    SyntaxKind::CaseExpr => "CaseExpr",
+                    SyntaxKind::CaseWhen => "CaseWhen",
+                    SyntaxKind::CaseTestExpr => "CaseTestExpr",
+                    SyntaxKind::ArrayExpr => "ArrayExpr",
+                    SyntaxKind::RowExpr => "RowExpr",
+                    SyntaxKind::RowCompareExpr => "RowCompareExpr",
+                    SyntaxKind::CoalesceExpr => "CoalesceExpr",
+                    SyntaxKind::MinMaxExpr => "MinMaxExpr",
+                    SyntaxKind::SqlvalueFunction => "SqlvalueFunction",
+                    SyntaxKind::XmlExpr => "XmlExpr",
+                    SyntaxKind::NullTest => "NullTest",
+                    SyntaxKind::BooleanTest => "BooleanTest",
+                    SyntaxKind::CoerceToDomain => "CoerceToDomain",
+                    SyntaxKind::CoerceToDomainValue => "CoerceToDomainValue",
+                    SyntaxKind::SetToDefault => "SetToDefault",
+                    SyntaxKind::CurrentOfExpr => "CurrentOfExpr",
+                    SyntaxKind::NextValueExpr => "NextValueExpr",
+                    SyntaxKind::InferenceElem => "InferenceElem",
+                    SyntaxKind::TargetEntry => "TargetEntry",
+                    SyntaxKind::RangeTblRef => "RangeTblRef",
+                    SyntaxKind::JoinExpr => "JoinExpr",
+                    SyntaxKind::FromExpr => "FromExpr",
+                    SyntaxKind::OnConflictExpr => "OnConflictExpr",
+                    SyntaxKind::IntoClause => "IntoClause",
+                    SyntaxKind::MergeAction => "MergeAction",
+                    SyntaxKind::RawStmt => "RawStmt",
+                    SyntaxKind::Query => "Query",
+                    SyntaxKind::InsertStmt => "InsertStmt",
+                    SyntaxKind::DeleteStmt => "DeleteStmt",
+                    SyntaxKind::UpdateStmt => "UpdateStmt",
+                    SyntaxKind::MergeStmt => "MergeStmt",
+                    SyntaxKind::SelectStmt => "SelectStmt",
+                    SyntaxKind::ReturnStmt => "ReturnStmt",
+                    SyntaxKind::PlassignStmt => "PlassignStmt",
+                    SyntaxKind::AlterTableStmt => "AlterTableStmt",
+                    SyntaxKind::AlterTableCmd => "AlterTableCmd",
+                    SyntaxKind::AlterDomainStmt => "AlterDomainStmt",
+                    SyntaxKind::SetOperationStmt => "SetOperationStmt",
+                    SyntaxKind::GrantStmt => "GrantStmt",
+                    SyntaxKind::GrantRoleStmt => "GrantRoleStmt",
+                    SyntaxKind::AlterDefaultPrivilegesStmt => {
+                        "AlterDefaultPrivilegesStmt"
+                    }
+                    SyntaxKind::ClosePortalStmt => "ClosePortalStmt",
+                    SyntaxKind::ClusterStmt => "ClusterStmt",
+                    SyntaxKind::CopyStmt => "CopyStmt",
+                    SyntaxKind::CreateStmt => "CreateStmt",
+                    SyntaxKind::DefineStmt => "DefineStmt",
+                    SyntaxKind::DropStmt => "DropStmt",
+                    SyntaxKind::TruncateStmt => "TruncateStmt",
+                    SyntaxKind::CommentStmt => "CommentStmt",
+                    SyntaxKind::FetchStmt => "FetchStmt",
+                    SyntaxKind::IndexStmt => "IndexStmt",
+                    SyntaxKind::CreateFunctionStmt => "CreateFunctionStmt",
+                    SyntaxKind::AlterFunctionStmt => "AlterFunctionStmt",
+                    SyntaxKind::DoStmt => "DoStmt",
+                    SyntaxKind::RenameStmt => "RenameStmt",
+                    SyntaxKind::RuleStmt => "RuleStmt",
+                    SyntaxKind::NotifyStmt => "NotifyStmt",
+                    SyntaxKind::ListenStmt => "ListenStmt",
+                    SyntaxKind::UnlistenStmt => "UnlistenStmt",
+                    SyntaxKind::TransactionStmt => "TransactionStmt",
+                    SyntaxKind::ViewStmt => "ViewStmt",
+                    SyntaxKind::LoadStmt => "LoadStmt",
+                    SyntaxKind::CreateDomainStmt => "CreateDomainStmt",
+                    SyntaxKind::CreatedbStmt => "CreatedbStmt",
+                    SyntaxKind::DropdbStmt => "DropdbStmt",
+                    SyntaxKind::VacuumStmt => "VacuumStmt",
+                    SyntaxKind::ExplainStmt => "ExplainStmt",
+                    SyntaxKind::CreateTableAsStmt => "CreateTableAsStmt",
+                    SyntaxKind::CreateSeqStmt => "CreateSeqStmt",
+                    SyntaxKind::AlterSeqStmt => "AlterSeqStmt",
+                    SyntaxKind::VariableSetStmt => "VariableSetStmt",
+                    SyntaxKind::VariableShowStmt => "VariableShowStmt",
+                    SyntaxKind::DiscardStmt => "DiscardStmt",
+                    SyntaxKind::CreateTrigStmt => "CreateTrigStmt",
+                    SyntaxKind::CreatePlangStmt => "CreatePlangStmt",
+                    SyntaxKind::CreateRoleStmt => "CreateRoleStmt",
+                    SyntaxKind::AlterRoleStmt => "AlterRoleStmt",
+                    SyntaxKind::DropRoleStmt => "DropRoleStmt",
+                    SyntaxKind::LockStmt => "LockStmt",
+                    SyntaxKind::ConstraintsSetStmt => "ConstraintsSetStmt",
+                    SyntaxKind::ReindexStmt => "ReindexStmt",
+                    SyntaxKind::CheckPointStmt => "CheckPointStmt",
+                    SyntaxKind::CreateSchemaStmt => "CreateSchemaStmt",
+                    SyntaxKind::AlterDatabaseStmt => "AlterDatabaseStmt",
+                    SyntaxKind::AlterDatabaseRefreshCollStmt => {
+                        "AlterDatabaseRefreshCollStmt"
+                    }
+                    SyntaxKind::AlterDatabaseSetStmt => "AlterDatabaseSetStmt",
+                    SyntaxKind::AlterRoleSetStmt => "AlterRoleSetStmt",
+                    SyntaxKind::CreateConversionStmt => "CreateConversionStmt",
+                    SyntaxKind::CreateCastStmt => "CreateCastStmt",
+                    SyntaxKind::CreateOpClassStmt => "CreateOpClassStmt",
+                    SyntaxKind::CreateOpFamilyStmt => "CreateOpFamilyStmt",
+                    SyntaxKind::AlterOpFamilyStmt => "AlterOpFamilyStmt",
+                    SyntaxKind::PrepareStmt => "PrepareStmt",
+                    SyntaxKind::ExecuteStmt => "ExecuteStmt",
+                    SyntaxKind::DeallocateStmt => "DeallocateStmt",
+                    SyntaxKind::DeclareCursorStmt => "DeclareCursorStmt",
+                    SyntaxKind::CreateTableSpaceStmt => "CreateTableSpaceStmt",
+                    SyntaxKind::DropTableSpaceStmt => "DropTableSpaceStmt",
+                    SyntaxKind::AlterObjectDependsStmt => "AlterObjectDependsStmt",
+                    SyntaxKind::AlterObjectSchemaStmt => "AlterObjectSchemaStmt",
+                    SyntaxKind::AlterOwnerStmt => "AlterOwnerStmt",
+                    SyntaxKind::AlterOperatorStmt => "AlterOperatorStmt",
+                    SyntaxKind::AlterTypeStmt => "AlterTypeStmt",
+                    SyntaxKind::DropOwnedStmt => "DropOwnedStmt",
+                    SyntaxKind::ReassignOwnedStmt => "ReassignOwnedStmt",
+                    SyntaxKind::CompositeTypeStmt => "CompositeTypeStmt",
+                    SyntaxKind::CreateEnumStmt => "CreateEnumStmt",
+                    SyntaxKind::CreateRangeStmt => "CreateRangeStmt",
+                    SyntaxKind::AlterEnumStmt => "AlterEnumStmt",
+                    SyntaxKind::AlterTsdictionaryStmt => "AlterTsdictionaryStmt",
+                    SyntaxKind::AlterTsconfigurationStmt => "AlterTsconfigurationStmt",
+                    SyntaxKind::CreateFdwStmt => "CreateFdwStmt",
+                    SyntaxKind::AlterFdwStmt => "AlterFdwStmt",
+                    SyntaxKind::CreateForeignServerStmt => "CreateForeignServerStmt",
+                    SyntaxKind::AlterForeignServerStmt => "AlterForeignServerStmt",
+                    SyntaxKind::CreateUserMappingStmt => "CreateUserMappingStmt",
+                    SyntaxKind::AlterUserMappingStmt => "AlterUserMappingStmt",
+                    SyntaxKind::DropUserMappingStmt => "DropUserMappingStmt",
+                    SyntaxKind::AlterTableSpaceOptionsStmt => {
+                        "AlterTableSpaceOptionsStmt"
+                    }
+                    SyntaxKind::AlterTableMoveAllStmt => "AlterTableMoveAllStmt",
+                    SyntaxKind::SecLabelStmt => "SecLabelStmt",
+                    SyntaxKind::CreateForeignTableStmt => "CreateForeignTableStmt",
+                    SyntaxKind::ImportForeignSchemaStmt => "ImportForeignSchemaStmt",
+                    SyntaxKind::CreateExtensionStmt => "CreateExtensionStmt",
+                    SyntaxKind::AlterExtensionStmt => "AlterExtensionStmt",
+                    SyntaxKind::AlterExtensionContentsStmt => {
+                        "AlterExtensionContentsStmt"
+                    }
+                    SyntaxKind::CreateEventTrigStmt => "CreateEventTrigStmt",
+                    SyntaxKind::AlterEventTrigStmt => "AlterEventTrigStmt",
+                    SyntaxKind::RefreshMatViewStmt => "RefreshMatViewStmt",
+                    SyntaxKind::ReplicaIdentityStmt => "ReplicaIdentityStmt",
+                    SyntaxKind::AlterSystemStmt => "AlterSystemStmt",
+                    SyntaxKind::CreatePolicyStmt => "CreatePolicyStmt",
+                    SyntaxKind::AlterPolicyStmt => "AlterPolicyStmt",
+                    SyntaxKind::CreateTransformStmt => "CreateTransformStmt",
+                    SyntaxKind::CreateAmStmt => "CreateAmStmt",
+                    SyntaxKind::CreatePublicationStmt => "CreatePublicationStmt",
+                    SyntaxKind::AlterPublicationStmt => "AlterPublicationStmt",
+                    SyntaxKind::CreateSubscriptionStmt => "CreateSubscriptionStmt",
+                    SyntaxKind::AlterSubscriptionStmt => "AlterSubscriptionStmt",
+                    SyntaxKind::DropSubscriptionStmt => "DropSubscriptionStmt",
+                    SyntaxKind::CreateStatsStmt => "CreateStatsStmt",
+                    SyntaxKind::AlterCollationStmt => "AlterCollationStmt",
+                    SyntaxKind::CallStmt => "CallStmt",
+                    SyntaxKind::AlterStatsStmt => "AlterStatsStmt",
+                    SyntaxKind::AExpr => "AExpr",
+                    SyntaxKind::ColumnRef => "ColumnRef",
+                    SyntaxKind::ParamRef => "ParamRef",
+                    SyntaxKind::FuncCall => "FuncCall",
+                    SyntaxKind::AStar => "AStar",
+                    SyntaxKind::AIndices => "AIndices",
+                    SyntaxKind::AIndirection => "AIndirection",
+                    SyntaxKind::AArrayExpr => "AArrayExpr",
+                    SyntaxKind::ResTarget => "ResTarget",
+                    SyntaxKind::MultiAssignRef => "MultiAssignRef",
+                    SyntaxKind::TypeCast => "TypeCast",
+                    SyntaxKind::CollateClause => "CollateClause",
+                    SyntaxKind::SortBy => "SortBy",
+                    SyntaxKind::WindowDef => "WindowDef",
+                    SyntaxKind::RangeSubselect => "RangeSubselect",
+                    SyntaxKind::RangeFunction => "RangeFunction",
+                    SyntaxKind::RangeTableSample => "RangeTableSample",
+                    SyntaxKind::RangeTableFunc => "RangeTableFunc",
+                    SyntaxKind::RangeTableFuncCol => "RangeTableFuncCol",
+                    SyntaxKind::TypeName => "TypeName",
+                    SyntaxKind::ColumnDef => "ColumnDef",
+                    SyntaxKind::IndexElem => "IndexElem",
+                    SyntaxKind::StatsElem => "StatsElem",
+                    SyntaxKind::Constraint => "Constraint",
+                    SyntaxKind::DefElem => "DefElem",
+                    SyntaxKind::RangeTblEntry => "RangeTblEntry",
+                    SyntaxKind::RangeTblFunction => "RangeTblFunction",
+                    SyntaxKind::TableSampleClause => "TableSampleClause",
+                    SyntaxKind::WithCheckOption => "WithCheckOption",
+                    SyntaxKind::SortGroupClause => "SortGroupClause",
+                    SyntaxKind::GroupingSet => "GroupingSet",
+                    SyntaxKind::WindowClause => "WindowClause",
+                    SyntaxKind::ObjectWithArgs => "ObjectWithArgs",
+                    SyntaxKind::AccessPriv => "AccessPriv",
+                    SyntaxKind::CreateOpClassItem => "CreateOpClassItem",
+                    SyntaxKind::TableLikeClause => "TableLikeClause",
+                    SyntaxKind::FunctionParameter => "FunctionParameter",
+                    SyntaxKind::LockingClause => "LockingClause",
+                    SyntaxKind::RowMarkClause => "RowMarkClause",
+                    SyntaxKind::XmlSerialize => "XmlSerialize",
+                    SyntaxKind::WithClause => "WithClause",
+                    SyntaxKind::InferClause => "InferClause",
+                    SyntaxKind::OnConflictClause => "OnConflictClause",
+                    SyntaxKind::CtesearchClause => "CtesearchClause",
+                    SyntaxKind::CtecycleClause => "CtecycleClause",
+                    SyntaxKind::CommonTableExpr => "CommonTableExpr",
+                    SyntaxKind::MergeWhenClause => "MergeWhenClause",
+                    SyntaxKind::RoleSpec => "RoleSpec",
+                    SyntaxKind::TriggerTransition => "TriggerTransition",
+                    SyntaxKind::PartitionElem => "PartitionElem",
+                    SyntaxKind::PartitionSpec => "PartitionSpec",
+                    SyntaxKind::PartitionBoundSpec => "PartitionBoundSpec",
+                    SyntaxKind::PartitionRangeDatum => "PartitionRangeDatum",
+                    SyntaxKind::PartitionCmd => "PartitionCmd",
+                    SyntaxKind::VacuumRelation => "VacuumRelation",
+                    SyntaxKind::PublicationObjSpec => "PublicationObjSpec",
+                    SyntaxKind::PublicationTable => "PublicationTable",
+                    SyntaxKind::InlineCodeBlock => "InlineCodeBlock",
+                    SyntaxKind::CallContext => "CallContext",
+                    SyntaxKind::Integer => "Integer",
+                    SyntaxKind::Float => "Float",
+                    SyntaxKind::Boolean => "Boolean",
+                    SyntaxKind::String => "String",
+                    SyntaxKind::BitString => "BitString",
+                    SyntaxKind::List => "List",
+                    SyntaxKind::IntList => "IntList",
+                    SyntaxKind::OidList => "OidList",
+                    SyntaxKind::AConst => "AConst",
+                    SyntaxKind::Nul => "Nul",
+                    SyntaxKind::Ascii37 => "Ascii37",
+                    SyntaxKind::Ascii40 => "Ascii40",
+                    SyntaxKind::Ascii41 => "Ascii41",
+                    SyntaxKind::Ascii42 => "Ascii42",
+                    SyntaxKind::Ascii43 => "Ascii43",
+                    SyntaxKind::Ascii44 => "Ascii44",
+                    SyntaxKind::Ascii45 => "Ascii45",
+                    SyntaxKind::Ascii46 => "Ascii46",
+                    SyntaxKind::Ascii47 => "Ascii47",
+                    SyntaxKind::Ascii58 => "Ascii58",
+                    SyntaxKind::Ascii59 => "Ascii59",
+                    SyntaxKind::Ascii60 => "Ascii60",
+                    SyntaxKind::Ascii61 => "Ascii61",
+                    SyntaxKind::Ascii62 => "Ascii62",
+                    SyntaxKind::Ascii63 => "Ascii63",
+                    SyntaxKind::Ascii91 => "Ascii91",
+                    SyntaxKind::Ascii92 => "Ascii92",
+                    SyntaxKind::Ascii93 => "Ascii93",
+                    SyntaxKind::Ascii94 => "Ascii94",
+                    SyntaxKind::Ident => "Ident",
+                    SyntaxKind::Uident => "Uident",
+                    SyntaxKind::Fconst => "Fconst",
+                    SyntaxKind::Sconst => "Sconst",
+                    SyntaxKind::Usconst => "Usconst",
+                    SyntaxKind::Bconst => "Bconst",
+                    SyntaxKind::Xconst => "Xconst",
+                    SyntaxKind::Op => "Op",
+                    SyntaxKind::Iconst => "Iconst",
+                    SyntaxKind::Typecast => "Typecast",
+                    SyntaxKind::DotDot => "DotDot",
+                    SyntaxKind::ColonEquals => "ColonEquals",
+                    SyntaxKind::EqualsGreater => "EqualsGreater",
+                    SyntaxKind::LessEquals => "LessEquals",
+                    SyntaxKind::GreaterEquals => "GreaterEquals",
+                    SyntaxKind::NotEquals => "NotEquals",
+                    SyntaxKind::SqlComment => "SqlComment",
+                    SyntaxKind::CComment => "CComment",
+                    SyntaxKind::AbortP => "AbortP",
+                    SyntaxKind::AbsoluteP => "AbsoluteP",
+                    SyntaxKind::Access => "Access",
+                    SyntaxKind::Action => "Action",
+                    SyntaxKind::AddP => "AddP",
+                    SyntaxKind::Admin => "Admin",
+                    SyntaxKind::After => "After",
+                    SyntaxKind::Aggregate => "Aggregate",
+                    SyntaxKind::All => "All",
+                    SyntaxKind::Also => "Also",
+                    SyntaxKind::Alter => "Alter",
+                    SyntaxKind::Always => "Always",
+                    SyntaxKind::Analyse => "Analyse",
+                    SyntaxKind::Analyze => "Analyze",
+                    SyntaxKind::And => "And",
+                    SyntaxKind::Any => "Any",
+                    SyntaxKind::Array => "Array",
+                    SyntaxKind::As => "As",
+                    SyntaxKind::Asc => "Asc",
+                    SyntaxKind::Asensitive => "Asensitive",
+                    SyntaxKind::Assertion => "Assertion",
+                    SyntaxKind::Assignment => "Assignment",
+                    SyntaxKind::Asymmetric => "Asymmetric",
+                    SyntaxKind::Atomic => "Atomic",
+                    SyntaxKind::At => "At",
+                    SyntaxKind::Attach => "Attach",
+                    SyntaxKind::Attribute => "Attribute",
+                    SyntaxKind::Authorization => "Authorization",
+                    SyntaxKind::Backward => "Backward",
+                    SyntaxKind::Before => "Before",
+                    SyntaxKind::BeginP => "BeginP",
+                    SyntaxKind::Between => "Between",
+                    SyntaxKind::Bigint => "Bigint",
+                    SyntaxKind::Binary => "Binary",
+                    SyntaxKind::Bit => "Bit",
+                    SyntaxKind::BooleanP => "BooleanP",
+                    SyntaxKind::Both => "Both",
+                    SyntaxKind::Breadth => "Breadth",
+                    SyntaxKind::By => "By",
+                    SyntaxKind::Cache => "Cache",
+                    SyntaxKind::Call => "Call",
+                    SyntaxKind::Called => "Called",
+                    SyntaxKind::Cascade => "Cascade",
+                    SyntaxKind::Cascaded => "Cascaded",
+                    SyntaxKind::Case => "Case",
+                    SyntaxKind::Cast => "Cast",
+                    SyntaxKind::CatalogP => "CatalogP",
+                    SyntaxKind::Chain => "Chain",
+                    SyntaxKind::CharP => "CharP",
+                    SyntaxKind::Character => "Character",
+                    SyntaxKind::Characteristics => "Characteristics",
+                    SyntaxKind::Check => "Check",
+                    SyntaxKind::Checkpoint => "Checkpoint",
+                    SyntaxKind::Class => "Class",
+                    SyntaxKind::Close => "Close",
+                    SyntaxKind::Cluster => "Cluster",
+                    SyntaxKind::Coalesce => "Coalesce",
+                    SyntaxKind::Collate => "Collate",
+                    SyntaxKind::Collation => "Collation",
+                    SyntaxKind::Column => "Column",
+                    SyntaxKind::Columns => "Columns",
+                    SyntaxKind::Comments => "Comments",
+                    SyntaxKind::Commit => "Commit",
+                    SyntaxKind::Committed => "Committed",
+                    SyntaxKind::Compression => "Compression",
+                    SyntaxKind::Concurrently => "Concurrently",
+                    SyntaxKind::Configuration => "Configuration",
+                    SyntaxKind::Conflict => "Conflict",
+                    SyntaxKind::Connection => "Connection",
+                    SyntaxKind::Constraints => "Constraints",
+                    SyntaxKind::ContentP => "ContentP",
+                    SyntaxKind::ContinueP => "ContinueP",
+                    SyntaxKind::ConversionP => "ConversionP",
+                    SyntaxKind::Copy => "Copy",
+                    SyntaxKind::Cost => "Cost",
+                    SyntaxKind::Create => "Create",
+                    SyntaxKind::Cross => "Cross",
+                    SyntaxKind::Csv => "Csv",
+                    SyntaxKind::Cube => "Cube",
+                    SyntaxKind::CurrentP => "CurrentP",
+                    SyntaxKind::CurrentCatalog => "CurrentCatalog",
+                    SyntaxKind::CurrentDate => "CurrentDate",
+                    SyntaxKind::CurrentRole => "CurrentRole",
+                    SyntaxKind::CurrentSchema => "CurrentSchema",
+                    SyntaxKind::CurrentTime => "CurrentTime",
+                    SyntaxKind::CurrentTimestamp => "CurrentTimestamp",
+                    SyntaxKind::CurrentUser => "CurrentUser",
+                    SyntaxKind::Cursor => "Cursor",
+                    SyntaxKind::Cycle => "Cycle",
+                    SyntaxKind::DataP => "DataP",
+                    SyntaxKind::Database => "Database",
+                    SyntaxKind::DayP => "DayP",
+                    SyntaxKind::Deallocate => "Deallocate",
+                    SyntaxKind::Dec => "Dec",
+                    SyntaxKind::DecimalP => "DecimalP",
+                    SyntaxKind::Declare => "Declare",
+                    SyntaxKind::Default => "Default",
+                    SyntaxKind::Defaults => "Defaults",
+                    SyntaxKind::Deferrable => "Deferrable",
+                    SyntaxKind::Deferred => "Deferred",
+                    SyntaxKind::Definer => "Definer",
+                    SyntaxKind::DeleteP => "DeleteP",
+                    SyntaxKind::Delimiter => "Delimiter",
+                    SyntaxKind::Delimiters => "Delimiters",
+                    SyntaxKind::Depends => "Depends",
+                    SyntaxKind::Depth => "Depth",
+                    SyntaxKind::Desc => "Desc",
+                    SyntaxKind::Detach => "Detach",
+                    SyntaxKind::Dictionary => "Dictionary",
+                    SyntaxKind::DisableP => "DisableP",
+                    SyntaxKind::Discard => "Discard",
+                    SyntaxKind::Distinct => "Distinct",
+                    SyntaxKind::Do => "Do",
+                    SyntaxKind::DocumentP => "DocumentP",
+                    SyntaxKind::DomainP => "DomainP",
+                    SyntaxKind::DoubleP => "DoubleP",
+                    SyntaxKind::Drop => "Drop",
+                    SyntaxKind::Each => "Each",
+                    SyntaxKind::Else => "Else",
+                    SyntaxKind::EnableP => "EnableP",
+                    SyntaxKind::Encoding => "Encoding",
+                    SyntaxKind::Encrypted => "Encrypted",
+                    SyntaxKind::EndP => "EndP",
+                    SyntaxKind::EnumP => "EnumP",
+                    SyntaxKind::Escape => "Escape",
+                    SyntaxKind::Event => "Event",
+                    SyntaxKind::Except => "Except",
+                    SyntaxKind::Exclude => "Exclude",
+                    SyntaxKind::Excluding => "Excluding",
+                    SyntaxKind::Exclusive => "Exclusive",
+                    SyntaxKind::Execute => "Execute",
+                    SyntaxKind::Exists => "Exists",
+                    SyntaxKind::Explain => "Explain",
+                    SyntaxKind::Expression => "Expression",
+                    SyntaxKind::Extension => "Extension",
+                    SyntaxKind::External => "External",
+                    SyntaxKind::Extract => "Extract",
+                    SyntaxKind::FalseP => "FalseP",
+                    SyntaxKind::Family => "Family",
+                    SyntaxKind::Fetch => "Fetch",
+                    SyntaxKind::Filter => "Filter",
+                    SyntaxKind::Finalize => "Finalize",
+                    SyntaxKind::FirstP => "FirstP",
+                    SyntaxKind::FloatP => "FloatP",
+                    SyntaxKind::Following => "Following",
+                    SyntaxKind::For => "For",
+                    SyntaxKind::Force => "Force",
+                    SyntaxKind::Foreign => "Foreign",
+                    SyntaxKind::Forward => "Forward",
+                    SyntaxKind::Freeze => "Freeze",
+                    SyntaxKind::From => "From",
+                    SyntaxKind::Full => "Full",
+                    SyntaxKind::Function => "Function",
+                    SyntaxKind::Functions => "Functions",
+                    SyntaxKind::Generated => "Generated",
+                    SyntaxKind::Global => "Global",
+                    SyntaxKind::Grant => "Grant",
+                    SyntaxKind::Granted => "Granted",
+                    SyntaxKind::Greatest => "Greatest",
+                    SyntaxKind::GroupP => "GroupP",
+                    SyntaxKind::Grouping => "Grouping",
+                    SyntaxKind::Groups => "Groups",
+                    SyntaxKind::Handler => "Handler",
+                    SyntaxKind::Having => "Having",
+                    SyntaxKind::HeaderP => "HeaderP",
+                    SyntaxKind::Hold => "Hold",
+                    SyntaxKind::HourP => "HourP",
+                    SyntaxKind::IdentityP => "IdentityP",
+                    SyntaxKind::IfP => "IfP",
+                    SyntaxKind::Ilike => "Ilike",
+                    SyntaxKind::Immediate => "Immediate",
+                    SyntaxKind::Immutable => "Immutable",
+                    SyntaxKind::ImplicitP => "ImplicitP",
+                    SyntaxKind::ImportP => "ImportP",
+                    SyntaxKind::InP => "InP",
+                    SyntaxKind::Include => "Include",
+                    SyntaxKind::Including => "Including",
+                    SyntaxKind::Increment => "Increment",
+                    SyntaxKind::Index => "Index",
+                    SyntaxKind::Indexes => "Indexes",
+                    SyntaxKind::Inherit => "Inherit",
+                    SyntaxKind::Inherits => "Inherits",
+                    SyntaxKind::Initially => "Initially",
+                    SyntaxKind::InlineP => "InlineP",
+                    SyntaxKind::InnerP => "InnerP",
+                    SyntaxKind::Inout => "Inout",
+                    SyntaxKind::InputP => "InputP",
+                    SyntaxKind::Insensitive => "Insensitive",
+                    SyntaxKind::Insert => "Insert",
+                    SyntaxKind::Instead => "Instead",
+                    SyntaxKind::IntP => "IntP",
+                    SyntaxKind::Intersect => "Intersect",
+                    SyntaxKind::Interval => "Interval",
+                    SyntaxKind::Into => "Into",
+                    SyntaxKind::Invoker => "Invoker",
+                    SyntaxKind::Is => "Is",
+                    SyntaxKind::Isnull => "Isnull",
+                    SyntaxKind::Isolation => "Isolation",
+                    SyntaxKind::Join => "Join",
+                    SyntaxKind::Key => "Key",
+                    SyntaxKind::Label => "Label",
+                    SyntaxKind::Language => "Language",
+                    SyntaxKind::LargeP => "LargeP",
+                    SyntaxKind::LastP => "LastP",
+                    SyntaxKind::LateralP => "LateralP",
+                    SyntaxKind::Leading => "Leading",
+                    SyntaxKind::Leakproof => "Leakproof",
+                    SyntaxKind::Least => "Least",
+                    SyntaxKind::Left => "Left",
+                    SyntaxKind::Level => "Level",
+                    SyntaxKind::Like => "Like",
+                    SyntaxKind::Limit => "Limit",
+                    SyntaxKind::Listen => "Listen",
+                    SyntaxKind::Load => "Load",
+                    SyntaxKind::Local => "Local",
+                    SyntaxKind::Localtime => "Localtime",
+                    SyntaxKind::Localtimestamp => "Localtimestamp",
+                    SyntaxKind::Location => "Location",
+                    SyntaxKind::LockP => "LockP",
+                    SyntaxKind::Locked => "Locked",
+                    SyntaxKind::Logged => "Logged",
+                    SyntaxKind::Mapping => "Mapping",
+                    SyntaxKind::Match => "Match",
+                    SyntaxKind::Matched => "Matched",
+                    SyntaxKind::Materialized => "Materialized",
+                    SyntaxKind::Maxvalue => "Maxvalue",
+                    SyntaxKind::Merge => "Merge",
+                    SyntaxKind::Method => "Method",
+                    SyntaxKind::MinuteP => "MinuteP",
+                    SyntaxKind::Minvalue => "Minvalue",
+                    SyntaxKind::Mode => "Mode",
+                    SyntaxKind::MonthP => "MonthP",
+                    SyntaxKind::Move => "Move",
+                    SyntaxKind::NameP => "NameP",
+                    SyntaxKind::Names => "Names",
+                    SyntaxKind::National => "National",
+                    SyntaxKind::Natural => "Natural",
+                    SyntaxKind::Nchar => "Nchar",
+                    SyntaxKind::New => "New",
+                    SyntaxKind::Next => "Next",
+                    SyntaxKind::Nfc => "Nfc",
+                    SyntaxKind::Nfd => "Nfd",
+                    SyntaxKind::Nfkc => "Nfkc",
+                    SyntaxKind::Nfkd => "Nfkd",
+                    SyntaxKind::No => "No",
+                    SyntaxKind::None => "None",
+                    SyntaxKind::Normalize => "Normalize",
+                    SyntaxKind::Normalized => "Normalized",
+                    SyntaxKind::Not => "Not",
+                    SyntaxKind::Nothing => "Nothing",
+                    SyntaxKind::Notify => "Notify",
+                    SyntaxKind::Notnull => "Notnull",
+                    SyntaxKind::Nowait => "Nowait",
+                    SyntaxKind::NullP => "NullP",
+                    SyntaxKind::Nullif => "Nullif",
+                    SyntaxKind::NullsP => "NullsP",
+                    SyntaxKind::Numeric => "Numeric",
+                    SyntaxKind::ObjectP => "ObjectP",
+                    SyntaxKind::Of => "Of",
+                    SyntaxKind::Off => "Off",
+                    SyntaxKind::Offset => "Offset",
+                    SyntaxKind::Oids => "Oids",
+                    SyntaxKind::Old => "Old",
+                    SyntaxKind::On => "On",
+                    SyntaxKind::Only => "Only",
+                    SyntaxKind::Operator => "Operator",
+                    SyntaxKind::Option => "Option",
+                    SyntaxKind::Options => "Options",
+                    SyntaxKind::Or => "Or",
+                    SyntaxKind::Order => "Order",
+                    SyntaxKind::Ordinality => "Ordinality",
+                    SyntaxKind::Others => "Others",
+                    SyntaxKind::OutP => "OutP",
+                    SyntaxKind::OuterP => "OuterP",
+                    SyntaxKind::Over => "Over",
+                    SyntaxKind::Overlaps => "Overlaps",
+                    SyntaxKind::Overlay => "Overlay",
+                    SyntaxKind::Overriding => "Overriding",
+                    SyntaxKind::Owned => "Owned",
+                    SyntaxKind::Owner => "Owner",
+                    SyntaxKind::Parallel => "Parallel",
+                    SyntaxKind::Parameter => "Parameter",
+                    SyntaxKind::Parser => "Parser",
+                    SyntaxKind::Partial => "Partial",
+                    SyntaxKind::Partition => "Partition",
+                    SyntaxKind::Passing => "Passing",
+                    SyntaxKind::Password => "Password",
+                    SyntaxKind::Placing => "Placing",
+                    SyntaxKind::Plans => "Plans",
+                    SyntaxKind::Policy => "Policy",
+                    SyntaxKind::Position => "Position",
+                    SyntaxKind::Preceding => "Preceding",
+                    SyntaxKind::Precision => "Precision",
+                    SyntaxKind::Preserve => "Preserve",
+                    SyntaxKind::Prepare => "Prepare",
+                    SyntaxKind::Prepared => "Prepared",
+                    SyntaxKind::Primary => "Primary",
+                    SyntaxKind::Prior => "Prior",
+                    SyntaxKind::Privileges => "Privileges",
+                    SyntaxKind::Procedural => "Procedural",
+                    SyntaxKind::Procedure => "Procedure",
+                    SyntaxKind::Procedures => "Procedures",
+                    SyntaxKind::Program => "Program",
+                    SyntaxKind::Publication => "Publication",
+                    SyntaxKind::Quote => "Quote",
+                    SyntaxKind::Range => "Range",
+                    SyntaxKind::Read => "Read",
+                    SyntaxKind::Real => "Real",
+                    SyntaxKind::Reassign => "Reassign",
+                    SyntaxKind::Recheck => "Recheck",
+                    SyntaxKind::Recursive => "Recursive",
+                    SyntaxKind::RefP => "RefP",
+                    SyntaxKind::References => "References",
+                    SyntaxKind::Referencing => "Referencing",
+                    SyntaxKind::Refresh => "Refresh",
+                    SyntaxKind::Reindex => "Reindex",
+                    SyntaxKind::RelativeP => "RelativeP",
+                    SyntaxKind::Release => "Release",
+                    SyntaxKind::Rename => "Rename",
+                    SyntaxKind::Repeatable => "Repeatable",
+                    SyntaxKind::Replace => "Replace",
+                    SyntaxKind::Replica => "Replica",
+                    SyntaxKind::Reset => "Reset",
+                    SyntaxKind::Restart => "Restart",
+                    SyntaxKind::Restrict => "Restrict",
+                    SyntaxKind::Return => "Return",
+                    SyntaxKind::Returning => "Returning",
+                    SyntaxKind::Returns => "Returns",
+                    SyntaxKind::Revoke => "Revoke",
+                    SyntaxKind::Right => "Right",
+                    SyntaxKind::Role => "Role",
+                    SyntaxKind::Rollback => "Rollback",
+                    SyntaxKind::Rollup => "Rollup",
+                    SyntaxKind::Routine => "Routine",
+                    SyntaxKind::Routines => "Routines",
+                    SyntaxKind::Row => "Row",
+                    SyntaxKind::Rows => "Rows",
+                    SyntaxKind::Rule => "Rule",
+                    SyntaxKind::Savepoint => "Savepoint",
+                    SyntaxKind::Schema => "Schema",
+                    SyntaxKind::Schemas => "Schemas",
+                    SyntaxKind::Scroll => "Scroll",
+                    SyntaxKind::Search => "Search",
+                    SyntaxKind::SecondP => "SecondP",
+                    SyntaxKind::Security => "Security",
+                    SyntaxKind::Select => "Select",
+                    SyntaxKind::Sequence => "Sequence",
+                    SyntaxKind::Sequences => "Sequences",
+                    SyntaxKind::Serializable => "Serializable",
+                    SyntaxKind::Server => "Server",
+                    SyntaxKind::Session => "Session",
+                    SyntaxKind::SessionUser => "SessionUser",
+                    SyntaxKind::Set => "Set",
+                    SyntaxKind::Sets => "Sets",
+                    SyntaxKind::Setof => "Setof",
+                    SyntaxKind::Share => "Share",
+                    SyntaxKind::Show => "Show",
+                    SyntaxKind::Similar => "Similar",
+                    SyntaxKind::Simple => "Simple",
+                    SyntaxKind::Skip => "Skip",
+                    SyntaxKind::Smallint => "Smallint",
+                    SyntaxKind::Snapshot => "Snapshot",
+                    SyntaxKind::Some => "Some",
+                    SyntaxKind::SqlP => "SqlP",
+                    SyntaxKind::Stable => "Stable",
+                    SyntaxKind::StandaloneP => "StandaloneP",
+                    SyntaxKind::Start => "Start",
+                    SyntaxKind::Statement => "Statement",
+                    SyntaxKind::Statistics => "Statistics",
+                    SyntaxKind::Stdin => "Stdin",
+                    SyntaxKind::Stdout => "Stdout",
+                    SyntaxKind::Storage => "Storage",
+                    SyntaxKind::Stored => "Stored",
+                    SyntaxKind::StrictP => "StrictP",
+                    SyntaxKind::StripP => "StripP",
+                    SyntaxKind::Subscription => "Subscription",
+                    SyntaxKind::Substring => "Substring",
+                    SyntaxKind::Support => "Support",
+                    SyntaxKind::Symmetric => "Symmetric",
+                    SyntaxKind::Sysid => "Sysid",
+                    SyntaxKind::SystemP => "SystemP",
+                    SyntaxKind::Table => "Table",
+                    SyntaxKind::Tables => "Tables",
+                    SyntaxKind::Tablesample => "Tablesample",
+                    SyntaxKind::Tablespace => "Tablespace",
+                    SyntaxKind::Temp => "Temp",
+                    SyntaxKind::Template => "Template",
+                    SyntaxKind::Temporary => "Temporary",
+                    SyntaxKind::TextP => "TextP",
+                    SyntaxKind::Then => "Then",
+                    SyntaxKind::Ties => "Ties",
+                    SyntaxKind::Time => "Time",
+                    SyntaxKind::Timestamp => "Timestamp",
+                    SyntaxKind::To => "To",
+                    SyntaxKind::Trailing => "Trailing",
+                    SyntaxKind::Transaction => "Transaction",
+                    SyntaxKind::Transform => "Transform",
+                    SyntaxKind::Treat => "Treat",
+                    SyntaxKind::Trigger => "Trigger",
+                    SyntaxKind::Trim => "Trim",
+                    SyntaxKind::TrueP => "TrueP",
+                    SyntaxKind::Truncate => "Truncate",
+                    SyntaxKind::Trusted => "Trusted",
+                    SyntaxKind::TypeP => "TypeP",
+                    SyntaxKind::TypesP => "TypesP",
+                    SyntaxKind::Uescape => "Uescape",
+                    SyntaxKind::Unbounded => "Unbounded",
+                    SyntaxKind::Uncommitted => "Uncommitted",
+                    SyntaxKind::Unencrypted => "Unencrypted",
+                    SyntaxKind::Union => "Union",
+                    SyntaxKind::Unique => "Unique",
+                    SyntaxKind::Unknown => "Unknown",
+                    SyntaxKind::Unlisten => "Unlisten",
+                    SyntaxKind::Unlogged => "Unlogged",
+                    SyntaxKind::Until => "Until",
+                    SyntaxKind::Update => "Update",
+                    SyntaxKind::User => "User",
+                    SyntaxKind::Using => "Using",
+                    SyntaxKind::Vacuum => "Vacuum",
+                    SyntaxKind::Valid => "Valid",
+                    SyntaxKind::Validate => "Validate",
+                    SyntaxKind::Validator => "Validator",
+                    SyntaxKind::ValueP => "ValueP",
+                    SyntaxKind::Values => "Values",
+                    SyntaxKind::Varchar => "Varchar",
+                    SyntaxKind::Variadic => "Variadic",
+                    SyntaxKind::Varying => "Varying",
+                    SyntaxKind::Verbose => "Verbose",
+                    SyntaxKind::VersionP => "VersionP",
+                    SyntaxKind::View => "View",
+                    SyntaxKind::Views => "Views",
+                    SyntaxKind::Volatile => "Volatile",
+                    SyntaxKind::When => "When",
+                    SyntaxKind::Where => "Where",
+                    SyntaxKind::WhitespaceP => "WhitespaceP",
+                    SyntaxKind::Window => "Window",
+                    SyntaxKind::With => "With",
+                    SyntaxKind::Within => "Within",
+                    SyntaxKind::Without => "Without",
+                    SyntaxKind::Work => "Work",
+                    SyntaxKind::Wrapper => "Wrapper",
+                    SyntaxKind::Write => "Write",
+                    SyntaxKind::XmlP => "XmlP",
+                    SyntaxKind::Xmlattributes => "Xmlattributes",
+                    SyntaxKind::Xmlconcat => "Xmlconcat",
+                    SyntaxKind::Xmlelement => "Xmlelement",
+                    SyntaxKind::Xmlexists => "Xmlexists",
+                    SyntaxKind::Xmlforest => "Xmlforest",
+                    SyntaxKind::Xmlnamespaces => "Xmlnamespaces",
+                    SyntaxKind::Xmlparse => "Xmlparse",
+                    SyntaxKind::Xmlpi => "Xmlpi",
+                    SyntaxKind::Xmlroot => "Xmlroot",
+                    SyntaxKind::Xmlserialize => "Xmlserialize",
+                    SyntaxKind::Xmltable => "Xmltable",
+                    SyntaxKind::YearP => "YearP",
+                    SyntaxKind::YesP => "YesP",
+                    SyntaxKind::Zone => "Zone",
+                    SyntaxKind::NotLa => "NotLa",
+                    SyntaxKind::NullsLa => "NullsLa",
+                    SyntaxKind::WithLa => "WithLa",
+                    SyntaxKind::ModeTypeName => "ModeTypeName",
+                    SyntaxKind::ModePlpgsqlExpr => "ModePlpgsqlExpr",
+                    SyntaxKind::ModePlpgsqlAssign1 => "ModePlpgsqlAssign1",
+                    SyntaxKind::ModePlpgsqlAssign2 => "ModePlpgsqlAssign2",
+                    SyntaxKind::ModePlpgsqlAssign3 => "ModePlpgsqlAssign3",
+                    SyntaxKind::Uminus => "Uminus",
+                },
+            )
+        }
+    }
+    #[automatically_derived]
+    impl ::cstree::Syntax for SyntaxKind {
+        fn from_raw(raw: ::cstree::RawSyntaxKind) -> Self {
+            if !(raw.0 < 748u32) {
+                {
+                    ::core::panicking::panic_fmt(
+                        format_args!("Invalid raw syntax kind: {0}", raw.0),
+                    );
+                }
+            }
+            unsafe { ::std::mem::transmute::<u32, SyntaxKind>(raw.0) }
+        }
+        fn into_raw(self) -> ::cstree::RawSyntaxKind {
+            ::cstree::RawSyntaxKind(self as u32)
+        }
+        fn static_text(self) -> ::core::option::Option<&'static str> {
+            match self {
+                SyntaxKind::SourceFile => ::core::option::Option::None,
+                SyntaxKind::Comment => ::core::option::Option::None,
+                SyntaxKind::Whitespace => ::core::option::Option::None,
+                SyntaxKind::Newline => ::core::option::Option::None,
+                SyntaxKind::Tab => ::core::option::Option::None,
+                SyntaxKind::Stmt => ::core::option::Option::None,
+                SyntaxKind::Alias => ::core::option::Option::None,
+                SyntaxKind::RangeVar => ::core::option::Option::None,
+                SyntaxKind::TableFunc => ::core::option::Option::None,
+                SyntaxKind::Var => ::core::option::Option::None,
+                SyntaxKind::Param => ::core::option::Option::None,
+                SyntaxKind::Aggref => ::core::option::Option::None,
+                SyntaxKind::GroupingFunc => ::core::option::Option::None,
+                SyntaxKind::WindowFunc => ::core::option::Option::None,
+                SyntaxKind::SubscriptingRef => ::core::option::Option::None,
+                SyntaxKind::FuncExpr => ::core::option::Option::None,
+                SyntaxKind::NamedArgExpr => ::core::option::Option::None,
+                SyntaxKind::OpExpr => ::core::option::Option::None,
+                SyntaxKind::DistinctExpr => ::core::option::Option::None,
+                SyntaxKind::NullIfExpr => ::core::option::Option::None,
+                SyntaxKind::ScalarArrayOpExpr => ::core::option::Option::None,
+                SyntaxKind::BoolExpr => ::core::option::Option::None,
+                SyntaxKind::SubLink => ::core::option::Option::None,
+                SyntaxKind::SubPlan => ::core::option::Option::None,
+                SyntaxKind::AlternativeSubPlan => ::core::option::Option::None,
+                SyntaxKind::FieldSelect => ::core::option::Option::None,
+                SyntaxKind::FieldStore => ::core::option::Option::None,
+                SyntaxKind::RelabelType => ::core::option::Option::None,
+                SyntaxKind::CoerceViaIo => ::core::option::Option::None,
+                SyntaxKind::ArrayCoerceExpr => ::core::option::Option::None,
+                SyntaxKind::ConvertRowtypeExpr => ::core::option::Option::None,
+                SyntaxKind::CollateExpr => ::core::option::Option::None,
+                SyntaxKind::CaseExpr => ::core::option::Option::None,
+                SyntaxKind::CaseWhen => ::core::option::Option::None,
+                SyntaxKind::CaseTestExpr => ::core::option::Option::None,
+                SyntaxKind::ArrayExpr => ::core::option::Option::None,
+                SyntaxKind::RowExpr => ::core::option::Option::None,
+                SyntaxKind::RowCompareExpr => ::core::option::Option::None,
+                SyntaxKind::CoalesceExpr => ::core::option::Option::None,
+                SyntaxKind::MinMaxExpr => ::core::option::Option::None,
+                SyntaxKind::SqlvalueFunction => ::core::option::Option::None,
+                SyntaxKind::XmlExpr => ::core::option::Option::None,
+                SyntaxKind::NullTest => ::core::option::Option::None,
+                SyntaxKind::BooleanTest => ::core::option::Option::None,
+                SyntaxKind::CoerceToDomain => ::core::option::Option::None,
+                SyntaxKind::CoerceToDomainValue => ::core::option::Option::None,
+                SyntaxKind::SetToDefault => ::core::option::Option::None,
+                SyntaxKind::CurrentOfExpr => ::core::option::Option::None,
+                SyntaxKind::NextValueExpr => ::core::option::Option::None,
+                SyntaxKind::InferenceElem => ::core::option::Option::None,
+                SyntaxKind::TargetEntry => ::core::option::Option::None,
+                SyntaxKind::RangeTblRef => ::core::option::Option::None,
+                SyntaxKind::JoinExpr => ::core::option::Option::None,
+                SyntaxKind::FromExpr => ::core::option::Option::None,
+                SyntaxKind::OnConflictExpr => ::core::option::Option::None,
+                SyntaxKind::IntoClause => ::core::option::Option::None,
+                SyntaxKind::MergeAction => ::core::option::Option::None,
+                SyntaxKind::RawStmt => ::core::option::Option::None,
+                SyntaxKind::Query => ::core::option::Option::None,
+                SyntaxKind::InsertStmt => ::core::option::Option::None,
+                SyntaxKind::DeleteStmt => ::core::option::Option::None,
+                SyntaxKind::UpdateStmt => ::core::option::Option::None,
+                SyntaxKind::MergeStmt => ::core::option::Option::None,
+                SyntaxKind::SelectStmt => ::core::option::Option::None,
+                SyntaxKind::ReturnStmt => ::core::option::Option::None,
+                SyntaxKind::PlassignStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTableStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTableCmd => ::core::option::Option::None,
+                SyntaxKind::AlterDomainStmt => ::core::option::Option::None,
+                SyntaxKind::SetOperationStmt => ::core::option::Option::None,
+                SyntaxKind::GrantStmt => ::core::option::Option::None,
+                SyntaxKind::GrantRoleStmt => ::core::option::Option::None,
+                SyntaxKind::AlterDefaultPrivilegesStmt => ::core::option::Option::None,
+                SyntaxKind::ClosePortalStmt => ::core::option::Option::None,
+                SyntaxKind::ClusterStmt => ::core::option::Option::None,
+                SyntaxKind::CopyStmt => ::core::option::Option::None,
+                SyntaxKind::CreateStmt => ::core::option::Option::None,
+                SyntaxKind::DefineStmt => ::core::option::Option::None,
+                SyntaxKind::DropStmt => ::core::option::Option::None,
+                SyntaxKind::TruncateStmt => ::core::option::Option::None,
+                SyntaxKind::CommentStmt => ::core::option::Option::None,
+                SyntaxKind::FetchStmt => ::core::option::Option::None,
+                SyntaxKind::IndexStmt => ::core::option::Option::None,
+                SyntaxKind::CreateFunctionStmt => ::core::option::Option::None,
+                SyntaxKind::AlterFunctionStmt => ::core::option::Option::None,
+                SyntaxKind::DoStmt => ::core::option::Option::None,
+                SyntaxKind::RenameStmt => ::core::option::Option::None,
+                SyntaxKind::RuleStmt => ::core::option::Option::None,
+                SyntaxKind::NotifyStmt => ::core::option::Option::None,
+                SyntaxKind::ListenStmt => ::core::option::Option::None,
+                SyntaxKind::UnlistenStmt => ::core::option::Option::None,
+                SyntaxKind::TransactionStmt => ::core::option::Option::None,
+                SyntaxKind::ViewStmt => ::core::option::Option::None,
+                SyntaxKind::LoadStmt => ::core::option::Option::None,
+                SyntaxKind::CreateDomainStmt => ::core::option::Option::None,
+                SyntaxKind::CreatedbStmt => ::core::option::Option::None,
+                SyntaxKind::DropdbStmt => ::core::option::Option::None,
+                SyntaxKind::VacuumStmt => ::core::option::Option::None,
+                SyntaxKind::ExplainStmt => ::core::option::Option::None,
+                SyntaxKind::CreateTableAsStmt => ::core::option::Option::None,
+                SyntaxKind::CreateSeqStmt => ::core::option::Option::None,
+                SyntaxKind::AlterSeqStmt => ::core::option::Option::None,
+                SyntaxKind::VariableSetStmt => ::core::option::Option::None,
+                SyntaxKind::VariableShowStmt => ::core::option::Option::None,
+                SyntaxKind::DiscardStmt => ::core::option::Option::None,
+                SyntaxKind::CreateTrigStmt => ::core::option::Option::None,
+                SyntaxKind::CreatePlangStmt => ::core::option::Option::None,
+                SyntaxKind::CreateRoleStmt => ::core::option::Option::None,
+                SyntaxKind::AlterRoleStmt => ::core::option::Option::None,
+                SyntaxKind::DropRoleStmt => ::core::option::Option::None,
+                SyntaxKind::LockStmt => ::core::option::Option::None,
+                SyntaxKind::ConstraintsSetStmt => ::core::option::Option::None,
+                SyntaxKind::ReindexStmt => ::core::option::Option::None,
+                SyntaxKind::CheckPointStmt => ::core::option::Option::None,
+                SyntaxKind::CreateSchemaStmt => ::core::option::Option::None,
+                SyntaxKind::AlterDatabaseStmt => ::core::option::Option::None,
+                SyntaxKind::AlterDatabaseRefreshCollStmt => ::core::option::Option::None,
+                SyntaxKind::AlterDatabaseSetStmt => ::core::option::Option::None,
+                SyntaxKind::AlterRoleSetStmt => ::core::option::Option::None,
+                SyntaxKind::CreateConversionStmt => ::core::option::Option::None,
+                SyntaxKind::CreateCastStmt => ::core::option::Option::None,
+                SyntaxKind::CreateOpClassStmt => ::core::option::Option::None,
+                SyntaxKind::CreateOpFamilyStmt => ::core::option::Option::None,
+                SyntaxKind::AlterOpFamilyStmt => ::core::option::Option::None,
+                SyntaxKind::PrepareStmt => ::core::option::Option::None,
+                SyntaxKind::ExecuteStmt => ::core::option::Option::None,
+                SyntaxKind::DeallocateStmt => ::core::option::Option::None,
+                SyntaxKind::DeclareCursorStmt => ::core::option::Option::None,
+                SyntaxKind::CreateTableSpaceStmt => ::core::option::Option::None,
+                SyntaxKind::DropTableSpaceStmt => ::core::option::Option::None,
+                SyntaxKind::AlterObjectDependsStmt => ::core::option::Option::None,
+                SyntaxKind::AlterObjectSchemaStmt => ::core::option::Option::None,
+                SyntaxKind::AlterOwnerStmt => ::core::option::Option::None,
+                SyntaxKind::AlterOperatorStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTypeStmt => ::core::option::Option::None,
+                SyntaxKind::DropOwnedStmt => ::core::option::Option::None,
+                SyntaxKind::ReassignOwnedStmt => ::core::option::Option::None,
+                SyntaxKind::CompositeTypeStmt => ::core::option::Option::None,
+                SyntaxKind::CreateEnumStmt => ::core::option::Option::None,
+                SyntaxKind::CreateRangeStmt => ::core::option::Option::None,
+                SyntaxKind::AlterEnumStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTsdictionaryStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTsconfigurationStmt => ::core::option::Option::None,
+                SyntaxKind::CreateFdwStmt => ::core::option::Option::None,
+                SyntaxKind::AlterFdwStmt => ::core::option::Option::None,
+                SyntaxKind::CreateForeignServerStmt => ::core::option::Option::None,
+                SyntaxKind::AlterForeignServerStmt => ::core::option::Option::None,
+                SyntaxKind::CreateUserMappingStmt => ::core::option::Option::None,
+                SyntaxKind::AlterUserMappingStmt => ::core::option::Option::None,
+                SyntaxKind::DropUserMappingStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTableSpaceOptionsStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTableMoveAllStmt => ::core::option::Option::None,
+                SyntaxKind::SecLabelStmt => ::core::option::Option::None,
+                SyntaxKind::CreateForeignTableStmt => ::core::option::Option::None,
+                SyntaxKind::ImportForeignSchemaStmt => ::core::option::Option::None,
+                SyntaxKind::CreateExtensionStmt => ::core::option::Option::None,
+                SyntaxKind::AlterExtensionStmt => ::core::option::Option::None,
+                SyntaxKind::AlterExtensionContentsStmt => ::core::option::Option::None,
+                SyntaxKind::CreateEventTrigStmt => ::core::option::Option::None,
+                SyntaxKind::AlterEventTrigStmt => ::core::option::Option::None,
+                SyntaxKind::RefreshMatViewStmt => ::core::option::Option::None,
+                SyntaxKind::ReplicaIdentityStmt => ::core::option::Option::None,
+                SyntaxKind::AlterSystemStmt => ::core::option::Option::None,
+                SyntaxKind::CreatePolicyStmt => ::core::option::Option::None,
+                SyntaxKind::AlterPolicyStmt => ::core::option::Option::None,
+                SyntaxKind::CreateTransformStmt => ::core::option::Option::None,
+                SyntaxKind::CreateAmStmt => ::core::option::Option::None,
+                SyntaxKind::CreatePublicationStmt => ::core::option::Option::None,
+                SyntaxKind::AlterPublicationStmt => ::core::option::Option::None,
+                SyntaxKind::CreateSubscriptionStmt => ::core::option::Option::None,
+                SyntaxKind::AlterSubscriptionStmt => ::core::option::Option::None,
+                SyntaxKind::DropSubscriptionStmt => ::core::option::Option::None,
+                SyntaxKind::CreateStatsStmt => ::core::option::Option::None,
+                SyntaxKind::AlterCollationStmt => ::core::option::Option::None,
+                SyntaxKind::CallStmt => ::core::option::Option::None,
+                SyntaxKind::AlterStatsStmt => ::core::option::Option::None,
+                SyntaxKind::AExpr => ::core::option::Option::None,
+                SyntaxKind::ColumnRef => ::core::option::Option::None,
+                SyntaxKind::ParamRef => ::core::option::Option::None,
+                SyntaxKind::FuncCall => ::core::option::Option::None,
+                SyntaxKind::AStar => ::core::option::Option::None,
+                SyntaxKind::AIndices => ::core::option::Option::None,
+                SyntaxKind::AIndirection => ::core::option::Option::None,
+                SyntaxKind::AArrayExpr => ::core::option::Option::None,
+                SyntaxKind::ResTarget => ::core::option::Option::None,
+                SyntaxKind::MultiAssignRef => ::core::option::Option::None,
+                SyntaxKind::TypeCast => ::core::option::Option::None,
+                SyntaxKind::CollateClause => ::core::option::Option::None,
+                SyntaxKind::SortBy => ::core::option::Option::None,
+                SyntaxKind::WindowDef => ::core::option::Option::None,
+                SyntaxKind::RangeSubselect => ::core::option::Option::None,
+                SyntaxKind::RangeFunction => ::core::option::Option::None,
+                SyntaxKind::RangeTableSample => ::core::option::Option::None,
+                SyntaxKind::RangeTableFunc => ::core::option::Option::None,
+                SyntaxKind::RangeTableFuncCol => ::core::option::Option::None,
+                SyntaxKind::TypeName => ::core::option::Option::None,
+                SyntaxKind::ColumnDef => ::core::option::Option::None,
+                SyntaxKind::IndexElem => ::core::option::Option::None,
+                SyntaxKind::StatsElem => ::core::option::Option::None,
+                SyntaxKind::Constraint => ::core::option::Option::None,
+                SyntaxKind::DefElem => ::core::option::Option::None,
+                SyntaxKind::RangeTblEntry => ::core::option::Option::None,
+                SyntaxKind::RangeTblFunction => ::core::option::Option::None,
+                SyntaxKind::TableSampleClause => ::core::option::Option::None,
+                SyntaxKind::WithCheckOption => ::core::option::Option::None,
+                SyntaxKind::SortGroupClause => ::core::option::Option::None,
+                SyntaxKind::GroupingSet => ::core::option::Option::None,
+                SyntaxKind::WindowClause => ::core::option::Option::None,
+                SyntaxKind::ObjectWithArgs => ::core::option::Option::None,
+                SyntaxKind::AccessPriv => ::core::option::Option::None,
+                SyntaxKind::CreateOpClassItem => ::core::option::Option::None,
+                SyntaxKind::TableLikeClause => ::core::option::Option::None,
+                SyntaxKind::FunctionParameter => ::core::option::Option::None,
+                SyntaxKind::LockingClause => ::core::option::Option::None,
+                SyntaxKind::RowMarkClause => ::core::option::Option::None,
+                SyntaxKind::XmlSerialize => ::core::option::Option::None,
+                SyntaxKind::WithClause => ::core::option::Option::None,
+                SyntaxKind::InferClause => ::core::option::Option::None,
+                SyntaxKind::OnConflictClause => ::core::option::Option::None,
+                SyntaxKind::CtesearchClause => ::core::option::Option::None,
+                SyntaxKind::CtecycleClause => ::core::option::Option::None,
+                SyntaxKind::CommonTableExpr => ::core::option::Option::None,
+                SyntaxKind::MergeWhenClause => ::core::option::Option::None,
+                SyntaxKind::RoleSpec => ::core::option::Option::None,
+                SyntaxKind::TriggerTransition => ::core::option::Option::None,
+                SyntaxKind::PartitionElem => ::core::option::Option::None,
+                SyntaxKind::PartitionSpec => ::core::option::Option::None,
+                SyntaxKind::PartitionBoundSpec => ::core::option::Option::None,
+                SyntaxKind::PartitionRangeDatum => ::core::option::Option::None,
+                SyntaxKind::PartitionCmd => ::core::option::Option::None,
+                SyntaxKind::VacuumRelation => ::core::option::Option::None,
+                SyntaxKind::PublicationObjSpec => ::core::option::Option::None,
+                SyntaxKind::PublicationTable => ::core::option::Option::None,
+                SyntaxKind::InlineCodeBlock => ::core::option::Option::None,
+                SyntaxKind::CallContext => ::core::option::Option::None,
+                SyntaxKind::Integer => ::core::option::Option::None,
+                SyntaxKind::Float => ::core::option::Option::None,
+                SyntaxKind::Boolean => ::core::option::Option::None,
+                SyntaxKind::String => ::core::option::Option::None,
+                SyntaxKind::BitString => ::core::option::Option::None,
+                SyntaxKind::List => ::core::option::Option::None,
+                SyntaxKind::IntList => ::core::option::Option::None,
+                SyntaxKind::OidList => ::core::option::Option::None,
+                SyntaxKind::AConst => ::core::option::Option::None,
+                SyntaxKind::Nul => ::core::option::Option::None,
+                SyntaxKind::Ascii37 => ::core::option::Option::None,
+                SyntaxKind::Ascii40 => ::core::option::Option::None,
+                SyntaxKind::Ascii41 => ::core::option::Option::None,
+                SyntaxKind::Ascii42 => ::core::option::Option::None,
+                SyntaxKind::Ascii43 => ::core::option::Option::None,
+                SyntaxKind::Ascii44 => ::core::option::Option::None,
+                SyntaxKind::Ascii45 => ::core::option::Option::None,
+                SyntaxKind::Ascii46 => ::core::option::Option::None,
+                SyntaxKind::Ascii47 => ::core::option::Option::None,
+                SyntaxKind::Ascii58 => ::core::option::Option::None,
+                SyntaxKind::Ascii59 => ::core::option::Option::None,
+                SyntaxKind::Ascii60 => ::core::option::Option::None,
+                SyntaxKind::Ascii61 => ::core::option::Option::None,
+                SyntaxKind::Ascii62 => ::core::option::Option::None,
+                SyntaxKind::Ascii63 => ::core::option::Option::None,
+                SyntaxKind::Ascii91 => ::core::option::Option::None,
+                SyntaxKind::Ascii92 => ::core::option::Option::None,
+                SyntaxKind::Ascii93 => ::core::option::Option::None,
+                SyntaxKind::Ascii94 => ::core::option::Option::None,
+                SyntaxKind::Ident => ::core::option::Option::None,
+                SyntaxKind::Uident => ::core::option::Option::None,
+                SyntaxKind::Fconst => ::core::option::Option::None,
+                SyntaxKind::Sconst => ::core::option::Option::None,
+                SyntaxKind::Usconst => ::core::option::Option::None,
+                SyntaxKind::Bconst => ::core::option::Option::None,
+                SyntaxKind::Xconst => ::core::option::Option::None,
+                SyntaxKind::Op => ::core::option::Option::None,
+                SyntaxKind::Iconst => ::core::option::Option::None,
+                SyntaxKind::Typecast => ::core::option::Option::None,
+                SyntaxKind::DotDot => ::core::option::Option::None,
+                SyntaxKind::ColonEquals => ::core::option::Option::None,
+                SyntaxKind::EqualsGreater => ::core::option::Option::None,
+                SyntaxKind::LessEquals => ::core::option::Option::None,
+                SyntaxKind::GreaterEquals => ::core::option::Option::None,
+                SyntaxKind::NotEquals => ::core::option::Option::None,
+                SyntaxKind::SqlComment => ::core::option::Option::None,
+                SyntaxKind::CComment => ::core::option::Option::None,
+                SyntaxKind::AbortP => ::core::option::Option::None,
+                SyntaxKind::AbsoluteP => ::core::option::Option::None,
+                SyntaxKind::Access => ::core::option::Option::None,
+                SyntaxKind::Action => ::core::option::Option::None,
+                SyntaxKind::AddP => ::core::option::Option::None,
+                SyntaxKind::Admin => ::core::option::Option::None,
+                SyntaxKind::After => ::core::option::Option::None,
+                SyntaxKind::Aggregate => ::core::option::Option::None,
+                SyntaxKind::All => ::core::option::Option::None,
+                SyntaxKind::Also => ::core::option::Option::None,
+                SyntaxKind::Alter => ::core::option::Option::None,
+                SyntaxKind::Always => ::core::option::Option::None,
+                SyntaxKind::Analyse => ::core::option::Option::None,
+                SyntaxKind::Analyze => ::core::option::Option::None,
+                SyntaxKind::And => ::core::option::Option::None,
+                SyntaxKind::Any => ::core::option::Option::None,
+                SyntaxKind::Array => ::core::option::Option::None,
+                SyntaxKind::As => ::core::option::Option::None,
+                SyntaxKind::Asc => ::core::option::Option::None,
+                SyntaxKind::Asensitive => ::core::option::Option::None,
+                SyntaxKind::Assertion => ::core::option::Option::None,
+                SyntaxKind::Assignment => ::core::option::Option::None,
+                SyntaxKind::Asymmetric => ::core::option::Option::None,
+                SyntaxKind::Atomic => ::core::option::Option::None,
+                SyntaxKind::At => ::core::option::Option::None,
+                SyntaxKind::Attach => ::core::option::Option::None,
+                SyntaxKind::Attribute => ::core::option::Option::None,
+                SyntaxKind::Authorization => ::core::option::Option::None,
+                SyntaxKind::Backward => ::core::option::Option::None,
+                SyntaxKind::Before => ::core::option::Option::None,
+                SyntaxKind::BeginP => ::core::option::Option::None,
+                SyntaxKind::Between => ::core::option::Option::None,
+                SyntaxKind::Bigint => ::core::option::Option::None,
+                SyntaxKind::Binary => ::core::option::Option::None,
+                SyntaxKind::Bit => ::core::option::Option::None,
+                SyntaxKind::BooleanP => ::core::option::Option::None,
+                SyntaxKind::Both => ::core::option::Option::None,
+                SyntaxKind::Breadth => ::core::option::Option::None,
+                SyntaxKind::By => ::core::option::Option::None,
+                SyntaxKind::Cache => ::core::option::Option::None,
+                SyntaxKind::Call => ::core::option::Option::None,
+                SyntaxKind::Called => ::core::option::Option::None,
+                SyntaxKind::Cascade => ::core::option::Option::None,
+                SyntaxKind::Cascaded => ::core::option::Option::None,
+                SyntaxKind::Case => ::core::option::Option::None,
+                SyntaxKind::Cast => ::core::option::Option::None,
+                SyntaxKind::CatalogP => ::core::option::Option::None,
+                SyntaxKind::Chain => ::core::option::Option::None,
+                SyntaxKind::CharP => ::core::option::Option::None,
+                SyntaxKind::Character => ::core::option::Option::None,
+                SyntaxKind::Characteristics => ::core::option::Option::None,
+                SyntaxKind::Check => ::core::option::Option::None,
+                SyntaxKind::Checkpoint => ::core::option::Option::None,
+                SyntaxKind::Class => ::core::option::Option::None,
+                SyntaxKind::Close => ::core::option::Option::None,
+                SyntaxKind::Cluster => ::core::option::Option::None,
+                SyntaxKind::Coalesce => ::core::option::Option::None,
+                SyntaxKind::Collate => ::core::option::Option::None,
+                SyntaxKind::Collation => ::core::option::Option::None,
+                SyntaxKind::Column => ::core::option::Option::None,
+                SyntaxKind::Columns => ::core::option::Option::None,
+                SyntaxKind::Comments => ::core::option::Option::None,
+                SyntaxKind::Commit => ::core::option::Option::None,
+                SyntaxKind::Committed => ::core::option::Option::None,
+                SyntaxKind::Compression => ::core::option::Option::None,
+                SyntaxKind::Concurrently => ::core::option::Option::None,
+                SyntaxKind::Configuration => ::core::option::Option::None,
+                SyntaxKind::Conflict => ::core::option::Option::None,
+                SyntaxKind::Connection => ::core::option::Option::None,
+                SyntaxKind::Constraints => ::core::option::Option::None,
+                SyntaxKind::ContentP => ::core::option::Option::None,
+                SyntaxKind::ContinueP => ::core::option::Option::None,
+                SyntaxKind::ConversionP => ::core::option::Option::None,
+                SyntaxKind::Copy => ::core::option::Option::None,
+                SyntaxKind::Cost => ::core::option::Option::None,
+                SyntaxKind::Create => ::core::option::Option::None,
+                SyntaxKind::Cross => ::core::option::Option::None,
+                SyntaxKind::Csv => ::core::option::Option::None,
+                SyntaxKind::Cube => ::core::option::Option::None,
+                SyntaxKind::CurrentP => ::core::option::Option::None,
+                SyntaxKind::CurrentCatalog => ::core::option::Option::None,
+                SyntaxKind::CurrentDate => ::core::option::Option::None,
+                SyntaxKind::CurrentRole => ::core::option::Option::None,
+                SyntaxKind::CurrentSchema => ::core::option::Option::None,
+                SyntaxKind::CurrentTime => ::core::option::Option::None,
+                SyntaxKind::CurrentTimestamp => ::core::option::Option::None,
+                SyntaxKind::CurrentUser => ::core::option::Option::None,
+                SyntaxKind::Cursor => ::core::option::Option::None,
+                SyntaxKind::Cycle => ::core::option::Option::None,
+                SyntaxKind::DataP => ::core::option::Option::None,
+                SyntaxKind::Database => ::core::option::Option::None,
+                SyntaxKind::DayP => ::core::option::Option::None,
+                SyntaxKind::Deallocate => ::core::option::Option::None,
+                SyntaxKind::Dec => ::core::option::Option::None,
+                SyntaxKind::DecimalP => ::core::option::Option::None,
+                SyntaxKind::Declare => ::core::option::Option::None,
+                SyntaxKind::Default => ::core::option::Option::None,
+                SyntaxKind::Defaults => ::core::option::Option::None,
+                SyntaxKind::Deferrable => ::core::option::Option::None,
+                SyntaxKind::Deferred => ::core::option::Option::None,
+                SyntaxKind::Definer => ::core::option::Option::None,
+                SyntaxKind::DeleteP => ::core::option::Option::None,
+                SyntaxKind::Delimiter => ::core::option::Option::None,
+                SyntaxKind::Delimiters => ::core::option::Option::None,
+                SyntaxKind::Depends => ::core::option::Option::None,
+                SyntaxKind::Depth => ::core::option::Option::None,
+                SyntaxKind::Desc => ::core::option::Option::None,
+                SyntaxKind::Detach => ::core::option::Option::None,
+                SyntaxKind::Dictionary => ::core::option::Option::None,
+                SyntaxKind::DisableP => ::core::option::Option::None,
+                SyntaxKind::Discard => ::core::option::Option::None,
+                SyntaxKind::Distinct => ::core::option::Option::None,
+                SyntaxKind::Do => ::core::option::Option::None,
+                SyntaxKind::DocumentP => ::core::option::Option::None,
+                SyntaxKind::DomainP => ::core::option::Option::None,
+                SyntaxKind::DoubleP => ::core::option::Option::None,
+                SyntaxKind::Drop => ::core::option::Option::None,
+                SyntaxKind::Each => ::core::option::Option::None,
+                SyntaxKind::Else => ::core::option::Option::None,
+                SyntaxKind::EnableP => ::core::option::Option::None,
+                SyntaxKind::Encoding => ::core::option::Option::None,
+                SyntaxKind::Encrypted => ::core::option::Option::None,
+                SyntaxKind::EndP => ::core::option::Option::None,
+                SyntaxKind::EnumP => ::core::option::Option::None,
+                SyntaxKind::Escape => ::core::option::Option::None,
+                SyntaxKind::Event => ::core::option::Option::None,
+                SyntaxKind::Except => ::core::option::Option::None,
+                SyntaxKind::Exclude => ::core::option::Option::None,
+                SyntaxKind::Excluding => ::core::option::Option::None,
+                SyntaxKind::Exclusive => ::core::option::Option::None,
+                SyntaxKind::Execute => ::core::option::Option::None,
+                SyntaxKind::Exists => ::core::option::Option::None,
+                SyntaxKind::Explain => ::core::option::Option::None,
+                SyntaxKind::Expression => ::core::option::Option::None,
+                SyntaxKind::Extension => ::core::option::Option::None,
+                SyntaxKind::External => ::core::option::Option::None,
+                SyntaxKind::Extract => ::core::option::Option::None,
+                SyntaxKind::FalseP => ::core::option::Option::None,
+                SyntaxKind::Family => ::core::option::Option::None,
+                SyntaxKind::Fetch => ::core::option::Option::None,
+                SyntaxKind::Filter => ::core::option::Option::None,
+                SyntaxKind::Finalize => ::core::option::Option::None,
+                SyntaxKind::FirstP => ::core::option::Option::None,
+                SyntaxKind::FloatP => ::core::option::Option::None,
+                SyntaxKind::Following => ::core::option::Option::None,
+                SyntaxKind::For => ::core::option::Option::None,
+                SyntaxKind::Force => ::core::option::Option::None,
+                SyntaxKind::Foreign => ::core::option::Option::None,
+                SyntaxKind::Forward => ::core::option::Option::None,
+                SyntaxKind::Freeze => ::core::option::Option::None,
+                SyntaxKind::From => ::core::option::Option::None,
+                SyntaxKind::Full => ::core::option::Option::None,
+                SyntaxKind::Function => ::core::option::Option::None,
+                SyntaxKind::Functions => ::core::option::Option::None,
+                SyntaxKind::Generated => ::core::option::Option::None,
+                SyntaxKind::Global => ::core::option::Option::None,
+                SyntaxKind::Grant => ::core::option::Option::None,
+                SyntaxKind::Granted => ::core::option::Option::None,
+                SyntaxKind::Greatest => ::core::option::Option::None,
+                SyntaxKind::GroupP => ::core::option::Option::None,
+                SyntaxKind::Grouping => ::core::option::Option::None,
+                SyntaxKind::Groups => ::core::option::Option::None,
+                SyntaxKind::Handler => ::core::option::Option::None,
+                SyntaxKind::Having => ::core::option::Option::None,
+                SyntaxKind::HeaderP => ::core::option::Option::None,
+                SyntaxKind::Hold => ::core::option::Option::None,
+                SyntaxKind::HourP => ::core::option::Option::None,
+                SyntaxKind::IdentityP => ::core::option::Option::None,
+                SyntaxKind::IfP => ::core::option::Option::None,
+                SyntaxKind::Ilike => ::core::option::Option::None,
+                SyntaxKind::Immediate => ::core::option::Option::None,
+                SyntaxKind::Immutable => ::core::option::Option::None,
+                SyntaxKind::ImplicitP => ::core::option::Option::None,
+                SyntaxKind::ImportP => ::core::option::Option::None,
+                SyntaxKind::InP => ::core::option::Option::None,
+                SyntaxKind::Include => ::core::option::Option::None,
+                SyntaxKind::Including => ::core::option::Option::None,
+                SyntaxKind::Increment => ::core::option::Option::None,
+                SyntaxKind::Index => ::core::option::Option::None,
+                SyntaxKind::Indexes => ::core::option::Option::None,
+                SyntaxKind::Inherit => ::core::option::Option::None,
+                SyntaxKind::Inherits => ::core::option::Option::None,
+                SyntaxKind::Initially => ::core::option::Option::None,
+                SyntaxKind::InlineP => ::core::option::Option::None,
+                SyntaxKind::InnerP => ::core::option::Option::None,
+                SyntaxKind::Inout => ::core::option::Option::None,
+                SyntaxKind::InputP => ::core::option::Option::None,
+                SyntaxKind::Insensitive => ::core::option::Option::None,
+                SyntaxKind::Insert => ::core::option::Option::None,
+                SyntaxKind::Instead => ::core::option::Option::None,
+                SyntaxKind::IntP => ::core::option::Option::None,
+                SyntaxKind::Intersect => ::core::option::Option::None,
+                SyntaxKind::Interval => ::core::option::Option::None,
+                SyntaxKind::Into => ::core::option::Option::None,
+                SyntaxKind::Invoker => ::core::option::Option::None,
+                SyntaxKind::Is => ::core::option::Option::None,
+                SyntaxKind::Isnull => ::core::option::Option::None,
+                SyntaxKind::Isolation => ::core::option::Option::None,
+                SyntaxKind::Join => ::core::option::Option::None,
+                SyntaxKind::Key => ::core::option::Option::None,
+                SyntaxKind::Label => ::core::option::Option::None,
+                SyntaxKind::Language => ::core::option::Option::None,
+                SyntaxKind::LargeP => ::core::option::Option::None,
+                SyntaxKind::LastP => ::core::option::Option::None,
+                SyntaxKind::LateralP => ::core::option::Option::None,
+                SyntaxKind::Leading => ::core::option::Option::None,
+                SyntaxKind::Leakproof => ::core::option::Option::None,
+                SyntaxKind::Least => ::core::option::Option::None,
+                SyntaxKind::Left => ::core::option::Option::None,
+                SyntaxKind::Level => ::core::option::Option::None,
+                SyntaxKind::Like => ::core::option::Option::None,
+                SyntaxKind::Limit => ::core::option::Option::None,
+                SyntaxKind::Listen => ::core::option::Option::None,
+                SyntaxKind::Load => ::core::option::Option::None,
+                SyntaxKind::Local => ::core::option::Option::None,
+                SyntaxKind::Localtime => ::core::option::Option::None,
+                SyntaxKind::Localtimestamp => ::core::option::Option::None,
+                SyntaxKind::Location => ::core::option::Option::None,
+                SyntaxKind::LockP => ::core::option::Option::None,
+                SyntaxKind::Locked => ::core::option::Option::None,
+                SyntaxKind::Logged => ::core::option::Option::None,
+                SyntaxKind::Mapping => ::core::option::Option::None,
+                SyntaxKind::Match => ::core::option::Option::None,
+                SyntaxKind::Matched => ::core::option::Option::None,
+                SyntaxKind::Materialized => ::core::option::Option::None,
+                SyntaxKind::Maxvalue => ::core::option::Option::None,
+                SyntaxKind::Merge => ::core::option::Option::None,
+                SyntaxKind::Method => ::core::option::Option::None,
+                SyntaxKind::MinuteP => ::core::option::Option::None,
+                SyntaxKind::Minvalue => ::core::option::Option::None,
+                SyntaxKind::Mode => ::core::option::Option::None,
+                SyntaxKind::MonthP => ::core::option::Option::None,
+                SyntaxKind::Move => ::core::option::Option::None,
+                SyntaxKind::NameP => ::core::option::Option::None,
+                SyntaxKind::Names => ::core::option::Option::None,
+                SyntaxKind::National => ::core::option::Option::None,
+                SyntaxKind::Natural => ::core::option::Option::None,
+                SyntaxKind::Nchar => ::core::option::Option::None,
+                SyntaxKind::New => ::core::option::Option::None,
+                SyntaxKind::Next => ::core::option::Option::None,
+                SyntaxKind::Nfc => ::core::option::Option::None,
+                SyntaxKind::Nfd => ::core::option::Option::None,
+                SyntaxKind::Nfkc => ::core::option::Option::None,
+                SyntaxKind::Nfkd => ::core::option::Option::None,
+                SyntaxKind::No => ::core::option::Option::None,
+                SyntaxKind::None => ::core::option::Option::None,
+                SyntaxKind::Normalize => ::core::option::Option::None,
+                SyntaxKind::Normalized => ::core::option::Option::None,
+                SyntaxKind::Not => ::core::option::Option::None,
+                SyntaxKind::Nothing => ::core::option::Option::None,
+                SyntaxKind::Notify => ::core::option::Option::None,
+                SyntaxKind::Notnull => ::core::option::Option::None,
+                SyntaxKind::Nowait => ::core::option::Option::None,
+                SyntaxKind::NullP => ::core::option::Option::None,
+                SyntaxKind::Nullif => ::core::option::Option::None,
+                SyntaxKind::NullsP => ::core::option::Option::None,
+                SyntaxKind::Numeric => ::core::option::Option::None,
+                SyntaxKind::ObjectP => ::core::option::Option::None,
+                SyntaxKind::Of => ::core::option::Option::None,
+                SyntaxKind::Off => ::core::option::Option::None,
+                SyntaxKind::Offset => ::core::option::Option::None,
+                SyntaxKind::Oids => ::core::option::Option::None,
+                SyntaxKind::Old => ::core::option::Option::None,
+                SyntaxKind::On => ::core::option::Option::None,
+                SyntaxKind::Only => ::core::option::Option::None,
+                SyntaxKind::Operator => ::core::option::Option::None,
+                SyntaxKind::Option => ::core::option::Option::None,
+                SyntaxKind::Options => ::core::option::Option::None,
+                SyntaxKind::Or => ::core::option::Option::None,
+                SyntaxKind::Order => ::core::option::Option::None,
+                SyntaxKind::Ordinality => ::core::option::Option::None,
+                SyntaxKind::Others => ::core::option::Option::None,
+                SyntaxKind::OutP => ::core::option::Option::None,
+                SyntaxKind::OuterP => ::core::option::Option::None,
+                SyntaxKind::Over => ::core::option::Option::None,
+                SyntaxKind::Overlaps => ::core::option::Option::None,
+                SyntaxKind::Overlay => ::core::option::Option::None,
+                SyntaxKind::Overriding => ::core::option::Option::None,
+                SyntaxKind::Owned => ::core::option::Option::None,
+                SyntaxKind::Owner => ::core::option::Option::None,
+                SyntaxKind::Parallel => ::core::option::Option::None,
+                SyntaxKind::Parameter => ::core::option::Option::None,
+                SyntaxKind::Parser => ::core::option::Option::None,
+                SyntaxKind::Partial => ::core::option::Option::None,
+                SyntaxKind::Partition => ::core::option::Option::None,
+                SyntaxKind::Passing => ::core::option::Option::None,
+                SyntaxKind::Password => ::core::option::Option::None,
+                SyntaxKind::Placing => ::core::option::Option::None,
+                SyntaxKind::Plans => ::core::option::Option::None,
+                SyntaxKind::Policy => ::core::option::Option::None,
+                SyntaxKind::Position => ::core::option::Option::None,
+                SyntaxKind::Preceding => ::core::option::Option::None,
+                SyntaxKind::Precision => ::core::option::Option::None,
+                SyntaxKind::Preserve => ::core::option::Option::None,
+                SyntaxKind::Prepare => ::core::option::Option::None,
+                SyntaxKind::Prepared => ::core::option::Option::None,
+                SyntaxKind::Primary => ::core::option::Option::None,
+                SyntaxKind::Prior => ::core::option::Option::None,
+                SyntaxKind::Privileges => ::core::option::Option::None,
+                SyntaxKind::Procedural => ::core::option::Option::None,
+                SyntaxKind::Procedure => ::core::option::Option::None,
+                SyntaxKind::Procedures => ::core::option::Option::None,
+                SyntaxKind::Program => ::core::option::Option::None,
+                SyntaxKind::Publication => ::core::option::Option::None,
+                SyntaxKind::Quote => ::core::option::Option::None,
+                SyntaxKind::Range => ::core::option::Option::None,
+                SyntaxKind::Read => ::core::option::Option::None,
+                SyntaxKind::Real => ::core::option::Option::None,
+                SyntaxKind::Reassign => ::core::option::Option::None,
+                SyntaxKind::Recheck => ::core::option::Option::None,
+                SyntaxKind::Recursive => ::core::option::Option::None,
+                SyntaxKind::RefP => ::core::option::Option::None,
+                SyntaxKind::References => ::core::option::Option::None,
+                SyntaxKind::Referencing => ::core::option::Option::None,
+                SyntaxKind::Refresh => ::core::option::Option::None,
+                SyntaxKind::Reindex => ::core::option::Option::None,
+                SyntaxKind::RelativeP => ::core::option::Option::None,
+                SyntaxKind::Release => ::core::option::Option::None,
+                SyntaxKind::Rename => ::core::option::Option::None,
+                SyntaxKind::Repeatable => ::core::option::Option::None,
+                SyntaxKind::Replace => ::core::option::Option::None,
+                SyntaxKind::Replica => ::core::option::Option::None,
+                SyntaxKind::Reset => ::core::option::Option::None,
+                SyntaxKind::Restart => ::core::option::Option::None,
+                SyntaxKind::Restrict => ::core::option::Option::None,
+                SyntaxKind::Return => ::core::option::Option::None,
+                SyntaxKind::Returning => ::core::option::Option::None,
+                SyntaxKind::Returns => ::core::option::Option::None,
+                SyntaxKind::Revoke => ::core::option::Option::None,
+                SyntaxKind::Right => ::core::option::Option::None,
+                SyntaxKind::Role => ::core::option::Option::None,
+                SyntaxKind::Rollback => ::core::option::Option::None,
+                SyntaxKind::Rollup => ::core::option::Option::None,
+                SyntaxKind::Routine => ::core::option::Option::None,
+                SyntaxKind::Routines => ::core::option::Option::None,
+                SyntaxKind::Row => ::core::option::Option::None,
+                SyntaxKind::Rows => ::core::option::Option::None,
+                SyntaxKind::Rule => ::core::option::Option::None,
+                SyntaxKind::Savepoint => ::core::option::Option::None,
+                SyntaxKind::Schema => ::core::option::Option::None,
+                SyntaxKind::Schemas => ::core::option::Option::None,
+                SyntaxKind::Scroll => ::core::option::Option::None,
+                SyntaxKind::Search => ::core::option::Option::None,
+                SyntaxKind::SecondP => ::core::option::Option::None,
+                SyntaxKind::Security => ::core::option::Option::None,
+                SyntaxKind::Select => ::core::option::Option::None,
+                SyntaxKind::Sequence => ::core::option::Option::None,
+                SyntaxKind::Sequences => ::core::option::Option::None,
+                SyntaxKind::Serializable => ::core::option::Option::None,
+                SyntaxKind::Server => ::core::option::Option::None,
+                SyntaxKind::Session => ::core::option::Option::None,
+                SyntaxKind::SessionUser => ::core::option::Option::None,
+                SyntaxKind::Set => ::core::option::Option::None,
+                SyntaxKind::Sets => ::core::option::Option::None,
+                SyntaxKind::Setof => ::core::option::Option::None,
+                SyntaxKind::Share => ::core::option::Option::None,
+                SyntaxKind::Show => ::core::option::Option::None,
+                SyntaxKind::Similar => ::core::option::Option::None,
+                SyntaxKind::Simple => ::core::option::Option::None,
+                SyntaxKind::Skip => ::core::option::Option::None,
+                SyntaxKind::Smallint => ::core::option::Option::None,
+                SyntaxKind::Snapshot => ::core::option::Option::None,
+                SyntaxKind::Some => ::core::option::Option::None,
+                SyntaxKind::SqlP => ::core::option::Option::None,
+                SyntaxKind::Stable => ::core::option::Option::None,
+                SyntaxKind::StandaloneP => ::core::option::Option::None,
+                SyntaxKind::Start => ::core::option::Option::None,
+                SyntaxKind::Statement => ::core::option::Option::None,
+                SyntaxKind::Statistics => ::core::option::Option::None,
+                SyntaxKind::Stdin => ::core::option::Option::None,
+                SyntaxKind::Stdout => ::core::option::Option::None,
+                SyntaxKind::Storage => ::core::option::Option::None,
+                SyntaxKind::Stored => ::core::option::Option::None,
+                SyntaxKind::StrictP => ::core::option::Option::None,
+                SyntaxKind::StripP => ::core::option::Option::None,
+                SyntaxKind::Subscription => ::core::option::Option::None,
+                SyntaxKind::Substring => ::core::option::Option::None,
+                SyntaxKind::Support => ::core::option::Option::None,
+                SyntaxKind::Symmetric => ::core::option::Option::None,
+                SyntaxKind::Sysid => ::core::option::Option::None,
+                SyntaxKind::SystemP => ::core::option::Option::None,
+                SyntaxKind::Table => ::core::option::Option::None,
+                SyntaxKind::Tables => ::core::option::Option::None,
+                SyntaxKind::Tablesample => ::core::option::Option::None,
+                SyntaxKind::Tablespace => ::core::option::Option::None,
+                SyntaxKind::Temp => ::core::option::Option::None,
+                SyntaxKind::Template => ::core::option::Option::None,
+                SyntaxKind::Temporary => ::core::option::Option::None,
+                SyntaxKind::TextP => ::core::option::Option::None,
+                SyntaxKind::Then => ::core::option::Option::None,
+                SyntaxKind::Ties => ::core::option::Option::None,
+                SyntaxKind::Time => ::core::option::Option::None,
+                SyntaxKind::Timestamp => ::core::option::Option::None,
+                SyntaxKind::To => ::core::option::Option::None,
+                SyntaxKind::Trailing => ::core::option::Option::None,
+                SyntaxKind::Transaction => ::core::option::Option::None,
+                SyntaxKind::Transform => ::core::option::Option::None,
+                SyntaxKind::Treat => ::core::option::Option::None,
+                SyntaxKind::Trigger => ::core::option::Option::None,
+                SyntaxKind::Trim => ::core::option::Option::None,
+                SyntaxKind::TrueP => ::core::option::Option::None,
+                SyntaxKind::Truncate => ::core::option::Option::None,
+                SyntaxKind::Trusted => ::core::option::Option::None,
+                SyntaxKind::TypeP => ::core::option::Option::None,
+                SyntaxKind::TypesP => ::core::option::Option::None,
+                SyntaxKind::Uescape => ::core::option::Option::None,
+                SyntaxKind::Unbounded => ::core::option::Option::None,
+                SyntaxKind::Uncommitted => ::core::option::Option::None,
+                SyntaxKind::Unencrypted => ::core::option::Option::None,
+                SyntaxKind::Union => ::core::option::Option::None,
+                SyntaxKind::Unique => ::core::option::Option::None,
+                SyntaxKind::Unknown => ::core::option::Option::None,
+                SyntaxKind::Unlisten => ::core::option::Option::None,
+                SyntaxKind::Unlogged => ::core::option::Option::None,
+                SyntaxKind::Until => ::core::option::Option::None,
+                SyntaxKind::Update => ::core::option::Option::None,
+                SyntaxKind::User => ::core::option::Option::None,
+                SyntaxKind::Using => ::core::option::Option::None,
+                SyntaxKind::Vacuum => ::core::option::Option::None,
+                SyntaxKind::Valid => ::core::option::Option::None,
+                SyntaxKind::Validate => ::core::option::Option::None,
+                SyntaxKind::Validator => ::core::option::Option::None,
+                SyntaxKind::ValueP => ::core::option::Option::None,
+                SyntaxKind::Values => ::core::option::Option::None,
+                SyntaxKind::Varchar => ::core::option::Option::None,
+                SyntaxKind::Variadic => ::core::option::Option::None,
+                SyntaxKind::Varying => ::core::option::Option::None,
+                SyntaxKind::Verbose => ::core::option::Option::None,
+                SyntaxKind::VersionP => ::core::option::Option::None,
+                SyntaxKind::View => ::core::option::Option::None,
+                SyntaxKind::Views => ::core::option::Option::None,
+                SyntaxKind::Volatile => ::core::option::Option::None,
+                SyntaxKind::When => ::core::option::Option::None,
+                SyntaxKind::Where => ::core::option::Option::None,
+                SyntaxKind::WhitespaceP => ::core::option::Option::None,
+                SyntaxKind::Window => ::core::option::Option::None,
+                SyntaxKind::With => ::core::option::Option::None,
+                SyntaxKind::Within => ::core::option::Option::None,
+                SyntaxKind::Without => ::core::option::Option::None,
+                SyntaxKind::Work => ::core::option::Option::None,
+                SyntaxKind::Wrapper => ::core::option::Option::None,
+                SyntaxKind::Write => ::core::option::Option::None,
+                SyntaxKind::XmlP => ::core::option::Option::None,
+                SyntaxKind::Xmlattributes => ::core::option::Option::None,
+                SyntaxKind::Xmlconcat => ::core::option::Option::None,
+                SyntaxKind::Xmlelement => ::core::option::Option::None,
+                SyntaxKind::Xmlexists => ::core::option::Option::None,
+                SyntaxKind::Xmlforest => ::core::option::Option::None,
+                SyntaxKind::Xmlnamespaces => ::core::option::Option::None,
+                SyntaxKind::Xmlparse => ::core::option::Option::None,
+                SyntaxKind::Xmlpi => ::core::option::Option::None,
+                SyntaxKind::Xmlroot => ::core::option::Option::None,
+                SyntaxKind::Xmlserialize => ::core::option::Option::None,
+                SyntaxKind::Xmltable => ::core::option::Option::None,
+                SyntaxKind::YearP => ::core::option::Option::None,
+                SyntaxKind::YesP => ::core::option::Option::None,
+                SyntaxKind::Zone => ::core::option::Option::None,
+                SyntaxKind::NotLa => ::core::option::Option::None,
+                SyntaxKind::NullsLa => ::core::option::Option::None,
+                SyntaxKind::WithLa => ::core::option::Option::None,
+                SyntaxKind::ModeTypeName => ::core::option::Option::None,
+                SyntaxKind::ModePlpgsqlExpr => ::core::option::Option::None,
+                SyntaxKind::ModePlpgsqlAssign1 => ::core::option::Option::None,
+                SyntaxKind::ModePlpgsqlAssign2 => ::core::option::Option::None,
+                SyntaxKind::ModePlpgsqlAssign3 => ::core::option::Option::None,
+                SyntaxKind::Uminus => ::core::option::Option::None,
+            }
+        }
+    }
+    impl SyntaxKind {
+        /// Converts a `pg_query` node to a `SyntaxKind`
+        pub fn new_from_pg_query_node(node: &NodeEnum) -> Self {
+            match node {
+                NodeEnum::Alias(_) => SyntaxKind::Alias,
+                NodeEnum::RangeVar(_) => SyntaxKind::RangeVar,
+                NodeEnum::TableFunc(_) => SyntaxKind::TableFunc,
+                NodeEnum::Var(_) => SyntaxKind::Var,
+                NodeEnum::Param(_) => SyntaxKind::Param,
+                NodeEnum::Aggref(_) => SyntaxKind::Aggref,
+                NodeEnum::GroupingFunc(_) => SyntaxKind::GroupingFunc,
+                NodeEnum::WindowFunc(_) => SyntaxKind::WindowFunc,
+                NodeEnum::SubscriptingRef(_) => SyntaxKind::SubscriptingRef,
+                NodeEnum::FuncExpr(_) => SyntaxKind::FuncExpr,
+                NodeEnum::NamedArgExpr(_) => SyntaxKind::NamedArgExpr,
+                NodeEnum::OpExpr(_) => SyntaxKind::OpExpr,
+                NodeEnum::DistinctExpr(_) => SyntaxKind::DistinctExpr,
+                NodeEnum::NullIfExpr(_) => SyntaxKind::NullIfExpr,
+                NodeEnum::ScalarArrayOpExpr(_) => SyntaxKind::ScalarArrayOpExpr,
+                NodeEnum::BoolExpr(_) => SyntaxKind::BoolExpr,
+                NodeEnum::SubLink(_) => SyntaxKind::SubLink,
+                NodeEnum::SubPlan(_) => SyntaxKind::SubPlan,
+                NodeEnum::AlternativeSubPlan(_) => SyntaxKind::AlternativeSubPlan,
+                NodeEnum::FieldSelect(_) => SyntaxKind::FieldSelect,
+                NodeEnum::FieldStore(_) => SyntaxKind::FieldStore,
+                NodeEnum::RelabelType(_) => SyntaxKind::RelabelType,
+                NodeEnum::CoerceViaIo(_) => SyntaxKind::CoerceViaIo,
+                NodeEnum::ArrayCoerceExpr(_) => SyntaxKind::ArrayCoerceExpr,
+                NodeEnum::ConvertRowtypeExpr(_) => SyntaxKind::ConvertRowtypeExpr,
+                NodeEnum::CollateExpr(_) => SyntaxKind::CollateExpr,
+                NodeEnum::CaseExpr(_) => SyntaxKind::CaseExpr,
+                NodeEnum::CaseWhen(_) => SyntaxKind::CaseWhen,
+                NodeEnum::CaseTestExpr(_) => SyntaxKind::CaseTestExpr,
+                NodeEnum::ArrayExpr(_) => SyntaxKind::ArrayExpr,
+                NodeEnum::RowExpr(_) => SyntaxKind::RowExpr,
+                NodeEnum::RowCompareExpr(_) => SyntaxKind::RowCompareExpr,
+                NodeEnum::CoalesceExpr(_) => SyntaxKind::CoalesceExpr,
+                NodeEnum::MinMaxExpr(_) => SyntaxKind::MinMaxExpr,
+                NodeEnum::SqlvalueFunction(_) => SyntaxKind::SqlvalueFunction,
+                NodeEnum::XmlExpr(_) => SyntaxKind::XmlExpr,
+                NodeEnum::NullTest(_) => SyntaxKind::NullTest,
+                NodeEnum::BooleanTest(_) => SyntaxKind::BooleanTest,
+                NodeEnum::CoerceToDomain(_) => SyntaxKind::CoerceToDomain,
+                NodeEnum::CoerceToDomainValue(_) => SyntaxKind::CoerceToDomainValue,
+                NodeEnum::SetToDefault(_) => SyntaxKind::SetToDefault,
+                NodeEnum::CurrentOfExpr(_) => SyntaxKind::CurrentOfExpr,
+                NodeEnum::NextValueExpr(_) => SyntaxKind::NextValueExpr,
+                NodeEnum::InferenceElem(_) => SyntaxKind::InferenceElem,
+                NodeEnum::TargetEntry(_) => SyntaxKind::TargetEntry,
+                NodeEnum::RangeTblRef(_) => SyntaxKind::RangeTblRef,
+                NodeEnum::JoinExpr(_) => SyntaxKind::JoinExpr,
+                NodeEnum::FromExpr(_) => SyntaxKind::FromExpr,
+                NodeEnum::OnConflictExpr(_) => SyntaxKind::OnConflictExpr,
+                NodeEnum::IntoClause(_) => SyntaxKind::IntoClause,
+                NodeEnum::MergeAction(_) => SyntaxKind::MergeAction,
+                NodeEnum::RawStmt(_) => SyntaxKind::RawStmt,
+                NodeEnum::Query(_) => SyntaxKind::Query,
+                NodeEnum::InsertStmt(_) => SyntaxKind::InsertStmt,
+                NodeEnum::DeleteStmt(_) => SyntaxKind::DeleteStmt,
+                NodeEnum::UpdateStmt(_) => SyntaxKind::UpdateStmt,
+                NodeEnum::MergeStmt(_) => SyntaxKind::MergeStmt,
+                NodeEnum::SelectStmt(_) => SyntaxKind::SelectStmt,
+                NodeEnum::ReturnStmt(_) => SyntaxKind::ReturnStmt,
+                NodeEnum::PlassignStmt(_) => SyntaxKind::PlassignStmt,
+                NodeEnum::AlterTableStmt(_) => SyntaxKind::AlterTableStmt,
+                NodeEnum::AlterTableCmd(_) => SyntaxKind::AlterTableCmd,
+                NodeEnum::AlterDomainStmt(_) => SyntaxKind::AlterDomainStmt,
+                NodeEnum::SetOperationStmt(_) => SyntaxKind::SetOperationStmt,
+                NodeEnum::GrantStmt(_) => SyntaxKind::GrantStmt,
+                NodeEnum::GrantRoleStmt(_) => SyntaxKind::GrantRoleStmt,
+                NodeEnum::AlterDefaultPrivilegesStmt(_) => {
+                    SyntaxKind::AlterDefaultPrivilegesStmt
+                }
+                NodeEnum::ClosePortalStmt(_) => SyntaxKind::ClosePortalStmt,
+                NodeEnum::ClusterStmt(_) => SyntaxKind::ClusterStmt,
+                NodeEnum::CopyStmt(_) => SyntaxKind::CopyStmt,
+                NodeEnum::CreateStmt(_) => SyntaxKind::CreateStmt,
+                NodeEnum::DefineStmt(_) => SyntaxKind::DefineStmt,
+                NodeEnum::DropStmt(_) => SyntaxKind::DropStmt,
+                NodeEnum::TruncateStmt(_) => SyntaxKind::TruncateStmt,
+                NodeEnum::CommentStmt(_) => SyntaxKind::CommentStmt,
+                NodeEnum::FetchStmt(_) => SyntaxKind::FetchStmt,
+                NodeEnum::IndexStmt(_) => SyntaxKind::IndexStmt,
+                NodeEnum::CreateFunctionStmt(_) => SyntaxKind::CreateFunctionStmt,
+                NodeEnum::AlterFunctionStmt(_) => SyntaxKind::AlterFunctionStmt,
+                NodeEnum::DoStmt(_) => SyntaxKind::DoStmt,
+                NodeEnum::RenameStmt(_) => SyntaxKind::RenameStmt,
+                NodeEnum::RuleStmt(_) => SyntaxKind::RuleStmt,
+                NodeEnum::NotifyStmt(_) => SyntaxKind::NotifyStmt,
+                NodeEnum::ListenStmt(_) => SyntaxKind::ListenStmt,
+                NodeEnum::UnlistenStmt(_) => SyntaxKind::UnlistenStmt,
+                NodeEnum::TransactionStmt(_) => SyntaxKind::TransactionStmt,
+                NodeEnum::ViewStmt(_) => SyntaxKind::ViewStmt,
+                NodeEnum::LoadStmt(_) => SyntaxKind::LoadStmt,
+                NodeEnum::CreateDomainStmt(_) => SyntaxKind::CreateDomainStmt,
+                NodeEnum::CreatedbStmt(_) => SyntaxKind::CreatedbStmt,
+                NodeEnum::DropdbStmt(_) => SyntaxKind::DropdbStmt,
+                NodeEnum::VacuumStmt(_) => SyntaxKind::VacuumStmt,
+                NodeEnum::ExplainStmt(_) => SyntaxKind::ExplainStmt,
+                NodeEnum::CreateTableAsStmt(_) => SyntaxKind::CreateTableAsStmt,
+                NodeEnum::CreateSeqStmt(_) => SyntaxKind::CreateSeqStmt,
+                NodeEnum::AlterSeqStmt(_) => SyntaxKind::AlterSeqStmt,
+                NodeEnum::VariableSetStmt(_) => SyntaxKind::VariableSetStmt,
+                NodeEnum::VariableShowStmt(_) => SyntaxKind::VariableShowStmt,
+                NodeEnum::DiscardStmt(_) => SyntaxKind::DiscardStmt,
+                NodeEnum::CreateTrigStmt(_) => SyntaxKind::CreateTrigStmt,
+                NodeEnum::CreatePlangStmt(_) => SyntaxKind::CreatePlangStmt,
+                NodeEnum::CreateRoleStmt(_) => SyntaxKind::CreateRoleStmt,
+                NodeEnum::AlterRoleStmt(_) => SyntaxKind::AlterRoleStmt,
+                NodeEnum::DropRoleStmt(_) => SyntaxKind::DropRoleStmt,
+                NodeEnum::LockStmt(_) => SyntaxKind::LockStmt,
+                NodeEnum::ConstraintsSetStmt(_) => SyntaxKind::ConstraintsSetStmt,
+                NodeEnum::ReindexStmt(_) => SyntaxKind::ReindexStmt,
+                NodeEnum::CheckPointStmt(_) => SyntaxKind::CheckPointStmt,
+                NodeEnum::CreateSchemaStmt(_) => SyntaxKind::CreateSchemaStmt,
+                NodeEnum::AlterDatabaseStmt(_) => SyntaxKind::AlterDatabaseStmt,
+                NodeEnum::AlterDatabaseRefreshCollStmt(_) => {
+                    SyntaxKind::AlterDatabaseRefreshCollStmt
+                }
+                NodeEnum::AlterDatabaseSetStmt(_) => SyntaxKind::AlterDatabaseSetStmt,
+                NodeEnum::AlterRoleSetStmt(_) => SyntaxKind::AlterRoleSetStmt,
+                NodeEnum::CreateConversionStmt(_) => SyntaxKind::CreateConversionStmt,
+                NodeEnum::CreateCastStmt(_) => SyntaxKind::CreateCastStmt,
+                NodeEnum::CreateOpClassStmt(_) => SyntaxKind::CreateOpClassStmt,
+                NodeEnum::CreateOpFamilyStmt(_) => SyntaxKind::CreateOpFamilyStmt,
+                NodeEnum::AlterOpFamilyStmt(_) => SyntaxKind::AlterOpFamilyStmt,
+                NodeEnum::PrepareStmt(_) => SyntaxKind::PrepareStmt,
+                NodeEnum::ExecuteStmt(_) => SyntaxKind::ExecuteStmt,
+                NodeEnum::DeallocateStmt(_) => SyntaxKind::DeallocateStmt,
+                NodeEnum::DeclareCursorStmt(_) => SyntaxKind::DeclareCursorStmt,
+                NodeEnum::CreateTableSpaceStmt(_) => SyntaxKind::CreateTableSpaceStmt,
+                NodeEnum::DropTableSpaceStmt(_) => SyntaxKind::DropTableSpaceStmt,
+                NodeEnum::AlterObjectDependsStmt(_) => SyntaxKind::AlterObjectDependsStmt,
+                NodeEnum::AlterObjectSchemaStmt(_) => SyntaxKind::AlterObjectSchemaStmt,
+                NodeEnum::AlterOwnerStmt(_) => SyntaxKind::AlterOwnerStmt,
+                NodeEnum::AlterOperatorStmt(_) => SyntaxKind::AlterOperatorStmt,
+                NodeEnum::AlterTypeStmt(_) => SyntaxKind::AlterTypeStmt,
+                NodeEnum::DropOwnedStmt(_) => SyntaxKind::DropOwnedStmt,
+                NodeEnum::ReassignOwnedStmt(_) => SyntaxKind::ReassignOwnedStmt,
+                NodeEnum::CompositeTypeStmt(_) => SyntaxKind::CompositeTypeStmt,
+                NodeEnum::CreateEnumStmt(_) => SyntaxKind::CreateEnumStmt,
+                NodeEnum::CreateRangeStmt(_) => SyntaxKind::CreateRangeStmt,
+                NodeEnum::AlterEnumStmt(_) => SyntaxKind::AlterEnumStmt,
+                NodeEnum::AlterTsdictionaryStmt(_) => SyntaxKind::AlterTsdictionaryStmt,
+                NodeEnum::AlterTsconfigurationStmt(_) => {
+                    SyntaxKind::AlterTsconfigurationStmt
+                }
+                NodeEnum::CreateFdwStmt(_) => SyntaxKind::CreateFdwStmt,
+                NodeEnum::AlterFdwStmt(_) => SyntaxKind::AlterFdwStmt,
+                NodeEnum::CreateForeignServerStmt(_) => {
+                    SyntaxKind::CreateForeignServerStmt
+                }
+                NodeEnum::AlterForeignServerStmt(_) => SyntaxKind::AlterForeignServerStmt,
+                NodeEnum::CreateUserMappingStmt(_) => SyntaxKind::CreateUserMappingStmt,
+                NodeEnum::AlterUserMappingStmt(_) => SyntaxKind::AlterUserMappingStmt,
+                NodeEnum::DropUserMappingStmt(_) => SyntaxKind::DropUserMappingStmt,
+                NodeEnum::AlterTableSpaceOptionsStmt(_) => {
+                    SyntaxKind::AlterTableSpaceOptionsStmt
+                }
+                NodeEnum::AlterTableMoveAllStmt(_) => SyntaxKind::AlterTableMoveAllStmt,
+                NodeEnum::SecLabelStmt(_) => SyntaxKind::SecLabelStmt,
+                NodeEnum::CreateForeignTableStmt(_) => SyntaxKind::CreateForeignTableStmt,
+                NodeEnum::ImportForeignSchemaStmt(_) => {
+                    SyntaxKind::ImportForeignSchemaStmt
+                }
+                NodeEnum::CreateExtensionStmt(_) => SyntaxKind::CreateExtensionStmt,
+                NodeEnum::AlterExtensionStmt(_) => SyntaxKind::AlterExtensionStmt,
+                NodeEnum::AlterExtensionContentsStmt(_) => {
+                    SyntaxKind::AlterExtensionContentsStmt
+                }
+                NodeEnum::CreateEventTrigStmt(_) => SyntaxKind::CreateEventTrigStmt,
+                NodeEnum::AlterEventTrigStmt(_) => SyntaxKind::AlterEventTrigStmt,
+                NodeEnum::RefreshMatViewStmt(_) => SyntaxKind::RefreshMatViewStmt,
+                NodeEnum::ReplicaIdentityStmt(_) => SyntaxKind::ReplicaIdentityStmt,
+                NodeEnum::AlterSystemStmt(_) => SyntaxKind::AlterSystemStmt,
+                NodeEnum::CreatePolicyStmt(_) => SyntaxKind::CreatePolicyStmt,
+                NodeEnum::AlterPolicyStmt(_) => SyntaxKind::AlterPolicyStmt,
+                NodeEnum::CreateTransformStmt(_) => SyntaxKind::CreateTransformStmt,
+                NodeEnum::CreateAmStmt(_) => SyntaxKind::CreateAmStmt,
+                NodeEnum::CreatePublicationStmt(_) => SyntaxKind::CreatePublicationStmt,
+                NodeEnum::AlterPublicationStmt(_) => SyntaxKind::AlterPublicationStmt,
+                NodeEnum::CreateSubscriptionStmt(_) => SyntaxKind::CreateSubscriptionStmt,
+                NodeEnum::AlterSubscriptionStmt(_) => SyntaxKind::AlterSubscriptionStmt,
+                NodeEnum::DropSubscriptionStmt(_) => SyntaxKind::DropSubscriptionStmt,
+                NodeEnum::CreateStatsStmt(_) => SyntaxKind::CreateStatsStmt,
+                NodeEnum::AlterCollationStmt(_) => SyntaxKind::AlterCollationStmt,
+                NodeEnum::CallStmt(_) => SyntaxKind::CallStmt,
+                NodeEnum::AlterStatsStmt(_) => SyntaxKind::AlterStatsStmt,
+                NodeEnum::AExpr(_) => SyntaxKind::AExpr,
+                NodeEnum::ColumnRef(_) => SyntaxKind::ColumnRef,
+                NodeEnum::ParamRef(_) => SyntaxKind::ParamRef,
+                NodeEnum::FuncCall(_) => SyntaxKind::FuncCall,
+                NodeEnum::AStar(_) => SyntaxKind::AStar,
+                NodeEnum::AIndices(_) => SyntaxKind::AIndices,
+                NodeEnum::AIndirection(_) => SyntaxKind::AIndirection,
+                NodeEnum::AArrayExpr(_) => SyntaxKind::AArrayExpr,
+                NodeEnum::ResTarget(_) => SyntaxKind::ResTarget,
+                NodeEnum::MultiAssignRef(_) => SyntaxKind::MultiAssignRef,
+                NodeEnum::TypeCast(_) => SyntaxKind::TypeCast,
+                NodeEnum::CollateClause(_) => SyntaxKind::CollateClause,
+                NodeEnum::SortBy(_) => SyntaxKind::SortBy,
+                NodeEnum::WindowDef(_) => SyntaxKind::WindowDef,
+                NodeEnum::RangeSubselect(_) => SyntaxKind::RangeSubselect,
+                NodeEnum::RangeFunction(_) => SyntaxKind::RangeFunction,
+                NodeEnum::RangeTableSample(_) => SyntaxKind::RangeTableSample,
+                NodeEnum::RangeTableFunc(_) => SyntaxKind::RangeTableFunc,
+                NodeEnum::RangeTableFuncCol(_) => SyntaxKind::RangeTableFuncCol,
+                NodeEnum::TypeName(_) => SyntaxKind::TypeName,
+                NodeEnum::ColumnDef(_) => SyntaxKind::ColumnDef,
+                NodeEnum::IndexElem(_) => SyntaxKind::IndexElem,
+                NodeEnum::StatsElem(_) => SyntaxKind::StatsElem,
+                NodeEnum::Constraint(_) => SyntaxKind::Constraint,
+                NodeEnum::DefElem(_) => SyntaxKind::DefElem,
+                NodeEnum::RangeTblEntry(_) => SyntaxKind::RangeTblEntry,
+                NodeEnum::RangeTblFunction(_) => SyntaxKind::RangeTblFunction,
+                NodeEnum::TableSampleClause(_) => SyntaxKind::TableSampleClause,
+                NodeEnum::WithCheckOption(_) => SyntaxKind::WithCheckOption,
+                NodeEnum::SortGroupClause(_) => SyntaxKind::SortGroupClause,
+                NodeEnum::GroupingSet(_) => SyntaxKind::GroupingSet,
+                NodeEnum::WindowClause(_) => SyntaxKind::WindowClause,
+                NodeEnum::ObjectWithArgs(_) => SyntaxKind::ObjectWithArgs,
+                NodeEnum::AccessPriv(_) => SyntaxKind::AccessPriv,
+                NodeEnum::CreateOpClassItem(_) => SyntaxKind::CreateOpClassItem,
+                NodeEnum::TableLikeClause(_) => SyntaxKind::TableLikeClause,
+                NodeEnum::FunctionParameter(_) => SyntaxKind::FunctionParameter,
+                NodeEnum::LockingClause(_) => SyntaxKind::LockingClause,
+                NodeEnum::RowMarkClause(_) => SyntaxKind::RowMarkClause,
+                NodeEnum::XmlSerialize(_) => SyntaxKind::XmlSerialize,
+                NodeEnum::WithClause(_) => SyntaxKind::WithClause,
+                NodeEnum::InferClause(_) => SyntaxKind::InferClause,
+                NodeEnum::OnConflictClause(_) => SyntaxKind::OnConflictClause,
+                NodeEnum::CtesearchClause(_) => SyntaxKind::CtesearchClause,
+                NodeEnum::CtecycleClause(_) => SyntaxKind::CtecycleClause,
+                NodeEnum::CommonTableExpr(_) => SyntaxKind::CommonTableExpr,
+                NodeEnum::MergeWhenClause(_) => SyntaxKind::MergeWhenClause,
+                NodeEnum::RoleSpec(_) => SyntaxKind::RoleSpec,
+                NodeEnum::TriggerTransition(_) => SyntaxKind::TriggerTransition,
+                NodeEnum::PartitionElem(_) => SyntaxKind::PartitionElem,
+                NodeEnum::PartitionSpec(_) => SyntaxKind::PartitionSpec,
+                NodeEnum::PartitionBoundSpec(_) => SyntaxKind::PartitionBoundSpec,
+                NodeEnum::PartitionRangeDatum(_) => SyntaxKind::PartitionRangeDatum,
+                NodeEnum::PartitionCmd(_) => SyntaxKind::PartitionCmd,
+                NodeEnum::VacuumRelation(_) => SyntaxKind::VacuumRelation,
+                NodeEnum::PublicationObjSpec(_) => SyntaxKind::PublicationObjSpec,
+                NodeEnum::PublicationTable(_) => SyntaxKind::PublicationTable,
+                NodeEnum::InlineCodeBlock(_) => SyntaxKind::InlineCodeBlock,
+                NodeEnum::CallContext(_) => SyntaxKind::CallContext,
+                NodeEnum::Integer(_) => SyntaxKind::Integer,
+                NodeEnum::Float(_) => SyntaxKind::Float,
+                NodeEnum::Boolean(_) => SyntaxKind::Boolean,
+                NodeEnum::String(_) => SyntaxKind::String,
+                NodeEnum::BitString(_) => SyntaxKind::BitString,
+                NodeEnum::List(_) => SyntaxKind::List,
+                NodeEnum::IntList(_) => SyntaxKind::IntList,
+                NodeEnum::OidList(_) => SyntaxKind::OidList,
+                NodeEnum::AConst(_) => SyntaxKind::AConst,
+            }
+        }
+        /// Converts a `pg_query` token to a `SyntaxKind`
+        pub fn new_from_pg_query_token(token: &ScanToken) -> Self {
+            match token.token {
+                0 => SyntaxKind::Nul,
+                37 => SyntaxKind::Ascii37,
+                40 => SyntaxKind::Ascii40,
+                41 => SyntaxKind::Ascii41,
+                42 => SyntaxKind::Ascii42,
+                43 => SyntaxKind::Ascii43,
+                44 => SyntaxKind::Ascii44,
+                45 => SyntaxKind::Ascii45,
+                46 => SyntaxKind::Ascii46,
+                47 => SyntaxKind::Ascii47,
+                58 => SyntaxKind::Ascii58,
+                59 => SyntaxKind::Ascii59,
+                60 => SyntaxKind::Ascii60,
+                61 => SyntaxKind::Ascii61,
+                62 => SyntaxKind::Ascii62,
+                63 => SyntaxKind::Ascii63,
+                91 => SyntaxKind::Ascii91,
+                92 => SyntaxKind::Ascii92,
+                93 => SyntaxKind::Ascii93,
+                94 => SyntaxKind::Ascii94,
+                258 => SyntaxKind::Ident,
+                259 => SyntaxKind::Uident,
+                260 => SyntaxKind::Fconst,
+                261 => SyntaxKind::Sconst,
+                262 => SyntaxKind::Usconst,
+                263 => SyntaxKind::Bconst,
+                264 => SyntaxKind::Xconst,
+                265 => SyntaxKind::Op,
+                266 => SyntaxKind::Iconst,
+                268 => SyntaxKind::Typecast,
+                269 => SyntaxKind::DotDot,
+                270 => SyntaxKind::ColonEquals,
+                271 => SyntaxKind::EqualsGreater,
+                272 => SyntaxKind::LessEquals,
+                273 => SyntaxKind::GreaterEquals,
+                274 => SyntaxKind::NotEquals,
+                275 => SyntaxKind::SqlComment,
+                276 => SyntaxKind::CComment,
+                277 => SyntaxKind::AbortP,
+                278 => SyntaxKind::AbsoluteP,
+                279 => SyntaxKind::Access,
+                280 => SyntaxKind::Action,
+                281 => SyntaxKind::AddP,
+                282 => SyntaxKind::Admin,
+                283 => SyntaxKind::After,
+                284 => SyntaxKind::Aggregate,
+                285 => SyntaxKind::All,
+                286 => SyntaxKind::Also,
+                287 => SyntaxKind::Alter,
+                288 => SyntaxKind::Always,
+                289 => SyntaxKind::Analyse,
+                290 => SyntaxKind::Analyze,
+                291 => SyntaxKind::And,
+                292 => SyntaxKind::Any,
+                293 => SyntaxKind::Array,
+                294 => SyntaxKind::As,
+                295 => SyntaxKind::Asc,
+                296 => SyntaxKind::Asensitive,
+                297 => SyntaxKind::Assertion,
+                298 => SyntaxKind::Assignment,
+                299 => SyntaxKind::Asymmetric,
+                300 => SyntaxKind::Atomic,
+                301 => SyntaxKind::At,
+                302 => SyntaxKind::Attach,
+                303 => SyntaxKind::Attribute,
+                304 => SyntaxKind::Authorization,
+                305 => SyntaxKind::Backward,
+                306 => SyntaxKind::Before,
+                307 => SyntaxKind::BeginP,
+                308 => SyntaxKind::Between,
+                309 => SyntaxKind::Bigint,
+                310 => SyntaxKind::Binary,
+                311 => SyntaxKind::Bit,
+                312 => SyntaxKind::BooleanP,
+                313 => SyntaxKind::Both,
+                314 => SyntaxKind::Breadth,
+                315 => SyntaxKind::By,
+                316 => SyntaxKind::Cache,
+                317 => SyntaxKind::Call,
+                318 => SyntaxKind::Called,
+                319 => SyntaxKind::Cascade,
+                320 => SyntaxKind::Cascaded,
+                321 => SyntaxKind::Case,
+                322 => SyntaxKind::Cast,
+                323 => SyntaxKind::CatalogP,
+                324 => SyntaxKind::Chain,
+                325 => SyntaxKind::CharP,
+                326 => SyntaxKind::Character,
+                327 => SyntaxKind::Characteristics,
+                328 => SyntaxKind::Check,
+                329 => SyntaxKind::Checkpoint,
+                330 => SyntaxKind::Class,
+                331 => SyntaxKind::Close,
+                332 => SyntaxKind::Cluster,
+                333 => SyntaxKind::Coalesce,
+                334 => SyntaxKind::Collate,
+                335 => SyntaxKind::Collation,
+                336 => SyntaxKind::Column,
+                337 => SyntaxKind::Columns,
+                339 => SyntaxKind::Comments,
+                340 => SyntaxKind::Commit,
+                341 => SyntaxKind::Committed,
+                342 => SyntaxKind::Compression,
+                343 => SyntaxKind::Concurrently,
+                344 => SyntaxKind::Configuration,
+                345 => SyntaxKind::Conflict,
+                346 => SyntaxKind::Connection,
+                348 => SyntaxKind::Constraints,
+                349 => SyntaxKind::ContentP,
+                350 => SyntaxKind::ContinueP,
+                351 => SyntaxKind::ConversionP,
+                352 => SyntaxKind::Copy,
+                353 => SyntaxKind::Cost,
+                354 => SyntaxKind::Create,
+                355 => SyntaxKind::Cross,
+                356 => SyntaxKind::Csv,
+                357 => SyntaxKind::Cube,
+                358 => SyntaxKind::CurrentP,
+                359 => SyntaxKind::CurrentCatalog,
+                360 => SyntaxKind::CurrentDate,
+                361 => SyntaxKind::CurrentRole,
+                362 => SyntaxKind::CurrentSchema,
+                363 => SyntaxKind::CurrentTime,
+                364 => SyntaxKind::CurrentTimestamp,
+                365 => SyntaxKind::CurrentUser,
+                366 => SyntaxKind::Cursor,
+                367 => SyntaxKind::Cycle,
+                368 => SyntaxKind::DataP,
+                369 => SyntaxKind::Database,
+                370 => SyntaxKind::DayP,
+                371 => SyntaxKind::Deallocate,
+                372 => SyntaxKind::Dec,
+                373 => SyntaxKind::DecimalP,
+                374 => SyntaxKind::Declare,
+                375 => SyntaxKind::Default,
+                376 => SyntaxKind::Defaults,
+                377 => SyntaxKind::Deferrable,
+                378 => SyntaxKind::Deferred,
+                379 => SyntaxKind::Definer,
+                380 => SyntaxKind::DeleteP,
+                381 => SyntaxKind::Delimiter,
+                382 => SyntaxKind::Delimiters,
+                383 => SyntaxKind::Depends,
+                384 => SyntaxKind::Depth,
+                385 => SyntaxKind::Desc,
+                386 => SyntaxKind::Detach,
+                387 => SyntaxKind::Dictionary,
+                388 => SyntaxKind::DisableP,
+                389 => SyntaxKind::Discard,
+                390 => SyntaxKind::Distinct,
+                391 => SyntaxKind::Do,
+                392 => SyntaxKind::DocumentP,
+                393 => SyntaxKind::DomainP,
+                394 => SyntaxKind::DoubleP,
+                395 => SyntaxKind::Drop,
+                396 => SyntaxKind::Each,
+                397 => SyntaxKind::Else,
+                398 => SyntaxKind::EnableP,
+                399 => SyntaxKind::Encoding,
+                400 => SyntaxKind::Encrypted,
+                401 => SyntaxKind::EndP,
+                402 => SyntaxKind::EnumP,
+                403 => SyntaxKind::Escape,
+                404 => SyntaxKind::Event,
+                405 => SyntaxKind::Except,
+                406 => SyntaxKind::Exclude,
+                407 => SyntaxKind::Excluding,
+                408 => SyntaxKind::Exclusive,
+                409 => SyntaxKind::Execute,
+                410 => SyntaxKind::Exists,
+                411 => SyntaxKind::Explain,
+                412 => SyntaxKind::Expression,
+                413 => SyntaxKind::Extension,
+                414 => SyntaxKind::External,
+                415 => SyntaxKind::Extract,
+                416 => SyntaxKind::FalseP,
+                417 => SyntaxKind::Family,
+                418 => SyntaxKind::Fetch,
+                419 => SyntaxKind::Filter,
+                420 => SyntaxKind::Finalize,
+                421 => SyntaxKind::FirstP,
+                422 => SyntaxKind::FloatP,
+                423 => SyntaxKind::Following,
+                424 => SyntaxKind::For,
+                425 => SyntaxKind::Force,
+                426 => SyntaxKind::Foreign,
+                427 => SyntaxKind::Forward,
+                428 => SyntaxKind::Freeze,
+                429 => SyntaxKind::From,
+                430 => SyntaxKind::Full,
+                431 => SyntaxKind::Function,
+                432 => SyntaxKind::Functions,
+                433 => SyntaxKind::Generated,
+                434 => SyntaxKind::Global,
+                435 => SyntaxKind::Grant,
+                436 => SyntaxKind::Granted,
+                437 => SyntaxKind::Greatest,
+                438 => SyntaxKind::GroupP,
+                439 => SyntaxKind::Grouping,
+                440 => SyntaxKind::Groups,
+                441 => SyntaxKind::Handler,
+                442 => SyntaxKind::Having,
+                443 => SyntaxKind::HeaderP,
+                444 => SyntaxKind::Hold,
+                445 => SyntaxKind::HourP,
+                446 => SyntaxKind::IdentityP,
+                447 => SyntaxKind::IfP,
+                448 => SyntaxKind::Ilike,
+                449 => SyntaxKind::Immediate,
+                450 => SyntaxKind::Immutable,
+                451 => SyntaxKind::ImplicitP,
+                452 => SyntaxKind::ImportP,
+                453 => SyntaxKind::InP,
+                454 => SyntaxKind::Include,
+                455 => SyntaxKind::Including,
+                456 => SyntaxKind::Increment,
+                457 => SyntaxKind::Index,
+                458 => SyntaxKind::Indexes,
+                459 => SyntaxKind::Inherit,
+                460 => SyntaxKind::Inherits,
+                461 => SyntaxKind::Initially,
+                462 => SyntaxKind::InlineP,
+                463 => SyntaxKind::InnerP,
+                464 => SyntaxKind::Inout,
+                465 => SyntaxKind::InputP,
+                466 => SyntaxKind::Insensitive,
+                467 => SyntaxKind::Insert,
+                468 => SyntaxKind::Instead,
+                469 => SyntaxKind::IntP,
+                471 => SyntaxKind::Intersect,
+                472 => SyntaxKind::Interval,
+                473 => SyntaxKind::Into,
+                474 => SyntaxKind::Invoker,
+                475 => SyntaxKind::Is,
+                476 => SyntaxKind::Isnull,
+                477 => SyntaxKind::Isolation,
+                478 => SyntaxKind::Join,
+                479 => SyntaxKind::Key,
+                480 => SyntaxKind::Label,
+                481 => SyntaxKind::Language,
+                482 => SyntaxKind::LargeP,
+                483 => SyntaxKind::LastP,
+                484 => SyntaxKind::LateralP,
+                485 => SyntaxKind::Leading,
+                486 => SyntaxKind::Leakproof,
+                487 => SyntaxKind::Least,
+                488 => SyntaxKind::Left,
+                489 => SyntaxKind::Level,
+                490 => SyntaxKind::Like,
+                491 => SyntaxKind::Limit,
+                492 => SyntaxKind::Listen,
+                493 => SyntaxKind::Load,
+                494 => SyntaxKind::Local,
+                495 => SyntaxKind::Localtime,
+                496 => SyntaxKind::Localtimestamp,
+                497 => SyntaxKind::Location,
+                498 => SyntaxKind::LockP,
+                499 => SyntaxKind::Locked,
+                500 => SyntaxKind::Logged,
+                501 => SyntaxKind::Mapping,
+                502 => SyntaxKind::Match,
+                503 => SyntaxKind::Matched,
+                504 => SyntaxKind::Materialized,
+                505 => SyntaxKind::Maxvalue,
+                506 => SyntaxKind::Merge,
+                507 => SyntaxKind::Method,
+                508 => SyntaxKind::MinuteP,
+                509 => SyntaxKind::Minvalue,
+                510 => SyntaxKind::Mode,
+                511 => SyntaxKind::MonthP,
+                512 => SyntaxKind::Move,
+                513 => SyntaxKind::NameP,
+                514 => SyntaxKind::Names,
+                515 => SyntaxKind::National,
+                516 => SyntaxKind::Natural,
+                517 => SyntaxKind::Nchar,
+                518 => SyntaxKind::New,
+                519 => SyntaxKind::Next,
+                520 => SyntaxKind::Nfc,
+                521 => SyntaxKind::Nfd,
+                522 => SyntaxKind::Nfkc,
+                523 => SyntaxKind::Nfkd,
+                524 => SyntaxKind::No,
+                525 => SyntaxKind::None,
+                526 => SyntaxKind::Normalize,
+                527 => SyntaxKind::Normalized,
+                528 => SyntaxKind::Not,
+                529 => SyntaxKind::Nothing,
+                530 => SyntaxKind::Notify,
+                531 => SyntaxKind::Notnull,
+                532 => SyntaxKind::Nowait,
+                533 => SyntaxKind::NullP,
+                534 => SyntaxKind::Nullif,
+                535 => SyntaxKind::NullsP,
+                536 => SyntaxKind::Numeric,
+                537 => SyntaxKind::ObjectP,
+                538 => SyntaxKind::Of,
+                539 => SyntaxKind::Off,
+                540 => SyntaxKind::Offset,
+                541 => SyntaxKind::Oids,
+                542 => SyntaxKind::Old,
+                543 => SyntaxKind::On,
+                544 => SyntaxKind::Only,
+                545 => SyntaxKind::Operator,
+                546 => SyntaxKind::Option,
+                547 => SyntaxKind::Options,
+                548 => SyntaxKind::Or,
+                549 => SyntaxKind::Order,
+                550 => SyntaxKind::Ordinality,
+                551 => SyntaxKind::Others,
+                552 => SyntaxKind::OutP,
+                553 => SyntaxKind::OuterP,
+                554 => SyntaxKind::Over,
+                555 => SyntaxKind::Overlaps,
+                556 => SyntaxKind::Overlay,
+                557 => SyntaxKind::Overriding,
+                558 => SyntaxKind::Owned,
+                559 => SyntaxKind::Owner,
+                560 => SyntaxKind::Parallel,
+                561 => SyntaxKind::Parameter,
+                562 => SyntaxKind::Parser,
+                563 => SyntaxKind::Partial,
+                564 => SyntaxKind::Partition,
+                565 => SyntaxKind::Passing,
+                566 => SyntaxKind::Password,
+                567 => SyntaxKind::Placing,
+                568 => SyntaxKind::Plans,
+                569 => SyntaxKind::Policy,
+                570 => SyntaxKind::Position,
+                571 => SyntaxKind::Preceding,
+                572 => SyntaxKind::Precision,
+                573 => SyntaxKind::Preserve,
+                574 => SyntaxKind::Prepare,
+                575 => SyntaxKind::Prepared,
+                576 => SyntaxKind::Primary,
+                577 => SyntaxKind::Prior,
+                578 => SyntaxKind::Privileges,
+                579 => SyntaxKind::Procedural,
+                580 => SyntaxKind::Procedure,
+                581 => SyntaxKind::Procedures,
+                582 => SyntaxKind::Program,
+                583 => SyntaxKind::Publication,
+                584 => SyntaxKind::Quote,
+                585 => SyntaxKind::Range,
+                586 => SyntaxKind::Read,
+                587 => SyntaxKind::Real,
+                588 => SyntaxKind::Reassign,
+                589 => SyntaxKind::Recheck,
+                590 => SyntaxKind::Recursive,
+                591 => SyntaxKind::RefP,
+                592 => SyntaxKind::References,
+                593 => SyntaxKind::Referencing,
+                594 => SyntaxKind::Refresh,
+                595 => SyntaxKind::Reindex,
+                596 => SyntaxKind::RelativeP,
+                597 => SyntaxKind::Release,
+                598 => SyntaxKind::Rename,
+                599 => SyntaxKind::Repeatable,
+                600 => SyntaxKind::Replace,
+                601 => SyntaxKind::Replica,
+                602 => SyntaxKind::Reset,
+                603 => SyntaxKind::Restart,
+                604 => SyntaxKind::Restrict,
+                605 => SyntaxKind::Return,
+                606 => SyntaxKind::Returning,
+                607 => SyntaxKind::Returns,
+                608 => SyntaxKind::Revoke,
+                609 => SyntaxKind::Right,
+                610 => SyntaxKind::Role,
+                611 => SyntaxKind::Rollback,
+                612 => SyntaxKind::Rollup,
+                613 => SyntaxKind::Routine,
+                614 => SyntaxKind::Routines,
+                615 => SyntaxKind::Row,
+                616 => SyntaxKind::Rows,
+                617 => SyntaxKind::Rule,
+                618 => SyntaxKind::Savepoint,
+                619 => SyntaxKind::Schema,
+                620 => SyntaxKind::Schemas,
+                621 => SyntaxKind::Scroll,
+                622 => SyntaxKind::Search,
+                623 => SyntaxKind::SecondP,
+                624 => SyntaxKind::Security,
+                625 => SyntaxKind::Select,
+                626 => SyntaxKind::Sequence,
+                627 => SyntaxKind::Sequences,
+                628 => SyntaxKind::Serializable,
+                629 => SyntaxKind::Server,
+                630 => SyntaxKind::Session,
+                631 => SyntaxKind::SessionUser,
+                632 => SyntaxKind::Set,
+                633 => SyntaxKind::Sets,
+                634 => SyntaxKind::Setof,
+                635 => SyntaxKind::Share,
+                636 => SyntaxKind::Show,
+                637 => SyntaxKind::Similar,
+                638 => SyntaxKind::Simple,
+                639 => SyntaxKind::Skip,
+                640 => SyntaxKind::Smallint,
+                641 => SyntaxKind::Snapshot,
+                642 => SyntaxKind::Some,
+                643 => SyntaxKind::SqlP,
+                644 => SyntaxKind::Stable,
+                645 => SyntaxKind::StandaloneP,
+                646 => SyntaxKind::Start,
+                647 => SyntaxKind::Statement,
+                648 => SyntaxKind::Statistics,
+                649 => SyntaxKind::Stdin,
+                650 => SyntaxKind::Stdout,
+                651 => SyntaxKind::Storage,
+                652 => SyntaxKind::Stored,
+                653 => SyntaxKind::StrictP,
+                654 => SyntaxKind::StripP,
+                655 => SyntaxKind::Subscription,
+                656 => SyntaxKind::Substring,
+                657 => SyntaxKind::Support,
+                658 => SyntaxKind::Symmetric,
+                659 => SyntaxKind::Sysid,
+                660 => SyntaxKind::SystemP,
+                661 => SyntaxKind::Table,
+                662 => SyntaxKind::Tables,
+                663 => SyntaxKind::Tablesample,
+                664 => SyntaxKind::Tablespace,
+                665 => SyntaxKind::Temp,
+                666 => SyntaxKind::Template,
+                667 => SyntaxKind::Temporary,
+                668 => SyntaxKind::TextP,
+                669 => SyntaxKind::Then,
+                670 => SyntaxKind::Ties,
+                671 => SyntaxKind::Time,
+                672 => SyntaxKind::Timestamp,
+                673 => SyntaxKind::To,
+                674 => SyntaxKind::Trailing,
+                675 => SyntaxKind::Transaction,
+                676 => SyntaxKind::Transform,
+                677 => SyntaxKind::Treat,
+                678 => SyntaxKind::Trigger,
+                679 => SyntaxKind::Trim,
+                680 => SyntaxKind::TrueP,
+                681 => SyntaxKind::Truncate,
+                682 => SyntaxKind::Trusted,
+                683 => SyntaxKind::TypeP,
+                684 => SyntaxKind::TypesP,
+                685 => SyntaxKind::Uescape,
+                686 => SyntaxKind::Unbounded,
+                687 => SyntaxKind::Uncommitted,
+                688 => SyntaxKind::Unencrypted,
+                689 => SyntaxKind::Union,
+                690 => SyntaxKind::Unique,
+                691 => SyntaxKind::Unknown,
+                692 => SyntaxKind::Unlisten,
+                693 => SyntaxKind::Unlogged,
+                694 => SyntaxKind::Until,
+                695 => SyntaxKind::Update,
+                696 => SyntaxKind::User,
+                697 => SyntaxKind::Using,
+                698 => SyntaxKind::Vacuum,
+                699 => SyntaxKind::Valid,
+                700 => SyntaxKind::Validate,
+                701 => SyntaxKind::Validator,
+                702 => SyntaxKind::ValueP,
+                703 => SyntaxKind::Values,
+                704 => SyntaxKind::Varchar,
+                705 => SyntaxKind::Variadic,
+                706 => SyntaxKind::Varying,
+                707 => SyntaxKind::Verbose,
+                708 => SyntaxKind::VersionP,
+                709 => SyntaxKind::View,
+                710 => SyntaxKind::Views,
+                711 => SyntaxKind::Volatile,
+                712 => SyntaxKind::When,
+                713 => SyntaxKind::Where,
+                714 => SyntaxKind::WhitespaceP,
+                715 => SyntaxKind::Window,
+                716 => SyntaxKind::With,
+                717 => SyntaxKind::Within,
+                718 => SyntaxKind::Without,
+                719 => SyntaxKind::Work,
+                720 => SyntaxKind::Wrapper,
+                721 => SyntaxKind::Write,
+                722 => SyntaxKind::XmlP,
+                723 => SyntaxKind::Xmlattributes,
+                724 => SyntaxKind::Xmlconcat,
+                725 => SyntaxKind::Xmlelement,
+                726 => SyntaxKind::Xmlexists,
+                727 => SyntaxKind::Xmlforest,
+                728 => SyntaxKind::Xmlnamespaces,
+                729 => SyntaxKind::Xmlparse,
+                730 => SyntaxKind::Xmlpi,
+                731 => SyntaxKind::Xmlroot,
+                732 => SyntaxKind::Xmlserialize,
+                733 => SyntaxKind::Xmltable,
+                734 => SyntaxKind::YearP,
+                735 => SyntaxKind::YesP,
+                736 => SyntaxKind::Zone,
+                737 => SyntaxKind::NotLa,
+                738 => SyntaxKind::NullsLa,
+                739 => SyntaxKind::WithLa,
+                740 => SyntaxKind::ModeTypeName,
+                741 => SyntaxKind::ModePlpgsqlExpr,
+                742 => SyntaxKind::ModePlpgsqlAssign1,
+                743 => SyntaxKind::ModePlpgsqlAssign2,
+                744 => SyntaxKind::ModePlpgsqlAssign3,
+                745 => SyntaxKind::Uminus,
+                _ => {
+                    ::core::panicking::panic_fmt(format_args!("Unknown token"));
+                }
+            }
+        }
+    }
+}
diff --git a/crates/codegen/src/get_children.rs b/crates/codegen/src/get_children.rs
new file mode 100644
index 00000000..f3d78207
--- /dev/null
+++ b/crates/codegen/src/get_children.rs
@@ -0,0 +1,133 @@
+// use pg_query_proto_parser::{FieldType, Node, ProtoParser};
+// use proc_macro2::{Ident, TokenStream};
+// use quote::{format_ident, quote};
+//
+// // todo: get_children should only return a Vec<NestedNode> with location being an Option<i32>
+// // we then pass the results into a resolve_locations function that takes a Vec<NestedNode> and returns a Vec<NestedNode>, but where location is an i32
+//
+// pub fn get_children_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
+//     let parser = ProtoParser::new("./libpg_query/protobuf/pg_query.proto");
+//     let proto_file = parser.parse();
+//
+//     let manual_node_names = manual_node_names();
+//
+//     let node_identifiers = node_identifiers(&proto_file.nodes, &manual_node_names);
+//     let node_handlers = node_handlers(&proto_file.nodes, &manual_node_names);
+//
+//     quote! {
+//         use pg_query::NodeEnum;
+//         use std::collections::VecDeque;
+//
+//         #[derive(Debug, Clone)]
+//         pub struct ChildrenNode {
+//             pub node: NodeEnum,
+//             pub depth: i32,
+//             pub location: Option<i32>,
+//             pub path: String,
+//         }
+//
+//         /// Returns all children of the node, recursively
+//         pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<ChildrenNode> {
+//             let mut nodes: Vec<ChildrenNode> = vec![];
+//             // Node, depth, path
+//             let mut stack: VecDeque<(NodeEnum, i32, String)> =
+//                 VecDeque::from(vec![(node.to_owned(), current_depth, "0".to_string())]);
+//             while !stack.is_empty() {
+//                 let (node, depth, path) = stack.pop_front().unwrap();
+//                 let current_depth = depth + 1;
+//                 let mut child_ctr: i32 = 0;
+//                 let mut handle_child = |c: NodeEnum| {
+//                     let location = get_location(&c);
+//                     let path = path.clone() + "." + child_ctr.to_string().as_str();
+//                     child_ctr = child_ctr + 1;
+//                     stack.push_back((c.to_owned(), current_depth, path.clone()));
+//                     nodes.push(ChildrenNode {
+//                         node: c,
+//                         depth: current_depth,
+//                         location,
+//                         path: path.clone(),
+//                     });
+//                 };
+//                 match &node {
+//                     // `AConst` is the only node with a `one of` property, so we handle it manually
+//                     // if you need to handle other nodes manually, add them to the `manual_node_names` function below
+//                     NodeEnum::AConst(n) => {
+//                         if n.val.is_some() {
+//                             handle_child(match n.val.to_owned().unwrap() {
+//                                 pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
+//                                 pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
+//                                 pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
+//                                 pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
+//                                 pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
+//                             });
+//                         }
+//                     }
+//                     #(NodeEnum::#node_identifiers(n) => {
+//                         #node_handlers
+//                     }),*,
+//                 };
+//             }
+//             nodes
+//         }
+//     }
+// }
+//
+// fn manual_node_names() -> Vec<&'static str> {
+//     vec!["AConst"]
+// }
+//
+// fn node_identifiers(nodes: &[Node], exclude_nodes: &[&str]) -> Vec<Ident> {
+//     nodes
+//         .iter()
+//         .filter(|node| !exclude_nodes.contains(&node.name.as_str()))
+//         .map(|node| format_ident!("{}", &node.name))
+//         .collect()
+// }
+//
+// fn node_handlers(nodes: &[Node], exclude_nodes: &[&str]) -> Vec<TokenStream> {
+//     nodes
+//         .iter()
+//         .filter(|node| !exclude_nodes.contains(&node.name.as_str()))
+//         .map(|node| {
+//             let property_handlers = property_handlers(&node);
+//             quote! {
+//                 #(#property_handlers)*
+//             }
+//         })
+//         .collect()
+// }
+//
+// fn property_handlers(node: &Node) -> Vec<TokenStream> {
+//     node.fields
+//         .iter()
+//         .map(|field| {
+//             if field.field_type == FieldType::Node && field.repeated {
+//                 let field_name = field.name.as_str();
+//                 quote! {
+//                     n.#field_name
+//                         .iter()
+//                         .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+//                 }
+//             } else if field.field_type == FieldType::Node && field.is_one_of == false {
+//                 if field.node_name == Some("Node".to_owned()) {
+//                     let field_name = field.name.as_str();
+//                     quote! {
+//                         if n.#field_name.is_some() {
+//                             handle_child(n.#field_name.to_owned().unwrap().node.unwrap());
+//                         }
+//                     }
+//                 } else {
+//                     let enum_variant_name = field.enum_variant_name.as_ref().unwrap();
+//                     let field_name = field.name.as_str();
+//                     quote! {
+//                         if n.#field_name.is_some() {
+//                             handle_child(NodeEnum::#enum_variant_name(n.#field_name.to_owned().unwrap()));
+//                         }
+//                     }
+//                 }
+//             } else {
+//                 panic!("Unhandled field type: {:?}", field);
+//             }
+//         })
+//         .collect()
+// }
diff --git a/crates/codegen/src/get_location.rs b/crates/codegen/src/get_location.rs
new file mode 100644
index 00000000..4b4c0559
--- /dev/null
+++ b/crates/codegen/src/get_location.rs
@@ -0,0 +1,72 @@
+use pg_query_proto_parser::{FieldType, Node, ProtoParser};
+use proc_macro2::{Ident, TokenStream};
+use quote::{format_ident, quote};
+
+pub fn get_location_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
+    let parser = ProtoParser::new("./libpg_query/protobuf/pg_query.proto");
+    let proto_file = parser.parse();
+
+    let manual_node_names = manual_node_names();
+
+    let node_identifiers = node_identifiers(&proto_file.nodes, &manual_node_names);
+    let location_idents = location_idents(&proto_file.nodes, &manual_node_names);
+
+    quote! {
+        use pg_query::NodeEnum;
+
+        //! Returns the location of a node
+        pub fn get_location(node: &NodeEnum) -> Option<i32> {
+            let location = match node {
+                // for some nodes, the location of the node itself is after their childrens location.
+                // we implement the logic for those nodes manually.
+                // if you add one, make sure to add its name to `manual_node_names()`.
+                NodeEnum::BoolExpr(n) => {
+                    let a = n.args.iter().min_by(|a, b| {
+                        let loc_a = get_location(&a.node.as_ref().unwrap());
+                        let loc_b = get_location(&b.node.as_ref().unwrap());
+                        loc_a.cmp(&loc_b)
+                    });
+                    get_location(&a.unwrap().node.as_ref().unwrap())
+                },
+                NodeEnum::AExpr(n) => get_location(&n.lexpr.as_ref().unwrap().node.as_ref().unwrap()),
+                #(NodeEnum::#node_identifiers(n) => #location_idents),*
+            };
+            if location.is_some() && location.unwrap() < 0 {
+                None
+            } else {
+                location
+            }
+        }
+    }
+}
+
+fn manual_node_names() -> Vec<&'static str> {
+    vec!["BoolExpr", "AExpr"]
+}
+
+fn location_idents(nodes: &[Node], exclude_nodes: &[&str]) -> Vec<TokenStream> {
+    nodes
+        .iter()
+        .filter(|n| !exclude_nodes.contains(&n.name.as_str()))
+        .map(|node| {
+            if node
+                .fields
+                .iter()
+                .find(|n| n.name == "location" && n.field_type == FieldType::Int32)
+                .is_some()
+            {
+                quote! { Some(n.location) }
+            } else {
+                quote! { None }
+            }
+        })
+        .collect()
+}
+
+fn node_identifiers(nodes: &[Node], exclude_nodes: &[&str]) -> Vec<Ident> {
+    nodes
+        .iter()
+        .filter(|n| !exclude_nodes.contains(&n.name.as_str()))
+        .map(|node| format_ident!("{}", &node.name))
+        .collect()
+}
diff --git a/crates/codegen/src/lib.rs b/crates/codegen/src/lib.rs
index 9390ded2..fb029ab2 100644
--- a/crates/codegen/src/lib.rs
+++ b/crates/codegen/src/lib.rs
@@ -1,8 +1,22 @@
+// mod get_children;
+mod get_location;
 mod syntax_kind;
 
+// use get_children::get_children_mod;
+use get_location::get_location_mod;
 use syntax_kind::syntax_kind_mod;
 
+// #[proc_macro]
+// pub fn get_children(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
+//     get_children_mod(item.into()).into()
+// }
+
 #[proc_macro]
 pub fn syntax_kind(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
     syntax_kind_mod(item.into()).into()
 }
+
+#[proc_macro]
+pub fn get_location(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
+    get_location_mod(item.into()).into()
+}
diff --git a/crates/parser/src/get_location_codegen.rs b/crates/parser/src/get_location_codegen.rs
new file mode 100644
index 00000000..fcc6685d
--- /dev/null
+++ b/crates/parser/src/get_location_codegen.rs
@@ -0,0 +1,3 @@
+use codegen::get_location;
+
+get_location!();
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index 66d83a6b..f465e0f6 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -16,6 +16,7 @@
 //! To see how these drawbacks are mitigated, see the `statement.rs` and the `source_file.rs` module.
 
 mod ast_node;
+mod get_location_codegen;
 mod parser;
 mod pg_query_utils_generated;
 mod pg_query_utils_generated_test;
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
index ce56722d..b7bd9aa9 100644
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ b/crates/parser/src/pg_query_utils_generated.rs
@@ -1,264 +1,10 @@
 //! Utilities for working with pg_query.rs
 //! This file is generated from the libg_query proto
+use crate::get_location_codegen::get_location;
 use crate::pg_query_utils_manual::derive_location;
 use pg_query::NodeEnum;
 use std::collections::VecDeque;
 
-pub fn get_location(node: &NodeEnum) -> Option<i32> {
-    let l = match node {
-        NodeEnum::Alias(_) => None,
-        NodeEnum::RangeVar(n) => Some(n.location),
-        NodeEnum::TableFunc(n) => Some(n.location),
-        NodeEnum::Var(n) => Some(n.location),
-        NodeEnum::Param(n) => Some(n.location),
-        NodeEnum::Aggref(n) => Some(n.location),
-        NodeEnum::GroupingFunc(n) => Some(n.location),
-        NodeEnum::WindowFunc(n) => Some(n.location),
-        NodeEnum::SubscriptingRef(_) => None,
-        NodeEnum::FuncExpr(n) => Some(n.location),
-        NodeEnum::NamedArgExpr(n) => Some(n.location),
-        NodeEnum::OpExpr(n) => Some(n.location),
-        NodeEnum::DistinctExpr(n) => Some(n.location),
-        NodeEnum::NullIfExpr(n) => Some(n.location),
-        NodeEnum::ScalarArrayOpExpr(n) => Some(n.location),
-        NodeEnum::BoolExpr(n) => {
-            let a = n.args.iter().min_by(|a, b| {
-                let loc_a = get_location(&a.node.as_ref().unwrap());
-                let loc_b = get_location(&b.node.as_ref().unwrap());
-                loc_a.cmp(&loc_b)
-            });
-            get_location(&a.unwrap().node.as_ref().unwrap())
-        }
-        NodeEnum::SubLink(n) => Some(n.location),
-        NodeEnum::SubPlan(_) => None,
-        NodeEnum::AlternativeSubPlan(_) => None,
-        NodeEnum::FieldSelect(_) => None,
-        NodeEnum::FieldStore(_) => None,
-        NodeEnum::RelabelType(n) => Some(n.location),
-        NodeEnum::CoerceViaIo(n) => Some(n.location),
-        NodeEnum::ArrayCoerceExpr(n) => Some(n.location),
-        NodeEnum::ConvertRowtypeExpr(n) => Some(n.location),
-        NodeEnum::CollateExpr(n) => Some(n.location),
-        NodeEnum::CaseExpr(n) => Some(n.location),
-        NodeEnum::CaseWhen(n) => Some(n.location),
-        NodeEnum::CaseTestExpr(_) => None,
-        NodeEnum::ArrayExpr(n) => Some(n.location),
-        NodeEnum::RowExpr(n) => Some(n.location),
-        NodeEnum::RowCompareExpr(_) => None,
-        NodeEnum::CoalesceExpr(n) => Some(n.location),
-        NodeEnum::MinMaxExpr(n) => Some(n.location),
-        NodeEnum::SqlvalueFunction(n) => Some(n.location),
-        NodeEnum::XmlExpr(n) => Some(n.location),
-        NodeEnum::NullTest(n) => Some(n.location),
-        NodeEnum::BooleanTest(n) => Some(n.location),
-        NodeEnum::CoerceToDomain(n) => Some(n.location),
-        NodeEnum::CoerceToDomainValue(n) => Some(n.location),
-        NodeEnum::SetToDefault(n) => Some(n.location),
-        NodeEnum::CurrentOfExpr(_) => None,
-        NodeEnum::NextValueExpr(_) => None,
-        NodeEnum::InferenceElem(_) => None,
-        NodeEnum::TargetEntry(_) => None,
-        NodeEnum::RangeTblRef(_) => None,
-        NodeEnum::JoinExpr(_) => None,
-        NodeEnum::FromExpr(_) => None,
-        NodeEnum::OnConflictExpr(_) => None,
-        NodeEnum::IntoClause(_) => None,
-        NodeEnum::MergeAction(_) => None,
-        NodeEnum::RawStmt(_) => None,
-        NodeEnum::Query(_) => None,
-        NodeEnum::InsertStmt(_) => None,
-        NodeEnum::DeleteStmt(_) => None,
-        NodeEnum::UpdateStmt(_) => None,
-        NodeEnum::MergeStmt(_) => None,
-        NodeEnum::SelectStmt(_) => None,
-        NodeEnum::ReturnStmt(_) => None,
-        NodeEnum::PlassignStmt(n) => Some(n.location),
-        NodeEnum::AlterTableStmt(_) => None,
-        NodeEnum::AlterTableCmd(_) => None,
-        NodeEnum::AlterDomainStmt(_) => None,
-        NodeEnum::SetOperationStmt(_) => None,
-        NodeEnum::GrantStmt(_) => None,
-        NodeEnum::GrantRoleStmt(_) => None,
-        NodeEnum::AlterDefaultPrivilegesStmt(_) => None,
-        NodeEnum::ClosePortalStmt(_) => None,
-        NodeEnum::ClusterStmt(_) => None,
-        NodeEnum::CopyStmt(_) => None,
-        NodeEnum::CreateStmt(_) => None,
-        NodeEnum::DefineStmt(_) => None,
-        NodeEnum::DropStmt(_) => None,
-        NodeEnum::TruncateStmt(_) => None,
-        NodeEnum::CommentStmt(_) => None,
-        NodeEnum::FetchStmt(_) => None,
-        NodeEnum::IndexStmt(_) => None,
-        NodeEnum::CreateFunctionStmt(_) => None,
-        NodeEnum::AlterFunctionStmt(_) => None,
-        NodeEnum::DoStmt(_) => None,
-        NodeEnum::RenameStmt(_) => None,
-        NodeEnum::RuleStmt(_) => None,
-        NodeEnum::NotifyStmt(_) => None,
-        NodeEnum::ListenStmt(_) => None,
-        NodeEnum::UnlistenStmt(_) => None,
-        NodeEnum::TransactionStmt(_) => None,
-        NodeEnum::ViewStmt(_) => None,
-        NodeEnum::LoadStmt(_) => None,
-        NodeEnum::CreateDomainStmt(_) => None,
-        NodeEnum::CreatedbStmt(_) => None,
-        NodeEnum::DropdbStmt(_) => None,
-        NodeEnum::VacuumStmt(_) => None,
-        NodeEnum::ExplainStmt(_) => None,
-        NodeEnum::CreateTableAsStmt(_) => None,
-        NodeEnum::CreateSeqStmt(_) => None,
-        NodeEnum::AlterSeqStmt(_) => None,
-        NodeEnum::VariableSetStmt(_) => None,
-        NodeEnum::VariableShowStmt(_) => None,
-        NodeEnum::DiscardStmt(_) => None,
-        NodeEnum::CreateTrigStmt(_) => None,
-        NodeEnum::CreatePlangStmt(_) => None,
-        NodeEnum::CreateRoleStmt(_) => None,
-        NodeEnum::AlterRoleStmt(_) => None,
-        NodeEnum::DropRoleStmt(_) => None,
-        NodeEnum::LockStmt(_) => None,
-        NodeEnum::ConstraintsSetStmt(_) => None,
-        NodeEnum::ReindexStmt(_) => None,
-        NodeEnum::CheckPointStmt(_) => None,
-        NodeEnum::CreateSchemaStmt(_) => None,
-        NodeEnum::AlterDatabaseStmt(_) => None,
-        NodeEnum::AlterDatabaseRefreshCollStmt(_) => None,
-        NodeEnum::AlterDatabaseSetStmt(_) => None,
-        NodeEnum::AlterRoleSetStmt(_) => None,
-        NodeEnum::CreateConversionStmt(_) => None,
-        NodeEnum::CreateCastStmt(_) => None,
-        NodeEnum::CreateOpClassStmt(_) => None,
-        NodeEnum::CreateOpFamilyStmt(_) => None,
-        NodeEnum::AlterOpFamilyStmt(_) => None,
-        NodeEnum::PrepareStmt(_) => None,
-        NodeEnum::ExecuteStmt(_) => None,
-        NodeEnum::DeallocateStmt(_) => None,
-        NodeEnum::DeclareCursorStmt(_) => None,
-        NodeEnum::CreateTableSpaceStmt(_) => None,
-        NodeEnum::DropTableSpaceStmt(_) => None,
-        NodeEnum::AlterObjectDependsStmt(_) => None,
-        NodeEnum::AlterObjectSchemaStmt(_) => None,
-        NodeEnum::AlterOwnerStmt(_) => None,
-        NodeEnum::AlterOperatorStmt(_) => None,
-        NodeEnum::AlterTypeStmt(_) => None,
-        NodeEnum::DropOwnedStmt(_) => None,
-        NodeEnum::ReassignOwnedStmt(_) => None,
-        NodeEnum::CompositeTypeStmt(_) => None,
-        NodeEnum::CreateEnumStmt(_) => None,
-        NodeEnum::CreateRangeStmt(_) => None,
-        NodeEnum::AlterEnumStmt(_) => None,
-        NodeEnum::AlterTsdictionaryStmt(_) => None,
-        NodeEnum::AlterTsconfigurationStmt(_) => None,
-        NodeEnum::CreateFdwStmt(_) => None,
-        NodeEnum::AlterFdwStmt(_) => None,
-        NodeEnum::CreateForeignServerStmt(_) => None,
-        NodeEnum::AlterForeignServerStmt(_) => None,
-        NodeEnum::CreateUserMappingStmt(_) => None,
-        NodeEnum::AlterUserMappingStmt(_) => None,
-        NodeEnum::DropUserMappingStmt(_) => None,
-        NodeEnum::AlterTableSpaceOptionsStmt(_) => None,
-        NodeEnum::AlterTableMoveAllStmt(_) => None,
-        NodeEnum::SecLabelStmt(_) => None,
-        NodeEnum::CreateForeignTableStmt(_) => None,
-        NodeEnum::ImportForeignSchemaStmt(_) => None,
-        NodeEnum::CreateExtensionStmt(_) => None,
-        NodeEnum::AlterExtensionStmt(_) => None,
-        NodeEnum::AlterExtensionContentsStmt(_) => None,
-        NodeEnum::CreateEventTrigStmt(_) => None,
-        NodeEnum::AlterEventTrigStmt(_) => None,
-        NodeEnum::RefreshMatViewStmt(_) => None,
-        NodeEnum::ReplicaIdentityStmt(_) => None,
-        NodeEnum::AlterSystemStmt(_) => None,
-        NodeEnum::CreatePolicyStmt(_) => None,
-        NodeEnum::AlterPolicyStmt(_) => None,
-        NodeEnum::CreateTransformStmt(_) => None,
-        NodeEnum::CreateAmStmt(_) => None,
-        NodeEnum::CreatePublicationStmt(_) => None,
-        NodeEnum::AlterPublicationStmt(_) => None,
-        NodeEnum::CreateSubscriptionStmt(_) => None,
-        NodeEnum::AlterSubscriptionStmt(_) => None,
-        NodeEnum::DropSubscriptionStmt(_) => None,
-        NodeEnum::CreateStatsStmt(_) => None,
-        NodeEnum::AlterCollationStmt(_) => None,
-        NodeEnum::CallStmt(_) => None,
-        NodeEnum::AlterStatsStmt(_) => None,
-        NodeEnum::AExpr(n) => get_location(&n.lexpr.as_ref().unwrap().node.as_ref().unwrap()),
-        NodeEnum::ColumnRef(n) => Some(n.location),
-        NodeEnum::ParamRef(n) => Some(n.location),
-        NodeEnum::FuncCall(n) => Some(n.location),
-        NodeEnum::AStar(_) => None,
-        NodeEnum::AIndices(_) => None,
-        NodeEnum::AIndirection(_) => None,
-        NodeEnum::AArrayExpr(n) => Some(n.location),
-        NodeEnum::ResTarget(n) => Some(n.location),
-        NodeEnum::MultiAssignRef(_) => None,
-        NodeEnum::TypeCast(n) => Some(n.location),
-        NodeEnum::CollateClause(n) => Some(n.location),
-        NodeEnum::SortBy(n) => Some(n.location),
-        NodeEnum::WindowDef(n) => Some(n.location),
-        NodeEnum::RangeSubselect(_) => None,
-        NodeEnum::RangeFunction(_) => None,
-        NodeEnum::RangeTableSample(n) => Some(n.location),
-        NodeEnum::RangeTableFunc(n) => Some(n.location),
-        NodeEnum::RangeTableFuncCol(n) => Some(n.location),
-        NodeEnum::TypeName(n) => Some(n.location),
-        NodeEnum::ColumnDef(n) => Some(n.location),
-        NodeEnum::IndexElem(_) => None,
-        NodeEnum::StatsElem(_) => None,
-        NodeEnum::Constraint(n) => Some(n.location),
-        NodeEnum::DefElem(n) => Some(n.location),
-        NodeEnum::RangeTblEntry(_) => None,
-        NodeEnum::RangeTblFunction(_) => None,
-        NodeEnum::TableSampleClause(_) => None,
-        NodeEnum::WithCheckOption(_) => None,
-        NodeEnum::SortGroupClause(_) => None,
-        NodeEnum::GroupingSet(n) => Some(n.location),
-        NodeEnum::WindowClause(_) => None,
-        NodeEnum::ObjectWithArgs(_) => None,
-        NodeEnum::AccessPriv(_) => None,
-        NodeEnum::CreateOpClassItem(_) => None,
-        NodeEnum::TableLikeClause(_) => None,
-        NodeEnum::FunctionParameter(_) => None,
-        NodeEnum::LockingClause(_) => None,
-        NodeEnum::RowMarkClause(_) => None,
-        NodeEnum::XmlSerialize(n) => Some(n.location),
-        NodeEnum::WithClause(n) => Some(n.location),
-        NodeEnum::InferClause(n) => Some(n.location),
-        NodeEnum::OnConflictClause(n) => Some(n.location),
-        NodeEnum::CtesearchClause(n) => Some(n.location),
-        NodeEnum::CtecycleClause(n) => Some(n.location),
-        NodeEnum::CommonTableExpr(n) => Some(n.location),
-        NodeEnum::MergeWhenClause(_) => None,
-        NodeEnum::RoleSpec(n) => Some(n.location),
-        NodeEnum::TriggerTransition(_) => None,
-        NodeEnum::PartitionElem(n) => Some(n.location),
-        NodeEnum::PartitionSpec(n) => Some(n.location),
-        NodeEnum::PartitionBoundSpec(n) => Some(n.location),
-        NodeEnum::PartitionRangeDatum(n) => Some(n.location),
-        NodeEnum::PartitionCmd(_) => None,
-        NodeEnum::VacuumRelation(_) => None,
-        NodeEnum::PublicationObjSpec(n) => Some(n.location),
-        NodeEnum::PublicationTable(_) => None,
-        NodeEnum::InlineCodeBlock(_) => None,
-        NodeEnum::CallContext(_) => None,
-        NodeEnum::Integer(_) => None,
-        NodeEnum::Float(_) => None,
-        NodeEnum::Boolean(_) => None,
-        NodeEnum::String(_) => None,
-        NodeEnum::BitString(_) => None,
-        NodeEnum::List(_) => None,
-        NodeEnum::IntList(_) => None,
-        NodeEnum::OidList(_) => None,
-        NodeEnum::AConst(n) => Some(n.location),
-    };
-    if l.is_some() && l.unwrap() < 0 {
-        None
-    } else {
-        l
-    }
-}
-
 #[derive(Debug, Clone)]
 pub struct NestedNode {
     pub node: NodeEnum,
diff --git a/expanded.rs b/expanded.rs
new file mode 100644
index 00000000..691c8b76
--- /dev/null
+++ b/expanded.rs
@@ -0,0 +1,3121 @@
+mod syntax_kind_codegen {
+    use codegen::syntax_kind;
+    use cstree::Syntax;
+    use pg_query::{protobuf::ScanToken, NodeEnum, NodeRef};
+    /// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres
+    /// sql dialect, and a few custom ones that are not parsed by pg_query.rs, such
+    /// as `Whitespace`.
+    #[repr(u32)]
+    pub enum SyntaxKind {
+        SourceFile,
+        Comment,
+        Whitespace,
+        Newline,
+        Tab,
+        Stmt,
+        Alias,
+        RangeVar,
+        TableFunc,
+        Var,
+        Param,
+        Aggref,
+        GroupingFunc,
+        WindowFunc,
+        SubscriptingRef,
+        FuncExpr,
+        NamedArgExpr,
+        OpExpr,
+        DistinctExpr,
+        NullIfExpr,
+        ScalarArrayOpExpr,
+        BoolExpr,
+        SubLink,
+        SubPlan,
+        AlternativeSubPlan,
+        FieldSelect,
+        FieldStore,
+        RelabelType,
+        CoerceViaIo,
+        ArrayCoerceExpr,
+        ConvertRowtypeExpr,
+        CollateExpr,
+        CaseExpr,
+        CaseWhen,
+        CaseTestExpr,
+        ArrayExpr,
+        RowExpr,
+        RowCompareExpr,
+        CoalesceExpr,
+        MinMaxExpr,
+        SqlvalueFunction,
+        XmlExpr,
+        NullTest,
+        BooleanTest,
+        CoerceToDomain,
+        CoerceToDomainValue,
+        SetToDefault,
+        CurrentOfExpr,
+        NextValueExpr,
+        InferenceElem,
+        TargetEntry,
+        RangeTblRef,
+        JoinExpr,
+        FromExpr,
+        OnConflictExpr,
+        IntoClause,
+        MergeAction,
+        RawStmt,
+        Query,
+        InsertStmt,
+        DeleteStmt,
+        UpdateStmt,
+        MergeStmt,
+        SelectStmt,
+        ReturnStmt,
+        PlassignStmt,
+        AlterTableStmt,
+        AlterTableCmd,
+        AlterDomainStmt,
+        SetOperationStmt,
+        GrantStmt,
+        GrantRoleStmt,
+        AlterDefaultPrivilegesStmt,
+        ClosePortalStmt,
+        ClusterStmt,
+        CopyStmt,
+        CreateStmt,
+        DefineStmt,
+        DropStmt,
+        TruncateStmt,
+        CommentStmt,
+        FetchStmt,
+        IndexStmt,
+        CreateFunctionStmt,
+        AlterFunctionStmt,
+        DoStmt,
+        RenameStmt,
+        RuleStmt,
+        NotifyStmt,
+        ListenStmt,
+        UnlistenStmt,
+        TransactionStmt,
+        ViewStmt,
+        LoadStmt,
+        CreateDomainStmt,
+        CreatedbStmt,
+        DropdbStmt,
+        VacuumStmt,
+        ExplainStmt,
+        CreateTableAsStmt,
+        CreateSeqStmt,
+        AlterSeqStmt,
+        VariableSetStmt,
+        VariableShowStmt,
+        DiscardStmt,
+        CreateTrigStmt,
+        CreatePlangStmt,
+        CreateRoleStmt,
+        AlterRoleStmt,
+        DropRoleStmt,
+        LockStmt,
+        ConstraintsSetStmt,
+        ReindexStmt,
+        CheckPointStmt,
+        CreateSchemaStmt,
+        AlterDatabaseStmt,
+        AlterDatabaseRefreshCollStmt,
+        AlterDatabaseSetStmt,
+        AlterRoleSetStmt,
+        CreateConversionStmt,
+        CreateCastStmt,
+        CreateOpClassStmt,
+        CreateOpFamilyStmt,
+        AlterOpFamilyStmt,
+        PrepareStmt,
+        ExecuteStmt,
+        DeallocateStmt,
+        DeclareCursorStmt,
+        CreateTableSpaceStmt,
+        DropTableSpaceStmt,
+        AlterObjectDependsStmt,
+        AlterObjectSchemaStmt,
+        AlterOwnerStmt,
+        AlterOperatorStmt,
+        AlterTypeStmt,
+        DropOwnedStmt,
+        ReassignOwnedStmt,
+        CompositeTypeStmt,
+        CreateEnumStmt,
+        CreateRangeStmt,
+        AlterEnumStmt,
+        AlterTsdictionaryStmt,
+        AlterTsconfigurationStmt,
+        CreateFdwStmt,
+        AlterFdwStmt,
+        CreateForeignServerStmt,
+        AlterForeignServerStmt,
+        CreateUserMappingStmt,
+        AlterUserMappingStmt,
+        DropUserMappingStmt,
+        AlterTableSpaceOptionsStmt,
+        AlterTableMoveAllStmt,
+        SecLabelStmt,
+        CreateForeignTableStmt,
+        ImportForeignSchemaStmt,
+        CreateExtensionStmt,
+        AlterExtensionStmt,
+        AlterExtensionContentsStmt,
+        CreateEventTrigStmt,
+        AlterEventTrigStmt,
+        RefreshMatViewStmt,
+        ReplicaIdentityStmt,
+        AlterSystemStmt,
+        CreatePolicyStmt,
+        AlterPolicyStmt,
+        CreateTransformStmt,
+        CreateAmStmt,
+        CreatePublicationStmt,
+        AlterPublicationStmt,
+        CreateSubscriptionStmt,
+        AlterSubscriptionStmt,
+        DropSubscriptionStmt,
+        CreateStatsStmt,
+        AlterCollationStmt,
+        CallStmt,
+        AlterStatsStmt,
+        AExpr,
+        ColumnRef,
+        ParamRef,
+        FuncCall,
+        AStar,
+        AIndices,
+        AIndirection,
+        AArrayExpr,
+        ResTarget,
+        MultiAssignRef,
+        TypeCast,
+        CollateClause,
+        SortBy,
+        WindowDef,
+        RangeSubselect,
+        RangeFunction,
+        RangeTableSample,
+        RangeTableFunc,
+        RangeTableFuncCol,
+        TypeName,
+        ColumnDef,
+        IndexElem,
+        StatsElem,
+        Constraint,
+        DefElem,
+        RangeTblEntry,
+        RangeTblFunction,
+        TableSampleClause,
+        WithCheckOption,
+        SortGroupClause,
+        GroupingSet,
+        WindowClause,
+        ObjectWithArgs,
+        AccessPriv,
+        CreateOpClassItem,
+        TableLikeClause,
+        FunctionParameter,
+        LockingClause,
+        RowMarkClause,
+        XmlSerialize,
+        WithClause,
+        InferClause,
+        OnConflictClause,
+        CtesearchClause,
+        CtecycleClause,
+        CommonTableExpr,
+        MergeWhenClause,
+        RoleSpec,
+        TriggerTransition,
+        PartitionElem,
+        PartitionSpec,
+        PartitionBoundSpec,
+        PartitionRangeDatum,
+        PartitionCmd,
+        VacuumRelation,
+        PublicationObjSpec,
+        PublicationTable,
+        InlineCodeBlock,
+        CallContext,
+        Integer,
+        Float,
+        Boolean,
+        String,
+        BitString,
+        List,
+        IntList,
+        OidList,
+        AConst,
+        Nul,
+        Ascii37,
+        Ascii40,
+        Ascii41,
+        Ascii42,
+        Ascii43,
+        Ascii44,
+        Ascii45,
+        Ascii46,
+        Ascii47,
+        Ascii58,
+        Ascii59,
+        Ascii60,
+        Ascii61,
+        Ascii62,
+        Ascii63,
+        Ascii91,
+        Ascii92,
+        Ascii93,
+        Ascii94,
+        Ident,
+        Uident,
+        Fconst,
+        Sconst,
+        Usconst,
+        Bconst,
+        Xconst,
+        Op,
+        Iconst,
+        Typecast,
+        DotDot,
+        ColonEquals,
+        EqualsGreater,
+        LessEquals,
+        GreaterEquals,
+        NotEquals,
+        SqlComment,
+        CComment,
+        AbortP,
+        AbsoluteP,
+        Access,
+        Action,
+        AddP,
+        Admin,
+        After,
+        Aggregate,
+        All,
+        Also,
+        Alter,
+        Always,
+        Analyse,
+        Analyze,
+        And,
+        Any,
+        Array,
+        As,
+        Asc,
+        Asensitive,
+        Assertion,
+        Assignment,
+        Asymmetric,
+        Atomic,
+        At,
+        Attach,
+        Attribute,
+        Authorization,
+        Backward,
+        Before,
+        BeginP,
+        Between,
+        Bigint,
+        Binary,
+        Bit,
+        BooleanP,
+        Both,
+        Breadth,
+        By,
+        Cache,
+        Call,
+        Called,
+        Cascade,
+        Cascaded,
+        Case,
+        Cast,
+        CatalogP,
+        Chain,
+        CharP,
+        Character,
+        Characteristics,
+        Check,
+        Checkpoint,
+        Class,
+        Close,
+        Cluster,
+        Coalesce,
+        Collate,
+        Collation,
+        Column,
+        Columns,
+        Comments,
+        Commit,
+        Committed,
+        Compression,
+        Concurrently,
+        Configuration,
+        Conflict,
+        Connection,
+        Constraints,
+        ContentP,
+        ContinueP,
+        ConversionP,
+        Copy,
+        Cost,
+        Create,
+        Cross,
+        Csv,
+        Cube,
+        CurrentP,
+        CurrentCatalog,
+        CurrentDate,
+        CurrentRole,
+        CurrentSchema,
+        CurrentTime,
+        CurrentTimestamp,
+        CurrentUser,
+        Cursor,
+        Cycle,
+        DataP,
+        Database,
+        DayP,
+        Deallocate,
+        Dec,
+        DecimalP,
+        Declare,
+        Default,
+        Defaults,
+        Deferrable,
+        Deferred,
+        Definer,
+        DeleteP,
+        Delimiter,
+        Delimiters,
+        Depends,
+        Depth,
+        Desc,
+        Detach,
+        Dictionary,
+        DisableP,
+        Discard,
+        Distinct,
+        Do,
+        DocumentP,
+        DomainP,
+        DoubleP,
+        Drop,
+        Each,
+        Else,
+        EnableP,
+        Encoding,
+        Encrypted,
+        EndP,
+        EnumP,
+        Escape,
+        Event,
+        Except,
+        Exclude,
+        Excluding,
+        Exclusive,
+        Execute,
+        Exists,
+        Explain,
+        Expression,
+        Extension,
+        External,
+        Extract,
+        FalseP,
+        Family,
+        Fetch,
+        Filter,
+        Finalize,
+        FirstP,
+        FloatP,
+        Following,
+        For,
+        Force,
+        Foreign,
+        Forward,
+        Freeze,
+        From,
+        Full,
+        Function,
+        Functions,
+        Generated,
+        Global,
+        Grant,
+        Granted,
+        Greatest,
+        GroupP,
+        Grouping,
+        Groups,
+        Handler,
+        Having,
+        HeaderP,
+        Hold,
+        HourP,
+        IdentityP,
+        IfP,
+        Ilike,
+        Immediate,
+        Immutable,
+        ImplicitP,
+        ImportP,
+        InP,
+        Include,
+        Including,
+        Increment,
+        Index,
+        Indexes,
+        Inherit,
+        Inherits,
+        Initially,
+        InlineP,
+        InnerP,
+        Inout,
+        InputP,
+        Insensitive,
+        Insert,
+        Instead,
+        IntP,
+        Intersect,
+        Interval,
+        Into,
+        Invoker,
+        Is,
+        Isnull,
+        Isolation,
+        Join,
+        Key,
+        Label,
+        Language,
+        LargeP,
+        LastP,
+        LateralP,
+        Leading,
+        Leakproof,
+        Least,
+        Left,
+        Level,
+        Like,
+        Limit,
+        Listen,
+        Load,
+        Local,
+        Localtime,
+        Localtimestamp,
+        Location,
+        LockP,
+        Locked,
+        Logged,
+        Mapping,
+        Match,
+        Matched,
+        Materialized,
+        Maxvalue,
+        Merge,
+        Method,
+        MinuteP,
+        Minvalue,
+        Mode,
+        MonthP,
+        Move,
+        NameP,
+        Names,
+        National,
+        Natural,
+        Nchar,
+        New,
+        Next,
+        Nfc,
+        Nfd,
+        Nfkc,
+        Nfkd,
+        No,
+        None,
+        Normalize,
+        Normalized,
+        Not,
+        Nothing,
+        Notify,
+        Notnull,
+        Nowait,
+        NullP,
+        Nullif,
+        NullsP,
+        Numeric,
+        ObjectP,
+        Of,
+        Off,
+        Offset,
+        Oids,
+        Old,
+        On,
+        Only,
+        Operator,
+        Option,
+        Options,
+        Or,
+        Order,
+        Ordinality,
+        Others,
+        OutP,
+        OuterP,
+        Over,
+        Overlaps,
+        Overlay,
+        Overriding,
+        Owned,
+        Owner,
+        Parallel,
+        Parameter,
+        Parser,
+        Partial,
+        Partition,
+        Passing,
+        Password,
+        Placing,
+        Plans,
+        Policy,
+        Position,
+        Preceding,
+        Precision,
+        Preserve,
+        Prepare,
+        Prepared,
+        Primary,
+        Prior,
+        Privileges,
+        Procedural,
+        Procedure,
+        Procedures,
+        Program,
+        Publication,
+        Quote,
+        Range,
+        Read,
+        Real,
+        Reassign,
+        Recheck,
+        Recursive,
+        RefP,
+        References,
+        Referencing,
+        Refresh,
+        Reindex,
+        RelativeP,
+        Release,
+        Rename,
+        Repeatable,
+        Replace,
+        Replica,
+        Reset,
+        Restart,
+        Restrict,
+        Return,
+        Returning,
+        Returns,
+        Revoke,
+        Right,
+        Role,
+        Rollback,
+        Rollup,
+        Routine,
+        Routines,
+        Row,
+        Rows,
+        Rule,
+        Savepoint,
+        Schema,
+        Schemas,
+        Scroll,
+        Search,
+        SecondP,
+        Security,
+        Select,
+        Sequence,
+        Sequences,
+        Serializable,
+        Server,
+        Session,
+        SessionUser,
+        Set,
+        Sets,
+        Setof,
+        Share,
+        Show,
+        Similar,
+        Simple,
+        Skip,
+        Smallint,
+        Snapshot,
+        Some,
+        SqlP,
+        Stable,
+        StandaloneP,
+        Start,
+        Statement,
+        Statistics,
+        Stdin,
+        Stdout,
+        Storage,
+        Stored,
+        StrictP,
+        StripP,
+        Subscription,
+        Substring,
+        Support,
+        Symmetric,
+        Sysid,
+        SystemP,
+        Table,
+        Tables,
+        Tablesample,
+        Tablespace,
+        Temp,
+        Template,
+        Temporary,
+        TextP,
+        Then,
+        Ties,
+        Time,
+        Timestamp,
+        To,
+        Trailing,
+        Transaction,
+        Transform,
+        Treat,
+        Trigger,
+        Trim,
+        TrueP,
+        Truncate,
+        Trusted,
+        TypeP,
+        TypesP,
+        Uescape,
+        Unbounded,
+        Uncommitted,
+        Unencrypted,
+        Union,
+        Unique,
+        Unknown,
+        Unlisten,
+        Unlogged,
+        Until,
+        Update,
+        User,
+        Using,
+        Vacuum,
+        Valid,
+        Validate,
+        Validator,
+        ValueP,
+        Values,
+        Varchar,
+        Variadic,
+        Varying,
+        Verbose,
+        VersionP,
+        View,
+        Views,
+        Volatile,
+        When,
+        Where,
+        WhitespaceP,
+        Window,
+        With,
+        Within,
+        Without,
+        Work,
+        Wrapper,
+        Write,
+        XmlP,
+        Xmlattributes,
+        Xmlconcat,
+        Xmlelement,
+        Xmlexists,
+        Xmlforest,
+        Xmlnamespaces,
+        Xmlparse,
+        Xmlpi,
+        Xmlroot,
+        Xmlserialize,
+        Xmltable,
+        YearP,
+        YesP,
+        Zone,
+        NotLa,
+        NullsLa,
+        WithLa,
+        ModeTypeName,
+        ModePlpgsqlExpr,
+        ModePlpgsqlAssign1,
+        ModePlpgsqlAssign2,
+        ModePlpgsqlAssign3,
+        Uminus,
+    }
+    #[automatically_derived]
+    impl ::core::clone::Clone for SyntaxKind {
+        #[inline]
+        fn clone(&self) -> SyntaxKind {
+            *self
+        }
+    }
+    #[automatically_derived]
+    impl ::core::marker::Copy for SyntaxKind {}
+    #[automatically_derived]
+    impl ::core::marker::StructuralPartialEq for SyntaxKind {}
+    #[automatically_derived]
+    impl ::core::cmp::PartialEq for SyntaxKind {
+        #[inline]
+        fn eq(&self, other: &SyntaxKind) -> bool {
+            let __self_tag = ::core::intrinsics::discriminant_value(self);
+            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
+            __self_tag == __arg1_tag
+        }
+    }
+    #[automatically_derived]
+    impl ::core::marker::StructuralEq for SyntaxKind {}
+    #[automatically_derived]
+    impl ::core::cmp::Eq for SyntaxKind {
+        #[inline]
+        #[doc(hidden)]
+        #[no_coverage]
+        fn assert_receiver_is_total_eq(&self) -> () {}
+    }
+    #[automatically_derived]
+    impl ::core::cmp::PartialOrd for SyntaxKind {
+        #[inline]
+        fn partial_cmp(
+            &self,
+            other: &SyntaxKind,
+        ) -> ::core::option::Option<::core::cmp::Ordering> {
+            let __self_tag = ::core::intrinsics::discriminant_value(self);
+            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
+            ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
+        }
+    }
+    #[automatically_derived]
+    impl ::core::cmp::Ord for SyntaxKind {
+        #[inline]
+        fn cmp(&self, other: &SyntaxKind) -> ::core::cmp::Ordering {
+            let __self_tag = ::core::intrinsics::discriminant_value(self);
+            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
+            ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
+        }
+    }
+    #[automatically_derived]
+    impl ::core::hash::Hash for SyntaxKind {
+        fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
+            let __self_tag = ::core::intrinsics::discriminant_value(self);
+            ::core::hash::Hash::hash(&__self_tag, state)
+        }
+    }
+    #[automatically_derived]
+    impl ::core::fmt::Debug for SyntaxKind {
+        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+            ::core::fmt::Formatter::write_str(
+                f,
+                match self {
+                    SyntaxKind::SourceFile => "SourceFile",
+                    SyntaxKind::Comment => "Comment",
+                    SyntaxKind::Whitespace => "Whitespace",
+                    SyntaxKind::Newline => "Newline",
+                    SyntaxKind::Tab => "Tab",
+                    SyntaxKind::Stmt => "Stmt",
+                    SyntaxKind::Alias => "Alias",
+                    SyntaxKind::RangeVar => "RangeVar",
+                    SyntaxKind::TableFunc => "TableFunc",
+                    SyntaxKind::Var => "Var",
+                    SyntaxKind::Param => "Param",
+                    SyntaxKind::Aggref => "Aggref",
+                    SyntaxKind::GroupingFunc => "GroupingFunc",
+                    SyntaxKind::WindowFunc => "WindowFunc",
+                    SyntaxKind::SubscriptingRef => "SubscriptingRef",
+                    SyntaxKind::FuncExpr => "FuncExpr",
+                    SyntaxKind::NamedArgExpr => "NamedArgExpr",
+                    SyntaxKind::OpExpr => "OpExpr",
+                    SyntaxKind::DistinctExpr => "DistinctExpr",
+                    SyntaxKind::NullIfExpr => "NullIfExpr",
+                    SyntaxKind::ScalarArrayOpExpr => "ScalarArrayOpExpr",
+                    SyntaxKind::BoolExpr => "BoolExpr",
+                    SyntaxKind::SubLink => "SubLink",
+                    SyntaxKind::SubPlan => "SubPlan",
+                    SyntaxKind::AlternativeSubPlan => "AlternativeSubPlan",
+                    SyntaxKind::FieldSelect => "FieldSelect",
+                    SyntaxKind::FieldStore => "FieldStore",
+                    SyntaxKind::RelabelType => "RelabelType",
+                    SyntaxKind::CoerceViaIo => "CoerceViaIo",
+                    SyntaxKind::ArrayCoerceExpr => "ArrayCoerceExpr",
+                    SyntaxKind::ConvertRowtypeExpr => "ConvertRowtypeExpr",
+                    SyntaxKind::CollateExpr => "CollateExpr",
+                    SyntaxKind::CaseExpr => "CaseExpr",
+                    SyntaxKind::CaseWhen => "CaseWhen",
+                    SyntaxKind::CaseTestExpr => "CaseTestExpr",
+                    SyntaxKind::ArrayExpr => "ArrayExpr",
+                    SyntaxKind::RowExpr => "RowExpr",
+                    SyntaxKind::RowCompareExpr => "RowCompareExpr",
+                    SyntaxKind::CoalesceExpr => "CoalesceExpr",
+                    SyntaxKind::MinMaxExpr => "MinMaxExpr",
+                    SyntaxKind::SqlvalueFunction => "SqlvalueFunction",
+                    SyntaxKind::XmlExpr => "XmlExpr",
+                    SyntaxKind::NullTest => "NullTest",
+                    SyntaxKind::BooleanTest => "BooleanTest",
+                    SyntaxKind::CoerceToDomain => "CoerceToDomain",
+                    SyntaxKind::CoerceToDomainValue => "CoerceToDomainValue",
+                    SyntaxKind::SetToDefault => "SetToDefault",
+                    SyntaxKind::CurrentOfExpr => "CurrentOfExpr",
+                    SyntaxKind::NextValueExpr => "NextValueExpr",
+                    SyntaxKind::InferenceElem => "InferenceElem",
+                    SyntaxKind::TargetEntry => "TargetEntry",
+                    SyntaxKind::RangeTblRef => "RangeTblRef",
+                    SyntaxKind::JoinExpr => "JoinExpr",
+                    SyntaxKind::FromExpr => "FromExpr",
+                    SyntaxKind::OnConflictExpr => "OnConflictExpr",
+                    SyntaxKind::IntoClause => "IntoClause",
+                    SyntaxKind::MergeAction => "MergeAction",
+                    SyntaxKind::RawStmt => "RawStmt",
+                    SyntaxKind::Query => "Query",
+                    SyntaxKind::InsertStmt => "InsertStmt",
+                    SyntaxKind::DeleteStmt => "DeleteStmt",
+                    SyntaxKind::UpdateStmt => "UpdateStmt",
+                    SyntaxKind::MergeStmt => "MergeStmt",
+                    SyntaxKind::SelectStmt => "SelectStmt",
+                    SyntaxKind::ReturnStmt => "ReturnStmt",
+                    SyntaxKind::PlassignStmt => "PlassignStmt",
+                    SyntaxKind::AlterTableStmt => "AlterTableStmt",
+                    SyntaxKind::AlterTableCmd => "AlterTableCmd",
+                    SyntaxKind::AlterDomainStmt => "AlterDomainStmt",
+                    SyntaxKind::SetOperationStmt => "SetOperationStmt",
+                    SyntaxKind::GrantStmt => "GrantStmt",
+                    SyntaxKind::GrantRoleStmt => "GrantRoleStmt",
+                    SyntaxKind::AlterDefaultPrivilegesStmt => {
+                        "AlterDefaultPrivilegesStmt"
+                    }
+                    SyntaxKind::ClosePortalStmt => "ClosePortalStmt",
+                    SyntaxKind::ClusterStmt => "ClusterStmt",
+                    SyntaxKind::CopyStmt => "CopyStmt",
+                    SyntaxKind::CreateStmt => "CreateStmt",
+                    SyntaxKind::DefineStmt => "DefineStmt",
+                    SyntaxKind::DropStmt => "DropStmt",
+                    SyntaxKind::TruncateStmt => "TruncateStmt",
+                    SyntaxKind::CommentStmt => "CommentStmt",
+                    SyntaxKind::FetchStmt => "FetchStmt",
+                    SyntaxKind::IndexStmt => "IndexStmt",
+                    SyntaxKind::CreateFunctionStmt => "CreateFunctionStmt",
+                    SyntaxKind::AlterFunctionStmt => "AlterFunctionStmt",
+                    SyntaxKind::DoStmt => "DoStmt",
+                    SyntaxKind::RenameStmt => "RenameStmt",
+                    SyntaxKind::RuleStmt => "RuleStmt",
+                    SyntaxKind::NotifyStmt => "NotifyStmt",
+                    SyntaxKind::ListenStmt => "ListenStmt",
+                    SyntaxKind::UnlistenStmt => "UnlistenStmt",
+                    SyntaxKind::TransactionStmt => "TransactionStmt",
+                    SyntaxKind::ViewStmt => "ViewStmt",
+                    SyntaxKind::LoadStmt => "LoadStmt",
+                    SyntaxKind::CreateDomainStmt => "CreateDomainStmt",
+                    SyntaxKind::CreatedbStmt => "CreatedbStmt",
+                    SyntaxKind::DropdbStmt => "DropdbStmt",
+                    SyntaxKind::VacuumStmt => "VacuumStmt",
+                    SyntaxKind::ExplainStmt => "ExplainStmt",
+                    SyntaxKind::CreateTableAsStmt => "CreateTableAsStmt",
+                    SyntaxKind::CreateSeqStmt => "CreateSeqStmt",
+                    SyntaxKind::AlterSeqStmt => "AlterSeqStmt",
+                    SyntaxKind::VariableSetStmt => "VariableSetStmt",
+                    SyntaxKind::VariableShowStmt => "VariableShowStmt",
+                    SyntaxKind::DiscardStmt => "DiscardStmt",
+                    SyntaxKind::CreateTrigStmt => "CreateTrigStmt",
+                    SyntaxKind::CreatePlangStmt => "CreatePlangStmt",
+                    SyntaxKind::CreateRoleStmt => "CreateRoleStmt",
+                    SyntaxKind::AlterRoleStmt => "AlterRoleStmt",
+                    SyntaxKind::DropRoleStmt => "DropRoleStmt",
+                    SyntaxKind::LockStmt => "LockStmt",
+                    SyntaxKind::ConstraintsSetStmt => "ConstraintsSetStmt",
+                    SyntaxKind::ReindexStmt => "ReindexStmt",
+                    SyntaxKind::CheckPointStmt => "CheckPointStmt",
+                    SyntaxKind::CreateSchemaStmt => "CreateSchemaStmt",
+                    SyntaxKind::AlterDatabaseStmt => "AlterDatabaseStmt",
+                    SyntaxKind::AlterDatabaseRefreshCollStmt => {
+                        "AlterDatabaseRefreshCollStmt"
+                    }
+                    SyntaxKind::AlterDatabaseSetStmt => "AlterDatabaseSetStmt",
+                    SyntaxKind::AlterRoleSetStmt => "AlterRoleSetStmt",
+                    SyntaxKind::CreateConversionStmt => "CreateConversionStmt",
+                    SyntaxKind::CreateCastStmt => "CreateCastStmt",
+                    SyntaxKind::CreateOpClassStmt => "CreateOpClassStmt",
+                    SyntaxKind::CreateOpFamilyStmt => "CreateOpFamilyStmt",
+                    SyntaxKind::AlterOpFamilyStmt => "AlterOpFamilyStmt",
+                    SyntaxKind::PrepareStmt => "PrepareStmt",
+                    SyntaxKind::ExecuteStmt => "ExecuteStmt",
+                    SyntaxKind::DeallocateStmt => "DeallocateStmt",
+                    SyntaxKind::DeclareCursorStmt => "DeclareCursorStmt",
+                    SyntaxKind::CreateTableSpaceStmt => "CreateTableSpaceStmt",
+                    SyntaxKind::DropTableSpaceStmt => "DropTableSpaceStmt",
+                    SyntaxKind::AlterObjectDependsStmt => "AlterObjectDependsStmt",
+                    SyntaxKind::AlterObjectSchemaStmt => "AlterObjectSchemaStmt",
+                    SyntaxKind::AlterOwnerStmt => "AlterOwnerStmt",
+                    SyntaxKind::AlterOperatorStmt => "AlterOperatorStmt",
+                    SyntaxKind::AlterTypeStmt => "AlterTypeStmt",
+                    SyntaxKind::DropOwnedStmt => "DropOwnedStmt",
+                    SyntaxKind::ReassignOwnedStmt => "ReassignOwnedStmt",
+                    SyntaxKind::CompositeTypeStmt => "CompositeTypeStmt",
+                    SyntaxKind::CreateEnumStmt => "CreateEnumStmt",
+                    SyntaxKind::CreateRangeStmt => "CreateRangeStmt",
+                    SyntaxKind::AlterEnumStmt => "AlterEnumStmt",
+                    SyntaxKind::AlterTsdictionaryStmt => "AlterTsdictionaryStmt",
+                    SyntaxKind::AlterTsconfigurationStmt => "AlterTsconfigurationStmt",
+                    SyntaxKind::CreateFdwStmt => "CreateFdwStmt",
+                    SyntaxKind::AlterFdwStmt => "AlterFdwStmt",
+                    SyntaxKind::CreateForeignServerStmt => "CreateForeignServerStmt",
+                    SyntaxKind::AlterForeignServerStmt => "AlterForeignServerStmt",
+                    SyntaxKind::CreateUserMappingStmt => "CreateUserMappingStmt",
+                    SyntaxKind::AlterUserMappingStmt => "AlterUserMappingStmt",
+                    SyntaxKind::DropUserMappingStmt => "DropUserMappingStmt",
+                    SyntaxKind::AlterTableSpaceOptionsStmt => {
+                        "AlterTableSpaceOptionsStmt"
+                    }
+                    SyntaxKind::AlterTableMoveAllStmt => "AlterTableMoveAllStmt",
+                    SyntaxKind::SecLabelStmt => "SecLabelStmt",
+                    SyntaxKind::CreateForeignTableStmt => "CreateForeignTableStmt",
+                    SyntaxKind::ImportForeignSchemaStmt => "ImportForeignSchemaStmt",
+                    SyntaxKind::CreateExtensionStmt => "CreateExtensionStmt",
+                    SyntaxKind::AlterExtensionStmt => "AlterExtensionStmt",
+                    SyntaxKind::AlterExtensionContentsStmt => {
+                        "AlterExtensionContentsStmt"
+                    }
+                    SyntaxKind::CreateEventTrigStmt => "CreateEventTrigStmt",
+                    SyntaxKind::AlterEventTrigStmt => "AlterEventTrigStmt",
+                    SyntaxKind::RefreshMatViewStmt => "RefreshMatViewStmt",
+                    SyntaxKind::ReplicaIdentityStmt => "ReplicaIdentityStmt",
+                    SyntaxKind::AlterSystemStmt => "AlterSystemStmt",
+                    SyntaxKind::CreatePolicyStmt => "CreatePolicyStmt",
+                    SyntaxKind::AlterPolicyStmt => "AlterPolicyStmt",
+                    SyntaxKind::CreateTransformStmt => "CreateTransformStmt",
+                    SyntaxKind::CreateAmStmt => "CreateAmStmt",
+                    SyntaxKind::CreatePublicationStmt => "CreatePublicationStmt",
+                    SyntaxKind::AlterPublicationStmt => "AlterPublicationStmt",
+                    SyntaxKind::CreateSubscriptionStmt => "CreateSubscriptionStmt",
+                    SyntaxKind::AlterSubscriptionStmt => "AlterSubscriptionStmt",
+                    SyntaxKind::DropSubscriptionStmt => "DropSubscriptionStmt",
+                    SyntaxKind::CreateStatsStmt => "CreateStatsStmt",
+                    SyntaxKind::AlterCollationStmt => "AlterCollationStmt",
+                    SyntaxKind::CallStmt => "CallStmt",
+                    SyntaxKind::AlterStatsStmt => "AlterStatsStmt",
+                    SyntaxKind::AExpr => "AExpr",
+                    SyntaxKind::ColumnRef => "ColumnRef",
+                    SyntaxKind::ParamRef => "ParamRef",
+                    SyntaxKind::FuncCall => "FuncCall",
+                    SyntaxKind::AStar => "AStar",
+                    SyntaxKind::AIndices => "AIndices",
+                    SyntaxKind::AIndirection => "AIndirection",
+                    SyntaxKind::AArrayExpr => "AArrayExpr",
+                    SyntaxKind::ResTarget => "ResTarget",
+                    SyntaxKind::MultiAssignRef => "MultiAssignRef",
+                    SyntaxKind::TypeCast => "TypeCast",
+                    SyntaxKind::CollateClause => "CollateClause",
+                    SyntaxKind::SortBy => "SortBy",
+                    SyntaxKind::WindowDef => "WindowDef",
+                    SyntaxKind::RangeSubselect => "RangeSubselect",
+                    SyntaxKind::RangeFunction => "RangeFunction",
+                    SyntaxKind::RangeTableSample => "RangeTableSample",
+                    SyntaxKind::RangeTableFunc => "RangeTableFunc",
+                    SyntaxKind::RangeTableFuncCol => "RangeTableFuncCol",
+                    SyntaxKind::TypeName => "TypeName",
+                    SyntaxKind::ColumnDef => "ColumnDef",
+                    SyntaxKind::IndexElem => "IndexElem",
+                    SyntaxKind::StatsElem => "StatsElem",
+                    SyntaxKind::Constraint => "Constraint",
+                    SyntaxKind::DefElem => "DefElem",
+                    SyntaxKind::RangeTblEntry => "RangeTblEntry",
+                    SyntaxKind::RangeTblFunction => "RangeTblFunction",
+                    SyntaxKind::TableSampleClause => "TableSampleClause",
+                    SyntaxKind::WithCheckOption => "WithCheckOption",
+                    SyntaxKind::SortGroupClause => "SortGroupClause",
+                    SyntaxKind::GroupingSet => "GroupingSet",
+                    SyntaxKind::WindowClause => "WindowClause",
+                    SyntaxKind::ObjectWithArgs => "ObjectWithArgs",
+                    SyntaxKind::AccessPriv => "AccessPriv",
+                    SyntaxKind::CreateOpClassItem => "CreateOpClassItem",
+                    SyntaxKind::TableLikeClause => "TableLikeClause",
+                    SyntaxKind::FunctionParameter => "FunctionParameter",
+                    SyntaxKind::LockingClause => "LockingClause",
+                    SyntaxKind::RowMarkClause => "RowMarkClause",
+                    SyntaxKind::XmlSerialize => "XmlSerialize",
+                    SyntaxKind::WithClause => "WithClause",
+                    SyntaxKind::InferClause => "InferClause",
+                    SyntaxKind::OnConflictClause => "OnConflictClause",
+                    SyntaxKind::CtesearchClause => "CtesearchClause",
+                    SyntaxKind::CtecycleClause => "CtecycleClause",
+                    SyntaxKind::CommonTableExpr => "CommonTableExpr",
+                    SyntaxKind::MergeWhenClause => "MergeWhenClause",
+                    SyntaxKind::RoleSpec => "RoleSpec",
+                    SyntaxKind::TriggerTransition => "TriggerTransition",
+                    SyntaxKind::PartitionElem => "PartitionElem",
+                    SyntaxKind::PartitionSpec => "PartitionSpec",
+                    SyntaxKind::PartitionBoundSpec => "PartitionBoundSpec",
+                    SyntaxKind::PartitionRangeDatum => "PartitionRangeDatum",
+                    SyntaxKind::PartitionCmd => "PartitionCmd",
+                    SyntaxKind::VacuumRelation => "VacuumRelation",
+                    SyntaxKind::PublicationObjSpec => "PublicationObjSpec",
+                    SyntaxKind::PublicationTable => "PublicationTable",
+                    SyntaxKind::InlineCodeBlock => "InlineCodeBlock",
+                    SyntaxKind::CallContext => "CallContext",
+                    SyntaxKind::Integer => "Integer",
+                    SyntaxKind::Float => "Float",
+                    SyntaxKind::Boolean => "Boolean",
+                    SyntaxKind::String => "String",
+                    SyntaxKind::BitString => "BitString",
+                    SyntaxKind::List => "List",
+                    SyntaxKind::IntList => "IntList",
+                    SyntaxKind::OidList => "OidList",
+                    SyntaxKind::AConst => "AConst",
+                    SyntaxKind::Nul => "Nul",
+                    SyntaxKind::Ascii37 => "Ascii37",
+                    SyntaxKind::Ascii40 => "Ascii40",
+                    SyntaxKind::Ascii41 => "Ascii41",
+                    SyntaxKind::Ascii42 => "Ascii42",
+                    SyntaxKind::Ascii43 => "Ascii43",
+                    SyntaxKind::Ascii44 => "Ascii44",
+                    SyntaxKind::Ascii45 => "Ascii45",
+                    SyntaxKind::Ascii46 => "Ascii46",
+                    SyntaxKind::Ascii47 => "Ascii47",
+                    SyntaxKind::Ascii58 => "Ascii58",
+                    SyntaxKind::Ascii59 => "Ascii59",
+                    SyntaxKind::Ascii60 => "Ascii60",
+                    SyntaxKind::Ascii61 => "Ascii61",
+                    SyntaxKind::Ascii62 => "Ascii62",
+                    SyntaxKind::Ascii63 => "Ascii63",
+                    SyntaxKind::Ascii91 => "Ascii91",
+                    SyntaxKind::Ascii92 => "Ascii92",
+                    SyntaxKind::Ascii93 => "Ascii93",
+                    SyntaxKind::Ascii94 => "Ascii94",
+                    SyntaxKind::Ident => "Ident",
+                    SyntaxKind::Uident => "Uident",
+                    SyntaxKind::Fconst => "Fconst",
+                    SyntaxKind::Sconst => "Sconst",
+                    SyntaxKind::Usconst => "Usconst",
+                    SyntaxKind::Bconst => "Bconst",
+                    SyntaxKind::Xconst => "Xconst",
+                    SyntaxKind::Op => "Op",
+                    SyntaxKind::Iconst => "Iconst",
+                    SyntaxKind::Typecast => "Typecast",
+                    SyntaxKind::DotDot => "DotDot",
+                    SyntaxKind::ColonEquals => "ColonEquals",
+                    SyntaxKind::EqualsGreater => "EqualsGreater",
+                    SyntaxKind::LessEquals => "LessEquals",
+                    SyntaxKind::GreaterEquals => "GreaterEquals",
+                    SyntaxKind::NotEquals => "NotEquals",
+                    SyntaxKind::SqlComment => "SqlComment",
+                    SyntaxKind::CComment => "CComment",
+                    SyntaxKind::AbortP => "AbortP",
+                    SyntaxKind::AbsoluteP => "AbsoluteP",
+                    SyntaxKind::Access => "Access",
+                    SyntaxKind::Action => "Action",
+                    SyntaxKind::AddP => "AddP",
+                    SyntaxKind::Admin => "Admin",
+                    SyntaxKind::After => "After",
+                    SyntaxKind::Aggregate => "Aggregate",
+                    SyntaxKind::All => "All",
+                    SyntaxKind::Also => "Also",
+                    SyntaxKind::Alter => "Alter",
+                    SyntaxKind::Always => "Always",
+                    SyntaxKind::Analyse => "Analyse",
+                    SyntaxKind::Analyze => "Analyze",
+                    SyntaxKind::And => "And",
+                    SyntaxKind::Any => "Any",
+                    SyntaxKind::Array => "Array",
+                    SyntaxKind::As => "As",
+                    SyntaxKind::Asc => "Asc",
+                    SyntaxKind::Asensitive => "Asensitive",
+                    SyntaxKind::Assertion => "Assertion",
+                    SyntaxKind::Assignment => "Assignment",
+                    SyntaxKind::Asymmetric => "Asymmetric",
+                    SyntaxKind::Atomic => "Atomic",
+                    SyntaxKind::At => "At",
+                    SyntaxKind::Attach => "Attach",
+                    SyntaxKind::Attribute => "Attribute",
+                    SyntaxKind::Authorization => "Authorization",
+                    SyntaxKind::Backward => "Backward",
+                    SyntaxKind::Before => "Before",
+                    SyntaxKind::BeginP => "BeginP",
+                    SyntaxKind::Between => "Between",
+                    SyntaxKind::Bigint => "Bigint",
+                    SyntaxKind::Binary => "Binary",
+                    SyntaxKind::Bit => "Bit",
+                    SyntaxKind::BooleanP => "BooleanP",
+                    SyntaxKind::Both => "Both",
+                    SyntaxKind::Breadth => "Breadth",
+                    SyntaxKind::By => "By",
+                    SyntaxKind::Cache => "Cache",
+                    SyntaxKind::Call => "Call",
+                    SyntaxKind::Called => "Called",
+                    SyntaxKind::Cascade => "Cascade",
+                    SyntaxKind::Cascaded => "Cascaded",
+                    SyntaxKind::Case => "Case",
+                    SyntaxKind::Cast => "Cast",
+                    SyntaxKind::CatalogP => "CatalogP",
+                    SyntaxKind::Chain => "Chain",
+                    SyntaxKind::CharP => "CharP",
+                    SyntaxKind::Character => "Character",
+                    SyntaxKind::Characteristics => "Characteristics",
+                    SyntaxKind::Check => "Check",
+                    SyntaxKind::Checkpoint => "Checkpoint",
+                    SyntaxKind::Class => "Class",
+                    SyntaxKind::Close => "Close",
+                    SyntaxKind::Cluster => "Cluster",
+                    SyntaxKind::Coalesce => "Coalesce",
+                    SyntaxKind::Collate => "Collate",
+                    SyntaxKind::Collation => "Collation",
+                    SyntaxKind::Column => "Column",
+                    SyntaxKind::Columns => "Columns",
+                    SyntaxKind::Comments => "Comments",
+                    SyntaxKind::Commit => "Commit",
+                    SyntaxKind::Committed => "Committed",
+                    SyntaxKind::Compression => "Compression",
+                    SyntaxKind::Concurrently => "Concurrently",
+                    SyntaxKind::Configuration => "Configuration",
+                    SyntaxKind::Conflict => "Conflict",
+                    SyntaxKind::Connection => "Connection",
+                    SyntaxKind::Constraints => "Constraints",
+                    SyntaxKind::ContentP => "ContentP",
+                    SyntaxKind::ContinueP => "ContinueP",
+                    SyntaxKind::ConversionP => "ConversionP",
+                    SyntaxKind::Copy => "Copy",
+                    SyntaxKind::Cost => "Cost",
+                    SyntaxKind::Create => "Create",
+                    SyntaxKind::Cross => "Cross",
+                    SyntaxKind::Csv => "Csv",
+                    SyntaxKind::Cube => "Cube",
+                    SyntaxKind::CurrentP => "CurrentP",
+                    SyntaxKind::CurrentCatalog => "CurrentCatalog",
+                    SyntaxKind::CurrentDate => "CurrentDate",
+                    SyntaxKind::CurrentRole => "CurrentRole",
+                    SyntaxKind::CurrentSchema => "CurrentSchema",
+                    SyntaxKind::CurrentTime => "CurrentTime",
+                    SyntaxKind::CurrentTimestamp => "CurrentTimestamp",
+                    SyntaxKind::CurrentUser => "CurrentUser",
+                    SyntaxKind::Cursor => "Cursor",
+                    SyntaxKind::Cycle => "Cycle",
+                    SyntaxKind::DataP => "DataP",
+                    SyntaxKind::Database => "Database",
+                    SyntaxKind::DayP => "DayP",
+                    SyntaxKind::Deallocate => "Deallocate",
+                    SyntaxKind::Dec => "Dec",
+                    SyntaxKind::DecimalP => "DecimalP",
+                    SyntaxKind::Declare => "Declare",
+                    SyntaxKind::Default => "Default",
+                    SyntaxKind::Defaults => "Defaults",
+                    SyntaxKind::Deferrable => "Deferrable",
+                    SyntaxKind::Deferred => "Deferred",
+                    SyntaxKind::Definer => "Definer",
+                    SyntaxKind::DeleteP => "DeleteP",
+                    SyntaxKind::Delimiter => "Delimiter",
+                    SyntaxKind::Delimiters => "Delimiters",
+                    SyntaxKind::Depends => "Depends",
+                    SyntaxKind::Depth => "Depth",
+                    SyntaxKind::Desc => "Desc",
+                    SyntaxKind::Detach => "Detach",
+                    SyntaxKind::Dictionary => "Dictionary",
+                    SyntaxKind::DisableP => "DisableP",
+                    SyntaxKind::Discard => "Discard",
+                    SyntaxKind::Distinct => "Distinct",
+                    SyntaxKind::Do => "Do",
+                    SyntaxKind::DocumentP => "DocumentP",
+                    SyntaxKind::DomainP => "DomainP",
+                    SyntaxKind::DoubleP => "DoubleP",
+                    SyntaxKind::Drop => "Drop",
+                    SyntaxKind::Each => "Each",
+                    SyntaxKind::Else => "Else",
+                    SyntaxKind::EnableP => "EnableP",
+                    SyntaxKind::Encoding => "Encoding",
+                    SyntaxKind::Encrypted => "Encrypted",
+                    SyntaxKind::EndP => "EndP",
+                    SyntaxKind::EnumP => "EnumP",
+                    SyntaxKind::Escape => "Escape",
+                    SyntaxKind::Event => "Event",
+                    SyntaxKind::Except => "Except",
+                    SyntaxKind::Exclude => "Exclude",
+                    SyntaxKind::Excluding => "Excluding",
+                    SyntaxKind::Exclusive => "Exclusive",
+                    SyntaxKind::Execute => "Execute",
+                    SyntaxKind::Exists => "Exists",
+                    SyntaxKind::Explain => "Explain",
+                    SyntaxKind::Expression => "Expression",
+                    SyntaxKind::Extension => "Extension",
+                    SyntaxKind::External => "External",
+                    SyntaxKind::Extract => "Extract",
+                    SyntaxKind::FalseP => "FalseP",
+                    SyntaxKind::Family => "Family",
+                    SyntaxKind::Fetch => "Fetch",
+                    SyntaxKind::Filter => "Filter",
+                    SyntaxKind::Finalize => "Finalize",
+                    SyntaxKind::FirstP => "FirstP",
+                    SyntaxKind::FloatP => "FloatP",
+                    SyntaxKind::Following => "Following",
+                    SyntaxKind::For => "For",
+                    SyntaxKind::Force => "Force",
+                    SyntaxKind::Foreign => "Foreign",
+                    SyntaxKind::Forward => "Forward",
+                    SyntaxKind::Freeze => "Freeze",
+                    SyntaxKind::From => "From",
+                    SyntaxKind::Full => "Full",
+                    SyntaxKind::Function => "Function",
+                    SyntaxKind::Functions => "Functions",
+                    SyntaxKind::Generated => "Generated",
+                    SyntaxKind::Global => "Global",
+                    SyntaxKind::Grant => "Grant",
+                    SyntaxKind::Granted => "Granted",
+                    SyntaxKind::Greatest => "Greatest",
+                    SyntaxKind::GroupP => "GroupP",
+                    SyntaxKind::Grouping => "Grouping",
+                    SyntaxKind::Groups => "Groups",
+                    SyntaxKind::Handler => "Handler",
+                    SyntaxKind::Having => "Having",
+                    SyntaxKind::HeaderP => "HeaderP",
+                    SyntaxKind::Hold => "Hold",
+                    SyntaxKind::HourP => "HourP",
+                    SyntaxKind::IdentityP => "IdentityP",
+                    SyntaxKind::IfP => "IfP",
+                    SyntaxKind::Ilike => "Ilike",
+                    SyntaxKind::Immediate => "Immediate",
+                    SyntaxKind::Immutable => "Immutable",
+                    SyntaxKind::ImplicitP => "ImplicitP",
+                    SyntaxKind::ImportP => "ImportP",
+                    SyntaxKind::InP => "InP",
+                    SyntaxKind::Include => "Include",
+                    SyntaxKind::Including => "Including",
+                    SyntaxKind::Increment => "Increment",
+                    SyntaxKind::Index => "Index",
+                    SyntaxKind::Indexes => "Indexes",
+                    SyntaxKind::Inherit => "Inherit",
+                    SyntaxKind::Inherits => "Inherits",
+                    SyntaxKind::Initially => "Initially",
+                    SyntaxKind::InlineP => "InlineP",
+                    SyntaxKind::InnerP => "InnerP",
+                    SyntaxKind::Inout => "Inout",
+                    SyntaxKind::InputP => "InputP",
+                    SyntaxKind::Insensitive => "Insensitive",
+                    SyntaxKind::Insert => "Insert",
+                    SyntaxKind::Instead => "Instead",
+                    SyntaxKind::IntP => "IntP",
+                    SyntaxKind::Intersect => "Intersect",
+                    SyntaxKind::Interval => "Interval",
+                    SyntaxKind::Into => "Into",
+                    SyntaxKind::Invoker => "Invoker",
+                    SyntaxKind::Is => "Is",
+                    SyntaxKind::Isnull => "Isnull",
+                    SyntaxKind::Isolation => "Isolation",
+                    SyntaxKind::Join => "Join",
+                    SyntaxKind::Key => "Key",
+                    SyntaxKind::Label => "Label",
+                    SyntaxKind::Language => "Language",
+                    SyntaxKind::LargeP => "LargeP",
+                    SyntaxKind::LastP => "LastP",
+                    SyntaxKind::LateralP => "LateralP",
+                    SyntaxKind::Leading => "Leading",
+                    SyntaxKind::Leakproof => "Leakproof",
+                    SyntaxKind::Least => "Least",
+                    SyntaxKind::Left => "Left",
+                    SyntaxKind::Level => "Level",
+                    SyntaxKind::Like => "Like",
+                    SyntaxKind::Limit => "Limit",
+                    SyntaxKind::Listen => "Listen",
+                    SyntaxKind::Load => "Load",
+                    SyntaxKind::Local => "Local",
+                    SyntaxKind::Localtime => "Localtime",
+                    SyntaxKind::Localtimestamp => "Localtimestamp",
+                    SyntaxKind::Location => "Location",
+                    SyntaxKind::LockP => "LockP",
+                    SyntaxKind::Locked => "Locked",
+                    SyntaxKind::Logged => "Logged",
+                    SyntaxKind::Mapping => "Mapping",
+                    SyntaxKind::Match => "Match",
+                    SyntaxKind::Matched => "Matched",
+                    SyntaxKind::Materialized => "Materialized",
+                    SyntaxKind::Maxvalue => "Maxvalue",
+                    SyntaxKind::Merge => "Merge",
+                    SyntaxKind::Method => "Method",
+                    SyntaxKind::MinuteP => "MinuteP",
+                    SyntaxKind::Minvalue => "Minvalue",
+                    SyntaxKind::Mode => "Mode",
+                    SyntaxKind::MonthP => "MonthP",
+                    SyntaxKind::Move => "Move",
+                    SyntaxKind::NameP => "NameP",
+                    SyntaxKind::Names => "Names",
+                    SyntaxKind::National => "National",
+                    SyntaxKind::Natural => "Natural",
+                    SyntaxKind::Nchar => "Nchar",
+                    SyntaxKind::New => "New",
+                    SyntaxKind::Next => "Next",
+                    SyntaxKind::Nfc => "Nfc",
+                    SyntaxKind::Nfd => "Nfd",
+                    SyntaxKind::Nfkc => "Nfkc",
+                    SyntaxKind::Nfkd => "Nfkd",
+                    SyntaxKind::No => "No",
+                    SyntaxKind::None => "None",
+                    SyntaxKind::Normalize => "Normalize",
+                    SyntaxKind::Normalized => "Normalized",
+                    SyntaxKind::Not => "Not",
+                    SyntaxKind::Nothing => "Nothing",
+                    SyntaxKind::Notify => "Notify",
+                    SyntaxKind::Notnull => "Notnull",
+                    SyntaxKind::Nowait => "Nowait",
+                    SyntaxKind::NullP => "NullP",
+                    SyntaxKind::Nullif => "Nullif",
+                    SyntaxKind::NullsP => "NullsP",
+                    SyntaxKind::Numeric => "Numeric",
+                    SyntaxKind::ObjectP => "ObjectP",
+                    SyntaxKind::Of => "Of",
+                    SyntaxKind::Off => "Off",
+                    SyntaxKind::Offset => "Offset",
+                    SyntaxKind::Oids => "Oids",
+                    SyntaxKind::Old => "Old",
+                    SyntaxKind::On => "On",
+                    SyntaxKind::Only => "Only",
+                    SyntaxKind::Operator => "Operator",
+                    SyntaxKind::Option => "Option",
+                    SyntaxKind::Options => "Options",
+                    SyntaxKind::Or => "Or",
+                    SyntaxKind::Order => "Order",
+                    SyntaxKind::Ordinality => "Ordinality",
+                    SyntaxKind::Others => "Others",
+                    SyntaxKind::OutP => "OutP",
+                    SyntaxKind::OuterP => "OuterP",
+                    SyntaxKind::Over => "Over",
+                    SyntaxKind::Overlaps => "Overlaps",
+                    SyntaxKind::Overlay => "Overlay",
+                    SyntaxKind::Overriding => "Overriding",
+                    SyntaxKind::Owned => "Owned",
+                    SyntaxKind::Owner => "Owner",
+                    SyntaxKind::Parallel => "Parallel",
+                    SyntaxKind::Parameter => "Parameter",
+                    SyntaxKind::Parser => "Parser",
+                    SyntaxKind::Partial => "Partial",
+                    SyntaxKind::Partition => "Partition",
+                    SyntaxKind::Passing => "Passing",
+                    SyntaxKind::Password => "Password",
+                    SyntaxKind::Placing => "Placing",
+                    SyntaxKind::Plans => "Plans",
+                    SyntaxKind::Policy => "Policy",
+                    SyntaxKind::Position => "Position",
+                    SyntaxKind::Preceding => "Preceding",
+                    SyntaxKind::Precision => "Precision",
+                    SyntaxKind::Preserve => "Preserve",
+                    SyntaxKind::Prepare => "Prepare",
+                    SyntaxKind::Prepared => "Prepared",
+                    SyntaxKind::Primary => "Primary",
+                    SyntaxKind::Prior => "Prior",
+                    SyntaxKind::Privileges => "Privileges",
+                    SyntaxKind::Procedural => "Procedural",
+                    SyntaxKind::Procedure => "Procedure",
+                    SyntaxKind::Procedures => "Procedures",
+                    SyntaxKind::Program => "Program",
+                    SyntaxKind::Publication => "Publication",
+                    SyntaxKind::Quote => "Quote",
+                    SyntaxKind::Range => "Range",
+                    SyntaxKind::Read => "Read",
+                    SyntaxKind::Real => "Real",
+                    SyntaxKind::Reassign => "Reassign",
+                    SyntaxKind::Recheck => "Recheck",
+                    SyntaxKind::Recursive => "Recursive",
+                    SyntaxKind::RefP => "RefP",
+                    SyntaxKind::References => "References",
+                    SyntaxKind::Referencing => "Referencing",
+                    SyntaxKind::Refresh => "Refresh",
+                    SyntaxKind::Reindex => "Reindex",
+                    SyntaxKind::RelativeP => "RelativeP",
+                    SyntaxKind::Release => "Release",
+                    SyntaxKind::Rename => "Rename",
+                    SyntaxKind::Repeatable => "Repeatable",
+                    SyntaxKind::Replace => "Replace",
+                    SyntaxKind::Replica => "Replica",
+                    SyntaxKind::Reset => "Reset",
+                    SyntaxKind::Restart => "Restart",
+                    SyntaxKind::Restrict => "Restrict",
+                    SyntaxKind::Return => "Return",
+                    SyntaxKind::Returning => "Returning",
+                    SyntaxKind::Returns => "Returns",
+                    SyntaxKind::Revoke => "Revoke",
+                    SyntaxKind::Right => "Right",
+                    SyntaxKind::Role => "Role",
+                    SyntaxKind::Rollback => "Rollback",
+                    SyntaxKind::Rollup => "Rollup",
+                    SyntaxKind::Routine => "Routine",
+                    SyntaxKind::Routines => "Routines",
+                    SyntaxKind::Row => "Row",
+                    SyntaxKind::Rows => "Rows",
+                    SyntaxKind::Rule => "Rule",
+                    SyntaxKind::Savepoint => "Savepoint",
+                    SyntaxKind::Schema => "Schema",
+                    SyntaxKind::Schemas => "Schemas",
+                    SyntaxKind::Scroll => "Scroll",
+                    SyntaxKind::Search => "Search",
+                    SyntaxKind::SecondP => "SecondP",
+                    SyntaxKind::Security => "Security",
+                    SyntaxKind::Select => "Select",
+                    SyntaxKind::Sequence => "Sequence",
+                    SyntaxKind::Sequences => "Sequences",
+                    SyntaxKind::Serializable => "Serializable",
+                    SyntaxKind::Server => "Server",
+                    SyntaxKind::Session => "Session",
+                    SyntaxKind::SessionUser => "SessionUser",
+                    SyntaxKind::Set => "Set",
+                    SyntaxKind::Sets => "Sets",
+                    SyntaxKind::Setof => "Setof",
+                    SyntaxKind::Share => "Share",
+                    SyntaxKind::Show => "Show",
+                    SyntaxKind::Similar => "Similar",
+                    SyntaxKind::Simple => "Simple",
+                    SyntaxKind::Skip => "Skip",
+                    SyntaxKind::Smallint => "Smallint",
+                    SyntaxKind::Snapshot => "Snapshot",
+                    SyntaxKind::Some => "Some",
+                    SyntaxKind::SqlP => "SqlP",
+                    SyntaxKind::Stable => "Stable",
+                    SyntaxKind::StandaloneP => "StandaloneP",
+                    SyntaxKind::Start => "Start",
+                    SyntaxKind::Statement => "Statement",
+                    SyntaxKind::Statistics => "Statistics",
+                    SyntaxKind::Stdin => "Stdin",
+                    SyntaxKind::Stdout => "Stdout",
+                    SyntaxKind::Storage => "Storage",
+                    SyntaxKind::Stored => "Stored",
+                    SyntaxKind::StrictP => "StrictP",
+                    SyntaxKind::StripP => "StripP",
+                    SyntaxKind::Subscription => "Subscription",
+                    SyntaxKind::Substring => "Substring",
+                    SyntaxKind::Support => "Support",
+                    SyntaxKind::Symmetric => "Symmetric",
+                    SyntaxKind::Sysid => "Sysid",
+                    SyntaxKind::SystemP => "SystemP",
+                    SyntaxKind::Table => "Table",
+                    SyntaxKind::Tables => "Tables",
+                    SyntaxKind::Tablesample => "Tablesample",
+                    SyntaxKind::Tablespace => "Tablespace",
+                    SyntaxKind::Temp => "Temp",
+                    SyntaxKind::Template => "Template",
+                    SyntaxKind::Temporary => "Temporary",
+                    SyntaxKind::TextP => "TextP",
+                    SyntaxKind::Then => "Then",
+                    SyntaxKind::Ties => "Ties",
+                    SyntaxKind::Time => "Time",
+                    SyntaxKind::Timestamp => "Timestamp",
+                    SyntaxKind::To => "To",
+                    SyntaxKind::Trailing => "Trailing",
+                    SyntaxKind::Transaction => "Transaction",
+                    SyntaxKind::Transform => "Transform",
+                    SyntaxKind::Treat => "Treat",
+                    SyntaxKind::Trigger => "Trigger",
+                    SyntaxKind::Trim => "Trim",
+                    SyntaxKind::TrueP => "TrueP",
+                    SyntaxKind::Truncate => "Truncate",
+                    SyntaxKind::Trusted => "Trusted",
+                    SyntaxKind::TypeP => "TypeP",
+                    SyntaxKind::TypesP => "TypesP",
+                    SyntaxKind::Uescape => "Uescape",
+                    SyntaxKind::Unbounded => "Unbounded",
+                    SyntaxKind::Uncommitted => "Uncommitted",
+                    SyntaxKind::Unencrypted => "Unencrypted",
+                    SyntaxKind::Union => "Union",
+                    SyntaxKind::Unique => "Unique",
+                    SyntaxKind::Unknown => "Unknown",
+                    SyntaxKind::Unlisten => "Unlisten",
+                    SyntaxKind::Unlogged => "Unlogged",
+                    SyntaxKind::Until => "Until",
+                    SyntaxKind::Update => "Update",
+                    SyntaxKind::User => "User",
+                    SyntaxKind::Using => "Using",
+                    SyntaxKind::Vacuum => "Vacuum",
+                    SyntaxKind::Valid => "Valid",
+                    SyntaxKind::Validate => "Validate",
+                    SyntaxKind::Validator => "Validator",
+                    SyntaxKind::ValueP => "ValueP",
+                    SyntaxKind::Values => "Values",
+                    SyntaxKind::Varchar => "Varchar",
+                    SyntaxKind::Variadic => "Variadic",
+                    SyntaxKind::Varying => "Varying",
+                    SyntaxKind::Verbose => "Verbose",
+                    SyntaxKind::VersionP => "VersionP",
+                    SyntaxKind::View => "View",
+                    SyntaxKind::Views => "Views",
+                    SyntaxKind::Volatile => "Volatile",
+                    SyntaxKind::When => "When",
+                    SyntaxKind::Where => "Where",
+                    SyntaxKind::WhitespaceP => "WhitespaceP",
+                    SyntaxKind::Window => "Window",
+                    SyntaxKind::With => "With",
+                    SyntaxKind::Within => "Within",
+                    SyntaxKind::Without => "Without",
+                    SyntaxKind::Work => "Work",
+                    SyntaxKind::Wrapper => "Wrapper",
+                    SyntaxKind::Write => "Write",
+                    SyntaxKind::XmlP => "XmlP",
+                    SyntaxKind::Xmlattributes => "Xmlattributes",
+                    SyntaxKind::Xmlconcat => "Xmlconcat",
+                    SyntaxKind::Xmlelement => "Xmlelement",
+                    SyntaxKind::Xmlexists => "Xmlexists",
+                    SyntaxKind::Xmlforest => "Xmlforest",
+                    SyntaxKind::Xmlnamespaces => "Xmlnamespaces",
+                    SyntaxKind::Xmlparse => "Xmlparse",
+                    SyntaxKind::Xmlpi => "Xmlpi",
+                    SyntaxKind::Xmlroot => "Xmlroot",
+                    SyntaxKind::Xmlserialize => "Xmlserialize",
+                    SyntaxKind::Xmltable => "Xmltable",
+                    SyntaxKind::YearP => "YearP",
+                    SyntaxKind::YesP => "YesP",
+                    SyntaxKind::Zone => "Zone",
+                    SyntaxKind::NotLa => "NotLa",
+                    SyntaxKind::NullsLa => "NullsLa",
+                    SyntaxKind::WithLa => "WithLa",
+                    SyntaxKind::ModeTypeName => "ModeTypeName",
+                    SyntaxKind::ModePlpgsqlExpr => "ModePlpgsqlExpr",
+                    SyntaxKind::ModePlpgsqlAssign1 => "ModePlpgsqlAssign1",
+                    SyntaxKind::ModePlpgsqlAssign2 => "ModePlpgsqlAssign2",
+                    SyntaxKind::ModePlpgsqlAssign3 => "ModePlpgsqlAssign3",
+                    SyntaxKind::Uminus => "Uminus",
+                },
+            )
+        }
+    }
+    #[automatically_derived]
+    impl ::cstree::Syntax for SyntaxKind {
+        fn from_raw(raw: ::cstree::RawSyntaxKind) -> Self {
+            if !(raw.0 < 748u32) {
+                {
+                    ::core::panicking::panic_fmt(
+                        format_args!("Invalid raw syntax kind: {0}", raw.0),
+                    );
+                }
+            }
+            unsafe { ::std::mem::transmute::<u32, SyntaxKind>(raw.0) }
+        }
+        fn into_raw(self) -> ::cstree::RawSyntaxKind {
+            ::cstree::RawSyntaxKind(self as u32)
+        }
+        fn static_text(self) -> ::core::option::Option<&'static str> {
+            match self {
+                SyntaxKind::SourceFile => ::core::option::Option::None,
+                SyntaxKind::Comment => ::core::option::Option::None,
+                SyntaxKind::Whitespace => ::core::option::Option::None,
+                SyntaxKind::Newline => ::core::option::Option::None,
+                SyntaxKind::Tab => ::core::option::Option::None,
+                SyntaxKind::Stmt => ::core::option::Option::None,
+                SyntaxKind::Alias => ::core::option::Option::None,
+                SyntaxKind::RangeVar => ::core::option::Option::None,
+                SyntaxKind::TableFunc => ::core::option::Option::None,
+                SyntaxKind::Var => ::core::option::Option::None,
+                SyntaxKind::Param => ::core::option::Option::None,
+                SyntaxKind::Aggref => ::core::option::Option::None,
+                SyntaxKind::GroupingFunc => ::core::option::Option::None,
+                SyntaxKind::WindowFunc => ::core::option::Option::None,
+                SyntaxKind::SubscriptingRef => ::core::option::Option::None,
+                SyntaxKind::FuncExpr => ::core::option::Option::None,
+                SyntaxKind::NamedArgExpr => ::core::option::Option::None,
+                SyntaxKind::OpExpr => ::core::option::Option::None,
+                SyntaxKind::DistinctExpr => ::core::option::Option::None,
+                SyntaxKind::NullIfExpr => ::core::option::Option::None,
+                SyntaxKind::ScalarArrayOpExpr => ::core::option::Option::None,
+                SyntaxKind::BoolExpr => ::core::option::Option::None,
+                SyntaxKind::SubLink => ::core::option::Option::None,
+                SyntaxKind::SubPlan => ::core::option::Option::None,
+                SyntaxKind::AlternativeSubPlan => ::core::option::Option::None,
+                SyntaxKind::FieldSelect => ::core::option::Option::None,
+                SyntaxKind::FieldStore => ::core::option::Option::None,
+                SyntaxKind::RelabelType => ::core::option::Option::None,
+                SyntaxKind::CoerceViaIo => ::core::option::Option::None,
+                SyntaxKind::ArrayCoerceExpr => ::core::option::Option::None,
+                SyntaxKind::ConvertRowtypeExpr => ::core::option::Option::None,
+                SyntaxKind::CollateExpr => ::core::option::Option::None,
+                SyntaxKind::CaseExpr => ::core::option::Option::None,
+                SyntaxKind::CaseWhen => ::core::option::Option::None,
+                SyntaxKind::CaseTestExpr => ::core::option::Option::None,
+                SyntaxKind::ArrayExpr => ::core::option::Option::None,
+                SyntaxKind::RowExpr => ::core::option::Option::None,
+                SyntaxKind::RowCompareExpr => ::core::option::Option::None,
+                SyntaxKind::CoalesceExpr => ::core::option::Option::None,
+                SyntaxKind::MinMaxExpr => ::core::option::Option::None,
+                SyntaxKind::SqlvalueFunction => ::core::option::Option::None,
+                SyntaxKind::XmlExpr => ::core::option::Option::None,
+                SyntaxKind::NullTest => ::core::option::Option::None,
+                SyntaxKind::BooleanTest => ::core::option::Option::None,
+                SyntaxKind::CoerceToDomain => ::core::option::Option::None,
+                SyntaxKind::CoerceToDomainValue => ::core::option::Option::None,
+                SyntaxKind::SetToDefault => ::core::option::Option::None,
+                SyntaxKind::CurrentOfExpr => ::core::option::Option::None,
+                SyntaxKind::NextValueExpr => ::core::option::Option::None,
+                SyntaxKind::InferenceElem => ::core::option::Option::None,
+                SyntaxKind::TargetEntry => ::core::option::Option::None,
+                SyntaxKind::RangeTblRef => ::core::option::Option::None,
+                SyntaxKind::JoinExpr => ::core::option::Option::None,
+                SyntaxKind::FromExpr => ::core::option::Option::None,
+                SyntaxKind::OnConflictExpr => ::core::option::Option::None,
+                SyntaxKind::IntoClause => ::core::option::Option::None,
+                SyntaxKind::MergeAction => ::core::option::Option::None,
+                SyntaxKind::RawStmt => ::core::option::Option::None,
+                SyntaxKind::Query => ::core::option::Option::None,
+                SyntaxKind::InsertStmt => ::core::option::Option::None,
+                SyntaxKind::DeleteStmt => ::core::option::Option::None,
+                SyntaxKind::UpdateStmt => ::core::option::Option::None,
+                SyntaxKind::MergeStmt => ::core::option::Option::None,
+                SyntaxKind::SelectStmt => ::core::option::Option::None,
+                SyntaxKind::ReturnStmt => ::core::option::Option::None,
+                SyntaxKind::PlassignStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTableStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTableCmd => ::core::option::Option::None,
+                SyntaxKind::AlterDomainStmt => ::core::option::Option::None,
+                SyntaxKind::SetOperationStmt => ::core::option::Option::None,
+                SyntaxKind::GrantStmt => ::core::option::Option::None,
+                SyntaxKind::GrantRoleStmt => ::core::option::Option::None,
+                SyntaxKind::AlterDefaultPrivilegesStmt => ::core::option::Option::None,
+                SyntaxKind::ClosePortalStmt => ::core::option::Option::None,
+                SyntaxKind::ClusterStmt => ::core::option::Option::None,
+                SyntaxKind::CopyStmt => ::core::option::Option::None,
+                SyntaxKind::CreateStmt => ::core::option::Option::None,
+                SyntaxKind::DefineStmt => ::core::option::Option::None,
+                SyntaxKind::DropStmt => ::core::option::Option::None,
+                SyntaxKind::TruncateStmt => ::core::option::Option::None,
+                SyntaxKind::CommentStmt => ::core::option::Option::None,
+                SyntaxKind::FetchStmt => ::core::option::Option::None,
+                SyntaxKind::IndexStmt => ::core::option::Option::None,
+                SyntaxKind::CreateFunctionStmt => ::core::option::Option::None,
+                SyntaxKind::AlterFunctionStmt => ::core::option::Option::None,
+                SyntaxKind::DoStmt => ::core::option::Option::None,
+                SyntaxKind::RenameStmt => ::core::option::Option::None,
+                SyntaxKind::RuleStmt => ::core::option::Option::None,
+                SyntaxKind::NotifyStmt => ::core::option::Option::None,
+                SyntaxKind::ListenStmt => ::core::option::Option::None,
+                SyntaxKind::UnlistenStmt => ::core::option::Option::None,
+                SyntaxKind::TransactionStmt => ::core::option::Option::None,
+                SyntaxKind::ViewStmt => ::core::option::Option::None,
+                SyntaxKind::LoadStmt => ::core::option::Option::None,
+                SyntaxKind::CreateDomainStmt => ::core::option::Option::None,
+                SyntaxKind::CreatedbStmt => ::core::option::Option::None,
+                SyntaxKind::DropdbStmt => ::core::option::Option::None,
+                SyntaxKind::VacuumStmt => ::core::option::Option::None,
+                SyntaxKind::ExplainStmt => ::core::option::Option::None,
+                SyntaxKind::CreateTableAsStmt => ::core::option::Option::None,
+                SyntaxKind::CreateSeqStmt => ::core::option::Option::None,
+                SyntaxKind::AlterSeqStmt => ::core::option::Option::None,
+                SyntaxKind::VariableSetStmt => ::core::option::Option::None,
+                SyntaxKind::VariableShowStmt => ::core::option::Option::None,
+                SyntaxKind::DiscardStmt => ::core::option::Option::None,
+                SyntaxKind::CreateTrigStmt => ::core::option::Option::None,
+                SyntaxKind::CreatePlangStmt => ::core::option::Option::None,
+                SyntaxKind::CreateRoleStmt => ::core::option::Option::None,
+                SyntaxKind::AlterRoleStmt => ::core::option::Option::None,
+                SyntaxKind::DropRoleStmt => ::core::option::Option::None,
+                SyntaxKind::LockStmt => ::core::option::Option::None,
+                SyntaxKind::ConstraintsSetStmt => ::core::option::Option::None,
+                SyntaxKind::ReindexStmt => ::core::option::Option::None,
+                SyntaxKind::CheckPointStmt => ::core::option::Option::None,
+                SyntaxKind::CreateSchemaStmt => ::core::option::Option::None,
+                SyntaxKind::AlterDatabaseStmt => ::core::option::Option::None,
+                SyntaxKind::AlterDatabaseRefreshCollStmt => ::core::option::Option::None,
+                SyntaxKind::AlterDatabaseSetStmt => ::core::option::Option::None,
+                SyntaxKind::AlterRoleSetStmt => ::core::option::Option::None,
+                SyntaxKind::CreateConversionStmt => ::core::option::Option::None,
+                SyntaxKind::CreateCastStmt => ::core::option::Option::None,
+                SyntaxKind::CreateOpClassStmt => ::core::option::Option::None,
+                SyntaxKind::CreateOpFamilyStmt => ::core::option::Option::None,
+                SyntaxKind::AlterOpFamilyStmt => ::core::option::Option::None,
+                SyntaxKind::PrepareStmt => ::core::option::Option::None,
+                SyntaxKind::ExecuteStmt => ::core::option::Option::None,
+                SyntaxKind::DeallocateStmt => ::core::option::Option::None,
+                SyntaxKind::DeclareCursorStmt => ::core::option::Option::None,
+                SyntaxKind::CreateTableSpaceStmt => ::core::option::Option::None,
+                SyntaxKind::DropTableSpaceStmt => ::core::option::Option::None,
+                SyntaxKind::AlterObjectDependsStmt => ::core::option::Option::None,
+                SyntaxKind::AlterObjectSchemaStmt => ::core::option::Option::None,
+                SyntaxKind::AlterOwnerStmt => ::core::option::Option::None,
+                SyntaxKind::AlterOperatorStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTypeStmt => ::core::option::Option::None,
+                SyntaxKind::DropOwnedStmt => ::core::option::Option::None,
+                SyntaxKind::ReassignOwnedStmt => ::core::option::Option::None,
+                SyntaxKind::CompositeTypeStmt => ::core::option::Option::None,
+                SyntaxKind::CreateEnumStmt => ::core::option::Option::None,
+                SyntaxKind::CreateRangeStmt => ::core::option::Option::None,
+                SyntaxKind::AlterEnumStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTsdictionaryStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTsconfigurationStmt => ::core::option::Option::None,
+                SyntaxKind::CreateFdwStmt => ::core::option::Option::None,
+                SyntaxKind::AlterFdwStmt => ::core::option::Option::None,
+                SyntaxKind::CreateForeignServerStmt => ::core::option::Option::None,
+                SyntaxKind::AlterForeignServerStmt => ::core::option::Option::None,
+                SyntaxKind::CreateUserMappingStmt => ::core::option::Option::None,
+                SyntaxKind::AlterUserMappingStmt => ::core::option::Option::None,
+                SyntaxKind::DropUserMappingStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTableSpaceOptionsStmt => ::core::option::Option::None,
+                SyntaxKind::AlterTableMoveAllStmt => ::core::option::Option::None,
+                SyntaxKind::SecLabelStmt => ::core::option::Option::None,
+                SyntaxKind::CreateForeignTableStmt => ::core::option::Option::None,
+                SyntaxKind::ImportForeignSchemaStmt => ::core::option::Option::None,
+                SyntaxKind::CreateExtensionStmt => ::core::option::Option::None,
+                SyntaxKind::AlterExtensionStmt => ::core::option::Option::None,
+                SyntaxKind::AlterExtensionContentsStmt => ::core::option::Option::None,
+                SyntaxKind::CreateEventTrigStmt => ::core::option::Option::None,
+                SyntaxKind::AlterEventTrigStmt => ::core::option::Option::None,
+                SyntaxKind::RefreshMatViewStmt => ::core::option::Option::None,
+                SyntaxKind::ReplicaIdentityStmt => ::core::option::Option::None,
+                SyntaxKind::AlterSystemStmt => ::core::option::Option::None,
+                SyntaxKind::CreatePolicyStmt => ::core::option::Option::None,
+                SyntaxKind::AlterPolicyStmt => ::core::option::Option::None,
+                SyntaxKind::CreateTransformStmt => ::core::option::Option::None,
+                SyntaxKind::CreateAmStmt => ::core::option::Option::None,
+                SyntaxKind::CreatePublicationStmt => ::core::option::Option::None,
+                SyntaxKind::AlterPublicationStmt => ::core::option::Option::None,
+                SyntaxKind::CreateSubscriptionStmt => ::core::option::Option::None,
+                SyntaxKind::AlterSubscriptionStmt => ::core::option::Option::None,
+                SyntaxKind::DropSubscriptionStmt => ::core::option::Option::None,
+                SyntaxKind::CreateStatsStmt => ::core::option::Option::None,
+                SyntaxKind::AlterCollationStmt => ::core::option::Option::None,
+                SyntaxKind::CallStmt => ::core::option::Option::None,
+                SyntaxKind::AlterStatsStmt => ::core::option::Option::None,
+                SyntaxKind::AExpr => ::core::option::Option::None,
+                SyntaxKind::ColumnRef => ::core::option::Option::None,
+                SyntaxKind::ParamRef => ::core::option::Option::None,
+                SyntaxKind::FuncCall => ::core::option::Option::None,
+                SyntaxKind::AStar => ::core::option::Option::None,
+                SyntaxKind::AIndices => ::core::option::Option::None,
+                SyntaxKind::AIndirection => ::core::option::Option::None,
+                SyntaxKind::AArrayExpr => ::core::option::Option::None,
+                SyntaxKind::ResTarget => ::core::option::Option::None,
+                SyntaxKind::MultiAssignRef => ::core::option::Option::None,
+                SyntaxKind::TypeCast => ::core::option::Option::None,
+                SyntaxKind::CollateClause => ::core::option::Option::None,
+                SyntaxKind::SortBy => ::core::option::Option::None,
+                SyntaxKind::WindowDef => ::core::option::Option::None,
+                SyntaxKind::RangeSubselect => ::core::option::Option::None,
+                SyntaxKind::RangeFunction => ::core::option::Option::None,
+                SyntaxKind::RangeTableSample => ::core::option::Option::None,
+                SyntaxKind::RangeTableFunc => ::core::option::Option::None,
+                SyntaxKind::RangeTableFuncCol => ::core::option::Option::None,
+                SyntaxKind::TypeName => ::core::option::Option::None,
+                SyntaxKind::ColumnDef => ::core::option::Option::None,
+                SyntaxKind::IndexElem => ::core::option::Option::None,
+                SyntaxKind::StatsElem => ::core::option::Option::None,
+                SyntaxKind::Constraint => ::core::option::Option::None,
+                SyntaxKind::DefElem => ::core::option::Option::None,
+                SyntaxKind::RangeTblEntry => ::core::option::Option::None,
+                SyntaxKind::RangeTblFunction => ::core::option::Option::None,
+                SyntaxKind::TableSampleClause => ::core::option::Option::None,
+                SyntaxKind::WithCheckOption => ::core::option::Option::None,
+                SyntaxKind::SortGroupClause => ::core::option::Option::None,
+                SyntaxKind::GroupingSet => ::core::option::Option::None,
+                SyntaxKind::WindowClause => ::core::option::Option::None,
+                SyntaxKind::ObjectWithArgs => ::core::option::Option::None,
+                SyntaxKind::AccessPriv => ::core::option::Option::None,
+                SyntaxKind::CreateOpClassItem => ::core::option::Option::None,
+                SyntaxKind::TableLikeClause => ::core::option::Option::None,
+                SyntaxKind::FunctionParameter => ::core::option::Option::None,
+                SyntaxKind::LockingClause => ::core::option::Option::None,
+                SyntaxKind::RowMarkClause => ::core::option::Option::None,
+                SyntaxKind::XmlSerialize => ::core::option::Option::None,
+                SyntaxKind::WithClause => ::core::option::Option::None,
+                SyntaxKind::InferClause => ::core::option::Option::None,
+                SyntaxKind::OnConflictClause => ::core::option::Option::None,
+                SyntaxKind::CtesearchClause => ::core::option::Option::None,
+                SyntaxKind::CtecycleClause => ::core::option::Option::None,
+                SyntaxKind::CommonTableExpr => ::core::option::Option::None,
+                SyntaxKind::MergeWhenClause => ::core::option::Option::None,
+                SyntaxKind::RoleSpec => ::core::option::Option::None,
+                SyntaxKind::TriggerTransition => ::core::option::Option::None,
+                SyntaxKind::PartitionElem => ::core::option::Option::None,
+                SyntaxKind::PartitionSpec => ::core::option::Option::None,
+                SyntaxKind::PartitionBoundSpec => ::core::option::Option::None,
+                SyntaxKind::PartitionRangeDatum => ::core::option::Option::None,
+                SyntaxKind::PartitionCmd => ::core::option::Option::None,
+                SyntaxKind::VacuumRelation => ::core::option::Option::None,
+                SyntaxKind::PublicationObjSpec => ::core::option::Option::None,
+                SyntaxKind::PublicationTable => ::core::option::Option::None,
+                SyntaxKind::InlineCodeBlock => ::core::option::Option::None,
+                SyntaxKind::CallContext => ::core::option::Option::None,
+                SyntaxKind::Integer => ::core::option::Option::None,
+                SyntaxKind::Float => ::core::option::Option::None,
+                SyntaxKind::Boolean => ::core::option::Option::None,
+                SyntaxKind::String => ::core::option::Option::None,
+                SyntaxKind::BitString => ::core::option::Option::None,
+                SyntaxKind::List => ::core::option::Option::None,
+                SyntaxKind::IntList => ::core::option::Option::None,
+                SyntaxKind::OidList => ::core::option::Option::None,
+                SyntaxKind::AConst => ::core::option::Option::None,
+                SyntaxKind::Nul => ::core::option::Option::None,
+                SyntaxKind::Ascii37 => ::core::option::Option::None,
+                SyntaxKind::Ascii40 => ::core::option::Option::None,
+                SyntaxKind::Ascii41 => ::core::option::Option::None,
+                SyntaxKind::Ascii42 => ::core::option::Option::None,
+                SyntaxKind::Ascii43 => ::core::option::Option::None,
+                SyntaxKind::Ascii44 => ::core::option::Option::None,
+                SyntaxKind::Ascii45 => ::core::option::Option::None,
+                SyntaxKind::Ascii46 => ::core::option::Option::None,
+                SyntaxKind::Ascii47 => ::core::option::Option::None,
+                SyntaxKind::Ascii58 => ::core::option::Option::None,
+                SyntaxKind::Ascii59 => ::core::option::Option::None,
+                SyntaxKind::Ascii60 => ::core::option::Option::None,
+                SyntaxKind::Ascii61 => ::core::option::Option::None,
+                SyntaxKind::Ascii62 => ::core::option::Option::None,
+                SyntaxKind::Ascii63 => ::core::option::Option::None,
+                SyntaxKind::Ascii91 => ::core::option::Option::None,
+                SyntaxKind::Ascii92 => ::core::option::Option::None,
+                SyntaxKind::Ascii93 => ::core::option::Option::None,
+                SyntaxKind::Ascii94 => ::core::option::Option::None,
+                SyntaxKind::Ident => ::core::option::Option::None,
+                SyntaxKind::Uident => ::core::option::Option::None,
+                SyntaxKind::Fconst => ::core::option::Option::None,
+                SyntaxKind::Sconst => ::core::option::Option::None,
+                SyntaxKind::Usconst => ::core::option::Option::None,
+                SyntaxKind::Bconst => ::core::option::Option::None,
+                SyntaxKind::Xconst => ::core::option::Option::None,
+                SyntaxKind::Op => ::core::option::Option::None,
+                SyntaxKind::Iconst => ::core::option::Option::None,
+                SyntaxKind::Typecast => ::core::option::Option::None,
+                SyntaxKind::DotDot => ::core::option::Option::None,
+                SyntaxKind::ColonEquals => ::core::option::Option::None,
+                SyntaxKind::EqualsGreater => ::core::option::Option::None,
+                SyntaxKind::LessEquals => ::core::option::Option::None,
+                SyntaxKind::GreaterEquals => ::core::option::Option::None,
+                SyntaxKind::NotEquals => ::core::option::Option::None,
+                SyntaxKind::SqlComment => ::core::option::Option::None,
+                SyntaxKind::CComment => ::core::option::Option::None,
+                SyntaxKind::AbortP => ::core::option::Option::None,
+                SyntaxKind::AbsoluteP => ::core::option::Option::None,
+                SyntaxKind::Access => ::core::option::Option::None,
+                SyntaxKind::Action => ::core::option::Option::None,
+                SyntaxKind::AddP => ::core::option::Option::None,
+                SyntaxKind::Admin => ::core::option::Option::None,
+                SyntaxKind::After => ::core::option::Option::None,
+                SyntaxKind::Aggregate => ::core::option::Option::None,
+                SyntaxKind::All => ::core::option::Option::None,
+                SyntaxKind::Also => ::core::option::Option::None,
+                SyntaxKind::Alter => ::core::option::Option::None,
+                SyntaxKind::Always => ::core::option::Option::None,
+                SyntaxKind::Analyse => ::core::option::Option::None,
+                SyntaxKind::Analyze => ::core::option::Option::None,
+                SyntaxKind::And => ::core::option::Option::None,
+                SyntaxKind::Any => ::core::option::Option::None,
+                SyntaxKind::Array => ::core::option::Option::None,
+                SyntaxKind::As => ::core::option::Option::None,
+                SyntaxKind::Asc => ::core::option::Option::None,
+                SyntaxKind::Asensitive => ::core::option::Option::None,
+                SyntaxKind::Assertion => ::core::option::Option::None,
+                SyntaxKind::Assignment => ::core::option::Option::None,
+                SyntaxKind::Asymmetric => ::core::option::Option::None,
+                SyntaxKind::Atomic => ::core::option::Option::None,
+                SyntaxKind::At => ::core::option::Option::None,
+                SyntaxKind::Attach => ::core::option::Option::None,
+                SyntaxKind::Attribute => ::core::option::Option::None,
+                SyntaxKind::Authorization => ::core::option::Option::None,
+                SyntaxKind::Backward => ::core::option::Option::None,
+                SyntaxKind::Before => ::core::option::Option::None,
+                SyntaxKind::BeginP => ::core::option::Option::None,
+                SyntaxKind::Between => ::core::option::Option::None,
+                SyntaxKind::Bigint => ::core::option::Option::None,
+                SyntaxKind::Binary => ::core::option::Option::None,
+                SyntaxKind::Bit => ::core::option::Option::None,
+                SyntaxKind::BooleanP => ::core::option::Option::None,
+                SyntaxKind::Both => ::core::option::Option::None,
+                SyntaxKind::Breadth => ::core::option::Option::None,
+                SyntaxKind::By => ::core::option::Option::None,
+                SyntaxKind::Cache => ::core::option::Option::None,
+                SyntaxKind::Call => ::core::option::Option::None,
+                SyntaxKind::Called => ::core::option::Option::None,
+                SyntaxKind::Cascade => ::core::option::Option::None,
+                SyntaxKind::Cascaded => ::core::option::Option::None,
+                SyntaxKind::Case => ::core::option::Option::None,
+                SyntaxKind::Cast => ::core::option::Option::None,
+                SyntaxKind::CatalogP => ::core::option::Option::None,
+                SyntaxKind::Chain => ::core::option::Option::None,
+                SyntaxKind::CharP => ::core::option::Option::None,
+                SyntaxKind::Character => ::core::option::Option::None,
+                SyntaxKind::Characteristics => ::core::option::Option::None,
+                SyntaxKind::Check => ::core::option::Option::None,
+                SyntaxKind::Checkpoint => ::core::option::Option::None,
+                SyntaxKind::Class => ::core::option::Option::None,
+                SyntaxKind::Close => ::core::option::Option::None,
+                SyntaxKind::Cluster => ::core::option::Option::None,
+                SyntaxKind::Coalesce => ::core::option::Option::None,
+                SyntaxKind::Collate => ::core::option::Option::None,
+                SyntaxKind::Collation => ::core::option::Option::None,
+                SyntaxKind::Column => ::core::option::Option::None,
+                SyntaxKind::Columns => ::core::option::Option::None,
+                SyntaxKind::Comments => ::core::option::Option::None,
+                SyntaxKind::Commit => ::core::option::Option::None,
+                SyntaxKind::Committed => ::core::option::Option::None,
+                SyntaxKind::Compression => ::core::option::Option::None,
+                SyntaxKind::Concurrently => ::core::option::Option::None,
+                SyntaxKind::Configuration => ::core::option::Option::None,
+                SyntaxKind::Conflict => ::core::option::Option::None,
+                SyntaxKind::Connection => ::core::option::Option::None,
+                SyntaxKind::Constraints => ::core::option::Option::None,
+                SyntaxKind::ContentP => ::core::option::Option::None,
+                SyntaxKind::ContinueP => ::core::option::Option::None,
+                SyntaxKind::ConversionP => ::core::option::Option::None,
+                SyntaxKind::Copy => ::core::option::Option::None,
+                SyntaxKind::Cost => ::core::option::Option::None,
+                SyntaxKind::Create => ::core::option::Option::None,
+                SyntaxKind::Cross => ::core::option::Option::None,
+                SyntaxKind::Csv => ::core::option::Option::None,
+                SyntaxKind::Cube => ::core::option::Option::None,
+                SyntaxKind::CurrentP => ::core::option::Option::None,
+                SyntaxKind::CurrentCatalog => ::core::option::Option::None,
+                SyntaxKind::CurrentDate => ::core::option::Option::None,
+                SyntaxKind::CurrentRole => ::core::option::Option::None,
+                SyntaxKind::CurrentSchema => ::core::option::Option::None,
+                SyntaxKind::CurrentTime => ::core::option::Option::None,
+                SyntaxKind::CurrentTimestamp => ::core::option::Option::None,
+                SyntaxKind::CurrentUser => ::core::option::Option::None,
+                SyntaxKind::Cursor => ::core::option::Option::None,
+                SyntaxKind::Cycle => ::core::option::Option::None,
+                SyntaxKind::DataP => ::core::option::Option::None,
+                SyntaxKind::Database => ::core::option::Option::None,
+                SyntaxKind::DayP => ::core::option::Option::None,
+                SyntaxKind::Deallocate => ::core::option::Option::None,
+                SyntaxKind::Dec => ::core::option::Option::None,
+                SyntaxKind::DecimalP => ::core::option::Option::None,
+                SyntaxKind::Declare => ::core::option::Option::None,
+                SyntaxKind::Default => ::core::option::Option::None,
+                SyntaxKind::Defaults => ::core::option::Option::None,
+                SyntaxKind::Deferrable => ::core::option::Option::None,
+                SyntaxKind::Deferred => ::core::option::Option::None,
+                SyntaxKind::Definer => ::core::option::Option::None,
+                SyntaxKind::DeleteP => ::core::option::Option::None,
+                SyntaxKind::Delimiter => ::core::option::Option::None,
+                SyntaxKind::Delimiters => ::core::option::Option::None,
+                SyntaxKind::Depends => ::core::option::Option::None,
+                SyntaxKind::Depth => ::core::option::Option::None,
+                SyntaxKind::Desc => ::core::option::Option::None,
+                SyntaxKind::Detach => ::core::option::Option::None,
+                SyntaxKind::Dictionary => ::core::option::Option::None,
+                SyntaxKind::DisableP => ::core::option::Option::None,
+                SyntaxKind::Discard => ::core::option::Option::None,
+                SyntaxKind::Distinct => ::core::option::Option::None,
+                SyntaxKind::Do => ::core::option::Option::None,
+                SyntaxKind::DocumentP => ::core::option::Option::None,
+                SyntaxKind::DomainP => ::core::option::Option::None,
+                SyntaxKind::DoubleP => ::core::option::Option::None,
+                SyntaxKind::Drop => ::core::option::Option::None,
+                SyntaxKind::Each => ::core::option::Option::None,
+                SyntaxKind::Else => ::core::option::Option::None,
+                SyntaxKind::EnableP => ::core::option::Option::None,
+                SyntaxKind::Encoding => ::core::option::Option::None,
+                SyntaxKind::Encrypted => ::core::option::Option::None,
+                SyntaxKind::EndP => ::core::option::Option::None,
+                SyntaxKind::EnumP => ::core::option::Option::None,
+                SyntaxKind::Escape => ::core::option::Option::None,
+                SyntaxKind::Event => ::core::option::Option::None,
+                SyntaxKind::Except => ::core::option::Option::None,
+                SyntaxKind::Exclude => ::core::option::Option::None,
+                SyntaxKind::Excluding => ::core::option::Option::None,
+                SyntaxKind::Exclusive => ::core::option::Option::None,
+                SyntaxKind::Execute => ::core::option::Option::None,
+                SyntaxKind::Exists => ::core::option::Option::None,
+                SyntaxKind::Explain => ::core::option::Option::None,
+                SyntaxKind::Expression => ::core::option::Option::None,
+                SyntaxKind::Extension => ::core::option::Option::None,
+                SyntaxKind::External => ::core::option::Option::None,
+                SyntaxKind::Extract => ::core::option::Option::None,
+                SyntaxKind::FalseP => ::core::option::Option::None,
+                SyntaxKind::Family => ::core::option::Option::None,
+                SyntaxKind::Fetch => ::core::option::Option::None,
+                SyntaxKind::Filter => ::core::option::Option::None,
+                SyntaxKind::Finalize => ::core::option::Option::None,
+                SyntaxKind::FirstP => ::core::option::Option::None,
+                SyntaxKind::FloatP => ::core::option::Option::None,
+                SyntaxKind::Following => ::core::option::Option::None,
+                SyntaxKind::For => ::core::option::Option::None,
+                SyntaxKind::Force => ::core::option::Option::None,
+                SyntaxKind::Foreign => ::core::option::Option::None,
+                SyntaxKind::Forward => ::core::option::Option::None,
+                SyntaxKind::Freeze => ::core::option::Option::None,
+                SyntaxKind::From => ::core::option::Option::None,
+                SyntaxKind::Full => ::core::option::Option::None,
+                SyntaxKind::Function => ::core::option::Option::None,
+                SyntaxKind::Functions => ::core::option::Option::None,
+                SyntaxKind::Generated => ::core::option::Option::None,
+                SyntaxKind::Global => ::core::option::Option::None,
+                SyntaxKind::Grant => ::core::option::Option::None,
+                SyntaxKind::Granted => ::core::option::Option::None,
+                SyntaxKind::Greatest => ::core::option::Option::None,
+                SyntaxKind::GroupP => ::core::option::Option::None,
+                SyntaxKind::Grouping => ::core::option::Option::None,
+                SyntaxKind::Groups => ::core::option::Option::None,
+                SyntaxKind::Handler => ::core::option::Option::None,
+                SyntaxKind::Having => ::core::option::Option::None,
+                SyntaxKind::HeaderP => ::core::option::Option::None,
+                SyntaxKind::Hold => ::core::option::Option::None,
+                SyntaxKind::HourP => ::core::option::Option::None,
+                SyntaxKind::IdentityP => ::core::option::Option::None,
+                SyntaxKind::IfP => ::core::option::Option::None,
+                SyntaxKind::Ilike => ::core::option::Option::None,
+                SyntaxKind::Immediate => ::core::option::Option::None,
+                SyntaxKind::Immutable => ::core::option::Option::None,
+                SyntaxKind::ImplicitP => ::core::option::Option::None,
+                SyntaxKind::ImportP => ::core::option::Option::None,
+                SyntaxKind::InP => ::core::option::Option::None,
+                SyntaxKind::Include => ::core::option::Option::None,
+                SyntaxKind::Including => ::core::option::Option::None,
+                SyntaxKind::Increment => ::core::option::Option::None,
+                SyntaxKind::Index => ::core::option::Option::None,
+                SyntaxKind::Indexes => ::core::option::Option::None,
+                SyntaxKind::Inherit => ::core::option::Option::None,
+                SyntaxKind::Inherits => ::core::option::Option::None,
+                SyntaxKind::Initially => ::core::option::Option::None,
+                SyntaxKind::InlineP => ::core::option::Option::None,
+                SyntaxKind::InnerP => ::core::option::Option::None,
+                SyntaxKind::Inout => ::core::option::Option::None,
+                SyntaxKind::InputP => ::core::option::Option::None,
+                SyntaxKind::Insensitive => ::core::option::Option::None,
+                SyntaxKind::Insert => ::core::option::Option::None,
+                SyntaxKind::Instead => ::core::option::Option::None,
+                SyntaxKind::IntP => ::core::option::Option::None,
+                SyntaxKind::Intersect => ::core::option::Option::None,
+                SyntaxKind::Interval => ::core::option::Option::None,
+                SyntaxKind::Into => ::core::option::Option::None,
+                SyntaxKind::Invoker => ::core::option::Option::None,
+                SyntaxKind::Is => ::core::option::Option::None,
+                SyntaxKind::Isnull => ::core::option::Option::None,
+                SyntaxKind::Isolation => ::core::option::Option::None,
+                SyntaxKind::Join => ::core::option::Option::None,
+                SyntaxKind::Key => ::core::option::Option::None,
+                SyntaxKind::Label => ::core::option::Option::None,
+                SyntaxKind::Language => ::core::option::Option::None,
+                SyntaxKind::LargeP => ::core::option::Option::None,
+                SyntaxKind::LastP => ::core::option::Option::None,
+                SyntaxKind::LateralP => ::core::option::Option::None,
+                SyntaxKind::Leading => ::core::option::Option::None,
+                SyntaxKind::Leakproof => ::core::option::Option::None,
+                SyntaxKind::Least => ::core::option::Option::None,
+                SyntaxKind::Left => ::core::option::Option::None,
+                SyntaxKind::Level => ::core::option::Option::None,
+                SyntaxKind::Like => ::core::option::Option::None,
+                SyntaxKind::Limit => ::core::option::Option::None,
+                SyntaxKind::Listen => ::core::option::Option::None,
+                SyntaxKind::Load => ::core::option::Option::None,
+                SyntaxKind::Local => ::core::option::Option::None,
+                SyntaxKind::Localtime => ::core::option::Option::None,
+                SyntaxKind::Localtimestamp => ::core::option::Option::None,
+                SyntaxKind::Location => ::core::option::Option::None,
+                SyntaxKind::LockP => ::core::option::Option::None,
+                SyntaxKind::Locked => ::core::option::Option::None,
+                SyntaxKind::Logged => ::core::option::Option::None,
+                SyntaxKind::Mapping => ::core::option::Option::None,
+                SyntaxKind::Match => ::core::option::Option::None,
+                SyntaxKind::Matched => ::core::option::Option::None,
+                SyntaxKind::Materialized => ::core::option::Option::None,
+                SyntaxKind::Maxvalue => ::core::option::Option::None,
+                SyntaxKind::Merge => ::core::option::Option::None,
+                SyntaxKind::Method => ::core::option::Option::None,
+                SyntaxKind::MinuteP => ::core::option::Option::None,
+                SyntaxKind::Minvalue => ::core::option::Option::None,
+                SyntaxKind::Mode => ::core::option::Option::None,
+                SyntaxKind::MonthP => ::core::option::Option::None,
+                SyntaxKind::Move => ::core::option::Option::None,
+                SyntaxKind::NameP => ::core::option::Option::None,
+                SyntaxKind::Names => ::core::option::Option::None,
+                SyntaxKind::National => ::core::option::Option::None,
+                SyntaxKind::Natural => ::core::option::Option::None,
+                SyntaxKind::Nchar => ::core::option::Option::None,
+                SyntaxKind::New => ::core::option::Option::None,
+                SyntaxKind::Next => ::core::option::Option::None,
+                SyntaxKind::Nfc => ::core::option::Option::None,
+                SyntaxKind::Nfd => ::core::option::Option::None,
+                SyntaxKind::Nfkc => ::core::option::Option::None,
+                SyntaxKind::Nfkd => ::core::option::Option::None,
+                SyntaxKind::No => ::core::option::Option::None,
+                SyntaxKind::None => ::core::option::Option::None,
+                SyntaxKind::Normalize => ::core::option::Option::None,
+                SyntaxKind::Normalized => ::core::option::Option::None,
+                SyntaxKind::Not => ::core::option::Option::None,
+                SyntaxKind::Nothing => ::core::option::Option::None,
+                SyntaxKind::Notify => ::core::option::Option::None,
+                SyntaxKind::Notnull => ::core::option::Option::None,
+                SyntaxKind::Nowait => ::core::option::Option::None,
+                SyntaxKind::NullP => ::core::option::Option::None,
+                SyntaxKind::Nullif => ::core::option::Option::None,
+                SyntaxKind::NullsP => ::core::option::Option::None,
+                SyntaxKind::Numeric => ::core::option::Option::None,
+                SyntaxKind::ObjectP => ::core::option::Option::None,
+                SyntaxKind::Of => ::core::option::Option::None,
+                SyntaxKind::Off => ::core::option::Option::None,
+                SyntaxKind::Offset => ::core::option::Option::None,
+                SyntaxKind::Oids => ::core::option::Option::None,
+                SyntaxKind::Old => ::core::option::Option::None,
+                SyntaxKind::On => ::core::option::Option::None,
+                SyntaxKind::Only => ::core::option::Option::None,
+                SyntaxKind::Operator => ::core::option::Option::None,
+                SyntaxKind::Option => ::core::option::Option::None,
+                SyntaxKind::Options => ::core::option::Option::None,
+                SyntaxKind::Or => ::core::option::Option::None,
+                SyntaxKind::Order => ::core::option::Option::None,
+                SyntaxKind::Ordinality => ::core::option::Option::None,
+                SyntaxKind::Others => ::core::option::Option::None,
+                SyntaxKind::OutP => ::core::option::Option::None,
+                SyntaxKind::OuterP => ::core::option::Option::None,
+                SyntaxKind::Over => ::core::option::Option::None,
+                SyntaxKind::Overlaps => ::core::option::Option::None,
+                SyntaxKind::Overlay => ::core::option::Option::None,
+                SyntaxKind::Overriding => ::core::option::Option::None,
+                SyntaxKind::Owned => ::core::option::Option::None,
+                SyntaxKind::Owner => ::core::option::Option::None,
+                SyntaxKind::Parallel => ::core::option::Option::None,
+                SyntaxKind::Parameter => ::core::option::Option::None,
+                SyntaxKind::Parser => ::core::option::Option::None,
+                SyntaxKind::Partial => ::core::option::Option::None,
+                SyntaxKind::Partition => ::core::option::Option::None,
+                SyntaxKind::Passing => ::core::option::Option::None,
+                SyntaxKind::Password => ::core::option::Option::None,
+                SyntaxKind::Placing => ::core::option::Option::None,
+                SyntaxKind::Plans => ::core::option::Option::None,
+                SyntaxKind::Policy => ::core::option::Option::None,
+                SyntaxKind::Position => ::core::option::Option::None,
+                SyntaxKind::Preceding => ::core::option::Option::None,
+                SyntaxKind::Precision => ::core::option::Option::None,
+                SyntaxKind::Preserve => ::core::option::Option::None,
+                SyntaxKind::Prepare => ::core::option::Option::None,
+                SyntaxKind::Prepared => ::core::option::Option::None,
+                SyntaxKind::Primary => ::core::option::Option::None,
+                SyntaxKind::Prior => ::core::option::Option::None,
+                SyntaxKind::Privileges => ::core::option::Option::None,
+                SyntaxKind::Procedural => ::core::option::Option::None,
+                SyntaxKind::Procedure => ::core::option::Option::None,
+                SyntaxKind::Procedures => ::core::option::Option::None,
+                SyntaxKind::Program => ::core::option::Option::None,
+                SyntaxKind::Publication => ::core::option::Option::None,
+                SyntaxKind::Quote => ::core::option::Option::None,
+                SyntaxKind::Range => ::core::option::Option::None,
+                SyntaxKind::Read => ::core::option::Option::None,
+                SyntaxKind::Real => ::core::option::Option::None,
+                SyntaxKind::Reassign => ::core::option::Option::None,
+                SyntaxKind::Recheck => ::core::option::Option::None,
+                SyntaxKind::Recursive => ::core::option::Option::None,
+                SyntaxKind::RefP => ::core::option::Option::None,
+                SyntaxKind::References => ::core::option::Option::None,
+                SyntaxKind::Referencing => ::core::option::Option::None,
+                SyntaxKind::Refresh => ::core::option::Option::None,
+                SyntaxKind::Reindex => ::core::option::Option::None,
+                SyntaxKind::RelativeP => ::core::option::Option::None,
+                SyntaxKind::Release => ::core::option::Option::None,
+                SyntaxKind::Rename => ::core::option::Option::None,
+                SyntaxKind::Repeatable => ::core::option::Option::None,
+                SyntaxKind::Replace => ::core::option::Option::None,
+                SyntaxKind::Replica => ::core::option::Option::None,
+                SyntaxKind::Reset => ::core::option::Option::None,
+                SyntaxKind::Restart => ::core::option::Option::None,
+                SyntaxKind::Restrict => ::core::option::Option::None,
+                SyntaxKind::Return => ::core::option::Option::None,
+                SyntaxKind::Returning => ::core::option::Option::None,
+                SyntaxKind::Returns => ::core::option::Option::None,
+                SyntaxKind::Revoke => ::core::option::Option::None,
+                SyntaxKind::Right => ::core::option::Option::None,
+                SyntaxKind::Role => ::core::option::Option::None,
+                SyntaxKind::Rollback => ::core::option::Option::None,
+                SyntaxKind::Rollup => ::core::option::Option::None,
+                SyntaxKind::Routine => ::core::option::Option::None,
+                SyntaxKind::Routines => ::core::option::Option::None,
+                SyntaxKind::Row => ::core::option::Option::None,
+                SyntaxKind::Rows => ::core::option::Option::None,
+                SyntaxKind::Rule => ::core::option::Option::None,
+                SyntaxKind::Savepoint => ::core::option::Option::None,
+                SyntaxKind::Schema => ::core::option::Option::None,
+                SyntaxKind::Schemas => ::core::option::Option::None,
+                SyntaxKind::Scroll => ::core::option::Option::None,
+                SyntaxKind::Search => ::core::option::Option::None,
+                SyntaxKind::SecondP => ::core::option::Option::None,
+                SyntaxKind::Security => ::core::option::Option::None,
+                SyntaxKind::Select => ::core::option::Option::None,
+                SyntaxKind::Sequence => ::core::option::Option::None,
+                SyntaxKind::Sequences => ::core::option::Option::None,
+                SyntaxKind::Serializable => ::core::option::Option::None,
+                SyntaxKind::Server => ::core::option::Option::None,
+                SyntaxKind::Session => ::core::option::Option::None,
+                SyntaxKind::SessionUser => ::core::option::Option::None,
+                SyntaxKind::Set => ::core::option::Option::None,
+                SyntaxKind::Sets => ::core::option::Option::None,
+                SyntaxKind::Setof => ::core::option::Option::None,
+                SyntaxKind::Share => ::core::option::Option::None,
+                SyntaxKind::Show => ::core::option::Option::None,
+                SyntaxKind::Similar => ::core::option::Option::None,
+                SyntaxKind::Simple => ::core::option::Option::None,
+                SyntaxKind::Skip => ::core::option::Option::None,
+                SyntaxKind::Smallint => ::core::option::Option::None,
+                SyntaxKind::Snapshot => ::core::option::Option::None,
+                SyntaxKind::Some => ::core::option::Option::None,
+                SyntaxKind::SqlP => ::core::option::Option::None,
+                SyntaxKind::Stable => ::core::option::Option::None,
+                SyntaxKind::StandaloneP => ::core::option::Option::None,
+                SyntaxKind::Start => ::core::option::Option::None,
+                SyntaxKind::Statement => ::core::option::Option::None,
+                SyntaxKind::Statistics => ::core::option::Option::None,
+                SyntaxKind::Stdin => ::core::option::Option::None,
+                SyntaxKind::Stdout => ::core::option::Option::None,
+                SyntaxKind::Storage => ::core::option::Option::None,
+                SyntaxKind::Stored => ::core::option::Option::None,
+                SyntaxKind::StrictP => ::core::option::Option::None,
+                SyntaxKind::StripP => ::core::option::Option::None,
+                SyntaxKind::Subscription => ::core::option::Option::None,
+                SyntaxKind::Substring => ::core::option::Option::None,
+                SyntaxKind::Support => ::core::option::Option::None,
+                SyntaxKind::Symmetric => ::core::option::Option::None,
+                SyntaxKind::Sysid => ::core::option::Option::None,
+                SyntaxKind::SystemP => ::core::option::Option::None,
+                SyntaxKind::Table => ::core::option::Option::None,
+                SyntaxKind::Tables => ::core::option::Option::None,
+                SyntaxKind::Tablesample => ::core::option::Option::None,
+                SyntaxKind::Tablespace => ::core::option::Option::None,
+                SyntaxKind::Temp => ::core::option::Option::None,
+                SyntaxKind::Template => ::core::option::Option::None,
+                SyntaxKind::Temporary => ::core::option::Option::None,
+                SyntaxKind::TextP => ::core::option::Option::None,
+                SyntaxKind::Then => ::core::option::Option::None,
+                SyntaxKind::Ties => ::core::option::Option::None,
+                SyntaxKind::Time => ::core::option::Option::None,
+                SyntaxKind::Timestamp => ::core::option::Option::None,
+                SyntaxKind::To => ::core::option::Option::None,
+                SyntaxKind::Trailing => ::core::option::Option::None,
+                SyntaxKind::Transaction => ::core::option::Option::None,
+                SyntaxKind::Transform => ::core::option::Option::None,
+                SyntaxKind::Treat => ::core::option::Option::None,
+                SyntaxKind::Trigger => ::core::option::Option::None,
+                SyntaxKind::Trim => ::core::option::Option::None,
+                SyntaxKind::TrueP => ::core::option::Option::None,
+                SyntaxKind::Truncate => ::core::option::Option::None,
+                SyntaxKind::Trusted => ::core::option::Option::None,
+                SyntaxKind::TypeP => ::core::option::Option::None,
+                SyntaxKind::TypesP => ::core::option::Option::None,
+                SyntaxKind::Uescape => ::core::option::Option::None,
+                SyntaxKind::Unbounded => ::core::option::Option::None,
+                SyntaxKind::Uncommitted => ::core::option::Option::None,
+                SyntaxKind::Unencrypted => ::core::option::Option::None,
+                SyntaxKind::Union => ::core::option::Option::None,
+                SyntaxKind::Unique => ::core::option::Option::None,
+                SyntaxKind::Unknown => ::core::option::Option::None,
+                SyntaxKind::Unlisten => ::core::option::Option::None,
+                SyntaxKind::Unlogged => ::core::option::Option::None,
+                SyntaxKind::Until => ::core::option::Option::None,
+                SyntaxKind::Update => ::core::option::Option::None,
+                SyntaxKind::User => ::core::option::Option::None,
+                SyntaxKind::Using => ::core::option::Option::None,
+                SyntaxKind::Vacuum => ::core::option::Option::None,
+                SyntaxKind::Valid => ::core::option::Option::None,
+                SyntaxKind::Validate => ::core::option::Option::None,
+                SyntaxKind::Validator => ::core::option::Option::None,
+                SyntaxKind::ValueP => ::core::option::Option::None,
+                SyntaxKind::Values => ::core::option::Option::None,
+                SyntaxKind::Varchar => ::core::option::Option::None,
+                SyntaxKind::Variadic => ::core::option::Option::None,
+                SyntaxKind::Varying => ::core::option::Option::None,
+                SyntaxKind::Verbose => ::core::option::Option::None,
+                SyntaxKind::VersionP => ::core::option::Option::None,
+                SyntaxKind::View => ::core::option::Option::None,
+                SyntaxKind::Views => ::core::option::Option::None,
+                SyntaxKind::Volatile => ::core::option::Option::None,
+                SyntaxKind::When => ::core::option::Option::None,
+                SyntaxKind::Where => ::core::option::Option::None,
+                SyntaxKind::WhitespaceP => ::core::option::Option::None,
+                SyntaxKind::Window => ::core::option::Option::None,
+                SyntaxKind::With => ::core::option::Option::None,
+                SyntaxKind::Within => ::core::option::Option::None,
+                SyntaxKind::Without => ::core::option::Option::None,
+                SyntaxKind::Work => ::core::option::Option::None,
+                SyntaxKind::Wrapper => ::core::option::Option::None,
+                SyntaxKind::Write => ::core::option::Option::None,
+                SyntaxKind::XmlP => ::core::option::Option::None,
+                SyntaxKind::Xmlattributes => ::core::option::Option::None,
+                SyntaxKind::Xmlconcat => ::core::option::Option::None,
+                SyntaxKind::Xmlelement => ::core::option::Option::None,
+                SyntaxKind::Xmlexists => ::core::option::Option::None,
+                SyntaxKind::Xmlforest => ::core::option::Option::None,
+                SyntaxKind::Xmlnamespaces => ::core::option::Option::None,
+                SyntaxKind::Xmlparse => ::core::option::Option::None,
+                SyntaxKind::Xmlpi => ::core::option::Option::None,
+                SyntaxKind::Xmlroot => ::core::option::Option::None,
+                SyntaxKind::Xmlserialize => ::core::option::Option::None,
+                SyntaxKind::Xmltable => ::core::option::Option::None,
+                SyntaxKind::YearP => ::core::option::Option::None,
+                SyntaxKind::YesP => ::core::option::Option::None,
+                SyntaxKind::Zone => ::core::option::Option::None,
+                SyntaxKind::NotLa => ::core::option::Option::None,
+                SyntaxKind::NullsLa => ::core::option::Option::None,
+                SyntaxKind::WithLa => ::core::option::Option::None,
+                SyntaxKind::ModeTypeName => ::core::option::Option::None,
+                SyntaxKind::ModePlpgsqlExpr => ::core::option::Option::None,
+                SyntaxKind::ModePlpgsqlAssign1 => ::core::option::Option::None,
+                SyntaxKind::ModePlpgsqlAssign2 => ::core::option::Option::None,
+                SyntaxKind::ModePlpgsqlAssign3 => ::core::option::Option::None,
+                SyntaxKind::Uminus => ::core::option::Option::None,
+            }
+        }
+    }
+    impl SyntaxKind {
+        /// Converts a `pg_query` node to a `SyntaxKind`
+        pub fn new_from_pg_query_node(node: &NodeEnum) -> Self {
+            match node {
+                NodeEnum::Alias(_) => SyntaxKind::Alias,
+                NodeEnum::RangeVar(_) => SyntaxKind::RangeVar,
+                NodeEnum::TableFunc(_) => SyntaxKind::TableFunc,
+                NodeEnum::Var(_) => SyntaxKind::Var,
+                NodeEnum::Param(_) => SyntaxKind::Param,
+                NodeEnum::Aggref(_) => SyntaxKind::Aggref,
+                NodeEnum::GroupingFunc(_) => SyntaxKind::GroupingFunc,
+                NodeEnum::WindowFunc(_) => SyntaxKind::WindowFunc,
+                NodeEnum::SubscriptingRef(_) => SyntaxKind::SubscriptingRef,
+                NodeEnum::FuncExpr(_) => SyntaxKind::FuncExpr,
+                NodeEnum::NamedArgExpr(_) => SyntaxKind::NamedArgExpr,
+                NodeEnum::OpExpr(_) => SyntaxKind::OpExpr,
+                NodeEnum::DistinctExpr(_) => SyntaxKind::DistinctExpr,
+                NodeEnum::NullIfExpr(_) => SyntaxKind::NullIfExpr,
+                NodeEnum::ScalarArrayOpExpr(_) => SyntaxKind::ScalarArrayOpExpr,
+                NodeEnum::BoolExpr(_) => SyntaxKind::BoolExpr,
+                NodeEnum::SubLink(_) => SyntaxKind::SubLink,
+                NodeEnum::SubPlan(_) => SyntaxKind::SubPlan,
+                NodeEnum::AlternativeSubPlan(_) => SyntaxKind::AlternativeSubPlan,
+                NodeEnum::FieldSelect(_) => SyntaxKind::FieldSelect,
+                NodeEnum::FieldStore(_) => SyntaxKind::FieldStore,
+                NodeEnum::RelabelType(_) => SyntaxKind::RelabelType,
+                NodeEnum::CoerceViaIo(_) => SyntaxKind::CoerceViaIo,
+                NodeEnum::ArrayCoerceExpr(_) => SyntaxKind::ArrayCoerceExpr,
+                NodeEnum::ConvertRowtypeExpr(_) => SyntaxKind::ConvertRowtypeExpr,
+                NodeEnum::CollateExpr(_) => SyntaxKind::CollateExpr,
+                NodeEnum::CaseExpr(_) => SyntaxKind::CaseExpr,
+                NodeEnum::CaseWhen(_) => SyntaxKind::CaseWhen,
+                NodeEnum::CaseTestExpr(_) => SyntaxKind::CaseTestExpr,
+                NodeEnum::ArrayExpr(_) => SyntaxKind::ArrayExpr,
+                NodeEnum::RowExpr(_) => SyntaxKind::RowExpr,
+                NodeEnum::RowCompareExpr(_) => SyntaxKind::RowCompareExpr,
+                NodeEnum::CoalesceExpr(_) => SyntaxKind::CoalesceExpr,
+                NodeEnum::MinMaxExpr(_) => SyntaxKind::MinMaxExpr,
+                NodeEnum::SqlvalueFunction(_) => SyntaxKind::SqlvalueFunction,
+                NodeEnum::XmlExpr(_) => SyntaxKind::XmlExpr,
+                NodeEnum::NullTest(_) => SyntaxKind::NullTest,
+                NodeEnum::BooleanTest(_) => SyntaxKind::BooleanTest,
+                NodeEnum::CoerceToDomain(_) => SyntaxKind::CoerceToDomain,
+                NodeEnum::CoerceToDomainValue(_) => SyntaxKind::CoerceToDomainValue,
+                NodeEnum::SetToDefault(_) => SyntaxKind::SetToDefault,
+                NodeEnum::CurrentOfExpr(_) => SyntaxKind::CurrentOfExpr,
+                NodeEnum::NextValueExpr(_) => SyntaxKind::NextValueExpr,
+                NodeEnum::InferenceElem(_) => SyntaxKind::InferenceElem,
+                NodeEnum::TargetEntry(_) => SyntaxKind::TargetEntry,
+                NodeEnum::RangeTblRef(_) => SyntaxKind::RangeTblRef,
+                NodeEnum::JoinExpr(_) => SyntaxKind::JoinExpr,
+                NodeEnum::FromExpr(_) => SyntaxKind::FromExpr,
+                NodeEnum::OnConflictExpr(_) => SyntaxKind::OnConflictExpr,
+                NodeEnum::IntoClause(_) => SyntaxKind::IntoClause,
+                NodeEnum::MergeAction(_) => SyntaxKind::MergeAction,
+                NodeEnum::RawStmt(_) => SyntaxKind::RawStmt,
+                NodeEnum::Query(_) => SyntaxKind::Query,
+                NodeEnum::InsertStmt(_) => SyntaxKind::InsertStmt,
+                NodeEnum::DeleteStmt(_) => SyntaxKind::DeleteStmt,
+                NodeEnum::UpdateStmt(_) => SyntaxKind::UpdateStmt,
+                NodeEnum::MergeStmt(_) => SyntaxKind::MergeStmt,
+                NodeEnum::SelectStmt(_) => SyntaxKind::SelectStmt,
+                NodeEnum::ReturnStmt(_) => SyntaxKind::ReturnStmt,
+                NodeEnum::PlassignStmt(_) => SyntaxKind::PlassignStmt,
+                NodeEnum::AlterTableStmt(_) => SyntaxKind::AlterTableStmt,
+                NodeEnum::AlterTableCmd(_) => SyntaxKind::AlterTableCmd,
+                NodeEnum::AlterDomainStmt(_) => SyntaxKind::AlterDomainStmt,
+                NodeEnum::SetOperationStmt(_) => SyntaxKind::SetOperationStmt,
+                NodeEnum::GrantStmt(_) => SyntaxKind::GrantStmt,
+                NodeEnum::GrantRoleStmt(_) => SyntaxKind::GrantRoleStmt,
+                NodeEnum::AlterDefaultPrivilegesStmt(_) => {
+                    SyntaxKind::AlterDefaultPrivilegesStmt
+                }
+                NodeEnum::ClosePortalStmt(_) => SyntaxKind::ClosePortalStmt,
+                NodeEnum::ClusterStmt(_) => SyntaxKind::ClusterStmt,
+                NodeEnum::CopyStmt(_) => SyntaxKind::CopyStmt,
+                NodeEnum::CreateStmt(_) => SyntaxKind::CreateStmt,
+                NodeEnum::DefineStmt(_) => SyntaxKind::DefineStmt,
+                NodeEnum::DropStmt(_) => SyntaxKind::DropStmt,
+                NodeEnum::TruncateStmt(_) => SyntaxKind::TruncateStmt,
+                NodeEnum::CommentStmt(_) => SyntaxKind::CommentStmt,
+                NodeEnum::FetchStmt(_) => SyntaxKind::FetchStmt,
+                NodeEnum::IndexStmt(_) => SyntaxKind::IndexStmt,
+                NodeEnum::CreateFunctionStmt(_) => SyntaxKind::CreateFunctionStmt,
+                NodeEnum::AlterFunctionStmt(_) => SyntaxKind::AlterFunctionStmt,
+                NodeEnum::DoStmt(_) => SyntaxKind::DoStmt,
+                NodeEnum::RenameStmt(_) => SyntaxKind::RenameStmt,
+                NodeEnum::RuleStmt(_) => SyntaxKind::RuleStmt,
+                NodeEnum::NotifyStmt(_) => SyntaxKind::NotifyStmt,
+                NodeEnum::ListenStmt(_) => SyntaxKind::ListenStmt,
+                NodeEnum::UnlistenStmt(_) => SyntaxKind::UnlistenStmt,
+                NodeEnum::TransactionStmt(_) => SyntaxKind::TransactionStmt,
+                NodeEnum::ViewStmt(_) => SyntaxKind::ViewStmt,
+                NodeEnum::LoadStmt(_) => SyntaxKind::LoadStmt,
+                NodeEnum::CreateDomainStmt(_) => SyntaxKind::CreateDomainStmt,
+                NodeEnum::CreatedbStmt(_) => SyntaxKind::CreatedbStmt,
+                NodeEnum::DropdbStmt(_) => SyntaxKind::DropdbStmt,
+                NodeEnum::VacuumStmt(_) => SyntaxKind::VacuumStmt,
+                NodeEnum::ExplainStmt(_) => SyntaxKind::ExplainStmt,
+                NodeEnum::CreateTableAsStmt(_) => SyntaxKind::CreateTableAsStmt,
+                NodeEnum::CreateSeqStmt(_) => SyntaxKind::CreateSeqStmt,
+                NodeEnum::AlterSeqStmt(_) => SyntaxKind::AlterSeqStmt,
+                NodeEnum::VariableSetStmt(_) => SyntaxKind::VariableSetStmt,
+                NodeEnum::VariableShowStmt(_) => SyntaxKind::VariableShowStmt,
+                NodeEnum::DiscardStmt(_) => SyntaxKind::DiscardStmt,
+                NodeEnum::CreateTrigStmt(_) => SyntaxKind::CreateTrigStmt,
+                NodeEnum::CreatePlangStmt(_) => SyntaxKind::CreatePlangStmt,
+                NodeEnum::CreateRoleStmt(_) => SyntaxKind::CreateRoleStmt,
+                NodeEnum::AlterRoleStmt(_) => SyntaxKind::AlterRoleStmt,
+                NodeEnum::DropRoleStmt(_) => SyntaxKind::DropRoleStmt,
+                NodeEnum::LockStmt(_) => SyntaxKind::LockStmt,
+                NodeEnum::ConstraintsSetStmt(_) => SyntaxKind::ConstraintsSetStmt,
+                NodeEnum::ReindexStmt(_) => SyntaxKind::ReindexStmt,
+                NodeEnum::CheckPointStmt(_) => SyntaxKind::CheckPointStmt,
+                NodeEnum::CreateSchemaStmt(_) => SyntaxKind::CreateSchemaStmt,
+                NodeEnum::AlterDatabaseStmt(_) => SyntaxKind::AlterDatabaseStmt,
+                NodeEnum::AlterDatabaseRefreshCollStmt(_) => {
+                    SyntaxKind::AlterDatabaseRefreshCollStmt
+                }
+                NodeEnum::AlterDatabaseSetStmt(_) => SyntaxKind::AlterDatabaseSetStmt,
+                NodeEnum::AlterRoleSetStmt(_) => SyntaxKind::AlterRoleSetStmt,
+                NodeEnum::CreateConversionStmt(_) => SyntaxKind::CreateConversionStmt,
+                NodeEnum::CreateCastStmt(_) => SyntaxKind::CreateCastStmt,
+                NodeEnum::CreateOpClassStmt(_) => SyntaxKind::CreateOpClassStmt,
+                NodeEnum::CreateOpFamilyStmt(_) => SyntaxKind::CreateOpFamilyStmt,
+                NodeEnum::AlterOpFamilyStmt(_) => SyntaxKind::AlterOpFamilyStmt,
+                NodeEnum::PrepareStmt(_) => SyntaxKind::PrepareStmt,
+                NodeEnum::ExecuteStmt(_) => SyntaxKind::ExecuteStmt,
+                NodeEnum::DeallocateStmt(_) => SyntaxKind::DeallocateStmt,
+                NodeEnum::DeclareCursorStmt(_) => SyntaxKind::DeclareCursorStmt,
+                NodeEnum::CreateTableSpaceStmt(_) => SyntaxKind::CreateTableSpaceStmt,
+                NodeEnum::DropTableSpaceStmt(_) => SyntaxKind::DropTableSpaceStmt,
+                NodeEnum::AlterObjectDependsStmt(_) => SyntaxKind::AlterObjectDependsStmt,
+                NodeEnum::AlterObjectSchemaStmt(_) => SyntaxKind::AlterObjectSchemaStmt,
+                NodeEnum::AlterOwnerStmt(_) => SyntaxKind::AlterOwnerStmt,
+                NodeEnum::AlterOperatorStmt(_) => SyntaxKind::AlterOperatorStmt,
+                NodeEnum::AlterTypeStmt(_) => SyntaxKind::AlterTypeStmt,
+                NodeEnum::DropOwnedStmt(_) => SyntaxKind::DropOwnedStmt,
+                NodeEnum::ReassignOwnedStmt(_) => SyntaxKind::ReassignOwnedStmt,
+                NodeEnum::CompositeTypeStmt(_) => SyntaxKind::CompositeTypeStmt,
+                NodeEnum::CreateEnumStmt(_) => SyntaxKind::CreateEnumStmt,
+                NodeEnum::CreateRangeStmt(_) => SyntaxKind::CreateRangeStmt,
+                NodeEnum::AlterEnumStmt(_) => SyntaxKind::AlterEnumStmt,
+                NodeEnum::AlterTsdictionaryStmt(_) => SyntaxKind::AlterTsdictionaryStmt,
+                NodeEnum::AlterTsconfigurationStmt(_) => {
+                    SyntaxKind::AlterTsconfigurationStmt
+                }
+                NodeEnum::CreateFdwStmt(_) => SyntaxKind::CreateFdwStmt,
+                NodeEnum::AlterFdwStmt(_) => SyntaxKind::AlterFdwStmt,
+                NodeEnum::CreateForeignServerStmt(_) => {
+                    SyntaxKind::CreateForeignServerStmt
+                }
+                NodeEnum::AlterForeignServerStmt(_) => SyntaxKind::AlterForeignServerStmt,
+                NodeEnum::CreateUserMappingStmt(_) => SyntaxKind::CreateUserMappingStmt,
+                NodeEnum::AlterUserMappingStmt(_) => SyntaxKind::AlterUserMappingStmt,
+                NodeEnum::DropUserMappingStmt(_) => SyntaxKind::DropUserMappingStmt,
+                NodeEnum::AlterTableSpaceOptionsStmt(_) => {
+                    SyntaxKind::AlterTableSpaceOptionsStmt
+                }
+                NodeEnum::AlterTableMoveAllStmt(_) => SyntaxKind::AlterTableMoveAllStmt,
+                NodeEnum::SecLabelStmt(_) => SyntaxKind::SecLabelStmt,
+                NodeEnum::CreateForeignTableStmt(_) => SyntaxKind::CreateForeignTableStmt,
+                NodeEnum::ImportForeignSchemaStmt(_) => {
+                    SyntaxKind::ImportForeignSchemaStmt
+                }
+                NodeEnum::CreateExtensionStmt(_) => SyntaxKind::CreateExtensionStmt,
+                NodeEnum::AlterExtensionStmt(_) => SyntaxKind::AlterExtensionStmt,
+                NodeEnum::AlterExtensionContentsStmt(_) => {
+                    SyntaxKind::AlterExtensionContentsStmt
+                }
+                NodeEnum::CreateEventTrigStmt(_) => SyntaxKind::CreateEventTrigStmt,
+                NodeEnum::AlterEventTrigStmt(_) => SyntaxKind::AlterEventTrigStmt,
+                NodeEnum::RefreshMatViewStmt(_) => SyntaxKind::RefreshMatViewStmt,
+                NodeEnum::ReplicaIdentityStmt(_) => SyntaxKind::ReplicaIdentityStmt,
+                NodeEnum::AlterSystemStmt(_) => SyntaxKind::AlterSystemStmt,
+                NodeEnum::CreatePolicyStmt(_) => SyntaxKind::CreatePolicyStmt,
+                NodeEnum::AlterPolicyStmt(_) => SyntaxKind::AlterPolicyStmt,
+                NodeEnum::CreateTransformStmt(_) => SyntaxKind::CreateTransformStmt,
+                NodeEnum::CreateAmStmt(_) => SyntaxKind::CreateAmStmt,
+                NodeEnum::CreatePublicationStmt(_) => SyntaxKind::CreatePublicationStmt,
+                NodeEnum::AlterPublicationStmt(_) => SyntaxKind::AlterPublicationStmt,
+                NodeEnum::CreateSubscriptionStmt(_) => SyntaxKind::CreateSubscriptionStmt,
+                NodeEnum::AlterSubscriptionStmt(_) => SyntaxKind::AlterSubscriptionStmt,
+                NodeEnum::DropSubscriptionStmt(_) => SyntaxKind::DropSubscriptionStmt,
+                NodeEnum::CreateStatsStmt(_) => SyntaxKind::CreateStatsStmt,
+                NodeEnum::AlterCollationStmt(_) => SyntaxKind::AlterCollationStmt,
+                NodeEnum::CallStmt(_) => SyntaxKind::CallStmt,
+                NodeEnum::AlterStatsStmt(_) => SyntaxKind::AlterStatsStmt,
+                NodeEnum::AExpr(_) => SyntaxKind::AExpr,
+                NodeEnum::ColumnRef(_) => SyntaxKind::ColumnRef,
+                NodeEnum::ParamRef(_) => SyntaxKind::ParamRef,
+                NodeEnum::FuncCall(_) => SyntaxKind::FuncCall,
+                NodeEnum::AStar(_) => SyntaxKind::AStar,
+                NodeEnum::AIndices(_) => SyntaxKind::AIndices,
+                NodeEnum::AIndirection(_) => SyntaxKind::AIndirection,
+                NodeEnum::AArrayExpr(_) => SyntaxKind::AArrayExpr,
+                NodeEnum::ResTarget(_) => SyntaxKind::ResTarget,
+                NodeEnum::MultiAssignRef(_) => SyntaxKind::MultiAssignRef,
+                NodeEnum::TypeCast(_) => SyntaxKind::TypeCast,
+                NodeEnum::CollateClause(_) => SyntaxKind::CollateClause,
+                NodeEnum::SortBy(_) => SyntaxKind::SortBy,
+                NodeEnum::WindowDef(_) => SyntaxKind::WindowDef,
+                NodeEnum::RangeSubselect(_) => SyntaxKind::RangeSubselect,
+                NodeEnum::RangeFunction(_) => SyntaxKind::RangeFunction,
+                NodeEnum::RangeTableSample(_) => SyntaxKind::RangeTableSample,
+                NodeEnum::RangeTableFunc(_) => SyntaxKind::RangeTableFunc,
+                NodeEnum::RangeTableFuncCol(_) => SyntaxKind::RangeTableFuncCol,
+                NodeEnum::TypeName(_) => SyntaxKind::TypeName,
+                NodeEnum::ColumnDef(_) => SyntaxKind::ColumnDef,
+                NodeEnum::IndexElem(_) => SyntaxKind::IndexElem,
+                NodeEnum::StatsElem(_) => SyntaxKind::StatsElem,
+                NodeEnum::Constraint(_) => SyntaxKind::Constraint,
+                NodeEnum::DefElem(_) => SyntaxKind::DefElem,
+                NodeEnum::RangeTblEntry(_) => SyntaxKind::RangeTblEntry,
+                NodeEnum::RangeTblFunction(_) => SyntaxKind::RangeTblFunction,
+                NodeEnum::TableSampleClause(_) => SyntaxKind::TableSampleClause,
+                NodeEnum::WithCheckOption(_) => SyntaxKind::WithCheckOption,
+                NodeEnum::SortGroupClause(_) => SyntaxKind::SortGroupClause,
+                NodeEnum::GroupingSet(_) => SyntaxKind::GroupingSet,
+                NodeEnum::WindowClause(_) => SyntaxKind::WindowClause,
+                NodeEnum::ObjectWithArgs(_) => SyntaxKind::ObjectWithArgs,
+                NodeEnum::AccessPriv(_) => SyntaxKind::AccessPriv,
+                NodeEnum::CreateOpClassItem(_) => SyntaxKind::CreateOpClassItem,
+                NodeEnum::TableLikeClause(_) => SyntaxKind::TableLikeClause,
+                NodeEnum::FunctionParameter(_) => SyntaxKind::FunctionParameter,
+                NodeEnum::LockingClause(_) => SyntaxKind::LockingClause,
+                NodeEnum::RowMarkClause(_) => SyntaxKind::RowMarkClause,
+                NodeEnum::XmlSerialize(_) => SyntaxKind::XmlSerialize,
+                NodeEnum::WithClause(_) => SyntaxKind::WithClause,
+                NodeEnum::InferClause(_) => SyntaxKind::InferClause,
+                NodeEnum::OnConflictClause(_) => SyntaxKind::OnConflictClause,
+                NodeEnum::CtesearchClause(_) => SyntaxKind::CtesearchClause,
+                NodeEnum::CtecycleClause(_) => SyntaxKind::CtecycleClause,
+                NodeEnum::CommonTableExpr(_) => SyntaxKind::CommonTableExpr,
+                NodeEnum::MergeWhenClause(_) => SyntaxKind::MergeWhenClause,
+                NodeEnum::RoleSpec(_) => SyntaxKind::RoleSpec,
+                NodeEnum::TriggerTransition(_) => SyntaxKind::TriggerTransition,
+                NodeEnum::PartitionElem(_) => SyntaxKind::PartitionElem,
+                NodeEnum::PartitionSpec(_) => SyntaxKind::PartitionSpec,
+                NodeEnum::PartitionBoundSpec(_) => SyntaxKind::PartitionBoundSpec,
+                NodeEnum::PartitionRangeDatum(_) => SyntaxKind::PartitionRangeDatum,
+                NodeEnum::PartitionCmd(_) => SyntaxKind::PartitionCmd,
+                NodeEnum::VacuumRelation(_) => SyntaxKind::VacuumRelation,
+                NodeEnum::PublicationObjSpec(_) => SyntaxKind::PublicationObjSpec,
+                NodeEnum::PublicationTable(_) => SyntaxKind::PublicationTable,
+                NodeEnum::InlineCodeBlock(_) => SyntaxKind::InlineCodeBlock,
+                NodeEnum::CallContext(_) => SyntaxKind::CallContext,
+                NodeEnum::Integer(_) => SyntaxKind::Integer,
+                NodeEnum::Float(_) => SyntaxKind::Float,
+                NodeEnum::Boolean(_) => SyntaxKind::Boolean,
+                NodeEnum::String(_) => SyntaxKind::String,
+                NodeEnum::BitString(_) => SyntaxKind::BitString,
+                NodeEnum::List(_) => SyntaxKind::List,
+                NodeEnum::IntList(_) => SyntaxKind::IntList,
+                NodeEnum::OidList(_) => SyntaxKind::OidList,
+                NodeEnum::AConst(_) => SyntaxKind::AConst,
+            }
+        }
+        /// Converts a `pg_query` token to a `SyntaxKind`
+        pub fn new_from_pg_query_token(token: &ScanToken) -> Self {
+            match token.token {
+                0 => SyntaxKind::Nul,
+                37 => SyntaxKind::Ascii37,
+                40 => SyntaxKind::Ascii40,
+                41 => SyntaxKind::Ascii41,
+                42 => SyntaxKind::Ascii42,
+                43 => SyntaxKind::Ascii43,
+                44 => SyntaxKind::Ascii44,
+                45 => SyntaxKind::Ascii45,
+                46 => SyntaxKind::Ascii46,
+                47 => SyntaxKind::Ascii47,
+                58 => SyntaxKind::Ascii58,
+                59 => SyntaxKind::Ascii59,
+                60 => SyntaxKind::Ascii60,
+                61 => SyntaxKind::Ascii61,
+                62 => SyntaxKind::Ascii62,
+                63 => SyntaxKind::Ascii63,
+                91 => SyntaxKind::Ascii91,
+                92 => SyntaxKind::Ascii92,
+                93 => SyntaxKind::Ascii93,
+                94 => SyntaxKind::Ascii94,
+                258 => SyntaxKind::Ident,
+                259 => SyntaxKind::Uident,
+                260 => SyntaxKind::Fconst,
+                261 => SyntaxKind::Sconst,
+                262 => SyntaxKind::Usconst,
+                263 => SyntaxKind::Bconst,
+                264 => SyntaxKind::Xconst,
+                265 => SyntaxKind::Op,
+                266 => SyntaxKind::Iconst,
+                268 => SyntaxKind::Typecast,
+                269 => SyntaxKind::DotDot,
+                270 => SyntaxKind::ColonEquals,
+                271 => SyntaxKind::EqualsGreater,
+                272 => SyntaxKind::LessEquals,
+                273 => SyntaxKind::GreaterEquals,
+                274 => SyntaxKind::NotEquals,
+                275 => SyntaxKind::SqlComment,
+                276 => SyntaxKind::CComment,
+                277 => SyntaxKind::AbortP,
+                278 => SyntaxKind::AbsoluteP,
+                279 => SyntaxKind::Access,
+                280 => SyntaxKind::Action,
+                281 => SyntaxKind::AddP,
+                282 => SyntaxKind::Admin,
+                283 => SyntaxKind::After,
+                284 => SyntaxKind::Aggregate,
+                285 => SyntaxKind::All,
+                286 => SyntaxKind::Also,
+                287 => SyntaxKind::Alter,
+                288 => SyntaxKind::Always,
+                289 => SyntaxKind::Analyse,
+                290 => SyntaxKind::Analyze,
+                291 => SyntaxKind::And,
+                292 => SyntaxKind::Any,
+                293 => SyntaxKind::Array,
+                294 => SyntaxKind::As,
+                295 => SyntaxKind::Asc,
+                296 => SyntaxKind::Asensitive,
+                297 => SyntaxKind::Assertion,
+                298 => SyntaxKind::Assignment,
+                299 => SyntaxKind::Asymmetric,
+                300 => SyntaxKind::Atomic,
+                301 => SyntaxKind::At,
+                302 => SyntaxKind::Attach,
+                303 => SyntaxKind::Attribute,
+                304 => SyntaxKind::Authorization,
+                305 => SyntaxKind::Backward,
+                306 => SyntaxKind::Before,
+                307 => SyntaxKind::BeginP,
+                308 => SyntaxKind::Between,
+                309 => SyntaxKind::Bigint,
+                310 => SyntaxKind::Binary,
+                311 => SyntaxKind::Bit,
+                312 => SyntaxKind::BooleanP,
+                313 => SyntaxKind::Both,
+                314 => SyntaxKind::Breadth,
+                315 => SyntaxKind::By,
+                316 => SyntaxKind::Cache,
+                317 => SyntaxKind::Call,
+                318 => SyntaxKind::Called,
+                319 => SyntaxKind::Cascade,
+                320 => SyntaxKind::Cascaded,
+                321 => SyntaxKind::Case,
+                322 => SyntaxKind::Cast,
+                323 => SyntaxKind::CatalogP,
+                324 => SyntaxKind::Chain,
+                325 => SyntaxKind::CharP,
+                326 => SyntaxKind::Character,
+                327 => SyntaxKind::Characteristics,
+                328 => SyntaxKind::Check,
+                329 => SyntaxKind::Checkpoint,
+                330 => SyntaxKind::Class,
+                331 => SyntaxKind::Close,
+                332 => SyntaxKind::Cluster,
+                333 => SyntaxKind::Coalesce,
+                334 => SyntaxKind::Collate,
+                335 => SyntaxKind::Collation,
+                336 => SyntaxKind::Column,
+                337 => SyntaxKind::Columns,
+                339 => SyntaxKind::Comments,
+                340 => SyntaxKind::Commit,
+                341 => SyntaxKind::Committed,
+                342 => SyntaxKind::Compression,
+                343 => SyntaxKind::Concurrently,
+                344 => SyntaxKind::Configuration,
+                345 => SyntaxKind::Conflict,
+                346 => SyntaxKind::Connection,
+                348 => SyntaxKind::Constraints,
+                349 => SyntaxKind::ContentP,
+                350 => SyntaxKind::ContinueP,
+                351 => SyntaxKind::ConversionP,
+                352 => SyntaxKind::Copy,
+                353 => SyntaxKind::Cost,
+                354 => SyntaxKind::Create,
+                355 => SyntaxKind::Cross,
+                356 => SyntaxKind::Csv,
+                357 => SyntaxKind::Cube,
+                358 => SyntaxKind::CurrentP,
+                359 => SyntaxKind::CurrentCatalog,
+                360 => SyntaxKind::CurrentDate,
+                361 => SyntaxKind::CurrentRole,
+                362 => SyntaxKind::CurrentSchema,
+                363 => SyntaxKind::CurrentTime,
+                364 => SyntaxKind::CurrentTimestamp,
+                365 => SyntaxKind::CurrentUser,
+                366 => SyntaxKind::Cursor,
+                367 => SyntaxKind::Cycle,
+                368 => SyntaxKind::DataP,
+                369 => SyntaxKind::Database,
+                370 => SyntaxKind::DayP,
+                371 => SyntaxKind::Deallocate,
+                372 => SyntaxKind::Dec,
+                373 => SyntaxKind::DecimalP,
+                374 => SyntaxKind::Declare,
+                375 => SyntaxKind::Default,
+                376 => SyntaxKind::Defaults,
+                377 => SyntaxKind::Deferrable,
+                378 => SyntaxKind::Deferred,
+                379 => SyntaxKind::Definer,
+                380 => SyntaxKind::DeleteP,
+                381 => SyntaxKind::Delimiter,
+                382 => SyntaxKind::Delimiters,
+                383 => SyntaxKind::Depends,
+                384 => SyntaxKind::Depth,
+                385 => SyntaxKind::Desc,
+                386 => SyntaxKind::Detach,
+                387 => SyntaxKind::Dictionary,
+                388 => SyntaxKind::DisableP,
+                389 => SyntaxKind::Discard,
+                390 => SyntaxKind::Distinct,
+                391 => SyntaxKind::Do,
+                392 => SyntaxKind::DocumentP,
+                393 => SyntaxKind::DomainP,
+                394 => SyntaxKind::DoubleP,
+                395 => SyntaxKind::Drop,
+                396 => SyntaxKind::Each,
+                397 => SyntaxKind::Else,
+                398 => SyntaxKind::EnableP,
+                399 => SyntaxKind::Encoding,
+                400 => SyntaxKind::Encrypted,
+                401 => SyntaxKind::EndP,
+                402 => SyntaxKind::EnumP,
+                403 => SyntaxKind::Escape,
+                404 => SyntaxKind::Event,
+                405 => SyntaxKind::Except,
+                406 => SyntaxKind::Exclude,
+                407 => SyntaxKind::Excluding,
+                408 => SyntaxKind::Exclusive,
+                409 => SyntaxKind::Execute,
+                410 => SyntaxKind::Exists,
+                411 => SyntaxKind::Explain,
+                412 => SyntaxKind::Expression,
+                413 => SyntaxKind::Extension,
+                414 => SyntaxKind::External,
+                415 => SyntaxKind::Extract,
+                416 => SyntaxKind::FalseP,
+                417 => SyntaxKind::Family,
+                418 => SyntaxKind::Fetch,
+                419 => SyntaxKind::Filter,
+                420 => SyntaxKind::Finalize,
+                421 => SyntaxKind::FirstP,
+                422 => SyntaxKind::FloatP,
+                423 => SyntaxKind::Following,
+                424 => SyntaxKind::For,
+                425 => SyntaxKind::Force,
+                426 => SyntaxKind::Foreign,
+                427 => SyntaxKind::Forward,
+                428 => SyntaxKind::Freeze,
+                429 => SyntaxKind::From,
+                430 => SyntaxKind::Full,
+                431 => SyntaxKind::Function,
+                432 => SyntaxKind::Functions,
+                433 => SyntaxKind::Generated,
+                434 => SyntaxKind::Global,
+                435 => SyntaxKind::Grant,
+                436 => SyntaxKind::Granted,
+                437 => SyntaxKind::Greatest,
+                438 => SyntaxKind::GroupP,
+                439 => SyntaxKind::Grouping,
+                440 => SyntaxKind::Groups,
+                441 => SyntaxKind::Handler,
+                442 => SyntaxKind::Having,
+                443 => SyntaxKind::HeaderP,
+                444 => SyntaxKind::Hold,
+                445 => SyntaxKind::HourP,
+                446 => SyntaxKind::IdentityP,
+                447 => SyntaxKind::IfP,
+                448 => SyntaxKind::Ilike,
+                449 => SyntaxKind::Immediate,
+                450 => SyntaxKind::Immutable,
+                451 => SyntaxKind::ImplicitP,
+                452 => SyntaxKind::ImportP,
+                453 => SyntaxKind::InP,
+                454 => SyntaxKind::Include,
+                455 => SyntaxKind::Including,
+                456 => SyntaxKind::Increment,
+                457 => SyntaxKind::Index,
+                458 => SyntaxKind::Indexes,
+                459 => SyntaxKind::Inherit,
+                460 => SyntaxKind::Inherits,
+                461 => SyntaxKind::Initially,
+                462 => SyntaxKind::InlineP,
+                463 => SyntaxKind::InnerP,
+                464 => SyntaxKind::Inout,
+                465 => SyntaxKind::InputP,
+                466 => SyntaxKind::Insensitive,
+                467 => SyntaxKind::Insert,
+                468 => SyntaxKind::Instead,
+                469 => SyntaxKind::IntP,
+                471 => SyntaxKind::Intersect,
+                472 => SyntaxKind::Interval,
+                473 => SyntaxKind::Into,
+                474 => SyntaxKind::Invoker,
+                475 => SyntaxKind::Is,
+                476 => SyntaxKind::Isnull,
+                477 => SyntaxKind::Isolation,
+                478 => SyntaxKind::Join,
+                479 => SyntaxKind::Key,
+                480 => SyntaxKind::Label,
+                481 => SyntaxKind::Language,
+                482 => SyntaxKind::LargeP,
+                483 => SyntaxKind::LastP,
+                484 => SyntaxKind::LateralP,
+                485 => SyntaxKind::Leading,
+                486 => SyntaxKind::Leakproof,
+                487 => SyntaxKind::Least,
+                488 => SyntaxKind::Left,
+                489 => SyntaxKind::Level,
+                490 => SyntaxKind::Like,
+                491 => SyntaxKind::Limit,
+                492 => SyntaxKind::Listen,
+                493 => SyntaxKind::Load,
+                494 => SyntaxKind::Local,
+                495 => SyntaxKind::Localtime,
+                496 => SyntaxKind::Localtimestamp,
+                497 => SyntaxKind::Location,
+                498 => SyntaxKind::LockP,
+                499 => SyntaxKind::Locked,
+                500 => SyntaxKind::Logged,
+                501 => SyntaxKind::Mapping,
+                502 => SyntaxKind::Match,
+                503 => SyntaxKind::Matched,
+                504 => SyntaxKind::Materialized,
+                505 => SyntaxKind::Maxvalue,
+                506 => SyntaxKind::Merge,
+                507 => SyntaxKind::Method,
+                508 => SyntaxKind::MinuteP,
+                509 => SyntaxKind::Minvalue,
+                510 => SyntaxKind::Mode,
+                511 => SyntaxKind::MonthP,
+                512 => SyntaxKind::Move,
+                513 => SyntaxKind::NameP,
+                514 => SyntaxKind::Names,
+                515 => SyntaxKind::National,
+                516 => SyntaxKind::Natural,
+                517 => SyntaxKind::Nchar,
+                518 => SyntaxKind::New,
+                519 => SyntaxKind::Next,
+                520 => SyntaxKind::Nfc,
+                521 => SyntaxKind::Nfd,
+                522 => SyntaxKind::Nfkc,
+                523 => SyntaxKind::Nfkd,
+                524 => SyntaxKind::No,
+                525 => SyntaxKind::None,
+                526 => SyntaxKind::Normalize,
+                527 => SyntaxKind::Normalized,
+                528 => SyntaxKind::Not,
+                529 => SyntaxKind::Nothing,
+                530 => SyntaxKind::Notify,
+                531 => SyntaxKind::Notnull,
+                532 => SyntaxKind::Nowait,
+                533 => SyntaxKind::NullP,
+                534 => SyntaxKind::Nullif,
+                535 => SyntaxKind::NullsP,
+                536 => SyntaxKind::Numeric,
+                537 => SyntaxKind::ObjectP,
+                538 => SyntaxKind::Of,
+                539 => SyntaxKind::Off,
+                540 => SyntaxKind::Offset,
+                541 => SyntaxKind::Oids,
+                542 => SyntaxKind::Old,
+                543 => SyntaxKind::On,
+                544 => SyntaxKind::Only,
+                545 => SyntaxKind::Operator,
+                546 => SyntaxKind::Option,
+                547 => SyntaxKind::Options,
+                548 => SyntaxKind::Or,
+                549 => SyntaxKind::Order,
+                550 => SyntaxKind::Ordinality,
+                551 => SyntaxKind::Others,
+                552 => SyntaxKind::OutP,
+                553 => SyntaxKind::OuterP,
+                554 => SyntaxKind::Over,
+                555 => SyntaxKind::Overlaps,
+                556 => SyntaxKind::Overlay,
+                557 => SyntaxKind::Overriding,
+                558 => SyntaxKind::Owned,
+                559 => SyntaxKind::Owner,
+                560 => SyntaxKind::Parallel,
+                561 => SyntaxKind::Parameter,
+                562 => SyntaxKind::Parser,
+                563 => SyntaxKind::Partial,
+                564 => SyntaxKind::Partition,
+                565 => SyntaxKind::Passing,
+                566 => SyntaxKind::Password,
+                567 => SyntaxKind::Placing,
+                568 => SyntaxKind::Plans,
+                569 => SyntaxKind::Policy,
+                570 => SyntaxKind::Position,
+                571 => SyntaxKind::Preceding,
+                572 => SyntaxKind::Precision,
+                573 => SyntaxKind::Preserve,
+                574 => SyntaxKind::Prepare,
+                575 => SyntaxKind::Prepared,
+                576 => SyntaxKind::Primary,
+                577 => SyntaxKind::Prior,
+                578 => SyntaxKind::Privileges,
+                579 => SyntaxKind::Procedural,
+                580 => SyntaxKind::Procedure,
+                581 => SyntaxKind::Procedures,
+                582 => SyntaxKind::Program,
+                583 => SyntaxKind::Publication,
+                584 => SyntaxKind::Quote,
+                585 => SyntaxKind::Range,
+                586 => SyntaxKind::Read,
+                587 => SyntaxKind::Real,
+                588 => SyntaxKind::Reassign,
+                589 => SyntaxKind::Recheck,
+                590 => SyntaxKind::Recursive,
+                591 => SyntaxKind::RefP,
+                592 => SyntaxKind::References,
+                593 => SyntaxKind::Referencing,
+                594 => SyntaxKind::Refresh,
+                595 => SyntaxKind::Reindex,
+                596 => SyntaxKind::RelativeP,
+                597 => SyntaxKind::Release,
+                598 => SyntaxKind::Rename,
+                599 => SyntaxKind::Repeatable,
+                600 => SyntaxKind::Replace,
+                601 => SyntaxKind::Replica,
+                602 => SyntaxKind::Reset,
+                603 => SyntaxKind::Restart,
+                604 => SyntaxKind::Restrict,
+                605 => SyntaxKind::Return,
+                606 => SyntaxKind::Returning,
+                607 => SyntaxKind::Returns,
+                608 => SyntaxKind::Revoke,
+                609 => SyntaxKind::Right,
+                610 => SyntaxKind::Role,
+                611 => SyntaxKind::Rollback,
+                612 => SyntaxKind::Rollup,
+                613 => SyntaxKind::Routine,
+                614 => SyntaxKind::Routines,
+                615 => SyntaxKind::Row,
+                616 => SyntaxKind::Rows,
+                617 => SyntaxKind::Rule,
+                618 => SyntaxKind::Savepoint,
+                619 => SyntaxKind::Schema,
+                620 => SyntaxKind::Schemas,
+                621 => SyntaxKind::Scroll,
+                622 => SyntaxKind::Search,
+                623 => SyntaxKind::SecondP,
+                624 => SyntaxKind::Security,
+                625 => SyntaxKind::Select,
+                626 => SyntaxKind::Sequence,
+                627 => SyntaxKind::Sequences,
+                628 => SyntaxKind::Serializable,
+                629 => SyntaxKind::Server,
+                630 => SyntaxKind::Session,
+                631 => SyntaxKind::SessionUser,
+                632 => SyntaxKind::Set,
+                633 => SyntaxKind::Sets,
+                634 => SyntaxKind::Setof,
+                635 => SyntaxKind::Share,
+                636 => SyntaxKind::Show,
+                637 => SyntaxKind::Similar,
+                638 => SyntaxKind::Simple,
+                639 => SyntaxKind::Skip,
+                640 => SyntaxKind::Smallint,
+                641 => SyntaxKind::Snapshot,
+                642 => SyntaxKind::Some,
+                643 => SyntaxKind::SqlP,
+                644 => SyntaxKind::Stable,
+                645 => SyntaxKind::StandaloneP,
+                646 => SyntaxKind::Start,
+                647 => SyntaxKind::Statement,
+                648 => SyntaxKind::Statistics,
+                649 => SyntaxKind::Stdin,
+                650 => SyntaxKind::Stdout,
+                651 => SyntaxKind::Storage,
+                652 => SyntaxKind::Stored,
+                653 => SyntaxKind::StrictP,
+                654 => SyntaxKind::StripP,
+                655 => SyntaxKind::Subscription,
+                656 => SyntaxKind::Substring,
+                657 => SyntaxKind::Support,
+                658 => SyntaxKind::Symmetric,
+                659 => SyntaxKind::Sysid,
+                660 => SyntaxKind::SystemP,
+                661 => SyntaxKind::Table,
+                662 => SyntaxKind::Tables,
+                663 => SyntaxKind::Tablesample,
+                664 => SyntaxKind::Tablespace,
+                665 => SyntaxKind::Temp,
+                666 => SyntaxKind::Template,
+                667 => SyntaxKind::Temporary,
+                668 => SyntaxKind::TextP,
+                669 => SyntaxKind::Then,
+                670 => SyntaxKind::Ties,
+                671 => SyntaxKind::Time,
+                672 => SyntaxKind::Timestamp,
+                673 => SyntaxKind::To,
+                674 => SyntaxKind::Trailing,
+                675 => SyntaxKind::Transaction,
+                676 => SyntaxKind::Transform,
+                677 => SyntaxKind::Treat,
+                678 => SyntaxKind::Trigger,
+                679 => SyntaxKind::Trim,
+                680 => SyntaxKind::TrueP,
+                681 => SyntaxKind::Truncate,
+                682 => SyntaxKind::Trusted,
+                683 => SyntaxKind::TypeP,
+                684 => SyntaxKind::TypesP,
+                685 => SyntaxKind::Uescape,
+                686 => SyntaxKind::Unbounded,
+                687 => SyntaxKind::Uncommitted,
+                688 => SyntaxKind::Unencrypted,
+                689 => SyntaxKind::Union,
+                690 => SyntaxKind::Unique,
+                691 => SyntaxKind::Unknown,
+                692 => SyntaxKind::Unlisten,
+                693 => SyntaxKind::Unlogged,
+                694 => SyntaxKind::Until,
+                695 => SyntaxKind::Update,
+                696 => SyntaxKind::User,
+                697 => SyntaxKind::Using,
+                698 => SyntaxKind::Vacuum,
+                699 => SyntaxKind::Valid,
+                700 => SyntaxKind::Validate,
+                701 => SyntaxKind::Validator,
+                702 => SyntaxKind::ValueP,
+                703 => SyntaxKind::Values,
+                704 => SyntaxKind::Varchar,
+                705 => SyntaxKind::Variadic,
+                706 => SyntaxKind::Varying,
+                707 => SyntaxKind::Verbose,
+                708 => SyntaxKind::VersionP,
+                709 => SyntaxKind::View,
+                710 => SyntaxKind::Views,
+                711 => SyntaxKind::Volatile,
+                712 => SyntaxKind::When,
+                713 => SyntaxKind::Where,
+                714 => SyntaxKind::WhitespaceP,
+                715 => SyntaxKind::Window,
+                716 => SyntaxKind::With,
+                717 => SyntaxKind::Within,
+                718 => SyntaxKind::Without,
+                719 => SyntaxKind::Work,
+                720 => SyntaxKind::Wrapper,
+                721 => SyntaxKind::Write,
+                722 => SyntaxKind::XmlP,
+                723 => SyntaxKind::Xmlattributes,
+                724 => SyntaxKind::Xmlconcat,
+                725 => SyntaxKind::Xmlelement,
+                726 => SyntaxKind::Xmlexists,
+                727 => SyntaxKind::Xmlforest,
+                728 => SyntaxKind::Xmlnamespaces,
+                729 => SyntaxKind::Xmlparse,
+                730 => SyntaxKind::Xmlpi,
+                731 => SyntaxKind::Xmlroot,
+                732 => SyntaxKind::Xmlserialize,
+                733 => SyntaxKind::Xmltable,
+                734 => SyntaxKind::YearP,
+                735 => SyntaxKind::YesP,
+                736 => SyntaxKind::Zone,
+                737 => SyntaxKind::NotLa,
+                738 => SyntaxKind::NullsLa,
+                739 => SyntaxKind::WithLa,
+                740 => SyntaxKind::ModeTypeName,
+                741 => SyntaxKind::ModePlpgsqlExpr,
+                742 => SyntaxKind::ModePlpgsqlAssign1,
+                743 => SyntaxKind::ModePlpgsqlAssign2,
+                744 => SyntaxKind::ModePlpgsqlAssign3,
+                745 => SyntaxKind::Uminus,
+                _ => {
+                    ::core::panicking::panic_fmt(format_args!("Unknown token"));
+                }
+            }
+        }
+    }
+}

From e973ab4c3b6282ee93bd08ee1bf7c1b4b0ff980f Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Wed, 30 Aug 2023 10:05:19 +0200
Subject: [PATCH 16/23] chore: cleanup

---
 SomeFile.txt | 3137 --------------------------------------------------
 1 file changed, 3137 deletions(-)
 delete mode 100644 SomeFile.txt

diff --git a/SomeFile.txt b/SomeFile.txt
deleted file mode 100644
index 5097dbc5..00000000
--- a/SomeFile.txt
+++ /dev/null
@@ -1,3137 +0,0 @@
-    Checking parser v0.0.0 (/Users/psteinroe/Developer/postgres_lsp/crates/parser)
-error: an inner attribute is not permitted in this context
- --> crates/parser/src/get_location_codegen.rs:3:1
-  |
-3 | get_location!();
-  | ^^^^^^^^^^^^^^^ the inner attribute doesn't annotate this function
-  |
-  = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
-  = note: this error originates in the macro `get_location` (in Nightly builds, run with -Z macro-backtrace for more info)
-help: to annotate the function, change the attribute from inner to outer style
-  |
-3 - get_location!();
-3 + gt_location!();
-  |
-error: could not compile `parser` (lib) due to previous error
-
-mod syntax_kind_codegen {
-    use codegen::syntax_kind;
-    use cstree::Syntax;
-    use pg_query::{protobuf::ScanToken, NodeEnum, NodeRef};
-    /// An u32 enum of all valid syntax elements (nodes and tokens) of the postgres
-    /// sql dialect, and a few custom ones that are not parsed by pg_query.rs, such
-    /// as `Whitespace`.
-    #[repr(u32)]
-    pub enum SyntaxKind {
-        SourceFile,
-        Comment,
-        Whitespace,
-        Newline,
-        Tab,
-        Stmt,
-        Alias,
-        RangeVar,
-        TableFunc,
-        Var,
-        Param,
-        Aggref,
-        GroupingFunc,
-        WindowFunc,
-        SubscriptingRef,
-        FuncExpr,
-        NamedArgExpr,
-        OpExpr,
-        DistinctExpr,
-        NullIfExpr,
-        ScalarArrayOpExpr,
-        BoolExpr,
-        SubLink,
-        SubPlan,
-        AlternativeSubPlan,
-        FieldSelect,
-        FieldStore,
-        RelabelType,
-        CoerceViaIo,
-        ArrayCoerceExpr,
-        ConvertRowtypeExpr,
-        CollateExpr,
-        CaseExpr,
-        CaseWhen,
-        CaseTestExpr,
-        ArrayExpr,
-        RowExpr,
-        RowCompareExpr,
-        CoalesceExpr,
-        MinMaxExpr,
-        SqlvalueFunction,
-        XmlExpr,
-        NullTest,
-        BooleanTest,
-        CoerceToDomain,
-        CoerceToDomainValue,
-        SetToDefault,
-        CurrentOfExpr,
-        NextValueExpr,
-        InferenceElem,
-        TargetEntry,
-        RangeTblRef,
-        JoinExpr,
-        FromExpr,
-        OnConflictExpr,
-        IntoClause,
-        MergeAction,
-        RawStmt,
-        Query,
-        InsertStmt,
-        DeleteStmt,
-        UpdateStmt,
-        MergeStmt,
-        SelectStmt,
-        ReturnStmt,
-        PlassignStmt,
-        AlterTableStmt,
-        AlterTableCmd,
-        AlterDomainStmt,
-        SetOperationStmt,
-        GrantStmt,
-        GrantRoleStmt,
-        AlterDefaultPrivilegesStmt,
-        ClosePortalStmt,
-        ClusterStmt,
-        CopyStmt,
-        CreateStmt,
-        DefineStmt,
-        DropStmt,
-        TruncateStmt,
-        CommentStmt,
-        FetchStmt,
-        IndexStmt,
-        CreateFunctionStmt,
-        AlterFunctionStmt,
-        DoStmt,
-        RenameStmt,
-        RuleStmt,
-        NotifyStmt,
-        ListenStmt,
-        UnlistenStmt,
-        TransactionStmt,
-        ViewStmt,
-        LoadStmt,
-        CreateDomainStmt,
-        CreatedbStmt,
-        DropdbStmt,
-        VacuumStmt,
-        ExplainStmt,
-        CreateTableAsStmt,
-        CreateSeqStmt,
-        AlterSeqStmt,
-        VariableSetStmt,
-        VariableShowStmt,
-        DiscardStmt,
-        CreateTrigStmt,
-        CreatePlangStmt,
-        CreateRoleStmt,
-        AlterRoleStmt,
-        DropRoleStmt,
-        LockStmt,
-        ConstraintsSetStmt,
-        ReindexStmt,
-        CheckPointStmt,
-        CreateSchemaStmt,
-        AlterDatabaseStmt,
-        AlterDatabaseRefreshCollStmt,
-        AlterDatabaseSetStmt,
-        AlterRoleSetStmt,
-        CreateConversionStmt,
-        CreateCastStmt,
-        CreateOpClassStmt,
-        CreateOpFamilyStmt,
-        AlterOpFamilyStmt,
-        PrepareStmt,
-        ExecuteStmt,
-        DeallocateStmt,
-        DeclareCursorStmt,
-        CreateTableSpaceStmt,
-        DropTableSpaceStmt,
-        AlterObjectDependsStmt,
-        AlterObjectSchemaStmt,
-        AlterOwnerStmt,
-        AlterOperatorStmt,
-        AlterTypeStmt,
-        DropOwnedStmt,
-        ReassignOwnedStmt,
-        CompositeTypeStmt,
-        CreateEnumStmt,
-        CreateRangeStmt,
-        AlterEnumStmt,
-        AlterTsdictionaryStmt,
-        AlterTsconfigurationStmt,
-        CreateFdwStmt,
-        AlterFdwStmt,
-        CreateForeignServerStmt,
-        AlterForeignServerStmt,
-        CreateUserMappingStmt,
-        AlterUserMappingStmt,
-        DropUserMappingStmt,
-        AlterTableSpaceOptionsStmt,
-        AlterTableMoveAllStmt,
-        SecLabelStmt,
-        CreateForeignTableStmt,
-        ImportForeignSchemaStmt,
-        CreateExtensionStmt,
-        AlterExtensionStmt,
-        AlterExtensionContentsStmt,
-        CreateEventTrigStmt,
-        AlterEventTrigStmt,
-        RefreshMatViewStmt,
-        ReplicaIdentityStmt,
-        AlterSystemStmt,
-        CreatePolicyStmt,
-        AlterPolicyStmt,
-        CreateTransformStmt,
-        CreateAmStmt,
-        CreatePublicationStmt,
-        AlterPublicationStmt,
-        CreateSubscriptionStmt,
-        AlterSubscriptionStmt,
-        DropSubscriptionStmt,
-        CreateStatsStmt,
-        AlterCollationStmt,
-        CallStmt,
-        AlterStatsStmt,
-        AExpr,
-        ColumnRef,
-        ParamRef,
-        FuncCall,
-        AStar,
-        AIndices,
-        AIndirection,
-        AArrayExpr,
-        ResTarget,
-        MultiAssignRef,
-        TypeCast,
-        CollateClause,
-        SortBy,
-        WindowDef,
-        RangeSubselect,
-        RangeFunction,
-        RangeTableSample,
-        RangeTableFunc,
-        RangeTableFuncCol,
-        TypeName,
-        ColumnDef,
-        IndexElem,
-        StatsElem,
-        Constraint,
-        DefElem,
-        RangeTblEntry,
-        RangeTblFunction,
-        TableSampleClause,
-        WithCheckOption,
-        SortGroupClause,
-        GroupingSet,
-        WindowClause,
-        ObjectWithArgs,
-        AccessPriv,
-        CreateOpClassItem,
-        TableLikeClause,
-        FunctionParameter,
-        LockingClause,
-        RowMarkClause,
-        XmlSerialize,
-        WithClause,
-        InferClause,
-        OnConflictClause,
-        CtesearchClause,
-        CtecycleClause,
-        CommonTableExpr,
-        MergeWhenClause,
-        RoleSpec,
-        TriggerTransition,
-        PartitionElem,
-        PartitionSpec,
-        PartitionBoundSpec,
-        PartitionRangeDatum,
-        PartitionCmd,
-        VacuumRelation,
-        PublicationObjSpec,
-        PublicationTable,
-        InlineCodeBlock,
-        CallContext,
-        Integer,
-        Float,
-        Boolean,
-        String,
-        BitString,
-        List,
-        IntList,
-        OidList,
-        AConst,
-        Nul,
-        Ascii37,
-        Ascii40,
-        Ascii41,
-        Ascii42,
-        Ascii43,
-        Ascii44,
-        Ascii45,
-        Ascii46,
-        Ascii47,
-        Ascii58,
-        Ascii59,
-        Ascii60,
-        Ascii61,
-        Ascii62,
-        Ascii63,
-        Ascii91,
-        Ascii92,
-        Ascii93,
-        Ascii94,
-        Ident,
-        Uident,
-        Fconst,
-        Sconst,
-        Usconst,
-        Bconst,
-        Xconst,
-        Op,
-        Iconst,
-        Typecast,
-        DotDot,
-        ColonEquals,
-        EqualsGreater,
-        LessEquals,
-        GreaterEquals,
-        NotEquals,
-        SqlComment,
-        CComment,
-        AbortP,
-        AbsoluteP,
-        Access,
-        Action,
-        AddP,
-        Admin,
-        After,
-        Aggregate,
-        All,
-        Also,
-        Alter,
-        Always,
-        Analyse,
-        Analyze,
-        And,
-        Any,
-        Array,
-        As,
-        Asc,
-        Asensitive,
-        Assertion,
-        Assignment,
-        Asymmetric,
-        Atomic,
-        At,
-        Attach,
-        Attribute,
-        Authorization,
-        Backward,
-        Before,
-        BeginP,
-        Between,
-        Bigint,
-        Binary,
-        Bit,
-        BooleanP,
-        Both,
-        Breadth,
-        By,
-        Cache,
-        Call,
-        Called,
-        Cascade,
-        Cascaded,
-        Case,
-        Cast,
-        CatalogP,
-        Chain,
-        CharP,
-        Character,
-        Characteristics,
-        Check,
-        Checkpoint,
-        Class,
-        Close,
-        Cluster,
-        Coalesce,
-        Collate,
-        Collation,
-        Column,
-        Columns,
-        Comments,
-        Commit,
-        Committed,
-        Compression,
-        Concurrently,
-        Configuration,
-        Conflict,
-        Connection,
-        Constraints,
-        ContentP,
-        ContinueP,
-        ConversionP,
-        Copy,
-        Cost,
-        Create,
-        Cross,
-        Csv,
-        Cube,
-        CurrentP,
-        CurrentCatalog,
-        CurrentDate,
-        CurrentRole,
-        CurrentSchema,
-        CurrentTime,
-        CurrentTimestamp,
-        CurrentUser,
-        Cursor,
-        Cycle,
-        DataP,
-        Database,
-        DayP,
-        Deallocate,
-        Dec,
-        DecimalP,
-        Declare,
-        Default,
-        Defaults,
-        Deferrable,
-        Deferred,
-        Definer,
-        DeleteP,
-        Delimiter,
-        Delimiters,
-        Depends,
-        Depth,
-        Desc,
-        Detach,
-        Dictionary,
-        DisableP,
-        Discard,
-        Distinct,
-        Do,
-        DocumentP,
-        DomainP,
-        DoubleP,
-        Drop,
-        Each,
-        Else,
-        EnableP,
-        Encoding,
-        Encrypted,
-        EndP,
-        EnumP,
-        Escape,
-        Event,
-        Except,
-        Exclude,
-        Excluding,
-        Exclusive,
-        Execute,
-        Exists,
-        Explain,
-        Expression,
-        Extension,
-        External,
-        Extract,
-        FalseP,
-        Family,
-        Fetch,
-        Filter,
-        Finalize,
-        FirstP,
-        FloatP,
-        Following,
-        For,
-        Force,
-        Foreign,
-        Forward,
-        Freeze,
-        From,
-        Full,
-        Function,
-        Functions,
-        Generated,
-        Global,
-        Grant,
-        Granted,
-        Greatest,
-        GroupP,
-        Grouping,
-        Groups,
-        Handler,
-        Having,
-        HeaderP,
-        Hold,
-        HourP,
-        IdentityP,
-        IfP,
-        Ilike,
-        Immediate,
-        Immutable,
-        ImplicitP,
-        ImportP,
-        InP,
-        Include,
-        Including,
-        Increment,
-        Index,
-        Indexes,
-        Inherit,
-        Inherits,
-        Initially,
-        InlineP,
-        InnerP,
-        Inout,
-        InputP,
-        Insensitive,
-        Insert,
-        Instead,
-        IntP,
-        Intersect,
-        Interval,
-        Into,
-        Invoker,
-        Is,
-        Isnull,
-        Isolation,
-        Join,
-        Key,
-        Label,
-        Language,
-        LargeP,
-        LastP,
-        LateralP,
-        Leading,
-        Leakproof,
-        Least,
-        Left,
-        Level,
-        Like,
-        Limit,
-        Listen,
-        Load,
-        Local,
-        Localtime,
-        Localtimestamp,
-        Location,
-        LockP,
-        Locked,
-        Logged,
-        Mapping,
-        Match,
-        Matched,
-        Materialized,
-        Maxvalue,
-        Merge,
-        Method,
-        MinuteP,
-        Minvalue,
-        Mode,
-        MonthP,
-        Move,
-        NameP,
-        Names,
-        National,
-        Natural,
-        Nchar,
-        New,
-        Next,
-        Nfc,
-        Nfd,
-        Nfkc,
-        Nfkd,
-        No,
-        None,
-        Normalize,
-        Normalized,
-        Not,
-        Nothing,
-        Notify,
-        Notnull,
-        Nowait,
-        NullP,
-        Nullif,
-        NullsP,
-        Numeric,
-        ObjectP,
-        Of,
-        Off,
-        Offset,
-        Oids,
-        Old,
-        On,
-        Only,
-        Operator,
-        Option,
-        Options,
-        Or,
-        Order,
-        Ordinality,
-        Others,
-        OutP,
-        OuterP,
-        Over,
-        Overlaps,
-        Overlay,
-        Overriding,
-        Owned,
-        Owner,
-        Parallel,
-        Parameter,
-        Parser,
-        Partial,
-        Partition,
-        Passing,
-        Password,
-        Placing,
-        Plans,
-        Policy,
-        Position,
-        Preceding,
-        Precision,
-        Preserve,
-        Prepare,
-        Prepared,
-        Primary,
-        Prior,
-        Privileges,
-        Procedural,
-        Procedure,
-        Procedures,
-        Program,
-        Publication,
-        Quote,
-        Range,
-        Read,
-        Real,
-        Reassign,
-        Recheck,
-        Recursive,
-        RefP,
-        References,
-        Referencing,
-        Refresh,
-        Reindex,
-        RelativeP,
-        Release,
-        Rename,
-        Repeatable,
-        Replace,
-        Replica,
-        Reset,
-        Restart,
-        Restrict,
-        Return,
-        Returning,
-        Returns,
-        Revoke,
-        Right,
-        Role,
-        Rollback,
-        Rollup,
-        Routine,
-        Routines,
-        Row,
-        Rows,
-        Rule,
-        Savepoint,
-        Schema,
-        Schemas,
-        Scroll,
-        Search,
-        SecondP,
-        Security,
-        Select,
-        Sequence,
-        Sequences,
-        Serializable,
-        Server,
-        Session,
-        SessionUser,
-        Set,
-        Sets,
-        Setof,
-        Share,
-        Show,
-        Similar,
-        Simple,
-        Skip,
-        Smallint,
-        Snapshot,
-        Some,
-        SqlP,
-        Stable,
-        StandaloneP,
-        Start,
-        Statement,
-        Statistics,
-        Stdin,
-        Stdout,
-        Storage,
-        Stored,
-        StrictP,
-        StripP,
-        Subscription,
-        Substring,
-        Support,
-        Symmetric,
-        Sysid,
-        SystemP,
-        Table,
-        Tables,
-        Tablesample,
-        Tablespace,
-        Temp,
-        Template,
-        Temporary,
-        TextP,
-        Then,
-        Ties,
-        Time,
-        Timestamp,
-        To,
-        Trailing,
-        Transaction,
-        Transform,
-        Treat,
-        Trigger,
-        Trim,
-        TrueP,
-        Truncate,
-        Trusted,
-        TypeP,
-        TypesP,
-        Uescape,
-        Unbounded,
-        Uncommitted,
-        Unencrypted,
-        Union,
-        Unique,
-        Unknown,
-        Unlisten,
-        Unlogged,
-        Until,
-        Update,
-        User,
-        Using,
-        Vacuum,
-        Valid,
-        Validate,
-        Validator,
-        ValueP,
-        Values,
-        Varchar,
-        Variadic,
-        Varying,
-        Verbose,
-        VersionP,
-        View,
-        Views,
-        Volatile,
-        When,
-        Where,
-        WhitespaceP,
-        Window,
-        With,
-        Within,
-        Without,
-        Work,
-        Wrapper,
-        Write,
-        XmlP,
-        Xmlattributes,
-        Xmlconcat,
-        Xmlelement,
-        Xmlexists,
-        Xmlforest,
-        Xmlnamespaces,
-        Xmlparse,
-        Xmlpi,
-        Xmlroot,
-        Xmlserialize,
-        Xmltable,
-        YearP,
-        YesP,
-        Zone,
-        NotLa,
-        NullsLa,
-        WithLa,
-        ModeTypeName,
-        ModePlpgsqlExpr,
-        ModePlpgsqlAssign1,
-        ModePlpgsqlAssign2,
-        ModePlpgsqlAssign3,
-        Uminus,
-    }
-    #[automatically_derived]
-    impl ::core::clone::Clone for SyntaxKind {
-        #[inline]
-        fn clone(&self) -> SyntaxKind {
-            *self
-        }
-    }
-    #[automatically_derived]
-    impl ::core::marker::Copy for SyntaxKind {}
-    #[automatically_derived]
-    impl ::core::marker::StructuralPartialEq for SyntaxKind {}
-    #[automatically_derived]
-    impl ::core::cmp::PartialEq for SyntaxKind {
-        #[inline]
-        fn eq(&self, other: &SyntaxKind) -> bool {
-            let __self_tag = ::core::intrinsics::discriminant_value(self);
-            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
-            __self_tag == __arg1_tag
-        }
-    }
-    #[automatically_derived]
-    impl ::core::marker::StructuralEq for SyntaxKind {}
-    #[automatically_derived]
-    impl ::core::cmp::Eq for SyntaxKind {
-        #[inline]
-        #[doc(hidden)]
-        #[no_coverage]
-        fn assert_receiver_is_total_eq(&self) -> () {}
-    }
-    #[automatically_derived]
-    impl ::core::cmp::PartialOrd for SyntaxKind {
-        #[inline]
-        fn partial_cmp(
-            &self,
-            other: &SyntaxKind,
-        ) -> ::core::option::Option<::core::cmp::Ordering> {
-            let __self_tag = ::core::intrinsics::discriminant_value(self);
-            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
-            ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag)
-        }
-    }
-    #[automatically_derived]
-    impl ::core::cmp::Ord for SyntaxKind {
-        #[inline]
-        fn cmp(&self, other: &SyntaxKind) -> ::core::cmp::Ordering {
-            let __self_tag = ::core::intrinsics::discriminant_value(self);
-            let __arg1_tag = ::core::intrinsics::discriminant_value(other);
-            ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag)
-        }
-    }
-    #[automatically_derived]
-    impl ::core::hash::Hash for SyntaxKind {
-        fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
-            let __self_tag = ::core::intrinsics::discriminant_value(self);
-            ::core::hash::Hash::hash(&__self_tag, state)
-        }
-    }
-    #[automatically_derived]
-    impl ::core::fmt::Debug for SyntaxKind {
-        fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
-            ::core::fmt::Formatter::write_str(
-                f,
-                match self {
-                    SyntaxKind::SourceFile => "SourceFile",
-                    SyntaxKind::Comment => "Comment",
-                    SyntaxKind::Whitespace => "Whitespace",
-                    SyntaxKind::Newline => "Newline",
-                    SyntaxKind::Tab => "Tab",
-                    SyntaxKind::Stmt => "Stmt",
-                    SyntaxKind::Alias => "Alias",
-                    SyntaxKind::RangeVar => "RangeVar",
-                    SyntaxKind::TableFunc => "TableFunc",
-                    SyntaxKind::Var => "Var",
-                    SyntaxKind::Param => "Param",
-                    SyntaxKind::Aggref => "Aggref",
-                    SyntaxKind::GroupingFunc => "GroupingFunc",
-                    SyntaxKind::WindowFunc => "WindowFunc",
-                    SyntaxKind::SubscriptingRef => "SubscriptingRef",
-                    SyntaxKind::FuncExpr => "FuncExpr",
-                    SyntaxKind::NamedArgExpr => "NamedArgExpr",
-                    SyntaxKind::OpExpr => "OpExpr",
-                    SyntaxKind::DistinctExpr => "DistinctExpr",
-                    SyntaxKind::NullIfExpr => "NullIfExpr",
-                    SyntaxKind::ScalarArrayOpExpr => "ScalarArrayOpExpr",
-                    SyntaxKind::BoolExpr => "BoolExpr",
-                    SyntaxKind::SubLink => "SubLink",
-                    SyntaxKind::SubPlan => "SubPlan",
-                    SyntaxKind::AlternativeSubPlan => "AlternativeSubPlan",
-                    SyntaxKind::FieldSelect => "FieldSelect",
-                    SyntaxKind::FieldStore => "FieldStore",
-                    SyntaxKind::RelabelType => "RelabelType",
-                    SyntaxKind::CoerceViaIo => "CoerceViaIo",
-                    SyntaxKind::ArrayCoerceExpr => "ArrayCoerceExpr",
-                    SyntaxKind::ConvertRowtypeExpr => "ConvertRowtypeExpr",
-                    SyntaxKind::CollateExpr => "CollateExpr",
-                    SyntaxKind::CaseExpr => "CaseExpr",
-                    SyntaxKind::CaseWhen => "CaseWhen",
-                    SyntaxKind::CaseTestExpr => "CaseTestExpr",
-                    SyntaxKind::ArrayExpr => "ArrayExpr",
-                    SyntaxKind::RowExpr => "RowExpr",
-                    SyntaxKind::RowCompareExpr => "RowCompareExpr",
-                    SyntaxKind::CoalesceExpr => "CoalesceExpr",
-                    SyntaxKind::MinMaxExpr => "MinMaxExpr",
-                    SyntaxKind::SqlvalueFunction => "SqlvalueFunction",
-                    SyntaxKind::XmlExpr => "XmlExpr",
-                    SyntaxKind::NullTest => "NullTest",
-                    SyntaxKind::BooleanTest => "BooleanTest",
-                    SyntaxKind::CoerceToDomain => "CoerceToDomain",
-                    SyntaxKind::CoerceToDomainValue => "CoerceToDomainValue",
-                    SyntaxKind::SetToDefault => "SetToDefault",
-                    SyntaxKind::CurrentOfExpr => "CurrentOfExpr",
-                    SyntaxKind::NextValueExpr => "NextValueExpr",
-                    SyntaxKind::InferenceElem => "InferenceElem",
-                    SyntaxKind::TargetEntry => "TargetEntry",
-                    SyntaxKind::RangeTblRef => "RangeTblRef",
-                    SyntaxKind::JoinExpr => "JoinExpr",
-                    SyntaxKind::FromExpr => "FromExpr",
-                    SyntaxKind::OnConflictExpr => "OnConflictExpr",
-                    SyntaxKind::IntoClause => "IntoClause",
-                    SyntaxKind::MergeAction => "MergeAction",
-                    SyntaxKind::RawStmt => "RawStmt",
-                    SyntaxKind::Query => "Query",
-                    SyntaxKind::InsertStmt => "InsertStmt",
-                    SyntaxKind::DeleteStmt => "DeleteStmt",
-                    SyntaxKind::UpdateStmt => "UpdateStmt",
-                    SyntaxKind::MergeStmt => "MergeStmt",
-                    SyntaxKind::SelectStmt => "SelectStmt",
-                    SyntaxKind::ReturnStmt => "ReturnStmt",
-                    SyntaxKind::PlassignStmt => "PlassignStmt",
-                    SyntaxKind::AlterTableStmt => "AlterTableStmt",
-                    SyntaxKind::AlterTableCmd => "AlterTableCmd",
-                    SyntaxKind::AlterDomainStmt => "AlterDomainStmt",
-                    SyntaxKind::SetOperationStmt => "SetOperationStmt",
-                    SyntaxKind::GrantStmt => "GrantStmt",
-                    SyntaxKind::GrantRoleStmt => "GrantRoleStmt",
-                    SyntaxKind::AlterDefaultPrivilegesStmt => {
-                        "AlterDefaultPrivilegesStmt"
-                    }
-                    SyntaxKind::ClosePortalStmt => "ClosePortalStmt",
-                    SyntaxKind::ClusterStmt => "ClusterStmt",
-                    SyntaxKind::CopyStmt => "CopyStmt",
-                    SyntaxKind::CreateStmt => "CreateStmt",
-                    SyntaxKind::DefineStmt => "DefineStmt",
-                    SyntaxKind::DropStmt => "DropStmt",
-                    SyntaxKind::TruncateStmt => "TruncateStmt",
-                    SyntaxKind::CommentStmt => "CommentStmt",
-                    SyntaxKind::FetchStmt => "FetchStmt",
-                    SyntaxKind::IndexStmt => "IndexStmt",
-                    SyntaxKind::CreateFunctionStmt => "CreateFunctionStmt",
-                    SyntaxKind::AlterFunctionStmt => "AlterFunctionStmt",
-                    SyntaxKind::DoStmt => "DoStmt",
-                    SyntaxKind::RenameStmt => "RenameStmt",
-                    SyntaxKind::RuleStmt => "RuleStmt",
-                    SyntaxKind::NotifyStmt => "NotifyStmt",
-                    SyntaxKind::ListenStmt => "ListenStmt",
-                    SyntaxKind::UnlistenStmt => "UnlistenStmt",
-                    SyntaxKind::TransactionStmt => "TransactionStmt",
-                    SyntaxKind::ViewStmt => "ViewStmt",
-                    SyntaxKind::LoadStmt => "LoadStmt",
-                    SyntaxKind::CreateDomainStmt => "CreateDomainStmt",
-                    SyntaxKind::CreatedbStmt => "CreatedbStmt",
-                    SyntaxKind::DropdbStmt => "DropdbStmt",
-                    SyntaxKind::VacuumStmt => "VacuumStmt",
-                    SyntaxKind::ExplainStmt => "ExplainStmt",
-                    SyntaxKind::CreateTableAsStmt => "CreateTableAsStmt",
-                    SyntaxKind::CreateSeqStmt => "CreateSeqStmt",
-                    SyntaxKind::AlterSeqStmt => "AlterSeqStmt",
-                    SyntaxKind::VariableSetStmt => "VariableSetStmt",
-                    SyntaxKind::VariableShowStmt => "VariableShowStmt",
-                    SyntaxKind::DiscardStmt => "DiscardStmt",
-                    SyntaxKind::CreateTrigStmt => "CreateTrigStmt",
-                    SyntaxKind::CreatePlangStmt => "CreatePlangStmt",
-                    SyntaxKind::CreateRoleStmt => "CreateRoleStmt",
-                    SyntaxKind::AlterRoleStmt => "AlterRoleStmt",
-                    SyntaxKind::DropRoleStmt => "DropRoleStmt",
-                    SyntaxKind::LockStmt => "LockStmt",
-                    SyntaxKind::ConstraintsSetStmt => "ConstraintsSetStmt",
-                    SyntaxKind::ReindexStmt => "ReindexStmt",
-                    SyntaxKind::CheckPointStmt => "CheckPointStmt",
-                    SyntaxKind::CreateSchemaStmt => "CreateSchemaStmt",
-                    SyntaxKind::AlterDatabaseStmt => "AlterDatabaseStmt",
-                    SyntaxKind::AlterDatabaseRefreshCollStmt => {
-                        "AlterDatabaseRefreshCollStmt"
-                    }
-                    SyntaxKind::AlterDatabaseSetStmt => "AlterDatabaseSetStmt",
-                    SyntaxKind::AlterRoleSetStmt => "AlterRoleSetStmt",
-                    SyntaxKind::CreateConversionStmt => "CreateConversionStmt",
-                    SyntaxKind::CreateCastStmt => "CreateCastStmt",
-                    SyntaxKind::CreateOpClassStmt => "CreateOpClassStmt",
-                    SyntaxKind::CreateOpFamilyStmt => "CreateOpFamilyStmt",
-                    SyntaxKind::AlterOpFamilyStmt => "AlterOpFamilyStmt",
-                    SyntaxKind::PrepareStmt => "PrepareStmt",
-                    SyntaxKind::ExecuteStmt => "ExecuteStmt",
-                    SyntaxKind::DeallocateStmt => "DeallocateStmt",
-                    SyntaxKind::DeclareCursorStmt => "DeclareCursorStmt",
-                    SyntaxKind::CreateTableSpaceStmt => "CreateTableSpaceStmt",
-                    SyntaxKind::DropTableSpaceStmt => "DropTableSpaceStmt",
-                    SyntaxKind::AlterObjectDependsStmt => "AlterObjectDependsStmt",
-                    SyntaxKind::AlterObjectSchemaStmt => "AlterObjectSchemaStmt",
-                    SyntaxKind::AlterOwnerStmt => "AlterOwnerStmt",
-                    SyntaxKind::AlterOperatorStmt => "AlterOperatorStmt",
-                    SyntaxKind::AlterTypeStmt => "AlterTypeStmt",
-                    SyntaxKind::DropOwnedStmt => "DropOwnedStmt",
-                    SyntaxKind::ReassignOwnedStmt => "ReassignOwnedStmt",
-                    SyntaxKind::CompositeTypeStmt => "CompositeTypeStmt",
-                    SyntaxKind::CreateEnumStmt => "CreateEnumStmt",
-                    SyntaxKind::CreateRangeStmt => "CreateRangeStmt",
-                    SyntaxKind::AlterEnumStmt => "AlterEnumStmt",
-                    SyntaxKind::AlterTsdictionaryStmt => "AlterTsdictionaryStmt",
-                    SyntaxKind::AlterTsconfigurationStmt => "AlterTsconfigurationStmt",
-                    SyntaxKind::CreateFdwStmt => "CreateFdwStmt",
-                    SyntaxKind::AlterFdwStmt => "AlterFdwStmt",
-                    SyntaxKind::CreateForeignServerStmt => "CreateForeignServerStmt",
-                    SyntaxKind::AlterForeignServerStmt => "AlterForeignServerStmt",
-                    SyntaxKind::CreateUserMappingStmt => "CreateUserMappingStmt",
-                    SyntaxKind::AlterUserMappingStmt => "AlterUserMappingStmt",
-                    SyntaxKind::DropUserMappingStmt => "DropUserMappingStmt",
-                    SyntaxKind::AlterTableSpaceOptionsStmt => {
-                        "AlterTableSpaceOptionsStmt"
-                    }
-                    SyntaxKind::AlterTableMoveAllStmt => "AlterTableMoveAllStmt",
-                    SyntaxKind::SecLabelStmt => "SecLabelStmt",
-                    SyntaxKind::CreateForeignTableStmt => "CreateForeignTableStmt",
-                    SyntaxKind::ImportForeignSchemaStmt => "ImportForeignSchemaStmt",
-                    SyntaxKind::CreateExtensionStmt => "CreateExtensionStmt",
-                    SyntaxKind::AlterExtensionStmt => "AlterExtensionStmt",
-                    SyntaxKind::AlterExtensionContentsStmt => {
-                        "AlterExtensionContentsStmt"
-                    }
-                    SyntaxKind::CreateEventTrigStmt => "CreateEventTrigStmt",
-                    SyntaxKind::AlterEventTrigStmt => "AlterEventTrigStmt",
-                    SyntaxKind::RefreshMatViewStmt => "RefreshMatViewStmt",
-                    SyntaxKind::ReplicaIdentityStmt => "ReplicaIdentityStmt",
-                    SyntaxKind::AlterSystemStmt => "AlterSystemStmt",
-                    SyntaxKind::CreatePolicyStmt => "CreatePolicyStmt",
-                    SyntaxKind::AlterPolicyStmt => "AlterPolicyStmt",
-                    SyntaxKind::CreateTransformStmt => "CreateTransformStmt",
-                    SyntaxKind::CreateAmStmt => "CreateAmStmt",
-                    SyntaxKind::CreatePublicationStmt => "CreatePublicationStmt",
-                    SyntaxKind::AlterPublicationStmt => "AlterPublicationStmt",
-                    SyntaxKind::CreateSubscriptionStmt => "CreateSubscriptionStmt",
-                    SyntaxKind::AlterSubscriptionStmt => "AlterSubscriptionStmt",
-                    SyntaxKind::DropSubscriptionStmt => "DropSubscriptionStmt",
-                    SyntaxKind::CreateStatsStmt => "CreateStatsStmt",
-                    SyntaxKind::AlterCollationStmt => "AlterCollationStmt",
-                    SyntaxKind::CallStmt => "CallStmt",
-                    SyntaxKind::AlterStatsStmt => "AlterStatsStmt",
-                    SyntaxKind::AExpr => "AExpr",
-                    SyntaxKind::ColumnRef => "ColumnRef",
-                    SyntaxKind::ParamRef => "ParamRef",
-                    SyntaxKind::FuncCall => "FuncCall",
-                    SyntaxKind::AStar => "AStar",
-                    SyntaxKind::AIndices => "AIndices",
-                    SyntaxKind::AIndirection => "AIndirection",
-                    SyntaxKind::AArrayExpr => "AArrayExpr",
-                    SyntaxKind::ResTarget => "ResTarget",
-                    SyntaxKind::MultiAssignRef => "MultiAssignRef",
-                    SyntaxKind::TypeCast => "TypeCast",
-                    SyntaxKind::CollateClause => "CollateClause",
-                    SyntaxKind::SortBy => "SortBy",
-                    SyntaxKind::WindowDef => "WindowDef",
-                    SyntaxKind::RangeSubselect => "RangeSubselect",
-                    SyntaxKind::RangeFunction => "RangeFunction",
-                    SyntaxKind::RangeTableSample => "RangeTableSample",
-                    SyntaxKind::RangeTableFunc => "RangeTableFunc",
-                    SyntaxKind::RangeTableFuncCol => "RangeTableFuncCol",
-                    SyntaxKind::TypeName => "TypeName",
-                    SyntaxKind::ColumnDef => "ColumnDef",
-                    SyntaxKind::IndexElem => "IndexElem",
-                    SyntaxKind::StatsElem => "StatsElem",
-                    SyntaxKind::Constraint => "Constraint",
-                    SyntaxKind::DefElem => "DefElem",
-                    SyntaxKind::RangeTblEntry => "RangeTblEntry",
-                    SyntaxKind::RangeTblFunction => "RangeTblFunction",
-                    SyntaxKind::TableSampleClause => "TableSampleClause",
-                    SyntaxKind::WithCheckOption => "WithCheckOption",
-                    SyntaxKind::SortGroupClause => "SortGroupClause",
-                    SyntaxKind::GroupingSet => "GroupingSet",
-                    SyntaxKind::WindowClause => "WindowClause",
-                    SyntaxKind::ObjectWithArgs => "ObjectWithArgs",
-                    SyntaxKind::AccessPriv => "AccessPriv",
-                    SyntaxKind::CreateOpClassItem => "CreateOpClassItem",
-                    SyntaxKind::TableLikeClause => "TableLikeClause",
-                    SyntaxKind::FunctionParameter => "FunctionParameter",
-                    SyntaxKind::LockingClause => "LockingClause",
-                    SyntaxKind::RowMarkClause => "RowMarkClause",
-                    SyntaxKind::XmlSerialize => "XmlSerialize",
-                    SyntaxKind::WithClause => "WithClause",
-                    SyntaxKind::InferClause => "InferClause",
-                    SyntaxKind::OnConflictClause => "OnConflictClause",
-                    SyntaxKind::CtesearchClause => "CtesearchClause",
-                    SyntaxKind::CtecycleClause => "CtecycleClause",
-                    SyntaxKind::CommonTableExpr => "CommonTableExpr",
-                    SyntaxKind::MergeWhenClause => "MergeWhenClause",
-                    SyntaxKind::RoleSpec => "RoleSpec",
-                    SyntaxKind::TriggerTransition => "TriggerTransition",
-                    SyntaxKind::PartitionElem => "PartitionElem",
-                    SyntaxKind::PartitionSpec => "PartitionSpec",
-                    SyntaxKind::PartitionBoundSpec => "PartitionBoundSpec",
-                    SyntaxKind::PartitionRangeDatum => "PartitionRangeDatum",
-                    SyntaxKind::PartitionCmd => "PartitionCmd",
-                    SyntaxKind::VacuumRelation => "VacuumRelation",
-                    SyntaxKind::PublicationObjSpec => "PublicationObjSpec",
-                    SyntaxKind::PublicationTable => "PublicationTable",
-                    SyntaxKind::InlineCodeBlock => "InlineCodeBlock",
-                    SyntaxKind::CallContext => "CallContext",
-                    SyntaxKind::Integer => "Integer",
-                    SyntaxKind::Float => "Float",
-                    SyntaxKind::Boolean => "Boolean",
-                    SyntaxKind::String => "String",
-                    SyntaxKind::BitString => "BitString",
-                    SyntaxKind::List => "List",
-                    SyntaxKind::IntList => "IntList",
-                    SyntaxKind::OidList => "OidList",
-                    SyntaxKind::AConst => "AConst",
-                    SyntaxKind::Nul => "Nul",
-                    SyntaxKind::Ascii37 => "Ascii37",
-                    SyntaxKind::Ascii40 => "Ascii40",
-                    SyntaxKind::Ascii41 => "Ascii41",
-                    SyntaxKind::Ascii42 => "Ascii42",
-                    SyntaxKind::Ascii43 => "Ascii43",
-                    SyntaxKind::Ascii44 => "Ascii44",
-                    SyntaxKind::Ascii45 => "Ascii45",
-                    SyntaxKind::Ascii46 => "Ascii46",
-                    SyntaxKind::Ascii47 => "Ascii47",
-                    SyntaxKind::Ascii58 => "Ascii58",
-                    SyntaxKind::Ascii59 => "Ascii59",
-                    SyntaxKind::Ascii60 => "Ascii60",
-                    SyntaxKind::Ascii61 => "Ascii61",
-                    SyntaxKind::Ascii62 => "Ascii62",
-                    SyntaxKind::Ascii63 => "Ascii63",
-                    SyntaxKind::Ascii91 => "Ascii91",
-                    SyntaxKind::Ascii92 => "Ascii92",
-                    SyntaxKind::Ascii93 => "Ascii93",
-                    SyntaxKind::Ascii94 => "Ascii94",
-                    SyntaxKind::Ident => "Ident",
-                    SyntaxKind::Uident => "Uident",
-                    SyntaxKind::Fconst => "Fconst",
-                    SyntaxKind::Sconst => "Sconst",
-                    SyntaxKind::Usconst => "Usconst",
-                    SyntaxKind::Bconst => "Bconst",
-                    SyntaxKind::Xconst => "Xconst",
-                    SyntaxKind::Op => "Op",
-                    SyntaxKind::Iconst => "Iconst",
-                    SyntaxKind::Typecast => "Typecast",
-                    SyntaxKind::DotDot => "DotDot",
-                    SyntaxKind::ColonEquals => "ColonEquals",
-                    SyntaxKind::EqualsGreater => "EqualsGreater",
-                    SyntaxKind::LessEquals => "LessEquals",
-                    SyntaxKind::GreaterEquals => "GreaterEquals",
-                    SyntaxKind::NotEquals => "NotEquals",
-                    SyntaxKind::SqlComment => "SqlComment",
-                    SyntaxKind::CComment => "CComment",
-                    SyntaxKind::AbortP => "AbortP",
-                    SyntaxKind::AbsoluteP => "AbsoluteP",
-                    SyntaxKind::Access => "Access",
-                    SyntaxKind::Action => "Action",
-                    SyntaxKind::AddP => "AddP",
-                    SyntaxKind::Admin => "Admin",
-                    SyntaxKind::After => "After",
-                    SyntaxKind::Aggregate => "Aggregate",
-                    SyntaxKind::All => "All",
-                    SyntaxKind::Also => "Also",
-                    SyntaxKind::Alter => "Alter",
-                    SyntaxKind::Always => "Always",
-                    SyntaxKind::Analyse => "Analyse",
-                    SyntaxKind::Analyze => "Analyze",
-                    SyntaxKind::And => "And",
-                    SyntaxKind::Any => "Any",
-                    SyntaxKind::Array => "Array",
-                    SyntaxKind::As => "As",
-                    SyntaxKind::Asc => "Asc",
-                    SyntaxKind::Asensitive => "Asensitive",
-                    SyntaxKind::Assertion => "Assertion",
-                    SyntaxKind::Assignment => "Assignment",
-                    SyntaxKind::Asymmetric => "Asymmetric",
-                    SyntaxKind::Atomic => "Atomic",
-                    SyntaxKind::At => "At",
-                    SyntaxKind::Attach => "Attach",
-                    SyntaxKind::Attribute => "Attribute",
-                    SyntaxKind::Authorization => "Authorization",
-                    SyntaxKind::Backward => "Backward",
-                    SyntaxKind::Before => "Before",
-                    SyntaxKind::BeginP => "BeginP",
-                    SyntaxKind::Between => "Between",
-                    SyntaxKind::Bigint => "Bigint",
-                    SyntaxKind::Binary => "Binary",
-                    SyntaxKind::Bit => "Bit",
-                    SyntaxKind::BooleanP => "BooleanP",
-                    SyntaxKind::Both => "Both",
-                    SyntaxKind::Breadth => "Breadth",
-                    SyntaxKind::By => "By",
-                    SyntaxKind::Cache => "Cache",
-                    SyntaxKind::Call => "Call",
-                    SyntaxKind::Called => "Called",
-                    SyntaxKind::Cascade => "Cascade",
-                    SyntaxKind::Cascaded => "Cascaded",
-                    SyntaxKind::Case => "Case",
-                    SyntaxKind::Cast => "Cast",
-                    SyntaxKind::CatalogP => "CatalogP",
-                    SyntaxKind::Chain => "Chain",
-                    SyntaxKind::CharP => "CharP",
-                    SyntaxKind::Character => "Character",
-                    SyntaxKind::Characteristics => "Characteristics",
-                    SyntaxKind::Check => "Check",
-                    SyntaxKind::Checkpoint => "Checkpoint",
-                    SyntaxKind::Class => "Class",
-                    SyntaxKind::Close => "Close",
-                    SyntaxKind::Cluster => "Cluster",
-                    SyntaxKind::Coalesce => "Coalesce",
-                    SyntaxKind::Collate => "Collate",
-                    SyntaxKind::Collation => "Collation",
-                    SyntaxKind::Column => "Column",
-                    SyntaxKind::Columns => "Columns",
-                    SyntaxKind::Comments => "Comments",
-                    SyntaxKind::Commit => "Commit",
-                    SyntaxKind::Committed => "Committed",
-                    SyntaxKind::Compression => "Compression",
-                    SyntaxKind::Concurrently => "Concurrently",
-                    SyntaxKind::Configuration => "Configuration",
-                    SyntaxKind::Conflict => "Conflict",
-                    SyntaxKind::Connection => "Connection",
-                    SyntaxKind::Constraints => "Constraints",
-                    SyntaxKind::ContentP => "ContentP",
-                    SyntaxKind::ContinueP => "ContinueP",
-                    SyntaxKind::ConversionP => "ConversionP",
-                    SyntaxKind::Copy => "Copy",
-                    SyntaxKind::Cost => "Cost",
-                    SyntaxKind::Create => "Create",
-                    SyntaxKind::Cross => "Cross",
-                    SyntaxKind::Csv => "Csv",
-                    SyntaxKind::Cube => "Cube",
-                    SyntaxKind::CurrentP => "CurrentP",
-                    SyntaxKind::CurrentCatalog => "CurrentCatalog",
-                    SyntaxKind::CurrentDate => "CurrentDate",
-                    SyntaxKind::CurrentRole => "CurrentRole",
-                    SyntaxKind::CurrentSchema => "CurrentSchema",
-                    SyntaxKind::CurrentTime => "CurrentTime",
-                    SyntaxKind::CurrentTimestamp => "CurrentTimestamp",
-                    SyntaxKind::CurrentUser => "CurrentUser",
-                    SyntaxKind::Cursor => "Cursor",
-                    SyntaxKind::Cycle => "Cycle",
-                    SyntaxKind::DataP => "DataP",
-                    SyntaxKind::Database => "Database",
-                    SyntaxKind::DayP => "DayP",
-                    SyntaxKind::Deallocate => "Deallocate",
-                    SyntaxKind::Dec => "Dec",
-                    SyntaxKind::DecimalP => "DecimalP",
-                    SyntaxKind::Declare => "Declare",
-                    SyntaxKind::Default => "Default",
-                    SyntaxKind::Defaults => "Defaults",
-                    SyntaxKind::Deferrable => "Deferrable",
-                    SyntaxKind::Deferred => "Deferred",
-                    SyntaxKind::Definer => "Definer",
-                    SyntaxKind::DeleteP => "DeleteP",
-                    SyntaxKind::Delimiter => "Delimiter",
-                    SyntaxKind::Delimiters => "Delimiters",
-                    SyntaxKind::Depends => "Depends",
-                    SyntaxKind::Depth => "Depth",
-                    SyntaxKind::Desc => "Desc",
-                    SyntaxKind::Detach => "Detach",
-                    SyntaxKind::Dictionary => "Dictionary",
-                    SyntaxKind::DisableP => "DisableP",
-                    SyntaxKind::Discard => "Discard",
-                    SyntaxKind::Distinct => "Distinct",
-                    SyntaxKind::Do => "Do",
-                    SyntaxKind::DocumentP => "DocumentP",
-                    SyntaxKind::DomainP => "DomainP",
-                    SyntaxKind::DoubleP => "DoubleP",
-                    SyntaxKind::Drop => "Drop",
-                    SyntaxKind::Each => "Each",
-                    SyntaxKind::Else => "Else",
-                    SyntaxKind::EnableP => "EnableP",
-                    SyntaxKind::Encoding => "Encoding",
-                    SyntaxKind::Encrypted => "Encrypted",
-                    SyntaxKind::EndP => "EndP",
-                    SyntaxKind::EnumP => "EnumP",
-                    SyntaxKind::Escape => "Escape",
-                    SyntaxKind::Event => "Event",
-                    SyntaxKind::Except => "Except",
-                    SyntaxKind::Exclude => "Exclude",
-                    SyntaxKind::Excluding => "Excluding",
-                    SyntaxKind::Exclusive => "Exclusive",
-                    SyntaxKind::Execute => "Execute",
-                    SyntaxKind::Exists => "Exists",
-                    SyntaxKind::Explain => "Explain",
-                    SyntaxKind::Expression => "Expression",
-                    SyntaxKind::Extension => "Extension",
-                    SyntaxKind::External => "External",
-                    SyntaxKind::Extract => "Extract",
-                    SyntaxKind::FalseP => "FalseP",
-                    SyntaxKind::Family => "Family",
-                    SyntaxKind::Fetch => "Fetch",
-                    SyntaxKind::Filter => "Filter",
-                    SyntaxKind::Finalize => "Finalize",
-                    SyntaxKind::FirstP => "FirstP",
-                    SyntaxKind::FloatP => "FloatP",
-                    SyntaxKind::Following => "Following",
-                    SyntaxKind::For => "For",
-                    SyntaxKind::Force => "Force",
-                    SyntaxKind::Foreign => "Foreign",
-                    SyntaxKind::Forward => "Forward",
-                    SyntaxKind::Freeze => "Freeze",
-                    SyntaxKind::From => "From",
-                    SyntaxKind::Full => "Full",
-                    SyntaxKind::Function => "Function",
-                    SyntaxKind::Functions => "Functions",
-                    SyntaxKind::Generated => "Generated",
-                    SyntaxKind::Global => "Global",
-                    SyntaxKind::Grant => "Grant",
-                    SyntaxKind::Granted => "Granted",
-                    SyntaxKind::Greatest => "Greatest",
-                    SyntaxKind::GroupP => "GroupP",
-                    SyntaxKind::Grouping => "Grouping",
-                    SyntaxKind::Groups => "Groups",
-                    SyntaxKind::Handler => "Handler",
-                    SyntaxKind::Having => "Having",
-                    SyntaxKind::HeaderP => "HeaderP",
-                    SyntaxKind::Hold => "Hold",
-                    SyntaxKind::HourP => "HourP",
-                    SyntaxKind::IdentityP => "IdentityP",
-                    SyntaxKind::IfP => "IfP",
-                    SyntaxKind::Ilike => "Ilike",
-                    SyntaxKind::Immediate => "Immediate",
-                    SyntaxKind::Immutable => "Immutable",
-                    SyntaxKind::ImplicitP => "ImplicitP",
-                    SyntaxKind::ImportP => "ImportP",
-                    SyntaxKind::InP => "InP",
-                    SyntaxKind::Include => "Include",
-                    SyntaxKind::Including => "Including",
-                    SyntaxKind::Increment => "Increment",
-                    SyntaxKind::Index => "Index",
-                    SyntaxKind::Indexes => "Indexes",
-                    SyntaxKind::Inherit => "Inherit",
-                    SyntaxKind::Inherits => "Inherits",
-                    SyntaxKind::Initially => "Initially",
-                    SyntaxKind::InlineP => "InlineP",
-                    SyntaxKind::InnerP => "InnerP",
-                    SyntaxKind::Inout => "Inout",
-                    SyntaxKind::InputP => "InputP",
-                    SyntaxKind::Insensitive => "Insensitive",
-                    SyntaxKind::Insert => "Insert",
-                    SyntaxKind::Instead => "Instead",
-                    SyntaxKind::IntP => "IntP",
-                    SyntaxKind::Intersect => "Intersect",
-                    SyntaxKind::Interval => "Interval",
-                    SyntaxKind::Into => "Into",
-                    SyntaxKind::Invoker => "Invoker",
-                    SyntaxKind::Is => "Is",
-                    SyntaxKind::Isnull => "Isnull",
-                    SyntaxKind::Isolation => "Isolation",
-                    SyntaxKind::Join => "Join",
-                    SyntaxKind::Key => "Key",
-                    SyntaxKind::Label => "Label",
-                    SyntaxKind::Language => "Language",
-                    SyntaxKind::LargeP => "LargeP",
-                    SyntaxKind::LastP => "LastP",
-                    SyntaxKind::LateralP => "LateralP",
-                    SyntaxKind::Leading => "Leading",
-                    SyntaxKind::Leakproof => "Leakproof",
-                    SyntaxKind::Least => "Least",
-                    SyntaxKind::Left => "Left",
-                    SyntaxKind::Level => "Level",
-                    SyntaxKind::Like => "Like",
-                    SyntaxKind::Limit => "Limit",
-                    SyntaxKind::Listen => "Listen",
-                    SyntaxKind::Load => "Load",
-                    SyntaxKind::Local => "Local",
-                    SyntaxKind::Localtime => "Localtime",
-                    SyntaxKind::Localtimestamp => "Localtimestamp",
-                    SyntaxKind::Location => "Location",
-                    SyntaxKind::LockP => "LockP",
-                    SyntaxKind::Locked => "Locked",
-                    SyntaxKind::Logged => "Logged",
-                    SyntaxKind::Mapping => "Mapping",
-                    SyntaxKind::Match => "Match",
-                    SyntaxKind::Matched => "Matched",
-                    SyntaxKind::Materialized => "Materialized",
-                    SyntaxKind::Maxvalue => "Maxvalue",
-                    SyntaxKind::Merge => "Merge",
-                    SyntaxKind::Method => "Method",
-                    SyntaxKind::MinuteP => "MinuteP",
-                    SyntaxKind::Minvalue => "Minvalue",
-                    SyntaxKind::Mode => "Mode",
-                    SyntaxKind::MonthP => "MonthP",
-                    SyntaxKind::Move => "Move",
-                    SyntaxKind::NameP => "NameP",
-                    SyntaxKind::Names => "Names",
-                    SyntaxKind::National => "National",
-                    SyntaxKind::Natural => "Natural",
-                    SyntaxKind::Nchar => "Nchar",
-                    SyntaxKind::New => "New",
-                    SyntaxKind::Next => "Next",
-                    SyntaxKind::Nfc => "Nfc",
-                    SyntaxKind::Nfd => "Nfd",
-                    SyntaxKind::Nfkc => "Nfkc",
-                    SyntaxKind::Nfkd => "Nfkd",
-                    SyntaxKind::No => "No",
-                    SyntaxKind::None => "None",
-                    SyntaxKind::Normalize => "Normalize",
-                    SyntaxKind::Normalized => "Normalized",
-                    SyntaxKind::Not => "Not",
-                    SyntaxKind::Nothing => "Nothing",
-                    SyntaxKind::Notify => "Notify",
-                    SyntaxKind::Notnull => "Notnull",
-                    SyntaxKind::Nowait => "Nowait",
-                    SyntaxKind::NullP => "NullP",
-                    SyntaxKind::Nullif => "Nullif",
-                    SyntaxKind::NullsP => "NullsP",
-                    SyntaxKind::Numeric => "Numeric",
-                    SyntaxKind::ObjectP => "ObjectP",
-                    SyntaxKind::Of => "Of",
-                    SyntaxKind::Off => "Off",
-                    SyntaxKind::Offset => "Offset",
-                    SyntaxKind::Oids => "Oids",
-                    SyntaxKind::Old => "Old",
-                    SyntaxKind::On => "On",
-                    SyntaxKind::Only => "Only",
-                    SyntaxKind::Operator => "Operator",
-                    SyntaxKind::Option => "Option",
-                    SyntaxKind::Options => "Options",
-                    SyntaxKind::Or => "Or",
-                    SyntaxKind::Order => "Order",
-                    SyntaxKind::Ordinality => "Ordinality",
-                    SyntaxKind::Others => "Others",
-                    SyntaxKind::OutP => "OutP",
-                    SyntaxKind::OuterP => "OuterP",
-                    SyntaxKind::Over => "Over",
-                    SyntaxKind::Overlaps => "Overlaps",
-                    SyntaxKind::Overlay => "Overlay",
-                    SyntaxKind::Overriding => "Overriding",
-                    SyntaxKind::Owned => "Owned",
-                    SyntaxKind::Owner => "Owner",
-                    SyntaxKind::Parallel => "Parallel",
-                    SyntaxKind::Parameter => "Parameter",
-                    SyntaxKind::Parser => "Parser",
-                    SyntaxKind::Partial => "Partial",
-                    SyntaxKind::Partition => "Partition",
-                    SyntaxKind::Passing => "Passing",
-                    SyntaxKind::Password => "Password",
-                    SyntaxKind::Placing => "Placing",
-                    SyntaxKind::Plans => "Plans",
-                    SyntaxKind::Policy => "Policy",
-                    SyntaxKind::Position => "Position",
-                    SyntaxKind::Preceding => "Preceding",
-                    SyntaxKind::Precision => "Precision",
-                    SyntaxKind::Preserve => "Preserve",
-                    SyntaxKind::Prepare => "Prepare",
-                    SyntaxKind::Prepared => "Prepared",
-                    SyntaxKind::Primary => "Primary",
-                    SyntaxKind::Prior => "Prior",
-                    SyntaxKind::Privileges => "Privileges",
-                    SyntaxKind::Procedural => "Procedural",
-                    SyntaxKind::Procedure => "Procedure",
-                    SyntaxKind::Procedures => "Procedures",
-                    SyntaxKind::Program => "Program",
-                    SyntaxKind::Publication => "Publication",
-                    SyntaxKind::Quote => "Quote",
-                    SyntaxKind::Range => "Range",
-                    SyntaxKind::Read => "Read",
-                    SyntaxKind::Real => "Real",
-                    SyntaxKind::Reassign => "Reassign",
-                    SyntaxKind::Recheck => "Recheck",
-                    SyntaxKind::Recursive => "Recursive",
-                    SyntaxKind::RefP => "RefP",
-                    SyntaxKind::References => "References",
-                    SyntaxKind::Referencing => "Referencing",
-                    SyntaxKind::Refresh => "Refresh",
-                    SyntaxKind::Reindex => "Reindex",
-                    SyntaxKind::RelativeP => "RelativeP",
-                    SyntaxKind::Release => "Release",
-                    SyntaxKind::Rename => "Rename",
-                    SyntaxKind::Repeatable => "Repeatable",
-                    SyntaxKind::Replace => "Replace",
-                    SyntaxKind::Replica => "Replica",
-                    SyntaxKind::Reset => "Reset",
-                    SyntaxKind::Restart => "Restart",
-                    SyntaxKind::Restrict => "Restrict",
-                    SyntaxKind::Return => "Return",
-                    SyntaxKind::Returning => "Returning",
-                    SyntaxKind::Returns => "Returns",
-                    SyntaxKind::Revoke => "Revoke",
-                    SyntaxKind::Right => "Right",
-                    SyntaxKind::Role => "Role",
-                    SyntaxKind::Rollback => "Rollback",
-                    SyntaxKind::Rollup => "Rollup",
-                    SyntaxKind::Routine => "Routine",
-                    SyntaxKind::Routines => "Routines",
-                    SyntaxKind::Row => "Row",
-                    SyntaxKind::Rows => "Rows",
-                    SyntaxKind::Rule => "Rule",
-                    SyntaxKind::Savepoint => "Savepoint",
-                    SyntaxKind::Schema => "Schema",
-                    SyntaxKind::Schemas => "Schemas",
-                    SyntaxKind::Scroll => "Scroll",
-                    SyntaxKind::Search => "Search",
-                    SyntaxKind::SecondP => "SecondP",
-                    SyntaxKind::Security => "Security",
-                    SyntaxKind::Select => "Select",
-                    SyntaxKind::Sequence => "Sequence",
-                    SyntaxKind::Sequences => "Sequences",
-                    SyntaxKind::Serializable => "Serializable",
-                    SyntaxKind::Server => "Server",
-                    SyntaxKind::Session => "Session",
-                    SyntaxKind::SessionUser => "SessionUser",
-                    SyntaxKind::Set => "Set",
-                    SyntaxKind::Sets => "Sets",
-                    SyntaxKind::Setof => "Setof",
-                    SyntaxKind::Share => "Share",
-                    SyntaxKind::Show => "Show",
-                    SyntaxKind::Similar => "Similar",
-                    SyntaxKind::Simple => "Simple",
-                    SyntaxKind::Skip => "Skip",
-                    SyntaxKind::Smallint => "Smallint",
-                    SyntaxKind::Snapshot => "Snapshot",
-                    SyntaxKind::Some => "Some",
-                    SyntaxKind::SqlP => "SqlP",
-                    SyntaxKind::Stable => "Stable",
-                    SyntaxKind::StandaloneP => "StandaloneP",
-                    SyntaxKind::Start => "Start",
-                    SyntaxKind::Statement => "Statement",
-                    SyntaxKind::Statistics => "Statistics",
-                    SyntaxKind::Stdin => "Stdin",
-                    SyntaxKind::Stdout => "Stdout",
-                    SyntaxKind::Storage => "Storage",
-                    SyntaxKind::Stored => "Stored",
-                    SyntaxKind::StrictP => "StrictP",
-                    SyntaxKind::StripP => "StripP",
-                    SyntaxKind::Subscription => "Subscription",
-                    SyntaxKind::Substring => "Substring",
-                    SyntaxKind::Support => "Support",
-                    SyntaxKind::Symmetric => "Symmetric",
-                    SyntaxKind::Sysid => "Sysid",
-                    SyntaxKind::SystemP => "SystemP",
-                    SyntaxKind::Table => "Table",
-                    SyntaxKind::Tables => "Tables",
-                    SyntaxKind::Tablesample => "Tablesample",
-                    SyntaxKind::Tablespace => "Tablespace",
-                    SyntaxKind::Temp => "Temp",
-                    SyntaxKind::Template => "Template",
-                    SyntaxKind::Temporary => "Temporary",
-                    SyntaxKind::TextP => "TextP",
-                    SyntaxKind::Then => "Then",
-                    SyntaxKind::Ties => "Ties",
-                    SyntaxKind::Time => "Time",
-                    SyntaxKind::Timestamp => "Timestamp",
-                    SyntaxKind::To => "To",
-                    SyntaxKind::Trailing => "Trailing",
-                    SyntaxKind::Transaction => "Transaction",
-                    SyntaxKind::Transform => "Transform",
-                    SyntaxKind::Treat => "Treat",
-                    SyntaxKind::Trigger => "Trigger",
-                    SyntaxKind::Trim => "Trim",
-                    SyntaxKind::TrueP => "TrueP",
-                    SyntaxKind::Truncate => "Truncate",
-                    SyntaxKind::Trusted => "Trusted",
-                    SyntaxKind::TypeP => "TypeP",
-                    SyntaxKind::TypesP => "TypesP",
-                    SyntaxKind::Uescape => "Uescape",
-                    SyntaxKind::Unbounded => "Unbounded",
-                    SyntaxKind::Uncommitted => "Uncommitted",
-                    SyntaxKind::Unencrypted => "Unencrypted",
-                    SyntaxKind::Union => "Union",
-                    SyntaxKind::Unique => "Unique",
-                    SyntaxKind::Unknown => "Unknown",
-                    SyntaxKind::Unlisten => "Unlisten",
-                    SyntaxKind::Unlogged => "Unlogged",
-                    SyntaxKind::Until => "Until",
-                    SyntaxKind::Update => "Update",
-                    SyntaxKind::User => "User",
-                    SyntaxKind::Using => "Using",
-                    SyntaxKind::Vacuum => "Vacuum",
-                    SyntaxKind::Valid => "Valid",
-                    SyntaxKind::Validate => "Validate",
-                    SyntaxKind::Validator => "Validator",
-                    SyntaxKind::ValueP => "ValueP",
-                    SyntaxKind::Values => "Values",
-                    SyntaxKind::Varchar => "Varchar",
-                    SyntaxKind::Variadic => "Variadic",
-                    SyntaxKind::Varying => "Varying",
-                    SyntaxKind::Verbose => "Verbose",
-                    SyntaxKind::VersionP => "VersionP",
-                    SyntaxKind::View => "View",
-                    SyntaxKind::Views => "Views",
-                    SyntaxKind::Volatile => "Volatile",
-                    SyntaxKind::When => "When",
-                    SyntaxKind::Where => "Where",
-                    SyntaxKind::WhitespaceP => "WhitespaceP",
-                    SyntaxKind::Window => "Window",
-                    SyntaxKind::With => "With",
-                    SyntaxKind::Within => "Within",
-                    SyntaxKind::Without => "Without",
-                    SyntaxKind::Work => "Work",
-                    SyntaxKind::Wrapper => "Wrapper",
-                    SyntaxKind::Write => "Write",
-                    SyntaxKind::XmlP => "XmlP",
-                    SyntaxKind::Xmlattributes => "Xmlattributes",
-                    SyntaxKind::Xmlconcat => "Xmlconcat",
-                    SyntaxKind::Xmlelement => "Xmlelement",
-                    SyntaxKind::Xmlexists => "Xmlexists",
-                    SyntaxKind::Xmlforest => "Xmlforest",
-                    SyntaxKind::Xmlnamespaces => "Xmlnamespaces",
-                    SyntaxKind::Xmlparse => "Xmlparse",
-                    SyntaxKind::Xmlpi => "Xmlpi",
-                    SyntaxKind::Xmlroot => "Xmlroot",
-                    SyntaxKind::Xmlserialize => "Xmlserialize",
-                    SyntaxKind::Xmltable => "Xmltable",
-                    SyntaxKind::YearP => "YearP",
-                    SyntaxKind::YesP => "YesP",
-                    SyntaxKind::Zone => "Zone",
-                    SyntaxKind::NotLa => "NotLa",
-                    SyntaxKind::NullsLa => "NullsLa",
-                    SyntaxKind::WithLa => "WithLa",
-                    SyntaxKind::ModeTypeName => "ModeTypeName",
-                    SyntaxKind::ModePlpgsqlExpr => "ModePlpgsqlExpr",
-                    SyntaxKind::ModePlpgsqlAssign1 => "ModePlpgsqlAssign1",
-                    SyntaxKind::ModePlpgsqlAssign2 => "ModePlpgsqlAssign2",
-                    SyntaxKind::ModePlpgsqlAssign3 => "ModePlpgsqlAssign3",
-                    SyntaxKind::Uminus => "Uminus",
-                },
-            )
-        }
-    }
-    #[automatically_derived]
-    impl ::cstree::Syntax for SyntaxKind {
-        fn from_raw(raw: ::cstree::RawSyntaxKind) -> Self {
-            if !(raw.0 < 748u32) {
-                {
-                    ::core::panicking::panic_fmt(
-                        format_args!("Invalid raw syntax kind: {0}", raw.0),
-                    );
-                }
-            }
-            unsafe { ::std::mem::transmute::<u32, SyntaxKind>(raw.0) }
-        }
-        fn into_raw(self) -> ::cstree::RawSyntaxKind {
-            ::cstree::RawSyntaxKind(self as u32)
-        }
-        fn static_text(self) -> ::core::option::Option<&'static str> {
-            match self {
-                SyntaxKind::SourceFile => ::core::option::Option::None,
-                SyntaxKind::Comment => ::core::option::Option::None,
-                SyntaxKind::Whitespace => ::core::option::Option::None,
-                SyntaxKind::Newline => ::core::option::Option::None,
-                SyntaxKind::Tab => ::core::option::Option::None,
-                SyntaxKind::Stmt => ::core::option::Option::None,
-                SyntaxKind::Alias => ::core::option::Option::None,
-                SyntaxKind::RangeVar => ::core::option::Option::None,
-                SyntaxKind::TableFunc => ::core::option::Option::None,
-                SyntaxKind::Var => ::core::option::Option::None,
-                SyntaxKind::Param => ::core::option::Option::None,
-                SyntaxKind::Aggref => ::core::option::Option::None,
-                SyntaxKind::GroupingFunc => ::core::option::Option::None,
-                SyntaxKind::WindowFunc => ::core::option::Option::None,
-                SyntaxKind::SubscriptingRef => ::core::option::Option::None,
-                SyntaxKind::FuncExpr => ::core::option::Option::None,
-                SyntaxKind::NamedArgExpr => ::core::option::Option::None,
-                SyntaxKind::OpExpr => ::core::option::Option::None,
-                SyntaxKind::DistinctExpr => ::core::option::Option::None,
-                SyntaxKind::NullIfExpr => ::core::option::Option::None,
-                SyntaxKind::ScalarArrayOpExpr => ::core::option::Option::None,
-                SyntaxKind::BoolExpr => ::core::option::Option::None,
-                SyntaxKind::SubLink => ::core::option::Option::None,
-                SyntaxKind::SubPlan => ::core::option::Option::None,
-                SyntaxKind::AlternativeSubPlan => ::core::option::Option::None,
-                SyntaxKind::FieldSelect => ::core::option::Option::None,
-                SyntaxKind::FieldStore => ::core::option::Option::None,
-                SyntaxKind::RelabelType => ::core::option::Option::None,
-                SyntaxKind::CoerceViaIo => ::core::option::Option::None,
-                SyntaxKind::ArrayCoerceExpr => ::core::option::Option::None,
-                SyntaxKind::ConvertRowtypeExpr => ::core::option::Option::None,
-                SyntaxKind::CollateExpr => ::core::option::Option::None,
-                SyntaxKind::CaseExpr => ::core::option::Option::None,
-                SyntaxKind::CaseWhen => ::core::option::Option::None,
-                SyntaxKind::CaseTestExpr => ::core::option::Option::None,
-                SyntaxKind::ArrayExpr => ::core::option::Option::None,
-                SyntaxKind::RowExpr => ::core::option::Option::None,
-                SyntaxKind::RowCompareExpr => ::core::option::Option::None,
-                SyntaxKind::CoalesceExpr => ::core::option::Option::None,
-                SyntaxKind::MinMaxExpr => ::core::option::Option::None,
-                SyntaxKind::SqlvalueFunction => ::core::option::Option::None,
-                SyntaxKind::XmlExpr => ::core::option::Option::None,
-                SyntaxKind::NullTest => ::core::option::Option::None,
-                SyntaxKind::BooleanTest => ::core::option::Option::None,
-                SyntaxKind::CoerceToDomain => ::core::option::Option::None,
-                SyntaxKind::CoerceToDomainValue => ::core::option::Option::None,
-                SyntaxKind::SetToDefault => ::core::option::Option::None,
-                SyntaxKind::CurrentOfExpr => ::core::option::Option::None,
-                SyntaxKind::NextValueExpr => ::core::option::Option::None,
-                SyntaxKind::InferenceElem => ::core::option::Option::None,
-                SyntaxKind::TargetEntry => ::core::option::Option::None,
-                SyntaxKind::RangeTblRef => ::core::option::Option::None,
-                SyntaxKind::JoinExpr => ::core::option::Option::None,
-                SyntaxKind::FromExpr => ::core::option::Option::None,
-                SyntaxKind::OnConflictExpr => ::core::option::Option::None,
-                SyntaxKind::IntoClause => ::core::option::Option::None,
-                SyntaxKind::MergeAction => ::core::option::Option::None,
-                SyntaxKind::RawStmt => ::core::option::Option::None,
-                SyntaxKind::Query => ::core::option::Option::None,
-                SyntaxKind::InsertStmt => ::core::option::Option::None,
-                SyntaxKind::DeleteStmt => ::core::option::Option::None,
-                SyntaxKind::UpdateStmt => ::core::option::Option::None,
-                SyntaxKind::MergeStmt => ::core::option::Option::None,
-                SyntaxKind::SelectStmt => ::core::option::Option::None,
-                SyntaxKind::ReturnStmt => ::core::option::Option::None,
-                SyntaxKind::PlassignStmt => ::core::option::Option::None,
-                SyntaxKind::AlterTableStmt => ::core::option::Option::None,
-                SyntaxKind::AlterTableCmd => ::core::option::Option::None,
-                SyntaxKind::AlterDomainStmt => ::core::option::Option::None,
-                SyntaxKind::SetOperationStmt => ::core::option::Option::None,
-                SyntaxKind::GrantStmt => ::core::option::Option::None,
-                SyntaxKind::GrantRoleStmt => ::core::option::Option::None,
-                SyntaxKind::AlterDefaultPrivilegesStmt => ::core::option::Option::None,
-                SyntaxKind::ClosePortalStmt => ::core::option::Option::None,
-                SyntaxKind::ClusterStmt => ::core::option::Option::None,
-                SyntaxKind::CopyStmt => ::core::option::Option::None,
-                SyntaxKind::CreateStmt => ::core::option::Option::None,
-                SyntaxKind::DefineStmt => ::core::option::Option::None,
-                SyntaxKind::DropStmt => ::core::option::Option::None,
-                SyntaxKind::TruncateStmt => ::core::option::Option::None,
-                SyntaxKind::CommentStmt => ::core::option::Option::None,
-                SyntaxKind::FetchStmt => ::core::option::Option::None,
-                SyntaxKind::IndexStmt => ::core::option::Option::None,
-                SyntaxKind::CreateFunctionStmt => ::core::option::Option::None,
-                SyntaxKind::AlterFunctionStmt => ::core::option::Option::None,
-                SyntaxKind::DoStmt => ::core::option::Option::None,
-                SyntaxKind::RenameStmt => ::core::option::Option::None,
-                SyntaxKind::RuleStmt => ::core::option::Option::None,
-                SyntaxKind::NotifyStmt => ::core::option::Option::None,
-                SyntaxKind::ListenStmt => ::core::option::Option::None,
-                SyntaxKind::UnlistenStmt => ::core::option::Option::None,
-                SyntaxKind::TransactionStmt => ::core::option::Option::None,
-                SyntaxKind::ViewStmt => ::core::option::Option::None,
-                SyntaxKind::LoadStmt => ::core::option::Option::None,
-                SyntaxKind::CreateDomainStmt => ::core::option::Option::None,
-                SyntaxKind::CreatedbStmt => ::core::option::Option::None,
-                SyntaxKind::DropdbStmt => ::core::option::Option::None,
-                SyntaxKind::VacuumStmt => ::core::option::Option::None,
-                SyntaxKind::ExplainStmt => ::core::option::Option::None,
-                SyntaxKind::CreateTableAsStmt => ::core::option::Option::None,
-                SyntaxKind::CreateSeqStmt => ::core::option::Option::None,
-                SyntaxKind::AlterSeqStmt => ::core::option::Option::None,
-                SyntaxKind::VariableSetStmt => ::core::option::Option::None,
-                SyntaxKind::VariableShowStmt => ::core::option::Option::None,
-                SyntaxKind::DiscardStmt => ::core::option::Option::None,
-                SyntaxKind::CreateTrigStmt => ::core::option::Option::None,
-                SyntaxKind::CreatePlangStmt => ::core::option::Option::None,
-                SyntaxKind::CreateRoleStmt => ::core::option::Option::None,
-                SyntaxKind::AlterRoleStmt => ::core::option::Option::None,
-                SyntaxKind::DropRoleStmt => ::core::option::Option::None,
-                SyntaxKind::LockStmt => ::core::option::Option::None,
-                SyntaxKind::ConstraintsSetStmt => ::core::option::Option::None,
-                SyntaxKind::ReindexStmt => ::core::option::Option::None,
-                SyntaxKind::CheckPointStmt => ::core::option::Option::None,
-                SyntaxKind::CreateSchemaStmt => ::core::option::Option::None,
-                SyntaxKind::AlterDatabaseStmt => ::core::option::Option::None,
-                SyntaxKind::AlterDatabaseRefreshCollStmt => ::core::option::Option::None,
-                SyntaxKind::AlterDatabaseSetStmt => ::core::option::Option::None,
-                SyntaxKind::AlterRoleSetStmt => ::core::option::Option::None,
-                SyntaxKind::CreateConversionStmt => ::core::option::Option::None,
-                SyntaxKind::CreateCastStmt => ::core::option::Option::None,
-                SyntaxKind::CreateOpClassStmt => ::core::option::Option::None,
-                SyntaxKind::CreateOpFamilyStmt => ::core::option::Option::None,
-                SyntaxKind::AlterOpFamilyStmt => ::core::option::Option::None,
-                SyntaxKind::PrepareStmt => ::core::option::Option::None,
-                SyntaxKind::ExecuteStmt => ::core::option::Option::None,
-                SyntaxKind::DeallocateStmt => ::core::option::Option::None,
-                SyntaxKind::DeclareCursorStmt => ::core::option::Option::None,
-                SyntaxKind::CreateTableSpaceStmt => ::core::option::Option::None,
-                SyntaxKind::DropTableSpaceStmt => ::core::option::Option::None,
-                SyntaxKind::AlterObjectDependsStmt => ::core::option::Option::None,
-                SyntaxKind::AlterObjectSchemaStmt => ::core::option::Option::None,
-                SyntaxKind::AlterOwnerStmt => ::core::option::Option::None,
-                SyntaxKind::AlterOperatorStmt => ::core::option::Option::None,
-                SyntaxKind::AlterTypeStmt => ::core::option::Option::None,
-                SyntaxKind::DropOwnedStmt => ::core::option::Option::None,
-                SyntaxKind::ReassignOwnedStmt => ::core::option::Option::None,
-                SyntaxKind::CompositeTypeStmt => ::core::option::Option::None,
-                SyntaxKind::CreateEnumStmt => ::core::option::Option::None,
-                SyntaxKind::CreateRangeStmt => ::core::option::Option::None,
-                SyntaxKind::AlterEnumStmt => ::core::option::Option::None,
-                SyntaxKind::AlterTsdictionaryStmt => ::core::option::Option::None,
-                SyntaxKind::AlterTsconfigurationStmt => ::core::option::Option::None,
-                SyntaxKind::CreateFdwStmt => ::core::option::Option::None,
-                SyntaxKind::AlterFdwStmt => ::core::option::Option::None,
-                SyntaxKind::CreateForeignServerStmt => ::core::option::Option::None,
-                SyntaxKind::AlterForeignServerStmt => ::core::option::Option::None,
-                SyntaxKind::CreateUserMappingStmt => ::core::option::Option::None,
-                SyntaxKind::AlterUserMappingStmt => ::core::option::Option::None,
-                SyntaxKind::DropUserMappingStmt => ::core::option::Option::None,
-                SyntaxKind::AlterTableSpaceOptionsStmt => ::core::option::Option::None,
-                SyntaxKind::AlterTableMoveAllStmt => ::core::option::Option::None,
-                SyntaxKind::SecLabelStmt => ::core::option::Option::None,
-                SyntaxKind::CreateForeignTableStmt => ::core::option::Option::None,
-                SyntaxKind::ImportForeignSchemaStmt => ::core::option::Option::None,
-                SyntaxKind::CreateExtensionStmt => ::core::option::Option::None,
-                SyntaxKind::AlterExtensionStmt => ::core::option::Option::None,
-                SyntaxKind::AlterExtensionContentsStmt => ::core::option::Option::None,
-                SyntaxKind::CreateEventTrigStmt => ::core::option::Option::None,
-                SyntaxKind::AlterEventTrigStmt => ::core::option::Option::None,
-                SyntaxKind::RefreshMatViewStmt => ::core::option::Option::None,
-                SyntaxKind::ReplicaIdentityStmt => ::core::option::Option::None,
-                SyntaxKind::AlterSystemStmt => ::core::option::Option::None,
-                SyntaxKind::CreatePolicyStmt => ::core::option::Option::None,
-                SyntaxKind::AlterPolicyStmt => ::core::option::Option::None,
-                SyntaxKind::CreateTransformStmt => ::core::option::Option::None,
-                SyntaxKind::CreateAmStmt => ::core::option::Option::None,
-                SyntaxKind::CreatePublicationStmt => ::core::option::Option::None,
-                SyntaxKind::AlterPublicationStmt => ::core::option::Option::None,
-                SyntaxKind::CreateSubscriptionStmt => ::core::option::Option::None,
-                SyntaxKind::AlterSubscriptionStmt => ::core::option::Option::None,
-                SyntaxKind::DropSubscriptionStmt => ::core::option::Option::None,
-                SyntaxKind::CreateStatsStmt => ::core::option::Option::None,
-                SyntaxKind::AlterCollationStmt => ::core::option::Option::None,
-                SyntaxKind::CallStmt => ::core::option::Option::None,
-                SyntaxKind::AlterStatsStmt => ::core::option::Option::None,
-                SyntaxKind::AExpr => ::core::option::Option::None,
-                SyntaxKind::ColumnRef => ::core::option::Option::None,
-                SyntaxKind::ParamRef => ::core::option::Option::None,
-                SyntaxKind::FuncCall => ::core::option::Option::None,
-                SyntaxKind::AStar => ::core::option::Option::None,
-                SyntaxKind::AIndices => ::core::option::Option::None,
-                SyntaxKind::AIndirection => ::core::option::Option::None,
-                SyntaxKind::AArrayExpr => ::core::option::Option::None,
-                SyntaxKind::ResTarget => ::core::option::Option::None,
-                SyntaxKind::MultiAssignRef => ::core::option::Option::None,
-                SyntaxKind::TypeCast => ::core::option::Option::None,
-                SyntaxKind::CollateClause => ::core::option::Option::None,
-                SyntaxKind::SortBy => ::core::option::Option::None,
-                SyntaxKind::WindowDef => ::core::option::Option::None,
-                SyntaxKind::RangeSubselect => ::core::option::Option::None,
-                SyntaxKind::RangeFunction => ::core::option::Option::None,
-                SyntaxKind::RangeTableSample => ::core::option::Option::None,
-                SyntaxKind::RangeTableFunc => ::core::option::Option::None,
-                SyntaxKind::RangeTableFuncCol => ::core::option::Option::None,
-                SyntaxKind::TypeName => ::core::option::Option::None,
-                SyntaxKind::ColumnDef => ::core::option::Option::None,
-                SyntaxKind::IndexElem => ::core::option::Option::None,
-                SyntaxKind::StatsElem => ::core::option::Option::None,
-                SyntaxKind::Constraint => ::core::option::Option::None,
-                SyntaxKind::DefElem => ::core::option::Option::None,
-                SyntaxKind::RangeTblEntry => ::core::option::Option::None,
-                SyntaxKind::RangeTblFunction => ::core::option::Option::None,
-                SyntaxKind::TableSampleClause => ::core::option::Option::None,
-                SyntaxKind::WithCheckOption => ::core::option::Option::None,
-                SyntaxKind::SortGroupClause => ::core::option::Option::None,
-                SyntaxKind::GroupingSet => ::core::option::Option::None,
-                SyntaxKind::WindowClause => ::core::option::Option::None,
-                SyntaxKind::ObjectWithArgs => ::core::option::Option::None,
-                SyntaxKind::AccessPriv => ::core::option::Option::None,
-                SyntaxKind::CreateOpClassItem => ::core::option::Option::None,
-                SyntaxKind::TableLikeClause => ::core::option::Option::None,
-                SyntaxKind::FunctionParameter => ::core::option::Option::None,
-                SyntaxKind::LockingClause => ::core::option::Option::None,
-                SyntaxKind::RowMarkClause => ::core::option::Option::None,
-                SyntaxKind::XmlSerialize => ::core::option::Option::None,
-                SyntaxKind::WithClause => ::core::option::Option::None,
-                SyntaxKind::InferClause => ::core::option::Option::None,
-                SyntaxKind::OnConflictClause => ::core::option::Option::None,
-                SyntaxKind::CtesearchClause => ::core::option::Option::None,
-                SyntaxKind::CtecycleClause => ::core::option::Option::None,
-                SyntaxKind::CommonTableExpr => ::core::option::Option::None,
-                SyntaxKind::MergeWhenClause => ::core::option::Option::None,
-                SyntaxKind::RoleSpec => ::core::option::Option::None,
-                SyntaxKind::TriggerTransition => ::core::option::Option::None,
-                SyntaxKind::PartitionElem => ::core::option::Option::None,
-                SyntaxKind::PartitionSpec => ::core::option::Option::None,
-                SyntaxKind::PartitionBoundSpec => ::core::option::Option::None,
-                SyntaxKind::PartitionRangeDatum => ::core::option::Option::None,
-                SyntaxKind::PartitionCmd => ::core::option::Option::None,
-                SyntaxKind::VacuumRelation => ::core::option::Option::None,
-                SyntaxKind::PublicationObjSpec => ::core::option::Option::None,
-                SyntaxKind::PublicationTable => ::core::option::Option::None,
-                SyntaxKind::InlineCodeBlock => ::core::option::Option::None,
-                SyntaxKind::CallContext => ::core::option::Option::None,
-                SyntaxKind::Integer => ::core::option::Option::None,
-                SyntaxKind::Float => ::core::option::Option::None,
-                SyntaxKind::Boolean => ::core::option::Option::None,
-                SyntaxKind::String => ::core::option::Option::None,
-                SyntaxKind::BitString => ::core::option::Option::None,
-                SyntaxKind::List => ::core::option::Option::None,
-                SyntaxKind::IntList => ::core::option::Option::None,
-                SyntaxKind::OidList => ::core::option::Option::None,
-                SyntaxKind::AConst => ::core::option::Option::None,
-                SyntaxKind::Nul => ::core::option::Option::None,
-                SyntaxKind::Ascii37 => ::core::option::Option::None,
-                SyntaxKind::Ascii40 => ::core::option::Option::None,
-                SyntaxKind::Ascii41 => ::core::option::Option::None,
-                SyntaxKind::Ascii42 => ::core::option::Option::None,
-                SyntaxKind::Ascii43 => ::core::option::Option::None,
-                SyntaxKind::Ascii44 => ::core::option::Option::None,
-                SyntaxKind::Ascii45 => ::core::option::Option::None,
-                SyntaxKind::Ascii46 => ::core::option::Option::None,
-                SyntaxKind::Ascii47 => ::core::option::Option::None,
-                SyntaxKind::Ascii58 => ::core::option::Option::None,
-                SyntaxKind::Ascii59 => ::core::option::Option::None,
-                SyntaxKind::Ascii60 => ::core::option::Option::None,
-                SyntaxKind::Ascii61 => ::core::option::Option::None,
-                SyntaxKind::Ascii62 => ::core::option::Option::None,
-                SyntaxKind::Ascii63 => ::core::option::Option::None,
-                SyntaxKind::Ascii91 => ::core::option::Option::None,
-                SyntaxKind::Ascii92 => ::core::option::Option::None,
-                SyntaxKind::Ascii93 => ::core::option::Option::None,
-                SyntaxKind::Ascii94 => ::core::option::Option::None,
-                SyntaxKind::Ident => ::core::option::Option::None,
-                SyntaxKind::Uident => ::core::option::Option::None,
-                SyntaxKind::Fconst => ::core::option::Option::None,
-                SyntaxKind::Sconst => ::core::option::Option::None,
-                SyntaxKind::Usconst => ::core::option::Option::None,
-                SyntaxKind::Bconst => ::core::option::Option::None,
-                SyntaxKind::Xconst => ::core::option::Option::None,
-                SyntaxKind::Op => ::core::option::Option::None,
-                SyntaxKind::Iconst => ::core::option::Option::None,
-                SyntaxKind::Typecast => ::core::option::Option::None,
-                SyntaxKind::DotDot => ::core::option::Option::None,
-                SyntaxKind::ColonEquals => ::core::option::Option::None,
-                SyntaxKind::EqualsGreater => ::core::option::Option::None,
-                SyntaxKind::LessEquals => ::core::option::Option::None,
-                SyntaxKind::GreaterEquals => ::core::option::Option::None,
-                SyntaxKind::NotEquals => ::core::option::Option::None,
-                SyntaxKind::SqlComment => ::core::option::Option::None,
-                SyntaxKind::CComment => ::core::option::Option::None,
-                SyntaxKind::AbortP => ::core::option::Option::None,
-                SyntaxKind::AbsoluteP => ::core::option::Option::None,
-                SyntaxKind::Access => ::core::option::Option::None,
-                SyntaxKind::Action => ::core::option::Option::None,
-                SyntaxKind::AddP => ::core::option::Option::None,
-                SyntaxKind::Admin => ::core::option::Option::None,
-                SyntaxKind::After => ::core::option::Option::None,
-                SyntaxKind::Aggregate => ::core::option::Option::None,
-                SyntaxKind::All => ::core::option::Option::None,
-                SyntaxKind::Also => ::core::option::Option::None,
-                SyntaxKind::Alter => ::core::option::Option::None,
-                SyntaxKind::Always => ::core::option::Option::None,
-                SyntaxKind::Analyse => ::core::option::Option::None,
-                SyntaxKind::Analyze => ::core::option::Option::None,
-                SyntaxKind::And => ::core::option::Option::None,
-                SyntaxKind::Any => ::core::option::Option::None,
-                SyntaxKind::Array => ::core::option::Option::None,
-                SyntaxKind::As => ::core::option::Option::None,
-                SyntaxKind::Asc => ::core::option::Option::None,
-                SyntaxKind::Asensitive => ::core::option::Option::None,
-                SyntaxKind::Assertion => ::core::option::Option::None,
-                SyntaxKind::Assignment => ::core::option::Option::None,
-                SyntaxKind::Asymmetric => ::core::option::Option::None,
-                SyntaxKind::Atomic => ::core::option::Option::None,
-                SyntaxKind::At => ::core::option::Option::None,
-                SyntaxKind::Attach => ::core::option::Option::None,
-                SyntaxKind::Attribute => ::core::option::Option::None,
-                SyntaxKind::Authorization => ::core::option::Option::None,
-                SyntaxKind::Backward => ::core::option::Option::None,
-                SyntaxKind::Before => ::core::option::Option::None,
-                SyntaxKind::BeginP => ::core::option::Option::None,
-                SyntaxKind::Between => ::core::option::Option::None,
-                SyntaxKind::Bigint => ::core::option::Option::None,
-                SyntaxKind::Binary => ::core::option::Option::None,
-                SyntaxKind::Bit => ::core::option::Option::None,
-                SyntaxKind::BooleanP => ::core::option::Option::None,
-                SyntaxKind::Both => ::core::option::Option::None,
-                SyntaxKind::Breadth => ::core::option::Option::None,
-                SyntaxKind::By => ::core::option::Option::None,
-                SyntaxKind::Cache => ::core::option::Option::None,
-                SyntaxKind::Call => ::core::option::Option::None,
-                SyntaxKind::Called => ::core::option::Option::None,
-                SyntaxKind::Cascade => ::core::option::Option::None,
-                SyntaxKind::Cascaded => ::core::option::Option::None,
-                SyntaxKind::Case => ::core::option::Option::None,
-                SyntaxKind::Cast => ::core::option::Option::None,
-                SyntaxKind::CatalogP => ::core::option::Option::None,
-                SyntaxKind::Chain => ::core::option::Option::None,
-                SyntaxKind::CharP => ::core::option::Option::None,
-                SyntaxKind::Character => ::core::option::Option::None,
-                SyntaxKind::Characteristics => ::core::option::Option::None,
-                SyntaxKind::Check => ::core::option::Option::None,
-                SyntaxKind::Checkpoint => ::core::option::Option::None,
-                SyntaxKind::Class => ::core::option::Option::None,
-                SyntaxKind::Close => ::core::option::Option::None,
-                SyntaxKind::Cluster => ::core::option::Option::None,
-                SyntaxKind::Coalesce => ::core::option::Option::None,
-                SyntaxKind::Collate => ::core::option::Option::None,
-                SyntaxKind::Collation => ::core::option::Option::None,
-                SyntaxKind::Column => ::core::option::Option::None,
-                SyntaxKind::Columns => ::core::option::Option::None,
-                SyntaxKind::Comments => ::core::option::Option::None,
-                SyntaxKind::Commit => ::core::option::Option::None,
-                SyntaxKind::Committed => ::core::option::Option::None,
-                SyntaxKind::Compression => ::core::option::Option::None,
-                SyntaxKind::Concurrently => ::core::option::Option::None,
-                SyntaxKind::Configuration => ::core::option::Option::None,
-                SyntaxKind::Conflict => ::core::option::Option::None,
-                SyntaxKind::Connection => ::core::option::Option::None,
-                SyntaxKind::Constraints => ::core::option::Option::None,
-                SyntaxKind::ContentP => ::core::option::Option::None,
-                SyntaxKind::ContinueP => ::core::option::Option::None,
-                SyntaxKind::ConversionP => ::core::option::Option::None,
-                SyntaxKind::Copy => ::core::option::Option::None,
-                SyntaxKind::Cost => ::core::option::Option::None,
-                SyntaxKind::Create => ::core::option::Option::None,
-                SyntaxKind::Cross => ::core::option::Option::None,
-                SyntaxKind::Csv => ::core::option::Option::None,
-                SyntaxKind::Cube => ::core::option::Option::None,
-                SyntaxKind::CurrentP => ::core::option::Option::None,
-                SyntaxKind::CurrentCatalog => ::core::option::Option::None,
-                SyntaxKind::CurrentDate => ::core::option::Option::None,
-                SyntaxKind::CurrentRole => ::core::option::Option::None,
-                SyntaxKind::CurrentSchema => ::core::option::Option::None,
-                SyntaxKind::CurrentTime => ::core::option::Option::None,
-                SyntaxKind::CurrentTimestamp => ::core::option::Option::None,
-                SyntaxKind::CurrentUser => ::core::option::Option::None,
-                SyntaxKind::Cursor => ::core::option::Option::None,
-                SyntaxKind::Cycle => ::core::option::Option::None,
-                SyntaxKind::DataP => ::core::option::Option::None,
-                SyntaxKind::Database => ::core::option::Option::None,
-                SyntaxKind::DayP => ::core::option::Option::None,
-                SyntaxKind::Deallocate => ::core::option::Option::None,
-                SyntaxKind::Dec => ::core::option::Option::None,
-                SyntaxKind::DecimalP => ::core::option::Option::None,
-                SyntaxKind::Declare => ::core::option::Option::None,
-                SyntaxKind::Default => ::core::option::Option::None,
-                SyntaxKind::Defaults => ::core::option::Option::None,
-                SyntaxKind::Deferrable => ::core::option::Option::None,
-                SyntaxKind::Deferred => ::core::option::Option::None,
-                SyntaxKind::Definer => ::core::option::Option::None,
-                SyntaxKind::DeleteP => ::core::option::Option::None,
-                SyntaxKind::Delimiter => ::core::option::Option::None,
-                SyntaxKind::Delimiters => ::core::option::Option::None,
-                SyntaxKind::Depends => ::core::option::Option::None,
-                SyntaxKind::Depth => ::core::option::Option::None,
-                SyntaxKind::Desc => ::core::option::Option::None,
-                SyntaxKind::Detach => ::core::option::Option::None,
-                SyntaxKind::Dictionary => ::core::option::Option::None,
-                SyntaxKind::DisableP => ::core::option::Option::None,
-                SyntaxKind::Discard => ::core::option::Option::None,
-                SyntaxKind::Distinct => ::core::option::Option::None,
-                SyntaxKind::Do => ::core::option::Option::None,
-                SyntaxKind::DocumentP => ::core::option::Option::None,
-                SyntaxKind::DomainP => ::core::option::Option::None,
-                SyntaxKind::DoubleP => ::core::option::Option::None,
-                SyntaxKind::Drop => ::core::option::Option::None,
-                SyntaxKind::Each => ::core::option::Option::None,
-                SyntaxKind::Else => ::core::option::Option::None,
-                SyntaxKind::EnableP => ::core::option::Option::None,
-                SyntaxKind::Encoding => ::core::option::Option::None,
-                SyntaxKind::Encrypted => ::core::option::Option::None,
-                SyntaxKind::EndP => ::core::option::Option::None,
-                SyntaxKind::EnumP => ::core::option::Option::None,
-                SyntaxKind::Escape => ::core::option::Option::None,
-                SyntaxKind::Event => ::core::option::Option::None,
-                SyntaxKind::Except => ::core::option::Option::None,
-                SyntaxKind::Exclude => ::core::option::Option::None,
-                SyntaxKind::Excluding => ::core::option::Option::None,
-                SyntaxKind::Exclusive => ::core::option::Option::None,
-                SyntaxKind::Execute => ::core::option::Option::None,
-                SyntaxKind::Exists => ::core::option::Option::None,
-                SyntaxKind::Explain => ::core::option::Option::None,
-                SyntaxKind::Expression => ::core::option::Option::None,
-                SyntaxKind::Extension => ::core::option::Option::None,
-                SyntaxKind::External => ::core::option::Option::None,
-                SyntaxKind::Extract => ::core::option::Option::None,
-                SyntaxKind::FalseP => ::core::option::Option::None,
-                SyntaxKind::Family => ::core::option::Option::None,
-                SyntaxKind::Fetch => ::core::option::Option::None,
-                SyntaxKind::Filter => ::core::option::Option::None,
-                SyntaxKind::Finalize => ::core::option::Option::None,
-                SyntaxKind::FirstP => ::core::option::Option::None,
-                SyntaxKind::FloatP => ::core::option::Option::None,
-                SyntaxKind::Following => ::core::option::Option::None,
-                SyntaxKind::For => ::core::option::Option::None,
-                SyntaxKind::Force => ::core::option::Option::None,
-                SyntaxKind::Foreign => ::core::option::Option::None,
-                SyntaxKind::Forward => ::core::option::Option::None,
-                SyntaxKind::Freeze => ::core::option::Option::None,
-                SyntaxKind::From => ::core::option::Option::None,
-                SyntaxKind::Full => ::core::option::Option::None,
-                SyntaxKind::Function => ::core::option::Option::None,
-                SyntaxKind::Functions => ::core::option::Option::None,
-                SyntaxKind::Generated => ::core::option::Option::None,
-                SyntaxKind::Global => ::core::option::Option::None,
-                SyntaxKind::Grant => ::core::option::Option::None,
-                SyntaxKind::Granted => ::core::option::Option::None,
-                SyntaxKind::Greatest => ::core::option::Option::None,
-                SyntaxKind::GroupP => ::core::option::Option::None,
-                SyntaxKind::Grouping => ::core::option::Option::None,
-                SyntaxKind::Groups => ::core::option::Option::None,
-                SyntaxKind::Handler => ::core::option::Option::None,
-                SyntaxKind::Having => ::core::option::Option::None,
-                SyntaxKind::HeaderP => ::core::option::Option::None,
-                SyntaxKind::Hold => ::core::option::Option::None,
-                SyntaxKind::HourP => ::core::option::Option::None,
-                SyntaxKind::IdentityP => ::core::option::Option::None,
-                SyntaxKind::IfP => ::core::option::Option::None,
-                SyntaxKind::Ilike => ::core::option::Option::None,
-                SyntaxKind::Immediate => ::core::option::Option::None,
-                SyntaxKind::Immutable => ::core::option::Option::None,
-                SyntaxKind::ImplicitP => ::core::option::Option::None,
-                SyntaxKind::ImportP => ::core::option::Option::None,
-                SyntaxKind::InP => ::core::option::Option::None,
-                SyntaxKind::Include => ::core::option::Option::None,
-                SyntaxKind::Including => ::core::option::Option::None,
-                SyntaxKind::Increment => ::core::option::Option::None,
-                SyntaxKind::Index => ::core::option::Option::None,
-                SyntaxKind::Indexes => ::core::option::Option::None,
-                SyntaxKind::Inherit => ::core::option::Option::None,
-                SyntaxKind::Inherits => ::core::option::Option::None,
-                SyntaxKind::Initially => ::core::option::Option::None,
-                SyntaxKind::InlineP => ::core::option::Option::None,
-                SyntaxKind::InnerP => ::core::option::Option::None,
-                SyntaxKind::Inout => ::core::option::Option::None,
-                SyntaxKind::InputP => ::core::option::Option::None,
-                SyntaxKind::Insensitive => ::core::option::Option::None,
-                SyntaxKind::Insert => ::core::option::Option::None,
-                SyntaxKind::Instead => ::core::option::Option::None,
-                SyntaxKind::IntP => ::core::option::Option::None,
-                SyntaxKind::Intersect => ::core::option::Option::None,
-                SyntaxKind::Interval => ::core::option::Option::None,
-                SyntaxKind::Into => ::core::option::Option::None,
-                SyntaxKind::Invoker => ::core::option::Option::None,
-                SyntaxKind::Is => ::core::option::Option::None,
-                SyntaxKind::Isnull => ::core::option::Option::None,
-                SyntaxKind::Isolation => ::core::option::Option::None,
-                SyntaxKind::Join => ::core::option::Option::None,
-                SyntaxKind::Key => ::core::option::Option::None,
-                SyntaxKind::Label => ::core::option::Option::None,
-                SyntaxKind::Language => ::core::option::Option::None,
-                SyntaxKind::LargeP => ::core::option::Option::None,
-                SyntaxKind::LastP => ::core::option::Option::None,
-                SyntaxKind::LateralP => ::core::option::Option::None,
-                SyntaxKind::Leading => ::core::option::Option::None,
-                SyntaxKind::Leakproof => ::core::option::Option::None,
-                SyntaxKind::Least => ::core::option::Option::None,
-                SyntaxKind::Left => ::core::option::Option::None,
-                SyntaxKind::Level => ::core::option::Option::None,
-                SyntaxKind::Like => ::core::option::Option::None,
-                SyntaxKind::Limit => ::core::option::Option::None,
-                SyntaxKind::Listen => ::core::option::Option::None,
-                SyntaxKind::Load => ::core::option::Option::None,
-                SyntaxKind::Local => ::core::option::Option::None,
-                SyntaxKind::Localtime => ::core::option::Option::None,
-                SyntaxKind::Localtimestamp => ::core::option::Option::None,
-                SyntaxKind::Location => ::core::option::Option::None,
-                SyntaxKind::LockP => ::core::option::Option::None,
-                SyntaxKind::Locked => ::core::option::Option::None,
-                SyntaxKind::Logged => ::core::option::Option::None,
-                SyntaxKind::Mapping => ::core::option::Option::None,
-                SyntaxKind::Match => ::core::option::Option::None,
-                SyntaxKind::Matched => ::core::option::Option::None,
-                SyntaxKind::Materialized => ::core::option::Option::None,
-                SyntaxKind::Maxvalue => ::core::option::Option::None,
-                SyntaxKind::Merge => ::core::option::Option::None,
-                SyntaxKind::Method => ::core::option::Option::None,
-                SyntaxKind::MinuteP => ::core::option::Option::None,
-                SyntaxKind::Minvalue => ::core::option::Option::None,
-                SyntaxKind::Mode => ::core::option::Option::None,
-                SyntaxKind::MonthP => ::core::option::Option::None,
-                SyntaxKind::Move => ::core::option::Option::None,
-                SyntaxKind::NameP => ::core::option::Option::None,
-                SyntaxKind::Names => ::core::option::Option::None,
-                SyntaxKind::National => ::core::option::Option::None,
-                SyntaxKind::Natural => ::core::option::Option::None,
-                SyntaxKind::Nchar => ::core::option::Option::None,
-                SyntaxKind::New => ::core::option::Option::None,
-                SyntaxKind::Next => ::core::option::Option::None,
-                SyntaxKind::Nfc => ::core::option::Option::None,
-                SyntaxKind::Nfd => ::core::option::Option::None,
-                SyntaxKind::Nfkc => ::core::option::Option::None,
-                SyntaxKind::Nfkd => ::core::option::Option::None,
-                SyntaxKind::No => ::core::option::Option::None,
-                SyntaxKind::None => ::core::option::Option::None,
-                SyntaxKind::Normalize => ::core::option::Option::None,
-                SyntaxKind::Normalized => ::core::option::Option::None,
-                SyntaxKind::Not => ::core::option::Option::None,
-                SyntaxKind::Nothing => ::core::option::Option::None,
-                SyntaxKind::Notify => ::core::option::Option::None,
-                SyntaxKind::Notnull => ::core::option::Option::None,
-                SyntaxKind::Nowait => ::core::option::Option::None,
-                SyntaxKind::NullP => ::core::option::Option::None,
-                SyntaxKind::Nullif => ::core::option::Option::None,
-                SyntaxKind::NullsP => ::core::option::Option::None,
-                SyntaxKind::Numeric => ::core::option::Option::None,
-                SyntaxKind::ObjectP => ::core::option::Option::None,
-                SyntaxKind::Of => ::core::option::Option::None,
-                SyntaxKind::Off => ::core::option::Option::None,
-                SyntaxKind::Offset => ::core::option::Option::None,
-                SyntaxKind::Oids => ::core::option::Option::None,
-                SyntaxKind::Old => ::core::option::Option::None,
-                SyntaxKind::On => ::core::option::Option::None,
-                SyntaxKind::Only => ::core::option::Option::None,
-                SyntaxKind::Operator => ::core::option::Option::None,
-                SyntaxKind::Option => ::core::option::Option::None,
-                SyntaxKind::Options => ::core::option::Option::None,
-                SyntaxKind::Or => ::core::option::Option::None,
-                SyntaxKind::Order => ::core::option::Option::None,
-                SyntaxKind::Ordinality => ::core::option::Option::None,
-                SyntaxKind::Others => ::core::option::Option::None,
-                SyntaxKind::OutP => ::core::option::Option::None,
-                SyntaxKind::OuterP => ::core::option::Option::None,
-                SyntaxKind::Over => ::core::option::Option::None,
-                SyntaxKind::Overlaps => ::core::option::Option::None,
-                SyntaxKind::Overlay => ::core::option::Option::None,
-                SyntaxKind::Overriding => ::core::option::Option::None,
-                SyntaxKind::Owned => ::core::option::Option::None,
-                SyntaxKind::Owner => ::core::option::Option::None,
-                SyntaxKind::Parallel => ::core::option::Option::None,
-                SyntaxKind::Parameter => ::core::option::Option::None,
-                SyntaxKind::Parser => ::core::option::Option::None,
-                SyntaxKind::Partial => ::core::option::Option::None,
-                SyntaxKind::Partition => ::core::option::Option::None,
-                SyntaxKind::Passing => ::core::option::Option::None,
-                SyntaxKind::Password => ::core::option::Option::None,
-                SyntaxKind::Placing => ::core::option::Option::None,
-                SyntaxKind::Plans => ::core::option::Option::None,
-                SyntaxKind::Policy => ::core::option::Option::None,
-                SyntaxKind::Position => ::core::option::Option::None,
-                SyntaxKind::Preceding => ::core::option::Option::None,
-                SyntaxKind::Precision => ::core::option::Option::None,
-                SyntaxKind::Preserve => ::core::option::Option::None,
-                SyntaxKind::Prepare => ::core::option::Option::None,
-                SyntaxKind::Prepared => ::core::option::Option::None,
-                SyntaxKind::Primary => ::core::option::Option::None,
-                SyntaxKind::Prior => ::core::option::Option::None,
-                SyntaxKind::Privileges => ::core::option::Option::None,
-                SyntaxKind::Procedural => ::core::option::Option::None,
-                SyntaxKind::Procedure => ::core::option::Option::None,
-                SyntaxKind::Procedures => ::core::option::Option::None,
-                SyntaxKind::Program => ::core::option::Option::None,
-                SyntaxKind::Publication => ::core::option::Option::None,
-                SyntaxKind::Quote => ::core::option::Option::None,
-                SyntaxKind::Range => ::core::option::Option::None,
-                SyntaxKind::Read => ::core::option::Option::None,
-                SyntaxKind::Real => ::core::option::Option::None,
-                SyntaxKind::Reassign => ::core::option::Option::None,
-                SyntaxKind::Recheck => ::core::option::Option::None,
-                SyntaxKind::Recursive => ::core::option::Option::None,
-                SyntaxKind::RefP => ::core::option::Option::None,
-                SyntaxKind::References => ::core::option::Option::None,
-                SyntaxKind::Referencing => ::core::option::Option::None,
-                SyntaxKind::Refresh => ::core::option::Option::None,
-                SyntaxKind::Reindex => ::core::option::Option::None,
-                SyntaxKind::RelativeP => ::core::option::Option::None,
-                SyntaxKind::Release => ::core::option::Option::None,
-                SyntaxKind::Rename => ::core::option::Option::None,
-                SyntaxKind::Repeatable => ::core::option::Option::None,
-                SyntaxKind::Replace => ::core::option::Option::None,
-                SyntaxKind::Replica => ::core::option::Option::None,
-                SyntaxKind::Reset => ::core::option::Option::None,
-                SyntaxKind::Restart => ::core::option::Option::None,
-                SyntaxKind::Restrict => ::core::option::Option::None,
-                SyntaxKind::Return => ::core::option::Option::None,
-                SyntaxKind::Returning => ::core::option::Option::None,
-                SyntaxKind::Returns => ::core::option::Option::None,
-                SyntaxKind::Revoke => ::core::option::Option::None,
-                SyntaxKind::Right => ::core::option::Option::None,
-                SyntaxKind::Role => ::core::option::Option::None,
-                SyntaxKind::Rollback => ::core::option::Option::None,
-                SyntaxKind::Rollup => ::core::option::Option::None,
-                SyntaxKind::Routine => ::core::option::Option::None,
-                SyntaxKind::Routines => ::core::option::Option::None,
-                SyntaxKind::Row => ::core::option::Option::None,
-                SyntaxKind::Rows => ::core::option::Option::None,
-                SyntaxKind::Rule => ::core::option::Option::None,
-                SyntaxKind::Savepoint => ::core::option::Option::None,
-                SyntaxKind::Schema => ::core::option::Option::None,
-                SyntaxKind::Schemas => ::core::option::Option::None,
-                SyntaxKind::Scroll => ::core::option::Option::None,
-                SyntaxKind::Search => ::core::option::Option::None,
-                SyntaxKind::SecondP => ::core::option::Option::None,
-                SyntaxKind::Security => ::core::option::Option::None,
-                SyntaxKind::Select => ::core::option::Option::None,
-                SyntaxKind::Sequence => ::core::option::Option::None,
-                SyntaxKind::Sequences => ::core::option::Option::None,
-                SyntaxKind::Serializable => ::core::option::Option::None,
-                SyntaxKind::Server => ::core::option::Option::None,
-                SyntaxKind::Session => ::core::option::Option::None,
-                SyntaxKind::SessionUser => ::core::option::Option::None,
-                SyntaxKind::Set => ::core::option::Option::None,
-                SyntaxKind::Sets => ::core::option::Option::None,
-                SyntaxKind::Setof => ::core::option::Option::None,
-                SyntaxKind::Share => ::core::option::Option::None,
-                SyntaxKind::Show => ::core::option::Option::None,
-                SyntaxKind::Similar => ::core::option::Option::None,
-                SyntaxKind::Simple => ::core::option::Option::None,
-                SyntaxKind::Skip => ::core::option::Option::None,
-                SyntaxKind::Smallint => ::core::option::Option::None,
-                SyntaxKind::Snapshot => ::core::option::Option::None,
-                SyntaxKind::Some => ::core::option::Option::None,
-                SyntaxKind::SqlP => ::core::option::Option::None,
-                SyntaxKind::Stable => ::core::option::Option::None,
-                SyntaxKind::StandaloneP => ::core::option::Option::None,
-                SyntaxKind::Start => ::core::option::Option::None,
-                SyntaxKind::Statement => ::core::option::Option::None,
-                SyntaxKind::Statistics => ::core::option::Option::None,
-                SyntaxKind::Stdin => ::core::option::Option::None,
-                SyntaxKind::Stdout => ::core::option::Option::None,
-                SyntaxKind::Storage => ::core::option::Option::None,
-                SyntaxKind::Stored => ::core::option::Option::None,
-                SyntaxKind::StrictP => ::core::option::Option::None,
-                SyntaxKind::StripP => ::core::option::Option::None,
-                SyntaxKind::Subscription => ::core::option::Option::None,
-                SyntaxKind::Substring => ::core::option::Option::None,
-                SyntaxKind::Support => ::core::option::Option::None,
-                SyntaxKind::Symmetric => ::core::option::Option::None,
-                SyntaxKind::Sysid => ::core::option::Option::None,
-                SyntaxKind::SystemP => ::core::option::Option::None,
-                SyntaxKind::Table => ::core::option::Option::None,
-                SyntaxKind::Tables => ::core::option::Option::None,
-                SyntaxKind::Tablesample => ::core::option::Option::None,
-                SyntaxKind::Tablespace => ::core::option::Option::None,
-                SyntaxKind::Temp => ::core::option::Option::None,
-                SyntaxKind::Template => ::core::option::Option::None,
-                SyntaxKind::Temporary => ::core::option::Option::None,
-                SyntaxKind::TextP => ::core::option::Option::None,
-                SyntaxKind::Then => ::core::option::Option::None,
-                SyntaxKind::Ties => ::core::option::Option::None,
-                SyntaxKind::Time => ::core::option::Option::None,
-                SyntaxKind::Timestamp => ::core::option::Option::None,
-                SyntaxKind::To => ::core::option::Option::None,
-                SyntaxKind::Trailing => ::core::option::Option::None,
-                SyntaxKind::Transaction => ::core::option::Option::None,
-                SyntaxKind::Transform => ::core::option::Option::None,
-                SyntaxKind::Treat => ::core::option::Option::None,
-                SyntaxKind::Trigger => ::core::option::Option::None,
-                SyntaxKind::Trim => ::core::option::Option::None,
-                SyntaxKind::TrueP => ::core::option::Option::None,
-                SyntaxKind::Truncate => ::core::option::Option::None,
-                SyntaxKind::Trusted => ::core::option::Option::None,
-                SyntaxKind::TypeP => ::core::option::Option::None,
-                SyntaxKind::TypesP => ::core::option::Option::None,
-                SyntaxKind::Uescape => ::core::option::Option::None,
-                SyntaxKind::Unbounded => ::core::option::Option::None,
-                SyntaxKind::Uncommitted => ::core::option::Option::None,
-                SyntaxKind::Unencrypted => ::core::option::Option::None,
-                SyntaxKind::Union => ::core::option::Option::None,
-                SyntaxKind::Unique => ::core::option::Option::None,
-                SyntaxKind::Unknown => ::core::option::Option::None,
-                SyntaxKind::Unlisten => ::core::option::Option::None,
-                SyntaxKind::Unlogged => ::core::option::Option::None,
-                SyntaxKind::Until => ::core::option::Option::None,
-                SyntaxKind::Update => ::core::option::Option::None,
-                SyntaxKind::User => ::core::option::Option::None,
-                SyntaxKind::Using => ::core::option::Option::None,
-                SyntaxKind::Vacuum => ::core::option::Option::None,
-                SyntaxKind::Valid => ::core::option::Option::None,
-                SyntaxKind::Validate => ::core::option::Option::None,
-                SyntaxKind::Validator => ::core::option::Option::None,
-                SyntaxKind::ValueP => ::core::option::Option::None,
-                SyntaxKind::Values => ::core::option::Option::None,
-                SyntaxKind::Varchar => ::core::option::Option::None,
-                SyntaxKind::Variadic => ::core::option::Option::None,
-                SyntaxKind::Varying => ::core::option::Option::None,
-                SyntaxKind::Verbose => ::core::option::Option::None,
-                SyntaxKind::VersionP => ::core::option::Option::None,
-                SyntaxKind::View => ::core::option::Option::None,
-                SyntaxKind::Views => ::core::option::Option::None,
-                SyntaxKind::Volatile => ::core::option::Option::None,
-                SyntaxKind::When => ::core::option::Option::None,
-                SyntaxKind::Where => ::core::option::Option::None,
-                SyntaxKind::WhitespaceP => ::core::option::Option::None,
-                SyntaxKind::Window => ::core::option::Option::None,
-                SyntaxKind::With => ::core::option::Option::None,
-                SyntaxKind::Within => ::core::option::Option::None,
-                SyntaxKind::Without => ::core::option::Option::None,
-                SyntaxKind::Work => ::core::option::Option::None,
-                SyntaxKind::Wrapper => ::core::option::Option::None,
-                SyntaxKind::Write => ::core::option::Option::None,
-                SyntaxKind::XmlP => ::core::option::Option::None,
-                SyntaxKind::Xmlattributes => ::core::option::Option::None,
-                SyntaxKind::Xmlconcat => ::core::option::Option::None,
-                SyntaxKind::Xmlelement => ::core::option::Option::None,
-                SyntaxKind::Xmlexists => ::core::option::Option::None,
-                SyntaxKind::Xmlforest => ::core::option::Option::None,
-                SyntaxKind::Xmlnamespaces => ::core::option::Option::None,
-                SyntaxKind::Xmlparse => ::core::option::Option::None,
-                SyntaxKind::Xmlpi => ::core::option::Option::None,
-                SyntaxKind::Xmlroot => ::core::option::Option::None,
-                SyntaxKind::Xmlserialize => ::core::option::Option::None,
-                SyntaxKind::Xmltable => ::core::option::Option::None,
-                SyntaxKind::YearP => ::core::option::Option::None,
-                SyntaxKind::YesP => ::core::option::Option::None,
-                SyntaxKind::Zone => ::core::option::Option::None,
-                SyntaxKind::NotLa => ::core::option::Option::None,
-                SyntaxKind::NullsLa => ::core::option::Option::None,
-                SyntaxKind::WithLa => ::core::option::Option::None,
-                SyntaxKind::ModeTypeName => ::core::option::Option::None,
-                SyntaxKind::ModePlpgsqlExpr => ::core::option::Option::None,
-                SyntaxKind::ModePlpgsqlAssign1 => ::core::option::Option::None,
-                SyntaxKind::ModePlpgsqlAssign2 => ::core::option::Option::None,
-                SyntaxKind::ModePlpgsqlAssign3 => ::core::option::Option::None,
-                SyntaxKind::Uminus => ::core::option::Option::None,
-            }
-        }
-    }
-    impl SyntaxKind {
-        /// Converts a `pg_query` node to a `SyntaxKind`
-        pub fn new_from_pg_query_node(node: &NodeEnum) -> Self {
-            match node {
-                NodeEnum::Alias(_) => SyntaxKind::Alias,
-                NodeEnum::RangeVar(_) => SyntaxKind::RangeVar,
-                NodeEnum::TableFunc(_) => SyntaxKind::TableFunc,
-                NodeEnum::Var(_) => SyntaxKind::Var,
-                NodeEnum::Param(_) => SyntaxKind::Param,
-                NodeEnum::Aggref(_) => SyntaxKind::Aggref,
-                NodeEnum::GroupingFunc(_) => SyntaxKind::GroupingFunc,
-                NodeEnum::WindowFunc(_) => SyntaxKind::WindowFunc,
-                NodeEnum::SubscriptingRef(_) => SyntaxKind::SubscriptingRef,
-                NodeEnum::FuncExpr(_) => SyntaxKind::FuncExpr,
-                NodeEnum::NamedArgExpr(_) => SyntaxKind::NamedArgExpr,
-                NodeEnum::OpExpr(_) => SyntaxKind::OpExpr,
-                NodeEnum::DistinctExpr(_) => SyntaxKind::DistinctExpr,
-                NodeEnum::NullIfExpr(_) => SyntaxKind::NullIfExpr,
-                NodeEnum::ScalarArrayOpExpr(_) => SyntaxKind::ScalarArrayOpExpr,
-                NodeEnum::BoolExpr(_) => SyntaxKind::BoolExpr,
-                NodeEnum::SubLink(_) => SyntaxKind::SubLink,
-                NodeEnum::SubPlan(_) => SyntaxKind::SubPlan,
-                NodeEnum::AlternativeSubPlan(_) => SyntaxKind::AlternativeSubPlan,
-                NodeEnum::FieldSelect(_) => SyntaxKind::FieldSelect,
-                NodeEnum::FieldStore(_) => SyntaxKind::FieldStore,
-                NodeEnum::RelabelType(_) => SyntaxKind::RelabelType,
-                NodeEnum::CoerceViaIo(_) => SyntaxKind::CoerceViaIo,
-                NodeEnum::ArrayCoerceExpr(_) => SyntaxKind::ArrayCoerceExpr,
-                NodeEnum::ConvertRowtypeExpr(_) => SyntaxKind::ConvertRowtypeExpr,
-                NodeEnum::CollateExpr(_) => SyntaxKind::CollateExpr,
-                NodeEnum::CaseExpr(_) => SyntaxKind::CaseExpr,
-                NodeEnum::CaseWhen(_) => SyntaxKind::CaseWhen,
-                NodeEnum::CaseTestExpr(_) => SyntaxKind::CaseTestExpr,
-                NodeEnum::ArrayExpr(_) => SyntaxKind::ArrayExpr,
-                NodeEnum::RowExpr(_) => SyntaxKind::RowExpr,
-                NodeEnum::RowCompareExpr(_) => SyntaxKind::RowCompareExpr,
-                NodeEnum::CoalesceExpr(_) => SyntaxKind::CoalesceExpr,
-                NodeEnum::MinMaxExpr(_) => SyntaxKind::MinMaxExpr,
-                NodeEnum::SqlvalueFunction(_) => SyntaxKind::SqlvalueFunction,
-                NodeEnum::XmlExpr(_) => SyntaxKind::XmlExpr,
-                NodeEnum::NullTest(_) => SyntaxKind::NullTest,
-                NodeEnum::BooleanTest(_) => SyntaxKind::BooleanTest,
-                NodeEnum::CoerceToDomain(_) => SyntaxKind::CoerceToDomain,
-                NodeEnum::CoerceToDomainValue(_) => SyntaxKind::CoerceToDomainValue,
-                NodeEnum::SetToDefault(_) => SyntaxKind::SetToDefault,
-                NodeEnum::CurrentOfExpr(_) => SyntaxKind::CurrentOfExpr,
-                NodeEnum::NextValueExpr(_) => SyntaxKind::NextValueExpr,
-                NodeEnum::InferenceElem(_) => SyntaxKind::InferenceElem,
-                NodeEnum::TargetEntry(_) => SyntaxKind::TargetEntry,
-                NodeEnum::RangeTblRef(_) => SyntaxKind::RangeTblRef,
-                NodeEnum::JoinExpr(_) => SyntaxKind::JoinExpr,
-                NodeEnum::FromExpr(_) => SyntaxKind::FromExpr,
-                NodeEnum::OnConflictExpr(_) => SyntaxKind::OnConflictExpr,
-                NodeEnum::IntoClause(_) => SyntaxKind::IntoClause,
-                NodeEnum::MergeAction(_) => SyntaxKind::MergeAction,
-                NodeEnum::RawStmt(_) => SyntaxKind::RawStmt,
-                NodeEnum::Query(_) => SyntaxKind::Query,
-                NodeEnum::InsertStmt(_) => SyntaxKind::InsertStmt,
-                NodeEnum::DeleteStmt(_) => SyntaxKind::DeleteStmt,
-                NodeEnum::UpdateStmt(_) => SyntaxKind::UpdateStmt,
-                NodeEnum::MergeStmt(_) => SyntaxKind::MergeStmt,
-                NodeEnum::SelectStmt(_) => SyntaxKind::SelectStmt,
-                NodeEnum::ReturnStmt(_) => SyntaxKind::ReturnStmt,
-                NodeEnum::PlassignStmt(_) => SyntaxKind::PlassignStmt,
-                NodeEnum::AlterTableStmt(_) => SyntaxKind::AlterTableStmt,
-                NodeEnum::AlterTableCmd(_) => SyntaxKind::AlterTableCmd,
-                NodeEnum::AlterDomainStmt(_) => SyntaxKind::AlterDomainStmt,
-                NodeEnum::SetOperationStmt(_) => SyntaxKind::SetOperationStmt,
-                NodeEnum::GrantStmt(_) => SyntaxKind::GrantStmt,
-                NodeEnum::GrantRoleStmt(_) => SyntaxKind::GrantRoleStmt,
-                NodeEnum::AlterDefaultPrivilegesStmt(_) => {
-                    SyntaxKind::AlterDefaultPrivilegesStmt
-                }
-                NodeEnum::ClosePortalStmt(_) => SyntaxKind::ClosePortalStmt,
-                NodeEnum::ClusterStmt(_) => SyntaxKind::ClusterStmt,
-                NodeEnum::CopyStmt(_) => SyntaxKind::CopyStmt,
-                NodeEnum::CreateStmt(_) => SyntaxKind::CreateStmt,
-                NodeEnum::DefineStmt(_) => SyntaxKind::DefineStmt,
-                NodeEnum::DropStmt(_) => SyntaxKind::DropStmt,
-                NodeEnum::TruncateStmt(_) => SyntaxKind::TruncateStmt,
-                NodeEnum::CommentStmt(_) => SyntaxKind::CommentStmt,
-                NodeEnum::FetchStmt(_) => SyntaxKind::FetchStmt,
-                NodeEnum::IndexStmt(_) => SyntaxKind::IndexStmt,
-                NodeEnum::CreateFunctionStmt(_) => SyntaxKind::CreateFunctionStmt,
-                NodeEnum::AlterFunctionStmt(_) => SyntaxKind::AlterFunctionStmt,
-                NodeEnum::DoStmt(_) => SyntaxKind::DoStmt,
-                NodeEnum::RenameStmt(_) => SyntaxKind::RenameStmt,
-                NodeEnum::RuleStmt(_) => SyntaxKind::RuleStmt,
-                NodeEnum::NotifyStmt(_) => SyntaxKind::NotifyStmt,
-                NodeEnum::ListenStmt(_) => SyntaxKind::ListenStmt,
-                NodeEnum::UnlistenStmt(_) => SyntaxKind::UnlistenStmt,
-                NodeEnum::TransactionStmt(_) => SyntaxKind::TransactionStmt,
-                NodeEnum::ViewStmt(_) => SyntaxKind::ViewStmt,
-                NodeEnum::LoadStmt(_) => SyntaxKind::LoadStmt,
-                NodeEnum::CreateDomainStmt(_) => SyntaxKind::CreateDomainStmt,
-                NodeEnum::CreatedbStmt(_) => SyntaxKind::CreatedbStmt,
-                NodeEnum::DropdbStmt(_) => SyntaxKind::DropdbStmt,
-                NodeEnum::VacuumStmt(_) => SyntaxKind::VacuumStmt,
-                NodeEnum::ExplainStmt(_) => SyntaxKind::ExplainStmt,
-                NodeEnum::CreateTableAsStmt(_) => SyntaxKind::CreateTableAsStmt,
-                NodeEnum::CreateSeqStmt(_) => SyntaxKind::CreateSeqStmt,
-                NodeEnum::AlterSeqStmt(_) => SyntaxKind::AlterSeqStmt,
-                NodeEnum::VariableSetStmt(_) => SyntaxKind::VariableSetStmt,
-                NodeEnum::VariableShowStmt(_) => SyntaxKind::VariableShowStmt,
-                NodeEnum::DiscardStmt(_) => SyntaxKind::DiscardStmt,
-                NodeEnum::CreateTrigStmt(_) => SyntaxKind::CreateTrigStmt,
-                NodeEnum::CreatePlangStmt(_) => SyntaxKind::CreatePlangStmt,
-                NodeEnum::CreateRoleStmt(_) => SyntaxKind::CreateRoleStmt,
-                NodeEnum::AlterRoleStmt(_) => SyntaxKind::AlterRoleStmt,
-                NodeEnum::DropRoleStmt(_) => SyntaxKind::DropRoleStmt,
-                NodeEnum::LockStmt(_) => SyntaxKind::LockStmt,
-                NodeEnum::ConstraintsSetStmt(_) => SyntaxKind::ConstraintsSetStmt,
-                NodeEnum::ReindexStmt(_) => SyntaxKind::ReindexStmt,
-                NodeEnum::CheckPointStmt(_) => SyntaxKind::CheckPointStmt,
-                NodeEnum::CreateSchemaStmt(_) => SyntaxKind::CreateSchemaStmt,
-                NodeEnum::AlterDatabaseStmt(_) => SyntaxKind::AlterDatabaseStmt,
-                NodeEnum::AlterDatabaseRefreshCollStmt(_) => {
-                    SyntaxKind::AlterDatabaseRefreshCollStmt
-                }
-                NodeEnum::AlterDatabaseSetStmt(_) => SyntaxKind::AlterDatabaseSetStmt,
-                NodeEnum::AlterRoleSetStmt(_) => SyntaxKind::AlterRoleSetStmt,
-                NodeEnum::CreateConversionStmt(_) => SyntaxKind::CreateConversionStmt,
-                NodeEnum::CreateCastStmt(_) => SyntaxKind::CreateCastStmt,
-                NodeEnum::CreateOpClassStmt(_) => SyntaxKind::CreateOpClassStmt,
-                NodeEnum::CreateOpFamilyStmt(_) => SyntaxKind::CreateOpFamilyStmt,
-                NodeEnum::AlterOpFamilyStmt(_) => SyntaxKind::AlterOpFamilyStmt,
-                NodeEnum::PrepareStmt(_) => SyntaxKind::PrepareStmt,
-                NodeEnum::ExecuteStmt(_) => SyntaxKind::ExecuteStmt,
-                NodeEnum::DeallocateStmt(_) => SyntaxKind::DeallocateStmt,
-                NodeEnum::DeclareCursorStmt(_) => SyntaxKind::DeclareCursorStmt,
-                NodeEnum::CreateTableSpaceStmt(_) => SyntaxKind::CreateTableSpaceStmt,
-                NodeEnum::DropTableSpaceStmt(_) => SyntaxKind::DropTableSpaceStmt,
-                NodeEnum::AlterObjectDependsStmt(_) => SyntaxKind::AlterObjectDependsStmt,
-                NodeEnum::AlterObjectSchemaStmt(_) => SyntaxKind::AlterObjectSchemaStmt,
-                NodeEnum::AlterOwnerStmt(_) => SyntaxKind::AlterOwnerStmt,
-                NodeEnum::AlterOperatorStmt(_) => SyntaxKind::AlterOperatorStmt,
-                NodeEnum::AlterTypeStmt(_) => SyntaxKind::AlterTypeStmt,
-                NodeEnum::DropOwnedStmt(_) => SyntaxKind::DropOwnedStmt,
-                NodeEnum::ReassignOwnedStmt(_) => SyntaxKind::ReassignOwnedStmt,
-                NodeEnum::CompositeTypeStmt(_) => SyntaxKind::CompositeTypeStmt,
-                NodeEnum::CreateEnumStmt(_) => SyntaxKind::CreateEnumStmt,
-                NodeEnum::CreateRangeStmt(_) => SyntaxKind::CreateRangeStmt,
-                NodeEnum::AlterEnumStmt(_) => SyntaxKind::AlterEnumStmt,
-                NodeEnum::AlterTsdictionaryStmt(_) => SyntaxKind::AlterTsdictionaryStmt,
-                NodeEnum::AlterTsconfigurationStmt(_) => {
-                    SyntaxKind::AlterTsconfigurationStmt
-                }
-                NodeEnum::CreateFdwStmt(_) => SyntaxKind::CreateFdwStmt,
-                NodeEnum::AlterFdwStmt(_) => SyntaxKind::AlterFdwStmt,
-                NodeEnum::CreateForeignServerStmt(_) => {
-                    SyntaxKind::CreateForeignServerStmt
-                }
-                NodeEnum::AlterForeignServerStmt(_) => SyntaxKind::AlterForeignServerStmt,
-                NodeEnum::CreateUserMappingStmt(_) => SyntaxKind::CreateUserMappingStmt,
-                NodeEnum::AlterUserMappingStmt(_) => SyntaxKind::AlterUserMappingStmt,
-                NodeEnum::DropUserMappingStmt(_) => SyntaxKind::DropUserMappingStmt,
-                NodeEnum::AlterTableSpaceOptionsStmt(_) => {
-                    SyntaxKind::AlterTableSpaceOptionsStmt
-                }
-                NodeEnum::AlterTableMoveAllStmt(_) => SyntaxKind::AlterTableMoveAllStmt,
-                NodeEnum::SecLabelStmt(_) => SyntaxKind::SecLabelStmt,
-                NodeEnum::CreateForeignTableStmt(_) => SyntaxKind::CreateForeignTableStmt,
-                NodeEnum::ImportForeignSchemaStmt(_) => {
-                    SyntaxKind::ImportForeignSchemaStmt
-                }
-                NodeEnum::CreateExtensionStmt(_) => SyntaxKind::CreateExtensionStmt,
-                NodeEnum::AlterExtensionStmt(_) => SyntaxKind::AlterExtensionStmt,
-                NodeEnum::AlterExtensionContentsStmt(_) => {
-                    SyntaxKind::AlterExtensionContentsStmt
-                }
-                NodeEnum::CreateEventTrigStmt(_) => SyntaxKind::CreateEventTrigStmt,
-                NodeEnum::AlterEventTrigStmt(_) => SyntaxKind::AlterEventTrigStmt,
-                NodeEnum::RefreshMatViewStmt(_) => SyntaxKind::RefreshMatViewStmt,
-                NodeEnum::ReplicaIdentityStmt(_) => SyntaxKind::ReplicaIdentityStmt,
-                NodeEnum::AlterSystemStmt(_) => SyntaxKind::AlterSystemStmt,
-                NodeEnum::CreatePolicyStmt(_) => SyntaxKind::CreatePolicyStmt,
-                NodeEnum::AlterPolicyStmt(_) => SyntaxKind::AlterPolicyStmt,
-                NodeEnum::CreateTransformStmt(_) => SyntaxKind::CreateTransformStmt,
-                NodeEnum::CreateAmStmt(_) => SyntaxKind::CreateAmStmt,
-                NodeEnum::CreatePublicationStmt(_) => SyntaxKind::CreatePublicationStmt,
-                NodeEnum::AlterPublicationStmt(_) => SyntaxKind::AlterPublicationStmt,
-                NodeEnum::CreateSubscriptionStmt(_) => SyntaxKind::CreateSubscriptionStmt,
-                NodeEnum::AlterSubscriptionStmt(_) => SyntaxKind::AlterSubscriptionStmt,
-                NodeEnum::DropSubscriptionStmt(_) => SyntaxKind::DropSubscriptionStmt,
-                NodeEnum::CreateStatsStmt(_) => SyntaxKind::CreateStatsStmt,
-                NodeEnum::AlterCollationStmt(_) => SyntaxKind::AlterCollationStmt,
-                NodeEnum::CallStmt(_) => SyntaxKind::CallStmt,
-                NodeEnum::AlterStatsStmt(_) => SyntaxKind::AlterStatsStmt,
-                NodeEnum::AExpr(_) => SyntaxKind::AExpr,
-                NodeEnum::ColumnRef(_) => SyntaxKind::ColumnRef,
-                NodeEnum::ParamRef(_) => SyntaxKind::ParamRef,
-                NodeEnum::FuncCall(_) => SyntaxKind::FuncCall,
-                NodeEnum::AStar(_) => SyntaxKind::AStar,
-                NodeEnum::AIndices(_) => SyntaxKind::AIndices,
-                NodeEnum::AIndirection(_) => SyntaxKind::AIndirection,
-                NodeEnum::AArrayExpr(_) => SyntaxKind::AArrayExpr,
-                NodeEnum::ResTarget(_) => SyntaxKind::ResTarget,
-                NodeEnum::MultiAssignRef(_) => SyntaxKind::MultiAssignRef,
-                NodeEnum::TypeCast(_) => SyntaxKind::TypeCast,
-                NodeEnum::CollateClause(_) => SyntaxKind::CollateClause,
-                NodeEnum::SortBy(_) => SyntaxKind::SortBy,
-                NodeEnum::WindowDef(_) => SyntaxKind::WindowDef,
-                NodeEnum::RangeSubselect(_) => SyntaxKind::RangeSubselect,
-                NodeEnum::RangeFunction(_) => SyntaxKind::RangeFunction,
-                NodeEnum::RangeTableSample(_) => SyntaxKind::RangeTableSample,
-                NodeEnum::RangeTableFunc(_) => SyntaxKind::RangeTableFunc,
-                NodeEnum::RangeTableFuncCol(_) => SyntaxKind::RangeTableFuncCol,
-                NodeEnum::TypeName(_) => SyntaxKind::TypeName,
-                NodeEnum::ColumnDef(_) => SyntaxKind::ColumnDef,
-                NodeEnum::IndexElem(_) => SyntaxKind::IndexElem,
-                NodeEnum::StatsElem(_) => SyntaxKind::StatsElem,
-                NodeEnum::Constraint(_) => SyntaxKind::Constraint,
-                NodeEnum::DefElem(_) => SyntaxKind::DefElem,
-                NodeEnum::RangeTblEntry(_) => SyntaxKind::RangeTblEntry,
-                NodeEnum::RangeTblFunction(_) => SyntaxKind::RangeTblFunction,
-                NodeEnum::TableSampleClause(_) => SyntaxKind::TableSampleClause,
-                NodeEnum::WithCheckOption(_) => SyntaxKind::WithCheckOption,
-                NodeEnum::SortGroupClause(_) => SyntaxKind::SortGroupClause,
-                NodeEnum::GroupingSet(_) => SyntaxKind::GroupingSet,
-                NodeEnum::WindowClause(_) => SyntaxKind::WindowClause,
-                NodeEnum::ObjectWithArgs(_) => SyntaxKind::ObjectWithArgs,
-                NodeEnum::AccessPriv(_) => SyntaxKind::AccessPriv,
-                NodeEnum::CreateOpClassItem(_) => SyntaxKind::CreateOpClassItem,
-                NodeEnum::TableLikeClause(_) => SyntaxKind::TableLikeClause,
-                NodeEnum::FunctionParameter(_) => SyntaxKind::FunctionParameter,
-                NodeEnum::LockingClause(_) => SyntaxKind::LockingClause,
-                NodeEnum::RowMarkClause(_) => SyntaxKind::RowMarkClause,
-                NodeEnum::XmlSerialize(_) => SyntaxKind::XmlSerialize,
-                NodeEnum::WithClause(_) => SyntaxKind::WithClause,
-                NodeEnum::InferClause(_) => SyntaxKind::InferClause,
-                NodeEnum::OnConflictClause(_) => SyntaxKind::OnConflictClause,
-                NodeEnum::CtesearchClause(_) => SyntaxKind::CtesearchClause,
-                NodeEnum::CtecycleClause(_) => SyntaxKind::CtecycleClause,
-                NodeEnum::CommonTableExpr(_) => SyntaxKind::CommonTableExpr,
-                NodeEnum::MergeWhenClause(_) => SyntaxKind::MergeWhenClause,
-                NodeEnum::RoleSpec(_) => SyntaxKind::RoleSpec,
-                NodeEnum::TriggerTransition(_) => SyntaxKind::TriggerTransition,
-                NodeEnum::PartitionElem(_) => SyntaxKind::PartitionElem,
-                NodeEnum::PartitionSpec(_) => SyntaxKind::PartitionSpec,
-                NodeEnum::PartitionBoundSpec(_) => SyntaxKind::PartitionBoundSpec,
-                NodeEnum::PartitionRangeDatum(_) => SyntaxKind::PartitionRangeDatum,
-                NodeEnum::PartitionCmd(_) => SyntaxKind::PartitionCmd,
-                NodeEnum::VacuumRelation(_) => SyntaxKind::VacuumRelation,
-                NodeEnum::PublicationObjSpec(_) => SyntaxKind::PublicationObjSpec,
-                NodeEnum::PublicationTable(_) => SyntaxKind::PublicationTable,
-                NodeEnum::InlineCodeBlock(_) => SyntaxKind::InlineCodeBlock,
-                NodeEnum::CallContext(_) => SyntaxKind::CallContext,
-                NodeEnum::Integer(_) => SyntaxKind::Integer,
-                NodeEnum::Float(_) => SyntaxKind::Float,
-                NodeEnum::Boolean(_) => SyntaxKind::Boolean,
-                NodeEnum::String(_) => SyntaxKind::String,
-                NodeEnum::BitString(_) => SyntaxKind::BitString,
-                NodeEnum::List(_) => SyntaxKind::List,
-                NodeEnum::IntList(_) => SyntaxKind::IntList,
-                NodeEnum::OidList(_) => SyntaxKind::OidList,
-                NodeEnum::AConst(_) => SyntaxKind::AConst,
-            }
-        }
-        /// Converts a `pg_query` token to a `SyntaxKind`
-        pub fn new_from_pg_query_token(token: &ScanToken) -> Self {
-            match token.token {
-                0 => SyntaxKind::Nul,
-                37 => SyntaxKind::Ascii37,
-                40 => SyntaxKind::Ascii40,
-                41 => SyntaxKind::Ascii41,
-                42 => SyntaxKind::Ascii42,
-                43 => SyntaxKind::Ascii43,
-                44 => SyntaxKind::Ascii44,
-                45 => SyntaxKind::Ascii45,
-                46 => SyntaxKind::Ascii46,
-                47 => SyntaxKind::Ascii47,
-                58 => SyntaxKind::Ascii58,
-                59 => SyntaxKind::Ascii59,
-                60 => SyntaxKind::Ascii60,
-                61 => SyntaxKind::Ascii61,
-                62 => SyntaxKind::Ascii62,
-                63 => SyntaxKind::Ascii63,
-                91 => SyntaxKind::Ascii91,
-                92 => SyntaxKind::Ascii92,
-                93 => SyntaxKind::Ascii93,
-                94 => SyntaxKind::Ascii94,
-                258 => SyntaxKind::Ident,
-                259 => SyntaxKind::Uident,
-                260 => SyntaxKind::Fconst,
-                261 => SyntaxKind::Sconst,
-                262 => SyntaxKind::Usconst,
-                263 => SyntaxKind::Bconst,
-                264 => SyntaxKind::Xconst,
-                265 => SyntaxKind::Op,
-                266 => SyntaxKind::Iconst,
-                268 => SyntaxKind::Typecast,
-                269 => SyntaxKind::DotDot,
-                270 => SyntaxKind::ColonEquals,
-                271 => SyntaxKind::EqualsGreater,
-                272 => SyntaxKind::LessEquals,
-                273 => SyntaxKind::GreaterEquals,
-                274 => SyntaxKind::NotEquals,
-                275 => SyntaxKind::SqlComment,
-                276 => SyntaxKind::CComment,
-                277 => SyntaxKind::AbortP,
-                278 => SyntaxKind::AbsoluteP,
-                279 => SyntaxKind::Access,
-                280 => SyntaxKind::Action,
-                281 => SyntaxKind::AddP,
-                282 => SyntaxKind::Admin,
-                283 => SyntaxKind::After,
-                284 => SyntaxKind::Aggregate,
-                285 => SyntaxKind::All,
-                286 => SyntaxKind::Also,
-                287 => SyntaxKind::Alter,
-                288 => SyntaxKind::Always,
-                289 => SyntaxKind::Analyse,
-                290 => SyntaxKind::Analyze,
-                291 => SyntaxKind::And,
-                292 => SyntaxKind::Any,
-                293 => SyntaxKind::Array,
-                294 => SyntaxKind::As,
-                295 => SyntaxKind::Asc,
-                296 => SyntaxKind::Asensitive,
-                297 => SyntaxKind::Assertion,
-                298 => SyntaxKind::Assignment,
-                299 => SyntaxKind::Asymmetric,
-                300 => SyntaxKind::Atomic,
-                301 => SyntaxKind::At,
-                302 => SyntaxKind::Attach,
-                303 => SyntaxKind::Attribute,
-                304 => SyntaxKind::Authorization,
-                305 => SyntaxKind::Backward,
-                306 => SyntaxKind::Before,
-                307 => SyntaxKind::BeginP,
-                308 => SyntaxKind::Between,
-                309 => SyntaxKind::Bigint,
-                310 => SyntaxKind::Binary,
-                311 => SyntaxKind::Bit,
-                312 => SyntaxKind::BooleanP,
-                313 => SyntaxKind::Both,
-                314 => SyntaxKind::Breadth,
-                315 => SyntaxKind::By,
-                316 => SyntaxKind::Cache,
-                317 => SyntaxKind::Call,
-                318 => SyntaxKind::Called,
-                319 => SyntaxKind::Cascade,
-                320 => SyntaxKind::Cascaded,
-                321 => SyntaxKind::Case,
-                322 => SyntaxKind::Cast,
-                323 => SyntaxKind::CatalogP,
-                324 => SyntaxKind::Chain,
-                325 => SyntaxKind::CharP,
-                326 => SyntaxKind::Character,
-                327 => SyntaxKind::Characteristics,
-                328 => SyntaxKind::Check,
-                329 => SyntaxKind::Checkpoint,
-                330 => SyntaxKind::Class,
-                331 => SyntaxKind::Close,
-                332 => SyntaxKind::Cluster,
-                333 => SyntaxKind::Coalesce,
-                334 => SyntaxKind::Collate,
-                335 => SyntaxKind::Collation,
-                336 => SyntaxKind::Column,
-                337 => SyntaxKind::Columns,
-                339 => SyntaxKind::Comments,
-                340 => SyntaxKind::Commit,
-                341 => SyntaxKind::Committed,
-                342 => SyntaxKind::Compression,
-                343 => SyntaxKind::Concurrently,
-                344 => SyntaxKind::Configuration,
-                345 => SyntaxKind::Conflict,
-                346 => SyntaxKind::Connection,
-                348 => SyntaxKind::Constraints,
-                349 => SyntaxKind::ContentP,
-                350 => SyntaxKind::ContinueP,
-                351 => SyntaxKind::ConversionP,
-                352 => SyntaxKind::Copy,
-                353 => SyntaxKind::Cost,
-                354 => SyntaxKind::Create,
-                355 => SyntaxKind::Cross,
-                356 => SyntaxKind::Csv,
-                357 => SyntaxKind::Cube,
-                358 => SyntaxKind::CurrentP,
-                359 => SyntaxKind::CurrentCatalog,
-                360 => SyntaxKind::CurrentDate,
-                361 => SyntaxKind::CurrentRole,
-                362 => SyntaxKind::CurrentSchema,
-                363 => SyntaxKind::CurrentTime,
-                364 => SyntaxKind::CurrentTimestamp,
-                365 => SyntaxKind::CurrentUser,
-                366 => SyntaxKind::Cursor,
-                367 => SyntaxKind::Cycle,
-                368 => SyntaxKind::DataP,
-                369 => SyntaxKind::Database,
-                370 => SyntaxKind::DayP,
-                371 => SyntaxKind::Deallocate,
-                372 => SyntaxKind::Dec,
-                373 => SyntaxKind::DecimalP,
-                374 => SyntaxKind::Declare,
-                375 => SyntaxKind::Default,
-                376 => SyntaxKind::Defaults,
-                377 => SyntaxKind::Deferrable,
-                378 => SyntaxKind::Deferred,
-                379 => SyntaxKind::Definer,
-                380 => SyntaxKind::DeleteP,
-                381 => SyntaxKind::Delimiter,
-                382 => SyntaxKind::Delimiters,
-                383 => SyntaxKind::Depends,
-                384 => SyntaxKind::Depth,
-                385 => SyntaxKind::Desc,
-                386 => SyntaxKind::Detach,
-                387 => SyntaxKind::Dictionary,
-                388 => SyntaxKind::DisableP,
-                389 => SyntaxKind::Discard,
-                390 => SyntaxKind::Distinct,
-                391 => SyntaxKind::Do,
-                392 => SyntaxKind::DocumentP,
-                393 => SyntaxKind::DomainP,
-                394 => SyntaxKind::DoubleP,
-                395 => SyntaxKind::Drop,
-                396 => SyntaxKind::Each,
-                397 => SyntaxKind::Else,
-                398 => SyntaxKind::EnableP,
-                399 => SyntaxKind::Encoding,
-                400 => SyntaxKind::Encrypted,
-                401 => SyntaxKind::EndP,
-                402 => SyntaxKind::EnumP,
-                403 => SyntaxKind::Escape,
-                404 => SyntaxKind::Event,
-                405 => SyntaxKind::Except,
-                406 => SyntaxKind::Exclude,
-                407 => SyntaxKind::Excluding,
-                408 => SyntaxKind::Exclusive,
-                409 => SyntaxKind::Execute,
-                410 => SyntaxKind::Exists,
-                411 => SyntaxKind::Explain,
-                412 => SyntaxKind::Expression,
-                413 => SyntaxKind::Extension,
-                414 => SyntaxKind::External,
-                415 => SyntaxKind::Extract,
-                416 => SyntaxKind::FalseP,
-                417 => SyntaxKind::Family,
-                418 => SyntaxKind::Fetch,
-                419 => SyntaxKind::Filter,
-                420 => SyntaxKind::Finalize,
-                421 => SyntaxKind::FirstP,
-                422 => SyntaxKind::FloatP,
-                423 => SyntaxKind::Following,
-                424 => SyntaxKind::For,
-                425 => SyntaxKind::Force,
-                426 => SyntaxKind::Foreign,
-                427 => SyntaxKind::Forward,
-                428 => SyntaxKind::Freeze,
-                429 => SyntaxKind::From,
-                430 => SyntaxKind::Full,
-                431 => SyntaxKind::Function,
-                432 => SyntaxKind::Functions,
-                433 => SyntaxKind::Generated,
-                434 => SyntaxKind::Global,
-                435 => SyntaxKind::Grant,
-                436 => SyntaxKind::Granted,
-                437 => SyntaxKind::Greatest,
-                438 => SyntaxKind::GroupP,
-                439 => SyntaxKind::Grouping,
-                440 => SyntaxKind::Groups,
-                441 => SyntaxKind::Handler,
-                442 => SyntaxKind::Having,
-                443 => SyntaxKind::HeaderP,
-                444 => SyntaxKind::Hold,
-                445 => SyntaxKind::HourP,
-                446 => SyntaxKind::IdentityP,
-                447 => SyntaxKind::IfP,
-                448 => SyntaxKind::Ilike,
-                449 => SyntaxKind::Immediate,
-                450 => SyntaxKind::Immutable,
-                451 => SyntaxKind::ImplicitP,
-                452 => SyntaxKind::ImportP,
-                453 => SyntaxKind::InP,
-                454 => SyntaxKind::Include,
-                455 => SyntaxKind::Including,
-                456 => SyntaxKind::Increment,
-                457 => SyntaxKind::Index,
-                458 => SyntaxKind::Indexes,
-                459 => SyntaxKind::Inherit,
-                460 => SyntaxKind::Inherits,
-                461 => SyntaxKind::Initially,
-                462 => SyntaxKind::InlineP,
-                463 => SyntaxKind::InnerP,
-                464 => SyntaxKind::Inout,
-                465 => SyntaxKind::InputP,
-                466 => SyntaxKind::Insensitive,
-                467 => SyntaxKind::Insert,
-                468 => SyntaxKind::Instead,
-                469 => SyntaxKind::IntP,
-                471 => SyntaxKind::Intersect,
-                472 => SyntaxKind::Interval,
-                473 => SyntaxKind::Into,
-                474 => SyntaxKind::Invoker,
-                475 => SyntaxKind::Is,
-                476 => SyntaxKind::Isnull,
-                477 => SyntaxKind::Isolation,
-                478 => SyntaxKind::Join,
-                479 => SyntaxKind::Key,
-                480 => SyntaxKind::Label,
-                481 => SyntaxKind::Language,
-                482 => SyntaxKind::LargeP,
-                483 => SyntaxKind::LastP,
-                484 => SyntaxKind::LateralP,
-                485 => SyntaxKind::Leading,
-                486 => SyntaxKind::Leakproof,
-                487 => SyntaxKind::Least,
-                488 => SyntaxKind::Left,
-                489 => SyntaxKind::Level,
-                490 => SyntaxKind::Like,
-                491 => SyntaxKind::Limit,
-                492 => SyntaxKind::Listen,
-                493 => SyntaxKind::Load,
-                494 => SyntaxKind::Local,
-                495 => SyntaxKind::Localtime,
-                496 => SyntaxKind::Localtimestamp,
-                497 => SyntaxKind::Location,
-                498 => SyntaxKind::LockP,
-                499 => SyntaxKind::Locked,
-                500 => SyntaxKind::Logged,
-                501 => SyntaxKind::Mapping,
-                502 => SyntaxKind::Match,
-                503 => SyntaxKind::Matched,
-                504 => SyntaxKind::Materialized,
-                505 => SyntaxKind::Maxvalue,
-                506 => SyntaxKind::Merge,
-                507 => SyntaxKind::Method,
-                508 => SyntaxKind::MinuteP,
-                509 => SyntaxKind::Minvalue,
-                510 => SyntaxKind::Mode,
-                511 => SyntaxKind::MonthP,
-                512 => SyntaxKind::Move,
-                513 => SyntaxKind::NameP,
-                514 => SyntaxKind::Names,
-                515 => SyntaxKind::National,
-                516 => SyntaxKind::Natural,
-                517 => SyntaxKind::Nchar,
-                518 => SyntaxKind::New,
-                519 => SyntaxKind::Next,
-                520 => SyntaxKind::Nfc,
-                521 => SyntaxKind::Nfd,
-                522 => SyntaxKind::Nfkc,
-                523 => SyntaxKind::Nfkd,
-                524 => SyntaxKind::No,
-                525 => SyntaxKind::None,
-                526 => SyntaxKind::Normalize,
-                527 => SyntaxKind::Normalized,
-                528 => SyntaxKind::Not,
-                529 => SyntaxKind::Nothing,
-                530 => SyntaxKind::Notify,
-                531 => SyntaxKind::Notnull,
-                532 => SyntaxKind::Nowait,
-                533 => SyntaxKind::NullP,
-                534 => SyntaxKind::Nullif,
-                535 => SyntaxKind::NullsP,
-                536 => SyntaxKind::Numeric,
-                537 => SyntaxKind::ObjectP,
-                538 => SyntaxKind::Of,
-                539 => SyntaxKind::Off,
-                540 => SyntaxKind::Offset,
-                541 => SyntaxKind::Oids,
-                542 => SyntaxKind::Old,
-                543 => SyntaxKind::On,
-                544 => SyntaxKind::Only,
-                545 => SyntaxKind::Operator,
-                546 => SyntaxKind::Option,
-                547 => SyntaxKind::Options,
-                548 => SyntaxKind::Or,
-                549 => SyntaxKind::Order,
-                550 => SyntaxKind::Ordinality,
-                551 => SyntaxKind::Others,
-                552 => SyntaxKind::OutP,
-                553 => SyntaxKind::OuterP,
-                554 => SyntaxKind::Over,
-                555 => SyntaxKind::Overlaps,
-                556 => SyntaxKind::Overlay,
-                557 => SyntaxKind::Overriding,
-                558 => SyntaxKind::Owned,
-                559 => SyntaxKind::Owner,
-                560 => SyntaxKind::Parallel,
-                561 => SyntaxKind::Parameter,
-                562 => SyntaxKind::Parser,
-                563 => SyntaxKind::Partial,
-                564 => SyntaxKind::Partition,
-                565 => SyntaxKind::Passing,
-                566 => SyntaxKind::Password,
-                567 => SyntaxKind::Placing,
-                568 => SyntaxKind::Plans,
-                569 => SyntaxKind::Policy,
-                570 => SyntaxKind::Position,
-                571 => SyntaxKind::Preceding,
-                572 => SyntaxKind::Precision,
-                573 => SyntaxKind::Preserve,
-                574 => SyntaxKind::Prepare,
-                575 => SyntaxKind::Prepared,
-                576 => SyntaxKind::Primary,
-                577 => SyntaxKind::Prior,
-                578 => SyntaxKind::Privileges,
-                579 => SyntaxKind::Procedural,
-                580 => SyntaxKind::Procedure,
-                581 => SyntaxKind::Procedures,
-                582 => SyntaxKind::Program,
-                583 => SyntaxKind::Publication,
-                584 => SyntaxKind::Quote,
-                585 => SyntaxKind::Range,
-                586 => SyntaxKind::Read,
-                587 => SyntaxKind::Real,
-                588 => SyntaxKind::Reassign,
-                589 => SyntaxKind::Recheck,
-                590 => SyntaxKind::Recursive,
-                591 => SyntaxKind::RefP,
-                592 => SyntaxKind::References,
-                593 => SyntaxKind::Referencing,
-                594 => SyntaxKind::Refresh,
-                595 => SyntaxKind::Reindex,
-                596 => SyntaxKind::RelativeP,
-                597 => SyntaxKind::Release,
-                598 => SyntaxKind::Rename,
-                599 => SyntaxKind::Repeatable,
-                600 => SyntaxKind::Replace,
-                601 => SyntaxKind::Replica,
-                602 => SyntaxKind::Reset,
-                603 => SyntaxKind::Restart,
-                604 => SyntaxKind::Restrict,
-                605 => SyntaxKind::Return,
-                606 => SyntaxKind::Returning,
-                607 => SyntaxKind::Returns,
-                608 => SyntaxKind::Revoke,
-                609 => SyntaxKind::Right,
-                610 => SyntaxKind::Role,
-                611 => SyntaxKind::Rollback,
-                612 => SyntaxKind::Rollup,
-                613 => SyntaxKind::Routine,
-                614 => SyntaxKind::Routines,
-                615 => SyntaxKind::Row,
-                616 => SyntaxKind::Rows,
-                617 => SyntaxKind::Rule,
-                618 => SyntaxKind::Savepoint,
-                619 => SyntaxKind::Schema,
-                620 => SyntaxKind::Schemas,
-                621 => SyntaxKind::Scroll,
-                622 => SyntaxKind::Search,
-                623 => SyntaxKind::SecondP,
-                624 => SyntaxKind::Security,
-                625 => SyntaxKind::Select,
-                626 => SyntaxKind::Sequence,
-                627 => SyntaxKind::Sequences,
-                628 => SyntaxKind::Serializable,
-                629 => SyntaxKind::Server,
-                630 => SyntaxKind::Session,
-                631 => SyntaxKind::SessionUser,
-                632 => SyntaxKind::Set,
-                633 => SyntaxKind::Sets,
-                634 => SyntaxKind::Setof,
-                635 => SyntaxKind::Share,
-                636 => SyntaxKind::Show,
-                637 => SyntaxKind::Similar,
-                638 => SyntaxKind::Simple,
-                639 => SyntaxKind::Skip,
-                640 => SyntaxKind::Smallint,
-                641 => SyntaxKind::Snapshot,
-                642 => SyntaxKind::Some,
-                643 => SyntaxKind::SqlP,
-                644 => SyntaxKind::Stable,
-                645 => SyntaxKind::StandaloneP,
-                646 => SyntaxKind::Start,
-                647 => SyntaxKind::Statement,
-                648 => SyntaxKind::Statistics,
-                649 => SyntaxKind::Stdin,
-                650 => SyntaxKind::Stdout,
-                651 => SyntaxKind::Storage,
-                652 => SyntaxKind::Stored,
-                653 => SyntaxKind::StrictP,
-                654 => SyntaxKind::StripP,
-                655 => SyntaxKind::Subscription,
-                656 => SyntaxKind::Substring,
-                657 => SyntaxKind::Support,
-                658 => SyntaxKind::Symmetric,
-                659 => SyntaxKind::Sysid,
-                660 => SyntaxKind::SystemP,
-                661 => SyntaxKind::Table,
-                662 => SyntaxKind::Tables,
-                663 => SyntaxKind::Tablesample,
-                664 => SyntaxKind::Tablespace,
-                665 => SyntaxKind::Temp,
-                666 => SyntaxKind::Template,
-                667 => SyntaxKind::Temporary,
-                668 => SyntaxKind::TextP,
-                669 => SyntaxKind::Then,
-                670 => SyntaxKind::Ties,
-                671 => SyntaxKind::Time,
-                672 => SyntaxKind::Timestamp,
-                673 => SyntaxKind::To,
-                674 => SyntaxKind::Trailing,
-                675 => SyntaxKind::Transaction,
-                676 => SyntaxKind::Transform,
-                677 => SyntaxKind::Treat,
-                678 => SyntaxKind::Trigger,
-                679 => SyntaxKind::Trim,
-                680 => SyntaxKind::TrueP,
-                681 => SyntaxKind::Truncate,
-                682 => SyntaxKind::Trusted,
-                683 => SyntaxKind::TypeP,
-                684 => SyntaxKind::TypesP,
-                685 => SyntaxKind::Uescape,
-                686 => SyntaxKind::Unbounded,
-                687 => SyntaxKind::Uncommitted,
-                688 => SyntaxKind::Unencrypted,
-                689 => SyntaxKind::Union,
-                690 => SyntaxKind::Unique,
-                691 => SyntaxKind::Unknown,
-                692 => SyntaxKind::Unlisten,
-                693 => SyntaxKind::Unlogged,
-                694 => SyntaxKind::Until,
-                695 => SyntaxKind::Update,
-                696 => SyntaxKind::User,
-                697 => SyntaxKind::Using,
-                698 => SyntaxKind::Vacuum,
-                699 => SyntaxKind::Valid,
-                700 => SyntaxKind::Validate,
-                701 => SyntaxKind::Validator,
-                702 => SyntaxKind::ValueP,
-                703 => SyntaxKind::Values,
-                704 => SyntaxKind::Varchar,
-                705 => SyntaxKind::Variadic,
-                706 => SyntaxKind::Varying,
-                707 => SyntaxKind::Verbose,
-                708 => SyntaxKind::VersionP,
-                709 => SyntaxKind::View,
-                710 => SyntaxKind::Views,
-                711 => SyntaxKind::Volatile,
-                712 => SyntaxKind::When,
-                713 => SyntaxKind::Where,
-                714 => SyntaxKind::WhitespaceP,
-                715 => SyntaxKind::Window,
-                716 => SyntaxKind::With,
-                717 => SyntaxKind::Within,
-                718 => SyntaxKind::Without,
-                719 => SyntaxKind::Work,
-                720 => SyntaxKind::Wrapper,
-                721 => SyntaxKind::Write,
-                722 => SyntaxKind::XmlP,
-                723 => SyntaxKind::Xmlattributes,
-                724 => SyntaxKind::Xmlconcat,
-                725 => SyntaxKind::Xmlelement,
-                726 => SyntaxKind::Xmlexists,
-                727 => SyntaxKind::Xmlforest,
-                728 => SyntaxKind::Xmlnamespaces,
-                729 => SyntaxKind::Xmlparse,
-                730 => SyntaxKind::Xmlpi,
-                731 => SyntaxKind::Xmlroot,
-                732 => SyntaxKind::Xmlserialize,
-                733 => SyntaxKind::Xmltable,
-                734 => SyntaxKind::YearP,
-                735 => SyntaxKind::YesP,
-                736 => SyntaxKind::Zone,
-                737 => SyntaxKind::NotLa,
-                738 => SyntaxKind::NullsLa,
-                739 => SyntaxKind::WithLa,
-                740 => SyntaxKind::ModeTypeName,
-                741 => SyntaxKind::ModePlpgsqlExpr,
-                742 => SyntaxKind::ModePlpgsqlAssign1,
-                743 => SyntaxKind::ModePlpgsqlAssign2,
-                744 => SyntaxKind::ModePlpgsqlAssign3,
-                745 => SyntaxKind::Uminus,
-                _ => {
-                    ::core::panicking::panic_fmt(format_args!("Unknown token"));
-                }
-            }
-        }
-    }
-}

From 490026c535adcc6c4285644e0ea8cd716c4554ec Mon Sep 17 00:00:00 2001
From: Raminder Singh <romi_ssk@yahoo.co.in>
Date: Wed, 30 Aug 2023 15:00:14 +0530
Subject: [PATCH 17/23] fix 'inner attribute doesn't annotate this function'
 error

---
 crates/codegen/src/get_location.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crates/codegen/src/get_location.rs b/crates/codegen/src/get_location.rs
index 4b4c0559..29c79088 100644
--- a/crates/codegen/src/get_location.rs
+++ b/crates/codegen/src/get_location.rs
@@ -14,7 +14,7 @@ pub fn get_location_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenSt
     quote! {
         use pg_query::NodeEnum;
 
-        //! Returns the location of a node
+        // Returns the location of a node
         pub fn get_location(node: &NodeEnum) -> Option<i32> {
             let location = match node {
                 // for some nodes, the location of the node itself is after their childrens location.

From a9f0d60480385afd54d227a195e1d009f37f9881 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Sat, 2 Sep 2023 14:07:45 +0200
Subject: [PATCH 18/23] refactor: migrate to codegen

---
 crates/codegen/src/get_children.rs            |  259 +-
 crates/codegen/src/lib.rs                     |   12 +-
 ...erated_test.rs => get_children_codegen.rs} |    6 +-
 crates/parser/src/lib.rs                      |    5 +-
 crates/parser/src/pg_query_utils_generated.rs | 2589 -----------------
 ...y_utils_manual.rs => resolve_locations.rs} |  194 +-
 crates/parser/src/statement.rs                |    5 +-
 7 files changed, 282 insertions(+), 2788 deletions(-)
 rename crates/parser/src/{pg_query_utils_generated_test.rs => get_children_codegen.rs} (87%)
 delete mode 100644 crates/parser/src/pg_query_utils_generated.rs
 rename crates/parser/src/{pg_query_utils_manual.rs => resolve_locations.rs} (85%)

diff --git a/crates/codegen/src/get_children.rs b/crates/codegen/src/get_children.rs
index f3d78207..e92c5f6e 100644
--- a/crates/codegen/src/get_children.rs
+++ b/crates/codegen/src/get_children.rs
@@ -1,133 +1,126 @@
-// use pg_query_proto_parser::{FieldType, Node, ProtoParser};
-// use proc_macro2::{Ident, TokenStream};
-// use quote::{format_ident, quote};
-//
-// // todo: get_children should only return a Vec<NestedNode> with location being an Option<i32>
-// // we then pass the results into a resolve_locations function that takes a Vec<NestedNode> and returns a Vec<NestedNode>, but where location is an i32
-//
-// pub fn get_children_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
-//     let parser = ProtoParser::new("./libpg_query/protobuf/pg_query.proto");
-//     let proto_file = parser.parse();
-//
-//     let manual_node_names = manual_node_names();
-//
-//     let node_identifiers = node_identifiers(&proto_file.nodes, &manual_node_names);
-//     let node_handlers = node_handlers(&proto_file.nodes, &manual_node_names);
-//
-//     quote! {
-//         use pg_query::NodeEnum;
-//         use std::collections::VecDeque;
-//
-//         #[derive(Debug, Clone)]
-//         pub struct ChildrenNode {
-//             pub node: NodeEnum,
-//             pub depth: i32,
-//             pub location: Option<i32>,
-//             pub path: String,
-//         }
-//
-//         /// Returns all children of the node, recursively
-//         pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<ChildrenNode> {
-//             let mut nodes: Vec<ChildrenNode> = vec![];
-//             // Node, depth, path
-//             let mut stack: VecDeque<(NodeEnum, i32, String)> =
-//                 VecDeque::from(vec![(node.to_owned(), current_depth, "0".to_string())]);
-//             while !stack.is_empty() {
-//                 let (node, depth, path) = stack.pop_front().unwrap();
-//                 let current_depth = depth + 1;
-//                 let mut child_ctr: i32 = 0;
-//                 let mut handle_child = |c: NodeEnum| {
-//                     let location = get_location(&c);
-//                     let path = path.clone() + "." + child_ctr.to_string().as_str();
-//                     child_ctr = child_ctr + 1;
-//                     stack.push_back((c.to_owned(), current_depth, path.clone()));
-//                     nodes.push(ChildrenNode {
-//                         node: c,
-//                         depth: current_depth,
-//                         location,
-//                         path: path.clone(),
-//                     });
-//                 };
-//                 match &node {
-//                     // `AConst` is the only node with a `one of` property, so we handle it manually
-//                     // if you need to handle other nodes manually, add them to the `manual_node_names` function below
-//                     NodeEnum::AConst(n) => {
-//                         if n.val.is_some() {
-//                             handle_child(match n.val.to_owned().unwrap() {
-//                                 pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
-//                                 pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
-//                                 pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
-//                                 pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
-//                                 pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
-//                             });
-//                         }
-//                     }
-//                     #(NodeEnum::#node_identifiers(n) => {
-//                         #node_handlers
-//                     }),*,
-//                 };
-//             }
-//             nodes
-//         }
-//     }
-// }
-//
-// fn manual_node_names() -> Vec<&'static str> {
-//     vec!["AConst"]
-// }
-//
-// fn node_identifiers(nodes: &[Node], exclude_nodes: &[&str]) -> Vec<Ident> {
-//     nodes
-//         .iter()
-//         .filter(|node| !exclude_nodes.contains(&node.name.as_str()))
-//         .map(|node| format_ident!("{}", &node.name))
-//         .collect()
-// }
-//
-// fn node_handlers(nodes: &[Node], exclude_nodes: &[&str]) -> Vec<TokenStream> {
-//     nodes
-//         .iter()
-//         .filter(|node| !exclude_nodes.contains(&node.name.as_str()))
-//         .map(|node| {
-//             let property_handlers = property_handlers(&node);
-//             quote! {
-//                 #(#property_handlers)*
-//             }
-//         })
-//         .collect()
-// }
-//
-// fn property_handlers(node: &Node) -> Vec<TokenStream> {
-//     node.fields
-//         .iter()
-//         .map(|field| {
-//             if field.field_type == FieldType::Node && field.repeated {
-//                 let field_name = field.name.as_str();
-//                 quote! {
-//                     n.#field_name
-//                         .iter()
-//                         .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-//                 }
-//             } else if field.field_type == FieldType::Node && field.is_one_of == false {
-//                 if field.node_name == Some("Node".to_owned()) {
-//                     let field_name = field.name.as_str();
-//                     quote! {
-//                         if n.#field_name.is_some() {
-//                             handle_child(n.#field_name.to_owned().unwrap().node.unwrap());
-//                         }
-//                     }
-//                 } else {
-//                     let enum_variant_name = field.enum_variant_name.as_ref().unwrap();
-//                     let field_name = field.name.as_str();
-//                     quote! {
-//                         if n.#field_name.is_some() {
-//                             handle_child(NodeEnum::#enum_variant_name(n.#field_name.to_owned().unwrap()));
-//                         }
-//                     }
-//                 }
-//             } else {
-//                 panic!("Unhandled field type: {:?}", field);
-//             }
-//         })
-//         .collect()
-// }
+use pg_query_proto_parser::{FieldType, Node, ProtoParser};
+use proc_macro2::{Ident, TokenStream};
+use quote::{format_ident, quote};
+
+pub fn get_children_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
+    let parser = ProtoParser::new("./libpg_query/protobuf/pg_query.proto");
+    let proto_file = parser.parse();
+
+    let manual_node_names = manual_node_names();
+
+    let node_identifiers = node_identifiers(&proto_file.nodes, &manual_node_names);
+    let node_handlers = node_handlers(&proto_file.nodes, &manual_node_names);
+
+    quote! {
+        use pg_query::NodeEnum;
+        use std::collections::VecDeque;
+
+        #[derive(Debug, Clone)]
+        pub struct ChildrenNode {
+            pub node: NodeEnum,
+            pub depth: i32,
+            pub path: String,
+        }
+
+        /// Returns all children of the node, recursively
+        /// location is resolved manually
+        pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<ChildrenNode> {
+            let mut nodes: Vec<ChildrenNode> = vec![];
+            // Node, depth, path
+            let mut stack: VecDeque<(NodeEnum, i32, String)> =
+                VecDeque::from(vec![(node.to_owned(), current_depth, "0".to_string())]);
+            while !stack.is_empty() {
+                let (node, depth, path) = stack.pop_front().unwrap();
+                let current_depth = depth + 1;
+                let mut child_ctr: i32 = 0;
+                let mut handle_child = |c: NodeEnum| {
+                    let path = path.clone() + "." + child_ctr.to_string().as_str();
+                    child_ctr = child_ctr + 1;
+                    stack.push_back((c.to_owned(), current_depth, path.clone()));
+                    nodes.push(ChildrenNode {
+                        node: c,
+                        depth: current_depth,
+                        path: path.clone(),
+                    });
+                };
+                match &node {
+                    // `AConst` is the only node with a `one of` property, so we handle it manually
+                    // if you need to handle other nodes manually, add them to the `manual_node_names` function below
+                    NodeEnum::AConst(n) => {
+                        if n.val.is_some() {
+                            handle_child(match n.val.to_owned().unwrap() {
+                                pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
+                                pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
+                                pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
+                                pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
+                                pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
+                            });
+                        }
+                    }
+                    #(NodeEnum::#node_identifiers(n) => {#node_handlers}),*,
+                };
+            }
+            nodes
+        }
+    }
+}
+
+fn manual_node_names() -> Vec<&'static str> {
+    vec!["AConst"]
+}
+
+fn node_identifiers(nodes: &[Node], exclude_nodes: &[&str]) -> Vec<Ident> {
+    nodes
+        .iter()
+        .filter(|node| !exclude_nodes.contains(&node.name.as_str()))
+        .map(|node| format_ident!("{}", &node.name))
+        .collect()
+}
+
+fn node_handlers(nodes: &[Node], exclude_nodes: &[&str]) -> Vec<TokenStream> {
+    nodes
+        .iter()
+        .filter(|node| !exclude_nodes.contains(&node.name.as_str()))
+        .map(|node| {
+            let property_handlers = property_handlers(&node);
+            quote! {
+                #(#property_handlers)*
+            }
+        })
+        .collect()
+}
+
+fn property_handlers(node: &Node) -> Vec<TokenStream> {
+    node.fields
+        .iter()
+        .filter_map(|field| {
+            let field_name = format_ident!("{}", field.name.as_str());
+            if field.field_type == FieldType::Node && field.repeated {
+                Some(quote! {
+                    n.#field_name
+                        .iter()
+                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
+
+                })
+            } else if field.field_type == FieldType::Node && field.is_one_of == false {
+                if field.node_name == Some("Node".to_owned()) {
+                    Some(quote! {
+                        if n.#field_name.is_some() {
+                            handle_child(n.#field_name.to_owned().unwrap().node.unwrap());
+                        }
+                    })
+                } else {
+                    let enum_variant_name =
+                        format_ident!("{}", field.enum_variant_name.as_ref().unwrap().as_str());
+                    Some(quote! {
+                        if n.#field_name.is_some() {
+                            handle_child(NodeEnum::#enum_variant_name(n.#field_name.to_owned().unwrap()));
+                        }
+                    })
+                }
+            } else {
+                None
+            }
+        })
+        .collect()
+}
diff --git a/crates/codegen/src/lib.rs b/crates/codegen/src/lib.rs
index fb029ab2..fba42ea7 100644
--- a/crates/codegen/src/lib.rs
+++ b/crates/codegen/src/lib.rs
@@ -1,15 +1,15 @@
-// mod get_children;
+mod get_children;
 mod get_location;
 mod syntax_kind;
 
-// use get_children::get_children_mod;
+use get_children::get_children_mod;
 use get_location::get_location_mod;
 use syntax_kind::syntax_kind_mod;
 
-// #[proc_macro]
-// pub fn get_children(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
-//     get_children_mod(item.into()).into()
-// }
+#[proc_macro]
+pub fn get_children(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
+    get_children_mod(item.into()).into()
+}
 
 #[proc_macro]
 pub fn syntax_kind(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
diff --git a/crates/parser/src/pg_query_utils_generated_test.rs b/crates/parser/src/get_children_codegen.rs
similarity index 87%
rename from crates/parser/src/pg_query_utils_generated_test.rs
rename to crates/parser/src/get_children_codegen.rs
index d5270652..13b895f2 100644
--- a/crates/parser/src/pg_query_utils_generated_test.rs
+++ b/crates/parser/src/get_children_codegen.rs
@@ -1,6 +1,10 @@
+use codegen::get_children;
+
+get_children!();
+
 #[cfg(test)]
 mod tests {
-    use crate::pg_query_utils_generated::get_children;
+    use crate::get_children_codegen::get_children;
 
     #[test]
     fn test_get_children() {
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index f465e0f6..bc1ead7c 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -16,11 +16,10 @@
 //! To see how these drawbacks are mitigated, see the `statement.rs` and the `source_file.rs` module.
 
 mod ast_node;
+mod get_children_codegen;
 mod get_location_codegen;
 mod parser;
-mod pg_query_utils_generated;
-mod pg_query_utils_generated_test;
-mod pg_query_utils_manual;
+mod resolve_locations;
 mod sibling_token;
 mod source_file;
 mod statement;
diff --git a/crates/parser/src/pg_query_utils_generated.rs b/crates/parser/src/pg_query_utils_generated.rs
deleted file mode 100644
index b7bd9aa9..00000000
--- a/crates/parser/src/pg_query_utils_generated.rs
+++ /dev/null
@@ -1,2589 +0,0 @@
-//! Utilities for working with pg_query.rs
-//! This file is generated from the libg_query proto
-use crate::get_location_codegen::get_location;
-use crate::pg_query_utils_manual::derive_location;
-use pg_query::NodeEnum;
-use std::collections::VecDeque;
-
-#[derive(Debug, Clone)]
-pub struct NestedNode {
-    pub node: NodeEnum,
-    pub depth: i32,
-    pub location: i32,
-    pub path: String,
-}
-
-/// Returns all children of the node, recursively
-pub fn get_children(node: &NodeEnum, text: String, current_depth: i32) -> Vec<NestedNode> {
-    let mut nodes: Vec<NestedNode> = vec![];
-    // Node, depth, path
-    let mut stack: VecDeque<(NodeEnum, i32, String)> =
-        VecDeque::from(vec![(node.to_owned(), current_depth, "0".to_string())]); // Node, depth, path
-    let mut location_stack: VecDeque<(NodeEnum, i32, String)> = VecDeque::new();
-    while !stack.is_empty() || !location_stack.is_empty() {
-        if !stack.is_empty() {
-            let (node, depth, path) = stack.pop_front().unwrap();
-            let current_depth = depth + 1;
-            let mut child_ctr: i32 = 0;
-            let mut handle_child = |c: NodeEnum| {
-                let location = get_location(&c);
-                let path = path.clone() + "." + child_ctr.to_string().as_str();
-                child_ctr = child_ctr + 1;
-                stack.push_back((c.to_owned(), current_depth, path.clone()));
-                if location.is_some() {
-                    nodes.push(NestedNode {
-                        node: c,
-                        depth: current_depth,
-                        location: location.unwrap(),
-                        path: path.clone(),
-                    });
-                } else {
-                    location_stack.push_back((c, current_depth, path));
-                }
-            };
-            match &node {
-                NodeEnum::Alias(n) => {
-                    n.colnames
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RangeVar(n) => {
-                    if n.alias.is_some() {
-                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::TableFunc(n) => {
-                    n.ns_uris
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.ns_names
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.docexpr.is_some() {
-                        handle_child(n.docexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.rowexpr.is_some() {
-                        handle_child(n.rowexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.colnames
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.coltypes
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.coltypmods
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.colcollations
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.colexprs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.coldefexprs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::Var(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::Param(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::Aggref(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.aggargtypes
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.aggdirectargs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.aggorder
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.aggdistinct
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.aggfilter.is_some() {
-                        handle_child(n.aggfilter.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::GroupingFunc(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.refs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.cols
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::WindowFunc(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.aggfilter.is_some() {
-                        handle_child(n.aggfilter.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::SubscriptingRef(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.refupperindexpr
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.reflowerindexpr
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.refexpr.is_some() {
-                        handle_child(n.refexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.refassgnexpr.is_some() {
-                        handle_child(n.refassgnexpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::FuncExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::NamedArgExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::OpExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DistinctExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::NullIfExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ScalarArrayOpExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::BoolExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::SubLink(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.testexpr.is_some() {
-                        handle_child(n.testexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.oper_name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.subselect.is_some() {
-                        handle_child(n.subselect.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::SubPlan(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.testexpr.is_some() {
-                        handle_child(n.testexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.param_ids
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.set_param
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.par_param
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlternativeSubPlan(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.subplans
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::FieldSelect(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::FieldStore(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.newvals
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.fieldnums
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RelabelType(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CoerceViaIo(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::ArrayCoerceExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.elemexpr.is_some() {
-                        handle_child(n.elemexpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::ConvertRowtypeExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CollateExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CaseExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.defresult.is_some() {
-                        handle_child(n.defresult.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CaseWhen(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.expr.is_some() {
-                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.result.is_some() {
-                        handle_child(n.result.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CaseTestExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::ArrayExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.elements
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RowExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.colnames
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RowCompareExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.opnos
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.opfamilies
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.inputcollids
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.largs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.rargs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CoalesceExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::MinMaxExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::SqlvalueFunction(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::XmlExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.named_args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.arg_names
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::NullTest(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::BooleanTest(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CoerceToDomain(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CoerceToDomainValue(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::SetToDefault(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CurrentOfExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::NextValueExpr(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::InferenceElem(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.expr.is_some() {
-                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::TargetEntry(n) => {
-                    if n.xpr.is_some() {
-                        handle_child(n.xpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.expr.is_some() {
-                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::RangeTblRef(n) => (),
-                NodeEnum::JoinExpr(n) => {
-                    if n.larg.is_some() {
-                        handle_child(n.larg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.rarg.is_some() {
-                        handle_child(n.rarg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.using_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.join_using_alias.is_some() {
-                        handle_child(NodeEnum::Alias(n.join_using_alias.to_owned().unwrap()));
-                    }
-
-                    if n.quals.is_some() {
-                        handle_child(n.quals.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.alias.is_some() {
-                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::FromExpr(n) => {
-                    n.fromlist
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.quals.is_some() {
-                        handle_child(n.quals.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::OnConflictExpr(n) => {
-                    n.arbiter_elems
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.arbiter_where.is_some() {
-                        handle_child(n.arbiter_where.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.on_conflict_set
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.on_conflict_where.is_some() {
-                        handle_child(n.on_conflict_where.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.excl_rel_tlist
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::IntoClause(n) => {
-                    if n.rel.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.rel.to_owned().unwrap()));
-                    }
-
-                    n.col_names
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.view_query.is_some() {
-                        handle_child(n.view_query.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::MergeAction(n) => {
-                    if n.qual.is_some() {
-                        handle_child(n.qual.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.target_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.update_colnos
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RawStmt(n) => {
-                    if n.stmt.is_some() {
-                        handle_child(n.stmt.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::Query(n) => {
-                    if n.utility_stmt.is_some() {
-                        handle_child(n.utility_stmt.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.cte_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.rtable
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.jointree.is_some() {
-                        handle_child(NodeEnum::FromExpr(n.jointree.to_owned().unwrap()));
-                    }
-
-                    n.merge_action_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.target_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.on_conflict.is_some() {
-                        handle_child(NodeEnum::OnConflictExpr(n.on_conflict.to_owned().unwrap()));
-                    }
-
-                    n.returning_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.group_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.grouping_sets
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.having_qual.is_some() {
-                        handle_child(n.having_qual.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.window_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.distinct_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.sort_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.limit_offset.is_some() {
-                        handle_child(n.limit_offset.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.limit_count.is_some() {
-                        handle_child(n.limit_count.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.row_marks
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.set_operations.is_some() {
-                        handle_child(n.set_operations.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.constraint_deps
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.with_check_options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::InsertStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.cols
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.select_stmt.is_some() {
-                        handle_child(n.select_stmt.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.on_conflict_clause.is_some() {
-                        handle_child(NodeEnum::OnConflictClause(
-                            n.on_conflict_clause.to_owned().unwrap(),
-                        ));
-                    }
-
-                    n.returning_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.with_clause.is_some() {
-                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::DeleteStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.using_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.returning_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.with_clause.is_some() {
-                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::UpdateStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.target_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.from_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.returning_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.with_clause.is_some() {
-                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::MergeStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    if n.source_relation.is_some() {
-                        handle_child(n.source_relation.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.join_condition.is_some() {
-                        handle_child(n.join_condition.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.merge_when_clauses
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.with_clause.is_some() {
-                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::SelectStmt(n) => {
-                    n.distinct_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.into_clause.is_some() {
-                        handle_child(NodeEnum::IntoClause(n.into_clause.to_owned().unwrap()));
-                    }
-
-                    n.target_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.from_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.group_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.having_clause.is_some() {
-                        handle_child(n.having_clause.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.window_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.values_lists
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.sort_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.limit_offset.is_some() {
-                        handle_child(n.limit_offset.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.limit_count.is_some() {
-                        handle_child(n.limit_count.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.locking_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.with_clause.is_some() {
-                        handle_child(NodeEnum::WithClause(n.with_clause.to_owned().unwrap()));
-                    }
-
-                    if n.larg.is_some() {
-                        handle_child(NodeEnum::SelectStmt(n.larg.to_owned().unwrap()));
-                    }
-
-                    if n.rarg.is_some() {
-                        handle_child(NodeEnum::SelectStmt(n.rarg.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::ReturnStmt(n) => {
-                    if n.returnval.is_some() {
-                        handle_child(n.returnval.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::PlassignStmt(n) => {
-                    n.indirection
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.val.is_some() {
-                        handle_child(NodeEnum::SelectStmt(n.val.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::AlterTableStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.cmds
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterTableCmd(n) => {
-                    if n.newowner.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.newowner.to_owned().unwrap()));
-                    }
-
-                    if n.def.is_some() {
-                        handle_child(n.def.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::AlterDomainStmt(n) => {
-                    n.type_name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.def.is_some() {
-                        handle_child(n.def.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::SetOperationStmt(n) => {
-                    if n.larg.is_some() {
-                        handle_child(n.larg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.rarg.is_some() {
-                        handle_child(n.rarg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.col_types
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.col_typmods
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.col_collations
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.group_clauses
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::GrantStmt(n) => {
-                    n.objects
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.privileges
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.grantees
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.grantor.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.grantor.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::GrantRoleStmt(n) => {
-                    n.granted_roles
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.grantee_roles
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.grantor.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.grantor.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::AlterDefaultPrivilegesStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.action.is_some() {
-                        handle_child(NodeEnum::GrantStmt(n.action.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::ClosePortalStmt(n) => (),
-                NodeEnum::ClusterStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.params
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CopyStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    if n.query.is_some() {
-                        handle_child(n.query.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.attlist
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CreateStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.table_elts
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.inh_relations
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.partbound.is_some() {
-                        handle_child(NodeEnum::PartitionBoundSpec(
-                            n.partbound.to_owned().unwrap(),
-                        ));
-                    }
-
-                    if n.partspec.is_some() {
-                        handle_child(NodeEnum::PartitionSpec(n.partspec.to_owned().unwrap()));
-                    }
-
-                    if n.of_typename.is_some() {
-                        handle_child(NodeEnum::TypeName(n.of_typename.to_owned().unwrap()));
-                    }
-
-                    n.constraints
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DefineStmt(n) => {
-                    n.defnames
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.definition
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DropStmt(n) => {
-                    n.objects
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::TruncateStmt(n) => {
-                    n.relations
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CommentStmt(n) => {
-                    if n.object.is_some() {
-                        handle_child(n.object.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::FetchStmt(n) => (),
-                NodeEnum::IndexStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.index_params
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.index_including_params
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.exclude_op_names
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateFunctionStmt(n) => {
-                    n.funcname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.parameters
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.return_type.is_some() {
-                        handle_child(NodeEnum::TypeName(n.return_type.to_owned().unwrap()));
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.sql_body.is_some() {
-                        handle_child(n.sql_body.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::AlterFunctionStmt(n) => {
-                    if n.func.is_some() {
-                        handle_child(NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap()));
-                    }
-
-                    n.actions
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DoStmt(n) => {
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RenameStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    if n.object.is_some() {
-                        handle_child(n.object.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::RuleStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.actions
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::NotifyStmt(n) => (),
-                NodeEnum::ListenStmt(n) => (),
-                NodeEnum::UnlistenStmt(n) => (),
-                NodeEnum::TransactionStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ViewStmt(n) => {
-                    if n.view.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.view.to_owned().unwrap()));
-                    }
-
-                    n.aliases
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.query.is_some() {
-                        handle_child(n.query.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::LoadStmt(n) => (),
-                NodeEnum::CreateDomainStmt(n) => {
-                    n.domainname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.type_name.is_some() {
-                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
-                    }
-
-                    if n.coll_clause.is_some() {
-                        handle_child(NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap()));
-                    }
-
-                    n.constraints
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreatedbStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DropdbStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::VacuumStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.rels
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ExplainStmt(n) => {
-                    if n.query.is_some() {
-                        handle_child(n.query.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateTableAsStmt(n) => {
-                    if n.query.is_some() {
-                        handle_child(n.query.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.into.is_some() {
-                        handle_child(NodeEnum::IntoClause(n.into.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::CreateSeqStmt(n) => {
-                    if n.sequence.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.sequence.to_owned().unwrap()));
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterSeqStmt(n) => {
-                    if n.sequence.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.sequence.to_owned().unwrap()));
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::VariableSetStmt(n) => {
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::VariableShowStmt(n) => (),
-                NodeEnum::DiscardStmt(n) => (),
-                NodeEnum::CreateTrigStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.funcname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.columns
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.when_clause.is_some() {
-                        handle_child(n.when_clause.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.transition_rels
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.constrrel.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.constrrel.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::CreatePlangStmt(n) => {
-                    n.plhandler
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.plinline
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.plvalidator
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateRoleStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterRoleStmt(n) => {
-                    if n.role.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.role.to_owned().unwrap()));
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DropRoleStmt(n) => {
-                    n.roles
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::LockStmt(n) => {
-                    n.relations
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ConstraintsSetStmt(n) => {
-                    n.constraints
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ReindexStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.params
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CheckPointStmt(n) => (),
-                NodeEnum::CreateSchemaStmt(n) => {
-                    if n.authrole.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.authrole.to_owned().unwrap()));
-                    }
-
-                    n.schema_elts
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterDatabaseStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterDatabaseRefreshCollStmt(n) => (),
-                NodeEnum::AlterDatabaseSetStmt(n) => {
-                    if n.setstmt.is_some() {
-                        handle_child(NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::AlterRoleSetStmt(n) => {
-                    if n.role.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.role.to_owned().unwrap()));
-                    }
-
-                    if n.setstmt.is_some() {
-                        handle_child(NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::CreateConversionStmt(n) => {
-                    n.conversion_name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.func_name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateCastStmt(n) => {
-                    if n.sourcetype.is_some() {
-                        handle_child(NodeEnum::TypeName(n.sourcetype.to_owned().unwrap()));
-                    }
-
-                    if n.targettype.is_some() {
-                        handle_child(NodeEnum::TypeName(n.targettype.to_owned().unwrap()));
-                    }
-
-                    if n.func.is_some() {
-                        handle_child(NodeEnum::ObjectWithArgs(n.func.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::CreateOpClassStmt(n) => {
-                    n.opclassname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.opfamilyname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.datatype.is_some() {
-                        handle_child(NodeEnum::TypeName(n.datatype.to_owned().unwrap()));
-                    }
-
-                    n.items
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateOpFamilyStmt(n) => {
-                    n.opfamilyname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterOpFamilyStmt(n) => {
-                    n.opfamilyname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.items
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::PrepareStmt(n) => {
-                    n.argtypes
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.query.is_some() {
-                        handle_child(n.query.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::ExecuteStmt(n) => {
-                    n.params
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DeallocateStmt(n) => (),
-                NodeEnum::DeclareCursorStmt(n) => {
-                    if n.query.is_some() {
-                        handle_child(n.query.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CreateTableSpaceStmt(n) => {
-                    if n.owner.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.owner.to_owned().unwrap()));
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DropTableSpaceStmt(n) => (),
-                NodeEnum::AlterObjectDependsStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    if n.object.is_some() {
-                        handle_child(n.object.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.extname.is_some() {
-                        handle_child(NodeEnum::String(n.extname.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::AlterObjectSchemaStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    if n.object.is_some() {
-                        handle_child(n.object.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::AlterOwnerStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    if n.object.is_some() {
-                        handle_child(n.object.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.newowner.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.newowner.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::AlterOperatorStmt(n) => {
-                    if n.opername.is_some() {
-                        handle_child(NodeEnum::ObjectWithArgs(n.opername.to_owned().unwrap()));
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterTypeStmt(n) => {
-                    n.type_name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DropOwnedStmt(n) => {
-                    n.roles
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ReassignOwnedStmt(n) => {
-                    n.roles
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.newrole.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.newrole.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::CompositeTypeStmt(n) => {
-                    if n.typevar.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.typevar.to_owned().unwrap()));
-                    }
-
-                    n.coldeflist
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateEnumStmt(n) => {
-                    n.type_name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.vals
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateRangeStmt(n) => {
-                    n.type_name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.params
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterEnumStmt(n) => {
-                    n.type_name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterTsdictionaryStmt(n) => {
-                    n.dictname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterTsconfigurationStmt(n) => {
-                    n.cfgname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.tokentype
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.dicts
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateFdwStmt(n) => {
-                    n.func_options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterFdwStmt(n) => {
-                    n.func_options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateForeignServerStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterForeignServerStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateUserMappingStmt(n) => {
-                    if n.user.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.user.to_owned().unwrap()));
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterUserMappingStmt(n) => {
-                    if n.user.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.user.to_owned().unwrap()));
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DropUserMappingStmt(n) => {
-                    if n.user.is_some() {
-                        handle_child(NodeEnum::RoleSpec(n.user.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::AlterTableSpaceOptionsStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterTableMoveAllStmt(n) => {
-                    n.roles
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::SecLabelStmt(n) => {
-                    if n.object.is_some() {
-                        handle_child(n.object.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CreateForeignTableStmt(n) => {
-                    if n.base_stmt.is_some() {
-                        handle_child(NodeEnum::CreateStmt(n.base_stmt.to_owned().unwrap()));
-                    }
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ImportForeignSchemaStmt(n) => {
-                    n.table_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateExtensionStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterExtensionStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterExtensionContentsStmt(n) => {
-                    if n.object.is_some() {
-                        handle_child(n.object.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CreateEventTrigStmt(n) => {
-                    n.whenclause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.funcname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterEventTrigStmt(n) => (),
-                NodeEnum::RefreshMatViewStmt(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::ReplicaIdentityStmt(n) => (),
-                NodeEnum::AlterSystemStmt(n) => {
-                    if n.setstmt.is_some() {
-                        handle_child(NodeEnum::VariableSetStmt(n.setstmt.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::CreatePolicyStmt(n) => {
-                    if n.table.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.table.to_owned().unwrap()));
-                    }
-
-                    n.roles
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.qual.is_some() {
-                        handle_child(n.qual.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.with_check.is_some() {
-                        handle_child(n.with_check.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::AlterPolicyStmt(n) => {
-                    if n.table.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.table.to_owned().unwrap()));
-                    }
-
-                    n.roles
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.qual.is_some() {
-                        handle_child(n.qual.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.with_check.is_some() {
-                        handle_child(n.with_check.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CreateTransformStmt(n) => {
-                    if n.type_name.is_some() {
-                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
-                    }
-
-                    if n.fromsql.is_some() {
-                        handle_child(NodeEnum::ObjectWithArgs(n.fromsql.to_owned().unwrap()));
-                    }
-
-                    if n.tosql.is_some() {
-                        handle_child(NodeEnum::ObjectWithArgs(n.tosql.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::CreateAmStmt(n) => {
-                    n.handler_name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreatePublicationStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.pubobjects
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterPublicationStmt(n) => {
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.pubobjects
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateSubscriptionStmt(n) => {
-                    n.publication
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterSubscriptionStmt(n) => {
-                    n.publication
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DropSubscriptionStmt(n) => (),
-                NodeEnum::CreateStatsStmt(n) => {
-                    n.defnames
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.stat_types
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.exprs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.relations
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterCollationStmt(n) => {
-                    n.collname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CallStmt(n) => {
-                    if n.funccall.is_some() {
-                        handle_child(NodeEnum::FuncCall(n.funccall.to_owned().unwrap()));
-                    }
-
-                    if n.funcexpr.is_some() {
-                        handle_child(NodeEnum::FuncExpr(n.funcexpr.to_owned().unwrap()));
-                    }
-
-                    n.outargs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AlterStatsStmt(n) => {
-                    n.defnames
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AExpr(n) => {
-                    n.name
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.lexpr.is_some() {
-                        handle_child(n.lexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.rexpr.is_some() {
-                        handle_child(n.rexpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::ColumnRef(n) => {
-                    n.fields
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ParamRef(n) => (),
-                NodeEnum::FuncCall(n) => {
-                    n.funcname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.agg_order
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.agg_filter.is_some() {
-                        handle_child(n.agg_filter.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.over.is_some() {
-                        handle_child(NodeEnum::WindowDef(n.over.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::AStar(n) => (),
-                NodeEnum::AIndices(n) => {
-                    if n.lidx.is_some() {
-                        handle_child(n.lidx.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.uidx.is_some() {
-                        handle_child(n.uidx.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::AIndirection(n) => {
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.indirection
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AArrayExpr(n) => {
-                    n.elements
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ResTarget(n) => {
-                    n.indirection
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.val.is_some() {
-                        handle_child(n.val.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::MultiAssignRef(n) => {
-                    if n.source.is_some() {
-                        handle_child(n.source.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::TypeCast(n) => {
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.type_name.is_some() {
-                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::CollateClause(n) => {
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.collname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::SortBy(n) => {
-                    if n.node.is_some() {
-                        handle_child(n.node.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.use_op
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::WindowDef(n) => {
-                    n.partition_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.order_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.start_offset.is_some() {
-                        handle_child(n.start_offset.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.end_offset.is_some() {
-                        handle_child(n.end_offset.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::RangeSubselect(n) => {
-                    if n.subquery.is_some() {
-                        handle_child(n.subquery.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.alias.is_some() {
-                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::RangeFunction(n) => {
-                    n.functions
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.alias.is_some() {
-                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
-                    }
-
-                    n.coldeflist
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RangeTableSample(n) => {
-                    if n.relation.is_some() {
-                        handle_child(n.relation.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.method
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.repeatable.is_some() {
-                        handle_child(n.repeatable.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::RangeTableFunc(n) => {
-                    if n.docexpr.is_some() {
-                        handle_child(n.docexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.rowexpr.is_some() {
-                        handle_child(n.rowexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.namespaces
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.columns
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.alias.is_some() {
-                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::RangeTableFuncCol(n) => {
-                    if n.type_name.is_some() {
-                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
-                    }
-
-                    if n.colexpr.is_some() {
-                        handle_child(n.colexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.coldefexpr.is_some() {
-                        handle_child(n.coldefexpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::TypeName(n) => {
-                    n.names
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.typmods
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.array_bounds
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ColumnDef(n) => {
-                    if n.type_name.is_some() {
-                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
-                    }
-
-                    if n.raw_default.is_some() {
-                        handle_child(n.raw_default.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.cooked_default.is_some() {
-                        handle_child(n.cooked_default.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.identity_sequence.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.identity_sequence.to_owned().unwrap()));
-                    }
-
-                    if n.coll_clause.is_some() {
-                        handle_child(NodeEnum::CollateClause(n.coll_clause.to_owned().unwrap()));
-                    }
-
-                    n.constraints
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.fdwoptions
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::IndexElem(n) => {
-                    if n.expr.is_some() {
-                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.collation
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.opclass
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.opclassopts
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::StatsElem(n) => {
-                    if n.expr.is_some() {
-                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::Constraint(n) => {
-                    if n.raw_expr.is_some() {
-                        handle_child(n.raw_expr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.keys
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.including
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.exclusions
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.options
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.pktable.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.pktable.to_owned().unwrap()));
-                    }
-
-                    n.fk_attrs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.pk_attrs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.fk_del_set_cols
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.old_conpfeqop
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::DefElem(n) => {
-                    if n.arg.is_some() {
-                        handle_child(n.arg.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::RangeTblEntry(n) => {
-                    if n.tablesample.is_some() {
-                        handle_child(NodeEnum::TableSampleClause(
-                            n.tablesample.to_owned().unwrap(),
-                        ));
-                    }
-
-                    if n.subquery.is_some() {
-                        handle_child(NodeEnum::Query(n.subquery.to_owned().unwrap()));
-                    }
-
-                    n.joinaliasvars
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.joinleftcols
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.joinrightcols
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.join_using_alias.is_some() {
-                        handle_child(NodeEnum::Alias(n.join_using_alias.to_owned().unwrap()));
-                    }
-
-                    n.functions
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.tablefunc.is_some() {
-                        handle_child(NodeEnum::TableFunc(n.tablefunc.to_owned().unwrap()));
-                    }
-
-                    n.values_lists
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.coltypes
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.coltypmods
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.colcollations
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.alias.is_some() {
-                        handle_child(NodeEnum::Alias(n.alias.to_owned().unwrap()));
-                    }
-
-                    if n.eref.is_some() {
-                        handle_child(NodeEnum::Alias(n.eref.to_owned().unwrap()));
-                    }
-
-                    n.security_quals
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RangeTblFunction(n) => {
-                    if n.funcexpr.is_some() {
-                        handle_child(n.funcexpr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.funccolnames
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.funccoltypes
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.funccoltypmods
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.funccolcollations
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::TableSampleClause(n) => {
-                    n.args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.repeatable.is_some() {
-                        handle_child(n.repeatable.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::WithCheckOption(n) => {
-                    if n.qual.is_some() {
-                        handle_child(n.qual.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::SortGroupClause(n) => (),
-                NodeEnum::GroupingSet(n) => {
-                    n.content
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::WindowClause(n) => {
-                    n.partition_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.order_clause
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.start_offset.is_some() {
-                        handle_child(n.start_offset.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.end_offset.is_some() {
-                        handle_child(n.end_offset.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.run_condition
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::ObjectWithArgs(n) => {
-                    n.objname
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.objargs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.objfuncargs
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AccessPriv(n) => {
-                    n.cols
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CreateOpClassItem(n) => {
-                    if n.name.is_some() {
-                        handle_child(NodeEnum::ObjectWithArgs(n.name.to_owned().unwrap()));
-                    }
-
-                    n.order_family
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.class_args
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.storedtype.is_some() {
-                        handle_child(NodeEnum::TypeName(n.storedtype.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::TableLikeClause(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::FunctionParameter(n) => {
-                    if n.arg_type.is_some() {
-                        handle_child(NodeEnum::TypeName(n.arg_type.to_owned().unwrap()));
-                    }
-
-                    if n.defexpr.is_some() {
-                        handle_child(n.defexpr.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::LockingClause(n) => {
-                    n.locked_rels
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RowMarkClause(n) => (),
-                NodeEnum::XmlSerialize(n) => {
-                    if n.expr.is_some() {
-                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.type_name.is_some() {
-                        handle_child(NodeEnum::TypeName(n.type_name.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::WithClause(n) => {
-                    n.ctes
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::InferClause(n) => {
-                    n.index_elems
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::OnConflictClause(n) => {
-                    if n.infer.is_some() {
-                        handle_child(NodeEnum::InferClause(n.infer.to_owned().unwrap()));
-                    }
-
-                    n.target_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CtesearchClause(n) => {
-                    n.search_col_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::CtecycleClause(n) => {
-                    n.cycle_col_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.cycle_mark_value.is_some() {
-                        handle_child(n.cycle_mark_value.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.cycle_mark_default.is_some() {
-                        handle_child(n.cycle_mark_default.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::CommonTableExpr(n) => {
-                    n.aliascolnames
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    if n.ctequery.is_some() {
-                        handle_child(n.ctequery.to_owned().unwrap().node.unwrap());
-                    }
-
-                    if n.search_clause.is_some() {
-                        handle_child(NodeEnum::CtesearchClause(
-                            n.search_clause.to_owned().unwrap(),
-                        ));
-                    }
-
-                    if n.cycle_clause.is_some() {
-                        handle_child(NodeEnum::CtecycleClause(n.cycle_clause.to_owned().unwrap()));
-                    }
-
-                    n.ctecolnames
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.ctecoltypes
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.ctecoltypmods
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.ctecolcollations
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::MergeWhenClause(n) => {
-                    if n.condition.is_some() {
-                        handle_child(n.condition.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.target_list
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.values
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::RoleSpec(n) => (),
-                NodeEnum::TriggerTransition(n) => (),
-                NodeEnum::PartitionElem(n) => {
-                    if n.expr.is_some() {
-                        handle_child(n.expr.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.collation
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.opclass
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::PartitionSpec(n) => {
-                    n.part_params
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::PartitionBoundSpec(n) => {
-                    n.listdatums
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.lowerdatums
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-
-                    n.upperdatums
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::PartitionRangeDatum(n) => {
-                    if n.value.is_some() {
-                        handle_child(n.value.to_owned().unwrap().node.unwrap());
-                    }
-                }
-                NodeEnum::PartitionCmd(n) => {
-                    if n.name.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.name.to_owned().unwrap()));
-                    }
-
-                    if n.bound.is_some() {
-                        handle_child(NodeEnum::PartitionBoundSpec(n.bound.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::VacuumRelation(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    n.va_cols
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::PublicationObjSpec(n) => {
-                    if n.pubtable.is_some() {
-                        handle_child(NodeEnum::PublicationTable(n.pubtable.to_owned().unwrap()));
-                    }
-                }
-                NodeEnum::PublicationTable(n) => {
-                    if n.relation.is_some() {
-                        handle_child(NodeEnum::RangeVar(n.relation.to_owned().unwrap()));
-                    }
-
-                    if n.where_clause.is_some() {
-                        handle_child(n.where_clause.to_owned().unwrap().node.unwrap());
-                    }
-
-                    n.columns
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::InlineCodeBlock(n) => (),
-                NodeEnum::CallContext(n) => (),
-                NodeEnum::Integer(n) => (),
-                NodeEnum::Float(n) => (),
-                NodeEnum::Boolean(n) => (),
-                NodeEnum::String(n) => (),
-                NodeEnum::BitString(n) => (),
-                NodeEnum::List(n) => {
-                    n.items
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::IntList(n) => {
-                    n.items
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::OidList(n) => {
-                    n.items
-                        .iter()
-                        .for_each(|x| handle_child(x.node.as_ref().unwrap().to_owned()));
-                }
-                NodeEnum::AConst(n) => {
-                    if n.val.is_some() {
-                        handle_child(match n.val.to_owned().unwrap() {
-                            pg_query::protobuf::a_const::Val::Ival(v) => NodeEnum::Integer(v),
-                            pg_query::protobuf::a_const::Val::Fval(v) => NodeEnum::Float(v),
-                            pg_query::protobuf::a_const::Val::Boolval(v) => NodeEnum::Boolean(v),
-                            pg_query::protobuf::a_const::Val::Sval(v) => NodeEnum::String(v),
-                            pg_query::protobuf::a_const::Val::Bsval(v) => NodeEnum::BitString(v),
-                        });
-                    }
-                }
-            };
-        } else if !location_stack.is_empty() {
-            let (node, depth, path) = location_stack.pop_front().unwrap();
-            let parent_node = nodes.iter().find(|n| {
-                let mut path_elements = path.split(".").collect::<Vec<&str>>();
-                path_elements.pop();
-                let parent_path = path_elements.join(".");
-                n.path == parent_path
-            });
-            let parent_location = if parent_node.is_some() {
-                parent_node.unwrap().location
-            } else {
-                0
-            };
-            // FISME: we assume that at least one (nested) child location is known.
-            // this is not true for all nodes, e.g.
-            // `DROP TABLE tablename;`, where the location of the `List` node that wraps the String node `tablename` is not known
-            // in this case, we could try to "recover" by putting it back into the stack and trying
-            // again after all children are processed
-            let earliest_child_location = nodes
-                .iter()
-                .filter(|n| n.path.starts_with(path.as_str()))
-                .min_by(|a, b| a.location.cmp(&b.location))
-                .map(|n| n.location);
-            let location = derive_location(
-                &node,
-                text.clone(),
-                parent_location,
-                earliest_child_location,
-            );
-            if location.is_some() {
-                nodes.push(NestedNode {
-                    node,
-                    depth,
-                    location: location.unwrap(),
-                    path: path.clone(),
-                });
-            } else if location_stack
-                .iter()
-                .find(|x| x.2.starts_with(path.as_str()))
-                .is_some()
-            {
-                location_stack.push_back((node, depth, path));
-            }
-        }
-    }
-    nodes.sort_by_key(|n| (n.location, n.depth));
-    nodes
-}
diff --git a/crates/parser/src/pg_query_utils_manual.rs b/crates/parser/src/resolve_locations.rs
similarity index 85%
rename from crates/parser/src/pg_query_utils_manual.rs
rename to crates/parser/src/resolve_locations.rs
index 9eafaa8f..3ffa6104 100644
--- a/crates/parser/src/pg_query_utils_manual.rs
+++ b/crates/parser/src/resolve_locations.rs
@@ -1,69 +1,101 @@
+//! Implements the `resolve_locations` function, which derives the location of a node if not set on
+//! the node itself.
+
+use crate::get_children_codegen::ChildrenNode;
+use crate::get_location_codegen::get_location;
 use pg_query::NodeEnum;
 use regex::Regex;
+use std::collections::VecDeque;
 
-fn find_location_via_regexp(
-    r: Regex,
-    text: String,
-    parent_location: i32,
-    earliest_child_location: Option<i32>,
-) -> Option<i32> {
-    struct Location {
-        location: i32,
-        distance: i32,
-    }
+#[derive(Debug, Clone)]
+pub struct NestedNode {
+    pub node: NodeEnum,
+    pub depth: i32,
+    pub location: i32,
+    pub path: String,
+}
 
-    let location = r
-        .find_iter(text.as_str())
-        .filter_map(|x| {
-            if x.start() as i32 >= parent_location {
-                Some({
-                    Location {
-                        location: x.start() as i32,
-                        distance: if earliest_child_location.is_some() {
-                            earliest_child_location.unwrap() - x.start() as i32
-                        } else {
-                            x.start() as i32 - parent_location
-                        },
-                    }
-                })
-            } else {
-                None
-            }
-        })
-        .min_by_key(|x| x.distance.abs());
+/// Resolves the location of `ChildrenNode`
+///
+/// Uses the `.location` property if available on the node, and otherwise tries to
+/// derive the location manually.
+pub fn resolve_locations(children: Vec<ChildrenNode>, text: &str) -> Vec<NestedNode> {
+    let mut nodes: Vec<NestedNode> = vec![];
 
-    if location.is_none() {
-        return None;
-    }
+    let mut stack: VecDeque<ChildrenNode> = VecDeque::from(children);
 
-    let location = location.unwrap().location;
+    while !stack.is_empty() {
+        let current_node = stack.pop_front().unwrap();
 
-    // Sanity check to ensure that the location is valid
-    if earliest_child_location.is_some() && earliest_child_location.unwrap() < location {
-        panic!("Regex returned invalid location: Node cannot have a location < its children");
-    }
+        // if location is set, we can skip the rest
+        let location = get_location(&current_node.node);
+        if location.is_some() {
+            nodes.push(NestedNode {
+                node: current_node.node,
+                depth: current_node.depth,
+                location: location.unwrap(),
+                path: current_node.path.clone(),
+            });
+            continue;
+        }
 
-    Some(location)
-}
+        // get parent node and its location
+        let parent_node = nodes.iter().find(|n| {
+            let mut path_elements = current_node.path.split(".").collect::<Vec<&str>>();
+            path_elements.pop();
+            let parent_path = path_elements.join(".");
+            n.path == parent_path
+        });
 
-fn get_location_via_regexp(
-    r: Regex,
-    text: String,
-    parent_location: i32,
-    earliest_child_location: Option<i32>,
-) -> i32 {
-    return find_location_via_regexp(r, text, parent_location, earliest_child_location).unwrap();
+        let parent_location = if parent_node.is_some() {
+            parent_node.unwrap().location
+        } else {
+            // fallback to 0 if no parent node is found
+            0
+        };
+
+        // we cannot assume that for each node, there is at least one child with a location.
+        // e.g. in `DROP TABLE tablename;`, the location of the `List` node that wraps the String node `tablename` is not known
+        let earliest_child_location = nodes
+            .iter()
+            .filter(|n| n.path.starts_with(current_node.path.as_str()))
+            .min_by(|a, b| a.location.cmp(&b.location))
+            .map(|n| n.location);
+
+        let location = derive_location(
+            &current_node.node,
+            text.clone(),
+            parent_location,
+            earliest_child_location,
+        );
+
+        if location.is_some() {
+            nodes.push(NestedNode {
+                node: current_node.node,
+                depth: current_node.depth,
+                location: location.unwrap(),
+                path: current_node.path.clone(),
+            });
+        } else if stack
+            .iter()
+            .find(|x| x.path.starts_with(current_node.path.as_str()))
+            .is_some()
+        {
+            // if there are still children to be processed, we push the node back to the stack and
+            // try again later in the hope that we could find the location for a children node of
+            // the current node
+            stack.push_back(current_node);
+        }
+    }
+
+    nodes
 }
 
-/// This is the only manual implementation required for the parser
-/// The problem this functions is attempting to solve is that not all nodes have a location property
-///
-/// I suspect for most of the nodes, a simple regular expression will be sufficient
-pub fn derive_location(
+fn derive_location(
     // The node to derive the location for
     node: &NodeEnum,
     // The full text of the query
-    text: String,
+    text: &str,
     // The location of the parent node
     parent_location: i32,
     // not given if node does not have any children
@@ -386,13 +418,67 @@ pub fn derive_location(
     }
 }
 
+fn find_location_via_regexp(
+    r: Regex,
+    text: &str,
+    parent_location: i32,
+    earliest_child_location: Option<i32>,
+) -> Option<i32> {
+    struct Location {
+        location: i32,
+        distance: i32,
+    }
+
+    let location = r
+        .find_iter(text)
+        .filter_map(|x| {
+            if x.start() as i32 >= parent_location {
+                Some({
+                    Location {
+                        location: x.start() as i32,
+                        distance: if earliest_child_location.is_some() {
+                            earliest_child_location.unwrap() - x.start() as i32
+                        } else {
+                            x.start() as i32 - parent_location
+                        },
+                    }
+                })
+            } else {
+                None
+            }
+        })
+        .min_by_key(|x| x.distance.abs());
+
+    if location.is_none() {
+        return None;
+    }
+
+    let location = location.unwrap().location;
+
+    // Sanity check to ensure that the location is valid
+    if earliest_child_location.is_some() && earliest_child_location.unwrap() < location {
+        panic!("Regex returned invalid location: Node cannot have a location < its children");
+    }
+
+    Some(location)
+}
+
+fn get_location_via_regexp(
+    r: Regex,
+    text: &str,
+    parent_location: i32,
+    earliest_child_location: Option<i32>,
+) -> i32 {
+    return find_location_via_regexp(r, text, parent_location, earliest_child_location).unwrap();
+}
+
 #[cfg(test)]
 mod tests {
     use std::assert_eq;
 
     use pg_query::NodeEnum;
 
-    use crate::pg_query_utils_manual::derive_location;
+    use crate::resolve_locations::derive_location;
 
     #[test]
     fn test_derive_location() {
@@ -431,7 +517,7 @@ mod tests {
 
         let l = derive_location(
             &insert_node.unwrap(),
-            input.to_string(),
+            input,
             cte_location.unwrap(),
             Some(23),
         );
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 3c1e24f8..e67e4933 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -2,8 +2,9 @@ use cstree::text::{TextRange, TextSize};
 use logos::{Logos, Span};
 
 use crate::{
+    get_children_codegen::get_children,
     parser::Parser,
-    pg_query_utils_generated::get_children,
+    resolve_locations::resolve_locations,
     syntax_kind_codegen::SyntaxKind,
     token_type::{
         get_token_type_from_pg_query_token, get_token_type_from_statement_token, TokenType,
@@ -94,7 +95,7 @@ impl Parser {
         };
 
         let mut pg_query_nodes = match &pg_query_root {
-            Some(root) => get_children(root, text.to_string(), 1)
+            Some(root) => resolve_locations(get_children(root, text.to_string(), 1), text)
                 .into_iter()
                 .peekable(),
             None => Vec::new().into_iter().peekable(),

From 48ce90177c31e4cd7e5c69c0469513a7d4428178 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Sun, 3 Sep 2023 21:43:58 +0200
Subject: [PATCH 19/23] feat: add snapshot tests

---
 Cargo.toml                                    |   3 +
 crates/parser/Cargo.toml                      |   3 +
 crates/parser/src/parser.rs                   |  14 ++-
 crates/parser/src/statement.rs                |  34 +----
 crates/parser/src/token_type.rs               | 116 +++++++++---------
 crates/parser/tests/common/mod.rs             |   3 +
 .../data/source_file}/valid/0001.sql          |   0
 .../data}/statements/valid/0001.sql           |   0
 .../data}/statements/valid/0002.sql           |   0
 .../data}/statements/valid/0003.sql           |   0
 .../data}/statements/valid/0004.sql           |   0
 .../data}/statements/valid/0005.sql           |   0
 .../data}/statements/valid/0006.sql           |   0
 .../data}/statements/valid/0007.sql           |   0
 .../data}/statements/valid/0008.sql           |   0
 .../data}/statements/valid/0009.sql           |   0
 .../data}/statements/valid/0010.sql           |   0
 .../data}/statements/valid/0011.sql           |   0
 .../data}/statements/valid/0012.sql           |   0
 .../data}/statements/valid/0013.sql           |   0
 .../data}/statements/valid/0014.sql           |   0
 .../data}/statements/valid/0015.sql           |   0
 .../data}/statements/valid/0016.sql           |   0
 .../data}/statements/valid/0017.sql           |   0
 .../data}/statements/valid/0018.sql           |   0
 .../data}/statements/valid/0019.sql           |   0
 .../data}/statements/valid/0020.sql           |   0
 .../data}/statements/valid/0021.sql           |   0
 .../data}/statements/valid/0022.sql           |   0
 .../data}/statements/valid/0023.sql           |   0
 .../data}/statements/valid/0024.sql           |   0
 .../data}/statements/valid/0025.sql           |   0
 .../data}/statements/valid/0026.sql           |   0
 .../data}/statements/valid/0027.sql           |   0
 .../data}/statements/valid/0028.sql           |   0
 .../data}/statements/valid/0029.sql           |   0
 .../data}/statements/valid/0030.sql           |   0
 .../data}/statements/valid/0031.sql           |   0
 .../data}/statements/valid/0032.sql           |   0
 .../data}/statements/valid/0033.sql           |   0
 .../data}/statements/valid/0034.sql           |   0
 .../data}/statements/valid/0035.sql           |   0
 .../data}/statements/valid/0036.sql           |   0
 .../snapshots/statements/valid/0001.snap      |  52 ++++++++
 .../snapshots/statements/valid/0002.snap      |  16 +++
 .../snapshots/statements/valid/0003.snap      |  62 ++++++++++
 .../snapshots/statements/valid/0004.snap      |  63 ++++++++++
 crates/parser/tests/statement_parser_test.rs  |  46 +++++++
 48 files changed, 323 insertions(+), 89 deletions(-)
 create mode 100644 crates/parser/tests/common/mod.rs
 rename crates/parser/{test_data/source => tests/data/source_file}/valid/0001.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0001.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0002.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0003.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0004.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0005.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0006.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0007.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0008.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0009.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0010.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0011.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0012.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0013.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0014.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0015.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0016.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0017.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0018.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0019.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0020.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0021.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0022.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0023.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0024.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0025.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0026.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0027.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0028.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0029.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0030.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0031.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0032.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0033.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0034.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0035.sql (100%)
 rename crates/parser/{test_data => tests/data}/statements/valid/0036.sql (100%)
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0001.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0002.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0003.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0004.snap
 create mode 100644 crates/parser/tests/statement_parser_test.rs

diff --git a/Cargo.toml b/Cargo.toml
index 7d0341f8..3a62c717 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,4 +10,7 @@ sourcegen = { path = "./crates/sourcegen", version = "0.0.0" }
 pg_query_proto_parser = { path = "./crates/pg_query_proto_parser", version = "0.0.0" }
 triomphe = { version = "0.1.8", default-features = false, features = ["std"] }
 
+[profile.dev.package]
+insta.opt-level = 3
+similar.opt-level = 3
 
diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml
index 5ff79d95..be917fe3 100644
--- a/crates/parser/Cargo.toml
+++ b/crates/parser/Cargo.toml
@@ -17,3 +17,6 @@ log = { version = "0.4.20" }
 
 codegen.workspace = true
 pg_query_proto_parser.workspace = true
+
+[dev-dependencies]
+insta = "1.31.0"
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index ab0425ae..7c925924 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -2,6 +2,7 @@ use std::collections::VecDeque;
 
 use cstree::syntax::ResolvedNode;
 use cstree::{build::GreenNodeBuilder, text::TextRange};
+use log::debug;
 use pg_query::NodeEnum;
 
 use crate::ast_node::RawStmt;
@@ -60,6 +61,7 @@ impl Parser {
 
     /// close all nodes until the specified depth is reached
     pub fn close_until_depth(&mut self, depth: i32) {
+        debug!("close until depth {}", depth);
         if self.open_nodes.is_empty() || self.get_current_depth() < depth {
             return;
         }
@@ -105,19 +107,20 @@ impl Parser {
     /// handles closing previous nodes if necessary
     /// and consumes token buffer before starting new node
     pub fn start_node_at(&mut self, kind: SyntaxKind, depth: i32) {
+        debug!("starting node at depth {} {:?}", depth, kind);
         // close until target depth
         self.close_until_depth(depth);
 
         self.consume_token_buffer(None);
 
         self.open_nodes.push((kind, depth));
+        debug!("start node {:?}", kind);
         self.inner.start_node(kind);
     }
 
     /// Applies closing sibling for open tokens at current depth
-    ///
-    /// FIXME: find closing token in token buffer, instead of just comparing with the first one
     fn consume_open_tokens(&mut self) {
+        debug!("consume open tokens");
         if self.open_tokens.is_empty() || self.token_buffer.is_empty() {
             return;
         }
@@ -149,6 +152,7 @@ impl Parser {
     /// finish current node
     /// applies all open tokens of current depth before
     pub fn finish_node(&mut self) {
+        debug!("finish_node");
         self.consume_open_tokens();
 
         let n = self.open_nodes.pop();
@@ -156,11 +160,13 @@ impl Parser {
             panic!("No node to finish");
         }
 
+        debug!("finish node {:?}", n.unwrap().0);
         self.inner.finish_node();
     }
 
     /// Drains the token buffer and applies all tokens
     pub fn consume_token_buffer(&mut self, until: Option<u32>) {
+        debug!("consume_token_buffer");
         if self.token_buffer.is_empty() {
             return;
         }
@@ -176,6 +182,7 @@ impl Parser {
     /// Applies token immediately
     /// if token is opening sibling, adds it to open tokens
     fn apply_token(&mut self, kind: SyntaxKind, text: &str) {
+        debug!("apply_token {:?} {:?}", kind, text);
         self.inner.token(kind, text);
         if kind.is_opening_sibling() {
             let depth = self.get_current_depth();
@@ -190,7 +197,9 @@ impl Parser {
     ///
     /// if `is_parsing_flat_node` is true, applies token immediately
     pub fn token(&mut self, kind: SyntaxKind, text: &str, token_type: Option<TokenType>) {
+        debug!("token {:?} {:?} {:?}", kind, text, token_type);
         if self.is_parsing_flat_node {
+            debug!("apply token {:?} {:?}", kind, text);
             self.inner.token(kind, text);
             return;
         }
@@ -200,6 +209,7 @@ impl Parser {
                 // move up to depth 2 and consume buffered tokens before applying closing token
                 self.close_until_depth(2);
                 self.consume_token_buffer(None);
+                debug!("apply token {:?} {:?}", kind, text);
                 self.inner.token(kind, text);
             }
             Some(TokenType::Follow) => {
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index e67e4933..565221da 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -94,6 +94,8 @@ impl Parser {
             }
         };
 
+        println!("pg_query_root: {:?}", pg_query_root);
+
         let mut pg_query_nodes = match &pg_query_root {
             Some(root) => resolve_locations(get_children(root, text.to_string(), 1), text)
                 .into_iter()
@@ -228,6 +230,8 @@ mod tests {
         parser.parse_statement(&input, None);
         let parsed = parser.finish();
 
+        let out = format!("{:#?}", parsed.cst);
+
         if log_enabled!(log::Level::Debug) {
             dbg!(&parsed.cst);
         }
@@ -241,36 +245,6 @@ mod tests {
         test_valid_stmt("simple_statement".to_string(), "select 1;".to_string());
     }
 
-    #[test]
-    fn test_temp() {
-        init();
-        let token = pg_query::scan(
-            "select coalesce(id, two) as id from contact;"
-                .to_string()
-                .as_str(),
-        )
-        .unwrap();
-        dbg!(token);
-    }
-
-    #[test]
-    fn test_valid_statements() {
-        init();
-        let mut paths: Vec<_> = fs::read_dir(VALID_STATEMENTS_PATH)
-            .unwrap()
-            .map(|r| r.unwrap())
-            .collect();
-        paths.sort_by_key(|dir| dir.path());
-
-        paths.iter().for_each(|f| {
-            let path = f.path();
-
-            let contents = fs::read_to_string(&path).unwrap();
-
-            test_valid_stmt(path.to_str().unwrap().to_string(), contents);
-        });
-    }
-
     #[test]
     fn test_invalid_statement() {
         let input = "select select;";
diff --git a/crates/parser/src/token_type.rs b/crates/parser/src/token_type.rs
index 66a1ce2e..23774f28 100644
--- a/crates/parser/src/token_type.rs
+++ b/crates/parser/src/token_type.rs
@@ -1,8 +1,8 @@
 use pg_query::protobuf::ScanToken;
 
 use crate::statement::StatementToken;
+use crate::syntax_kind_codegen::SyntaxKind;
 
-///
 ///  Kind of a `SyntaxKind`
 ///  This is the only manual definition required for properly creating a concrete
 /// syntax tree.
@@ -44,66 +44,68 @@ pub fn get_token_type_from_statement_token(token: &StatementToken) -> Option<Tok
     }
 }
 
+// Returns the token type of a `ScanToken` from the `pg_query` crate.
+//
+// converts the token to a `SyntaxKind` for better readability.
 pub fn get_token_type_from_pg_query_token(token: &ScanToken) -> Option<TokenType> {
+    println!("token: {:?}", token);
+
     let r = match token.keyword_kind() {
-        pg_query::protobuf::KeywordKind::NoKeyword => match token.token {
-            37 => Some(TokenType::Follow),
-            40 => Some(TokenType::Follow),
-            41 => Some(TokenType::Follow),
-            42 => Some(TokenType::Follow),
-            43 => Some(TokenType::Follow),
-            44 => Some(TokenType::Follow),
-            45 => Some(TokenType::Follow),
-            46 => Some(TokenType::Follow),
-            47 => Some(TokenType::Follow),
-            58 => Some(TokenType::Follow),
-            // ";"
-            59 => Some(TokenType::Close),
-            60 => Some(TokenType::Follow),
-            61 => Some(TokenType::Follow),
-            62 => Some(TokenType::Follow),
-            63 => Some(TokenType::Follow),
-            // 91 => Some(TokenType::Follow),
-            92 => Some(TokenType::Follow),
-            93 => Some(TokenType::Follow),
-            94 => Some(TokenType::Follow),
-            // NotEquals
-            274 => Some(TokenType::Follow),
-            _ => None,
-        },
-        pg_query::protobuf::KeywordKind::UnreservedKeyword => match token.token {
-            // AddP
-            281 => Some(TokenType::Follow),
-            // Update
-            695 => Some(TokenType::Follow),
-            _ => None,
-        },
+        pg_query::protobuf::KeywordKind::NoKeyword => {
+            match SyntaxKind::new_from_pg_query_token(token) {
+                SyntaxKind::Ascii37 => Some(TokenType::Follow),
+                SyntaxKind::Ascii40 => Some(TokenType::Follow),
+                SyntaxKind::Ascii41 => Some(TokenType::Follow),
+                SyntaxKind::Ascii42 => Some(TokenType::Follow),
+                SyntaxKind::Ascii43 => Some(TokenType::Follow),
+                SyntaxKind::Ascii44 => Some(TokenType::Follow),
+                SyntaxKind::Ascii45 => Some(TokenType::Follow),
+                SyntaxKind::Ascii46 => Some(TokenType::Follow),
+                SyntaxKind::Ascii47 => Some(TokenType::Follow),
+                SyntaxKind::Ascii58 => Some(TokenType::Follow),
+                // ";"
+                SyntaxKind::Ascii59 => Some(TokenType::Close),
+                SyntaxKind::Ascii60 => Some(TokenType::Follow),
+                SyntaxKind::Ascii61 => Some(TokenType::Follow),
+                SyntaxKind::Ascii62 => Some(TokenType::Follow),
+                SyntaxKind::Ascii63 => Some(TokenType::Follow),
+                SyntaxKind::Ascii92 => Some(TokenType::Follow),
+                SyntaxKind::Ascii93 => Some(TokenType::Follow),
+                SyntaxKind::Ascii94 => Some(TokenType::Follow),
+                SyntaxKind::NotEquals => Some(TokenType::Follow),
+                SyntaxKind::Sconst => Some(TokenType::Follow),
+                _ => None,
+            }
+        }
+        pg_query::protobuf::KeywordKind::UnreservedKeyword => {
+            match SyntaxKind::new_from_pg_query_token(token) {
+                SyntaxKind::AddP => Some(TokenType::Follow),
+                SyntaxKind::Update => Some(TokenType::Follow),
+                SyntaxKind::By => Some(TokenType::Follow),
+                _ => None,
+            }
+        }
         pg_query::protobuf::KeywordKind::ColNameKeyword => None,
         pg_query::protobuf::KeywordKind::TypeFuncNameKeyword => None,
-        pg_query::protobuf::KeywordKind::ReservedKeyword => match token.token {
-            // And
-            291 => Some(TokenType::Follow),
-            // Check
-            328 => Some(TokenType::Follow),
-            // End
-            401 => Some(TokenType::Follow),
-            // For
-            424 => Some(TokenType::Follow),
-            // From
-            429 => Some(TokenType::Follow),
-            // InP
-            453 => Some(TokenType::Follow),
-            543 => Some(TokenType::Follow),
-            // Then
-            669 => Some(TokenType::Follow),
-            673 => Some(TokenType::Follow),
-            697 => Some(TokenType::Follow),
-            // Where
-            713 => Some(TokenType::Follow),
-            // With
-            716 => Some(TokenType::Follow),
-            _ => None,
-        },
+        pg_query::protobuf::KeywordKind::ReservedKeyword => {
+            match SyntaxKind::new_from_pg_query_token(token) {
+                SyntaxKind::And => Some(TokenType::Follow),
+                SyntaxKind::Check => Some(TokenType::Follow),
+                SyntaxKind::EndP => Some(TokenType::Follow),
+                SyntaxKind::For => Some(TokenType::Follow),
+                SyntaxKind::From => Some(TokenType::Follow),
+                SyntaxKind::InP => Some(TokenType::Follow),
+                SyntaxKind::On => Some(TokenType::Follow),
+                SyntaxKind::Then => Some(TokenType::Follow),
+                SyntaxKind::To => Some(TokenType::Follow),
+                SyntaxKind::Using => Some(TokenType::Follow),
+                SyntaxKind::Where => Some(TokenType::Follow),
+                SyntaxKind::With => Some(TokenType::Follow),
+                SyntaxKind::GroupP => Some(TokenType::Follow),
+                SyntaxKind::As => Some(TokenType::Follow),
+                _ => None,
+            }
+        }
     };
     r
 }
diff --git a/crates/parser/tests/common/mod.rs b/crates/parser/tests/common/mod.rs
new file mode 100644
index 00000000..af191dab
--- /dev/null
+++ b/crates/parser/tests/common/mod.rs
@@ -0,0 +1,3 @@
+pub fn setup() {
+    let _ = env_logger::builder().is_test(true).try_init();
+}
diff --git a/crates/parser/test_data/source/valid/0001.sql b/crates/parser/tests/data/source_file/valid/0001.sql
similarity index 100%
rename from crates/parser/test_data/source/valid/0001.sql
rename to crates/parser/tests/data/source_file/valid/0001.sql
diff --git a/crates/parser/test_data/statements/valid/0001.sql b/crates/parser/tests/data/statements/valid/0001.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0001.sql
rename to crates/parser/tests/data/statements/valid/0001.sql
diff --git a/crates/parser/test_data/statements/valid/0002.sql b/crates/parser/tests/data/statements/valid/0002.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0002.sql
rename to crates/parser/tests/data/statements/valid/0002.sql
diff --git a/crates/parser/test_data/statements/valid/0003.sql b/crates/parser/tests/data/statements/valid/0003.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0003.sql
rename to crates/parser/tests/data/statements/valid/0003.sql
diff --git a/crates/parser/test_data/statements/valid/0004.sql b/crates/parser/tests/data/statements/valid/0004.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0004.sql
rename to crates/parser/tests/data/statements/valid/0004.sql
diff --git a/crates/parser/test_data/statements/valid/0005.sql b/crates/parser/tests/data/statements/valid/0005.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0005.sql
rename to crates/parser/tests/data/statements/valid/0005.sql
diff --git a/crates/parser/test_data/statements/valid/0006.sql b/crates/parser/tests/data/statements/valid/0006.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0006.sql
rename to crates/parser/tests/data/statements/valid/0006.sql
diff --git a/crates/parser/test_data/statements/valid/0007.sql b/crates/parser/tests/data/statements/valid/0007.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0007.sql
rename to crates/parser/tests/data/statements/valid/0007.sql
diff --git a/crates/parser/test_data/statements/valid/0008.sql b/crates/parser/tests/data/statements/valid/0008.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0008.sql
rename to crates/parser/tests/data/statements/valid/0008.sql
diff --git a/crates/parser/test_data/statements/valid/0009.sql b/crates/parser/tests/data/statements/valid/0009.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0009.sql
rename to crates/parser/tests/data/statements/valid/0009.sql
diff --git a/crates/parser/test_data/statements/valid/0010.sql b/crates/parser/tests/data/statements/valid/0010.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0010.sql
rename to crates/parser/tests/data/statements/valid/0010.sql
diff --git a/crates/parser/test_data/statements/valid/0011.sql b/crates/parser/tests/data/statements/valid/0011.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0011.sql
rename to crates/parser/tests/data/statements/valid/0011.sql
diff --git a/crates/parser/test_data/statements/valid/0012.sql b/crates/parser/tests/data/statements/valid/0012.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0012.sql
rename to crates/parser/tests/data/statements/valid/0012.sql
diff --git a/crates/parser/test_data/statements/valid/0013.sql b/crates/parser/tests/data/statements/valid/0013.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0013.sql
rename to crates/parser/tests/data/statements/valid/0013.sql
diff --git a/crates/parser/test_data/statements/valid/0014.sql b/crates/parser/tests/data/statements/valid/0014.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0014.sql
rename to crates/parser/tests/data/statements/valid/0014.sql
diff --git a/crates/parser/test_data/statements/valid/0015.sql b/crates/parser/tests/data/statements/valid/0015.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0015.sql
rename to crates/parser/tests/data/statements/valid/0015.sql
diff --git a/crates/parser/test_data/statements/valid/0016.sql b/crates/parser/tests/data/statements/valid/0016.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0016.sql
rename to crates/parser/tests/data/statements/valid/0016.sql
diff --git a/crates/parser/test_data/statements/valid/0017.sql b/crates/parser/tests/data/statements/valid/0017.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0017.sql
rename to crates/parser/tests/data/statements/valid/0017.sql
diff --git a/crates/parser/test_data/statements/valid/0018.sql b/crates/parser/tests/data/statements/valid/0018.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0018.sql
rename to crates/parser/tests/data/statements/valid/0018.sql
diff --git a/crates/parser/test_data/statements/valid/0019.sql b/crates/parser/tests/data/statements/valid/0019.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0019.sql
rename to crates/parser/tests/data/statements/valid/0019.sql
diff --git a/crates/parser/test_data/statements/valid/0020.sql b/crates/parser/tests/data/statements/valid/0020.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0020.sql
rename to crates/parser/tests/data/statements/valid/0020.sql
diff --git a/crates/parser/test_data/statements/valid/0021.sql b/crates/parser/tests/data/statements/valid/0021.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0021.sql
rename to crates/parser/tests/data/statements/valid/0021.sql
diff --git a/crates/parser/test_data/statements/valid/0022.sql b/crates/parser/tests/data/statements/valid/0022.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0022.sql
rename to crates/parser/tests/data/statements/valid/0022.sql
diff --git a/crates/parser/test_data/statements/valid/0023.sql b/crates/parser/tests/data/statements/valid/0023.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0023.sql
rename to crates/parser/tests/data/statements/valid/0023.sql
diff --git a/crates/parser/test_data/statements/valid/0024.sql b/crates/parser/tests/data/statements/valid/0024.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0024.sql
rename to crates/parser/tests/data/statements/valid/0024.sql
diff --git a/crates/parser/test_data/statements/valid/0025.sql b/crates/parser/tests/data/statements/valid/0025.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0025.sql
rename to crates/parser/tests/data/statements/valid/0025.sql
diff --git a/crates/parser/test_data/statements/valid/0026.sql b/crates/parser/tests/data/statements/valid/0026.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0026.sql
rename to crates/parser/tests/data/statements/valid/0026.sql
diff --git a/crates/parser/test_data/statements/valid/0027.sql b/crates/parser/tests/data/statements/valid/0027.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0027.sql
rename to crates/parser/tests/data/statements/valid/0027.sql
diff --git a/crates/parser/test_data/statements/valid/0028.sql b/crates/parser/tests/data/statements/valid/0028.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0028.sql
rename to crates/parser/tests/data/statements/valid/0028.sql
diff --git a/crates/parser/test_data/statements/valid/0029.sql b/crates/parser/tests/data/statements/valid/0029.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0029.sql
rename to crates/parser/tests/data/statements/valid/0029.sql
diff --git a/crates/parser/test_data/statements/valid/0030.sql b/crates/parser/tests/data/statements/valid/0030.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0030.sql
rename to crates/parser/tests/data/statements/valid/0030.sql
diff --git a/crates/parser/test_data/statements/valid/0031.sql b/crates/parser/tests/data/statements/valid/0031.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0031.sql
rename to crates/parser/tests/data/statements/valid/0031.sql
diff --git a/crates/parser/test_data/statements/valid/0032.sql b/crates/parser/tests/data/statements/valid/0032.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0032.sql
rename to crates/parser/tests/data/statements/valid/0032.sql
diff --git a/crates/parser/test_data/statements/valid/0033.sql b/crates/parser/tests/data/statements/valid/0033.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0033.sql
rename to crates/parser/tests/data/statements/valid/0033.sql
diff --git a/crates/parser/test_data/statements/valid/0034.sql b/crates/parser/tests/data/statements/valid/0034.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0034.sql
rename to crates/parser/tests/data/statements/valid/0034.sql
diff --git a/crates/parser/test_data/statements/valid/0035.sql b/crates/parser/tests/data/statements/valid/0035.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0035.sql
rename to crates/parser/tests/data/statements/valid/0035.sql
diff --git a/crates/parser/test_data/statements/valid/0036.sql b/crates/parser/tests/data/statements/valid/0036.sql
similarity index 100%
rename from crates/parser/test_data/statements/valid/0036.sql
rename to crates/parser/tests/data/statements/valid/0036.sql
diff --git a/crates/parser/tests/snapshots/statements/valid/0001.snap b/crates/parser/tests/snapshots/statements/valid/0001.snap
new file mode 100644
index 00000000..ed195ee2
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0001.snap
@@ -0,0 +1,52 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT city, count(*) FILTER (WHERE temp_lo < 45), max(temp_lo)\n    FROM weather\n    GROUP BY city;\n"
+---
+SelectStmt@0..100
+  Select@0..6 "SELECT"
+  Whitespace@6..7 " "
+  ResTarget@7..11
+    Ident@7..11 "city"
+  Ascii44@11..12 ","
+  Whitespace@12..13 " "
+  ResTarget@13..49
+    Ident@13..18 "count"
+    Ascii40@18..19 "("
+    Ascii42@19..20 "*"
+    Ascii41@20..21 ")"
+    Whitespace@21..22 " "
+    Filter@22..28 "FILTER"
+    Whitespace@28..29 " "
+    Ascii40@29..30 "("
+    Where@30..35 "WHERE"
+    Whitespace@35..36 " "
+    Ident@36..43 "temp_lo"
+    Whitespace@43..44 " "
+    Ascii60@44..45 "<"
+    Whitespace@45..46 " "
+    Iconst@46..48 "45"
+    Ascii41@48..49 ")"
+  Ascii44@49..50 ","
+  Whitespace@50..51 " "
+  ResTarget@51..63
+    Ident@51..54 "max"
+    Ascii40@54..55 "("
+    Ident@55..62 "temp_lo"
+    Ascii41@62..63 ")"
+  Newline@63..64 "\n"
+  Whitespace@64..68 "    "
+  From@68..72 "FROM"
+  Whitespace@72..73 " "
+  RangeVar@73..80
+    Ident@73..80 "weather"
+  Newline@80..81 "\n"
+  Whitespace@81..85 "    "
+  GroupP@85..90 "GROUP"
+  Whitespace@90..91 " "
+  By@91..93 "BY"
+  Whitespace@93..94 " "
+  ColumnRef@94..98
+    Ident@94..98 "city"
+  Ascii59@98..99 ";"
+  Newline@99..100 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0002.snap b/crates/parser/tests/snapshots/statements/valid/0002.snap
new file mode 100644
index 00000000..14f73259
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0002.snap
@@ -0,0 +1,16 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "COPY weather FROM '/home/user/weather.txt';\n"
+---
+CopyStmt@0..44
+  Copy@0..4 "COPY"
+  Whitespace@4..5 " "
+  RangeVar@5..12
+    Ident@5..12 "weather"
+  Whitespace@12..13 " "
+  From@13..17 "FROM"
+  Whitespace@17..18 " "
+  Sconst@18..42 "'/home/user/weather.txt'"
+  Ascii59@42..43 ";"
+  Newline@43..44 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0003.snap b/crates/parser/tests/snapshots/statements/valid/0003.snap
new file mode 100644
index 00000000..52a0329a
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0003.snap
@@ -0,0 +1,62 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE TABLE weather (\n        city      varchar(80) references cities(name),\n        temp_lo   int,\n        temp_hi   int,\n        prcp      real,\n        date      date\n);\n"
+---
+CreateStmt@0..174
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Table@7..12 "TABLE"
+  Whitespace@12..13 " "
+  RangeVar@13..20
+    Ident@13..20 "weather"
+  Whitespace@20..21 " "
+  Ascii40@21..22 "("
+  Newline@22..23 "\n"
+  Whitespace@23..31 "        "
+  ColumnDef@31..76
+    Ident@31..35 "city"
+    Whitespace@35..41 "      "
+    Varchar@41..48 "varchar"
+    Ascii40@48..49 "("
+    Iconst@49..51 "80"
+    Ascii41@51..52 ")"
+    Whitespace@52..53 " "
+    References@53..63 "references"
+    Whitespace@63..64 " "
+    Ident@64..70 "cities"
+    Ascii40@70..71 "("
+    NameP@71..75 "name"
+    Ascii41@75..76 ")"
+  Ascii44@76..77 ","
+  Newline@77..78 "\n"
+  Whitespace@78..86 "        "
+  ColumnDef@86..99
+    Ident@86..93 "temp_lo"
+    Whitespace@93..96 "   "
+    IntP@96..99 "int"
+  Ascii44@99..100 ","
+  Newline@100..101 "\n"
+  Whitespace@101..109 "        "
+  ColumnDef@109..122
+    Ident@109..116 "temp_hi"
+    Whitespace@116..119 "   "
+    IntP@119..122 "int"
+  Ascii44@122..123 ","
+  Newline@123..124 "\n"
+  Whitespace@124..132 "        "
+  ColumnDef@132..146
+    Ident@132..136 "prcp"
+    Whitespace@136..142 "      "
+    Real@142..146 "real"
+  Ascii44@146..147 ","
+  Newline@147..148 "\n"
+  Whitespace@148..156 "        "
+  ColumnDef@156..172
+    Ident@156..160 "date"
+    Whitespace@160..166 "      "
+    Ident@166..170 "date"
+    Newline@170..171 "\n"
+    Ascii41@171..172 ")"
+  Ascii59@172..173 ";"
+  Newline@173..174 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0004.snap b/crates/parser/tests/snapshots/statements/valid/0004.snap
new file mode 100644
index 00000000..bdfbe342
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0004.snap
@@ -0,0 +1,63 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE VIEW myview AS\n    SELECT name, temp_lo, temp_hi, prcp, date, location\n        FROM weather, cities\n        WHERE city = name;\n"
+---
+ViewStmt@0..134
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  View@7..11 "VIEW"
+  Whitespace@11..12 " "
+  RangeVar@12..18
+    Ident@12..18 "myview"
+  Whitespace@18..19 " "
+  As@19..21 "AS"
+  Newline@21..22 "\n"
+  Whitespace@22..26 "    "
+  SelectStmt@26..132
+    Select@26..32 "SELECT"
+    Whitespace@32..33 " "
+    ResTarget@33..37
+      NameP@33..37 "name"
+    Ascii44@37..38 ","
+    Whitespace@38..39 " "
+    ResTarget@39..46
+      Ident@39..46 "temp_lo"
+    Ascii44@46..47 ","
+    Whitespace@47..48 " "
+    ResTarget@48..55
+      Ident@48..55 "temp_hi"
+    Ascii44@55..56 ","
+    Whitespace@56..57 " "
+    ResTarget@57..61
+      Ident@57..61 "prcp"
+    Ascii44@61..62 ","
+    Whitespace@62..63 " "
+    ResTarget@63..67
+      Ident@63..67 "date"
+    Ascii44@67..68 ","
+    Whitespace@68..69 " "
+    ResTarget@69..77
+      Location@69..77 "location"
+    Newline@77..78 "\n"
+    Whitespace@78..86 "        "
+    From@86..90 "FROM"
+    Whitespace@90..91 " "
+    RangeVar@91..98
+      Ident@91..98 "weather"
+    Ascii44@98..99 ","
+    Whitespace@99..100 " "
+    RangeVar@100..106
+      Ident@100..106 "cities"
+    Newline@106..107 "\n"
+    Whitespace@107..115 "        "
+    Where@115..120 "WHERE"
+    Whitespace@120..121 " "
+    AExpr@121..132
+      Ident@121..125 "city"
+      Whitespace@125..126 " "
+      Ascii61@126..127 "="
+      Whitespace@127..128 " "
+      NameP@128..132 "name"
+  Ascii59@132..133 ";"
+  Newline@133..134 "\n"
+
diff --git a/crates/parser/tests/statement_parser_test.rs b/crates/parser/tests/statement_parser_test.rs
new file mode 100644
index 00000000..73c1eeca
--- /dev/null
+++ b/crates/parser/tests/statement_parser_test.rs
@@ -0,0 +1,46 @@
+use std::assert_eq;
+use std::fs;
+mod common;
+use insta;
+use parser::Parser;
+
+const VALID_STATEMENTS_PATH: &str = "tests/data/statements/valid/";
+
+#[test]
+fn valid_statements() {
+    common::setup();
+
+    let mut paths: Vec<_> = fs::read_dir(VALID_STATEMENTS_PATH)
+        .unwrap()
+        .map(|r| r.unwrap())
+        .collect();
+    paths.sort_by_key(|dir| dir.path());
+
+    paths.iter().for_each(|f| {
+        let path = f.path();
+
+        let contents = fs::read_to_string(&path).unwrap();
+
+        let mut parser = Parser::new();
+        parser.parse_statement(&contents, None);
+        let parsed = parser.finish();
+
+        let file_name = path.file_name().unwrap();
+        let test_name = file_name.to_str().unwrap().replace(".sql", "");
+
+        let mut settings = insta::Settings::clone_current();
+        settings.set_input_file(path);
+        settings.set_prepend_module_to_snapshot(false);
+        settings.set_description(contents);
+        settings.set_omit_expression(true);
+        settings.set_snapshot_path("snapshots/statements/valid");
+        settings.bind(|| {
+            insta::assert_debug_snapshot!(test_name, &parsed.cst);
+        });
+    });
+}
+
+#[test]
+fn invalid_statements() {
+    assert_eq!(4, 2);
+}

From 228b039f7603f51f526bf3123503b81accd73c72 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Mon, 4 Sep 2023 22:42:15 +0200
Subject: [PATCH 20/23] refactor: parse flat cst only. deep cst progress is
 saved on other branch

---
 crates/codegen/src/syntax_kind.rs             |  36 +-
 crates/parser/src/get_children_codegen.rs     |  30 -
 crates/parser/src/get_location_codegen.rs     |   3 -
 crates/parser/src/lib.rs                      |   4 -
 crates/parser/src/parser.rs                   | 112 +---
 crates/parser/src/resolve_locations.rs        | 527 ------------------
 crates/parser/src/source_file.rs              |   4 +-
 crates/parser/src/statement.rs                |  82 +--
 crates/parser/src/token_type.rs               | 111 ----
 .../snapshots/statements/valid/0001.snap      |  51 +-
 .../snapshots/statements/valid/0002.snap      |   3 +-
 .../snapshots/statements/valid/0003.snap      |  62 +--
 .../snapshots/statements/valid/0004.snap      |  83 ++-
 .../snapshots/statements/valid/0005.snap      |  21 +
 .../snapshots/statements/valid/0006.snap      |  13 +
 .../snapshots/statements/valid/0007.snap      |  36 ++
 .../snapshots/statements/valid/0008.snap      |  42 ++
 .../snapshots/statements/valid/0009.snap      |  93 ++++
 .../snapshots/statements/valid/0010.snap      |  31 ++
 .../snapshots/statements/valid/0011.snap      |  25 +
 .../snapshots/statements/valid/0012.snap      |  52 ++
 .../snapshots/statements/valid/0013.snap      |  44 ++
 .../snapshots/statements/valid/0014.snap      |  56 ++
 .../snapshots/statements/valid/0015.snap      |  58 ++
 .../snapshots/statements/valid/0016.snap      |  27 +
 .../snapshots/statements/valid/0017.snap      |  42 ++
 .../snapshots/statements/valid/0018.snap      |  22 +
 .../snapshots/statements/valid/0019.snap      |  42 ++
 .../snapshots/statements/valid/0020.snap      |  48 ++
 .../snapshots/statements/valid/0021.snap      |  32 ++
 .../snapshots/statements/valid/0022.snap      |  38 ++
 .../snapshots/statements/valid/0023.snap      |  72 +++
 .../snapshots/statements/valid/0024.snap      |  55 ++
 .../snapshots/statements/valid/0025.snap      |  25 +
 .../snapshots/statements/valid/0026.snap      |  28 +
 .../snapshots/statements/valid/0027.snap      |  19 +
 .../snapshots/statements/valid/0028.snap      |  19 +
 .../snapshots/statements/valid/0029.snap      |  30 +
 .../snapshots/statements/valid/0030.snap      |  32 ++
 .../snapshots/statements/valid/0031.snap      |  68 +++
 .../snapshots/statements/valid/0032.snap      |  17 +
 .../snapshots/statements/valid/0033.snap      |  58 ++
 .../snapshots/statements/valid/0034.snap      |  25 +
 .../snapshots/statements/valid/0035.snap      |  25 +
 .../snapshots/statements/valid/0036.snap      |  42 ++
 crates/parser/tests/statement_parser_test.rs  |  11 +-
 46 files changed, 1348 insertions(+), 1008 deletions(-)
 delete mode 100644 crates/parser/src/get_children_codegen.rs
 delete mode 100644 crates/parser/src/get_location_codegen.rs
 delete mode 100644 crates/parser/src/resolve_locations.rs
 delete mode 100644 crates/parser/src/token_type.rs
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0005.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0006.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0007.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0008.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0009.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0010.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0011.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0012.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0013.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0014.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0015.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0016.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0017.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0018.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0019.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0020.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0021.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0022.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0023.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0024.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0025.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0026.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0027.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0028.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0029.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0030.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0031.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0032.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0033.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0034.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0035.snap
 create mode 100644 crates/parser/tests/snapshots/statements/valid/0036.snap

diff --git a/crates/codegen/src/syntax_kind.rs b/crates/codegen/src/syntax_kind.rs
index 3ae6738b..76b9467f 100644
--- a/crates/codegen/src/syntax_kind.rs
+++ b/crates/codegen/src/syntax_kind.rs
@@ -8,21 +8,23 @@ pub fn syntax_kind_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStr
     let parser = ProtoParser::new("./libpg_query/protobuf/pg_query.proto");
     let proto_file = parser.parse();
 
-    let mut current_enum_names: HashSet<&str> = HashSet::new();
-
     let custom_node_names = custom_node_names();
     let custom_node_identifiers = custom_node_identifiers(&custom_node_names);
-    current_enum_names.extend(&custom_node_names);
 
-    let node_identifiers = node_identifiers(&proto_file.nodes, &current_enum_names);
-    current_enum_names.extend(node_names(&proto_file.nodes));
+    let node_identifiers = node_identifiers(&proto_file.nodes);
 
-    let token_identifiers = token_identifiers(&proto_file.tokens, &current_enum_names);
-    let token_value_literals = token_value_literals(&proto_file.tokens, &current_enum_names);
+    let token_identifiers = token_identifiers(&proto_file.tokens);
+    let token_value_literals = token_value_literals(&proto_file.tokens);
 
     let syntax_kind_impl =
         syntax_kind_impl(&node_identifiers, &token_identifiers, &token_value_literals);
 
+    let mut enum_variants = HashSet::new();
+    enum_variants.extend(&custom_node_identifiers);
+    enum_variants.extend(&node_identifiers);
+    enum_variants.extend(&token_identifiers);
+    let unique_enum_variants = enum_variants.into_iter().collect::<Vec<_>>();
+
     quote! {
         use cstree::Syntax;
         use pg_query::{protobuf::ScanToken, NodeEnum, NodeRef};
@@ -33,10 +35,7 @@ pub fn syntax_kind_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStr
         #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Syntax)]
         #[repr(u32)]
         pub enum SyntaxKind {
-            // custom nodes, which are not parsed by pg_query.rs
-            #(#custom_node_identifiers),*,
-            #(#node_identifiers),*,
-            #(#token_identifiers),*,
+            #(#unique_enum_variants),*,
         }
 
         #syntax_kind_impl
@@ -54,10 +53,6 @@ fn custom_node_names() -> Vec<&'static str> {
     ]
 }
 
-fn node_names(nodes: &[Node]) -> impl Iterator<Item = &str> {
-    nodes.iter().map(|node| node.name.as_str())
-}
-
 fn custom_node_identifiers(custom_node_names: &[&str]) -> Vec<Ident> {
     custom_node_names
         .iter()
@@ -65,26 +60,23 @@ fn custom_node_identifiers(custom_node_names: &[&str]) -> Vec<Ident> {
         .collect()
 }
 
-fn node_identifiers(nodes: &[Node], existing_enum_names: &HashSet<&str>) -> Vec<Ident> {
+fn node_identifiers(nodes: &[Node]) -> Vec<Ident> {
     nodes
         .iter()
-        .filter(|&token| !existing_enum_names.contains(token.name.as_str()))
         .map(|node| format_ident!("{}", &node.name))
         .collect()
 }
 
-fn token_identifiers(tokens: &[Token], existing_enum_names: &HashSet<&str>) -> Vec<Ident> {
+fn token_identifiers(tokens: &[Token]) -> Vec<Ident> {
     tokens
         .iter()
-        .filter(|&token| !existing_enum_names.contains(token.name.as_str()))
         .map(|token| format_ident!("{}", &token.name))
         .collect()
 }
 
-fn token_value_literals(tokens: &[Token], existing_enum_names: &HashSet<&str>) -> Vec<Literal> {
+fn token_value_literals(tokens: &[Token]) -> Vec<Literal> {
     tokens
         .iter()
-        .filter(|&token| !existing_enum_names.contains(token.name.as_str()))
         .map(|token| Literal::i32_unsuffixed(token.value))
         .collect()
 }
@@ -126,7 +118,7 @@ fn new_from_pg_query_token_fn(
         pub fn new_from_pg_query_token(token: &ScanToken) -> Self {
             match token.token {
                 #(#token_value_literals => SyntaxKind::#token_identifiers),*,
-                _ => panic!("Unknown token"),
+                _ => panic!("Unknown token: {:?}", token.token),
             }
         }
     }
diff --git a/crates/parser/src/get_children_codegen.rs b/crates/parser/src/get_children_codegen.rs
deleted file mode 100644
index 13b895f2..00000000
--- a/crates/parser/src/get_children_codegen.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-use codegen::get_children;
-
-get_children!();
-
-#[cfg(test)]
-mod tests {
-    use crate::get_children_codegen::get_children;
-
-    #[test]
-    fn test_get_children() {
-        let input = "with c as (insert into contact (id) values ('id')) select * from c;";
-
-        let pg_query_root = match pg_query::parse(input) {
-            Ok(parsed) => Some(
-                parsed
-                    .protobuf
-                    .nodes()
-                    .iter()
-                    .find(|n| n.1 == 1)
-                    .unwrap()
-                    .0
-                    .to_enum(),
-            ),
-            Err(_) => None,
-        };
-
-        let children = get_children(&pg_query_root.unwrap(), input.to_string(), 1);
-        assert_eq!(children.len(), 13);
-    }
-}
diff --git a/crates/parser/src/get_location_codegen.rs b/crates/parser/src/get_location_codegen.rs
deleted file mode 100644
index fcc6685d..00000000
--- a/crates/parser/src/get_location_codegen.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-use codegen::get_location;
-
-get_location!();
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index bc1ead7c..e871b2a5 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -16,17 +16,13 @@
 //! To see how these drawbacks are mitigated, see the `statement.rs` and the `source_file.rs` module.
 
 mod ast_node;
-mod get_children_codegen;
-mod get_location_codegen;
 mod parser;
-mod resolve_locations;
 mod sibling_token;
 mod source_file;
 mod statement;
 mod syntax_error;
 mod syntax_kind_codegen;
 mod syntax_node;
-mod token_type;
 
 pub use crate::parser::{Parse, Parser};
 pub use crate::syntax_kind_codegen::SyntaxKind;
diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs
index 7c925924..80219f8d 100644
--- a/crates/parser/src/parser.rs
+++ b/crates/parser/src/parser.rs
@@ -1,5 +1,3 @@
-use std::collections::VecDeque;
-
 use cstree::syntax::ResolvedNode;
 use cstree::{build::GreenNodeBuilder, text::TextRange};
 use log::debug;
@@ -9,15 +7,12 @@ use crate::ast_node::RawStmt;
 use crate::syntax_error::SyntaxError;
 use crate::syntax_kind_codegen::SyntaxKind;
 use crate::syntax_node::SyntaxNode;
-use crate::token_type::TokenType;
 
 /// Main parser that controls the cst building process, and collects errors and statements
 #[derive(Debug)]
 pub struct Parser {
     /// The cst builder
     inner: GreenNodeBuilder<'static, 'static, SyntaxKind>,
-    /// A buffer for tokens that are not yet applied to the cst
-    token_buffer: VecDeque<(SyntaxKind, String)>,
     /// The syntax errors accumulated during parsing
     errors: Vec<SyntaxError>,
     /// The pg_query statements representing the abtract syntax tree
@@ -29,9 +24,6 @@ pub struct Parser {
     /// Keeps track of currently open nodes
     /// Latest opened is last
     open_nodes: Vec<(SyntaxKind, i32)>,
-    /// Keeps track of currently open tokens (e.g. "(")
-    /// Latest opened is last
-    open_tokens: Vec<(SyntaxKind, String, i32)>,
 }
 
 /// Result of parsing
@@ -49,13 +41,11 @@ impl Parser {
     pub fn new() -> Self {
         Self {
             inner: GreenNodeBuilder::new(),
-            token_buffer: VecDeque::new(),
             errors: Vec::new(),
             stmts: Vec::new(),
             checkpoint: None,
             is_parsing_flat_node: false,
             open_nodes: Vec::new(),
-            open_tokens: Vec::new(),
         }
     }
 
@@ -80,22 +70,16 @@ impl Parser {
     /// set a checkpoint at current depth
     ///
     /// if `is_parsing_flat_node` is true, all tokens parsed until this checkpoint is closed will be applied immediately
-    pub fn set_checkpoint(&mut self, is_parsing_flat_node: bool) {
+    pub fn set_checkpoint(&mut self) {
         assert!(
             self.checkpoint.is_none(),
             "Must close previouos checkpoint before setting new one"
         );
-        assert!(
-            self.token_buffer.is_empty(),
-            "Token buffer must be empty before setting a checkpoint"
-        );
         self.checkpoint = Some(self.get_current_depth());
-        self.is_parsing_flat_node = is_parsing_flat_node;
     }
 
     /// close all nodes until checkpoint depth is reached
     pub fn close_checkpoint(&mut self) {
-        self.consume_token_buffer(None);
         if self.checkpoint.is_some() {
             self.close_until_depth(self.checkpoint.unwrap());
         }
@@ -105,55 +89,19 @@ impl Parser {
 
     /// start a new node of `SyntaxKind` at `depth`
     /// handles closing previous nodes if necessary
-    /// and consumes token buffer before starting new node
     pub fn start_node_at(&mut self, kind: SyntaxKind, depth: i32) {
         debug!("starting node at depth {} {:?}", depth, kind);
         // close until target depth
         self.close_until_depth(depth);
 
-        self.consume_token_buffer(None);
-
         self.open_nodes.push((kind, depth));
         debug!("start node {:?}", kind);
         self.inner.start_node(kind);
     }
 
-    /// Applies closing sibling for open tokens at current depth
-    fn consume_open_tokens(&mut self) {
-        debug!("consume open tokens");
-        if self.open_tokens.is_empty() || self.token_buffer.is_empty() {
-            return;
-        }
-        let depth = self.get_current_depth();
-        loop {
-            if self.open_tokens.is_empty() || self.token_buffer.is_empty() {
-                break;
-            }
-            let (token, _, token_depth) = self.open_tokens[self.open_tokens.len() - 1];
-            if token_depth != depth {
-                break;
-            }
-            // find closing token in token buffer
-            let closing_token_pos = self
-                .token_buffer
-                .iter()
-                .position(|t| t.0 == token.sibling().unwrap());
-            if closing_token_pos.is_none() {
-                break;
-            }
-            let closing_token_pos = closing_token_pos.unwrap();
-
-            // drain token buffer until closing token inclusively
-            self.open_tokens.pop();
-            self.consume_token_buffer(Some((closing_token_pos + 1) as u32));
-        }
-    }
-
     /// finish current node
-    /// applies all open tokens of current depth before
     pub fn finish_node(&mut self) {
         debug!("finish_node");
-        self.consume_open_tokens();
 
         let n = self.open_nodes.pop();
         if n.is_none() {
@@ -164,63 +112,9 @@ impl Parser {
         self.inner.finish_node();
     }
 
-    /// Drains the token buffer and applies all tokens
-    pub fn consume_token_buffer(&mut self, until: Option<u32>) {
-        debug!("consume_token_buffer");
-        if self.token_buffer.is_empty() {
-            return;
-        }
-        let range = match until {
-            Some(u) => 0..u as usize,
-            None => 0..self.token_buffer.len(),
-        };
-        for (kind, text) in self.token_buffer.drain(range).collect::<VecDeque<_>>() {
-            self.apply_token(kind, text.as_str());
-        }
-    }
-
-    /// Applies token immediately
-    /// if token is opening sibling, adds it to open tokens
-    fn apply_token(&mut self, kind: SyntaxKind, text: &str) {
-        debug!("apply_token {:?} {:?}", kind, text);
+    /// applies token
+    pub fn token(&mut self, kind: SyntaxKind, text: &str) {
         self.inner.token(kind, text);
-        if kind.is_opening_sibling() {
-            let depth = self.get_current_depth();
-            self.open_tokens.push((kind, text.to_string(), depth));
-        }
-    }
-
-    /// applies token based on its `SyntaxKindType`
-    /// if `SyntaxKindType::Close`, closes all nodes until depth 1
-    /// if `SyntaxKindType::Follow`, add token to buffer and wait until next node or non-Follow token to apply token at same depth
-    /// otherwise, applies token immediately
-    ///
-    /// if `is_parsing_flat_node` is true, applies token immediately
-    pub fn token(&mut self, kind: SyntaxKind, text: &str, token_type: Option<TokenType>) {
-        debug!("token {:?} {:?} {:?}", kind, text, token_type);
-        if self.is_parsing_flat_node {
-            debug!("apply token {:?} {:?}", kind, text);
-            self.inner.token(kind, text);
-            return;
-        }
-
-        match token_type {
-            Some(TokenType::Close) => {
-                // move up to depth 2 and consume buffered tokens before applying closing token
-                self.close_until_depth(2);
-                self.consume_token_buffer(None);
-                debug!("apply token {:?} {:?}", kind, text);
-                self.inner.token(kind, text);
-            }
-            Some(TokenType::Follow) => {
-                // wait until next node, and apply token at same depth
-                self.token_buffer.push_back((kind, text.to_string()));
-            }
-            _ => {
-                self.consume_token_buffer(None);
-                self.apply_token(kind, text);
-            }
-        }
     }
 
     /// collects an SyntaxError with an `error` message at `range`
diff --git a/crates/parser/src/resolve_locations.rs b/crates/parser/src/resolve_locations.rs
deleted file mode 100644
index 3ffa6104..00000000
--- a/crates/parser/src/resolve_locations.rs
+++ /dev/null
@@ -1,527 +0,0 @@
-//! Implements the `resolve_locations` function, which derives the location of a node if not set on
-//! the node itself.
-
-use crate::get_children_codegen::ChildrenNode;
-use crate::get_location_codegen::get_location;
-use pg_query::NodeEnum;
-use regex::Regex;
-use std::collections::VecDeque;
-
-#[derive(Debug, Clone)]
-pub struct NestedNode {
-    pub node: NodeEnum,
-    pub depth: i32,
-    pub location: i32,
-    pub path: String,
-}
-
-/// Resolves the location of `ChildrenNode`
-///
-/// Uses the `.location` property if available on the node, and otherwise tries to
-/// derive the location manually.
-pub fn resolve_locations(children: Vec<ChildrenNode>, text: &str) -> Vec<NestedNode> {
-    let mut nodes: Vec<NestedNode> = vec![];
-
-    let mut stack: VecDeque<ChildrenNode> = VecDeque::from(children);
-
-    while !stack.is_empty() {
-        let current_node = stack.pop_front().unwrap();
-
-        // if location is set, we can skip the rest
-        let location = get_location(&current_node.node);
-        if location.is_some() {
-            nodes.push(NestedNode {
-                node: current_node.node,
-                depth: current_node.depth,
-                location: location.unwrap(),
-                path: current_node.path.clone(),
-            });
-            continue;
-        }
-
-        // get parent node and its location
-        let parent_node = nodes.iter().find(|n| {
-            let mut path_elements = current_node.path.split(".").collect::<Vec<&str>>();
-            path_elements.pop();
-            let parent_path = path_elements.join(".");
-            n.path == parent_path
-        });
-
-        let parent_location = if parent_node.is_some() {
-            parent_node.unwrap().location
-        } else {
-            // fallback to 0 if no parent node is found
-            0
-        };
-
-        // we cannot assume that for each node, there is at least one child with a location.
-        // e.g. in `DROP TABLE tablename;`, the location of the `List` node that wraps the String node `tablename` is not known
-        let earliest_child_location = nodes
-            .iter()
-            .filter(|n| n.path.starts_with(current_node.path.as_str()))
-            .min_by(|a, b| a.location.cmp(&b.location))
-            .map(|n| n.location);
-
-        let location = derive_location(
-            &current_node.node,
-            text.clone(),
-            parent_location,
-            earliest_child_location,
-        );
-
-        if location.is_some() {
-            nodes.push(NestedNode {
-                node: current_node.node,
-                depth: current_node.depth,
-                location: location.unwrap(),
-                path: current_node.path.clone(),
-            });
-        } else if stack
-            .iter()
-            .find(|x| x.path.starts_with(current_node.path.as_str()))
-            .is_some()
-        {
-            // if there are still children to be processed, we push the node back to the stack and
-            // try again later in the hope that we could find the location for a children node of
-            // the current node
-            stack.push_back(current_node);
-        }
-    }
-
-    nodes
-}
-
-fn derive_location(
-    // The node to derive the location for
-    node: &NodeEnum,
-    // The full text of the query
-    text: &str,
-    // The location of the parent node
-    parent_location: i32,
-    // not given if node does not have any children
-    earliest_child_location: Option<i32>,
-) -> Option<i32> {
-    match node {
-        NodeEnum::Alias(_) => todo!(),
-        NodeEnum::RangeVar(_) => panic!("Node has location property."),
-        NodeEnum::TableFunc(_) => panic!("Node has location property."),
-        NodeEnum::Var(_) => panic!("Node has location property."),
-        NodeEnum::Param(_) => panic!("Node has location property."),
-        NodeEnum::Aggref(_) => panic!("Node has location property."),
-        NodeEnum::GroupingFunc(_) => panic!("Node has location property."),
-        NodeEnum::WindowFunc(_) => panic!("Node has location property."),
-        NodeEnum::SubscriptingRef(_) => todo!(),
-        NodeEnum::FuncExpr(_) => panic!("Node has location property."),
-        NodeEnum::NamedArgExpr(_) => panic!("Node has location property."),
-        NodeEnum::OpExpr(_) => panic!("Node has location property."),
-        NodeEnum::DistinctExpr(_) => panic!("Node has location property."),
-        NodeEnum::NullIfExpr(_) => panic!("Node has location property."),
-        NodeEnum::ScalarArrayOpExpr(_) => panic!("Node has location property."),
-        NodeEnum::BoolExpr(_) => panic!("Node has location property."),
-        NodeEnum::SubLink(_) => panic!("Node has location property."),
-        NodeEnum::SubPlan(_) => todo!(),
-        NodeEnum::AlternativeSubPlan(_) => todo!(),
-        NodeEnum::FieldSelect(_) => todo!(),
-        NodeEnum::FieldStore(_) => todo!(),
-        NodeEnum::RelabelType(_) => panic!("Node has location property."),
-        NodeEnum::CoerceViaIo(_) => panic!("Node has location property."),
-        NodeEnum::ArrayCoerceExpr(_) => panic!("Node has location property."),
-        NodeEnum::ConvertRowtypeExpr(_) => panic!("Node has location property."),
-        NodeEnum::CollateExpr(_) => panic!("Node has location property."),
-        NodeEnum::CaseExpr(_) => panic!("Node has location property."),
-        NodeEnum::CaseWhen(_) => panic!("Node has location property."),
-        NodeEnum::CaseTestExpr(_) => todo!(),
-        NodeEnum::ArrayExpr(_) => panic!("Node has location property."),
-        NodeEnum::RowExpr(_) => panic!("Node has location property."),
-        NodeEnum::RowCompareExpr(_) => todo!(),
-        NodeEnum::CoalesceExpr(_) => panic!("Node has location property."),
-        NodeEnum::MinMaxExpr(_) => panic!("Node has location property."),
-        NodeEnum::SqlvalueFunction(_) => panic!("Node has location property."),
-        NodeEnum::XmlExpr(_) => panic!("Node has location property."),
-        NodeEnum::NullTest(_) => panic!("Node has location property."),
-        NodeEnum::BooleanTest(_) => panic!("Node has location property."),
-        NodeEnum::CoerceToDomain(_) => panic!("Node has location property."),
-        NodeEnum::CoerceToDomainValue(_) => panic!("Node has location property."),
-        NodeEnum::SetToDefault(_) => panic!("Node has location property."),
-        NodeEnum::CurrentOfExpr(_) => todo!(),
-        NodeEnum::NextValueExpr(_) => todo!(),
-        NodeEnum::InferenceElem(_) => todo!(),
-        NodeEnum::TargetEntry(_) => todo!(),
-        NodeEnum::RangeTblRef(_) => todo!(),
-        NodeEnum::JoinExpr(n) => {
-            let keyword_regexp = match n.jointype() {
-                pg_query::protobuf::JoinType::Undefined => todo!(),
-                pg_query::protobuf::JoinType::JoinInner => "join|inner",
-                pg_query::protobuf::JoinType::JoinLeft => "join",
-                pg_query::protobuf::JoinType::JoinFull => "full",
-                pg_query::protobuf::JoinType::JoinRight => "join",
-                pg_query::protobuf::JoinType::JoinSemi => todo!(),
-                pg_query::protobuf::JoinType::JoinAnti => todo!(),
-                pg_query::protobuf::JoinType::JoinUniqueOuter => todo!(),
-                pg_query::protobuf::JoinType::JoinUniqueInner => todo!(),
-            };
-
-            Some(get_location_via_regexp(
-                Regex::new(format!("(?mi){}", keyword_regexp).as_str()).unwrap(),
-                text,
-                parent_location,
-                earliest_child_location,
-            ))
-        }
-        NodeEnum::FromExpr(_) => todo!(),
-        NodeEnum::OnConflictExpr(_) => todo!(),
-        NodeEnum::IntoClause(_) => todo!(),
-        NodeEnum::MergeAction(_) => todo!(),
-        NodeEnum::RawStmt(_) => todo!(),
-        NodeEnum::Query(_) => todo!(),
-        NodeEnum::InsertStmt(_) => Some(get_location_via_regexp(
-            Regex::new(r"(?mi)insert\s+into").unwrap(),
-            text,
-            parent_location,
-            earliest_child_location,
-        )),
-        NodeEnum::DeleteStmt(_) => Some(get_location_via_regexp(
-            Regex::new(r"(?mi)delete\s+from").unwrap(),
-            text,
-            parent_location,
-            earliest_child_location,
-        )),
-        NodeEnum::UpdateStmt(_) => todo!(),
-        NodeEnum::MergeStmt(_) => todo!(),
-        NodeEnum::SelectStmt(_) => Some(get_location_via_regexp(
-            // in "insert into contact (id) values (1)" the "values (1)" is a select statement
-            Regex::new(r"(?mi)select|values").unwrap(),
-            text,
-            parent_location,
-            earliest_child_location,
-        )),
-        NodeEnum::ReturnStmt(_) => todo!(),
-        NodeEnum::PlassignStmt(_) => panic!("Node has location property."),
-        NodeEnum::AlterTableStmt(_) => Some(get_location_via_regexp(
-            Regex::new(r"(?mi)alter\s+table").unwrap(),
-            text,
-            parent_location,
-            earliest_child_location,
-        )),
-        NodeEnum::AlterTableCmd(n) => Some(get_location_via_regexp(
-            Regex::new(format!("(?mi)alter.*{}", n.name).as_str()).unwrap(),
-            text,
-            parent_location,
-            earliest_child_location,
-        )),
-        NodeEnum::AlterDomainStmt(_) => todo!(),
-        NodeEnum::SetOperationStmt(_) => todo!(),
-        NodeEnum::GrantStmt(_) => todo!(),
-        NodeEnum::GrantRoleStmt(_) => todo!(),
-        NodeEnum::AlterDefaultPrivilegesStmt(_) => todo!(),
-        NodeEnum::ClosePortalStmt(_) => todo!(),
-        NodeEnum::ClusterStmt(_) => todo!(),
-        NodeEnum::CopyStmt(_) => todo!(),
-        NodeEnum::CreateStmt(_) => todo!(),
-        NodeEnum::DefineStmt(_) => todo!(),
-        NodeEnum::DropStmt(_) => todo!(),
-        NodeEnum::TruncateStmt(_) => todo!(),
-        NodeEnum::CommentStmt(_) => todo!(),
-        NodeEnum::FetchStmt(_) => todo!(),
-        NodeEnum::IndexStmt(_) => todo!(),
-        NodeEnum::CreateFunctionStmt(_) => todo!(),
-        NodeEnum::AlterFunctionStmt(_) => todo!(),
-        NodeEnum::DoStmt(_) => todo!(),
-        NodeEnum::RenameStmt(_) => todo!(),
-        NodeEnum::RuleStmt(_) => todo!(),
-        NodeEnum::NotifyStmt(_) => todo!(),
-        NodeEnum::ListenStmt(_) => todo!(),
-        NodeEnum::UnlistenStmt(_) => todo!(),
-        NodeEnum::TransactionStmt(_) => todo!(),
-        NodeEnum::ViewStmt(_) => todo!(),
-        NodeEnum::LoadStmt(_) => todo!(),
-        NodeEnum::CreateDomainStmt(_) => todo!(),
-        NodeEnum::CreatedbStmt(_) => todo!(),
-        NodeEnum::DropdbStmt(_) => todo!(),
-        NodeEnum::VacuumStmt(_) => todo!(),
-        NodeEnum::ExplainStmt(_) => todo!(),
-        NodeEnum::CreateTableAsStmt(_) => todo!(),
-        NodeEnum::CreateSeqStmt(_) => todo!(),
-        NodeEnum::AlterSeqStmt(_) => todo!(),
-        NodeEnum::VariableSetStmt(_) => todo!(),
-        NodeEnum::VariableShowStmt(_) => todo!(),
-        NodeEnum::DiscardStmt(_) => todo!(),
-        NodeEnum::CreateTrigStmt(_) => todo!(),
-        NodeEnum::CreatePlangStmt(_) => todo!(),
-        NodeEnum::CreateRoleStmt(_) => todo!(),
-        NodeEnum::AlterRoleStmt(_) => todo!(),
-        NodeEnum::DropRoleStmt(_) => todo!(),
-        NodeEnum::LockStmt(_) => todo!(),
-        NodeEnum::ConstraintsSetStmt(_) => todo!(),
-        NodeEnum::ReindexStmt(_) => todo!(),
-        NodeEnum::CheckPointStmt(_) => todo!(),
-        NodeEnum::CreateSchemaStmt(_) => todo!(),
-        NodeEnum::AlterDatabaseStmt(_) => todo!(),
-        NodeEnum::AlterDatabaseRefreshCollStmt(_) => todo!(),
-        NodeEnum::AlterDatabaseSetStmt(_) => todo!(),
-        NodeEnum::AlterRoleSetStmt(_) => todo!(),
-        NodeEnum::CreateConversionStmt(_) => todo!(),
-        NodeEnum::CreateCastStmt(_) => todo!(),
-        NodeEnum::CreateOpClassStmt(_) => todo!(),
-        NodeEnum::CreateOpFamilyStmt(_) => todo!(),
-        NodeEnum::AlterOpFamilyStmt(_) => todo!(),
-        NodeEnum::PrepareStmt(_) => todo!(),
-        NodeEnum::ExecuteStmt(_) => todo!(),
-        NodeEnum::DeallocateStmt(_) => todo!(),
-        NodeEnum::DeclareCursorStmt(_) => todo!(),
-        NodeEnum::CreateTableSpaceStmt(_) => todo!(),
-        NodeEnum::DropTableSpaceStmt(_) => todo!(),
-        NodeEnum::AlterObjectDependsStmt(_) => todo!(),
-        NodeEnum::AlterObjectSchemaStmt(_) => todo!(),
-        NodeEnum::AlterOwnerStmt(_) => todo!(),
-        NodeEnum::AlterOperatorStmt(_) => todo!(),
-        NodeEnum::AlterTypeStmt(_) => todo!(),
-        NodeEnum::DropOwnedStmt(_) => todo!(),
-        NodeEnum::ReassignOwnedStmt(_) => todo!(),
-        NodeEnum::CompositeTypeStmt(_) => todo!(),
-        NodeEnum::CreateEnumStmt(_) => todo!(),
-        NodeEnum::CreateRangeStmt(_) => todo!(),
-        NodeEnum::AlterEnumStmt(_) => todo!(),
-        NodeEnum::AlterTsdictionaryStmt(_) => todo!(),
-        NodeEnum::AlterTsconfigurationStmt(_) => todo!(),
-        NodeEnum::CreateFdwStmt(_) => todo!(),
-        NodeEnum::AlterFdwStmt(_) => todo!(),
-        NodeEnum::CreateForeignServerStmt(_) => todo!(),
-        NodeEnum::AlterForeignServerStmt(_) => todo!(),
-        NodeEnum::CreateUserMappingStmt(_) => todo!(),
-        NodeEnum::AlterUserMappingStmt(_) => todo!(),
-        NodeEnum::DropUserMappingStmt(_) => todo!(),
-        NodeEnum::AlterTableSpaceOptionsStmt(_) => todo!(),
-        NodeEnum::AlterTableMoveAllStmt(_) => todo!(),
-        NodeEnum::SecLabelStmt(_) => todo!(),
-        NodeEnum::CreateForeignTableStmt(_) => todo!(),
-        NodeEnum::ImportForeignSchemaStmt(_) => todo!(),
-        NodeEnum::CreateExtensionStmt(_) => todo!(),
-        NodeEnum::AlterExtensionStmt(_) => todo!(),
-        NodeEnum::AlterExtensionContentsStmt(_) => todo!(),
-        NodeEnum::CreateEventTrigStmt(_) => todo!(),
-        NodeEnum::AlterEventTrigStmt(_) => todo!(),
-        NodeEnum::RefreshMatViewStmt(_) => todo!(),
-        NodeEnum::ReplicaIdentityStmt(_) => todo!(),
-        NodeEnum::AlterSystemStmt(_) => todo!(),
-        NodeEnum::CreatePolicyStmt(_) => todo!(),
-        NodeEnum::AlterPolicyStmt(_) => todo!(),
-        NodeEnum::CreateTransformStmt(_) => todo!(),
-        NodeEnum::CreateAmStmt(_) => todo!(),
-        NodeEnum::CreatePublicationStmt(_) => todo!(),
-        NodeEnum::AlterPublicationStmt(_) => todo!(),
-        NodeEnum::CreateSubscriptionStmt(_) => todo!(),
-        NodeEnum::AlterSubscriptionStmt(_) => todo!(),
-        NodeEnum::DropSubscriptionStmt(_) => todo!(),
-        NodeEnum::CreateStatsStmt(_) => todo!(),
-        NodeEnum::AlterCollationStmt(_) => todo!(),
-        NodeEnum::CallStmt(_) => todo!(),
-        NodeEnum::AlterStatsStmt(_) => todo!(),
-        NodeEnum::AExpr(_) => panic!("Node has location property."),
-        NodeEnum::ColumnRef(_) => panic!("Node has location property."),
-        NodeEnum::ParamRef(_) => panic!("Node has location property."),
-        NodeEnum::FuncCall(_) => panic!("Node has location property."),
-        NodeEnum::AStar(_) => Some(get_location_via_regexp(
-            Regex::new(r"(?mi)\*").unwrap(),
-            text,
-            parent_location,
-            earliest_child_location,
-        )),
-        NodeEnum::AIndices(_) => todo!(),
-        NodeEnum::AIndirection(_) => todo!(),
-        NodeEnum::AArrayExpr(_) => panic!("Node has location property."),
-        NodeEnum::ResTarget(_) => panic!("Node has location property."),
-        NodeEnum::MultiAssignRef(_) => todo!(),
-        NodeEnum::TypeCast(_) => panic!("Node has location property."),
-        NodeEnum::CollateClause(_) => panic!("Node has location property."),
-        NodeEnum::SortBy(_) => panic!("Node has location property."),
-        NodeEnum::WindowDef(_) => panic!("Node has location property."),
-        NodeEnum::RangeSubselect(_) => todo!(),
-        NodeEnum::RangeFunction(_) => todo!(),
-        NodeEnum::RangeTableSample(_) => panic!("Node has location property."),
-        NodeEnum::RangeTableFunc(_) => panic!("Node has location property."),
-        NodeEnum::RangeTableFuncCol(_) => panic!("Node has location property."),
-        NodeEnum::TypeName(_) => panic!("Node has location property."),
-        NodeEnum::ColumnDef(_) => panic!("Node has location property."),
-        NodeEnum::IndexElem(_) => todo!(),
-        NodeEnum::StatsElem(_) => todo!(),
-        NodeEnum::Constraint(_) => panic!("Node has location property."),
-        NodeEnum::DefElem(_) => panic!("Node has location property."),
-        NodeEnum::RangeTblEntry(_) => todo!(),
-        NodeEnum::RangeTblFunction(_) => todo!(),
-        NodeEnum::TableSampleClause(_) => todo!(),
-        NodeEnum::WithCheckOption(_) => todo!(),
-        NodeEnum::SortGroupClause(_) => todo!(),
-        NodeEnum::GroupingSet(_) => panic!("Node has location property."),
-        NodeEnum::WindowClause(_) => todo!(),
-        NodeEnum::ObjectWithArgs(_) => todo!(),
-        NodeEnum::AccessPriv(n) => Some(get_location_via_regexp(
-            Regex::new(format!("(?mi){}", n.priv_name).as_str()).unwrap(),
-            text,
-            parent_location,
-            earliest_child_location,
-        )),
-        NodeEnum::CreateOpClassItem(_) => todo!(),
-        NodeEnum::TableLikeClause(_) => todo!(),
-        NodeEnum::FunctionParameter(_) => todo!(),
-        NodeEnum::LockingClause(_) => todo!(),
-        NodeEnum::RowMarkClause(_) => todo!(),
-        NodeEnum::XmlSerialize(_) => panic!("Node has location property."),
-        NodeEnum::WithClause(_) => panic!("Node has location property."),
-        NodeEnum::InferClause(_) => panic!("Node has location property."),
-        NodeEnum::OnConflictClause(_) => panic!("Node has location property."),
-        NodeEnum::CtesearchClause(_) => panic!("Node has location property."),
-        NodeEnum::CtecycleClause(_) => panic!("Node has location property."),
-        NodeEnum::CommonTableExpr(_) => panic!("Node has location property."),
-        NodeEnum::MergeWhenClause(_) => todo!(),
-        NodeEnum::RoleSpec(n) => {
-            if n.location == -1 {
-                None
-            } else {
-                todo!()
-            }
-        }
-        NodeEnum::TriggerTransition(_) => todo!(),
-        NodeEnum::PartitionElem(_) => panic!("Node has location property."),
-        NodeEnum::PartitionSpec(_) => panic!("Node has location property."),
-        NodeEnum::PartitionBoundSpec(_) => panic!("Node has location property."),
-        NodeEnum::PartitionRangeDatum(_) => panic!("Node has location property."),
-        NodeEnum::PartitionCmd(_) => todo!(),
-        NodeEnum::VacuumRelation(_) => todo!(),
-        NodeEnum::PublicationObjSpec(_) => panic!("Node has location property."),
-        NodeEnum::PublicationTable(_) => todo!(),
-        NodeEnum::InlineCodeBlock(_) => todo!(),
-        NodeEnum::CallContext(_) => todo!(),
-        NodeEnum::Integer(_) => None,
-        NodeEnum::Float(_) => None,
-        NodeEnum::Boolean(_) => None,
-        NodeEnum::String(n) => find_location_via_regexp(
-            Regex::new(format!("(?mi){}", n.sval).as_str()).unwrap(),
-            text,
-            parent_location,
-            earliest_child_location,
-        ),
-        NodeEnum::BitString(_) => None,
-        NodeEnum::List(_) => find_location_via_regexp(
-            Regex::new(r"(?mi)\((.*?)\)").unwrap(),
-            text,
-            parent_location,
-            earliest_child_location,
-        )
-        // sometimes, a list is not enclosed by parentheses, but starts at the earliest child
-        // location, e.g. `DROP TABLE tablename`, where `tablename` is enclosed by an invisible
-        // `List`
-        .or(earliest_child_location),
-        NodeEnum::IntList(_) => todo!(),
-        NodeEnum::OidList(_) => todo!(),
-        NodeEnum::AConst(_) => panic!("Node has location property."),
-    }
-}
-
-fn find_location_via_regexp(
-    r: Regex,
-    text: &str,
-    parent_location: i32,
-    earliest_child_location: Option<i32>,
-) -> Option<i32> {
-    struct Location {
-        location: i32,
-        distance: i32,
-    }
-
-    let location = r
-        .find_iter(text)
-        .filter_map(|x| {
-            if x.start() as i32 >= parent_location {
-                Some({
-                    Location {
-                        location: x.start() as i32,
-                        distance: if earliest_child_location.is_some() {
-                            earliest_child_location.unwrap() - x.start() as i32
-                        } else {
-                            x.start() as i32 - parent_location
-                        },
-                    }
-                })
-            } else {
-                None
-            }
-        })
-        .min_by_key(|x| x.distance.abs());
-
-    if location.is_none() {
-        return None;
-    }
-
-    let location = location.unwrap().location;
-
-    // Sanity check to ensure that the location is valid
-    if earliest_child_location.is_some() && earliest_child_location.unwrap() < location {
-        panic!("Regex returned invalid location: Node cannot have a location < its children");
-    }
-
-    Some(location)
-}
-
-fn get_location_via_regexp(
-    r: Regex,
-    text: &str,
-    parent_location: i32,
-    earliest_child_location: Option<i32>,
-) -> i32 {
-    return find_location_via_regexp(r, text, parent_location, earliest_child_location).unwrap();
-}
-
-#[cfg(test)]
-mod tests {
-    use std::assert_eq;
-
-    use pg_query::NodeEnum;
-
-    use crate::resolve_locations::derive_location;
-
-    #[test]
-    fn test_derive_location() {
-        let input = "with c as (insert into contact (id) values ('id')) select * from c;";
-
-        let insert_node = match pg_query::parse(input) {
-            Ok(parsed) => Some(
-                parsed
-                    .protobuf
-                    .nodes()
-                    .iter()
-                    .find(|n| match n.0.to_enum() {
-                        NodeEnum::InsertStmt(_) => true,
-                        _ => false,
-                    })
-                    .unwrap()
-                    .0
-                    .to_enum(),
-            ),
-            Err(_) => None,
-        };
-        let cte_location = match pg_query::parse(input) {
-            Ok(parsed) => Some(
-                parsed
-                    .protobuf
-                    .nodes()
-                    .iter()
-                    .find_map(|n| match n.0.to_enum() {
-                        NodeEnum::CommonTableExpr(n) => Some(n.location),
-                        _ => None,
-                    })
-                    .unwrap(),
-            ),
-            Err(_) => None,
-        };
-
-        let l = derive_location(
-            &insert_node.unwrap(),
-            input,
-            cte_location.unwrap(),
-            Some(23),
-        );
-
-        assert_eq!(l, Some(11));
-    }
-}
diff --git a/crates/parser/src/source_file.rs b/crates/parser/src/source_file.rs
index d258ee58..9ae9b641 100644
--- a/crates/parser/src/source_file.rs
+++ b/crates/parser/src/source_file.rs
@@ -34,10 +34,10 @@ impl Parser {
                 Ok(token) => {
                     match token {
                         SourceFileToken::Comment => {
-                            self.token(SyntaxKind::Comment, lexer.slice(), None);
+                            self.token(SyntaxKind::Comment, lexer.slice());
                         }
                         SourceFileToken::Newline => {
-                            self.token(SyntaxKind::Newline, lexer.slice(), None);
+                            self.token(SyntaxKind::Newline, lexer.slice());
                         }
                         SourceFileToken::Statement => {
                             self.parse_statement(lexer.slice(), Some(lexer.span().start as u32));
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 565221da..7c5d7334 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -1,15 +1,7 @@
 use cstree::text::{TextRange, TextSize};
 use logos::{Logos, Span};
 
-use crate::{
-    get_children_codegen::get_children,
-    parser::Parser,
-    resolve_locations::resolve_locations,
-    syntax_kind_codegen::SyntaxKind,
-    token_type::{
-        get_token_type_from_pg_query_token, get_token_type_from_statement_token, TokenType,
-    },
-};
+use crate::{parser::Parser, syntax_kind_codegen::SyntaxKind};
 
 /// A super simple lexer for sql statements.
 ///
@@ -38,7 +30,6 @@ impl StatementToken {
             StatementToken::Newline => SyntaxKind::Newline,
             StatementToken::Tab => SyntaxKind::Tab,
             StatementToken::Comment => SyntaxKind::Comment,
-            _ => panic!("Unknown StatementToken: {:?}", self),
         }
     }
 }
@@ -94,15 +85,6 @@ impl Parser {
             }
         };
 
-        println!("pg_query_root: {:?}", pg_query_root);
-
-        let mut pg_query_nodes = match &pg_query_root {
-            Some(root) => resolve_locations(get_children(root, text.to_string(), 1), text)
-                .into_iter()
-                .peekable(),
-            None => Vec::new().into_iter().peekable(),
-        };
-
         let mut lexer = StatementToken::lexer(&text);
 
         // parse root node if no syntax errors
@@ -110,13 +92,11 @@ impl Parser {
             let root_node = pg_query_root.unwrap();
             self.stmt(root_node.to_owned(), range);
             self.start_node_at(SyntaxKind::new_from_pg_query_node(&root_node), 1);
-            // if there is only one node, there are no children, and we do not need to buffer the tokens.
-            self.set_checkpoint(pg_query_nodes.len() == 0);
         } else {
             // fallback to generic node as root
             self.start_node_at(SyntaxKind::Stmt, 1);
-            self.set_checkpoint(true);
         }
+        self.set_checkpoint();
 
         // start at 0, and increment by the length of the token
         let mut pointer: i32 = 0;
@@ -125,13 +105,9 @@ impl Parser {
         struct Token {
             syntax_kind: SyntaxKind,
             span: Span,
-            token_type: Option<TokenType>,
         }
 
         while pointer < text.len() as i32 {
-            // first get token WITHOUT applying it
-            // then consume pg_query nodes until there is none, or the node is outside of the current tokens' span
-
             // Check if the pointer is within a pg_query token
             let next_pg_query_token = pg_query_tokens.peek();
             let token = if next_pg_query_token.is_some()
@@ -140,7 +116,6 @@ impl Parser {
             {
                 let token = pg_query_tokens.next().unwrap();
                 Token {
-                    token_type: get_token_type_from_pg_query_token(&token),
                     syntax_kind: SyntaxKind::new_from_pg_query_token(&token),
                     span: Span {
                         start: token.start as usize,
@@ -164,32 +139,11 @@ impl Parser {
                     );
                 }
                 Token {
-                    token_type: get_token_type_from_statement_token(
-                        &token.as_ref().unwrap().as_ref().unwrap(),
-                    ),
                     syntax_kind: token.unwrap().unwrap().syntax_kind(),
                     span: lexer.span(),
                 }
             };
 
-            // consume pg_query nodes until there is none, or the node is outside of the current text span
-            while let Some(node) = pg_query_nodes.peek() {
-                if token
-                    .span
-                    .contains(&usize::try_from(node.location).unwrap())
-                    == false
-                {
-                    break;
-                } else {
-                    // node is within span
-                    let nested_node = pg_query_nodes.next().unwrap();
-                    self.start_node_at(
-                        SyntaxKind::new_from_pg_query_node(&nested_node.node),
-                        nested_node.depth,
-                    );
-                }
-            }
-
             self.token(
                 token.syntax_kind,
                 text.chars()
@@ -197,7 +151,6 @@ impl Parser {
                     .take(token.span.end - token.span.start)
                     .collect::<String>()
                     .as_str(),
-                token.token_type,
             );
 
             pointer = pointer + (token.span.end - token.span.start) as i32;
@@ -210,41 +163,10 @@ impl Parser {
 
 #[cfg(test)]
 mod tests {
-    use log::info;
-    use log::log_enabled;
     use std::assert_eq;
-    use std::fs;
 
     use super::*;
 
-    const VALID_STATEMENTS_PATH: &str = "test_data/statements/valid/";
-
-    fn init() {
-        let _ = env_logger::builder().is_test(true).try_init();
-    }
-
-    fn test_valid_stmt(name: String, input: String) {
-        info!("[{}]: {}", name, input);
-
-        let mut parser = Parser::new();
-        parser.parse_statement(&input, None);
-        let parsed = parser.finish();
-
-        let out = format!("{:#?}", parsed.cst);
-
-        if log_enabled!(log::Level::Debug) {
-            dbg!(&parsed.cst);
-        }
-
-        assert_eq!(parsed.cst.text(), input.as_str())
-    }
-
-    #[test]
-    fn test_simple_statement() {
-        init();
-        test_valid_stmt("simple_statement".to_string(), "select 1;".to_string());
-    }
-
     #[test]
     fn test_invalid_statement() {
         let input = "select select;";
diff --git a/crates/parser/src/token_type.rs b/crates/parser/src/token_type.rs
deleted file mode 100644
index 23774f28..00000000
--- a/crates/parser/src/token_type.rs
+++ /dev/null
@@ -1,111 +0,0 @@
-use pg_query::protobuf::ScanToken;
-
-use crate::statement::StatementToken;
-use crate::syntax_kind_codegen::SyntaxKind;
-
-///  Kind of a `SyntaxKind`
-///  This is the only manual definition required for properly creating a concrete
-/// syntax tree.
-///  If a token is of type `Follow`, it is not immediately applied to the syntax
-/// tree, but put into
-///  a buffer. Before the next node is started, all buffered tokens are applied
-/// to the syntax tree
-///  at the depth of the node that is opened next.
-///
-///  For example, in `select * from contact;`, the whitespace between `*` and
-/// `from` should be a direct
-///  child of the `SelectStmt` node. Without this concept, it would be put into
-/// the `ColumnRef`
-///  node.
-///
-///  SelectStmt@0..22
-///    Select@0..6 "select"
-///    Whitespace@6..7 " "
-///    ResTarget@7..8
-///      ColumnRef@7..8
-///        Ascii42@7..8 "*"
-///    Whitespace@8..9 " "
-///    From@9..13 "from"
-///   Whitespace@13..14 " "
-///    RangeVar@14..21
-///      Ident@14..21 "contact"
-///    Ascii59@21..22 ";"
-#[derive(Debug)]
-pub enum TokenType {
-    Follow,
-    Close,
-}
-
-pub fn get_token_type_from_statement_token(token: &StatementToken) -> Option<TokenType> {
-    match token {
-        StatementToken::Whitespace => Some(TokenType::Follow),
-        StatementToken::Newline => Some(TokenType::Follow),
-        _ => None,
-    }
-}
-
-// Returns the token type of a `ScanToken` from the `pg_query` crate.
-//
-// converts the token to a `SyntaxKind` for better readability.
-pub fn get_token_type_from_pg_query_token(token: &ScanToken) -> Option<TokenType> {
-    println!("token: {:?}", token);
-
-    let r = match token.keyword_kind() {
-        pg_query::protobuf::KeywordKind::NoKeyword => {
-            match SyntaxKind::new_from_pg_query_token(token) {
-                SyntaxKind::Ascii37 => Some(TokenType::Follow),
-                SyntaxKind::Ascii40 => Some(TokenType::Follow),
-                SyntaxKind::Ascii41 => Some(TokenType::Follow),
-                SyntaxKind::Ascii42 => Some(TokenType::Follow),
-                SyntaxKind::Ascii43 => Some(TokenType::Follow),
-                SyntaxKind::Ascii44 => Some(TokenType::Follow),
-                SyntaxKind::Ascii45 => Some(TokenType::Follow),
-                SyntaxKind::Ascii46 => Some(TokenType::Follow),
-                SyntaxKind::Ascii47 => Some(TokenType::Follow),
-                SyntaxKind::Ascii58 => Some(TokenType::Follow),
-                // ";"
-                SyntaxKind::Ascii59 => Some(TokenType::Close),
-                SyntaxKind::Ascii60 => Some(TokenType::Follow),
-                SyntaxKind::Ascii61 => Some(TokenType::Follow),
-                SyntaxKind::Ascii62 => Some(TokenType::Follow),
-                SyntaxKind::Ascii63 => Some(TokenType::Follow),
-                SyntaxKind::Ascii92 => Some(TokenType::Follow),
-                SyntaxKind::Ascii93 => Some(TokenType::Follow),
-                SyntaxKind::Ascii94 => Some(TokenType::Follow),
-                SyntaxKind::NotEquals => Some(TokenType::Follow),
-                SyntaxKind::Sconst => Some(TokenType::Follow),
-                _ => None,
-            }
-        }
-        pg_query::protobuf::KeywordKind::UnreservedKeyword => {
-            match SyntaxKind::new_from_pg_query_token(token) {
-                SyntaxKind::AddP => Some(TokenType::Follow),
-                SyntaxKind::Update => Some(TokenType::Follow),
-                SyntaxKind::By => Some(TokenType::Follow),
-                _ => None,
-            }
-        }
-        pg_query::protobuf::KeywordKind::ColNameKeyword => None,
-        pg_query::protobuf::KeywordKind::TypeFuncNameKeyword => None,
-        pg_query::protobuf::KeywordKind::ReservedKeyword => {
-            match SyntaxKind::new_from_pg_query_token(token) {
-                SyntaxKind::And => Some(TokenType::Follow),
-                SyntaxKind::Check => Some(TokenType::Follow),
-                SyntaxKind::EndP => Some(TokenType::Follow),
-                SyntaxKind::For => Some(TokenType::Follow),
-                SyntaxKind::From => Some(TokenType::Follow),
-                SyntaxKind::InP => Some(TokenType::Follow),
-                SyntaxKind::On => Some(TokenType::Follow),
-                SyntaxKind::Then => Some(TokenType::Follow),
-                SyntaxKind::To => Some(TokenType::Follow),
-                SyntaxKind::Using => Some(TokenType::Follow),
-                SyntaxKind::Where => Some(TokenType::Follow),
-                SyntaxKind::With => Some(TokenType::Follow),
-                SyntaxKind::GroupP => Some(TokenType::Follow),
-                SyntaxKind::As => Some(TokenType::Follow),
-                _ => None,
-            }
-        }
-    };
-    r
-}
diff --git a/crates/parser/tests/snapshots/statements/valid/0001.snap b/crates/parser/tests/snapshots/statements/valid/0001.snap
index ed195ee2..1c2083ab 100644
--- a/crates/parser/tests/snapshots/statements/valid/0001.snap
+++ b/crates/parser/tests/snapshots/statements/valid/0001.snap
@@ -5,48 +5,43 @@ description: "SELECT city, count(*) FILTER (WHERE temp_lo < 45), max(temp_lo)\n
 SelectStmt@0..100
   Select@0..6 "SELECT"
   Whitespace@6..7 " "
-  ResTarget@7..11
-    Ident@7..11 "city"
+  Ident@7..11 "city"
   Ascii44@11..12 ","
   Whitespace@12..13 " "
-  ResTarget@13..49
-    Ident@13..18 "count"
-    Ascii40@18..19 "("
-    Ascii42@19..20 "*"
-    Ascii41@20..21 ")"
-    Whitespace@21..22 " "
-    Filter@22..28 "FILTER"
-    Whitespace@28..29 " "
-    Ascii40@29..30 "("
-    Where@30..35 "WHERE"
-    Whitespace@35..36 " "
-    Ident@36..43 "temp_lo"
-    Whitespace@43..44 " "
-    Ascii60@44..45 "<"
-    Whitespace@45..46 " "
-    Iconst@46..48 "45"
-    Ascii41@48..49 ")"
+  Ident@13..18 "count"
+  Ascii40@18..19 "("
+  Ascii42@19..20 "*"
+  Ascii41@20..21 ")"
+  Whitespace@21..22 " "
+  Filter@22..28 "FILTER"
+  Whitespace@28..29 " "
+  Ascii40@29..30 "("
+  Where@30..35 "WHERE"
+  Whitespace@35..36 " "
+  Ident@36..43 "temp_lo"
+  Whitespace@43..44 " "
+  Ascii60@44..45 "<"
+  Whitespace@45..46 " "
+  Iconst@46..48 "45"
+  Ascii41@48..49 ")"
   Ascii44@49..50 ","
   Whitespace@50..51 " "
-  ResTarget@51..63
-    Ident@51..54 "max"
-    Ascii40@54..55 "("
-    Ident@55..62 "temp_lo"
-    Ascii41@62..63 ")"
+  Ident@51..54 "max"
+  Ascii40@54..55 "("
+  Ident@55..62 "temp_lo"
+  Ascii41@62..63 ")"
   Newline@63..64 "\n"
   Whitespace@64..68 "    "
   From@68..72 "FROM"
   Whitespace@72..73 " "
-  RangeVar@73..80
-    Ident@73..80 "weather"
+  Ident@73..80 "weather"
   Newline@80..81 "\n"
   Whitespace@81..85 "    "
   GroupP@85..90 "GROUP"
   Whitespace@90..91 " "
   By@91..93 "BY"
   Whitespace@93..94 " "
-  ColumnRef@94..98
-    Ident@94..98 "city"
+  Ident@94..98 "city"
   Ascii59@98..99 ";"
   Newline@99..100 "\n"
 
diff --git a/crates/parser/tests/snapshots/statements/valid/0002.snap b/crates/parser/tests/snapshots/statements/valid/0002.snap
index 14f73259..45ebc465 100644
--- a/crates/parser/tests/snapshots/statements/valid/0002.snap
+++ b/crates/parser/tests/snapshots/statements/valid/0002.snap
@@ -5,8 +5,7 @@ description: "COPY weather FROM '/home/user/weather.txt';\n"
 CopyStmt@0..44
   Copy@0..4 "COPY"
   Whitespace@4..5 " "
-  RangeVar@5..12
-    Ident@5..12 "weather"
+  Ident@5..12 "weather"
   Whitespace@12..13 " "
   From@13..17 "FROM"
   Whitespace@17..18 " "
diff --git a/crates/parser/tests/snapshots/statements/valid/0003.snap b/crates/parser/tests/snapshots/statements/valid/0003.snap
index 52a0329a..090b3a9a 100644
--- a/crates/parser/tests/snapshots/statements/valid/0003.snap
+++ b/crates/parser/tests/snapshots/statements/valid/0003.snap
@@ -7,56 +7,50 @@ CreateStmt@0..174
   Whitespace@6..7 " "
   Table@7..12 "TABLE"
   Whitespace@12..13 " "
-  RangeVar@13..20
-    Ident@13..20 "weather"
+  Ident@13..20 "weather"
   Whitespace@20..21 " "
   Ascii40@21..22 "("
   Newline@22..23 "\n"
   Whitespace@23..31 "        "
-  ColumnDef@31..76
-    Ident@31..35 "city"
-    Whitespace@35..41 "      "
-    Varchar@41..48 "varchar"
-    Ascii40@48..49 "("
-    Iconst@49..51 "80"
-    Ascii41@51..52 ")"
-    Whitespace@52..53 " "
-    References@53..63 "references"
-    Whitespace@63..64 " "
-    Ident@64..70 "cities"
-    Ascii40@70..71 "("
-    NameP@71..75 "name"
-    Ascii41@75..76 ")"
+  Ident@31..35 "city"
+  Whitespace@35..41 "      "
+  Varchar@41..48 "varchar"
+  Ascii40@48..49 "("
+  Iconst@49..51 "80"
+  Ascii41@51..52 ")"
+  Whitespace@52..53 " "
+  References@53..63 "references"
+  Whitespace@63..64 " "
+  Ident@64..70 "cities"
+  Ascii40@70..71 "("
+  NameP@71..75 "name"
+  Ascii41@75..76 ")"
   Ascii44@76..77 ","
   Newline@77..78 "\n"
   Whitespace@78..86 "        "
-  ColumnDef@86..99
-    Ident@86..93 "temp_lo"
-    Whitespace@93..96 "   "
-    IntP@96..99 "int"
+  Ident@86..93 "temp_lo"
+  Whitespace@93..96 "   "
+  IntP@96..99 "int"
   Ascii44@99..100 ","
   Newline@100..101 "\n"
   Whitespace@101..109 "        "
-  ColumnDef@109..122
-    Ident@109..116 "temp_hi"
-    Whitespace@116..119 "   "
-    IntP@119..122 "int"
+  Ident@109..116 "temp_hi"
+  Whitespace@116..119 "   "
+  IntP@119..122 "int"
   Ascii44@122..123 ","
   Newline@123..124 "\n"
   Whitespace@124..132 "        "
-  ColumnDef@132..146
-    Ident@132..136 "prcp"
-    Whitespace@136..142 "      "
-    Real@142..146 "real"
+  Ident@132..136 "prcp"
+  Whitespace@136..142 "      "
+  Real@142..146 "real"
   Ascii44@146..147 ","
   Newline@147..148 "\n"
   Whitespace@148..156 "        "
-  ColumnDef@156..172
-    Ident@156..160 "date"
-    Whitespace@160..166 "      "
-    Ident@166..170 "date"
-    Newline@170..171 "\n"
-    Ascii41@171..172 ")"
+  Ident@156..160 "date"
+  Whitespace@160..166 "      "
+  Ident@166..170 "date"
+  Newline@170..171 "\n"
+  Ascii41@171..172 ")"
   Ascii59@172..173 ";"
   Newline@173..174 "\n"
 
diff --git a/crates/parser/tests/snapshots/statements/valid/0004.snap b/crates/parser/tests/snapshots/statements/valid/0004.snap
index bdfbe342..d5e1524f 100644
--- a/crates/parser/tests/snapshots/statements/valid/0004.snap
+++ b/crates/parser/tests/snapshots/statements/valid/0004.snap
@@ -7,57 +7,46 @@ ViewStmt@0..134
   Whitespace@6..7 " "
   View@7..11 "VIEW"
   Whitespace@11..12 " "
-  RangeVar@12..18
-    Ident@12..18 "myview"
+  Ident@12..18 "myview"
   Whitespace@18..19 " "
   As@19..21 "AS"
   Newline@21..22 "\n"
   Whitespace@22..26 "    "
-  SelectStmt@26..132
-    Select@26..32 "SELECT"
-    Whitespace@32..33 " "
-    ResTarget@33..37
-      NameP@33..37 "name"
-    Ascii44@37..38 ","
-    Whitespace@38..39 " "
-    ResTarget@39..46
-      Ident@39..46 "temp_lo"
-    Ascii44@46..47 ","
-    Whitespace@47..48 " "
-    ResTarget@48..55
-      Ident@48..55 "temp_hi"
-    Ascii44@55..56 ","
-    Whitespace@56..57 " "
-    ResTarget@57..61
-      Ident@57..61 "prcp"
-    Ascii44@61..62 ","
-    Whitespace@62..63 " "
-    ResTarget@63..67
-      Ident@63..67 "date"
-    Ascii44@67..68 ","
-    Whitespace@68..69 " "
-    ResTarget@69..77
-      Location@69..77 "location"
-    Newline@77..78 "\n"
-    Whitespace@78..86 "        "
-    From@86..90 "FROM"
-    Whitespace@90..91 " "
-    RangeVar@91..98
-      Ident@91..98 "weather"
-    Ascii44@98..99 ","
-    Whitespace@99..100 " "
-    RangeVar@100..106
-      Ident@100..106 "cities"
-    Newline@106..107 "\n"
-    Whitespace@107..115 "        "
-    Where@115..120 "WHERE"
-    Whitespace@120..121 " "
-    AExpr@121..132
-      Ident@121..125 "city"
-      Whitespace@125..126 " "
-      Ascii61@126..127 "="
-      Whitespace@127..128 " "
-      NameP@128..132 "name"
+  Select@26..32 "SELECT"
+  Whitespace@32..33 " "
+  NameP@33..37 "name"
+  Ascii44@37..38 ","
+  Whitespace@38..39 " "
+  Ident@39..46 "temp_lo"
+  Ascii44@46..47 ","
+  Whitespace@47..48 " "
+  Ident@48..55 "temp_hi"
+  Ascii44@55..56 ","
+  Whitespace@56..57 " "
+  Ident@57..61 "prcp"
+  Ascii44@61..62 ","
+  Whitespace@62..63 " "
+  Ident@63..67 "date"
+  Ascii44@67..68 ","
+  Whitespace@68..69 " "
+  Location@69..77 "location"
+  Newline@77..78 "\n"
+  Whitespace@78..86 "        "
+  From@86..90 "FROM"
+  Whitespace@90..91 " "
+  Ident@91..98 "weather"
+  Ascii44@98..99 ","
+  Whitespace@99..100 " "
+  Ident@100..106 "cities"
+  Newline@106..107 "\n"
+  Whitespace@107..115 "        "
+  Where@115..120 "WHERE"
+  Whitespace@120..121 " "
+  Ident@121..125 "city"
+  Whitespace@125..126 " "
+  Ascii61@126..127 "="
+  Whitespace@127..128 " "
+  NameP@128..132 "name"
   Ascii59@132..133 ";"
   Newline@133..134 "\n"
 
diff --git a/crates/parser/tests/snapshots/statements/valid/0005.snap b/crates/parser/tests/snapshots/statements/valid/0005.snap
new file mode 100644
index 00000000..d99908db
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0005.snap
@@ -0,0 +1,21 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "DELETE FROM weather WHERE city = 'Hayward';\n"
+---
+DeleteStmt@0..44
+  DeleteP@0..6 "DELETE"
+  Whitespace@6..7 " "
+  From@7..11 "FROM"
+  Whitespace@11..12 " "
+  Ident@12..19 "weather"
+  Whitespace@19..20 " "
+  Where@20..25 "WHERE"
+  Whitespace@25..26 " "
+  Ident@26..30 "city"
+  Whitespace@30..31 " "
+  Ascii61@31..32 "="
+  Whitespace@32..33 " "
+  Sconst@33..42 "'Hayward'"
+  Ascii59@42..43 ";"
+  Newline@43..44 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0006.snap b/crates/parser/tests/snapshots/statements/valid/0006.snap
new file mode 100644
index 00000000..37cfd337
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0006.snap
@@ -0,0 +1,13 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "DROP TABLE tablename;\n"
+---
+DropStmt@0..22
+  Drop@0..4 "DROP"
+  Whitespace@4..5 " "
+  Table@5..10 "TABLE"
+  Whitespace@10..11 " "
+  Ident@11..20 "tablename"
+  Ascii59@20..21 ";"
+  Newline@21..22 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0007.snap b/crates/parser/tests/snapshots/statements/valid/0007.snap
new file mode 100644
index 00000000..61ccfb22
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0007.snap
@@ -0,0 +1,36 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE TABLE cities (\n  name       text,\n  population real,\n  elevation  int     -- (in ft)\n);\n\n"
+---
+CreateStmt@0..96
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Table@7..12 "TABLE"
+  Whitespace@12..13 " "
+  Ident@13..19 "cities"
+  Whitespace@19..20 " "
+  Ascii40@20..21 "("
+  Newline@21..22 "\n"
+  Whitespace@22..24 "  "
+  NameP@24..28 "name"
+  Whitespace@28..35 "       "
+  TextP@35..39 "text"
+  Ascii44@39..40 ","
+  Newline@40..41 "\n"
+  Whitespace@41..43 "  "
+  Ident@43..53 "population"
+  Whitespace@53..54 " "
+  Real@54..58 "real"
+  Ascii44@58..59 ","
+  Newline@59..60 "\n"
+  Whitespace@60..62 "  "
+  Ident@62..71 "elevation"
+  Whitespace@71..73 "  "
+  IntP@73..76 "int"
+  Whitespace@76..81 "     "
+  SqlComment@81..91 "-- (in ft)"
+  Newline@91..92 "\n"
+  Ascii41@92..93 ")"
+  Ascii59@93..94 ";"
+  Newline@94..96 "\n\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0008.snap b/crates/parser/tests/snapshots/statements/valid/0008.snap
new file mode 100644
index 00000000..a33927f9
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0008.snap
@@ -0,0 +1,42 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "INSERT INTO weather (date, city, temp_hi, temp_lo)\n    VALUES ('1994-11-29', 'Hayward', 54, 37);\n"
+---
+InsertStmt@0..97
+  Insert@0..6 "INSERT"
+  Whitespace@6..7 " "
+  Into@7..11 "INTO"
+  Whitespace@11..12 " "
+  Ident@12..19 "weather"
+  Whitespace@19..20 " "
+  Ascii40@20..21 "("
+  Ident@21..25 "date"
+  Ascii44@25..26 ","
+  Whitespace@26..27 " "
+  Ident@27..31 "city"
+  Ascii44@31..32 ","
+  Whitespace@32..33 " "
+  Ident@33..40 "temp_hi"
+  Ascii44@40..41 ","
+  Whitespace@41..42 " "
+  Ident@42..49 "temp_lo"
+  Ascii41@49..50 ")"
+  Newline@50..51 "\n"
+  Whitespace@51..55 "    "
+  Values@55..61 "VALUES"
+  Whitespace@61..62 " "
+  Ascii40@62..63 "("
+  Sconst@63..75 "'1994-11-29'"
+  Ascii44@75..76 ","
+  Whitespace@76..77 " "
+  Sconst@77..86 "'Hayward'"
+  Ascii44@86..87 ","
+  Whitespace@87..88 " "
+  Iconst@88..90 "54"
+  Ascii44@90..91 ","
+  Whitespace@91..92 " "
+  Iconst@92..94 "37"
+  Ascii41@94..95 ")"
+  Ascii59@95..96 ";"
+  Newline@96..97 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0009.snap b/crates/parser/tests/snapshots/statements/valid/0009.snap
new file mode 100644
index 00000000..bf17d60a
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0009.snap
@@ -0,0 +1,93 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT w1.city, w1.temp_lo AS low, w1.temp_hi AS high,\n       w2.city, w2.temp_lo AS low, w2.temp_hi AS high\n    FROM weather w1 JOIN weather w2\n        ON w1.temp_lo < w2.temp_lo AND w1.temp_hi > w2.temp_hi;\n"
+---
+SelectStmt@0..209
+  Select@0..6 "SELECT"
+  Whitespace@6..7 " "
+  Ident@7..9 "w1"
+  Ascii46@9..10 "."
+  Ident@10..14 "city"
+  Ascii44@14..15 ","
+  Whitespace@15..16 " "
+  Ident@16..18 "w1"
+  Ascii46@18..19 "."
+  Ident@19..26 "temp_lo"
+  Whitespace@26..27 " "
+  As@27..29 "AS"
+  Whitespace@29..30 " "
+  Ident@30..33 "low"
+  Ascii44@33..34 ","
+  Whitespace@34..35 " "
+  Ident@35..37 "w1"
+  Ascii46@37..38 "."
+  Ident@38..45 "temp_hi"
+  Whitespace@45..46 " "
+  As@46..48 "AS"
+  Whitespace@48..49 " "
+  Ident@49..53 "high"
+  Ascii44@53..54 ","
+  Newline@54..55 "\n"
+  Whitespace@55..62 "       "
+  Ident@62..64 "w2"
+  Ascii46@64..65 "."
+  Ident@65..69 "city"
+  Ascii44@69..70 ","
+  Whitespace@70..71 " "
+  Ident@71..73 "w2"
+  Ascii46@73..74 "."
+  Ident@74..81 "temp_lo"
+  Whitespace@81..82 " "
+  As@82..84 "AS"
+  Whitespace@84..85 " "
+  Ident@85..88 "low"
+  Ascii44@88..89 ","
+  Whitespace@89..90 " "
+  Ident@90..92 "w2"
+  Ascii46@92..93 "."
+  Ident@93..100 "temp_hi"
+  Whitespace@100..101 " "
+  As@101..103 "AS"
+  Whitespace@103..104 " "
+  Ident@104..108 "high"
+  Newline@108..109 "\n"
+  Whitespace@109..113 "    "
+  From@113..117 "FROM"
+  Whitespace@117..118 " "
+  Ident@118..125 "weather"
+  Whitespace@125..126 " "
+  Ident@126..128 "w1"
+  Whitespace@128..129 " "
+  Join@129..133 "JOIN"
+  Whitespace@133..134 " "
+  Ident@134..141 "weather"
+  Whitespace@141..142 " "
+  Ident@142..144 "w2"
+  Newline@144..145 "\n"
+  Whitespace@145..153 "        "
+  On@153..155 "ON"
+  Whitespace@155..156 " "
+  Ident@156..158 "w1"
+  Ascii46@158..159 "."
+  Ident@159..166 "temp_lo"
+  Whitespace@166..167 " "
+  Ascii60@167..168 "<"
+  Whitespace@168..169 " "
+  Ident@169..171 "w2"
+  Ascii46@171..172 "."
+  Ident@172..179 "temp_lo"
+  Whitespace@179..180 " "
+  And@180..183 "AND"
+  Whitespace@183..184 " "
+  Ident@184..186 "w1"
+  Ascii46@186..187 "."
+  Ident@187..194 "temp_hi"
+  Whitespace@194..195 " "
+  Ascii62@195..196 ">"
+  Whitespace@196..197 " "
+  Ident@197..199 "w2"
+  Ascii46@199..200 "."
+  Ident@200..207 "temp_hi"
+  Ascii59@207..208 ";"
+  Newline@208..209 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0010.snap b/crates/parser/tests/snapshots/statements/valid/0010.snap
new file mode 100644
index 00000000..402b5c07
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0010.snap
@@ -0,0 +1,31 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');\n"
+---
+InsertStmt@0..74
+  Insert@0..6 "INSERT"
+  Whitespace@6..7 " "
+  Into@7..11 "INTO"
+  Whitespace@11..12 " "
+  Ident@12..19 "weather"
+  Whitespace@19..20 " "
+  Values@20..26 "VALUES"
+  Whitespace@26..27 " "
+  Ascii40@27..28 "("
+  Sconst@28..43 "'San Francisco'"
+  Ascii44@43..44 ","
+  Whitespace@44..45 " "
+  Iconst@45..47 "46"
+  Ascii44@47..48 ","
+  Whitespace@48..49 " "
+  Iconst@49..51 "50"
+  Ascii44@51..52 ","
+  Whitespace@52..53 " "
+  Fconst@53..57 "0.25"
+  Ascii44@57..58 ","
+  Whitespace@58..59 " "
+  Sconst@59..71 "'1994-11-27'"
+  Ascii41@71..72 ")"
+  Ascii59@72..73 ";"
+  Newline@73..74 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0011.snap b/crates/parser/tests/snapshots/statements/valid/0011.snap
new file mode 100644
index 00000000..48d7b674
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0011.snap
@@ -0,0 +1,25 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT DISTINCT city\n    FROM weather\n    ORDER BY city;\n"
+---
+SelectStmt@0..57
+  Select@0..6 "SELECT"
+  Whitespace@6..7 " "
+  Distinct@7..15 "DISTINCT"
+  Whitespace@15..16 " "
+  Ident@16..20 "city"
+  Newline@20..21 "\n"
+  Whitespace@21..25 "    "
+  From@25..29 "FROM"
+  Whitespace@29..30 " "
+  Ident@30..37 "weather"
+  Newline@37..38 "\n"
+  Whitespace@38..42 "    "
+  Order@42..47 "ORDER"
+  Whitespace@47..48 " "
+  By@48..50 "BY"
+  Whitespace@50..51 " "
+  Ident@51..55 "city"
+  Ascii59@55..56 ";"
+  Newline@56..57 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0012.snap b/crates/parser/tests/snapshots/statements/valid/0012.snap
new file mode 100644
index 00000000..f4d77ae0
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0012.snap
@@ -0,0 +1,52 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE TABLE measurement_y2008m01 PARTITION OF measurement\n    FOR VALUES FROM ('2008-01-01') TO ('2008-02-01')\n    WITH (parallel_workers = 4)\n    TABLESPACE fasttablespace;\n"
+---
+CreateStmt@0..175
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Table@7..12 "TABLE"
+  Whitespace@12..13 " "
+  Ident@13..33 "measurement_y2008m01"
+  Whitespace@33..34 " "
+  Partition@34..43 "PARTITION"
+  Whitespace@43..44 " "
+  Of@44..46 "OF"
+  Whitespace@46..47 " "
+  Ident@47..58 "measurement"
+  Newline@58..59 "\n"
+  Whitespace@59..63 "    "
+  For@63..66 "FOR"
+  Whitespace@66..67 " "
+  Values@67..73 "VALUES"
+  Whitespace@73..74 " "
+  From@74..78 "FROM"
+  Whitespace@78..79 " "
+  Ascii40@79..80 "("
+  Sconst@80..92 "'2008-01-01'"
+  Ascii41@92..93 ")"
+  Whitespace@93..94 " "
+  To@94..96 "TO"
+  Whitespace@96..97 " "
+  Ascii40@97..98 "("
+  Sconst@98..110 "'2008-02-01'"
+  Ascii41@110..111 ")"
+  Newline@111..112 "\n"
+  Whitespace@112..116 "    "
+  With@116..120 "WITH"
+  Whitespace@120..121 " "
+  Ascii40@121..122 "("
+  Ident@122..138 "parallel_workers"
+  Whitespace@138..139 " "
+  Ascii61@139..140 "="
+  Whitespace@140..141 " "
+  Iconst@141..142 "4"
+  Ascii41@142..143 ")"
+  Newline@143..144 "\n"
+  Whitespace@144..148 "    "
+  Tablespace@148..158 "TABLESPACE"
+  Whitespace@158..159 " "
+  Ident@159..173 "fasttablespace"
+  Ascii59@173..174 ";"
+  Newline@174..175 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0013.snap b/crates/parser/tests/snapshots/statements/valid/0013.snap
new file mode 100644
index 00000000..643f1e95
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0013.snap
@@ -0,0 +1,44 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "UPDATE weather\n    SET temp_hi = temp_hi - 2,  temp_lo = temp_lo - 2\n    WHERE date > '1994-11-28';\n"
+---
+UpdateStmt@0..100
+  Update@0..6 "UPDATE"
+  Whitespace@6..7 " "
+  Ident@7..14 "weather"
+  Newline@14..15 "\n"
+  Whitespace@15..19 "    "
+  Set@19..22 "SET"
+  Whitespace@22..23 " "
+  Ident@23..30 "temp_hi"
+  Whitespace@30..31 " "
+  Ascii61@31..32 "="
+  Whitespace@32..33 " "
+  Ident@33..40 "temp_hi"
+  Whitespace@40..41 " "
+  Ascii45@41..42 "-"
+  Whitespace@42..43 " "
+  Iconst@43..44 "2"
+  Ascii44@44..45 ","
+  Whitespace@45..47 "  "
+  Ident@47..54 "temp_lo"
+  Whitespace@54..55 " "
+  Ascii61@55..56 "="
+  Whitespace@56..57 " "
+  Ident@57..64 "temp_lo"
+  Whitespace@64..65 " "
+  Ascii45@65..66 "-"
+  Whitespace@66..67 " "
+  Iconst@67..68 "2"
+  Newline@68..69 "\n"
+  Whitespace@69..73 "    "
+  Where@73..78 "WHERE"
+  Whitespace@78..79 " "
+  Ident@79..83 "date"
+  Whitespace@83..84 " "
+  Ascii62@84..85 ">"
+  Whitespace@85..86 " "
+  Sconst@86..98 "'1994-11-28'"
+  Ascii59@98..99 ";"
+  Newline@99..100 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0014.snap b/crates/parser/tests/snapshots/statements/valid/0014.snap
new file mode 100644
index 00000000..80ceaf6d
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0014.snap
@@ -0,0 +1,56 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT sum(salary) OVER w, avg(salary) OVER w\n  FROM empsalary\n  WINDOW w AS (PARTITION BY depname ORDER BY salary DESC);\n"
+---
+SelectStmt@0..122
+  Select@0..6 "SELECT"
+  Whitespace@6..7 " "
+  Ident@7..10 "sum"
+  Ascii40@10..11 "("
+  Ident@11..17 "salary"
+  Ascii41@17..18 ")"
+  Whitespace@18..19 " "
+  Over@19..23 "OVER"
+  Whitespace@23..24 " "
+  Ident@24..25 "w"
+  Ascii44@25..26 ","
+  Whitespace@26..27 " "
+  Ident@27..30 "avg"
+  Ascii40@30..31 "("
+  Ident@31..37 "salary"
+  Ascii41@37..38 ")"
+  Whitespace@38..39 " "
+  Over@39..43 "OVER"
+  Whitespace@43..44 " "
+  Ident@44..45 "w"
+  Newline@45..46 "\n"
+  Whitespace@46..48 "  "
+  From@48..52 "FROM"
+  Whitespace@52..53 " "
+  Ident@53..62 "empsalary"
+  Newline@62..63 "\n"
+  Whitespace@63..65 "  "
+  Window@65..71 "WINDOW"
+  Whitespace@71..72 " "
+  Ident@72..73 "w"
+  Whitespace@73..74 " "
+  As@74..76 "AS"
+  Whitespace@76..77 " "
+  Ascii40@77..78 "("
+  Partition@78..87 "PARTITION"
+  Whitespace@87..88 " "
+  By@88..90 "BY"
+  Whitespace@90..91 " "
+  Ident@91..98 "depname"
+  Whitespace@98..99 " "
+  Order@99..104 "ORDER"
+  Whitespace@104..105 " "
+  By@105..107 "BY"
+  Whitespace@107..108 " "
+  Ident@108..114 "salary"
+  Whitespace@114..115 " "
+  Desc@115..119 "DESC"
+  Ascii41@119..120 ")"
+  Ascii59@120..121 ";"
+  Newline@121..122 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0015.snap b/crates/parser/tests/snapshots/statements/valid/0015.snap
new file mode 100644
index 00000000..0d9223c5
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0015.snap
@@ -0,0 +1,58 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT\n    count(*) AS unfiltered,\n    count(*) FILTER (WHERE i < 5) AS filtered\nFROM generate_series(1,10) AS s(i);\n"
+---
+SelectStmt@0..117
+  Select@0..6 "SELECT"
+  Newline@6..7 "\n"
+  Whitespace@7..11 "    "
+  Ident@11..16 "count"
+  Ascii40@16..17 "("
+  Ascii42@17..18 "*"
+  Ascii41@18..19 ")"
+  Whitespace@19..20 " "
+  As@20..22 "AS"
+  Whitespace@22..23 " "
+  Ident@23..33 "unfiltered"
+  Ascii44@33..34 ","
+  Newline@34..35 "\n"
+  Whitespace@35..39 "    "
+  Ident@39..44 "count"
+  Ascii40@44..45 "("
+  Ascii42@45..46 "*"
+  Ascii41@46..47 ")"
+  Whitespace@47..48 " "
+  Filter@48..54 "FILTER"
+  Whitespace@54..55 " "
+  Ascii40@55..56 "("
+  Where@56..61 "WHERE"
+  Whitespace@61..62 " "
+  Ident@62..63 "i"
+  Whitespace@63..64 " "
+  Ascii60@64..65 "<"
+  Whitespace@65..66 " "
+  Iconst@66..67 "5"
+  Ascii41@67..68 ")"
+  Whitespace@68..69 " "
+  As@69..71 "AS"
+  Whitespace@71..72 " "
+  Ident@72..80 "filtered"
+  Newline@80..81 "\n"
+  From@81..85 "FROM"
+  Whitespace@85..86 " "
+  Ident@86..101 "generate_series"
+  Ascii40@101..102 "("
+  Iconst@102..103 "1"
+  Ascii44@103..104 ","
+  Iconst@104..106 "10"
+  Ascii41@106..107 ")"
+  Whitespace@107..108 " "
+  As@108..110 "AS"
+  Whitespace@110..111 " "
+  Ident@111..112 "s"
+  Ascii40@112..113 "("
+  Ident@113..114 "i"
+  Ascii41@114..115 ")"
+  Ascii59@115..116 ";"
+  Newline@116..117 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0016.snap b/crates/parser/tests/snapshots/statements/valid/0016.snap
new file mode 100644
index 00000000..6306aa10
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0016.snap
@@ -0,0 +1,27 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT * FROM tbl WHERE a COLLATE \"C\" > 'foo';\n"
+---
+SelectStmt@0..47
+  Select@0..6 "SELECT"
+  Whitespace@6..7 " "
+  Ascii42@7..8 "*"
+  Whitespace@8..9 " "
+  From@9..13 "FROM"
+  Whitespace@13..14 " "
+  Ident@14..17 "tbl"
+  Whitespace@17..18 " "
+  Where@18..23 "WHERE"
+  Whitespace@23..24 " "
+  Ident@24..25 "a"
+  Whitespace@25..26 " "
+  Collate@26..33 "COLLATE"
+  Whitespace@33..34 " "
+  Ident@34..37 "\"C\""
+  Whitespace@37..38 " "
+  Ascii62@38..39 ">"
+  Whitespace@39..40 " "
+  Sconst@40..45 "'foo'"
+  Ascii59@45..46 ";"
+  Newline@46..47 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0017.snap b/crates/parser/tests/snapshots/statements/valid/0017.snap
new file mode 100644
index 00000000..6c3f9d52
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0017.snap
@@ -0,0 +1,42 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT name, (SELECT max(pop) FROM cities WHERE cities.state = states.name)\n    FROM states;\n"
+---
+SelectStmt@0..93
+  Select@0..6 "SELECT"
+  Whitespace@6..7 " "
+  NameP@7..11 "name"
+  Ascii44@11..12 ","
+  Whitespace@12..13 " "
+  Ascii40@13..14 "("
+  Select@14..20 "SELECT"
+  Whitespace@20..21 " "
+  Ident@21..24 "max"
+  Ascii40@24..25 "("
+  Ident@25..28 "pop"
+  Ascii41@28..29 ")"
+  Whitespace@29..30 " "
+  From@30..34 "FROM"
+  Whitespace@34..35 " "
+  Ident@35..41 "cities"
+  Whitespace@41..42 " "
+  Where@42..47 "WHERE"
+  Whitespace@47..48 " "
+  Ident@48..54 "cities"
+  Ascii46@54..55 "."
+  Ident@55..60 "state"
+  Whitespace@60..61 " "
+  Ascii61@61..62 "="
+  Whitespace@62..63 " "
+  Ident@63..69 "states"
+  Ascii46@69..70 "."
+  NameP@70..74 "name"
+  Ascii41@74..75 ")"
+  Newline@75..76 "\n"
+  Whitespace@76..80 "    "
+  From@80..84 "FROM"
+  Whitespace@84..85 " "
+  Ident@85..91 "states"
+  Ascii59@91..92 ";"
+  Newline@92..93 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0018.snap b/crates/parser/tests/snapshots/statements/valid/0018.snap
new file mode 100644
index 00000000..a93ef99c
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0018.snap
@@ -0,0 +1,22 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT ARRAY[1,2,22.7]::integer[];\n"
+---
+SelectStmt@0..35
+  Select@0..6 "SELECT"
+  Whitespace@6..7 " "
+  Array@7..12 "ARRAY"
+  Ascii91@12..13 "["
+  Iconst@13..14 "1"
+  Ascii44@14..15 ","
+  Iconst@15..16 "2"
+  Ascii44@16..17 ","
+  Fconst@17..21 "22.7"
+  Ascii93@21..22 "]"
+  Typecast@22..24 "::"
+  Integer@24..31 "integer"
+  Ascii91@31..32 "["
+  Ascii93@32..33 "]"
+  Ascii59@33..34 ";"
+  Newline@34..35 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0019.snap b/crates/parser/tests/snapshots/statements/valid/0019.snap
new file mode 100644
index 00000000..97f59c8f
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0019.snap
@@ -0,0 +1,42 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT CASE WHEN min(employees) > 0\n            THEN avg(expenses / employees)\n       END\n    FROM departments;\n"
+---
+SelectStmt@0..112
+  Select@0..6 "SELECT"
+  Whitespace@6..7 " "
+  Case@7..11 "CASE"
+  Whitespace@11..12 " "
+  When@12..16 "WHEN"
+  Whitespace@16..17 " "
+  Ident@17..20 "min"
+  Ascii40@20..21 "("
+  Ident@21..30 "employees"
+  Ascii41@30..31 ")"
+  Whitespace@31..32 " "
+  Ascii62@32..33 ">"
+  Whitespace@33..34 " "
+  Iconst@34..35 "0"
+  Newline@35..36 "\n"
+  Whitespace@36..48 "            "
+  Then@48..52 "THEN"
+  Whitespace@52..53 " "
+  Ident@53..56 "avg"
+  Ascii40@56..57 "("
+  Ident@57..65 "expenses"
+  Whitespace@65..66 " "
+  Ascii47@66..67 "/"
+  Whitespace@67..68 " "
+  Ident@68..77 "employees"
+  Ascii41@77..78 ")"
+  Newline@78..79 "\n"
+  Whitespace@79..86 "       "
+  EndP@86..89 "END"
+  Newline@89..90 "\n"
+  Whitespace@90..94 "    "
+  From@94..98 "FROM"
+  Whitespace@98..99 " "
+  Ident@99..110 "departments"
+  Ascii59@110..111 ";"
+  Newline@111..112 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0020.snap b/crates/parser/tests/snapshots/statements/valid/0020.snap
new file mode 100644
index 00000000..f84f0ed9
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0020.snap
@@ -0,0 +1,48 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE FUNCTION concat_lower_or_upper(a text, b text, uppercase boolean DEFAULT false)\nRETURNS text\nAS\n$$\n SELECT CASE\n        WHEN $3 THEN UPPER($1 || ' ' || $2)\n        ELSE LOWER($1 || ' ' || $2)\n        END;\n$$\nLANGUAGE SQL IMMUTABLE STRICT;\n"
+---
+CreateFunctionStmt@0..246
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Function@7..15 "FUNCTION"
+  Whitespace@15..16 " "
+  Ident@16..37 "concat_lower_or_upper"
+  Ascii40@37..38 "("
+  Ident@38..39 "a"
+  Whitespace@39..40 " "
+  TextP@40..44 "text"
+  Ascii44@44..45 ","
+  Whitespace@45..46 " "
+  Ident@46..47 "b"
+  Whitespace@47..48 " "
+  TextP@48..52 "text"
+  Ascii44@52..53 ","
+  Whitespace@53..54 " "
+  Ident@54..63 "uppercase"
+  Whitespace@63..64 " "
+  BooleanP@64..71 "boolean"
+  Whitespace@71..72 " "
+  Default@72..79 "DEFAULT"
+  Whitespace@79..80 " "
+  FalseP@80..85 "false"
+  Ascii41@85..86 ")"
+  Newline@86..87 "\n"
+  Returns@87..94 "RETURNS"
+  Whitespace@94..95 " "
+  TextP@95..99 "text"
+  Newline@99..100 "\n"
+  As@100..102 "AS"
+  Newline@102..103 "\n"
+  Sconst@103..214 "$$\n SELECT CASE\n      ..."
+  Newline@214..215 "\n"
+  Language@215..223 "LANGUAGE"
+  Whitespace@223..224 " "
+  SqlP@224..227 "SQL"
+  Whitespace@227..228 " "
+  Immutable@228..237 "IMMUTABLE"
+  Whitespace@237..238 " "
+  StrictP@238..244 "STRICT"
+  Ascii59@244..245 ";"
+  Newline@245..246 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0021.snap b/crates/parser/tests/snapshots/statements/valid/0021.snap
new file mode 100644
index 00000000..ec8ea421
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0021.snap
@@ -0,0 +1,32 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SELECT concat_lower_or_upper(a => 'Hello', b => 'World', uppercase => true);\n"
+---
+SelectStmt@0..77
+  Select@0..6 "SELECT"
+  Whitespace@6..7 " "
+  Ident@7..28 "concat_lower_or_upper"
+  Ascii40@28..29 "("
+  Ident@29..30 "a"
+  Whitespace@30..31 " "
+  EqualsGreater@31..33 "=>"
+  Whitespace@33..34 " "
+  Sconst@34..41 "'Hello'"
+  Ascii44@41..42 ","
+  Whitespace@42..43 " "
+  Ident@43..44 "b"
+  Whitespace@44..45 " "
+  EqualsGreater@45..47 "=>"
+  Whitespace@47..48 " "
+  Sconst@48..55 "'World'"
+  Ascii44@55..56 ","
+  Whitespace@56..57 " "
+  Ident@57..66 "uppercase"
+  Whitespace@66..67 " "
+  EqualsGreater@67..69 "=>"
+  Whitespace@69..70 " "
+  TrueP@70..74 "true"
+  Ascii41@74..75 ")"
+  Ascii59@75..76 ";"
+  Newline@76..77 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0022.snap b/crates/parser/tests/snapshots/statements/valid/0022.snap
new file mode 100644
index 00000000..b80610e9
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0022.snap
@@ -0,0 +1,38 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE TABLE products (\n    product_no integer,\n    name text,\n    price numeric DEFAULT 9.99\n);\n"
+---
+CreateStmt@0..97
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Table@7..12 "TABLE"
+  Whitespace@12..13 " "
+  Ident@13..21 "products"
+  Whitespace@21..22 " "
+  Ascii40@22..23 "("
+  Newline@23..24 "\n"
+  Whitespace@24..28 "    "
+  Ident@28..38 "product_no"
+  Whitespace@38..39 " "
+  Integer@39..46 "integer"
+  Ascii44@46..47 ","
+  Newline@47..48 "\n"
+  Whitespace@48..52 "    "
+  NameP@52..56 "name"
+  Whitespace@56..57 " "
+  TextP@57..61 "text"
+  Ascii44@61..62 ","
+  Newline@62..63 "\n"
+  Whitespace@63..67 "    "
+  Ident@67..72 "price"
+  Whitespace@72..73 " "
+  Numeric@73..80 "numeric"
+  Whitespace@80..81 " "
+  Default@81..88 "DEFAULT"
+  Whitespace@88..89 " "
+  Fconst@89..93 "9.99"
+  Newline@93..94 "\n"
+  Ascii41@94..95 ")"
+  Ascii59@95..96 ";"
+  Newline@96..97 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0023.snap b/crates/parser/tests/snapshots/statements/valid/0023.snap
new file mode 100644
index 00000000..2a8ccc2b
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0023.snap
@@ -0,0 +1,72 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE TABLE products (\n    product_no integer,\n    name text,\n    price numeric CHECK (price > 0),\n    discounted_price numeric CHECK (discounted_price > 0),\n    CHECK (price > discounted_price)\n);\n"
+---
+CreateStmt@0..199
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Table@7..12 "TABLE"
+  Whitespace@12..13 " "
+  Ident@13..21 "products"
+  Whitespace@21..22 " "
+  Ascii40@22..23 "("
+  Newline@23..24 "\n"
+  Whitespace@24..28 "    "
+  Ident@28..38 "product_no"
+  Whitespace@38..39 " "
+  Integer@39..46 "integer"
+  Ascii44@46..47 ","
+  Newline@47..48 "\n"
+  Whitespace@48..52 "    "
+  NameP@52..56 "name"
+  Whitespace@56..57 " "
+  TextP@57..61 "text"
+  Ascii44@61..62 ","
+  Newline@62..63 "\n"
+  Whitespace@63..67 "    "
+  Ident@67..72 "price"
+  Whitespace@72..73 " "
+  Numeric@73..80 "numeric"
+  Whitespace@80..81 " "
+  Check@81..86 "CHECK"
+  Whitespace@86..87 " "
+  Ascii40@87..88 "("
+  Ident@88..93 "price"
+  Whitespace@93..94 " "
+  Ascii62@94..95 ">"
+  Whitespace@95..96 " "
+  Iconst@96..97 "0"
+  Ascii41@97..98 ")"
+  Ascii44@98..99 ","
+  Newline@99..100 "\n"
+  Whitespace@100..104 "    "
+  Ident@104..120 "discounted_price"
+  Whitespace@120..121 " "
+  Numeric@121..128 "numeric"
+  Whitespace@128..129 " "
+  Check@129..134 "CHECK"
+  Whitespace@134..135 " "
+  Ascii40@135..136 "("
+  Ident@136..152 "discounted_price"
+  Whitespace@152..153 " "
+  Ascii62@153..154 ">"
+  Whitespace@154..155 " "
+  Iconst@155..156 "0"
+  Ascii41@156..157 ")"
+  Ascii44@157..158 ","
+  Newline@158..159 "\n"
+  Whitespace@159..163 "    "
+  Check@163..168 "CHECK"
+  Whitespace@168..169 " "
+  Ascii40@169..170 "("
+  Ident@170..175 "price"
+  Whitespace@175..176 " "
+  Ascii62@176..177 ">"
+  Whitespace@177..178 " "
+  Ident@178..194 "discounted_price"
+  Ascii41@194..195 ")"
+  Newline@195..196 "\n"
+  Ascii41@196..197 ")"
+  Ascii59@197..198 ";"
+  Newline@198..199 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0024.snap b/crates/parser/tests/snapshots/statements/valid/0024.snap
new file mode 100644
index 00000000..e4c63589
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0024.snap
@@ -0,0 +1,55 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE TABLE order_items (\n    product_no integer REFERENCES products,\n    order_id integer REFERENCES orders,\n    quantity integer,\n    PRIMARY KEY (product_no, order_id)\n);\n"
+---
+CreateStmt@0..175
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Table@7..12 "TABLE"
+  Whitespace@12..13 " "
+  Ident@13..24 "order_items"
+  Whitespace@24..25 " "
+  Ascii40@25..26 "("
+  Newline@26..27 "\n"
+  Whitespace@27..31 "    "
+  Ident@31..41 "product_no"
+  Whitespace@41..42 " "
+  Integer@42..49 "integer"
+  Whitespace@49..50 " "
+  References@50..60 "REFERENCES"
+  Whitespace@60..61 " "
+  Ident@61..69 "products"
+  Ascii44@69..70 ","
+  Newline@70..71 "\n"
+  Whitespace@71..75 "    "
+  Ident@75..83 "order_id"
+  Whitespace@83..84 " "
+  Integer@84..91 "integer"
+  Whitespace@91..92 " "
+  References@92..102 "REFERENCES"
+  Whitespace@102..103 " "
+  Ident@103..109 "orders"
+  Ascii44@109..110 ","
+  Newline@110..111 "\n"
+  Whitespace@111..115 "    "
+  Ident@115..123 "quantity"
+  Whitespace@123..124 " "
+  Integer@124..131 "integer"
+  Ascii44@131..132 ","
+  Newline@132..133 "\n"
+  Whitespace@133..137 "    "
+  Primary@137..144 "PRIMARY"
+  Whitespace@144..145 " "
+  Key@145..148 "KEY"
+  Whitespace@148..149 " "
+  Ascii40@149..150 "("
+  Ident@150..160 "product_no"
+  Ascii44@160..161 ","
+  Whitespace@161..162 " "
+  Ident@162..170 "order_id"
+  Ascii41@170..171 ")"
+  Newline@171..172 "\n"
+  Ascii41@172..173 ")"
+  Ascii59@173..174 ";"
+  Newline@174..175 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0025.snap b/crates/parser/tests/snapshots/statements/valid/0025.snap
new file mode 100644
index 00000000..cc279acf
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0025.snap
@@ -0,0 +1,25 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "ALTER TABLE products ADD CHECK (name <> '');\n"
+---
+AlterTableStmt@0..45
+  Alter@0..5 "ALTER"
+  Whitespace@5..6 " "
+  Table@6..11 "TABLE"
+  Whitespace@11..12 " "
+  Ident@12..20 "products"
+  Whitespace@20..21 " "
+  AddP@21..24 "ADD"
+  Whitespace@24..25 " "
+  Check@25..30 "CHECK"
+  Whitespace@30..31 " "
+  Ascii40@31..32 "("
+  NameP@32..36 "name"
+  Whitespace@36..37 " "
+  NotEquals@37..39 "<>"
+  Whitespace@39..40 " "
+  Sconst@40..42 "''"
+  Ascii41@42..43 ")"
+  Ascii59@43..44 ";"
+  Newline@44..45 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0026.snap b/crates/parser/tests/snapshots/statements/valid/0026.snap
new file mode 100644
index 00000000..730b2138
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0026.snap
@@ -0,0 +1,28 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "ALTER TABLE products ALTER COLUMN price TYPE numeric(10,2);\n"
+---
+AlterTableStmt@0..60
+  Alter@0..5 "ALTER"
+  Whitespace@5..6 " "
+  Table@6..11 "TABLE"
+  Whitespace@11..12 " "
+  Ident@12..20 "products"
+  Whitespace@20..21 " "
+  Alter@21..26 "ALTER"
+  Whitespace@26..27 " "
+  Column@27..33 "COLUMN"
+  Whitespace@33..34 " "
+  Ident@34..39 "price"
+  Whitespace@39..40 " "
+  TypeP@40..44 "TYPE"
+  Whitespace@44..45 " "
+  Numeric@45..52 "numeric"
+  Ascii40@52..53 "("
+  Iconst@53..55 "10"
+  Ascii44@55..56 ","
+  Iconst@56..57 "2"
+  Ascii41@57..58 ")"
+  Ascii59@58..59 ";"
+  Newline@59..60 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0027.snap b/crates/parser/tests/snapshots/statements/valid/0027.snap
new file mode 100644
index 00000000..2b88e432
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0027.snap
@@ -0,0 +1,19 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "GRANT UPDATE ON accounts TO joe;\n"
+---
+GrantStmt@0..33
+  Grant@0..5 "GRANT"
+  Whitespace@5..6 " "
+  Update@6..12 "UPDATE"
+  Whitespace@12..13 " "
+  On@13..15 "ON"
+  Whitespace@15..16 " "
+  Ident@16..24 "accounts"
+  Whitespace@24..25 " "
+  To@25..27 "TO"
+  Whitespace@27..28 " "
+  Ident@28..31 "joe"
+  Ascii59@31..32 ";"
+  Newline@32..33 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0028.snap b/crates/parser/tests/snapshots/statements/valid/0028.snap
new file mode 100644
index 00000000..c9ca0372
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0028.snap
@@ -0,0 +1,19 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "REVOKE ALL ON accounts FROM PUBLIC;\n"
+---
+GrantStmt@0..36
+  Revoke@0..6 "REVOKE"
+  Whitespace@6..7 " "
+  All@7..10 "ALL"
+  Whitespace@10..11 " "
+  On@11..13 "ON"
+  Whitespace@13..14 " "
+  Ident@14..22 "accounts"
+  Whitespace@22..23 " "
+  From@23..27 "FROM"
+  Whitespace@27..28 " "
+  Ident@28..34 "PUBLIC"
+  Ascii59@34..35 ";"
+  Newline@35..36 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0029.snap b/crates/parser/tests/snapshots/statements/valid/0029.snap
new file mode 100644
index 00000000..ae280f52
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0029.snap
@@ -0,0 +1,30 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "GRANT SELECT (col1), UPDATE (col1) ON mytable TO miriam_rw;\n"
+---
+GrantStmt@0..60
+  Grant@0..5 "GRANT"
+  Whitespace@5..6 " "
+  Select@6..12 "SELECT"
+  Whitespace@12..13 " "
+  Ascii40@13..14 "("
+  Ident@14..18 "col1"
+  Ascii41@18..19 ")"
+  Ascii44@19..20 ","
+  Whitespace@20..21 " "
+  Update@21..27 "UPDATE"
+  Whitespace@27..28 " "
+  Ascii40@28..29 "("
+  Ident@29..33 "col1"
+  Ascii41@33..34 ")"
+  Whitespace@34..35 " "
+  On@35..37 "ON"
+  Whitespace@37..38 " "
+  Ident@38..45 "mytable"
+  Whitespace@45..46 " "
+  To@46..48 "TO"
+  Whitespace@48..49 " "
+  Ident@49..58 "miriam_rw"
+  Ascii59@58..59 ";"
+  Newline@59..60 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0030.snap b/crates/parser/tests/snapshots/statements/valid/0030.snap
new file mode 100644
index 00000000..68c40f34
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0030.snap
@@ -0,0 +1,32 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE POLICY account_managers ON accounts TO managers\n    USING (manager = current_user);\n"
+---
+CreatePolicyStmt@0..91
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Policy@7..13 "POLICY"
+  Whitespace@13..14 " "
+  Ident@14..30 "account_managers"
+  Whitespace@30..31 " "
+  On@31..33 "ON"
+  Whitespace@33..34 " "
+  Ident@34..42 "accounts"
+  Whitespace@42..43 " "
+  To@43..45 "TO"
+  Whitespace@45..46 " "
+  Ident@46..54 "managers"
+  Newline@54..55 "\n"
+  Whitespace@55..59 "    "
+  Using@59..64 "USING"
+  Whitespace@64..65 " "
+  Ascii40@65..66 "("
+  Ident@66..73 "manager"
+  Whitespace@73..74 " "
+  Ascii61@74..75 "="
+  Whitespace@75..76 " "
+  CurrentUser@76..88 "current_user"
+  Ascii41@88..89 ")"
+  Ascii59@89..90 ";"
+  Newline@90..91 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0031.snap b/crates/parser/tests/snapshots/statements/valid/0031.snap
new file mode 100644
index 00000000..f3456e11
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0031.snap
@@ -0,0 +1,68 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE POLICY user_mod ON passwd FOR UPDATE\n  USING (current_user = user_name)\n  WITH CHECK (\n    current_user = user_name AND\n    shell IN ('/bin/bash','/bin/sh','/bin/dash','/bin/zsh','/bin/tcsh')\n  );\n"
+---
+CreatePolicyStmt@0..204
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Policy@7..13 "POLICY"
+  Whitespace@13..14 " "
+  Ident@14..22 "user_mod"
+  Whitespace@22..23 " "
+  On@23..25 "ON"
+  Whitespace@25..26 " "
+  Ident@26..32 "passwd"
+  Whitespace@32..33 " "
+  For@33..36 "FOR"
+  Whitespace@36..37 " "
+  Update@37..43 "UPDATE"
+  Newline@43..44 "\n"
+  Whitespace@44..46 "  "
+  Using@46..51 "USING"
+  Whitespace@51..52 " "
+  Ascii40@52..53 "("
+  CurrentUser@53..65 "current_user"
+  Whitespace@65..66 " "
+  Ascii61@66..67 "="
+  Whitespace@67..68 " "
+  Ident@68..77 "user_name"
+  Ascii41@77..78 ")"
+  Newline@78..79 "\n"
+  Whitespace@79..81 "  "
+  With@81..85 "WITH"
+  Whitespace@85..86 " "
+  Check@86..91 "CHECK"
+  Whitespace@91..92 " "
+  Ascii40@92..93 "("
+  Newline@93..94 "\n"
+  Whitespace@94..98 "    "
+  CurrentUser@98..110 "current_user"
+  Whitespace@110..111 " "
+  Ascii61@111..112 "="
+  Whitespace@112..113 " "
+  Ident@113..122 "user_name"
+  Whitespace@122..123 " "
+  And@123..126 "AND"
+  Newline@126..127 "\n"
+  Whitespace@127..131 "    "
+  Ident@131..136 "shell"
+  Whitespace@136..137 " "
+  InP@137..139 "IN"
+  Whitespace@139..140 " "
+  Ascii40@140..141 "("
+  Sconst@141..152 "'/bin/bash'"
+  Ascii44@152..153 ","
+  Sconst@153..162 "'/bin/sh'"
+  Ascii44@162..163 ","
+  Sconst@163..174 "'/bin/dash'"
+  Ascii44@174..175 ","
+  Sconst@175..185 "'/bin/zsh'"
+  Ascii44@185..186 ","
+  Sconst@186..197 "'/bin/tcsh'"
+  Ascii41@197..198 ")"
+  Newline@198..199 "\n"
+  Whitespace@199..201 "  "
+  Ascii41@201..202 ")"
+  Ascii59@202..203 ";"
+  Newline@203..204 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0032.snap b/crates/parser/tests/snapshots/statements/valid/0032.snap
new file mode 100644
index 00000000..d82132b6
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0032.snap
@@ -0,0 +1,17 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "SET search_path TO myschema,public;\n"
+---
+VariableSetStmt@0..36
+  Set@0..3 "SET"
+  Whitespace@3..4 " "
+  Ident@4..15 "search_path"
+  Whitespace@15..16 " "
+  To@16..18 "TO"
+  Whitespace@18..19 " "
+  Ident@19..27 "myschema"
+  Ascii44@27..28 ","
+  Ident@28..34 "public"
+  Ascii59@34..35 ";"
+  Newline@35..36 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0033.snap b/crates/parser/tests/snapshots/statements/valid/0033.snap
new file mode 100644
index 00000000..dbef84a2
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0033.snap
@@ -0,0 +1,58 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE TABLE measurement (\n    city_id         int not null,\n    logdate         date not null,\n    peaktemp        int,\n    unitsales       int\n) PARTITION BY RANGE (logdate);\n"
+---
+CreateStmt@0..177
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Table@7..12 "TABLE"
+  Whitespace@12..13 " "
+  Ident@13..24 "measurement"
+  Whitespace@24..25 " "
+  Ascii40@25..26 "("
+  Newline@26..27 "\n"
+  Whitespace@27..31 "    "
+  Ident@31..38 "city_id"
+  Whitespace@38..47 "         "
+  IntP@47..50 "int"
+  Whitespace@50..51 " "
+  Not@51..54 "not"
+  Whitespace@54..55 " "
+  NullP@55..59 "null"
+  Ascii44@59..60 ","
+  Newline@60..61 "\n"
+  Whitespace@61..65 "    "
+  Ident@65..72 "logdate"
+  Whitespace@72..81 "         "
+  Ident@81..85 "date"
+  Whitespace@85..86 " "
+  Not@86..89 "not"
+  Whitespace@89..90 " "
+  NullP@90..94 "null"
+  Ascii44@94..95 ","
+  Newline@95..96 "\n"
+  Whitespace@96..100 "    "
+  Ident@100..108 "peaktemp"
+  Whitespace@108..116 "        "
+  IntP@116..119 "int"
+  Ascii44@119..120 ","
+  Newline@120..121 "\n"
+  Whitespace@121..125 "    "
+  Ident@125..134 "unitsales"
+  Whitespace@134..141 "       "
+  IntP@141..144 "int"
+  Newline@144..145 "\n"
+  Ascii41@145..146 ")"
+  Whitespace@146..147 " "
+  Partition@147..156 "PARTITION"
+  Whitespace@156..157 " "
+  By@157..159 "BY"
+  Whitespace@159..160 " "
+  Range@160..165 "RANGE"
+  Whitespace@165..166 " "
+  Ascii40@166..167 "("
+  Ident@167..174 "logdate"
+  Ascii41@174..175 ")"
+  Ascii59@175..176 ";"
+  Newline@176..177 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0034.snap b/crates/parser/tests/snapshots/statements/valid/0034.snap
new file mode 100644
index 00000000..efede445
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0034.snap
@@ -0,0 +1,25 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "select *,some_col from contact where id = '123 4 5';\n"
+---
+SelectStmt@0..53
+  Select@0..6 "select"
+  Whitespace@6..7 " "
+  Ascii42@7..8 "*"
+  Ascii44@8..9 ","
+  Ident@9..17 "some_col"
+  Whitespace@17..18 " "
+  From@18..22 "from"
+  Whitespace@22..23 " "
+  Ident@23..30 "contact"
+  Whitespace@30..31 " "
+  Where@31..36 "where"
+  Whitespace@36..37 " "
+  Ident@37..39 "id"
+  Whitespace@39..40 " "
+  Ascii61@40..41 "="
+  Whitespace@41..42 " "
+  Sconst@42..51 "'123 4 5'"
+  Ascii59@51..52 ";"
+  Newline@52..53 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0035.snap b/crates/parser/tests/snapshots/statements/valid/0035.snap
new file mode 100644
index 00000000..efede445
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0035.snap
@@ -0,0 +1,25 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "select *,some_col from contact where id = '123 4 5';\n"
+---
+SelectStmt@0..53
+  Select@0..6 "select"
+  Whitespace@6..7 " "
+  Ascii42@7..8 "*"
+  Ascii44@8..9 ","
+  Ident@9..17 "some_col"
+  Whitespace@17..18 " "
+  From@18..22 "from"
+  Whitespace@22..23 " "
+  Ident@23..30 "contact"
+  Whitespace@30..31 " "
+  Where@31..36 "where"
+  Whitespace@36..37 " "
+  Ident@37..39 "id"
+  Whitespace@39..40 " "
+  Ascii61@40..41 "="
+  Whitespace@41..42 " "
+  Sconst@42..51 "'123 4 5'"
+  Ascii59@51..52 ";"
+  Newline@52..53 "\n"
+
diff --git a/crates/parser/tests/snapshots/statements/valid/0036.snap b/crates/parser/tests/snapshots/statements/valid/0036.snap
new file mode 100644
index 00000000..56b13946
--- /dev/null
+++ b/crates/parser/tests/snapshots/statements/valid/0036.snap
@@ -0,0 +1,42 @@
+---
+source: crates/parser/tests/statement_parser_test.rs
+description: "CREATE FUNCTION dup(in int, out f1 int, out f2 text)\n    AS $$ SELECT $1, CAST($1 AS text) || ' is text' $$\n    LANGUAGE SQL;\n"
+---
+CreateFunctionStmt@0..126
+  Create@0..6 "CREATE"
+  Whitespace@6..7 " "
+  Function@7..15 "FUNCTION"
+  Whitespace@15..16 " "
+  Ident@16..19 "dup"
+  Ascii40@19..20 "("
+  InP@20..22 "in"
+  Whitespace@22..23 " "
+  IntP@23..26 "int"
+  Ascii44@26..27 ","
+  Whitespace@27..28 " "
+  OutP@28..31 "out"
+  Whitespace@31..32 " "
+  Ident@32..34 "f1"
+  Whitespace@34..35 " "
+  IntP@35..38 "int"
+  Ascii44@38..39 ","
+  Whitespace@39..40 " "
+  OutP@40..43 "out"
+  Whitespace@43..44 " "
+  Ident@44..46 "f2"
+  Whitespace@46..47 " "
+  TextP@47..51 "text"
+  Ascii41@51..52 ")"
+  Newline@52..53 "\n"
+  Whitespace@53..57 "    "
+  As@57..59 "AS"
+  Whitespace@59..60 " "
+  Sconst@60..107 "$$ SELECT $1, CAST($1 ..."
+  Newline@107..108 "\n"
+  Whitespace@108..112 "    "
+  Language@112..120 "LANGUAGE"
+  Whitespace@120..121 " "
+  SqlP@121..124 "SQL"
+  Ascii59@124..125 ";"
+  Newline@125..126 "\n"
+
diff --git a/crates/parser/tests/statement_parser_test.rs b/crates/parser/tests/statement_parser_test.rs
index 73c1eeca..4eef7303 100644
--- a/crates/parser/tests/statement_parser_test.rs
+++ b/crates/parser/tests/statement_parser_test.rs
@@ -1,4 +1,3 @@
-use std::assert_eq;
 use std::fs;
 mod common;
 use insta;
@@ -18,6 +17,8 @@ fn valid_statements() {
 
     paths.iter().for_each(|f| {
         let path = f.path();
+        let file_name = path.file_name().unwrap();
+        let test_name = file_name.to_str().unwrap().replace(".sql", "");
 
         let contents = fs::read_to_string(&path).unwrap();
 
@@ -25,9 +26,6 @@ fn valid_statements() {
         parser.parse_statement(&contents, None);
         let parsed = parser.finish();
 
-        let file_name = path.file_name().unwrap();
-        let test_name = file_name.to_str().unwrap().replace(".sql", "");
-
         let mut settings = insta::Settings::clone_current();
         settings.set_input_file(path);
         settings.set_prepend_module_to_snapshot(false);
@@ -39,8 +37,3 @@ fn valid_statements() {
         });
     });
 }
-
-#[test]
-fn invalid_statements() {
-    assert_eq!(4, 2);
-}

From 2059e0743f5d89ffd0f39293117dd93fce458e1c Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Tue, 12 Sep 2023 18:39:02 +0200
Subject: [PATCH 21/23] chore: cleanup

---
 crates/codegen/Cargo.toml               |  2 ++
 crates/codegen/src/syntax_kind.rs       |  3 ++-
 crates/parser/Cargo.toml                |  3 +++
 crates/parser/src/statement.rs          | 20 +++++++++-----------
 crates/pg_query_proto_parser/Cargo.toml |  3 +++
 5 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/crates/codegen/Cargo.toml b/crates/codegen/Cargo.toml
index 78776067..86b06851 100644
--- a/crates/codegen/Cargo.toml
+++ b/crates/codegen/Cargo.toml
@@ -12,3 +12,5 @@ pg_query_proto_parser.workspace = true
 
 [lib]
 proc-macro = true
+doctest = false
+
diff --git a/crates/codegen/src/syntax_kind.rs b/crates/codegen/src/syntax_kind.rs
index 76b9467f..652cb16b 100644
--- a/crates/codegen/src/syntax_kind.rs
+++ b/crates/codegen/src/syntax_kind.rs
@@ -1,11 +1,12 @@
 use std::collections::HashSet;
+use std::env::current_dir;
 
 use pg_query_proto_parser::{Node, ProtoParser, Token};
 use proc_macro2::{Ident, Literal};
 use quote::{format_ident, quote};
 
 pub fn syntax_kind_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
-    let parser = ProtoParser::new("./libpg_query/protobuf/pg_query.proto");
+    let parser = ProtoParser::new("libpg_query/protobuf/pg_query.proto");
     let proto_file = parser.parse();
 
     let custom_node_names = custom_node_names();
diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml
index be917fe3..2049bace 100644
--- a/crates/parser/Cargo.toml
+++ b/crates/parser/Cargo.toml
@@ -20,3 +20,6 @@ pg_query_proto_parser.workspace = true
 
 [dev-dependencies]
 insta = "1.31.0"
+
+[lib]
+doctest = false
diff --git a/crates/parser/src/statement.rs b/crates/parser/src/statement.rs
index 7c5d7334..51b488b5 100644
--- a/crates/parser/src/statement.rs
+++ b/crates/parser/src/statement.rs
@@ -5,9 +5,8 @@ use crate::{parser::Parser, syntax_kind_codegen::SyntaxKind};
 
 /// A super simple lexer for sql statements.
 ///
-/// One weakness of pg_query.rs is that it does not parse whitespace or newlines. To circumvent
-/// this, we use a very simple lexer that just knows what kind of characters are being used. It
-/// does not know anything about postgres syntax or keywords. For example, all words such as `select` and `from` are put into the `Word` type.
+/// One weakness of pg_query.rs is that it does not parse whitespace or newlines. We use a very
+/// simple lexer to fill the gaps.
 #[derive(Logos, Debug, PartialEq)]
 pub enum StatementToken {
     // comments and whitespaces
@@ -38,18 +37,17 @@ impl Parser {
     /// The main entry point for parsing a statement `text`. `at_offset` is the offset of the statement in the source file.
     ///
     /// On a high level, the algorithm works as follows:
-    /// 1. Parse the statement with pg_query.rs and order nodes by their position. If the
-    ///   statement contains syntax errors, the parser will report the error and continue to work without information
+    /// 1. Parse the statement with pg_query.rs. If the statement contains syntax errors, the parser will report the error and continue to work without information
     ///   about the nodes. The result will be a flat list of tokens under the generic `Stmt` node.
     ///   If successful, the first node in the ordered list will be the main node of the statement,
     ///   and serves as a root node.
     /// 2. Scan the statements for tokens with pg_query.rs. This will never fail, even if the statement contains syntax errors.
-    /// 3. Parse the statement with the `StatementToken` lexer. The lexer will be the main vehicle
-    ///    while walking the statement.
-    /// 4. Walk the statement with the `StatementToken` lexer.
-    ///    - at every token, consume all nodes that are within the token's range.
-    ///    - if there is a pg_query token within the token's range, consume it. if not, fallback to
-    ///    the StatementToken. This is the case for e.g. whitespace.
+    /// 3. Parse the statement with the `StatementToken` lexer. The lexer only contains the tokens
+    ///    that are not parsed by pg_query.rs, such as whitespace.
+    /// 4. Define a pointer that starts at 0 and move it along the statement.
+    ///    - first, check if the current pointer is within a pg_query token. If so, consume the
+    ///    token.
+    ///    - if not, consume the next token from the `StatementToken` lexer.
     /// 5. Close all open nodes for that statement.
     pub fn parse_statement(&mut self, text: &str, at_offset: Option<u32>) {
         let offset = at_offset.unwrap_or(0);
diff --git a/crates/pg_query_proto_parser/Cargo.toml b/crates/pg_query_proto_parser/Cargo.toml
index 36679697..a8c0fdb5 100644
--- a/crates/pg_query_proto_parser/Cargo.toml
+++ b/crates/pg_query_proto_parser/Cargo.toml
@@ -9,3 +9,6 @@ edition = "2021"
 protobuf-parse = "3.2.0"
 protobuf = "3.2.0"
 convert_case = "0.6.0"
+
+[lib]
+doctest = false

From c7b3a408d5c6e8c4004ae030940ac9cb229cf750 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Fri, 15 Sep 2023 11:21:46 +0200
Subject: [PATCH 22/23] fix: checkout submodule in ci

---
 .github/workflows/ci.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 50a2f674..cd99e9ec 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -17,6 +17,8 @@ jobs:
     steps:
       - name: 🏗 Setup repository
         uses: actions/checkout@v3
+        with:
+          submodules: "libpg_query"
 
       - name: 🏗 Setup monorepo
         uses: ./.github/actions/setup-monorepo

From 5300b17339cde44c6071fc1d6b31186b1b5615e6 Mon Sep 17 00:00:00 2001
From: psteinroe <philipp@steinroetter.com>
Date: Fri, 15 Sep 2023 11:28:50 +0200
Subject: [PATCH 23/23] fix: checkout submodule in ci

---
 .github/workflows/ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index cd99e9ec..8517ca70 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -18,7 +18,7 @@ jobs:
       - name: 🏗 Setup repository
         uses: actions/checkout@v3
         with:
-          submodules: "libpg_query"
+          submodules: true
 
       - name: 🏗 Setup monorepo
         uses: ./.github/actions/setup-monorepo