duckdb 0.7.1-dev37.0 → 0.7.1-dev415.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 (171) hide show
  1. package/README.md +1 -1
  2. package/binding.gyp +7 -7
  3. package/package.json +3 -3
  4. package/src/duckdb/extension/json/buffered_json_reader.cpp +50 -9
  5. package/src/duckdb/extension/json/include/buffered_json_reader.hpp +7 -2
  6. package/src/duckdb/extension/json/include/json_scan.hpp +45 -10
  7. package/src/duckdb/extension/json/json_functions/copy_json.cpp +35 -22
  8. package/src/duckdb/extension/json/json_functions/json_create.cpp +8 -8
  9. package/src/duckdb/extension/json/json_functions/json_structure.cpp +8 -3
  10. package/src/duckdb/extension/json/json_functions/json_transform.cpp +54 -10
  11. package/src/duckdb/extension/json/json_functions/read_json.cpp +104 -49
  12. package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +5 -3
  13. package/src/duckdb/extension/json/json_functions.cpp +7 -0
  14. package/src/duckdb/extension/json/json_scan.cpp +144 -37
  15. package/src/duckdb/extension/parquet/column_reader.cpp +7 -0
  16. package/src/duckdb/extension/parquet/include/column_reader.hpp +1 -0
  17. package/src/duckdb/extension/parquet/parquet-extension.cpp +2 -9
  18. package/src/duckdb/src/catalog/catalog.cpp +62 -13
  19. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +8 -7
  20. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +1 -1
  21. package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
  22. package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
  23. package/src/duckdb/src/common/bind_helpers.cpp +55 -0
  24. package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
  25. package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
  26. package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
  27. package/src/duckdb/src/common/file_system.cpp +28 -0
  28. package/src/duckdb/src/common/hive_partitioning.cpp +1 -0
  29. package/src/duckdb/src/common/local_file_system.cpp +4 -4
  30. package/src/duckdb/src/common/operator/cast_operators.cpp +10 -4
  31. package/src/duckdb/src/common/string_util.cpp +8 -4
  32. package/src/duckdb/src/common/types/partitioned_column_data.cpp +1 -0
  33. package/src/duckdb/src/common/types/time.cpp +1 -1
  34. package/src/duckdb/src/common/types/timestamp.cpp +35 -4
  35. package/src/duckdb/src/common/types.cpp +37 -11
  36. package/src/duckdb/src/execution/column_binding_resolver.cpp +5 -2
  37. package/src/duckdb/src/execution/index/art/art.cpp +117 -67
  38. package/src/duckdb/src/execution/index/art/art_key.cpp +24 -12
  39. package/src/duckdb/src/execution/index/art/leaf.cpp +7 -8
  40. package/src/duckdb/src/execution/index/art/node.cpp +13 -27
  41. package/src/duckdb/src/execution/index/art/node16.cpp +5 -8
  42. package/src/duckdb/src/execution/index/art/node256.cpp +3 -5
  43. package/src/duckdb/src/execution/index/art/node4.cpp +4 -7
  44. package/src/duckdb/src/execution/index/art/node48.cpp +5 -8
  45. package/src/duckdb/src/execution/index/art/prefix.cpp +2 -3
  46. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +6 -27
  47. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +1 -9
  48. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +1 -9
  49. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +7 -9
  50. package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +6 -11
  51. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +13 -13
  52. package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +37 -0
  53. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +0 -5
  54. package/src/duckdb/src/execution/physical_operator.cpp +6 -6
  55. package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +4 -0
  56. package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -0
  57. package/src/duckdb/src/function/pragma/pragma_queries.cpp +38 -11
  58. package/src/duckdb/src/function/scalar/generic/current_setting.cpp +2 -2
  59. package/src/duckdb/src/function/scalar/map/map.cpp +69 -21
  60. package/src/duckdb/src/function/table/read_csv.cpp +17 -5
  61. package/src/duckdb/src/function/table/system/duckdb_temporary_files.cpp +59 -0
  62. package/src/duckdb/src/function/table/system_functions.cpp +1 -0
  63. package/src/duckdb/src/function/table/table_scan.cpp +3 -0
  64. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  65. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +7 -1
  66. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
  67. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
  68. package/src/duckdb/src/include/duckdb/common/bind_helpers.hpp +2 -0
  69. package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
  70. package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
  71. package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +3 -2
  72. package/src/duckdb/src/include/duckdb/common/enums/wal_type.hpp +3 -0
  73. package/src/duckdb/src/include/duckdb/common/exception.hpp +10 -0
  74. package/src/duckdb/src/include/duckdb/common/file_system.hpp +1 -0
  75. package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +9 -1
  76. package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +4 -4
  77. package/src/duckdb/src/include/duckdb/common/string_util.hpp +9 -2
  78. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +5 -1
  79. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +37 -41
  80. package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +8 -11
  81. package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +1 -3
  82. package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +0 -2
  83. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
  84. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +32 -0
  85. package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
  86. package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -2
  87. package/src/duckdb/src/include/duckdb/main/config.hpp +2 -3
  88. package/src/duckdb/src/include/duckdb/main/{extension_functions.hpp → extension_entries.hpp} +26 -5
  89. package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +3 -0
  90. package/src/duckdb/src/include/duckdb/main/settings.hpp +9 -0
  91. package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +0 -7
  92. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -4
  93. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +32 -0
  94. package/src/duckdb/src/include/duckdb/parser/query_node/select_node.hpp +1 -1
  95. package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +2 -2
  96. package/src/duckdb/src/include/duckdb/parser/statement/copy_statement.hpp +1 -1
  97. package/src/duckdb/src/include/duckdb/parser/statement/detach_statement.hpp +29 -0
  98. package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
  99. package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +3 -3
  100. package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +1 -1
  101. package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
  102. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +1 -0
  103. package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -0
  104. package/src/duckdb/src/include/duckdb/planner/expression_binder/index_binder.hpp +10 -3
  105. package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +1 -5
  106. package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +1 -2
  107. package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +8 -0
  108. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +7 -1
  109. package/src/duckdb/src/include/duckdb/storage/index.hpp +47 -38
  110. package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +7 -0
  111. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -0
  112. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +7 -0
  113. package/src/duckdb/src/main/client_context.cpp +2 -0
  114. package/src/duckdb/src/main/config.cpp +1 -0
  115. package/src/duckdb/src/main/database.cpp +14 -5
  116. package/src/duckdb/src/main/extension/extension_alias.cpp +2 -1
  117. package/src/duckdb/src/main/extension/extension_install.cpp +43 -9
  118. package/src/duckdb/src/main/extension/extension_load.cpp +29 -5
  119. package/src/duckdb/src/main/settings/settings.cpp +16 -0
  120. package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +2 -6
  121. package/src/duckdb/src/parallel/pipeline_executor.cpp +1 -55
  122. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +3 -0
  123. package/src/duckdb/src/parser/statement/copy_statement.cpp +2 -13
  124. package/src/duckdb/src/parser/statement/delete_statement.cpp +3 -0
  125. package/src/duckdb/src/parser/statement/detach_statement.cpp +15 -0
  126. package/src/duckdb/src/parser/statement/insert_statement.cpp +9 -0
  127. package/src/duckdb/src/parser/statement/update_statement.cpp +3 -0
  128. package/src/duckdb/src/parser/transform/expression/transform_case.cpp +3 -3
  129. package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -1
  130. package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +19 -0
  131. package/src/duckdb/src/parser/transformer.cpp +2 -0
  132. package/src/duckdb/src/planner/bind_context.cpp +1 -1
  133. package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +3 -0
  134. package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +7 -14
  135. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +16 -14
  136. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +13 -0
  137. package/src/duckdb/src/planner/binder/statement/bind_detach.cpp +19 -0
  138. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +29 -4
  139. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +22 -1
  140. package/src/duckdb/src/planner/binder.cpp +2 -0
  141. package/src/duckdb/src/planner/expression_binder/index_binder.cpp +32 -1
  142. package/src/duckdb/src/planner/logical_operator.cpp +6 -1
  143. package/src/duckdb/src/planner/planner.cpp +1 -0
  144. package/src/duckdb/src/storage/buffer_manager.cpp +105 -26
  145. package/src/duckdb/src/storage/compression/bitpacking.cpp +16 -7
  146. package/src/duckdb/src/storage/data_table.cpp +66 -3
  147. package/src/duckdb/src/storage/index.cpp +1 -1
  148. package/src/duckdb/src/storage/local_storage.cpp +1 -1
  149. package/src/duckdb/src/storage/table/column_data.cpp +4 -2
  150. package/src/duckdb/src/storage/table/update_segment.cpp +15 -0
  151. package/src/duckdb/src/storage/table_index_list.cpp +1 -2
  152. package/src/duckdb/src/storage/wal_replay.cpp +68 -0
  153. package/src/duckdb/src/storage/write_ahead_log.cpp +21 -1
  154. package/src/duckdb/src/transaction/commit_state.cpp +5 -2
  155. package/src/duckdb/third_party/concurrentqueue/blockingconcurrentqueue.h +2 -2
  156. package/src/duckdb/third_party/fmt/include/fmt/core.h +1 -2
  157. package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +1 -0
  158. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +14 -0
  159. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +530 -1006
  160. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +17659 -17626
  161. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
  162. package/src/duckdb/ub_src_execution_operator_schema.cpp +2 -0
  163. package/src/duckdb/ub_src_function_table_system.cpp +2 -0
  164. package/src/duckdb/ub_src_parser_statement.cpp +2 -0
  165. package/src/duckdb/ub_src_parser_transform_statement.cpp +2 -0
  166. package/src/duckdb/ub_src_planner_binder_statement.cpp +2 -0
  167. package/src/statement.cpp +46 -12
  168. package/test/arrow.test.ts +3 -3
  169. package/test/prepare.test.ts +39 -1
  170. package/test/typescript_decls.test.ts +1 -1
  171. package/src/duckdb/src/include/duckdb/function/create_database_extension.hpp +0 -37
