duckdb 0.7.2-dev3441.0 → 0.7.2-dev3546.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 (160) hide show
  1. package/configure.py +2 -0
  2. package/package.json +2 -2
  3. package/src/duckdb/extension/json/json_functions/json_create.cpp +1 -1
  4. package/src/duckdb/extension/json/json_functions/read_json.cpp +1 -0
  5. package/src/duckdb/src/catalog/catalog_entry/macro_catalog_entry.cpp +42 -0
  6. package/src/duckdb/src/catalog/catalog_search_path.cpp +5 -0
  7. package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
  8. package/src/duckdb/src/catalog/default/default_functions.cpp +1 -0
  9. package/src/duckdb/src/common/arrow/arrow_converter.cpp +4 -4
  10. package/src/duckdb/src/common/compressed_file_system.cpp +2 -2
  11. package/src/duckdb/src/common/constants.cpp +1 -0
  12. package/src/duckdb/src/common/file_system.cpp +2 -2
  13. package/src/duckdb/src/common/row_operations/row_gather.cpp +2 -2
  14. package/src/duckdb/src/common/serializer/binary_deserializer.cpp +1 -1
  15. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +1 -1
  16. package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +1 -1
  17. package/src/duckdb/src/common/serializer/buffered_serializer.cpp +4 -3
  18. package/src/duckdb/src/common/serializer.cpp +1 -1
  19. package/src/duckdb/src/common/sort/radix_sort.cpp +5 -5
  20. package/src/duckdb/src/common/string_util.cpp +2 -2
  21. package/src/duckdb/src/common/types/bit.cpp +2 -2
  22. package/src/duckdb/src/common/types/blob.cpp +2 -2
  23. package/src/duckdb/src/common/types/data_chunk.cpp +2 -2
  24. package/src/duckdb/src/common/types/date.cpp +1 -1
  25. package/src/duckdb/src/common/types/decimal.cpp +2 -2
  26. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +14 -2
  27. package/src/duckdb/src/common/types/selection_vector.cpp +1 -1
  28. package/src/duckdb/src/common/types/time.cpp +1 -1
  29. package/src/duckdb/src/common/types/vector.cpp +10 -10
  30. package/src/duckdb/src/common/types/vector_buffer.cpp +11 -3
  31. package/src/duckdb/src/common/types/vector_cache.cpp +5 -5
  32. package/src/duckdb/src/common/virtual_file_system.cpp +4 -0
  33. package/src/duckdb/src/common/windows_util.cpp +2 -2
  34. package/src/duckdb/src/core_functions/aggregate/distributive/string_agg.cpp +6 -3
  35. package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +2 -5
  36. package/src/duckdb/src/core_functions/scalar/string/printf.cpp +1 -1
  37. package/src/duckdb/src/execution/aggregate_hashtable.cpp +1 -1
  38. package/src/duckdb/src/execution/join_hashtable.cpp +3 -3
  39. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +2 -2
  40. package/src/duckdb/src/execution/operator/join/outer_join_marker.cpp +1 -1
  41. package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +1 -1
  42. package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
  43. package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -7
  44. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +4 -41
  45. package/src/duckdb/src/execution/operator/persistent/csv_file_handle.cpp +158 -0
  46. package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +1 -1
  47. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +2 -2
  48. package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +2 -2
  49. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +3 -4
  50. package/src/duckdb/src/execution/window_segment_tree.cpp +1 -1
  51. package/src/duckdb/src/function/macro_function.cpp +43 -0
  52. package/src/duckdb/src/function/pragma/pragma_queries.cpp +1 -1
  53. package/src/duckdb/src/function/scalar/strftime_format.cpp +2 -1
  54. package/src/duckdb/src/function/scalar/string/concat.cpp +1 -1
  55. package/src/duckdb/src/function/scalar/string/like.cpp +2 -2
  56. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -5
  57. package/src/duckdb/src/function/scalar_macro_function.cpp +10 -0
  58. package/src/duckdb/src/function/table/copy_csv.cpp +3 -7
  59. package/src/duckdb/src/function/table/read_csv.cpp +60 -35
  60. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  61. package/src/duckdb/src/function/table_macro_function.cpp +10 -0
  62. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +3 -1
  63. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +0 -6
  64. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +0 -6
  65. package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
  66. package/src/duckdb/src/include/duckdb/common/compressed_file_system.hpp +3 -3
  67. package/src/duckdb/src/include/duckdb/common/constants.hpp +2 -5
  68. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +3 -3
  69. package/src/duckdb/src/include/duckdb/common/helper.hpp +22 -9
  70. package/src/duckdb/src/include/duckdb/common/memory_safety.hpp +15 -0
  71. package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +1 -0
  72. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +1 -1
  73. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +1 -1
  74. package/src/duckdb/src/include/duckdb/common/serializer/buffered_serializer.hpp +3 -2
  75. package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +2 -3
  76. package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +11 -6
  77. package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +2 -1
  78. package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +1 -1
  79. package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +3 -3
  80. package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +16 -6
  81. package/src/duckdb/src/include/duckdb/common/unique_ptr.hpp +53 -22
  82. package/src/duckdb/src/include/duckdb/common/vector.hpp +5 -2
  83. package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +1 -1
  84. package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +4 -4
  85. package/src/duckdb/src/include/duckdb/execution/operator/join/outer_join_marker.hpp +1 -1
  86. package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp +1 -1
  87. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_range_join.hpp +1 -1
  88. package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +0 -2
  89. package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +2 -2
  90. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +27 -127
  91. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +1 -2
  92. package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +2 -2
  93. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +1 -1
  94. package/src/duckdb/src/include/duckdb/execution/perfect_aggregate_hashtable.hpp +2 -2
  95. package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +1 -1
  96. package/src/duckdb/src/include/duckdb/function/macro_function.hpp +7 -1
  97. package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +3 -4
  98. package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +7 -2
  99. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +2 -4
  100. package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +5 -0
  101. package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +3 -3
  102. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +4 -7
  103. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +8 -12
  104. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_sequence_info.hpp +6 -20
  105. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_type_info.hpp +6 -18
  106. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +4 -8
  107. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +4 -38
  108. package/src/duckdb/src/include/duckdb/parser/parsed_data/transaction_info.hpp +5 -2
  109. package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +10 -10
  110. package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +5 -0
  111. package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +2 -2
  112. package/src/duckdb/src/include/duckdb/storage/buffer/buffer_handle.hpp +9 -2
  113. package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +1 -1
  114. package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +1 -1
  115. package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +1 -1
  116. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -2
  117. package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +5 -5
  118. package/src/duckdb/src/optimizer/unnest_rewriter.cpp +14 -6
  119. package/src/duckdb/src/parser/parsed_data/attach_info.cpp +42 -0
  120. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +0 -7
  121. package/src/duckdb/src/parser/parsed_data/create_info.cpp +19 -8
  122. package/src/duckdb/src/parser/parsed_data/create_macro_info.cpp +46 -0
  123. package/src/duckdb/src/parser/parsed_data/create_sequence_info.cpp +56 -0
  124. package/src/duckdb/src/parser/parsed_data/create_type_info.cpp +47 -0
  125. package/src/duckdb/src/parser/parsed_data/detach_info.cpp +34 -0
  126. package/src/duckdb/src/parser/parsed_data/drop_info.cpp +46 -0
  127. package/src/duckdb/src/parser/parsed_data/transaction_info.cpp +24 -0
  128. package/src/duckdb/src/parser/parsed_data/vacuum_info.cpp +37 -0
  129. package/src/duckdb/src/parser/statement/insert_statement.cpp +4 -1
  130. package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +10 -0
  131. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +27 -9
  132. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +2 -1
  133. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +1 -0
  134. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +32 -7
  135. package/src/duckdb/src/planner/logical_operator.cpp +1 -2
  136. package/src/duckdb/src/planner/operator/logical_create_index.cpp +16 -25
  137. package/src/duckdb/src/planner/operator/logical_insert.cpp +30 -0
  138. package/src/duckdb/src/planner/operator/logical_simple.cpp +33 -5
  139. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +6 -16
  140. package/src/duckdb/src/planner/planner.cpp +4 -13
  141. package/src/duckdb/src/storage/arena_allocator.cpp +1 -1
  142. package/src/duckdb/src/storage/buffer/buffer_handle.cpp +2 -11
  143. package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +1 -1
  144. package/src/duckdb/src/storage/checkpoint_manager.cpp +12 -6
  145. package/src/duckdb/src/storage/compression/string_uncompressed.cpp +2 -2
  146. package/src/duckdb/src/storage/statistics/list_stats.cpp +1 -1
  147. package/src/duckdb/src/storage/statistics/struct_stats.cpp +1 -1
  148. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  149. package/src/duckdb/src/storage/table/row_group.cpp +2 -2
  150. package/src/duckdb/src/storage/table/update_segment.cpp +7 -6
  151. package/src/duckdb/third_party/fsst/libfsst.cpp +1 -2
  152. package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +9 -0
  153. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +13 -12
  154. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +2 -1
  155. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12537 -12415
  156. package/src/duckdb/ub_src_catalog_catalog_entry.cpp +1 -1
  157. package/src/duckdb/ub_src_execution_operator_persistent.cpp +2 -0
  158. package/src/duckdb/ub_src_parser_parsed_data.cpp +16 -0
  159. package/src/statement.cpp +15 -13
  160. package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +0 -104
