duckdb 0.7.2-dev2507.0 → 0.7.2-dev2675.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.
- package/binding.gyp +7 -7
- package/package.json +2 -2
- package/src/connection.cpp +1 -1
- package/src/duckdb/extension/icu/icu-dateadd.cpp +3 -3
- package/src/duckdb/extension/icu/icu-datepart.cpp +3 -3
- package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +3 -3
- package/src/duckdb/extension/icu/icu-list-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
- package/src/duckdb/extension/icu/icu-strptime.cpp +4 -4
- package/src/duckdb/extension/icu/icu-table-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-timebucket.cpp +1 -1
- package/src/duckdb/extension/icu/icu-timezone.cpp +4 -4
- package/src/duckdb/extension/json/json-extension.cpp +6 -6
- package/src/duckdb/extension/parquet/parquet-extension.cpp +9 -8
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +3 -0
- package/src/duckdb/src/catalog/catalog.cpp +166 -127
- package/src/duckdb/src/catalog/catalog_entry/copy_function_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +90 -82
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +65 -67
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/pragma_function_catalog_entry.cpp +4 -4
- package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +8 -8
- package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +10 -10
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +4 -4
- package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +9 -9
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +5 -5
- package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +23 -23
- package/src/duckdb/src/catalog/catalog_entry.cpp +27 -6
- package/src/duckdb/src/catalog/catalog_search_path.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +84 -87
- package/src/duckdb/src/catalog/catalog_transaction.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_functions.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_schemas.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_types.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
- package/src/duckdb/src/catalog/dependency_list.cpp +2 -2
- package/src/duckdb/src/catalog/dependency_manager.cpp +9 -10
- package/src/duckdb/src/catalog/duck_catalog.cpp +30 -26
- package/src/duckdb/src/catalog/similar_catalog_entry.cpp +1 -1
- package/src/duckdb/src/common/radix_partitioning.cpp +1 -1
- package/src/duckdb/src/common/types.cpp +15 -27
- package/src/duckdb/src/execution/index/art/art.cpp +286 -269
- package/src/duckdb/src/execution/index/art/art_key.cpp +22 -32
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +224 -0
- package/src/duckdb/src/execution/index/art/iterator.cpp +142 -123
- package/src/duckdb/src/execution/index/art/leaf.cpp +319 -170
- package/src/duckdb/src/execution/index/art/leaf_segment.cpp +42 -0
- package/src/duckdb/src/execution/index/art/node.cpp +444 -379
- package/src/duckdb/src/execution/index/art/node16.cpp +178 -114
- package/src/duckdb/src/execution/index/art/node256.cpp +117 -79
- package/src/duckdb/src/execution/index/art/node4.cpp +169 -114
- package/src/duckdb/src/execution/index/art/node48.cpp +175 -105
- package/src/duckdb/src/execution/index/art/prefix.cpp +405 -127
- package/src/duckdb/src/execution/index/art/prefix_segment.cpp +42 -0
- package/src/duckdb/src/execution/index/art/swizzleable_pointer.cpp +10 -85
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +4 -3
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +2 -0
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +4 -3
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +19 -18
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +5 -5
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +17 -17
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +4 -3
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +4 -3
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
- package/src/duckdb/src/function/built_in_functions.cpp +10 -10
- package/src/duckdb/src/function/function_binder.cpp +3 -3
- package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +5 -6
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +2 -2
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +9 -8
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +6 -6
- package/src/duckdb/src/function/table/arrow.cpp +5 -5
- package/src/duckdb/src/function/table/read_csv.cpp +5 -1
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +8 -7
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +14 -14
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +26 -25
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +13 -12
- package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +7 -7
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +8 -9
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +10 -9
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +13 -13
- package/src/duckdb/src/function/table/system/duckdb_views.cpp +11 -10
- package/src/duckdb/src/function/table/system/pragma_collations.cpp +2 -2
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +5 -5
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +3 -3
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +2 -2
- package/src/duckdb/src/function/table/table_scan.cpp +39 -37
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/function/udf_function.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +122 -81
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +2 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +24 -20
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +22 -17
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +28 -7
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +20 -19
- package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +9 -9
- package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +2 -1
- package/src/duckdb/src/include/duckdb/catalog/standard_entry.hpp +10 -4
- package/src/duckdb/src/include/duckdb/common/enums/on_entry_not_found.hpp +17 -0
- package/src/duckdb/src/include/duckdb/common/queue.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types.hpp +3 -4
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +53 -45
- package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +29 -24
- package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +114 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +26 -20
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +63 -39
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +36 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +98 -116
- package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +48 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +52 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +46 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +57 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +57 -50
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix_segment.hpp +40 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/swizzleable_pointer.hpp +38 -31
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -4
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -2
- package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +5 -4
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +28 -15
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/keyword_helper.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +7 -5
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +5 -5
- package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +13 -0
- package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +5 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +4 -1
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +4 -7
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +0 -5
- package/src/duckdb/src/include/duckdb/storage/index.hpp +13 -28
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +0 -2
- package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +5 -0
- package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +12 -0
- package/src/duckdb/src/include/duckdb.h +26 -0
- package/src/duckdb/src/main/attached_database.cpp +12 -6
- package/src/duckdb/src/main/capi/helper-c.cpp +7 -0
- package/src/duckdb/src/main/capi/table_function-c.cpp +17 -16
- package/src/duckdb/src/main/client_context.cpp +12 -11
- package/src/duckdb/src/main/database_manager.cpp +13 -12
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -2
- package/src/duckdb/src/parser/parsed_data/alter_info.cpp +3 -3
- package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +9 -9
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +2 -2
- package/src/duckdb/src/parser/statement/insert_statement.cpp +15 -6
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +18 -5
- package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +3 -2
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +5 -1
- package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +5 -7
- package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +26 -27
- package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +17 -17
- package/src/duckdb/src/planner/binder/expression/bind_case_expression.cpp +9 -9
- package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +21 -21
- package/src/duckdb/src/planner/binder/expression/bind_conjunction_expression.cpp +2 -3
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +33 -36
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +5 -5
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +23 -23
- package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +4 -4
- package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +7 -7
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +23 -23
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +14 -13
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +56 -42
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +3 -3
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +10 -10
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +16 -11
- package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +5 -4
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +3 -3
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +10 -12
- package/src/duckdb/src/planner/binder.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_expression.cpp +11 -2
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +2 -5
- package/src/duckdb/src/planner/operator/logical_create.cpp +2 -1
- package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_get.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_insert.cpp +2 -7
- package/src/duckdb/src/planner/operator/logical_update.cpp +2 -6
- package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +2 -2
- package/src/duckdb/src/planner/pragma_handler.cpp +3 -4
- package/src/duckdb/src/storage/checkpoint_manager.cpp +57 -55
- package/src/duckdb/src/storage/data_table.cpp +9 -9
- package/src/duckdb/src/storage/index.cpp +18 -6
- package/src/duckdb/src/storage/local_storage.cpp +8 -2
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +0 -9
- package/src/duckdb/src/storage/table/update_segment.cpp +1 -1
- package/src/duckdb/src/storage/wal_replay.cpp +29 -31
- package/src/duckdb/src/storage/write_ahead_log.cpp +8 -8
- package/src/duckdb/src/transaction/cleanup_state.cpp +7 -1
- package/src/duckdb/src/transaction/commit_state.cpp +3 -4
- package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
- package/src/duckdb/src/transaction/undo_buffer.cpp +8 -0
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
- package/src/duckdb/ub_src_execution_index_art.cpp +7 -1
@@ -58,15 +58,10 @@ public:
|
|
58
58
|
//! Construct a managed buffer.
|
59
59
|
virtual unique_ptr<FileBuffer> ConstructManagedBuffer(idx_t size, unique_ptr<FileBuffer> &&source,
|
60
60
|
FileBufferType type = FileBufferType::MANAGED_BUFFER);
|
61
|
-
//! Increases the currently allocated memory, but the actual allocation does not go through the buffer manager
|
62
|
-
virtual void IncreaseUsedMemory(idx_t size, bool unsafe = false) = 0;
|
63
|
-
//! Decrease the currently allocated memory, but the actual deallocation does not go through the buffer manager
|
64
|
-
virtual void DecreaseUsedMemory(idx_t size) = 0;
|
65
61
|
//! Get the underlying buffer pool responsible for managing the buffers
|
66
62
|
virtual BufferPool &GetBufferPool();
|
67
63
|
|
68
64
|
// Static methods
|
69
|
-
|
70
65
|
DUCKDB_API static BufferManager &GetBufferManager(DatabaseInstance &db);
|
71
66
|
DUCKDB_API static BufferManager &GetBufferManager(ClientContext &context);
|
72
67
|
DUCKDB_API static BufferManager &GetBufferManager(AttachedDatabase &db);
|
@@ -32,8 +32,7 @@ struct IndexScanState;
|
|
32
32
|
class Index {
|
33
33
|
public:
|
34
34
|
Index(AttachedDatabase &db, IndexType type, TableIOManager &table_io_manager, const vector<column_t> &column_ids,
|
35
|
-
const vector<unique_ptr<Expression>> &unbound_expressions, IndexConstraintType constraint_type
|
36
|
-
bool track_memory);
|
35
|
+
const vector<unique_ptr<Expression>> &unbound_expressions, IndexConstraintType constraint_type);
|
37
36
|
virtual ~Index() = default;
|
38
37
|
|
39
38
|
//! The type of the index
|
@@ -57,25 +56,21 @@ public:
|
|
57
56
|
AttachedDatabase &db;
|
58
57
|
//! Buffer manager of the database instance
|
59
58
|
BufferManager &buffer_manager;
|
60
|
-
//! The size of the index in memory
|
61
|
-
//! This does not track the size of the index meta information, but only allocated nodes and leaves
|
62
|
-
idx_t memory_size;
|
63
|
-
//! Flag determining if this index's size is tracked by the buffer manager
|
64
|
-
bool track_memory;
|
65
59
|
|
66
60
|
public:
|
67
61
|
//! Initialize a single predicate scan on the index with the given expression and column IDs
|
68
62
|
virtual unique_ptr<IndexScanState> InitializeScanSinglePredicate(const Transaction &transaction, const Value &value,
|
69
|
-
ExpressionType
|
63
|
+
const ExpressionType expression_type) = 0;
|
70
64
|
//! Initialize a two predicate scan on the index with the given expression and column IDs
|
71
|
-
virtual unique_ptr<IndexScanState> InitializeScanTwoPredicates(Transaction &transaction,
|
72
|
-
|
65
|
+
virtual unique_ptr<IndexScanState> InitializeScanTwoPredicates(const Transaction &transaction,
|
66
|
+
const Value &low_value,
|
67
|
+
const ExpressionType low_expression_type,
|
73
68
|
const Value &high_value,
|
74
|
-
ExpressionType high_expression_type) = 0;
|
69
|
+
const ExpressionType high_expression_type) = 0;
|
75
70
|
//! Performs a lookup on the index, fetching up to max_count result IDs. Returns true if all row IDs were fetched,
|
76
71
|
//! and false otherwise
|
77
|
-
virtual bool Scan(Transaction &transaction, DataTable &table, IndexScanState &state,
|
78
|
-
vector<row_t> &result_ids) = 0;
|
72
|
+
virtual bool Scan(const Transaction &transaction, const DataTable &table, IndexScanState &state,
|
73
|
+
const idx_t max_count, vector<row_t> &result_ids) = 0;
|
79
74
|
|
80
75
|
//! Obtain a lock on the index
|
81
76
|
virtual void InitializeLock(IndexLock &state);
|
@@ -104,23 +99,13 @@ public:
|
|
104
99
|
//! Obtains a lock and calls MergeIndexes while holding that lock
|
105
100
|
bool MergeIndexes(Index &other_index);
|
106
101
|
|
102
|
+
//! Traverses an ART and vacuums the qualifying nodes. The lock obtained from InitializeLock must be held
|
103
|
+
virtual void Vacuum(IndexLock &state) = 0;
|
104
|
+
//! Obtains a lock and calls Vacuum while holding that lock
|
105
|
+
void Vacuum();
|
106
|
+
|
107
107
|
//! Returns the string representation of an index
|
108
108
|
virtual string ToString() = 0;
|
109
|
-
//! Verifies that the in-memory size value of the index matches its actual size
|
110
|
-
virtual void Verify() = 0;
|
111
|
-
//! Increases the memory size by the difference between the old size and the current size
|
112
|
-
//! and performs verifications
|
113
|
-
virtual void IncreaseAndVerifyMemorySize(idx_t old_memory_size) = 0;
|
114
|
-
|
115
|
-
//! Increases the in-memory size value
|
116
|
-
inline void IncreaseMemorySize(idx_t size) {
|
117
|
-
memory_size += size;
|
118
|
-
};
|
119
|
-
//! Decreases the in-memory size value
|
120
|
-
inline void DecreaseMemorySize(idx_t size) {
|
121
|
-
D_ASSERT(memory_size >= size);
|
122
|
-
memory_size -= size;
|
123
|
-
};
|
124
109
|
|
125
110
|
//! Returns true if the index is affected by updates on the specified column IDs, and false otherwise
|
126
111
|
bool IndexIsUpdated(const vector<PhysicalIndex> &column_ids) const;
|
@@ -45,8 +45,6 @@ public:
|
|
45
45
|
shared_ptr<BlockHandle> RegisterSmallMemory(idx_t block_size) final override;
|
46
46
|
|
47
47
|
idx_t GetUsedMemory() const final override;
|
48
|
-
void IncreaseUsedMemory(idx_t amount, bool unsafe = false) final override;
|
49
|
-
void DecreaseUsedMemory(idx_t amount) final override;
|
50
48
|
idx_t GetMaxMemory() const final override;
|
51
49
|
|
52
50
|
//! Allocate an in-memory buffer with a single pin.
|
@@ -10,8 +10,10 @@
|
|
10
10
|
|
11
11
|
#include "duckdb/transaction/undo_buffer.hpp"
|
12
12
|
#include "duckdb/common/types/data_chunk.hpp"
|
13
|
+
#include "duckdb/common/unordered_map.hpp"
|
13
14
|
|
14
15
|
namespace duckdb {
|
16
|
+
|
15
17
|
class DataTable;
|
16
18
|
|
17
19
|
struct DeleteInfo;
|
@@ -22,6 +24,9 @@ public:
|
|
22
24
|
CleanupState();
|
23
25
|
~CleanupState();
|
24
26
|
|
27
|
+
// all tables with indexes that possibly need a vacuum (after e.g. a delete)
|
28
|
+
unordered_map<string, optional_ptr<DataTable>> indexed_tables;
|
29
|
+
|
25
30
|
public:
|
26
31
|
void CleanupEntry(UndoFlags type, data_ptr_t data);
|
27
32
|
|
@@ -57,6 +57,18 @@ public:
|
|
57
57
|
virtual bool IsDuckTransaction() const {
|
58
58
|
return false;
|
59
59
|
}
|
60
|
+
|
61
|
+
public:
|
62
|
+
template <class TARGET>
|
63
|
+
TARGET &Cast() {
|
64
|
+
D_ASSERT(dynamic_cast<TARGET *>(this));
|
65
|
+
return (TARGET &)*this;
|
66
|
+
}
|
67
|
+
template <class TARGET>
|
68
|
+
const TARGET &Cast() const {
|
69
|
+
D_ASSERT(dynamic_cast<const TARGET *>(this));
|
70
|
+
return (const TARGET &)*this;
|
71
|
+
}
|
60
72
|
};
|
61
73
|
|
62
74
|
} // namespace duckdb
|
@@ -190,6 +190,23 @@ typedef struct {
|
|
190
190
|
idx_t size;
|
191
191
|
} duckdb_string;
|
192
192
|
|
193
|
+
/*
|
194
|
+
The internal data representation of a VARCHAR/BLOB column
|
195
|
+
*/
|
196
|
+
typedef struct {
|
197
|
+
union {
|
198
|
+
struct {
|
199
|
+
uint32_t length;
|
200
|
+
char prefix[4];
|
201
|
+
char *ptr;
|
202
|
+
} pointer;
|
203
|
+
struct {
|
204
|
+
uint32_t length;
|
205
|
+
char inlined[12];
|
206
|
+
} inlined;
|
207
|
+
} value;
|
208
|
+
} duckdb_string_t;
|
209
|
+
|
193
210
|
typedef struct {
|
194
211
|
void *data;
|
195
212
|
idx_t size;
|
@@ -298,6 +315,7 @@ typedef enum {
|
|
298
315
|
/*!
|
299
316
|
Creates a new database or opens an existing database file stored at the the given path.
|
300
317
|
If no path is given a new in-memory database is created instead.
|
318
|
+
The instantiated database should be closed with 'duckdb_close'
|
301
319
|
|
302
320
|
* path: Path to the database file on disk, or `nullptr` or `:memory:` to open an in-memory database.
|
303
321
|
* out_database: The result database object.
|
@@ -331,6 +349,7 @@ DUCKDB_API void duckdb_close(duckdb_database *database);
|
|
331
349
|
/*!
|
332
350
|
Opens a connection to a database. Connections are required to query the database, and store transactional state
|
333
351
|
associated with the connection.
|
352
|
+
The instantiated connection should be closed using 'duckdb_disconnect'
|
334
353
|
|
335
354
|
* database: The database file to connect to.
|
336
355
|
* out_connection: The result connection object.
|
@@ -751,6 +770,13 @@ This is the amount of tuples that will fit into a data chunk created by `duckdb_
|
|
751
770
|
*/
|
752
771
|
DUCKDB_API idx_t duckdb_vector_size();
|
753
772
|
|
773
|
+
/*!
|
774
|
+
Whether or not the duckdb_string_t value is inlined.
|
775
|
+
This means that the data of the string does not have a separate allocation.
|
776
|
+
|
777
|
+
*/
|
778
|
+
DUCKDB_API bool duckdb_string_is_inlined(duckdb_string_t string);
|
779
|
+
|
754
780
|
//===--------------------------------------------------------------------===//
|
755
781
|
// Date/Time/Timestamp Helpers
|
756
782
|
//===--------------------------------------------------------------------===//
|
@@ -8,8 +8,8 @@
|
|
8
8
|
namespace duckdb {
|
9
9
|
|
10
10
|
AttachedDatabase::AttachedDatabase(DatabaseInstance &db, AttachedDatabaseType type)
|
11
|
-
: CatalogEntry(CatalogType::DATABASE_ENTRY,
|
12
|
-
type == AttachedDatabaseType::SYSTEM_DATABASE ? SYSTEM_CATALOG : TEMP_CATALOG),
|
11
|
+
: CatalogEntry(CatalogType::DATABASE_ENTRY,
|
12
|
+
type == AttachedDatabaseType::SYSTEM_DATABASE ? SYSTEM_CATALOG : TEMP_CATALOG, 0),
|
13
13
|
db(db), type(type) {
|
14
14
|
D_ASSERT(type == AttachedDatabaseType::TEMP_DATABASE || type == AttachedDatabaseType::SYSTEM_DATABASE);
|
15
15
|
if (type == AttachedDatabaseType::TEMP_DATABASE) {
|
@@ -22,9 +22,10 @@ AttachedDatabase::AttachedDatabase(DatabaseInstance &db, AttachedDatabaseType ty
|
|
22
22
|
|
23
23
|
AttachedDatabase::AttachedDatabase(DatabaseInstance &db, Catalog &catalog_p, string name_p, string file_path_p,
|
24
24
|
AccessMode access_mode)
|
25
|
-
: CatalogEntry(CatalogType::DATABASE_ENTRY,
|
25
|
+
: CatalogEntry(CatalogType::DATABASE_ENTRY, catalog_p, std::move(name_p)), db(db),
|
26
26
|
type(access_mode == AccessMode::READ_ONLY ? AttachedDatabaseType::READ_ONLY_DATABASE
|
27
|
-
: AttachedDatabaseType::READ_WRITE_DATABASE)
|
27
|
+
: AttachedDatabaseType::READ_WRITE_DATABASE),
|
28
|
+
parent_catalog(&catalog_p) {
|
28
29
|
storage = make_uniq<SingleFileStorageManager>(*this, std::move(file_path_p), access_mode == AccessMode::READ_ONLY);
|
29
30
|
catalog = make_uniq<DuckCatalog>(*this);
|
30
31
|
transaction_manager = make_uniq<DuckTransactionManager>(*this);
|
@@ -33,9 +34,10 @@ AttachedDatabase::AttachedDatabase(DatabaseInstance &db, Catalog &catalog_p, str
|
|
33
34
|
|
34
35
|
AttachedDatabase::AttachedDatabase(DatabaseInstance &db, Catalog &catalog_p, StorageExtension &storage_extension,
|
35
36
|
string name_p, AttachInfo &info, AccessMode access_mode)
|
36
|
-
: CatalogEntry(CatalogType::DATABASE_ENTRY,
|
37
|
+
: CatalogEntry(CatalogType::DATABASE_ENTRY, catalog_p, std::move(name_p)), db(db),
|
37
38
|
type(access_mode == AccessMode::READ_ONLY ? AttachedDatabaseType::READ_ONLY_DATABASE
|
38
|
-
: AttachedDatabaseType::READ_WRITE_DATABASE)
|
39
|
+
: AttachedDatabaseType::READ_WRITE_DATABASE),
|
40
|
+
parent_catalog(&catalog_p) {
|
39
41
|
catalog = storage_extension.attach(storage_extension.storage_info.get(), *this, name, info, access_mode);
|
40
42
|
if (!catalog) {
|
41
43
|
throw InternalException("AttachedDatabase - attach function did not return a catalog");
|
@@ -116,4 +118,8 @@ TransactionManager &AttachedDatabase::GetTransactionManager() {
|
|
116
118
|
return *transaction_manager;
|
117
119
|
}
|
118
120
|
|
121
|
+
Catalog &AttachedDatabase::ParentCatalog() {
|
122
|
+
return *parent_catalog;
|
123
|
+
}
|
124
|
+
|
119
125
|
} // namespace duckdb
|
@@ -186,3 +186,10 @@ void duckdb_free(void *ptr) {
|
|
186
186
|
idx_t duckdb_vector_size() {
|
187
187
|
return STANDARD_VECTOR_SIZE;
|
188
188
|
}
|
189
|
+
|
190
|
+
bool duckdb_string_is_inlined(duckdb_string_t string_p) {
|
191
|
+
static_assert(sizeof(duckdb_string_t) == sizeof(duckdb::string_t),
|
192
|
+
"duckdb_string_t should have the same memory layout as duckdb::string_t");
|
193
|
+
auto &string = *(duckdb::string_t *)(&string_p);
|
194
|
+
return string.IsInlined();
|
195
|
+
}
|
@@ -25,6 +25,8 @@ struct CTableFunctionInfo : public TableFunctionInfo {
|
|
25
25
|
};
|
26
26
|
|
27
27
|
struct CTableBindData : public TableFunctionData {
|
28
|
+
CTableBindData(CTableFunctionInfo &info) : info(info) {
|
29
|
+
}
|
28
30
|
~CTableBindData() {
|
29
31
|
if (bind_data && delete_callback) {
|
30
32
|
delete_callback(bind_data);
|
@@ -33,7 +35,7 @@ struct CTableBindData : public TableFunctionData {
|
|
33
35
|
delete_callback = nullptr;
|
34
36
|
}
|
35
37
|
|
36
|
-
CTableFunctionInfo
|
38
|
+
CTableFunctionInfo &info;
|
37
39
|
void *bind_data = nullptr;
|
38
40
|
duckdb_delete_callback_t delete_callback = nullptr;
|
39
41
|
unique_ptr<NodeStatistics> stats;
|
@@ -84,14 +86,14 @@ struct CTableLocalInitData : public LocalTableFunctionState {
|
|
84
86
|
|
85
87
|
struct CTableInternalInitInfo {
|
86
88
|
CTableInternalInitInfo(const CTableBindData &bind_data, CTableInitData &init_data,
|
87
|
-
const vector<column_t> &column_ids, TableFilterSet
|
89
|
+
const vector<column_t> &column_ids, optional_ptr<TableFilterSet> filters)
|
88
90
|
: bind_data(bind_data), init_data(init_data), column_ids(column_ids), filters(filters), success(true) {
|
89
91
|
}
|
90
92
|
|
91
93
|
const CTableBindData &bind_data;
|
92
94
|
CTableInitData &init_data;
|
93
95
|
const vector<column_t> &column_ids;
|
94
|
-
TableFilterSet
|
96
|
+
optional_ptr<TableFilterSet> filters;
|
95
97
|
bool success;
|
96
98
|
string error;
|
97
99
|
};
|
@@ -110,16 +112,15 @@ struct CTableInternalFunctionInfo {
|
|
110
112
|
|
111
113
|
unique_ptr<FunctionData> CTableFunctionBind(ClientContext &context, TableFunctionBindInput &input,
|
112
114
|
vector<LogicalType> &return_types, vector<string> &names) {
|
113
|
-
auto info =
|
114
|
-
D_ASSERT(info
|
115
|
-
auto result = make_uniq<CTableBindData>();
|
116
|
-
CTableInternalBindInfo bind_info(context, input, return_types, names, *result,
|
117
|
-
info
|
115
|
+
auto &info = input.info->Cast<CTableFunctionInfo>();
|
116
|
+
D_ASSERT(info.bind && info.function && info.init);
|
117
|
+
auto result = make_uniq<CTableBindData>(info);
|
118
|
+
CTableInternalBindInfo bind_info(context, input, return_types, names, *result, info);
|
119
|
+
info.bind(&bind_info);
|
118
120
|
if (!bind_info.success) {
|
119
121
|
throw Exception(bind_info.error);
|
120
122
|
}
|
121
123
|
|
122
|
-
result->info = info;
|
123
124
|
return std::move(result);
|
124
125
|
}
|
125
126
|
|
@@ -128,7 +129,7 @@ unique_ptr<GlobalTableFunctionState> CTableFunctionInit(ClientContext &context,
|
|
128
129
|
auto result = make_uniq<CTableGlobalInitData>();
|
129
130
|
|
130
131
|
CTableInternalInitInfo init_info(bind_data, result->init_data, data_p.column_ids, data_p.filters);
|
131
|
-
bind_data.info
|
132
|
+
bind_data.info.init(&init_info);
|
132
133
|
if (!init_info.success) {
|
133
134
|
throw Exception(init_info.error);
|
134
135
|
}
|
@@ -139,12 +140,12 @@ unique_ptr<LocalTableFunctionState> CTableFunctionLocalInit(ExecutionContext &co
|
|
139
140
|
GlobalTableFunctionState *gstate) {
|
140
141
|
auto &bind_data = data_p.bind_data->Cast<CTableBindData>();
|
141
142
|
auto result = make_uniq<CTableLocalInitData>();
|
142
|
-
if (!bind_data.info
|
143
|
+
if (!bind_data.info.local_init) {
|
143
144
|
return std::move(result);
|
144
145
|
}
|
145
146
|
|
146
147
|
CTableInternalInitInfo init_info(bind_data, result->init_data, data_p.column_ids, data_p.filters);
|
147
|
-
bind_data.info
|
148
|
+
bind_data.info.local_init(&init_info);
|
148
149
|
if (!init_info.success) {
|
149
150
|
throw Exception(init_info.error);
|
150
151
|
}
|
@@ -164,7 +165,7 @@ void CTableFunction(ClientContext &context, TableFunctionInput &data_p, DataChun
|
|
164
165
|
auto &global_data = (CTableGlobalInitData &)*data_p.global_state;
|
165
166
|
auto &local_data = (CTableLocalInitData &)*data_p.local_state;
|
166
167
|
CTableInternalFunctionInfo function_info(bind_data, global_data.init_data, local_data.init_data);
|
167
|
-
bind_data.info
|
168
|
+
bind_data.info.function(&function_info, reinterpret_cast<duckdb_data_chunk>(&output));
|
168
169
|
if (!function_info.success) {
|
169
170
|
throw Exception(function_info.error);
|
170
171
|
}
|
@@ -288,7 +289,7 @@ duckdb_state duckdb_register_table_function(duckdb_connection connection, duckdb
|
|
288
289
|
duckdb::CreateTableFunctionInfo tf_info(*tf);
|
289
290
|
|
290
291
|
// create the function in the catalog
|
291
|
-
catalog.CreateTableFunction(*con->context,
|
292
|
+
catalog.CreateTableFunction(*con->context, tf_info);
|
292
293
|
});
|
293
294
|
return DuckDBSuccess;
|
294
295
|
}
|
@@ -380,7 +381,7 @@ void *duckdb_init_get_extra_info(duckdb_init_info info) {
|
|
380
381
|
return nullptr;
|
381
382
|
}
|
382
383
|
auto init_info = (duckdb::CTableInternalInitInfo *)info;
|
383
|
-
return init_info->bind_data.info
|
384
|
+
return init_info->bind_data.info.extra_info;
|
384
385
|
}
|
385
386
|
|
386
387
|
void *duckdb_init_get_bind_data(duckdb_init_info info) {
|
@@ -444,7 +445,7 @@ void *duckdb_function_get_extra_info(duckdb_function_info info) {
|
|
444
445
|
return nullptr;
|
445
446
|
}
|
446
447
|
auto function_info = (duckdb::CTableInternalFunctionInfo *)info;
|
447
|
-
return function_info->bind_data.info
|
448
|
+
return function_info->bind_data.info.extra_info;
|
448
449
|
}
|
449
450
|
|
450
451
|
void *duckdb_function_get_bind_data(duckdb_function_info info) {
|
@@ -916,15 +916,15 @@ void ClientContext::DisableProfiling() {
|
|
916
916
|
config.enable_profiler = false;
|
917
917
|
}
|
918
918
|
|
919
|
-
void ClientContext::RegisterFunction(CreateFunctionInfo
|
919
|
+
void ClientContext::RegisterFunction(CreateFunctionInfo &info) {
|
920
920
|
RunFunctionInTransaction([&]() {
|
921
|
-
auto existing_function =
|
922
|
-
|
921
|
+
auto existing_function = Catalog::GetEntry<ScalarFunctionCatalogEntry>(*this, INVALID_CATALOG, info.schema,
|
922
|
+
info.name, OnEntryNotFound::RETURN_NULL);
|
923
923
|
if (existing_function) {
|
924
|
-
auto new_info = (CreateScalarFunctionInfo
|
925
|
-
if (new_info
|
924
|
+
auto &new_info = (CreateScalarFunctionInfo &)info;
|
925
|
+
if (new_info.functions.MergeFunctionSet(existing_function->functions)) {
|
926
926
|
// function info was updated from catalog entry, rewrite is needed
|
927
|
-
info
|
927
|
+
info.on_conflict = OnCreateConflict::REPLACE_ON_CONFLICT;
|
928
928
|
}
|
929
929
|
}
|
930
930
|
// create function
|
@@ -978,7 +978,8 @@ unique_ptr<TableDescription> ClientContext::TableInfo(const string &schema_name,
|
|
978
978
|
unique_ptr<TableDescription> result;
|
979
979
|
RunFunctionInTransaction([&]() {
|
980
980
|
// obtain the table info
|
981
|
-
auto table = Catalog::GetEntry<TableCatalogEntry>(*this, INVALID_CATALOG, schema_name, table_name,
|
981
|
+
auto table = Catalog::GetEntry<TableCatalogEntry>(*this, INVALID_CATALOG, schema_name, table_name,
|
982
|
+
OnEntryNotFound::RETURN_NULL);
|
982
983
|
if (!table) {
|
983
984
|
return;
|
984
985
|
}
|
@@ -995,18 +996,18 @@ unique_ptr<TableDescription> ClientContext::TableInfo(const string &schema_name,
|
|
995
996
|
|
996
997
|
void ClientContext::Append(TableDescription &description, ColumnDataCollection &collection) {
|
997
998
|
RunFunctionInTransaction([&]() {
|
998
|
-
auto table_entry =
|
999
|
+
auto &table_entry =
|
999
1000
|
Catalog::GetEntry<TableCatalogEntry>(*this, INVALID_CATALOG, description.schema, description.table);
|
1000
1001
|
// verify that the table columns and types match up
|
1001
|
-
if (description.columns.size() != table_entry
|
1002
|
+
if (description.columns.size() != table_entry.GetColumns().PhysicalColumnCount()) {
|
1002
1003
|
throw Exception("Failed to append: table entry has different number of columns!");
|
1003
1004
|
}
|
1004
1005
|
for (idx_t i = 0; i < description.columns.size(); i++) {
|
1005
|
-
if (description.columns[i].Type() != table_entry
|
1006
|
+
if (description.columns[i].Type() != table_entry.GetColumns().GetColumn(PhysicalIndex(i)).Type()) {
|
1006
1007
|
throw Exception("Failed to append: table entry has different number of columns!");
|
1007
1008
|
}
|
1008
1009
|
}
|
1009
|
-
table_entry
|
1010
|
+
table_entry.GetStorage().LocalAppend(table_entry, *this, collection);
|
1010
1011
|
});
|
1011
1012
|
}
|
1012
1013
|
|
@@ -27,7 +27,7 @@ optional_ptr<AttachedDatabase> DatabaseManager::GetDatabase(ClientContext &conte
|
|
27
27
|
if (StringUtil::Lower(name) == TEMP_CATALOG) {
|
28
28
|
return context.client_data->temporary_objects.get();
|
29
29
|
}
|
30
|
-
return (AttachedDatabase *)databases->GetEntry(context, name);
|
30
|
+
return (AttachedDatabase *)databases->GetEntry(context, name).get();
|
31
31
|
}
|
32
32
|
|
33
33
|
void DatabaseManager::AddDatabase(ClientContext &context, unique_ptr<AttachedDatabase> db_instance) {
|
@@ -42,9 +42,9 @@ void DatabaseManager::AddDatabase(ClientContext &context, unique_ptr<AttachedDat
|
|
42
42
|
}
|
43
43
|
}
|
44
44
|
|
45
|
-
void DatabaseManager::DetachDatabase(ClientContext &context, const string &name,
|
45
|
+
void DatabaseManager::DetachDatabase(ClientContext &context, const string &name, OnEntryNotFound if_not_found) {
|
46
46
|
if (!databases->DropEntry(context, name, false, true)) {
|
47
|
-
if (
|
47
|
+
if (if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
|
48
48
|
throw BinderException("Failed to detach database with name \"%s\": database not found", name);
|
49
49
|
}
|
50
50
|
}
|
@@ -52,17 +52,18 @@ void DatabaseManager::DetachDatabase(ClientContext &context, const string &name,
|
|
52
52
|
|
53
53
|
optional_ptr<AttachedDatabase> DatabaseManager::GetDatabaseFromPath(ClientContext &context, const string &path) {
|
54
54
|
auto databases = GetDatabases(context);
|
55
|
-
for (auto
|
56
|
-
|
55
|
+
for (auto &db_ref : databases) {
|
56
|
+
auto &db = db_ref.get();
|
57
|
+
if (db.IsSystem()) {
|
57
58
|
continue;
|
58
59
|
}
|
59
|
-
auto &catalog = Catalog::GetCatalog(
|
60
|
+
auto &catalog = Catalog::GetCatalog(db);
|
60
61
|
if (catalog.InMemory()) {
|
61
62
|
continue;
|
62
63
|
}
|
63
64
|
auto db_path = catalog.GetDBPath();
|
64
65
|
if (StringUtil::CIEquals(path, db_path)) {
|
65
|
-
return db;
|
66
|
+
return &db;
|
66
67
|
}
|
67
68
|
}
|
68
69
|
return nullptr;
|
@@ -81,11 +82,11 @@ const string &DatabaseManager::GetDefaultDatabase(ClientContext &context) {
|
|
81
82
|
return default_entry.catalog;
|
82
83
|
}
|
83
84
|
|
84
|
-
vector<
|
85
|
-
vector<
|
86
|
-
databases->Scan(context, [&](CatalogEntry
|
87
|
-
result.push_back(system
|
88
|
-
result.push_back(context.client_data->temporary_objects
|
85
|
+
vector<reference<AttachedDatabase>> DatabaseManager::GetDatabases(ClientContext &context) {
|
86
|
+
vector<reference<AttachedDatabase>> result;
|
87
|
+
databases->Scan(context, [&](CatalogEntry &entry) { result.push_back(entry.Cast<AttachedDatabase>()); });
|
88
|
+
result.push_back(*system);
|
89
|
+
result.push_back(*context.client_data->temporary_objects);
|
89
90
|
return result;
|
90
91
|
}
|
91
92
|
|
@@ -15,8 +15,7 @@ namespace duckdb {
|
|
15
15
|
static optional_ptr<TableCatalogEntry> GetCatalogTableEntry(LogicalOperator &op) {
|
16
16
|
D_ASSERT(op.type == LogicalOperatorType::LOGICAL_GET);
|
17
17
|
auto &get = op.Cast<LogicalGet>();
|
18
|
-
|
19
|
-
return entry;
|
18
|
+
return get.GetTable();
|
20
19
|
}
|
21
20
|
|
22
21
|
// The filter was made on top of a logical sample or other projection,
|
@@ -7,8 +7,8 @@
|
|
7
7
|
|
8
8
|
namespace duckdb {
|
9
9
|
|
10
|
-
AlterInfo::AlterInfo(AlterType type, string catalog_p, string schema_p, string name_p,
|
11
|
-
: type(type),
|
10
|
+
AlterInfo::AlterInfo(AlterType type, string catalog_p, string schema_p, string name_p, OnEntryNotFound if_not_found)
|
11
|
+
: type(type), if_not_found(if_not_found), catalog(std::move(catalog_p)), schema(std::move(schema_p)),
|
12
12
|
name(std::move(name_p)), allow_internal(false) {
|
13
13
|
}
|
14
14
|
|
@@ -53,7 +53,7 @@ AlterEntryData AlterInfo::GetAlterEntryData() const {
|
|
53
53
|
data.catalog = catalog;
|
54
54
|
data.schema = schema;
|
55
55
|
data.name = name;
|
56
|
-
data.
|
56
|
+
data.if_not_found = if_not_found;
|
57
57
|
return data;
|
58
58
|
}
|
59
59
|
|
@@ -10,7 +10,7 @@ namespace duckdb {
|
|
10
10
|
//===--------------------------------------------------------------------===//
|
11
11
|
AlterScalarFunctionInfo::AlterScalarFunctionInfo(AlterScalarFunctionType type, AlterEntryData data)
|
12
12
|
: AlterInfo(AlterType::ALTER_SCALAR_FUNCTION, std::move(data.catalog), std::move(data.schema), std::move(data.name),
|
13
|
-
data.
|
13
|
+
data.if_not_found),
|
14
14
|
alter_scalar_function_type(type) {
|
15
15
|
}
|
16
16
|
AlterScalarFunctionInfo::~AlterScalarFunctionInfo() {
|
@@ -25,7 +25,7 @@ void AlterScalarFunctionInfo::Serialize(FieldWriter &writer) const {
|
|
25
25
|
writer.WriteString(catalog);
|
26
26
|
writer.WriteString(schema);
|
27
27
|
writer.WriteString(name);
|
28
|
-
writer.WriteField(
|
28
|
+
writer.WriteField(if_not_found);
|
29
29
|
}
|
30
30
|
|
31
31
|
unique_ptr<AlterInfo> AlterScalarFunctionInfo::Deserialize(FieldReader &reader) {
|
@@ -10,7 +10,7 @@ namespace duckdb {
|
|
10
10
|
//===--------------------------------------------------------------------===//
|
11
11
|
AlterTableFunctionInfo::AlterTableFunctionInfo(AlterTableFunctionType type, AlterEntryData data)
|
12
12
|
: AlterInfo(AlterType::ALTER_TABLE_FUNCTION, std::move(data.catalog), std::move(data.schema), std::move(data.name),
|
13
|
-
data.
|
13
|
+
data.if_not_found),
|
14
14
|
alter_table_function_type(type) {
|
15
15
|
}
|
16
16
|
AlterTableFunctionInfo::~AlterTableFunctionInfo() {
|
@@ -25,7 +25,7 @@ void AlterTableFunctionInfo::Serialize(FieldWriter &writer) const {
|
|
25
25
|
writer.WriteString(catalog);
|
26
26
|
writer.WriteString(schema);
|
27
27
|
writer.WriteString(name);
|
28
|
-
writer.WriteField(
|
28
|
+
writer.WriteField(if_not_found);
|
29
29
|
}
|
30
30
|
|
31
31
|
unique_ptr<AlterInfo> AlterTableFunctionInfo::Deserialize(FieldReader &reader) {
|
@@ -10,9 +10,9 @@ namespace duckdb {
|
|
10
10
|
//===--------------------------------------------------------------------===//
|
11
11
|
ChangeOwnershipInfo::ChangeOwnershipInfo(CatalogType entry_catalog_type, string entry_catalog_p, string entry_schema_p,
|
12
12
|
string entry_name_p, string owner_schema_p, string owner_name_p,
|
13
|
-
|
13
|
+
OnEntryNotFound if_not_found)
|
14
14
|
: AlterInfo(AlterType::CHANGE_OWNERSHIP, std::move(entry_catalog_p), std::move(entry_schema_p),
|
15
|
-
std::move(entry_name_p),
|
15
|
+
std::move(entry_name_p), if_not_found),
|
16
16
|
entry_catalog_type(entry_catalog_type), owner_schema(std::move(owner_schema_p)),
|
17
17
|
owner_name(std::move(owner_name_p)) {
|
18
18
|
}
|
@@ -23,7 +23,7 @@ CatalogType ChangeOwnershipInfo::GetCatalogType() const {
|
|
23
23
|
|
24
24
|
unique_ptr<AlterInfo> ChangeOwnershipInfo::Copy() const {
|
25
25
|
return make_uniq_base<AlterInfo, ChangeOwnershipInfo>(entry_catalog_type, catalog, schema, name, owner_schema,
|
26
|
-
owner_name,
|
26
|
+
owner_name, if_not_found);
|
27
27
|
}
|
28
28
|
|
29
29
|
void ChangeOwnershipInfo::Serialize(FieldWriter &writer) const {
|
@@ -35,7 +35,7 @@ void ChangeOwnershipInfo::Serialize(FieldWriter &writer) const {
|
|
35
35
|
//===--------------------------------------------------------------------===//
|
36
36
|
AlterTableInfo::AlterTableInfo(AlterTableType type, AlterEntryData data)
|
37
37
|
: AlterInfo(AlterType::ALTER_TABLE, std::move(data.catalog), std::move(data.schema), std::move(data.name),
|
38
|
-
data.
|
38
|
+
data.if_not_found),
|
39
39
|
alter_table_type(type) {
|
40
40
|
}
|
41
41
|
AlterTableInfo::~AlterTableInfo() {
|
@@ -50,7 +50,7 @@ void AlterTableInfo::Serialize(FieldWriter &writer) const {
|
|
50
50
|
writer.WriteString(catalog);
|
51
51
|
writer.WriteString(schema);
|
52
52
|
writer.WriteString(name);
|
53
|
-
writer.WriteField(
|
53
|
+
writer.WriteField(if_not_found);
|
54
54
|
SerializeAlterTable(writer);
|
55
55
|
}
|
56
56
|
|
@@ -60,7 +60,7 @@ unique_ptr<AlterInfo> AlterTableInfo::Deserialize(FieldReader &reader) {
|
|
60
60
|
data.catalog = reader.ReadRequired<string>();
|
61
61
|
data.schema = reader.ReadRequired<string>();
|
62
62
|
data.name = reader.ReadRequired<string>();
|
63
|
-
data.
|
63
|
+
data.if_not_found = reader.ReadRequired<OnEntryNotFound>();
|
64
64
|
|
65
65
|
unique_ptr<AlterTableInfo> info;
|
66
66
|
switch (type) {
|
@@ -330,7 +330,7 @@ unique_ptr<AlterInfo> AlterForeignKeyInfo::Deserialize(FieldReader &reader, Alte
|
|
330
330
|
//===--------------------------------------------------------------------===//
|
331
331
|
AlterViewInfo::AlterViewInfo(AlterViewType type, AlterEntryData data)
|
332
332
|
: AlterInfo(AlterType::ALTER_VIEW, std::move(data.catalog), std::move(data.schema), std::move(data.name),
|
333
|
-
data.
|
333
|
+
data.if_not_found),
|
334
334
|
alter_view_type(type) {
|
335
335
|
}
|
336
336
|
AlterViewInfo::~AlterViewInfo() {
|
@@ -345,7 +345,7 @@ void AlterViewInfo::Serialize(FieldWriter &writer) const {
|
|
345
345
|
writer.WriteString(catalog);
|
346
346
|
writer.WriteString(schema);
|
347
347
|
writer.WriteString(name);
|
348
|
-
writer.WriteField<
|
348
|
+
writer.WriteField<OnEntryNotFound>(if_not_found);
|
349
349
|
SerializeAlterView(writer);
|
350
350
|
}
|
351
351
|
|
@@ -355,7 +355,7 @@ unique_ptr<AlterInfo> AlterViewInfo::Deserialize(FieldReader &reader) {
|
|
355
355
|
data.catalog = reader.ReadRequired<string>();
|
356
356
|
data.schema = reader.ReadRequired<string>();
|
357
357
|
data.name = reader.ReadRequired<string>();
|
358
|
-
data.
|
358
|
+
data.if_not_found = reader.ReadRequired<OnEntryNotFound>();
|
359
359
|
unique_ptr<AlterViewInfo> info;
|
360
360
|
switch (type) {
|
361
361
|
case AlterViewType::RENAME_VIEW:
|
@@ -27,8 +27,8 @@ unique_ptr<CreateInfo> CreateScalarFunctionInfo::Copy() const {
|
|
27
27
|
}
|
28
28
|
|
29
29
|
unique_ptr<AlterInfo> CreateScalarFunctionInfo::GetAlterInfo() const {
|
30
|
-
return make_uniq_base<AlterInfo, AddScalarFunctionOverloadInfo>(
|
31
|
-
|
30
|
+
return make_uniq_base<AlterInfo, AddScalarFunctionOverloadInfo>(
|
31
|
+
AlterEntryData(catalog, schema, name, OnEntryNotFound::RETURN_NULL), functions);
|
32
32
|
}
|
33
33
|
|
34
34
|
} // namespace duckdb
|
@@ -27,8 +27,8 @@ unique_ptr<CreateInfo> CreateTableFunctionInfo::Copy() const {
|
|
27
27
|
}
|
28
28
|
|
29
29
|
unique_ptr<AlterInfo> CreateTableFunctionInfo::GetAlterInfo() const {
|
30
|
-
return make_uniq_base<AlterInfo, AddTableFunctionOverloadInfo>(
|
31
|
-
|
30
|
+
return make_uniq_base<AlterInfo, AddTableFunctionOverloadInfo>(
|
31
|
+
AlterEntryData(catalog, schema, name, OnEntryNotFound::RETURN_NULL), functions);
|
32
32
|
}
|
33
33
|
|
34
34
|
} // namespace duckdb
|