@@ -29,24 +29,21 @@ namespace duckdb {
29
29
  class ConflictManager;
30
30
 
31
31
  struct ARTIndexScanState : public IndexScanState {
32
- ARTIndexScanState() : checked(false), result_index(0) {
33
- }
34
32
 
33
+ //! Scan predicates (single predicate scan or range scan)
35
34
  Value values[2];
35
+ //! Expressions of the scan predicates
36
36
  ExpressionType expressions[2];
37
- bool checked;
37
+ bool checked = false;
38
+ //! All scanned row IDs
38
39
  vector<row_t> result_ids;
39
40
  Iterator iterator;
40
- //! Stores the current leaf
41
- Leaf *cur_leaf = nullptr;
42
- //! Offset to leaf
43
- idx_t result_index = 0;
44
41
  };
45
42
 
46
43
  enum class VerifyExistenceType : uint8_t {
47
- APPEND = 0, // for purpose to append into table
48
- APPEND_FK = 1, // for purpose to append into table has foreign key
49
- DELETE_FK = 2 // for purpose to delete from table related to foreign key
44
+ APPEND = 0, // appends to a table
45
+ APPEND_FK = 1, // appends to a table that has a foreign key
46
+ DELETE_FK = 2 // delete from a table that has a foreign key
50
47
  };
51
48
 
52
49
  class ART : public Index {
@@ -62,47 +59,44 @@ public:
62
59
  Node *tree;
63
60
 
64
61
  public:
65
- //! Initialize a scan on the index with the given expression and column ids
66
- //! to fetch from the base table for a single predicate
62
+ //! Initialize a single predicate scan on the index with the given expression and column IDs
67
63
  unique_ptr<IndexScanState> InitializeScanSinglePredicate(const Transaction &transaction, const Value &value,
68
64
  ExpressionType expression_type) override;
69
-
70
- //! Initialize a scan on the index with the given expression and column ids
71
- //! to fetch from the base table for two predicates
65
+ //! Initialize a two predicate scan on the index with the given expression and column IDs
72
66
  unique_ptr<IndexScanState> InitializeScanTwoPredicates(Transaction &transaction, const Value &low_value,
73
67
  ExpressionType low_expression_type, const Value &high_value,
74
68
  ExpressionType high_expression_type) override;
75
-
76
- //! Perform a lookup on the index
69
+ //! Performs a lookup on the index, fetching up to max_count result IDs. Returns true if all row IDs were fetched,
70
+ //! and false otherwise
77
71
  bool Scan(Transaction &transaction, DataTable &table, IndexScanState &state, idx_t max_count,
78
72
  vector<row_t> &result_ids) override;
79
- //! Append entries to the index
73
+
74
+ //! Called when data is appended to the index. The lock obtained from InitializeLock must be held
80
75
  bool Append(IndexLock &lock, DataChunk &entries, Vector &row_identifiers) override;
81
- //! Verify that data can be appended to the index
76
+ //! Verify that data can be appended to the index without a constraint violation
82
77
  void VerifyAppend(DataChunk &chunk) override;
83
- //! Verify that data can be appended to the index
78
+ //! Verify that data can be appended to the index without a constraint violation using the conflict manager
84
79
  void VerifyAppend(DataChunk &chunk, ConflictManager &conflict_manager) override;
85
- //! Verify that data can be appended to the index for foreign key constraint
86
- void VerifyAppendForeignKey(DataChunk &chunk) override;
87
- //! Verify that data can be delete from the index for foreign key constraint
88
- void VerifyDeleteForeignKey(DataChunk &chunk) override;
89
- //! Delete entries in the index
80
+ //! Delete a chunk of entries from the index. The lock obtained from InitializeLock must be held
90
81
  void Delete(IndexLock &lock, DataChunk &entries, Vector &row_identifiers) override;
91
- //! Insert data into the index
82
+ //! Insert a chunk of entries into the index
92
83
  bool Insert(IndexLock &lock, DataChunk &data, Vector &row_ids) override;
93
84
 
94
85
  //! Construct an ART from a vector of sorted keys
95
86
  bool ConstructFromSorted(idx_t count, vector<Key> &keys, Vector &row_identifiers);
96
87
 
97
- //! Search Equal and fetches the row IDs
88
+ //! Search equal values and fetches the row IDs
98
89
  bool SearchEqual(Key &key, idx_t max_count, vector<row_t> &result_ids);
99
- //! Search Equal used for Joins that do not need to fetch data
90
+ //! Search equal values used for joins that do not need to fetch data
100
91
  void SearchEqualJoinNoFetch(Key &key, idx_t &result_size);
101
- //! Serialized the ART
92
+
93
+ //! Serializes the index and returns the pair of block_id offset positions
102
94
  BlockPointer Serialize(duckdb::MetaBlockWriter &writer) override;
103
95
 
104
- //! Merge two ARTs
96
+ //! Merge another index into this index. The lock obtained from InitializeLock must be held, and the other
97
+ //! index must also be locked during the merge
105
98
  bool MergeIndexes(IndexLock &state, Index *other_index) override;
99
+
106
100
  //! Generate ART keys for an input chunk
107
101
  static void GenerateKeys(ArenaAllocator &allocator, DataChunk &input, vector<Key> &keys);
108
102
 
@@ -110,30 +104,32 @@ public:
110
104
  string GenerateErrorKeyName(DataChunk &input, idx_t row);
111
105
  //! Generate the matching error message for a constraint violation
112
106
  string GenerateConstraintErrorMessage(VerifyExistenceType verify_type, const string &key_name);
107
+ //! Performs constraint checking for a chunk of input data
108
+ void CheckConstraintsForChunk(DataChunk &input, ConflictManager &conflict_manager) override;
113
109
 
114
110
  //! Returns the string representation of an ART
115
111
  string ToString() override;
116
- //! Verifies that the memory_size value of the ART matches its actual size
112
+ //! Verifies that the in-memory size value of the index matches its actual size
117
113
  void Verify() override;
114
+ //! Increases the memory size by the difference between the old size and the current size
115
+ //! and performs verifications
116
+ void IncreaseAndVerifyMemorySize(idx_t old_memory_size) override;
118
117
 
119
118
  private:
120
- //! Insert a row id into a leaf node
119
+ //! Insert a row ID into a leaf
121
120
  bool InsertToLeaf(Leaf &leaf, row_t row_id);
122
- //! Insert the leaf value into the tree
121
+ //! Insert a key into the tree
123
122
  bool Insert(Node *&node, Key &key, idx_t depth, row_t row_id);
124
-
125
- //! Erase element from leaf (if leaf has more than one value) or eliminate the leaf itself
123
+ //! Erase a key from the tree (if a leaf has more than one value) or erase the leaf itself
126
124
  void Erase(Node *&node, Key &key, idx_t depth, row_t row_id);
127
-
128
- //! Perform 'Lookup' for an entire chunk, marking which succeeded
129
- void LookupValues(DataChunk &input, ConflictManager &conflict_manager) final override;
130
-
131
- //! Find the node with a matching key, optimistic version
125
+ //! Find the node with a matching key, or return nullptr if not found
132
126
  Leaf *Lookup(Node *node, Key &key, idx_t depth);
133
-
127
+ //! Returns all row IDs belonging to a key greater (or equal) than the search key
134
128
  bool SearchGreater(ARTIndexScanState *state, Key &key, bool inclusive, idx_t max_count, vector<row_t> &result_ids);
129
+ //! Returns all row IDs belonging to a key less (or equal) than the upper_bound
135
130
  bool SearchLess(ARTIndexScanState *state, Key &upper_bound, bool inclusive, idx_t max_count,
136
131
  vector<row_t> &result_ids);
132
+ //! Returns all row IDs belonging to a key within the range of lower_bound and upper_bound
137
133
  bool SearchCloseRange(ARTIndexScanState *state, Key &lower_bound, Key &upper_bound, bool left_inclusive,
138
134
  bool right_inclusive, idx_t max_count, vector<row_t> &result_ids);
139
135
  };
@@ -28,24 +28,24 @@ public:
28
28
 
29
29
  public:
30
30
  template <class T>
31
- static inline Key CreateKey(ArenaAllocator &allocator, T element) {
31
+ static inline Key CreateKey(ArenaAllocator &allocator, const LogicalType &type, T element) {
32
32
  auto data = Key::CreateData<T>(allocator, element);
33
33
  return Key(data, sizeof(element));
34
34
  }
35
35
 
36
36
  template <class T>
37
- static inline Key CreateKey(ArenaAllocator &allocator, const Value &element) {
38
- return CreateKey(allocator, element.GetValueUnsafe<T>());
37
+ static inline Key CreateKey(ArenaAllocator &allocator, const LogicalType &type, const Value &element) {
38
+ return CreateKey(allocator, type, element.GetValueUnsafe<T>());
39
39
  }
40
40
 
41
41
  template <class T>
42
- static inline void CreateKey(ArenaAllocator &allocator, Key &key, T element) {
42
+ static inline void CreateKey(ArenaAllocator &allocator, const LogicalType &type, Key &key, T element) {
43
43
  key.data = Key::CreateData<T>(allocator, element);
44
44
  key.len = sizeof(element);
45
45
  }
46
46
 
47
47
  template <class T>
48
- static inline void CreateKey(ArenaAllocator &allocator, Key &key, const Value element) {
48
+ static inline void CreateKey(ArenaAllocator &allocator, const LogicalType &type, Key &key, const Value element) {
49
49
  key.data = Key::CreateData<T>(allocator, element.GetValueUnsafe<T>());
50
50
  key.len = sizeof(element);
51
51
  }
@@ -76,12 +76,9 @@ private:
76
76
  };
77
77
 
78
78
  template <>
79
- Key Key::CreateKey(ArenaAllocator &allocator, string_t value);
79
+ Key Key::CreateKey(ArenaAllocator &allocator, const LogicalType &type, string_t value);
80
80
  template <>
81
- Key Key::CreateKey(ArenaAllocator &allocator, const char *value);
81
+ Key Key::CreateKey(ArenaAllocator &allocator, const LogicalType &type, const char *value);
82
82
  template <>
83
- void Key::CreateKey(ArenaAllocator &allocator, Key &key, string_t value);
84
- template <>
85
- void Key::CreateKey(ArenaAllocator &allocator, Key &key, const char *value);
86
-
83
+ void Key::CreateKey(ArenaAllocator &allocator, const LogicalType &type, Key &key, string_t value);
87
84
  } // namespace duckdb
@@ -35,11 +35,9 @@ class BaseCSVReader {
35
35
  public:
36
36
  BaseCSVReader(ClientContext &context, BufferedCSVReaderOptions options,
37
37
  const vector<LogicalType> &requested_types = vector<LogicalType>());
38
-
39
- BaseCSVReader(FileSystem &fs, Allocator &allocator, FileOpener *opener, BufferedCSVReaderOptions options,
40
- const vector<LogicalType> &requested_types = vector<LogicalType>());
41
38
  ~BaseCSVReader();
42
39
 
40
+ ClientContext &context;
43
41
  FileSystem &fs;
44
42
  Allocator &allocator;
45
43
  FileOpener *opener;
@@ -55,8 +55,6 @@ class BufferedCSVReader : public BaseCSVReader {
55
55
  public:
56
56
  BufferedCSVReader(ClientContext &context, BufferedCSVReaderOptions options,
57
57
  const vector<LogicalType> &requested_types = vector<LogicalType>());
58
- BufferedCSVReader(FileSystem &fs, Allocator &allocator, FileOpener *opener, BufferedCSVReaderOptions options,
59
- const vector<LogicalType> &requested_types = vector<LogicalType>());
60
58
  BufferedCSVReader(ClientContext &context, string filename, BufferedCSVReaderOptions options,
61
59
  const vector<LogicalType> &requested_types = vector<LogicalType>());
62
60
  ~BufferedCSVReader();
@@ -75,6 +75,8 @@ struct BufferedCSVReaderOptions {
75
75
  case_insensitive_map_t<idx_t> sql_types_per_column;
76
76
  //! User-defined SQL type list
77
77
  vector<LogicalType> sql_type_list;
78
+ //! User-defined name list
79
+ vector<string> name_list;
78
80
  //===--------------------------------------------------------------------===//
79
81
  // ReadCSVOptions
80
82
  //===--------------------------------------------------------------------===//
@@ -0,0 +1,32 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // duckdb/execution/operator/schema/physical_detach.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb/execution/physical_operator.hpp"
12
+ #include "duckdb/parser/parsed_data/detach_info.hpp"
13
+
14
+ namespace duckdb {
15
+
16
+ class PhysicalDetach : public PhysicalOperator {
17
+ public:
18
+ explicit PhysicalDetach(unique_ptr<DetachInfo> info, idx_t estimated_cardinality)
19
+ : PhysicalOperator(PhysicalOperatorType::DETACH, {LogicalType::BOOLEAN}, estimated_cardinality),
20
+ info(std::move(info)) {
21
+ }
22
+
23
+ unique_ptr<DetachInfo> info;
24
+
25
+ public:
26
+ // Source interface
27
+ unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
28
+ void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
29
+ LocalSourceState &lstate) const override;
30
+ };
31
+
32
+ } // namespace duckdb
@@ -89,6 +89,10 @@ struct DuckDBTablesFun {
89
89
  static void RegisterFunction(BuiltinFunctions &set);
90
90
  };
91
91
 
92
+ struct DuckDBTemporaryFilesFun {
93
+ static void RegisterFunction(BuiltinFunctions &set);
94
+ };
95
+
92
96
  struct DuckDBTypesFun {
93
97
  static void RegisterFunction(BuiltinFunctions &set);
94
98
  };
@@ -11,7 +11,7 @@
11
11
  #include "duckdb/common/common.hpp"
12
12
  #include "duckdb/common/enums/output_type.hpp"
13
13
  #include "duckdb/common/types/value.hpp"
14
- #include "duckdb/common/unordered_map.hpp"
14
+ #include "duckdb/common/case_insensitive_map.hpp"
15
15
  #include "duckdb/common/atomic.hpp"
16
16
 
17
17
  namespace duckdb {
@@ -39,7 +39,7 @@ struct ClientData {
39
39
  //! The set of temporary objects that belong to this client
40
40
  shared_ptr<AttachedDatabase> temporary_objects;
41
41
  //! The set of bound prepared statements that belong to this client
42
- unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
42
+ case_insensitive_map_t<shared_ptr<PreparedStatementData>> prepared_statements;
43
43
 
44
44
  //! The writer used to log queries (if logging is enabled)
45
45
  unique_ptr<BufferedFileWriter> log_query_writer;
@@ -25,7 +25,6 @@
25
25
  #include "duckdb/storage/compression/bitpacking.hpp"
26
26
  #include "duckdb/function/cast/default_casts.hpp"
27
27
  #include "duckdb/function/replacement_scan.hpp"
28
- #include "duckdb/function/create_database_extension.hpp"
29
28
  #include "duckdb/optimizer/optimizer_extension.hpp"
30
29
  #include "duckdb/parser/parser_extension.hpp"
31
30
  #include "duckdb/planner/operator_extension.hpp"
@@ -137,6 +136,8 @@ struct DBConfigOptions {
137
136
  case_insensitive_map_t<Value> set_variables;
138
137
  //! Database configuration variable default values;
139
138
  case_insensitive_map_t<Value> set_variable_defaults;
139
+ //! Directory to store extension binaries in
140
+ string extension_directory;
140
141
  //! Whether unsigned extensions should be loaded
141
142
  bool allow_unsigned_extensions = false;
142
143
  //! Enable emitting FSST Vectors
@@ -185,8 +186,6 @@ public:
185
186
  vector<std::unique_ptr<OperatorExtension>> operator_extensions;
186
187
  //! Extensions made to storage
187
188
  case_insensitive_map_t<std::unique_ptr<StorageExtension>> storage_extensions;
188
- //! Extensions made to binder to implement the create_database functionality
189
- vector<CreateDatabaseExtension> create_database_extensions;
190
189
 
191
190
  public:
192
191
  DUCKDB_API static DBConfig &GetConfig(ClientContext &context);
@@ -1,7 +1,7 @@
1
1
  //===----------------------------------------------------------------------===//
2
2
  // DuckDB
3
3
  //
4
- // duckdb/main/extension_functions.hpp
4
+ // duckdb/main/extension_entries.hpp
5
5
  //
6
6
  //
7
7
  //===----------------------------------------------------------------------===//
@@ -12,12 +12,12 @@
12
12
 
13
13
  namespace duckdb {
14
14
 
15
- struct ExtensionFunction {
16
- char function[48];
15
+ struct ExtensionEntry {
16
+ char name[48];
17
17
  char extension[48];
18
18
  };
19
19
 
20
- static constexpr ExtensionFunction EXTENSION_FUNCTIONS[] = {
20
+ static constexpr ExtensionEntry EXTENSION_FUNCTIONS[] = {
21
21
  {"->>", "json"},
22
22
  {"array_to_json", "json"},
23
23
  {"create_fts_index", "fts"},
@@ -30,9 +30,9 @@ static constexpr ExtensionFunction EXTENSION_FUNCTIONS[] = {
30
30
  {"from_json", "json"},
31
31
  {"from_json_strict", "json"},
32
32
  {"from_substrait", "substrait"},
33
+ {"from_substrait_json", "substrait"},
33
34
  {"get_substrait", "substrait"},
34
35
  {"get_substrait_json", "substrait"},
35
- {"from_substrait_json", "substrait"},
36
36
  {"icu_calendar_names", "icu"},
37
37
  {"icu_sort_key", "icu"},
38
38
  {"json", "json"},
@@ -88,4 +88,25 @@ static constexpr ExtensionFunction EXTENSION_FUNCTIONS[] = {
88
88
  {"visualize_json_profiling_output", "visualizer"},
89
89
  {"visualize_last_profiling_output", "visualizer"},
90
90
  };
91
+
92
+ static constexpr ExtensionEntry EXTENSION_SETTINGS[] = {
93
+ {"binary_as_string", "parquet"},
94
+ {"calendar", "icu"},
95
+ {"http_retries", "httpfs"},
96
+ {"http_retry_backoff", "httpfs"},
97
+ {"http_retry_wait_ms", "httpfs"},
98
+ {"http_timeout", "httpfs"},
99
+ {"s3_access_key_id", "httpfs"},
100
+ {"s3_endpoint", "httpfs"},
101
+ {"s3_region", "httpfs"},
102
+ {"s3_secret_access_key", "httpfs"},
103
+ {"s3_session_token", "httpfs"},
104
+ {"s3_uploader_max_filesize", "httpfs"},
105
+ {"s3_uploader_max_parts_per_file", "httpfs"},
106
+ {"s3_uploader_thread_limit", "httpfs"},
107
+ {"s3_url_style", "httpfs"},
108
+ {"s3_use_ssl", "httpfs"},
109
+ {"sqlite_all_varchar", "sqlite_scanner"},
110
+ {"timezone", "icu"},
111
+ };
91
112
  } // namespace duckdb
@@ -62,6 +62,9 @@ public:
62
62
  //! Apply any known extension aliases
63
63
  static string ApplyExtensionAlias(string extension_name);
64
64
 
65
+ static string GetExtensionName(const string &extension);
66
+ static bool IsFullPath(const string &extension);
67
+
65
68
  private:
66
69
  static const vector<string> PathComponents();
67
70
  static ExtensionInitResult InitialLoad(DBConfig &context, FileOpener *opener, const string &extension);
@@ -216,6 +216,15 @@ struct ExplainOutputSetting {
216
216
  static Value GetSetting(ClientContext &context);
217
217
  };
218
218
 
219
+ struct ExtensionDirectorySetting {
220
+ static constexpr const char *Name = "extension_directory";
221
+ static constexpr const char *Description = "Set the directory to store extensions in";
222
+ static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
223
+ static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
224
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
225
+ static Value GetSetting(ClientContext &context);
226
+ };
227
+
219
228
  struct ExternalThreadsSetting {
220
229
  static constexpr const char *Name = "external_threads";
221
230
  static constexpr const char *Description = "The number of external threads that work on DuckDB tasks.";
@@ -69,13 +69,6 @@ private:
69
69
  //! The final chunk used for moving data into the sink
70
70
  DataChunk final_chunk;
71
71
 
72
- //! Indicates that the first non-finished operator in the pipeline with RequireFinalExecute has some pending result
73
- bool pending_final_execute = false;
74
- //! The OperatorFinalizeResultType corresponding to the currently pending final_execute result
75
- OperatorFinalizeResultType cached_final_execute_result;
76
- //! Source has been exhausted
77
- bool source_empty = false;
78
-
79
72
  //! The operators that are not yet finished executing and have data remaining
80
73
  //! If the stack of in_process_operators is empty, we fetch from the source instead
81
74
  stack<idx_t> in_process_operators;
@@ -16,9 +16,6 @@ struct CreateDatabaseInfo : public CreateInfo {
16
16
  CreateDatabaseInfo() : CreateInfo(CatalogType::DATABASE_ENTRY) {
17
17
  }
18
18
 
19
- //! Extension name which creates databases
20
- string extension_name;
21
-
22
19
  //! Name of the database
23
20
  string name;
24
21
 
@@ -29,7 +26,6 @@ public:
29
26
  unique_ptr<CreateInfo> Copy() const override {
30
27
  auto result = make_unique<CreateDatabaseInfo>();
31
28
  CopyProperties(*result);
32
- result->extension_name = extension_name;
33
29
  result->name = name;
34
30
  result->path = path;
35
31
  return unique_ptr<CreateInfo>(result.release());
@@ -0,0 +1,32 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // duckdb/parser/parsed_data/detach_info.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb/parser/parsed_data/parse_info.hpp"
12
+
13
+ namespace duckdb {
14
+
15
+ struct DetachInfo : public ParseInfo {
16
+ DetachInfo() {
17
+ }
18
+
19
+ //! The alias of the attached database
20
+ string name;
21
+ //! Whether to throw an exception if alias is not found
22
+ bool if_exists;
23
+
24
+ public:
25
+ unique_ptr<DetachInfo> Copy() const {
26
+ auto result = make_unique<DetachInfo>();
27
+ result->name = name;
28
+ result->if_exists = if_exists;
29
+ return result;
30
+ }
31
+ };
32
+ } // namespace duckdb
@@ -21,7 +21,7 @@ namespace duckdb {
21
21
  //! SelectNode represents a standard SELECT statement
22
22
  class SelectNode : public QueryNode {
23
23
  public:
24
- SelectNode();
24
+ DUCKDB_API SelectNode();
25
25
 
26
26
  //! The projection list
27
27
  vector<unique_ptr<ParsedExpression>> select_list;
@@ -40,11 +40,11 @@ protected:
40
40
  SQLStatement(const SQLStatement &other) = default;
41
41
 
42
42
  public:
43
- virtual string ToString() const {
43
+ DUCKDB_API virtual string ToString() const {
44
44
  throw InternalException("ToString not supported for this type of SQLStatement: '%s'",
45
45
  StatementTypeToString(type));
46
46
  }
47
47
  //! Create a copy of this SelectStatement
48
- virtual unique_ptr<SQLStatement> Copy() const = 0;
48
+ DUCKDB_API virtual unique_ptr<SQLStatement> Copy() const = 0;
49
49
  };
50
50
  } // namespace duckdb
@@ -28,7 +28,7 @@ protected:
28
28
  CopyStatement(const CopyStatement &other);
29
29
 
30
30
  public:
31
- unique_ptr<SQLStatement> Copy() const override;
31
+ DUCKDB_API unique_ptr<SQLStatement> Copy() const override;
32
32
 
33
33
  private:
34
34
  };
@@ -0,0 +1,29 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // duckdb/parser/statement/detach_statement.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb/parser/parsed_data/detach_info.hpp"
12
+ #include "duckdb/parser/sql_statement.hpp"
13
+
14
+ namespace duckdb {
15
+
16
+ class DetachStatement : public SQLStatement {
17
+ public:
18
+ DetachStatement();
19
+
20
+ unique_ptr<DetachInfo> info;
21
+
22
+ protected:
23
+ DetachStatement(const DetachStatement &other);
24
+
25
+ public:
26
+ unique_ptr<SQLStatement> Copy() const override;
27
+ };
28
+
29
+ } // namespace duckdb
@@ -4,6 +4,7 @@
4
4
  #include "duckdb/parser/statement/copy_statement.hpp"
5
5
  #include "duckdb/parser/statement/create_statement.hpp"
6
6
  #include "duckdb/parser/statement/delete_statement.hpp"
7
+ #include "duckdb/parser/statement/detach_statement.hpp"
7
8
  #include "duckdb/parser/statement/drop_statement.hpp"
8
9
  #include "duckdb/parser/statement/execute_statement.hpp"
9
10
  #include "duckdb/parser/statement/explain_statement.hpp"
@@ -21,7 +21,7 @@ class QueryNode;
21
21
  //! SelectStatement is a typical SELECT clause
22
22
  class SelectStatement : public SQLStatement {
23
23
  public:
24
- SelectStatement() : SQLStatement(StatementType::SELECT_STATEMENT) {
24
+ DUCKDB_API SelectStatement() : SQLStatement(StatementType::SELECT_STATEMENT) {
25
25
  }
26
26
 
27
27
  //! The main query node
@@ -32,9 +32,9 @@ protected:
32
32
 
33
33
  public:
34
34
  //! Convert the SELECT statement to a string
35
- string ToString() const override;
35
+ DUCKDB_API string ToString() const override;
36
36
  //! Create a copy of this SelectStatement
37
- unique_ptr<SQLStatement> Copy() const override;
37
+ DUCKDB_API unique_ptr<SQLStatement> Copy() const override;
38
38
  //! Serializes a SelectStatement to a stand-alone binary blob
39
39
  void Serialize(Serializer &serializer) const;
40
40
  //! Deserializes a blob back into a SelectStatement, returns nullptr if
@@ -15,7 +15,7 @@ namespace duckdb {
15
15
  //! Represents a subquery
16
16
  class SubqueryRef : public TableRef {
17
17
  public:
18
- explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
18
+ DUCKDB_API explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
19
19
 
20
20
  //! The subquery
21
21
  unique_ptr<SelectStatement> subquery;
@@ -20,6 +20,7 @@ class AttachStatement;
20
20
  class CallStatement;
21
21
  class CopyStatement;
22
22
  class CreateStatement;
23
+ class DetachStatement;
23
24
  class DeleteStatement;
24
25
  class DropStatement;
25
26
  class ExtensionStatement;
@@ -156,6 +156,7 @@ private:
156
156
  unique_ptr<SQLStatement> TransformShow(duckdb_libpgquery::PGNode *node);
157
157
  unique_ptr<ShowStatement> TransformShowSelect(duckdb_libpgquery::PGNode *node);
158
158
  unique_ptr<AttachStatement> TransformAttach(duckdb_libpgquery::PGNode *node);
159
+ unique_ptr<DetachStatement> TransformDetach(duckdb_libpgquery::PGNode *node);
159
160
  unique_ptr<SetStatement> TransformUse(duckdb_libpgquery::PGNode *node);
160
161
 
161
162
  unique_ptr<PrepareStatement> TransformPrepare(duckdb_libpgquery::PGNode *node);
@@ -108,6 +108,9 @@ public:
108
108
 
109
109
  unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info);
110
110
  unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info, SchemaCatalogEntry *schema);
111
+
112
+ vector<unique_ptr<Expression>> BindCreateIndexExpressions(TableCatalogEntry *table, CreateIndexInfo *info);
113
+
111
114
  void BindCreateViewInfo(CreateViewInfo &base);
112
115
  SchemaCatalogEntry *BindSchema(CreateInfo &info);
113
116
  SchemaCatalogEntry *BindCreateFunctionInfo(CreateInfo &info);
@@ -247,6 +250,7 @@ private:
247
250
  BoundStatement Bind(LoadStatement &stmt);
248
251
  BoundStatement Bind(LogicalPlanStatement &stmt);
249
252
  BoundStatement Bind(AttachStatement &stmt);
253
+ BoundStatement Bind(DetachStatement &stmt);
250
254
 
251
255
  BoundStatement BindReturning(vector<unique_ptr<ParsedExpression>> returning_list, TableCatalogEntry *table,
252
256
  idx_t update_table_index, unique_ptr<LogicalOperator> child_operator,
@@ -10,20 +10,27 @@
10
10
 
11
11
  #include "duckdb/planner/expression_binder.hpp"
12
12
  #include "duckdb/common/unordered_map.hpp"
13
+ #include "duckdb/parser/parsed_data/create_index_info.hpp"
14
+ #include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
13
15
 
14
16
  namespace duckdb {
15
17
  class BoundColumnRefExpression;
16
18
 
17
- //! The INDEX binder is responsible for binding an expression within an Index statement
19
+ //! The IndexBinder is responsible for binding an expression within an index statement
18
20
  class IndexBinder : public ExpressionBinder {
19
21
  public:
20
- IndexBinder(Binder &binder, ClientContext &context);
22
+ IndexBinder(Binder &binder, ClientContext &context, TableCatalogEntry *table = nullptr,
23
+ CreateIndexInfo *info = nullptr);
21
24
 
22
25
  protected:
23
26
  BindResult BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth,
24
27
  bool root_expression = false) override;
25
-
26
28
  string UnsupportedAggregateMessage() override;
29
+
30
+ private:
31
+ // only for WAL replay
32
+ TableCatalogEntry *table;
33
+ CreateIndexInfo *info;
27
34
  };
28
35
 
29
36
  } // namespace duckdb