duckdb 0.7.2-dev2430.0 → 0.7.2-dev2552.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/package.json +1 -1
  2. package/src/connection.cpp +1 -1
  3. package/src/duckdb/extension/icu/icu-dateadd.cpp +3 -3
  4. package/src/duckdb/extension/icu/icu-datepart.cpp +3 -3
  5. package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
  6. package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
  7. package/src/duckdb/extension/icu/icu-extension.cpp +3 -3
  8. package/src/duckdb/extension/icu/icu-list-range.cpp +2 -2
  9. package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
  10. package/src/duckdb/extension/icu/icu-strptime.cpp +4 -4
  11. package/src/duckdb/extension/icu/icu-table-range.cpp +2 -2
  12. package/src/duckdb/extension/icu/icu-timebucket.cpp +1 -1
  13. package/src/duckdb/extension/icu/icu-timezone.cpp +4 -4
  14. package/src/duckdb/extension/json/json-extension.cpp +6 -6
  15. package/src/duckdb/extension/parquet/parquet-extension.cpp +9 -8
  16. package/src/duckdb/src/catalog/catalog.cpp +166 -127
  17. package/src/duckdb/src/catalog/catalog_entry/copy_function_catalog_entry.cpp +3 -3
  18. package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +1 -1
  19. package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +90 -82
  20. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +65 -67
  21. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +3 -3
  22. package/src/duckdb/src/catalog/catalog_entry/pragma_function_catalog_entry.cpp +4 -4
  23. package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +8 -8
  24. package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +10 -10
  25. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +6 -6
  26. package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +6 -6
  27. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +4 -4
  28. package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +9 -9
  29. package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +5 -5
  30. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +23 -23
  31. package/src/duckdb/src/catalog/catalog_entry.cpp +27 -6
  32. package/src/duckdb/src/catalog/catalog_search_path.cpp +2 -2
  33. package/src/duckdb/src/catalog/catalog_set.cpp +84 -87
  34. package/src/duckdb/src/catalog/catalog_transaction.cpp +1 -1
  35. package/src/duckdb/src/catalog/default/default_functions.cpp +1 -1
  36. package/src/duckdb/src/catalog/default/default_schemas.cpp +1 -1
  37. package/src/duckdb/src/catalog/default/default_types.cpp +1 -1
  38. package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
  39. package/src/duckdb/src/catalog/dependency_list.cpp +2 -2
  40. package/src/duckdb/src/catalog/dependency_manager.cpp +9 -10
  41. package/src/duckdb/src/catalog/duck_catalog.cpp +30 -26
  42. package/src/duckdb/src/catalog/similar_catalog_entry.cpp +1 -1
  43. package/src/duckdb/src/common/types.cpp +15 -27
  44. package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +2 -2
  45. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +4 -3
  46. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +19 -18
  47. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +5 -5
  48. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
  49. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +1 -1
  50. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +6 -5
  51. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +1 -1
  52. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +1 -1
  53. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
  54. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +4 -3
  55. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +1 -1
  56. package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +1 -1
  57. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +2 -2
  58. package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +1 -1
  59. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
  60. package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +4 -3
  61. package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
  62. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
  63. package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
  64. package/src/duckdb/src/function/built_in_functions.cpp +10 -10
  65. package/src/duckdb/src/function/function_binder.cpp +3 -3
  66. package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +5 -6
  67. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +2 -2
  68. package/src/duckdb/src/function/scalar/sequence/nextval.cpp +9 -8
  69. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +6 -6
  70. package/src/duckdb/src/function/table/arrow.cpp +32 -31
  71. package/src/duckdb/src/function/table/arrow_conversion.cpp +75 -59
  72. package/src/duckdb/src/function/table/system/duckdb_columns.cpp +8 -7
  73. package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +14 -14
  74. package/src/duckdb/src/function/table/system/duckdb_databases.cpp +2 -2
  75. package/src/duckdb/src/function/table/system/duckdb_functions.cpp +26 -25
  76. package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +13 -12
  77. package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +7 -7
  78. package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +8 -9
  79. package/src/duckdb/src/function/table/system/duckdb_tables.cpp +10 -9
  80. package/src/duckdb/src/function/table/system/duckdb_types.cpp +13 -13
  81. package/src/duckdb/src/function/table/system/duckdb_views.cpp +11 -10
  82. package/src/duckdb/src/function/table/system/pragma_collations.cpp +2 -2
  83. package/src/duckdb/src/function/table/system/pragma_database_size.cpp +5 -5
  84. package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +3 -3
  85. package/src/duckdb/src/function/table/system/pragma_table_info.cpp +2 -2
  86. package/src/duckdb/src/function/table/table_scan.cpp +39 -37
  87. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  88. package/src/duckdb/src/function/udf_function.cpp +2 -2
  89. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +122 -81
  90. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +2 -3
  91. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +3 -3
  92. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +1 -1
  93. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
  94. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +24 -20
  95. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +3 -3
  96. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
  97. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +2 -2
  98. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +1 -1
  99. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +2 -2
  100. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +1 -1
  101. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +22 -17
  102. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -1
  103. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -1
  104. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +2 -2
  105. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +1 -1
  106. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -1
  107. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +3 -3
  108. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +28 -7
  109. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +20 -19
  110. package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +9 -9
  111. package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +2 -1
  112. package/src/duckdb/src/include/duckdb/catalog/standard_entry.hpp +10 -4
  113. package/src/duckdb/src/include/duckdb/common/enums/on_entry_not_found.hpp +17 -0
  114. package/src/duckdb/src/include/duckdb/common/types.hpp +3 -4
  115. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -4
  116. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -2
  117. package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +5 -4
  118. package/src/duckdb/src/include/duckdb/function/table_function.hpp +28 -15
  119. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +2 -0
  120. package/src/duckdb/src/include/duckdb/main/client_context.hpp +1 -1
  121. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -2
  122. package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +2 -0
  123. package/src/duckdb/src/include/duckdb/parser/keyword_helper.hpp +2 -2
  124. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +7 -5
  125. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +1 -1
  126. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +1 -1
  127. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +1 -1
  128. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +3 -2
  129. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +5 -5
  130. package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +13 -0
  131. package/src/duckdb/src/include/duckdb/parser/tableref.hpp +5 -2
  132. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
  133. package/src/duckdb/src/include/duckdb/planner/binder.hpp +2 -2
  134. package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -2
  135. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +4 -7
  136. package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +1 -1
  137. package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +12 -0
  138. package/src/duckdb/src/main/attached_database.cpp +12 -6
  139. package/src/duckdb/src/main/capi/table_function-c.cpp +17 -16
  140. package/src/duckdb/src/main/client_context.cpp +12 -11
  141. package/src/duckdb/src/main/database_manager.cpp +13 -12
  142. package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -2
  143. package/src/duckdb/src/parser/parsed_data/alter_info.cpp +3 -3
  144. package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +2 -2
  145. package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +2 -2
  146. package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +9 -9
  147. package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +2 -2
  148. package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +2 -2
  149. package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +2 -2
  150. package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +2 -2
  151. package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +3 -2
  152. package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +5 -1
  153. package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +1 -1
  154. package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +1 -1
  155. package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +1 -1
  156. package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +26 -27
  157. package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +17 -17
  158. package/src/duckdb/src/planner/binder/expression/bind_case_expression.cpp +9 -9
  159. package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +6 -6
  160. package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +6 -6
  161. package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +2 -2
  162. package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +21 -21
  163. package/src/duckdb/src/planner/binder/expression/bind_conjunction_expression.cpp +2 -3
  164. package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +33 -36
  165. package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +5 -5
  166. package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +23 -23
  167. package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +4 -4
  168. package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +7 -7
  169. package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +23 -23
  170. package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +4 -4
  171. package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +14 -13
  172. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +36 -35
  173. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +3 -3
  174. package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
  175. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +4 -4
  176. package/src/duckdb/src/planner/binder/statement/bind_export.cpp +10 -10
  177. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +2 -2
  178. package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +4 -4
  179. package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +5 -4
  180. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
  181. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +3 -3
  182. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +10 -12
  183. package/src/duckdb/src/planner/binder.cpp +2 -2
  184. package/src/duckdb/src/planner/expression/bound_expression.cpp +11 -2
  185. package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +2 -5
  186. package/src/duckdb/src/planner/operator/logical_create.cpp +2 -1
  187. package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
  188. package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -2
  189. package/src/duckdb/src/planner/operator/logical_get.cpp +1 -1
  190. package/src/duckdb/src/planner/operator/logical_insert.cpp +2 -7
  191. package/src/duckdb/src/planner/operator/logical_update.cpp +2 -6
  192. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +2 -2
  193. package/src/duckdb/src/planner/pragma_handler.cpp +3 -4
  194. package/src/duckdb/src/storage/checkpoint_manager.cpp +46 -46
  195. package/src/duckdb/src/storage/data_table.cpp +3 -6
  196. package/src/duckdb/src/storage/table/update_segment.cpp +1 -1
  197. package/src/duckdb/src/storage/wal_replay.cpp +28 -30
  198. package/src/duckdb/src/storage/write_ahead_log.cpp +8 -8
  199. package/src/duckdb/src/transaction/cleanup_state.cpp +1 -1
  200. package/src/duckdb/src/transaction/commit_state.cpp +3 -4
  201. package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