@@ -55,7 +55,7 @@ struct WriteCSVData : public BaseCSVData {
55
55
  //! The size of the CSV file (in bytes) that we buffer before we flush it to disk
56
56
  idx_t flush_size = 4096 * 8;
57
57
  //! For each byte whether or not the CSV file requires quotes when containing the byte
58
- unique_ptr<bool[]> requires_quotes;
58
+ unsafe_array_ptr<bool> requires_quotes;
59
59
  };
60
60
 
61
61
  struct ColumnInfo {
@@ -65,7 +65,7 @@ struct ColumnInfo {
65
65
  names = std::move(names_p);
66
66
  types = std::move(types_p);
67
67
  }
68
- void Serialize(FieldWriter &writer) {
68
+ void Serialize(FieldWriter &writer) const {
69
69
  writer.WriteList<string>(names);
70
70
  writer.WriteRegularSerializableList<LogicalType>(types);
71
71
  }
@@ -99,8 +99,6 @@ struct ReadCSVData : public BaseCSVData {
99
99
  bool single_threaded = false;
100
100
  //! Reader bind data
101
101
  MultiFileReaderBindData reader_bind;
102
- //! If any file is a pipe
103
- bool is_pipe = false;
104
102
  vector<ColumnInfo> column_info;
105
103
 
106
104
  void Initialize(unique_ptr<BufferedCSVReader> &reader) {
@@ -33,6 +33,11 @@ public:
33
33
  unique_ptr<MacroFunction> Copy() const override;
34
34
 
35
35
  string ToSQL(const string &schema, const string &name) const override;
36
+
37
+ static unique_ptr<MacroFunction> Deserialize(FieldReader &reader);
38
+
39
+ protected:
40
+ void SerializeInternal(FieldWriter &writer) const override;
36
41
  };
37
42
 
38
43
  } // namespace duckdb
@@ -27,12 +27,12 @@ struct SingleJoinRelation {
27
27
 
28
28
  //! Set of relations, used in the join graph.
29
29
  struct JoinRelationSet {
30
- JoinRelationSet(unique_ptr<idx_t[]> relations, idx_t count) : relations(std::move(relations)), count(count) {
30
+ JoinRelationSet(unsafe_array_ptr<idx_t> relations, idx_t count) : relations(std::move(relations)), count(count) {
31
31
  }
32
32
 
33
33
  string ToString() const;
34
34
 
35
- unique_ptr<idx_t[]> relations;
35
+ unsafe_array_ptr<idx_t> relations;
36
36
  idx_t count;
37
37
 
38
38
  static bool IsSubset(JoinRelationSet &super, JoinRelationSet &sub);
@@ -55,7 +55,7 @@ public:
55
55
  //! Create or get a JoinRelationSet from a set of relation bindings
56
56
  JoinRelationSet &GetJoinRelation(unordered_set<idx_t> &bindings);
57
57
  //! Create or get a JoinRelationSet from a (sorted, duplicate-free!) list of relations
58
- JoinRelationSet &GetJoinRelation(unique_ptr<idx_t[]> relations, idx_t count);
58
+ JoinRelationSet &GetJoinRelation(unsafe_array_ptr<idx_t> relations, idx_t count);
59
59
  //! Union two sets of relations together and create a new relation set
60
60
  JoinRelationSet &Union(JoinRelationSet &left, JoinRelationSet &right);
61
61
  // //! Create the set difference of left \ right (i.e. all elements in left that are not in right)
@@ -27,13 +27,10 @@ struct AttachInfo : public ParseInfo {
27
27
  unordered_map<string, Value> options;
28
28
 
29
29
  public:
30
- unique_ptr<AttachInfo> Copy() const {
31
- auto result = make_uniq<AttachInfo>();
32
- result->name = name;
33
- result->path = path;
34
- result->options = options;
35
- return result;
36
- }
30
+ unique_ptr<AttachInfo> Copy() const;
31
+
32
+ void Serialize(Serializer &serializer) const;
33
+ static unique_ptr<ParseInfo> Deserialize(Deserializer &deserializer);
37
34
  };
38
35
 
39
36
  } // namespace duckdb
@@ -14,22 +14,18 @@
14
14
  namespace duckdb {
15
15
 
16
16
  struct CreateMacroInfo : public CreateFunctionInfo {
17
- CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
18
- }
19
-
20
- CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
21
- }
17
+ CreateMacroInfo();
18
+ CreateMacroInfo(CatalogType type);
22
19
 
23
20
  unique_ptr<MacroFunction> function;
24
21
 
25
22
  public:
26
- unique_ptr<CreateInfo> Copy() const override {
27
- auto result = make_uniq<CreateMacroInfo>();
28
- result->function = function->Copy();
29
- result->name = name;
30
- CopyProperties(*result);
31
- return std::move(result);
32
- }
23
+ unique_ptr<CreateInfo> Copy() const override;
24
+
25
+ DUCKDB_API static unique_ptr<CreateMacroInfo> Deserialize(Deserializer &deserializer);
26
+
27
+ protected:
28
+ void SerializeInternal(Serializer &) const override;
33
29
  };
34
30
 
35
31
  } // namespace duckdb
@@ -29,10 +29,7 @@ enum class SequenceInfo : uint8_t {
29
29
  };
30
30
 
31
31
  struct CreateSequenceInfo : public CreateInfo {
32
- CreateSequenceInfo()
33
- : CreateInfo(CatalogType::SEQUENCE_ENTRY, INVALID_SCHEMA), name(string()), usage_count(0), increment(1),
34
- min_value(1), max_value(NumericLimits<int64_t>::Maximum()), start_value(1), cycle(false) {
35
- }
32
+ CreateSequenceInfo();
36
33
 
37
34
  //! Sequence name to create
38
35
  string name;
@@ -50,24 +47,13 @@ struct CreateSequenceInfo : public CreateInfo {
50
47
  bool cycle;
51
48
 
52
49
  public:
53
- unique_ptr<CreateInfo> Copy() const override {
54
- auto result = make_uniq<CreateSequenceInfo>();
55
- CopyProperties(*result);
56
- result->name = name;
57
- result->schema = schema;
58
- result->usage_count = usage_count;
59
- result->increment = increment;
60
- result->min_value = min_value;
61
- result->max_value = max_value;
62
- result->start_value = start_value;
63
- result->cycle = cycle;
64
- return std::move(result);
65
- }
50
+ unique_ptr<CreateInfo> Copy() const override;
51
+
52
+ public:
53
+ DUCKDB_API static unique_ptr<CreateSequenceInfo> Deserialize(Deserializer &deserializer);
66
54
 
67
55
  protected:
68
- void SerializeInternal(Serializer &) const override {
69
- throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(type));
70
- }
56
+ void SerializeInternal(Serializer &) const override;
71
57
  };
72
58
 
73
59
  } // namespace duckdb
@@ -16,11 +16,8 @@
16
16
  namespace duckdb {
17
17
 
18
18
  struct CreateTypeInfo : public CreateInfo {
19
- CreateTypeInfo() : CreateInfo(CatalogType::TYPE_ENTRY) {
20
- }
21
- CreateTypeInfo(string name_p, LogicalType type_p)
22
- : CreateInfo(CatalogType::TYPE_ENTRY), name(std::move(name_p)), type(std::move(type_p)) {
23
- }
19
+ CreateTypeInfo();
20
+ CreateTypeInfo(string name_p, LogicalType type_p);
24
21
 
25
22
  //! Name of the Type
26
23
  string name;
@@ -30,21 +27,12 @@ struct CreateTypeInfo : public CreateInfo {
30
27
  unique_ptr<SQLStatement> query;
31
28
 
32
29
  public:
33
- unique_ptr<CreateInfo> Copy() const override {
34
- auto result = make_uniq<CreateTypeInfo>();
35
- CopyProperties(*result);
36
- result->name = name;
37
- result->type = type;
38
- if (query) {
39
- result->query = query->Copy();
40
- }
41
- return std::move(result);
42
- }
30
+ unique_ptr<CreateInfo> Copy() const override;
31
+
32
+ DUCKDB_API static unique_ptr<CreateTypeInfo> Deserialize(Deserializer &deserializer);
43
33
 
44
34
  protected:
45
- void SerializeInternal(Serializer &) const override {
46
- throw NotImplementedException("Cannot serialize '%s'", CatalogTypeToString(CreateInfo::type));
47
- }
35
+ void SerializeInternal(Serializer &) const override;
48
36
  };
49
37
 
50
38
  } // namespace duckdb
@@ -14,8 +14,7 @@
14
14
  namespace duckdb {
15
15
 
16
16
  struct DetachInfo : public ParseInfo {
17
- DetachInfo() {
18
- }
17
+ DetachInfo();
19
18
 
20
19
  //! The alias of the attached database
21
20
  string name;
@@ -23,11 +22,8 @@ struct DetachInfo : public ParseInfo {
23
22
  OnEntryNotFound if_not_found;
24
23
 
25
24
  public:
26
- unique_ptr<DetachInfo> Copy() const {
27
- auto result = make_uniq<DetachInfo>();
28
- result->name = name;
29
- result->if_not_found = if_not_found;
30
- return result;
31
- }
25
+ unique_ptr<DetachInfo> Copy() const;
26
+ void Serialize(Serializer &serializer) const;
27
+ static unique_ptr<ParseInfo> Deserialize(Deserializer &deserializer);
32
28
  };
33
29
  } // namespace duckdb
@@ -15,8 +15,7 @@
15
15
  namespace duckdb {
16
16
 
17
17
  struct DropInfo : public ParseInfo {
18
- DropInfo() : catalog(INVALID_CATALOG), schema(INVALID_SCHEMA), cascade(false) {
19
- }
18
+ DropInfo();
20
19
 
21
20
  //! The catalog type to drop
22
21
  CatalogType type;
@@ -35,43 +34,10 @@ struct DropInfo : public ParseInfo {
35
34
  bool allow_drop_internal = false;
36
35
 
37
36
  public:
38
- unique_ptr<DropInfo> Copy() const {
39
- auto result = make_uniq<DropInfo>();
40
- result->type = type;
41
- result->catalog = catalog;
42
- result->schema = schema;
43
- result->name = name;
44
- result->if_not_found = if_not_found;
45
- result->cascade = cascade;
46
- result->allow_drop_internal = allow_drop_internal;
47
- return result;
48
- }
37
+ unique_ptr<DropInfo> Copy() const;
49
38
 
50
- void Serialize(Serializer &serializer) const {
51
- FieldWriter writer(serializer);
52
- writer.WriteField<CatalogType>(type);
53
- writer.WriteString(catalog);
54
- writer.WriteString(schema);
55
- writer.WriteString(name);
56
- writer.WriteField(if_not_found);
57
- writer.WriteField(cascade);
58
- writer.WriteField(allow_drop_internal);
59
- writer.Finalize();
60
- }
61
-
62
- static unique_ptr<ParseInfo> Deserialize(Deserializer &deserializer) {
63
- FieldReader reader(deserializer);
64
- auto drop_info = make_uniq<DropInfo>();
65
- drop_info->type = reader.ReadRequired<CatalogType>();
66
- drop_info->catalog = reader.ReadRequired<string>();
67
- drop_info->schema = reader.ReadRequired<string>();
68
- drop_info->name = reader.ReadRequired<string>();
69
- drop_info->if_not_found = reader.ReadRequired<OnEntryNotFound>();
70
- drop_info->cascade = reader.ReadRequired<bool>();
71
- drop_info->allow_drop_internal = reader.ReadRequired<bool>();
72
- reader.Finalize();
73
- return std::move(drop_info);
74
- }
39
+ void Serialize(Serializer &serializer) const;
40
+ static unique_ptr<ParseInfo> Deserialize(Deserializer &deserializer);
75
41
  };
76
42
 
77
43
  } // namespace duckdb
@@ -15,11 +15,14 @@ namespace duckdb {
15
15
  enum class TransactionType : uint8_t { INVALID, BEGIN_TRANSACTION, COMMIT, ROLLBACK };
16
16
 
17
17
  struct TransactionInfo : public ParseInfo {
18
- explicit TransactionInfo(TransactionType type) : type(type) {
19
- }
18
+ explicit TransactionInfo(TransactionType type);
20
19
 
21
20
  //! The type of transaction statement
22
21
  TransactionType type;
22
+
23
+ public:
24
+ void Serialize(Serializer &serializer) const;
25
+ static unique_ptr<ParseInfo> Deserialize(Deserializer &deserializer);
23
26
  };
24
27
 
25
28
  } // namespace duckdb
@@ -17,22 +17,16 @@
17
17
  namespace duckdb {
18
18
 
19
19
  struct VacuumOptions {
20
+ VacuumOptions() : vacuum(false), analyze(false) {
21
+ }
22
+
20
23
  bool vacuum;
21
24
  bool analyze;
22
25
  };
23
26
 
24
27
  struct VacuumInfo : public ParseInfo {
25
28
  public:
26
- explicit VacuumInfo(VacuumOptions options) : options(options), has_table(false) {};
27
-
28
- unique_ptr<VacuumInfo> Copy() {
29
- auto result = make_uniq<VacuumInfo>(options);
30
- result->has_table = has_table;
31
- if (has_table) {
32
- result->ref = ref->Copy();
33
- }
34
- return result;
35
- }
29
+ explicit VacuumInfo(VacuumOptions options);
36
30
 
37
31
  const VacuumOptions options;
38
32
 
@@ -42,6 +36,12 @@ public:
42
36
  optional_ptr<TableCatalogEntry> table;
43
37
  unordered_map<idx_t, idx_t> column_id_map;
44
38
  vector<string> columns;
39
+
40
+ public:
41
+ unique_ptr<VacuumInfo> Copy();
42
+
43
+ void Serialize(Serializer &serializer) const;
44
+ static unique_ptr<ParseInfo> Deserialize(Deserializer &deserializer);
45
45
  };
46
46
 
47
47
  } // namespace duckdb
@@ -24,6 +24,8 @@ enum class OnConflictAction : uint8_t {
24
24
  REPLACE // Only used in transform/bind step, changed to UPDATE later
25
25
  };
26
26
 
27
+ enum class InsertColumnOrder : uint8_t { INSERT_BY_POSITION = 0, INSERT_BY_NAME = 1 };
28
+
27
29
  class OnConflictInfo {
28
30
  public:
29
31
  OnConflictInfo();
@@ -75,6 +77,9 @@ public:
75
77
  //! Whether or not this a DEFAULT VALUES
76
78
  bool default_values = false;
77
79
 
80
+ //! INSERT BY POSITION or INSERT BY NAME
81
+ InsertColumnOrder column_order = InsertColumnOrder::INSERT_BY_POSITION;
82
+
78
83
  protected:
79
84
  InsertStatement(const InsertStatement &other);
80
85
 
@@ -20,7 +20,7 @@ struct ArenaChunk {
20
20
  AllocatedData data;
21
21
  idx_t current_position;
22
22
  idx_t maximum_size;
23
- unique_ptr<ArenaChunk> next;
23
+ unsafe_unique_ptr<ArenaChunk> next;
24
24
  ArenaChunk *prev;
25
25
  };
26
26
 
@@ -56,7 +56,7 @@ private:
56
56
  //! Internal allocator that is used by the arena allocator
57
57
  Allocator &allocator;
58
58
  idx_t current_capacity;
59
- unique_ptr<ArenaChunk> head;
59
+ unsafe_unique_ptr<ArenaChunk> head;
60
60
  ArenaChunk *tail;
61
61
  //! An allocator wrapper using this arena allocator
62
62
  Allocator arena_allocator;
@@ -9,6 +9,7 @@
9
9
  #pragma once
10
10
 
11
11
  #include "duckdb/storage/storage_info.hpp"
12
+ #include "duckdb/common/file_buffer.hpp"
12
13
 
13
14
  namespace duckdb {
14
15
  class BlockHandle;
@@ -30,9 +31,15 @@ public:
30
31
  //! Returns whether or not the BufferHandle is valid.
31
32
  DUCKDB_API bool IsValid() const;
32
33
  //! Returns a pointer to the buffer data. Handle must be valid.
33
- DUCKDB_API data_ptr_t Ptr() const;
34
+ inline data_ptr_t Ptr() const {
35
+ D_ASSERT(IsValid());
36
+ return node->buffer;
37
+ }
34
38
  //! Returns a pointer to the buffer data. Handle must be valid.
35
- DUCKDB_API data_ptr_t Ptr();
39
+ inline data_ptr_t Ptr() {
40
+ D_ASSERT(IsValid());
41
+ return node->buffer;
42
+ }
36
43
  //! Gets the underlying file buffer. Handle must be valid.
37
44
  DUCKDB_API FileBuffer &GetFileBuffer();
38
45
  //! Destroys the buffer handle
@@ -138,7 +138,7 @@ private:
138
138
  StringStatsData string_data;
139
139
  } stats_union;
140
140
  //! Child stats (for LIST and STRUCT)
141
- unique_ptr<BaseStatistics[]> child_stats;
141
+ unsafe_array_ptr<BaseStatistics> child_stats;
142
142
  };
143
143
 
144
144
  } // namespace duckdb
@@ -44,7 +44,7 @@ struct RowGroupAppendState {
44
44
  //! The current row_group we are appending to
45
45
  RowGroup *row_group;
46
46
  //! The column append states
47
- unique_ptr<ColumnAppendState[]> states;
47
+ unsafe_array_ptr<ColumnAppendState> states;
48
48
  //! Offset within the row_group
49
49
  idx_t offset_in_row_group;
50
50
  };
@@ -99,7 +99,7 @@ public:
99
99
  //! The maximum row within the row group
100
100
  idx_t max_row_group_row;
101
101
  //! Child column scans
102
- unique_ptr<ColumnScanState[]> column_scans;
102
+ unsafe_array_ptr<ColumnScanState> column_scans;
103
103
  //! Row group segment tree
104
104
  RowGroupSegmentTree *row_groups;
105
105
  //! The total maximum row index
@@ -96,8 +96,8 @@ private:
96
96
 
97
97
  struct UpdateNodeData {
98
98
  unique_ptr<UpdateInfo> info;
99
- unique_ptr<sel_t[]> tuples;
100
- unique_ptr<data_t[]> tuple_data;
99
+ unsafe_array_ptr<sel_t> tuples;
100
+ unsafe_array_ptr<data_t> tuple_data;
101
101
  };
102
102
 
103
103
  struct UpdateNode {
@@ -35,7 +35,7 @@ bool JoinRelationSet::IsSubset(JoinRelationSet &super, JoinRelationSet &sub) {
35
35
  return false;
36
36
  }
37
37
 
38
- JoinRelationSet &JoinRelationSetManager::GetJoinRelation(unique_ptr<idx_t[]> relations, idx_t count) {
38
+ JoinRelationSet &JoinRelationSetManager::GetJoinRelation(unsafe_array_ptr<idx_t> relations, idx_t count) {
39
39
  // now look it up in the tree
40
40
  reference<JoinRelationTreeNode> info(root);
41
41
  for (idx_t i = 0; i < count; i++) {
@@ -59,7 +59,7 @@ JoinRelationSet &JoinRelationSetManager::GetJoinRelation(unique_ptr<idx_t[]> rel
59
59
  //! Create or get a JoinRelationSet from a single node with the given index
60
60
  JoinRelationSet &JoinRelationSetManager::GetJoinRelation(idx_t index) {
61
61
  // create a sorted vector of the relations
62
- auto relations = unique_ptr<idx_t[]>(new idx_t[1]);
62
+ auto relations = make_unsafe_array<idx_t>(1);
63
63
  relations[0] = index;
64
64
  idx_t count = 1;
65
65
  return GetJoinRelation(std::move(relations), count);
@@ -67,7 +67,7 @@ JoinRelationSet &JoinRelationSetManager::GetJoinRelation(idx_t index) {
67
67
 
68
68
  JoinRelationSet &JoinRelationSetManager::GetJoinRelation(unordered_set<idx_t> &bindings) {
69
69
  // create a sorted vector of the relations
70
- unique_ptr<idx_t[]> relations = bindings.empty() ? nullptr : unique_ptr<idx_t[]>(new idx_t[bindings.size()]);
70
+ unsafe_array_ptr<idx_t> relations = bindings.empty() ? nullptr : make_unsafe_array<idx_t>(bindings.size());
71
71
  idx_t count = 0;
72
72
  for (auto &entry : bindings) {
73
73
  relations[count++] = entry;
@@ -77,7 +77,7 @@ JoinRelationSet &JoinRelationSetManager::GetJoinRelation(unordered_set<idx_t> &b
77
77
  }
78
78
 
79
79
  JoinRelationSet &JoinRelationSetManager::Union(JoinRelationSet &left, JoinRelationSet &right) {
80
- auto relations = unique_ptr<idx_t[]>(new idx_t[left.count + right.count]);
80
+ auto relations = make_unsafe_array<idx_t>(left.count + right.count);
81
81
  idx_t count = 0;
82
82
  // move through the left and right relations, eliminating duplicates
83
83
  idx_t i = 0, j = 0;
@@ -113,7 +113,7 @@ JoinRelationSet &JoinRelationSetManager::Union(JoinRelationSet &left, JoinRelati
113
113
  }
114
114
 
115
115
  // JoinRelationSet *JoinRelationSetManager::Difference(JoinRelationSet *left, JoinRelationSet *right) {
116
- // auto relations = unique_ptr<idx_t[]>(new idx_t[left->count]);
116
+ // auto relations = unsafe_array_ptr<idx_t>(new idx_t[left->count]);
117
117
  // idx_t count = 0;
118
118
  // // move through the left and right relations
119
119
  // idx_t i = 0, j = 0;
@@ -195,18 +195,24 @@ void UnnestRewriter::UpdateRHSBindings(unique_ptr<LogicalOperator> *plan_ptr, un
195
195
  updater.replace_bindings.push_back(replace_binding);
196
196
  }
197
197
 
198
- // temporarily remove the BOUND_UNNEST and the child of the LOGICAL_UNNEST from the plan
198
+ // temporarily remove the BOUND_UNNESTs and the child of the LOGICAL_UNNEST from the plan
199
199
  D_ASSERT(curr_op->get()->type == LogicalOperatorType::LOGICAL_UNNEST);
200
200
  auto &unnest = curr_op->get()->Cast<LogicalUnnest>();
201
- auto temp_bound_unnest = std::move(unnest.expressions[0]);
201
+ vector<unique_ptr<Expression>> temp_bound_unnests;
202
+ for (auto &temp_bound_unnest : unnest.expressions) {
203
+ temp_bound_unnests.push_back(std::move(temp_bound_unnest));
204
+ }
205
+ D_ASSERT(unnest.children.size() == 1);
202
206
  auto temp_unnest_child = std::move(unnest.children[0]);
203
207
  unnest.expressions.clear();
204
208
  unnest.children.clear();
205
209
  // update the bindings of the plan
206
210
  updater.VisitOperator(*plan_ptr->get());
207
211
  updater.replace_bindings.clear();
208
- // add the child again
209
- unnest.expressions.push_back(std::move(temp_bound_unnest));
212
+ // add the children again
213
+ for (auto &temp_bound_unnest : temp_bound_unnests) {
214
+ unnest.expressions.push_back(std::move(temp_bound_unnest));
215
+ }
210
216
  unnest.children.push_back(std::move(temp_unnest_child));
211
217
 
212
218
  // add the LHS expressions to each LOGICAL_PROJECTION
@@ -256,6 +262,7 @@ void UnnestRewriter::UpdateBoundUnnestBindings(UnnestRewriterPlanUpdater &update
256
262
  D_ASSERT(curr_op->get()->type == LogicalOperatorType::LOGICAL_UNNEST);
257
263
  auto &unnest = curr_op->get()->Cast<LogicalUnnest>();
258
264
 
265
+ D_ASSERT(unnest.children.size() == 1);
259
266
  auto unnest_child_cols = unnest.children[0]->GetColumnBindings();
260
267
  for (idx_t delim_col_idx = 0; delim_col_idx < delim_columns.size(); delim_col_idx++) {
261
268
  for (idx_t child_col_idx = 0; child_col_idx < unnest_child_cols.size(); child_col_idx++) {
@@ -268,8 +275,9 @@ void UnnestRewriter::UpdateBoundUnnestBindings(UnnestRewriterPlanUpdater &update
268
275
  }
269
276
 
270
277
  // update bindings
271
- D_ASSERT(unnest.expressions.size() == 1);
272
- updater.VisitExpression(&unnest.expressions[0]);
278
+ for (auto &unnest_expr : unnest.expressions) {
279
+ updater.VisitExpression(&unnest_expr);
280
+ }
273
281
  updater.replace_bindings.clear();
274
282
  }
275
283
 
@@ -0,0 +1,42 @@
1
+ #include "duckdb/parser/parsed_data/attach_info.hpp"
2
+ #include "duckdb/common/field_writer.hpp"
3
+
4
+ namespace duckdb {
5
+
6
+ unique_ptr<AttachInfo> AttachInfo::Copy() const {
7
+ auto result = make_uniq<AttachInfo>();
8
+ result->name = name;
9
+ result->path = path;
10
+ result->options = options;
11
+ return result;
12
+ }
13
+
14
+ void AttachInfo::Serialize(Serializer &main_serializer) const {
15
+ FieldWriter writer(main_serializer);
16
+ writer.WriteString(name);
17
+ writer.WriteString(path);
18
+ writer.WriteField<uint32_t>(options.size());
19
+ auto &serializer = writer.GetSerializer();
20
+ for (auto &kv : options) {
21
+ serializer.WriteString(kv.first);
22
+ kv.second.Serialize(serializer);
23
+ }
24
+ writer.Finalize();
25
+ }
26
+
27
+ unique_ptr<ParseInfo> AttachInfo::Deserialize(Deserializer &deserializer) {
28
+ FieldReader reader(deserializer);
29
+ auto attach_info = make_uniq<AttachInfo>();
30
+ attach_info->name = reader.ReadRequired<string>();
31
+ attach_info->path = reader.ReadRequired<string>();
32
+ auto default_attach_count = reader.ReadRequired<uint32_t>();
33
+ auto &source = reader.GetSource();
34
+ for (idx_t i = 0; i < default_attach_count; i++) {
35
+ auto name = source.Read<string>();
36
+ attach_info->options[name] = Value::Deserialize(source);
37
+ }
38
+ reader.Finalize();
39
+ return std::move(attach_info);
40
+ }
41
+
42
+ } // namespace duckdb
@@ -5,7 +5,6 @@
5
5
  namespace duckdb {
6
6
 
7
7
  unique_ptr<CreateInfo> CreateIndexInfo::Copy() const {
8
-
9
8
  auto result = make_uniq<CreateIndexInfo>();
10
9
  CopyProperties(*result);
11
10
 
@@ -27,24 +26,20 @@ unique_ptr<CreateInfo> CreateIndexInfo::Copy() const {
27
26
  }
28
27
 
29
28
  void CreateIndexInfo::SerializeInternal(Serializer &serializer) const {
30
-
31
29
  FieldWriter writer(serializer);
32
30
  writer.WriteField(index_type);
33
31
  writer.WriteString(index_name);
34
32
  writer.WriteField(constraint_type);
35
33
 
36
- writer.WriteSerializableList<ParsedExpression>(expressions);
37
34
  writer.WriteSerializableList<ParsedExpression>(parsed_expressions);
38
35
 
39
36
  writer.WriteRegularSerializableList(scan_types);
40
37
  writer.WriteList<string>(names);
41
38
  writer.WriteList<column_t>(column_ids);
42
-
43
39
  writer.Finalize();
44
40
  }
45
41
 
46
42
  unique_ptr<CreateIndexInfo> CreateIndexInfo::Deserialize(Deserializer &deserializer) {
47
-
48
43
  auto result = make_uniq<CreateIndexInfo>();
49
44
  result->DeserializeBase(deserializer);
50
45
 
@@ -53,13 +48,11 @@ unique_ptr<CreateIndexInfo> CreateIndexInfo::Deserialize(Deserializer &deseriali
53
48
  result->index_name = reader.ReadRequired<string>();
54
49
  result->constraint_type = reader.ReadRequired<IndexConstraintType>();
55
50
 
56
- result->expressions = reader.ReadRequiredSerializableList<ParsedExpression>();
57
51
  result->parsed_expressions = reader.ReadRequiredSerializableList<ParsedExpression>();
58
52
 
59
53
  result->scan_types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
60
54
  result->names = reader.ReadRequiredList<string>();
61
55
  result->column_ids = reader.ReadRequiredList<column_t>();
62
-
63
56
  reader.Finalize();
64
57
  return result;
65
58
  }