@@ -57,8 +57,8 @@ BindResult SelectBinder::BindUnnest(FunctionExpression &function, idx_t depth, b
57
57
  if (!error.empty()) {
58
58
  return BindResult(error);
59
59
  }
60
- auto &const_child = (BoundExpression &)*function.children[i];
61
- auto value = ExpressionExecutor::EvaluateScalar(context, *const_child.expr, true);
60
+ auto &const_child = BoundExpression::GetExpression(*function.children[i]);
61
+ auto value = ExpressionExecutor::EvaluateScalar(context, *const_child, true);
62
62
  if (alias == "recursive") {
63
63
  auto recursive = value.GetValue<bool>();
64
64
  if (recursive) {
@@ -90,11 +90,11 @@ BindResult SelectBinder::BindUnnest(FunctionExpression &function, idx_t depth, b
90
90
  if (!BindCorrelatedColumns(function.children[0])) {
91
91
  return BindResult(error);
92
92
  }
93
- auto bound_expr = (BoundExpression *)function.children[0].get();
94
- ExtractCorrelatedExpressions(binder, *bound_expr->expr);
93
+ auto &bound_expr = BoundExpression::GetExpression(*function.children[0]);
94
+ ExtractCorrelatedExpressions(binder, *bound_expr);
95
95
  }
96
- auto &child = (BoundExpression &)*function.children[0];
97
- auto &child_type = child.expr->return_type;
96
+ auto &child = BoundExpression::GetExpression(*function.children[0]);
97
+ auto &child_type = child->return_type;
98
98
  unnest_level--;
99
99
 
100
100
  if (unnest_level > 0) {
@@ -116,7 +116,7 @@ BindResult SelectBinder::BindUnnest(FunctionExpression &function, idx_t depth, b
116
116
  idx_t list_unnests;
117
117
  idx_t struct_unnests = 0;
118
118
 
119
- auto unnest_expr = std::move(child.expr);
119
+ auto unnest_expr = std::move(child);
120
120
  if (child_type.id() == LogicalTypeId::SQLNULL) {
121
121
  list_unnests = 1;
122
122
  } else {
@@ -70,7 +70,7 @@ static unique_ptr<Expression> GetExpression(unique_ptr<ParsedExpression> &expr)
70
70
  }
71
71
  D_ASSERT(expr.get());
72
72
  D_ASSERT(expr->expression_class == ExpressionClass::BOUND_EXPRESSION);
73
- return std::move(((BoundExpression &)*expr).expr);
73
+ return std::move(BoundExpression::GetExpression(*expr));
74
74
  }
75
75
 
76
76
  static unique_ptr<Expression> CastWindowExpression(unique_ptr<ParsedExpression> &expr, const LogicalType &type) {
@@ -80,10 +80,10 @@ static unique_ptr<Expression> CastWindowExpression(unique_ptr<ParsedExpression>
80
80
  D_ASSERT(expr.get());
81
81
  D_ASSERT(expr->expression_class == ExpressionClass::BOUND_EXPRESSION);
82
82
 
83
- auto &bound = (BoundExpression &)*expr;
84
- bound.expr = BoundCastExpression::AddDefaultCastToType(std::move(bound.expr), type);
83
+ auto &bound = BoundExpression::GetExpression(*expr);
84
+ bound = BoundCastExpression::AddDefaultCastToType(std::move(bound), type);
85
85
 
86
- return std::move(bound.expr);
86
+ return std::move(bound);
87
87
  }
88
88
 
89
89
  static LogicalType BindRangeExpression(ClientContext &context, const string &name, unique_ptr<ParsedExpression> &expr,
@@ -93,13 +93,13 @@ static LogicalType BindRangeExpression(ClientContext &context, const string &nam
93
93
 
94
94
  D_ASSERT(order_expr.get());
95
95
  D_ASSERT(order_expr->expression_class == ExpressionClass::BOUND_EXPRESSION);
96
- auto &bound_order = (BoundExpression &)*order_expr;
97
- children.emplace_back(bound_order.expr->Copy());
96
+ auto &bound_order = BoundExpression::GetExpression(*order_expr);
97
+ children.emplace_back(bound_order->Copy());
98
98
 
99
99
  D_ASSERT(expr.get());
100
100
  D_ASSERT(expr->expression_class == ExpressionClass::BOUND_EXPRESSION);
101
- auto &bound = (BoundExpression &)*expr;
102
- children.emplace_back(std::move(bound.expr));
101
+ auto &bound = BoundExpression::GetExpression(*expr);
102
+ children.emplace_back(std::move(bound));
103
103
 
104
104
  string error;
105
105
  FunctionBinder function_binder(context);
@@ -107,8 +107,8 @@ static LogicalType BindRangeExpression(ClientContext &context, const string &nam
107
107
  if (!function) {
108
108
  throw BinderException(error);
109
109
  }
110
- bound.expr = std::move(function);
111
- return bound.expr->return_type;
110
+ bound = std::move(function);
111
+ return bound->return_type;
112
112
  }
113
113
 
114
114
  BindResult BaseSelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
@@ -157,26 +157,26 @@ BindResult BaseSelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
157
157
  for (auto &child : window.children) {
158
158
  D_ASSERT(child.get());
159
159
  D_ASSERT(child->expression_class == ExpressionClass::BOUND_EXPRESSION);
160
- auto &bound = (BoundExpression &)*child;
160
+ auto &bound = BoundExpression::GetExpression(*child);
161
161
  // Add casts for positional arguments
162
162
  const auto argno = children.size();
163
163
  switch (window.type) {
164
164
  case ExpressionType::WINDOW_NTILE:
165
165
  // ntile(bigint)
166
166
  if (argno == 0) {
167
- bound.expr = BoundCastExpression::AddCastToType(context, std::move(bound.expr), LogicalType::BIGINT);
167
+ bound = BoundCastExpression::AddCastToType(context, std::move(bound), LogicalType::BIGINT);
168
168
  }
169
169
  break;
170
170
  case ExpressionType::WINDOW_NTH_VALUE:
171
171
  // nth_value(<expr>, index)
172
172
  if (argno == 1) {
173
- bound.expr = BoundCastExpression::AddCastToType(context, std::move(bound.expr), LogicalType::BIGINT);
173
+ bound = BoundCastExpression::AddCastToType(context, std::move(bound), LogicalType::BIGINT);
174
174
  }
175
175
  default:
176
176
  break;
177
177
  }
178
- types.push_back(bound.expr->return_type);
179
- children.push_back(std::move(bound.expr));
178
+ types.push_back(bound->return_type);
179
+ children.push_back(std::move(bound));
180
180
  }
181
181
  // Determine the function type.
182
182
  LogicalType sql_type;
@@ -184,19 +184,19 @@ BindResult BaseSelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
184
184
  unique_ptr<FunctionData> bind_info;
185
185
  if (window.type == ExpressionType::WINDOW_AGGREGATE) {
186
186
  // Look up the aggregate function in the catalog
187
- auto func = Catalog::GetEntry<AggregateFunctionCatalogEntry>(context, window.catalog, window.schema,
188
- window.function_name, false, error_context);
189
- D_ASSERT(func->type == CatalogType::AGGREGATE_FUNCTION_ENTRY);
187
+ auto &func = Catalog::GetEntry<AggregateFunctionCatalogEntry>(context, window.catalog, window.schema,
188
+ window.function_name, error_context);
189
+ D_ASSERT(func.type == CatalogType::AGGREGATE_FUNCTION_ENTRY);
190
190
 
191
191
  // bind the aggregate
192
192
  string error;
193
193
  FunctionBinder function_binder(context);
194
- auto best_function = function_binder.BindFunction(func->name, func->functions, types, error);
194
+ auto best_function = function_binder.BindFunction(func.name, func.functions, types, error);
195
195
  if (best_function == DConstants::INVALID_INDEX) {
196
196
  throw BinderException(binder.FormatError(window, error));
197
197
  }
198
198
  // found a matching function! bind it as an aggregate
199
- auto bound_function = func->functions.GetFunctionByOffset(best_function);
199
+ auto bound_function = func.functions.GetFunctionByOffset(best_function);
200
200
  auto bound_aggregate = function_binder.BindAggregateFunction(bound_function, std::move(children));
201
201
  // create the aggregate
202
202
  aggregate = make_uniq<AggregateFunction>(bound_aggregate->function);
@@ -253,8 +253,8 @@ BindResult BaseSelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
253
253
  auto &order_expr = window.orders[0].expression;
254
254
  D_ASSERT(order_expr.get());
255
255
  D_ASSERT(order_expr->expression_class == ExpressionClass::BOUND_EXPRESSION);
256
- auto &bound_order = (BoundExpression &)*order_expr;
257
- auto order_type = bound_order.expr->return_type;
256
+ auto &bound_order = BoundExpression::GetExpression(*order_expr);
257
+ auto order_type = bound_order->return_type;
258
258
  if (window.start_expr) {
259
259
  order_type = LogicalType::MaxLogicalType(order_type, start_type);
260
260
  }
@@ -263,7 +263,7 @@ BindResult BaseSelectBinder::BindWindow(WindowExpression &window, idx_t depth) {
263
263
  }
264
264
 
265
265
  // Cast all three to match
266
- bound_order.expr = BoundCastExpression::AddCastToType(context, std::move(bound_order.expr), order_type);
266
+ bound_order = BoundCastExpression::AddCastToType(context, std::move(bound_order), order_type);
267
267
  start_type = end_type = order_type;
268
268
  }
269
269
 
@@ -16,10 +16,10 @@
16
16
 
17
17
  namespace duckdb {
18
18
 
19
- unique_ptr<QueryNode> Binder::BindTableMacro(FunctionExpression &function, TableMacroCatalogEntry *macro_func,
19
+ unique_ptr<QueryNode> Binder::BindTableMacro(FunctionExpression &function, TableMacroCatalogEntry &macro_func,
20
20
  idx_t depth) {
21
21
 
22
- auto &macro_def = macro_func->function->Cast<TableMacroFunction>();
22
+ auto &macro_def = macro_func.function->Cast<TableMacroFunction>();
23
23
  auto node = macro_def.query_node->Copy();
24
24
 
25
25
  // auto &macro_def = *macro_func->function;
@@ -28,7 +28,7 @@ unique_ptr<QueryNode> Binder::BindTableMacro(FunctionExpression &function, Table
28
28
  vector<unique_ptr<ParsedExpression>> positionals;
29
29
  unordered_map<string, unique_ptr<ParsedExpression>> defaults;
30
30
  string error =
31
- MacroFunction::ValidateArguments(*macro_func->function, macro_func->name, function, positionals, defaults);
31
+ MacroFunction::ValidateArguments(*macro_func.function, macro_func.name, function, positionals, defaults);
32
32
  if (!error.empty()) {
33
33
  // cannot use error below as binder rnot in scope
34
34
  // return BindResult(binder. FormatError(*expr->get(), error));
@@ -51,7 +51,7 @@ unique_ptr<QueryNode> Binder::BindTableMacro(FunctionExpression &function, Table
51
51
  // now push the defaults into the positionals
52
52
  positionals.push_back(std::move(defaults[it->first]));
53
53
  }
54
- auto new_macro_binding = make_uniq<DummyBinding>(types, names, macro_func->name);
54
+ auto new_macro_binding = make_uniq<DummyBinding>(types, names, macro_func.name);
55
55
  new_macro_binding->arguments = &positionals;
56
56
 
57
57
  // We need an ExpressionBinder so that we can call ExpressionBinder::ReplaceMacroParametersRecursive()
@@ -63,17 +63,17 @@ BoundStatement Binder::BindCopyTo(CopyStatement &stmt) {
63
63
  result.names = {"Count"};
64
64
 
65
65
  // lookup the format in the catalog
66
- auto copy_function =
66
+ auto &copy_function =
67
67
  Catalog::GetEntry<CopyFunctionCatalogEntry>(context, INVALID_CATALOG, DEFAULT_SCHEMA, stmt.info->format);
68
- if (copy_function->function.plan) {
68
+ if (copy_function.function.plan) {
69
69
  // plan rewrite COPY TO
70
- return copy_function->function.plan(*this, stmt);
70
+ return copy_function.function.plan(*this, stmt);
71
71
  }
72
72
 
73
73
  // bind the select statement
74
74
  auto select_node = Bind(*stmt.select_statement);
75
75
 
76
- if (!copy_function->function.copy_to_bind) {
76
+ if (!copy_function.function.copy_to_bind) {
77
77
  throw NotImplementedException("COPY TO is not supported for FORMAT \"%s\"", stmt.info->format);
78
78
  }
79
79
  bool use_tmp_file = true;
@@ -138,9 +138,9 @@ BoundStatement Binder::BindCopyTo(CopyStatement &stmt) {
138
138
  auto unique_column_names = GetUniqueNames(select_node.names);
139
139
 
140
140
  auto function_data =
141
- copy_function->function.copy_to_bind(context, *stmt.info, unique_column_names, select_node.types);
141
+ copy_function.function.copy_to_bind(context, *stmt.info, unique_column_names, select_node.types);
142
142
  // now create the copy information
143
- auto copy = make_uniq<LogicalCopyToFile>(copy_function->function, std::move(function_data));
143
+ auto copy = make_uniq<LogicalCopyToFile>(copy_function.function, std::move(function_data));
144
144
  copy->file_path = stmt.info->file_path;
145
145
  copy->use_tmp_file = use_tmp_file;
146
146
  copy->overwrite_or_ignore = overwrite_or_ignore;
@@ -187,17 +187,18 @@ BoundStatement Binder::BindCopyFrom(CopyStatement &stmt) {
187
187
 
188
188
  // lookup the format in the catalog
189
189
  auto &catalog = Catalog::GetSystemCatalog(context);
190
- auto copy_function = catalog.GetEntry<CopyFunctionCatalogEntry>(context, DEFAULT_SCHEMA, stmt.info->format);
191
- if (!copy_function->function.copy_from_bind) {
190
+ auto &copy_function = catalog.GetEntry<CopyFunctionCatalogEntry>(context, DEFAULT_SCHEMA, stmt.info->format);
191
+ if (!copy_function.function.copy_from_bind) {
192
192
  throw NotImplementedException("COPY FROM is not supported for FORMAT \"%s\"", stmt.info->format);
193
193
  }
194
194
  // lookup the table to copy into
195
195
  BindSchemaOrCatalog(stmt.info->catalog, stmt.info->schema);
196
- auto table = Catalog::GetEntry<TableCatalogEntry>(context, stmt.info->catalog, stmt.info->schema, stmt.info->table);
196
+ auto &table =
197
+ Catalog::GetEntry<TableCatalogEntry>(context, stmt.info->catalog, stmt.info->schema, stmt.info->table);
197
198
  vector<string> expected_names;
198
199
  if (!bound_insert.column_index_map.empty()) {
199
200
  expected_names.resize(bound_insert.expected_types.size());
200
- for (auto &col : table->GetColumns().Physical()) {
201
+ for (auto &col : table.GetColumns().Physical()) {
201
202
  auto i = col.Physical();
202
203
  if (bound_insert.column_index_map[i] != DConstants::INVALID_INDEX) {
203
204
  expected_names[bound_insert.column_index_map[i]] = col.Name();
@@ -205,14 +206,14 @@ BoundStatement Binder::BindCopyFrom(CopyStatement &stmt) {
205
206
  }
206
207
  } else {
207
208
  expected_names.reserve(bound_insert.expected_types.size());
208
- for (auto &col : table->GetColumns().Physical()) {
209
+ for (auto &col : table.GetColumns().Physical()) {
209
210
  expected_names.push_back(col.Name());
210
211
  }
211
212
  }
212
213
 
213
214
  auto function_data =
214
- copy_function->function.copy_from_bind(context, *stmt.info, expected_names, bound_insert.expected_types);
215
- auto get = make_uniq<LogicalGet>(GenerateTableIndex(), copy_function->function.copy_from_function,
215
+ copy_function.function.copy_from_bind(context, *stmt.info, expected_names, bound_insert.expected_types);
216
+ auto get = make_uniq<LogicalGet>(GenerateTableIndex(), copy_function.function.copy_from_function,
216
217
  std::move(function_data), bound_insert.expected_types, expected_names);
217
218
  for (idx_t i = 0; i < bound_insert.expected_types.size(); i++) {
218
219
  get->column_ids.push_back(i);
@@ -49,9 +49,9 @@ void Binder::BindSchemaOrCatalog(ClientContext &context, string &catalog, string
49
49
  if (database) {
50
50
  // we have a database with this name
51
51
  // check if there is a schema
52
- auto schema_obj = Catalog::GetSchema(context, INVALID_CATALOG, schema, true);
52
+ auto schema_obj = Catalog::GetSchema(context, INVALID_CATALOG, schema, OnEntryNotFound::RETURN_NULL);
53
53
  if (schema_obj) {
54
- auto &attached = schema_obj->catalog->GetAttached();
54
+ auto &attached = schema_obj->catalog.GetAttached();
55
55
  throw BinderException(
56
56
  "Ambiguous reference to catalog or schema \"%s\" - use a fully qualified path like \"%s.%s\"",
57
57
  schema, attached.GetName(), schema);
@@ -95,18 +95,18 @@ SchemaCatalogEntry &Binder::BindSchema(CreateInfo &info) {
95
95
  }
96
96
  }
97
97
  // fetch the schema in which we want to create the object
98
- auto schema_obj = Catalog::GetSchema(context, info.catalog, info.schema);
99
- D_ASSERT(schema_obj->type == CatalogType::SCHEMA_ENTRY);
100
- info.schema = schema_obj->name;
98
+ auto &schema_obj = Catalog::GetSchema(context, info.catalog, info.schema);
99
+ D_ASSERT(schema_obj.type == CatalogType::SCHEMA_ENTRY);
100
+ info.schema = schema_obj.name;
101
101
  if (!info.temporary) {
102
- properties.modified_databases.insert(schema_obj->catalog->GetName());
102
+ properties.modified_databases.insert(schema_obj.catalog.GetName());
103
103
  }
104
- return *schema_obj;
104
+ return schema_obj;
105
105
  }
106
106
 
107
107
  SchemaCatalogEntry &Binder::BindCreateSchema(CreateInfo &info) {
108
108
  auto &schema = BindSchema(info);
109
- if (schema.catalog->IsSystemCatalog()) {
109
+ if (schema.catalog.IsSystemCatalog()) {
110
110
  throw BinderException("Cannot create entry in system catalog");
111
111
  }
112
112
  return schema;
@@ -136,11 +136,11 @@ static void QualifyFunctionNames(ClientContext &context, unique_ptr<ParsedExpres
136
136
  switch (expr->GetExpressionClass()) {
137
137
  case ExpressionClass::FUNCTION: {
138
138
  auto &func = expr->Cast<FunctionExpression>();
139
- auto function = (StandardEntry *)Catalog::GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, func.catalog,
140
- func.schema, func.function_name, true);
139
+ auto function = Catalog::GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, func.catalog, func.schema,
140
+ func.function_name, OnEntryNotFound::RETURN_NULL);
141
141
  if (function) {
142
- func.catalog = function->catalog->GetName();
143
- func.schema = function->schema->name;
142
+ func.catalog = function->ParentCatalog().GetName();
143
+ func.schema = function->ParentSchema().name;
144
144
  }
145
145
  break;
146
146
  }
@@ -160,7 +160,7 @@ static void QualifyFunctionNames(ClientContext &context, unique_ptr<ParsedExpres
160
160
  }
161
161
 
162
162
  SchemaCatalogEntry &Binder::BindCreateFunctionInfo(CreateInfo &info) {
163
- auto &base = (CreateMacroInfo &)info;
163
+ auto &base = info.Cast<CreateMacroInfo>();
164
164
  auto &scalar_function = base.function->Cast<ScalarMacroFunction>();
165
165
 
166
166
  if (scalar_function.expression->HasParameter()) {
@@ -207,7 +207,8 @@ SchemaCatalogEntry &Binder::BindCreateFunctionInfo(CreateInfo &info) {
207
207
  return BindCreateSchema(info);
208
208
  }
209
209
 
210
- void Binder::BindLogicalType(ClientContext &context, LogicalType &type, Catalog *catalog, const string &schema) {
210
+ void Binder::BindLogicalType(ClientContext &context, LogicalType &type, optional_ptr<Catalog> catalog,
211
+ const string &schema) {
211
212
  if (type.id() == LogicalTypeId::LIST || type.id() == LogicalTypeId::MAP) {
212
213
  auto child_type = ListType::GetChildType(type);
213
214
  BindLogicalType(context, child_type, catalog, schema);
@@ -241,7 +242,7 @@ void Binder::BindLogicalType(ClientContext &context, LogicalType &type, Catalog
241
242
  } else if (type.id() == LogicalTypeId::USER) {
242
243
  auto &user_type_name = UserType::GetTypeName(type);
243
244
  if (catalog) {
244
- type = catalog->GetType(context, schema, user_type_name, true);
245
+ type = catalog->GetType(context, schema, user_type_name, OnEntryNotFound::RETURN_NULL);
245
246
  if (type.id() == LogicalTypeId::INVALID) {
246
247
  // look in the system catalog if the type was not found
247
248
  type = Catalog::GetType(context, SYSTEM_CATALOG, schema, user_type_name);
@@ -251,20 +252,21 @@ void Binder::BindLogicalType(ClientContext &context, LogicalType &type, Catalog
251
252
  }
252
253
  } else if (type.id() == LogicalTypeId::ENUM) {
253
254
  auto &enum_type_name = EnumType::GetTypeName(type);
254
- TypeCatalogEntry *enum_type_catalog;
255
+ optional_ptr<TypeCatalogEntry> enum_type_catalog;
255
256
  if (catalog) {
256
- enum_type_catalog = catalog->GetEntry<TypeCatalogEntry>(context, schema, enum_type_name, true);
257
+ enum_type_catalog =
258
+ catalog->GetEntry<TypeCatalogEntry>(context, schema, enum_type_name, OnEntryNotFound::RETURN_NULL);
257
259
  if (!enum_type_catalog) {
258
260
  // look in the system catalog if the type was not found
259
- enum_type_catalog =
260
- Catalog::GetEntry<TypeCatalogEntry>(context, SYSTEM_CATALOG, schema, enum_type_name, true);
261
+ enum_type_catalog = Catalog::GetEntry<TypeCatalogEntry>(context, SYSTEM_CATALOG, schema, enum_type_name,
262
+ OnEntryNotFound::RETURN_NULL);
261
263
  }
262
264
  } else {
263
- enum_type_catalog =
264
- Catalog::GetEntry<TypeCatalogEntry>(context, INVALID_CATALOG, schema, enum_type_name, true);
265
+ enum_type_catalog = Catalog::GetEntry<TypeCatalogEntry>(context, INVALID_CATALOG, schema, enum_type_name,
266
+ OnEntryNotFound::RETURN_NULL);
265
267
  }
266
268
 
267
- LogicalType::SetCatalog(type, enum_type_catalog);
269
+ EnumType::SetCatalog(type, enum_type_catalog.get());
268
270
  }
269
271
  }
270
272
 
@@ -501,7 +503,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
501
503
  break;
502
504
  }
503
505
  case CatalogType::INDEX_ENTRY: {
504
- auto &base = (CreateIndexInfo &)*stmt.info;
506
+ auto &base = stmt.info->Cast<CreateIndexInfo>();
505
507
 
506
508
  // visit the table reference
507
509
  auto bound_table = Bind(*base.table);
@@ -519,11 +521,11 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
519
521
  throw BinderException("Cannot create index on a view!");
520
522
  }
521
523
 
522
- result.plan = table.catalog->BindCreateIndex(*this, stmt, table, std::move(plan));
524
+ result.plan = table.catalog.BindCreateIndex(*this, stmt, table, std::move(plan));
523
525
  break;
524
526
  }
525
527
  case CatalogType::TABLE_ENTRY: {
526
- auto &create_info = (CreateTableInfo &)*stmt.info;
528
+ auto &create_info = stmt.info->Cast<CreateTableInfo>();
527
529
  // If there is a foreign key constraint, resolve primary key column's index from primary key column's name
528
530
  reference_set_t<SchemaCatalogEntry> fk_schemas;
529
531
  for (idx_t i = 0; i < create_info.constraints.size(); i++) {
@@ -546,21 +548,20 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
546
548
  CheckForeignKeyTypes(create_info.columns, create_info.columns, fk);
547
549
  } else {
548
550
  // have to resolve referenced table
549
- auto pk_table_entry_ptr =
551
+ auto &pk_table_entry_ptr =
550
552
  Catalog::GetEntry<TableCatalogEntry>(context, INVALID_CATALOG, fk.info.schema, fk.info.table);
551
- fk_schemas.insert(*pk_table_entry_ptr->schema);
552
- FindMatchingPrimaryKeyColumns(pk_table_entry_ptr->GetColumns(), pk_table_entry_ptr->GetConstraints(),
553
- fk);
554
- FindForeignKeyIndexes(pk_table_entry_ptr->GetColumns(), fk.pk_columns, fk.info.pk_keys);
555
- CheckForeignKeyTypes(pk_table_entry_ptr->GetColumns(), create_info.columns, fk);
556
- auto &storage = pk_table_entry_ptr->GetStorage();
553
+ fk_schemas.insert(pk_table_entry_ptr.schema);
554
+ FindMatchingPrimaryKeyColumns(pk_table_entry_ptr.GetColumns(), pk_table_entry_ptr.GetConstraints(), fk);
555
+ FindForeignKeyIndexes(pk_table_entry_ptr.GetColumns(), fk.pk_columns, fk.info.pk_keys);
556
+ CheckForeignKeyTypes(pk_table_entry_ptr.GetColumns(), create_info.columns, fk);
557
+ auto &storage = pk_table_entry_ptr.GetStorage();
557
558
  auto index = storage.info->indexes.FindForeignKeyIndex(fk.info.pk_keys,
558
559
  ForeignKeyType::FK_TYPE_PRIMARY_KEY_TABLE);
559
560
  if (!index) {
560
561
  auto fk_column_names = StringUtil::Join(fk.pk_columns, ",");
561
562
  throw BinderException("Failed to create foreign key on %s(%s): no UNIQUE or PRIMARY KEY constraint "
562
563
  "present on these columns",
563
- pk_table_entry_ptr->name, fk_column_names);
564
+ pk_table_entry_ptr.name, fk_column_names);
564
565
  }
565
566
  }
566
567
  D_ASSERT(fk.info.pk_keys.size() == fk.info.fk_keys.size());
@@ -635,10 +636,10 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
635
636
  // 2: create a type alias with a custom type.
636
637
  // eg. CREATE TYPE a AS INT; CREATE TYPE b AS a;
637
638
  // We set b to be an alias for the underlying type of a
638
- auto inner_type = Catalog::GetType(context, schema.catalog->GetName(), schema.name,
639
+ auto inner_type = Catalog::GetType(context, schema.catalog.GetName(), schema.name,
639
640
  UserType::GetTypeName(create_type_info.type));
640
641
  // clear to nullptr, we don't need this
641
- LogicalType::SetCatalog(inner_type, nullptr);
642
+ EnumType::SetCatalog(inner_type, nullptr);
642
643
  inner_type.SetAlias(create_type_info.name);
643
644
  create_type_info.type = inner_type;
644
645
  }
@@ -291,15 +291,15 @@ unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateIn
291
291
  if (column.Type().id() == LogicalTypeId::VARCHAR) {
292
292
  ExpressionBinder::TestCollation(context, StringType::GetCollation(column.Type()));
293
293
  }
294
- BindLogicalType(context, column.TypeMutable(), result->schema.catalog);
294
+ BindLogicalType(context, column.TypeMutable(), &result->schema.catalog);
295
295
  // We add a catalog dependency
296
- auto type_dependency = LogicalType::GetCatalog(column.Type());
296
+ auto type_dependency = EnumType::GetCatalog(column.Type());
297
297
  if (type_dependency) {
298
298
  // Only if the USER comes from a create type
299
299
  result->dependencies.AddDependency(*type_dependency);
300
300
  }
301
301
  }
302
- result->dependencies.VerifyDependencies(*schema.catalog, result->Base().table);
302
+ result->dependencies.VerifyDependencies(schema.catalog, result->Base().table);
303
303
  properties.allow_stream_result = false;
304
304
  return result;
305
305
  }
@@ -29,7 +29,7 @@ BoundStatement Binder::Bind(DeleteStatement &stmt) {
29
29
 
30
30
  if (!table.temporary) {
31
31
  // delete from persistent table: not read only!
32
- properties.modified_databases.insert(table.catalog->GetName());
32
+ properties.modified_databases.insert(table.catalog.GetName());
33
33
  }
34
34
 
35
35
  // Add CTEs as bindable
@@ -34,17 +34,17 @@ BoundStatement Binder::Bind(DropStatement &stmt) {
34
34
  case CatalogType::TABLE_ENTRY:
35
35
  case CatalogType::TYPE_ENTRY: {
36
36
  BindSchemaOrCatalog(stmt.info->catalog, stmt.info->schema);
37
- auto entry = (StandardEntry *)Catalog::GetEntry(context, stmt.info->type, stmt.info->catalog, stmt.info->schema,
38
- stmt.info->name, true);
37
+ auto entry = Catalog::GetEntry(context, stmt.info->type, stmt.info->catalog, stmt.info->schema, stmt.info->name,
38
+ OnEntryNotFound::RETURN_NULL);
39
39
  if (!entry) {
40
40
  break;
41
41
  }
42
- stmt.info->catalog = entry->catalog->GetName();
42
+ stmt.info->catalog = entry->ParentCatalog().GetName();
43
43
  if (!entry->temporary) {
44
44
  // we can only drop temporary tables in read-only mode
45
45
  properties.modified_databases.insert(stmt.info->catalog);
46
46
  }
47
- stmt.info->schema = entry->schema->name;
47
+ stmt.info->schema = entry->ParentSchema().name;
48
48
  break;
49
49
  }
50
50
  case CatalogType::DATABASE_ENTRY: {
@@ -89,10 +89,10 @@ void ReorderTableEntries(vector<reference<TableCatalogEntry>> &tables) {
89
89
 
90
90
  string CreateFileName(const string &id_suffix, TableCatalogEntry &table, const string &extension) {
91
91
  auto name = SanitizeExportIdentifier(table.name);
92
- if (table.schema->name == DEFAULT_SCHEMA) {
92
+ if (table.schema.name == DEFAULT_SCHEMA) {
93
93
  return StringUtil::Format("%s%s.%s", name, id_suffix, extension);
94
94
  }
95
- auto schema = SanitizeExportIdentifier(table.schema->name);
95
+ auto schema = SanitizeExportIdentifier(table.schema.name);
96
96
  return StringUtil::Format("%s_%s%s.%s", schema, name, id_suffix, extension);
97
97
  }
98
98
 
@@ -107,9 +107,9 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
107
107
  result.names = {"Success"};
108
108
 
109
109
  // lookup the format in the catalog
110
- auto copy_function =
110
+ auto &copy_function =
111
111
  Catalog::GetEntry<CopyFunctionCatalogEntry>(context, INVALID_CATALOG, DEFAULT_SCHEMA, stmt.info->format);
112
- if (!copy_function->function.copy_to_bind && !copy_function->function.plan) {
112
+ if (!copy_function.function.copy_to_bind && !copy_function.function.plan) {
113
113
  throw NotImplementedException("COPY TO is not supported for FORMAT \"%s\"", stmt.info->format);
114
114
  }
115
115
 
@@ -118,9 +118,9 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
118
118
  vector<reference<TableCatalogEntry>> tables;
119
119
  auto schemas = Catalog::GetSchemas(context, catalog);
120
120
  for (auto &schema : schemas) {
121
- schema->Scan(context, CatalogType::TABLE_ENTRY, [&](CatalogEntry *entry) {
122
- if (entry->type == CatalogType::TABLE_ENTRY) {
123
- tables.push_back(entry->Cast<TableCatalogEntry>());
121
+ schema.get().Scan(context, CatalogType::TABLE_ENTRY, [&](CatalogEntry &entry) {
122
+ if (entry.type == CatalogType::TABLE_ENTRY) {
123
+ tables.push_back(entry.Cast<TableCatalogEntry>());
124
124
  }
125
125
  });
126
126
  }
@@ -146,7 +146,7 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
146
146
  idx_t id = 0;
147
147
  while (true) {
148
148
  string id_suffix = id == 0 ? string() : "_" + to_string(id);
149
- auto name = CreateFileName(id_suffix, table, copy_function->function.extension);
149
+ auto name = CreateFileName(id_suffix, table, copy_function.function.extension);
150
150
  auto directory = stmt.info->file_path;
151
151
  auto full_path = fs.JoinPath(directory, name);
152
152
  info->file_path = full_path;
@@ -159,7 +159,7 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
159
159
  }
160
160
  info->is_from = false;
161
161
  info->catalog = catalog;
162
- info->schema = table.schema->name;
162
+ info->schema = table.schema.name;
163
163
  info->table = table.name;
164
164
 
165
165
  // We can not export generated columns
@@ -202,7 +202,7 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
202
202
  }
203
203
 
204
204
  // create the export node
205
- auto export_node = make_uniq<LogicalExport>(copy_function->function, std::move(stmt.info), exported_tables);
205
+ auto export_node = make_uniq<LogicalExport>(copy_function.function, std::move(stmt.info), exported_tables);
206
206
 
207
207
  if (child_operator) {
208
208
  export_node->children.push_back(std::move(child_operator));
@@ -398,10 +398,10 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
398
398
  result.types = {LogicalType::BIGINT};
399
399
 
400
400
  BindSchemaOrCatalog(stmt.catalog, stmt.schema);
401
- auto &table = *Catalog::GetEntry<TableCatalogEntry>(context, stmt.catalog, stmt.schema, stmt.table);
401
+ auto &table = Catalog::GetEntry<TableCatalogEntry>(context, stmt.catalog, stmt.schema, stmt.table);
402
402
  if (!table.temporary) {
403
403
  // inserting into a non-temporary table: alters underlying database
404
- properties.modified_databases.insert(table.catalog->GetName());
404
+ properties.modified_databases.insert(table.catalog.GetName());
405
405
  }
406
406
 
407
407
  auto insert = make_uniq<LogicalInsert>(table, GenerateTableIndex());
@@ -9,15 +9,15 @@ namespace duckdb {
9
9
 
10
10
  BoundStatement Binder::Bind(PragmaStatement &stmt) {
11
11
  // bind the pragma function
12
- auto entry =
13
- Catalog::GetEntry<PragmaFunctionCatalogEntry>(context, INVALID_CATALOG, DEFAULT_SCHEMA, stmt.info->name, false);
12
+ auto &entry =
13
+ Catalog::GetEntry<PragmaFunctionCatalogEntry>(context, INVALID_CATALOG, DEFAULT_SCHEMA, stmt.info->name);
14
14
  string error;
15
15
  FunctionBinder function_binder(context);
16
- idx_t bound_idx = function_binder.BindFunction(entry->name, entry->functions, *stmt.info, error);
16
+ idx_t bound_idx = function_binder.BindFunction(entry.name, entry.functions, *stmt.info, error);
17
17
  if (bound_idx == DConstants::INVALID_INDEX) {
18
18
  throw BinderException(FormatError(stmt.stmt_location, error));
19
19
  }
20
- auto bound_function = entry->functions.GetFunctionByOffset(bound_idx);
20
+ auto bound_function = entry.functions.GetFunctionByOffset(bound_idx);
21
21
  if (!bound_function.function) {
22
22
  throw BinderException("PRAGMA function does not have a function specified");
23
23
  }
@@ -18,14 +18,15 @@ BoundStatement Binder::Bind(AlterStatement &stmt) {
18
18
  result.types = {LogicalType::BOOLEAN};
19
19
  BindSchemaOrCatalog(stmt.info->catalog, stmt.info->schema);
20
20
  auto entry = Catalog::GetEntry(context, stmt.info->GetCatalogType(), stmt.info->catalog, stmt.info->schema,
21
- stmt.info->name, stmt.info->if_exists);
21
+ stmt.info->name, stmt.info->if_not_found);
22
22
  if (entry) {
23
+ auto &catalog = entry->ParentCatalog();
23
24
  if (!entry->temporary) {
24
25
  // we can only alter temporary tables/views in read-only mode
25
- properties.modified_databases.insert(entry->catalog->GetName());
26
+ properties.modified_databases.insert(catalog.GetName());
26
27
  }
27
- stmt.info->catalog = entry->catalog->GetName();
28
- stmt.info->schema = ((StandardEntry *)entry)->schema->name;
28
+ stmt.info->catalog = catalog.GetName();
29
+ stmt.info->schema = entry->ParentSchema().name;
29
30
  }
30
31
  result.plan = make_uniq<LogicalSimple>(LogicalOperatorType::LOGICAL_ALTER, std::move(stmt.info));
31
32
  properties.return_type = StatementReturnType::NOTHING;
@@ -209,7 +209,7 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
209
209
 
210
210
  if (!table.temporary) {
211
211
  // update of persistent table: not read only!
212
- properties.modified_databases.insert(table.catalog->GetName());
212
+ properties.modified_databases.insert(table.catalog.GetName());
213
213
  }
214
214
  auto update = make_uniq<LogicalUpdate>(table);
215
215