duckdb 1.1.4-dev9.0 → 1.2.1-dev4.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/LICENSE +1 -1
- package/binding.gyp +1 -0
- package/package.json +2 -2
- package/src/connection.cpp +42 -15
- package/src/duckdb/extension/core_functions/function_list.cpp +1 -0
- package/src/duckdb/extension/core_functions/include/core_functions/scalar/map_functions.hpp +9 -0
- package/src/duckdb/extension/core_functions/scalar/date/current.cpp +1 -0
- package/src/duckdb/extension/core_functions/scalar/generic/can_implicitly_cast.cpp +2 -2
- package/src/duckdb/extension/core_functions/scalar/generic/typeof.cpp +1 -1
- package/src/duckdb/extension/core_functions/scalar/list/flatten.cpp +91 -61
- package/src/duckdb/extension/core_functions/scalar/map/map_extract.cpp +89 -8
- package/src/duckdb/extension/icu/icu-current.cpp +63 -0
- package/src/duckdb/extension/icu/icu-makedate.cpp +43 -39
- package/src/duckdb/extension/icu/icu-timezone.cpp +63 -63
- package/src/duckdb/extension/icu/icu_extension.cpp +2 -0
- package/src/duckdb/extension/icu/include/icu-casts.hpp +39 -0
- package/src/duckdb/extension/icu/include/icu-current.hpp +17 -0
- package/src/duckdb/extension/icu/third_party/icu/stubdata/stubdata.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +3 -1
- package/src/duckdb/extension/parquet/column_writer.cpp +26 -18
- package/src/duckdb/extension/parquet/include/parquet_reader.hpp +0 -6
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +15 -1
- package/src/duckdb/extension/parquet/include/resizable_buffer.hpp +1 -0
- package/src/duckdb/extension/parquet/parquet_extension.cpp +67 -15
- package/src/duckdb/extension/parquet/parquet_reader.cpp +5 -3
- package/src/duckdb/extension/parquet/parquet_writer.cpp +5 -6
- package/src/duckdb/src/catalog/catalog.cpp +21 -8
- package/src/duckdb/src/catalog/catalog_search_path.cpp +17 -1
- package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_functions.cpp +0 -3
- package/src/duckdb/src/catalog/dependency_list.cpp +7 -0
- package/src/duckdb/src/common/adbc/adbc.cpp +1 -56
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +3 -2
- package/src/duckdb/src/common/arrow/arrow_type_extension.cpp +58 -28
- package/src/duckdb/src/common/arrow/schema_metadata.cpp +1 -1
- package/src/duckdb/src/common/compressed_file_system.cpp +6 -2
- package/src/duckdb/src/common/enum_util.cpp +26 -22
- package/src/duckdb/src/common/error_data.cpp +3 -2
- package/src/duckdb/src/common/gzip_file_system.cpp +8 -8
- package/src/duckdb/src/common/local_file_system.cpp +2 -2
- package/src/duckdb/src/common/multi_file_reader.cpp +1 -1
- package/src/duckdb/src/common/random_engine.cpp +4 -1
- package/src/duckdb/src/common/serializer/memory_stream.cpp +23 -19
- package/src/duckdb/src/common/serializer/serializer.cpp +1 -1
- package/src/duckdb/src/common/types/bit.cpp +1 -1
- package/src/duckdb/src/common/types/column/column_data_allocator.cpp +0 -5
- package/src/duckdb/src/common/types/column/column_data_collection.cpp +4 -1
- package/src/duckdb/src/common/types/data_chunk.cpp +2 -1
- package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +0 -4
- package/src/duckdb/src/common/types.cpp +1 -1
- package/src/duckdb/src/execution/index/art/art.cpp +52 -42
- package/src/duckdb/src/execution/index/art/leaf.cpp +4 -9
- package/src/duckdb/src/execution/index/art/node.cpp +13 -13
- package/src/duckdb/src/execution/index/art/prefix.cpp +21 -16
- package/src/duckdb/src/execution/index/bound_index.cpp +6 -8
- package/src/duckdb/src/execution/index/fixed_size_allocator.cpp +39 -34
- package/src/duckdb/src/execution/index/fixed_size_buffer.cpp +2 -1
- package/src/duckdb/src/execution/index/unbound_index.cpp +10 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +62 -44
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/column_count_scanner.cpp +26 -0
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +69 -40
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +3 -7
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/header_detection.cpp +11 -5
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_detection.cpp +4 -0
- package/src/duckdb/src/execution/operator/csv_scanner/state_machine/csv_state_machine_cache.cpp +8 -8
- package/src/duckdb/src/execution/operator/csv_scanner/util/csv_error.cpp +36 -12
- package/src/duckdb/src/execution/operator/csv_scanner/util/csv_reader_options.cpp +12 -9
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +0 -1
- package/src/duckdb/src/execution/operator/persistent/physical_copy_database.cpp +29 -1
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +58 -10
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +58 -35
- package/src/duckdb/src/execution/operator/schema/physical_create_art_index.cpp +2 -1
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +9 -4
- package/src/duckdb/src/execution/sample/reservoir_sample.cpp +7 -6
- package/src/duckdb/src/function/compression_config.cpp +4 -0
- package/src/duckdb/src/function/function_binder.cpp +1 -1
- package/src/duckdb/src/function/scalar/system/write_log.cpp +2 -2
- package/src/duckdb/src/function/table/arrow/arrow_duck_schema.cpp +15 -2
- package/src/duckdb/src/function/table/arrow_conversion.cpp +10 -10
- package/src/duckdb/src/function/table/copy_csv.cpp +8 -5
- package/src/duckdb/src/function/table/read_csv.cpp +21 -4
- package/src/duckdb/src/function/table/sniff_csv.cpp +7 -0
- package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +4 -0
- package/src/duckdb/src/function/table/system/duckdb_secret_types.cpp +71 -0
- package/src/duckdb/src/function/table/system_functions.cpp +1 -0
- package/src/duckdb/src/function/table/table_scan.cpp +120 -36
- package/src/duckdb/src/function/table/version/pragma_version.cpp +4 -4
- package/src/duckdb/src/function/window/window_aggregate_function.cpp +6 -1
- package/src/duckdb/src/function/window/window_boundaries_state.cpp +135 -11
- package/src/duckdb/src/function/window/window_segment_tree.cpp +50 -22
- package/src/duckdb/src/function/window/window_token_tree.cpp +4 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +2 -0
- package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_type_extension.hpp +4 -2
- package/src/duckdb/src/include/duckdb/common/enum_util.hpp +8 -8
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +0 -2
- package/src/duckdb/src/include/duckdb/common/serializer/deserializer.hpp +8 -3
- package/src/duckdb/src/include/duckdb/common/serializer/memory_stream.hpp +6 -1
- package/src/duckdb/src/include/duckdb/common/serializer/serialization_data.hpp +25 -0
- package/src/duckdb/src/include/duckdb/common/serializer/serializer.hpp +9 -3
- package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +11 -14
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +5 -4
- package/src/duckdb/src/include/duckdb/execution/index/bound_index.hpp +21 -10
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_allocator.hpp +6 -5
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_buffer.hpp +37 -32
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/base_scanner.hpp +36 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/column_count_scanner.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/sniffer/csv_sniffer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine_options.hpp +5 -5
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/string_value_scanner.hpp +5 -30
- package/src/duckdb/src/include/duckdb/execution/reservoir_sample.hpp +7 -1
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -3
- package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_duck_schema.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/window/window_boundaries_state.hpp +2 -2
- package/src/duckdb/src/include/duckdb/logging/logger.hpp +40 -119
- package/src/duckdb/src/include/duckdb/logging/logging.hpp +0 -2
- package/src/duckdb/src/include/duckdb/main/config.hpp +5 -0
- package/src/duckdb/src/include/duckdb/main/connection.hpp +0 -8
- package/src/duckdb/src/include/duckdb/main/connection_manager.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/extension.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +11 -7
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/secret/secret.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/secret/secret_manager.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +10 -0
- package/src/duckdb/src/include/duckdb/parser/constraint.hpp +9 -0
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +36 -9
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/query_node/set_operation_node.hpp +8 -2
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_data.hpp +9 -1
- package/src/duckdb/src/include/duckdb/planner/filter/constant_filter.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/filter/in_filter.hpp +0 -2
- package/src/duckdb/src/include/duckdb/planner/filter/optional_filter.hpp +4 -4
- package/src/duckdb/src/include/duckdb/planner/table_filter.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +14 -10
- package/src/duckdb/src/include/duckdb/storage/index_storage_info.hpp +4 -0
- package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +6 -1
- package/src/duckdb/src/include/duckdb/storage/storage_info.hpp +7 -2
- package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +9 -0
- package/src/duckdb/src/include/duckdb/storage/storage_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +4 -3
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +6 -4
- package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +2 -0
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +2 -0
- package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +1 -1
- package/src/duckdb/src/logging/logger.cpp +8 -66
- package/src/duckdb/src/main/attached_database.cpp +3 -1
- package/src/duckdb/src/main/client_context.cpp +4 -2
- package/src/duckdb/src/main/config.cpp +20 -2
- package/src/duckdb/src/main/connection.cpp +2 -29
- package/src/duckdb/src/main/connection_manager.cpp +5 -3
- package/src/duckdb/src/main/database.cpp +2 -2
- package/src/duckdb/src/main/extension/extension_helper.cpp +4 -5
- package/src/duckdb/src/main/extension/extension_install.cpp +23 -10
- package/src/duckdb/src/main/extension/extension_load.cpp +6 -7
- package/src/duckdb/src/main/extension.cpp +27 -9
- package/src/duckdb/src/main/secret/secret_manager.cpp +11 -0
- package/src/duckdb/src/main/settings/custom_settings.cpp +44 -0
- package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +6 -0
- package/src/duckdb/src/optimizer/filter_combiner.cpp +13 -3
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +33 -6
- package/src/duckdb/src/optimizer/late_materialization.cpp +14 -3
- package/src/duckdb/src/optimizer/remove_unused_columns.cpp +0 -3
- package/src/duckdb/src/parser/parsed_data/attach_info.cpp +5 -1
- package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +6 -3
- package/src/duckdb/src/parser/query_node/set_operation_node.cpp +49 -0
- package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +1 -0
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +50 -12
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +7 -5
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +1 -0
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +12 -2
- package/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp +0 -1
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +55 -39
- package/src/duckdb/src/planner/binder/statement/bind_execute.cpp +2 -1
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +15 -7
- package/src/duckdb/src/planner/binder/tableref/bind_showref.cpp +13 -8
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +8 -3
- package/src/duckdb/src/planner/expression/bound_function_expression.cpp +17 -1
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +1 -0
- package/src/duckdb/src/planner/filter/conjunction_filter.cpp +1 -0
- package/src/duckdb/src/planner/filter/constant_filter.cpp +21 -0
- package/src/duckdb/src/planner/filter/in_filter.cpp +4 -7
- package/src/duckdb/src/planner/logical_operator.cpp +5 -3
- package/src/duckdb/src/planner/planner.cpp +1 -1
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +2 -0
- package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +3 -4
- package/src/duckdb/src/storage/checkpoint_manager.cpp +3 -5
- package/src/duckdb/src/storage/compression/dictionary/decompression.cpp +4 -4
- package/src/duckdb/src/storage/compression/fsst.cpp +2 -2
- package/src/duckdb/src/storage/compression/roaring/common.cpp +10 -1
- package/src/duckdb/src/storage/compression/string_uncompressed.cpp +11 -6
- package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +4 -0
- package/src/duckdb/src/storage/compression/zstd.cpp +6 -0
- package/src/duckdb/src/storage/data_table.cpp +104 -109
- package/src/duckdb/src/storage/local_storage.cpp +8 -6
- package/src/duckdb/src/storage/magic_bytes.cpp +1 -1
- package/src/duckdb/src/storage/serialization/serialize_dependency.cpp +3 -3
- package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +3 -3
- package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +7 -5
- package/src/duckdb/src/storage/single_file_block_manager.cpp +95 -28
- package/src/duckdb/src/storage/storage_info.cpp +38 -0
- package/src/duckdb/src/storage/storage_manager.cpp +11 -0
- package/src/duckdb/src/storage/table/column_data.cpp +4 -0
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +3 -3
- package/src/duckdb/src/storage/table/row_group_collection.cpp +67 -68
- package/src/duckdb/src/storage/table/table_statistics.cpp +4 -4
- package/src/duckdb/src/storage/table_index_list.cpp +41 -15
- package/src/duckdb/src/storage/wal_replay.cpp +3 -1
- package/src/duckdb/src/storage/write_ahead_log.cpp +11 -4
- package/src/duckdb/src/transaction/meta_transaction.cpp +1 -1
- package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +2 -1
- package/src/duckdb/third_party/httplib/httplib.hpp +0 -1
- package/src/duckdb/third_party/re2/util/logging.h +10 -10
- package/src/duckdb/ub_src_function_table_system.cpp +2 -0
@@ -14,6 +14,11 @@ ArrowTypeExtension::ArrowTypeExtension(string extension_name, string arrow_forma
|
|
14
14
|
: extension_metadata(std::move(extension_name), {}, {}, std::move(arrow_format)), type_extension(std::move(type)) {
|
15
15
|
}
|
16
16
|
|
17
|
+
ArrowTypeExtension::ArrowTypeExtension(ArrowExtensionMetadata &extension_metadata, unique_ptr<ArrowType> type)
|
18
|
+
: extension_metadata(extension_metadata) {
|
19
|
+
type_extension = make_shared_ptr<ArrowTypeExtensionData>(type->GetDuckType());
|
20
|
+
}
|
21
|
+
|
17
22
|
ArrowExtensionMetadata::ArrowExtensionMetadata(string extension_name, string vendor_name, string type_name,
|
18
23
|
string arrow_format)
|
19
24
|
: extension_name(std::move(extension_name)), vendor_name(std::move(vendor_name)), type_name(std::move(type_name)),
|
@@ -121,14 +126,14 @@ ArrowExtensionMetadata ArrowTypeExtension::GetInfo() const {
|
|
121
126
|
return extension_metadata;
|
122
127
|
}
|
123
128
|
|
124
|
-
|
129
|
+
unique_ptr<ArrowType> ArrowTypeExtension::GetType(const ArrowSchema &schema,
|
125
130
|
const ArrowSchemaMetadata &schema_metadata) const {
|
126
131
|
if (get_type) {
|
127
132
|
return get_type(schema, schema_metadata);
|
128
133
|
}
|
129
134
|
// FIXME: THis is not good
|
130
135
|
auto duckdb_type = type_extension->GetDuckDBType();
|
131
|
-
return
|
136
|
+
return make_uniq<ArrowType>(duckdb_type);
|
132
137
|
}
|
133
138
|
|
134
139
|
shared_ptr<ArrowTypeExtensionData> ArrowTypeExtension::GetTypeExtension() const {
|
@@ -177,7 +182,7 @@ void ArrowTypeExtension::PopulateArrowSchema(DuckDBArrowSchemaHolder &root_holde
|
|
177
182
|
}
|
178
183
|
|
179
184
|
void DBConfig::RegisterArrowExtension(const ArrowTypeExtension &extension) const {
|
180
|
-
lock_guard<mutex> l(
|
185
|
+
lock_guard<mutex> l(arrow_extensions->lock);
|
181
186
|
auto extension_info = extension.GetInfo();
|
182
187
|
if (arrow_extensions->type_extensions.find(extension_info) != arrow_extensions->type_extensions.end()) {
|
183
188
|
throw NotImplementedException("Arrow Extension with configuration %s is already registered",
|
@@ -193,27 +198,39 @@ void DBConfig::RegisterArrowExtension(const ArrowTypeExtension &extension) const
|
|
193
198
|
arrow_extensions->type_to_info[type_info].push_back(extension_info);
|
194
199
|
}
|
195
200
|
|
196
|
-
ArrowTypeExtension
|
197
|
-
|
201
|
+
ArrowTypeExtension GetArrowExtensionInternal(
|
202
|
+
unordered_map<ArrowExtensionMetadata, ArrowTypeExtension, HashArrowTypeExtension> &type_extensions,
|
203
|
+
ArrowExtensionMetadata info) {
|
204
|
+
if (type_extensions.find(info) == type_extensions.end()) {
|
205
|
+
auto og_info = info;
|
198
206
|
info.SetArrowFormat("");
|
199
|
-
if (
|
200
|
-
|
201
|
-
|
207
|
+
if (type_extensions.find(info) == type_extensions.end()) {
|
208
|
+
auto format = og_info.GetArrowFormat();
|
209
|
+
auto type = ArrowType::GetTypeFromFormat(format);
|
210
|
+
return ArrowTypeExtension(og_info, std::move(type));
|
202
211
|
}
|
203
212
|
}
|
204
|
-
return
|
213
|
+
return type_extensions[info];
|
214
|
+
}
|
215
|
+
ArrowTypeExtension DBConfig::GetArrowExtension(ArrowExtensionMetadata info) const {
|
216
|
+
lock_guard<mutex> l(arrow_extensions->lock);
|
217
|
+
return GetArrowExtensionInternal(arrow_extensions->type_extensions, std::move(info));
|
205
218
|
}
|
206
219
|
|
207
220
|
ArrowTypeExtension DBConfig::GetArrowExtension(const LogicalType &type) const {
|
221
|
+
lock_guard<mutex> l(arrow_extensions->lock);
|
208
222
|
TypeInfo type_info(type);
|
209
223
|
if (!arrow_extensions->type_to_info[type_info].empty()) {
|
210
|
-
return
|
224
|
+
return GetArrowExtensionInternal(arrow_extensions->type_extensions,
|
225
|
+
arrow_extensions->type_to_info[type_info].front());
|
211
226
|
}
|
212
227
|
type_info.type = LogicalTypeId::ANY;
|
213
|
-
return
|
228
|
+
return GetArrowExtensionInternal(arrow_extensions->type_extensions,
|
229
|
+
arrow_extensions->type_to_info[type_info].front());
|
214
230
|
}
|
215
231
|
|
216
232
|
bool DBConfig::HasArrowExtension(const LogicalType &type) const {
|
233
|
+
lock_guard<mutex> l(arrow_extensions->lock);
|
217
234
|
TypeInfo type_info(type);
|
218
235
|
if (!arrow_extensions->type_to_info[type_info].empty()) {
|
219
236
|
return true;
|
@@ -222,18 +239,33 @@ bool DBConfig::HasArrowExtension(const LogicalType &type) const {
|
|
222
239
|
return !arrow_extensions->type_to_info[type_info].empty();
|
223
240
|
}
|
224
241
|
|
242
|
+
bool DBConfig::HasArrowExtension(ArrowExtensionMetadata info) const {
|
243
|
+
lock_guard<mutex> l(arrow_extensions->lock);
|
244
|
+
auto type_extensions = arrow_extensions->type_extensions;
|
245
|
+
|
246
|
+
if (type_extensions.find(info) != type_extensions.end()) {
|
247
|
+
return true;
|
248
|
+
}
|
249
|
+
|
250
|
+
auto og_info = info;
|
251
|
+
info.SetArrowFormat("");
|
252
|
+
if (type_extensions.find(info) != type_extensions.end()) {
|
253
|
+
return true;
|
254
|
+
}
|
255
|
+
|
256
|
+
return false;
|
257
|
+
}
|
258
|
+
|
225
259
|
struct ArrowJson {
|
226
|
-
static
|
260
|
+
static unique_ptr<ArrowType> GetType(const ArrowSchema &schema, const ArrowSchemaMetadata &schema_metadata) {
|
227
261
|
const auto format = string(schema.format);
|
228
262
|
if (format == "u") {
|
229
|
-
return
|
230
|
-
make_uniq<ArrowStringInfo>(ArrowVariableSizeType::NORMAL));
|
263
|
+
return make_uniq<ArrowType>(LogicalType::JSON(), make_uniq<ArrowStringInfo>(ArrowVariableSizeType::NORMAL));
|
231
264
|
} else if (format == "U") {
|
232
|
-
return
|
233
|
-
|
265
|
+
return make_uniq<ArrowType>(LogicalType::JSON(),
|
266
|
+
make_uniq<ArrowStringInfo>(ArrowVariableSizeType::SUPER_SIZE));
|
234
267
|
} else if (format == "vu") {
|
235
|
-
return
|
236
|
-
make_uniq<ArrowStringInfo>(ArrowVariableSizeType::NORMAL));
|
268
|
+
return make_uniq<ArrowType>(LogicalType::JSON(), make_uniq<ArrowStringInfo>(ArrowVariableSizeType::VIEW));
|
237
269
|
}
|
238
270
|
throw InvalidInputException("Arrow extension type \"%s\" not supported for arrow.json", format.c_str());
|
239
271
|
}
|
@@ -258,14 +290,13 @@ struct ArrowJson {
|
|
258
290
|
};
|
259
291
|
|
260
292
|
struct ArrowBit {
|
261
|
-
static
|
293
|
+
static unique_ptr<ArrowType> GetType(const ArrowSchema &schema, const ArrowSchemaMetadata &schema_metadata) {
|
262
294
|
const auto format = string(schema.format);
|
263
295
|
if (format == "z") {
|
264
|
-
return
|
265
|
-
make_uniq<ArrowStringInfo>(ArrowVariableSizeType::NORMAL));
|
296
|
+
return make_uniq<ArrowType>(LogicalType::BIT, make_uniq<ArrowStringInfo>(ArrowVariableSizeType::NORMAL));
|
266
297
|
} else if (format == "Z") {
|
267
|
-
return
|
268
|
-
|
298
|
+
return make_uniq<ArrowType>(LogicalType::BIT,
|
299
|
+
make_uniq<ArrowStringInfo>(ArrowVariableSizeType::SUPER_SIZE));
|
269
300
|
}
|
270
301
|
throw InvalidInputException("Arrow extension type \"%s\" not supported for BIT type", format.c_str());
|
271
302
|
}
|
@@ -286,14 +317,13 @@ struct ArrowBit {
|
|
286
317
|
};
|
287
318
|
|
288
319
|
struct ArrowVarint {
|
289
|
-
static
|
320
|
+
static unique_ptr<ArrowType> GetType(const ArrowSchema &schema, const ArrowSchemaMetadata &schema_metadata) {
|
290
321
|
const auto format = string(schema.format);
|
291
322
|
if (format == "z") {
|
292
|
-
return
|
293
|
-
make_uniq<ArrowStringInfo>(ArrowVariableSizeType::NORMAL));
|
323
|
+
return make_uniq<ArrowType>(LogicalType::VARINT, make_uniq<ArrowStringInfo>(ArrowVariableSizeType::NORMAL));
|
294
324
|
} else if (format == "Z") {
|
295
|
-
return
|
296
|
-
|
325
|
+
return make_uniq<ArrowType>(LogicalType::VARINT,
|
326
|
+
make_uniq<ArrowStringInfo>(ArrowVariableSizeType::SUPER_SIZE));
|
297
327
|
}
|
298
328
|
throw InvalidInputException("Arrow extension type \"%s\" not supported for Varint", format.c_str());
|
299
329
|
}
|
@@ -66,7 +66,7 @@ ArrowSchemaMetadata ArrowSchemaMetadata::NonCanonicalType(const string &type_nam
|
|
66
66
|
|
67
67
|
bool ArrowSchemaMetadata::HasExtension() const {
|
68
68
|
auto arrow_extension = GetOption(ArrowSchemaMetadata::ARROW_EXTENSION_NAME);
|
69
|
-
return !arrow_extension.empty()
|
69
|
+
return !arrow_extension.empty();
|
70
70
|
}
|
71
71
|
|
72
72
|
ArrowExtensionMetadata ArrowSchemaMetadata::GetExtensionInfo(string format) {
|
@@ -11,7 +11,11 @@ CompressedFile::CompressedFile(CompressedFileSystem &fs, unique_ptr<FileHandle>
|
|
11
11
|
}
|
12
12
|
|
13
13
|
CompressedFile::~CompressedFile() {
|
14
|
-
|
14
|
+
try {
|
15
|
+
// stream_wrapper->Close() might throw
|
16
|
+
CompressedFile::Close();
|
17
|
+
} catch (...) { // NOLINT - cannot throw in exception
|
18
|
+
}
|
15
19
|
}
|
16
20
|
|
17
21
|
void CompressedFile::Initialize(bool write) {
|
@@ -44,7 +48,7 @@ int64_t CompressedFile::ReadData(void *buffer, int64_t remaining) {
|
|
44
48
|
auto available =
|
45
49
|
MinValue<idx_t>(UnsafeNumericCast<idx_t>(remaining),
|
46
50
|
UnsafeNumericCast<idx_t>(stream_data.out_buff_end - stream_data.out_buff_start));
|
47
|
-
memcpy(data_ptr_t(buffer) + total_read, stream_data.out_buff_start, available);
|
51
|
+
memcpy(static_cast<data_ptr_t>(buffer) + total_read, stream_data.out_buff_start, available);
|
48
52
|
|
49
53
|
// increment the total read variables as required
|
50
54
|
stream_data.out_buff_start += available;
|
@@ -83,6 +83,7 @@
|
|
83
83
|
#include "duckdb/common/types/vector_buffer.hpp"
|
84
84
|
#include "duckdb/execution/index/art/art.hpp"
|
85
85
|
#include "duckdb/execution/index/art/node.hpp"
|
86
|
+
#include "duckdb/execution/index/bound_index.hpp"
|
86
87
|
#include "duckdb/execution/operator/csv_scanner/csv_option.hpp"
|
87
88
|
#include "duckdb/execution/operator/csv_scanner/csv_state.hpp"
|
88
89
|
#include "duckdb/execution/operator/csv_scanner/quote_rules.hpp"
|
@@ -150,25 +151,6 @@
|
|
150
151
|
|
151
152
|
namespace duckdb {
|
152
153
|
|
153
|
-
const StringUtil::EnumStringLiteral *GetARTAppendModeValues() {
|
154
|
-
static constexpr StringUtil::EnumStringLiteral values[] {
|
155
|
-
{ static_cast<uint32_t>(ARTAppendMode::DEFAULT), "DEFAULT" },
|
156
|
-
{ static_cast<uint32_t>(ARTAppendMode::IGNORE_DUPLICATES), "IGNORE_DUPLICATES" },
|
157
|
-
{ static_cast<uint32_t>(ARTAppendMode::INSERT_DUPLICATES), "INSERT_DUPLICATES" }
|
158
|
-
};
|
159
|
-
return values;
|
160
|
-
}
|
161
|
-
|
162
|
-
template<>
|
163
|
-
const char* EnumUtil::ToChars<ARTAppendMode>(ARTAppendMode value) {
|
164
|
-
return StringUtil::EnumToString(GetARTAppendModeValues(), 3, "ARTAppendMode", static_cast<uint32_t>(value));
|
165
|
-
}
|
166
|
-
|
167
|
-
template<>
|
168
|
-
ARTAppendMode EnumUtil::FromString<ARTAppendMode>(const char *value) {
|
169
|
-
return static_cast<ARTAppendMode>(StringUtil::StringToEnum(GetARTAppendModeValues(), 3, "ARTAppendMode", value));
|
170
|
-
}
|
171
|
-
|
172
154
|
const StringUtil::EnumStringLiteral *GetARTConflictTypeValues() {
|
173
155
|
static constexpr StringUtil::EnumStringLiteral values[] {
|
174
156
|
{ static_cast<uint32_t>(ARTConflictType::NO_CONFLICT), "NO_CONFLICT" },
|
@@ -1878,6 +1860,25 @@ HLLStorageType EnumUtil::FromString<HLLStorageType>(const char *value) {
|
|
1878
1860
|
return static_cast<HLLStorageType>(StringUtil::StringToEnum(GetHLLStorageTypeValues(), 2, "HLLStorageType", value));
|
1879
1861
|
}
|
1880
1862
|
|
1863
|
+
const StringUtil::EnumStringLiteral *GetIndexAppendModeValues() {
|
1864
|
+
static constexpr StringUtil::EnumStringLiteral values[] {
|
1865
|
+
{ static_cast<uint32_t>(IndexAppendMode::DEFAULT), "DEFAULT" },
|
1866
|
+
{ static_cast<uint32_t>(IndexAppendMode::IGNORE_DUPLICATES), "IGNORE_DUPLICATES" },
|
1867
|
+
{ static_cast<uint32_t>(IndexAppendMode::INSERT_DUPLICATES), "INSERT_DUPLICATES" }
|
1868
|
+
};
|
1869
|
+
return values;
|
1870
|
+
}
|
1871
|
+
|
1872
|
+
template<>
|
1873
|
+
const char* EnumUtil::ToChars<IndexAppendMode>(IndexAppendMode value) {
|
1874
|
+
return StringUtil::EnumToString(GetIndexAppendModeValues(), 3, "IndexAppendMode", static_cast<uint32_t>(value));
|
1875
|
+
}
|
1876
|
+
|
1877
|
+
template<>
|
1878
|
+
IndexAppendMode EnumUtil::FromString<IndexAppendMode>(const char *value) {
|
1879
|
+
return static_cast<IndexAppendMode>(StringUtil::StringToEnum(GetIndexAppendModeValues(), 3, "IndexAppendMode", value));
|
1880
|
+
}
|
1881
|
+
|
1881
1882
|
const StringUtil::EnumStringLiteral *GetIndexConstraintTypeValues() {
|
1882
1883
|
static constexpr StringUtil::EnumStringLiteral values[] {
|
1883
1884
|
{ static_cast<uint32_t>(IndexConstraintType::NONE), "NONE" },
|
@@ -4283,19 +4284,22 @@ const StringUtil::EnumStringLiteral *GetWindowBoundaryValues() {
|
|
4283
4284
|
{ static_cast<uint32_t>(WindowBoundary::EXPR_PRECEDING_ROWS), "EXPR_PRECEDING_ROWS" },
|
4284
4285
|
{ static_cast<uint32_t>(WindowBoundary::EXPR_FOLLOWING_ROWS), "EXPR_FOLLOWING_ROWS" },
|
4285
4286
|
{ static_cast<uint32_t>(WindowBoundary::EXPR_PRECEDING_RANGE), "EXPR_PRECEDING_RANGE" },
|
4286
|
-
{ static_cast<uint32_t>(WindowBoundary::EXPR_FOLLOWING_RANGE), "EXPR_FOLLOWING_RANGE" }
|
4287
|
+
{ static_cast<uint32_t>(WindowBoundary::EXPR_FOLLOWING_RANGE), "EXPR_FOLLOWING_RANGE" },
|
4288
|
+
{ static_cast<uint32_t>(WindowBoundary::CURRENT_ROW_GROUPS), "CURRENT_ROW_GROUPS" },
|
4289
|
+
{ static_cast<uint32_t>(WindowBoundary::EXPR_PRECEDING_GROUPS), "EXPR_PRECEDING_GROUPS" },
|
4290
|
+
{ static_cast<uint32_t>(WindowBoundary::EXPR_FOLLOWING_GROUPS), "EXPR_FOLLOWING_GROUPS" }
|
4287
4291
|
};
|
4288
4292
|
return values;
|
4289
4293
|
}
|
4290
4294
|
|
4291
4295
|
template<>
|
4292
4296
|
const char* EnumUtil::ToChars<WindowBoundary>(WindowBoundary value) {
|
4293
|
-
return StringUtil::EnumToString(GetWindowBoundaryValues(),
|
4297
|
+
return StringUtil::EnumToString(GetWindowBoundaryValues(), 12, "WindowBoundary", static_cast<uint32_t>(value));
|
4294
4298
|
}
|
4295
4299
|
|
4296
4300
|
template<>
|
4297
4301
|
WindowBoundary EnumUtil::FromString<WindowBoundary>(const char *value) {
|
4298
|
-
return static_cast<WindowBoundary>(StringUtil::StringToEnum(GetWindowBoundaryValues(),
|
4302
|
+
return static_cast<WindowBoundary>(StringUtil::StringToEnum(GetWindowBoundaryValues(), 12, "WindowBoundary", value));
|
4299
4303
|
}
|
4300
4304
|
|
4301
4305
|
const StringUtil::EnumStringLiteral *GetWindowExcludeModeValues() {
|
@@ -95,7 +95,7 @@ bool ErrorData::operator==(const ErrorData &other) const {
|
|
95
95
|
}
|
96
96
|
|
97
97
|
void ErrorData::ConvertErrorToJSON() {
|
98
|
-
if (raw_message.empty()
|
98
|
+
if (!raw_message.empty() && raw_message[0] == '{') {
|
99
99
|
// empty or already JSON
|
100
100
|
return;
|
101
101
|
}
|
@@ -121,8 +121,9 @@ void ErrorData::AddErrorLocation(const string &query) {
|
|
121
121
|
}
|
122
122
|
{
|
123
123
|
auto entry = extra_info.find("stack_trace");
|
124
|
-
if (entry != extra_info.end()) {
|
124
|
+
if (entry != extra_info.end() && !entry->second.empty()) {
|
125
125
|
raw_message += "\n\nStack Trace:\n" + entry->second;
|
126
|
+
entry->second = "";
|
126
127
|
}
|
127
128
|
}
|
128
129
|
final_message = ConstructFinalMessage();
|
@@ -82,7 +82,7 @@ public:
|
|
82
82
|
|
83
83
|
void Close() override;
|
84
84
|
|
85
|
-
void FlushStream();
|
85
|
+
void FlushStream() const;
|
86
86
|
};
|
87
87
|
|
88
88
|
MiniZStreamWrapper::~MiniZStreamWrapper() {
|
@@ -146,7 +146,7 @@ void MiniZStreamWrapper::Initialize(CompressedFile &file, bool write) {
|
|
146
146
|
bool MiniZStreamWrapper::Read(StreamData &sd) {
|
147
147
|
// Handling for the concatenated files
|
148
148
|
if (sd.refresh) {
|
149
|
-
auto available =
|
149
|
+
auto available = static_cast<uint32_t>(sd.in_buff_end - sd.in_buff_start);
|
150
150
|
if (available <= GZIP_FOOTER_SIZE) {
|
151
151
|
// Only footer is available so we just close and return finished
|
152
152
|
Close();
|
@@ -173,7 +173,7 @@ bool MiniZStreamWrapper::Read(StreamData &sd) {
|
|
173
173
|
c = UnsafeNumericCast<char>(*body_ptr);
|
174
174
|
body_ptr++;
|
175
175
|
} while (c != '\0' && body_ptr < sd.in_buff_end);
|
176
|
-
if (
|
176
|
+
if (static_cast<idx_t>(body_ptr - sd.in_buff_start) >= GZIP_HEADER_MAXSIZE) {
|
177
177
|
throw InternalException("Filename resulting in GZIP header larger than defined maximum (%d)",
|
178
178
|
GZIP_HEADER_MAXSIZE);
|
179
179
|
}
|
@@ -193,9 +193,9 @@ bool MiniZStreamWrapper::Read(StreamData &sd) {
|
|
193
193
|
// actually decompress
|
194
194
|
mz_stream_ptr->next_in = sd.in_buff_start;
|
195
195
|
D_ASSERT(sd.in_buff_end - sd.in_buff_start < NumericLimits<int32_t>::Maximum());
|
196
|
-
mz_stream_ptr->avail_in =
|
196
|
+
mz_stream_ptr->avail_in = static_cast<uint32_t>(sd.in_buff_end - sd.in_buff_start);
|
197
197
|
mz_stream_ptr->next_out = data_ptr_cast(sd.out_buff_end);
|
198
|
-
mz_stream_ptr->avail_out =
|
198
|
+
mz_stream_ptr->avail_out = static_cast<uint32_t>((sd.out_buff.get() + sd.out_buf_size) - sd.out_buff_end);
|
199
199
|
auto ret = duckdb_miniz::mz_inflate(mz_stream_ptr.get(), duckdb_miniz::MZ_NO_FLUSH);
|
200
200
|
if (ret != duckdb_miniz::MZ_OK && ret != duckdb_miniz::MZ_STREAM_END) {
|
201
201
|
throw IOException("Failed to decode gzip stream: %s", duckdb_miniz::mz_error(ret));
|
@@ -248,7 +248,7 @@ void MiniZStreamWrapper::Write(CompressedFile &file, StreamData &sd, data_ptr_t
|
|
248
248
|
}
|
249
249
|
}
|
250
250
|
|
251
|
-
void MiniZStreamWrapper::FlushStream() {
|
251
|
+
void MiniZStreamWrapper::FlushStream() const {
|
252
252
|
auto &sd = file->stream_data;
|
253
253
|
mz_stream_ptr->next_in = nullptr;
|
254
254
|
mz_stream_ptr->avail_in = 0;
|
@@ -371,7 +371,7 @@ string GZipFileSystem::UncompressGZIPString(const char *data, idx_t size) {
|
|
371
371
|
do {
|
372
372
|
c = *body_ptr;
|
373
373
|
body_ptr++;
|
374
|
-
} while (c != '\0' &&
|
374
|
+
} while (c != '\0' && static_cast<idx_t>(body_ptr - data) < size);
|
375
375
|
}
|
376
376
|
|
377
377
|
// stream is now set to beginning of payload data
|
@@ -384,10 +384,10 @@ string GZipFileSystem::UncompressGZIPString(const char *data, idx_t size) {
|
|
384
384
|
mz_stream_ptr->next_in = const_uchar_ptr_cast(body_ptr);
|
385
385
|
mz_stream_ptr->avail_in = NumericCast<unsigned int>(bytes_remaining);
|
386
386
|
|
387
|
-
unsigned char decompress_buffer[BUFSIZ];
|
388
387
|
string decompressed;
|
389
388
|
|
390
389
|
while (status == duckdb_miniz::MZ_OK) {
|
390
|
+
unsigned char decompress_buffer[BUFSIZ];
|
391
391
|
mz_stream_ptr->next_out = decompress_buffer;
|
392
392
|
mz_stream_ptr->avail_out = sizeof(decompress_buffer);
|
393
393
|
status = mz_inflate(mz_stream_ptr.get(), duckdb_miniz::MZ_NO_FLUSH);
|
@@ -302,7 +302,7 @@ unique_ptr<FileHandle> LocalFileSystem::OpenFile(const string &path_p, FileOpenF
|
|
302
302
|
}
|
303
303
|
|
304
304
|
if (opener) {
|
305
|
-
|
305
|
+
DUCKDB_LOG_INFO(*opener, "duckdb.FileSystem.LocalFileSystem.OpenFile", path_p);
|
306
306
|
}
|
307
307
|
|
308
308
|
flags.Verify();
|
@@ -842,7 +842,7 @@ unique_ptr<FileHandle> LocalFileSystem::OpenFile(const string &path_p, FileOpenF
|
|
842
842
|
flags.Verify();
|
843
843
|
|
844
844
|
if (opener) {
|
845
|
-
|
845
|
+
DUCKDB_LOG_INFO(*opener, "duckdb.FileSystem.LocalFileSystem.OpenFile", path_p);
|
846
846
|
}
|
847
847
|
|
848
848
|
DWORD desired_access;
|
@@ -125,7 +125,7 @@ bool MultiFileReader::ParseOption(const string &key, const Value &val, MultiFile
|
|
125
125
|
"'hive_types' only accepts a STRUCT('name':VARCHAR, ...), but '%s' was provided",
|
126
126
|
val.type().ToString());
|
127
127
|
}
|
128
|
-
// verify that
|
128
|
+
// verify that all the children of the struct value are VARCHAR
|
129
129
|
auto &children = StructValue::GetChildren(val);
|
130
130
|
for (idx_t i = 0; i < children.size(); i++) {
|
131
131
|
const Value &child = children[i];
|
@@ -21,7 +21,10 @@ RandomEngine::RandomEngine(int64_t seed) : random_state(make_uniq<RandomState>()
|
|
21
21
|
if (seed < 0) {
|
22
22
|
#ifdef __linux__
|
23
23
|
idx_t random_seed = 0;
|
24
|
-
|
24
|
+
int result = -1;
|
25
|
+
#if defined(SYS_getrandom)
|
26
|
+
result = static_cast<int>(syscall(SYS_getrandom, &random_seed, sizeof(random_seed), 0));
|
27
|
+
#endif
|
25
28
|
if (result == -1) {
|
26
29
|
// Something went wrong with the syscall, we use chrono
|
27
30
|
const auto now = std::chrono::high_resolution_clock::now();
|
@@ -1,23 +1,24 @@
|
|
1
1
|
#include "duckdb/common/serializer/memory_stream.hpp"
|
2
2
|
|
3
|
+
#include "duckdb/common/allocator.hpp"
|
4
|
+
|
3
5
|
namespace duckdb {
|
4
6
|
|
5
|
-
MemoryStream::MemoryStream(
|
7
|
+
MemoryStream::MemoryStream(Allocator &allocator_p, idx_t capacity)
|
8
|
+
: allocator(&allocator_p), position(0), capacity(capacity) {
|
6
9
|
D_ASSERT(capacity != 0 && IsPowerOfTwo(capacity));
|
7
|
-
|
8
|
-
if (!data_malloc_result) {
|
9
|
-
throw std::bad_alloc();
|
10
|
-
}
|
11
|
-
data = static_cast<data_ptr_t>(data_malloc_result);
|
10
|
+
data = allocator_p.AllocateData(capacity);
|
12
11
|
}
|
13
12
|
|
14
|
-
MemoryStream::MemoryStream(
|
15
|
-
|
13
|
+
MemoryStream::MemoryStream(idx_t capacity) : MemoryStream(Allocator::DefaultAllocator(), capacity) {
|
14
|
+
}
|
15
|
+
|
16
|
+
MemoryStream::MemoryStream(data_ptr_t buffer, idx_t capacity) : position(0), capacity(capacity), data(buffer) {
|
16
17
|
}
|
17
18
|
|
18
19
|
MemoryStream::~MemoryStream() {
|
19
|
-
if (
|
20
|
-
|
20
|
+
if (allocator && data) {
|
21
|
+
allocator->FreeData(data, capacity);
|
21
22
|
}
|
22
23
|
}
|
23
24
|
|
@@ -26,46 +27,49 @@ MemoryStream::MemoryStream(MemoryStream &&other) noexcept {
|
|
26
27
|
data = other.data;
|
27
28
|
position = other.position;
|
28
29
|
capacity = other.capacity;
|
29
|
-
|
30
|
+
allocator = other.allocator;
|
30
31
|
|
31
32
|
// Reset the other stream
|
32
33
|
other.data = nullptr;
|
33
34
|
other.position = 0;
|
34
35
|
other.capacity = 0;
|
35
|
-
other.
|
36
|
+
other.allocator = nullptr;
|
36
37
|
}
|
37
38
|
|
38
39
|
MemoryStream &MemoryStream::operator=(MemoryStream &&other) noexcept {
|
39
40
|
if (this != &other) {
|
40
41
|
// Free the current data
|
41
|
-
if (
|
42
|
-
|
42
|
+
if (allocator) {
|
43
|
+
allocator->FreeData(data, capacity);
|
43
44
|
}
|
44
45
|
|
45
46
|
// Move the data from the other stream into this stream
|
46
47
|
data = other.data;
|
47
48
|
position = other.position;
|
48
49
|
capacity = other.capacity;
|
49
|
-
|
50
|
+
allocator = other.allocator;
|
50
51
|
|
51
52
|
// Reset the other stream
|
52
53
|
other.data = nullptr;
|
53
54
|
other.position = 0;
|
54
55
|
other.capacity = 0;
|
55
|
-
other.
|
56
|
+
other.allocator = nullptr;
|
56
57
|
}
|
57
58
|
return *this;
|
58
59
|
}
|
59
60
|
|
60
61
|
void MemoryStream::WriteData(const_data_ptr_t source, idx_t write_size) {
|
62
|
+
const auto old_capacity = capacity;
|
61
63
|
while (position + write_size > capacity) {
|
62
|
-
if (
|
64
|
+
if (allocator) {
|
63
65
|
capacity *= 2;
|
64
|
-
data = static_cast<data_ptr_t>(realloc(data, capacity));
|
65
66
|
} else {
|
66
67
|
throw SerializationException("Failed to serialize: not enough space in buffer to fulfill write request");
|
67
68
|
}
|
68
69
|
}
|
70
|
+
if (capacity != old_capacity) {
|
71
|
+
data = allocator->ReallocateData(data, old_capacity, capacity);
|
72
|
+
}
|
69
73
|
memcpy(data + position, source, write_size);
|
70
74
|
position += write_size;
|
71
75
|
}
|
@@ -83,7 +87,7 @@ void MemoryStream::Rewind() {
|
|
83
87
|
}
|
84
88
|
|
85
89
|
void MemoryStream::Release() {
|
86
|
-
|
90
|
+
allocator = nullptr;
|
87
91
|
}
|
88
92
|
|
89
93
|
data_ptr_t MemoryStream::GetData() const {
|
@@ -15,7 +15,7 @@ void Serializer::WriteValue(const vector<bool> &vec) {
|
|
15
15
|
|
16
16
|
template <>
|
17
17
|
void Serializer::WritePropertyWithDefault<Value>(const field_id_t field_id, const char *tag, const Value &value,
|
18
|
-
const Value
|
18
|
+
const Value &default_value) {
|
19
19
|
// If current value is default, don't write it
|
20
20
|
if (!options.serialize_default_values && ValueOperations::NotDistinctFrom(value, default_value)) {
|
21
21
|
OnOptionalPropertyBegin(field_id, tag, false);
|
@@ -179,7 +179,7 @@ void Bit::BitToBlob(bitstring_t bit, string_t &output_blob) {
|
|
179
179
|
auto output = output_blob.GetDataWriteable();
|
180
180
|
idx_t size = output_blob.GetSize();
|
181
181
|
|
182
|
-
output[0] =
|
182
|
+
output[0] = static_cast<char>(GetFirstByte(bit));
|
183
183
|
if (size >= 2) {
|
184
184
|
++output;
|
185
185
|
// First byte in bitstring contains amount of padded bits,
|
@@ -54,12 +54,7 @@ ColumnDataAllocator::~ColumnDataAllocator() {
|
|
54
54
|
for (auto &block : blocks) {
|
55
55
|
block.handle->SetDestroyBufferUpon(DestroyBufferUpon::UNPIN);
|
56
56
|
}
|
57
|
-
const auto data_size = SizeInBytes();
|
58
57
|
blocks.clear();
|
59
|
-
if (Allocator::SupportsFlush() &&
|
60
|
-
data_size > alloc.buffer_manager->GetBufferPool().GetAllocatorBulkDeallocationFlushThreshold()) {
|
61
|
-
Allocator::FlushAll();
|
62
|
-
}
|
63
58
|
}
|
64
59
|
|
65
60
|
BufferHandle ColumnDataAllocator::Pin(uint32_t block_id) {
|
@@ -799,7 +799,10 @@ static bool IsComplexType(const LogicalType &type) {
|
|
799
799
|
|
800
800
|
void ColumnDataCollection::Append(ColumnDataAppendState &state, DataChunk &input) {
|
801
801
|
D_ASSERT(!finished_append);
|
802
|
-
|
802
|
+
{
|
803
|
+
auto input_types = input.GetTypes();
|
804
|
+
D_ASSERT(types == input_types);
|
805
|
+
}
|
803
806
|
|
804
807
|
auto &segment = *segments.back();
|
805
808
|
for (idx_t vector_idx = 0; vector_idx < types.size(); vector_idx++) {
|
@@ -369,7 +369,8 @@ void DataChunk::Verify() {
|
|
369
369
|
}
|
370
370
|
|
371
371
|
// verify that we can round-trip chunk serialization
|
372
|
-
|
372
|
+
Allocator allocator;
|
373
|
+
MemoryStream mem_stream(allocator);
|
373
374
|
BinarySerializer serializer(mem_stream);
|
374
375
|
|
375
376
|
serializer.Begin();
|
@@ -119,10 +119,6 @@ TupleDataSegment::~TupleDataSegment() {
|
|
119
119
|
}
|
120
120
|
pinned_row_handles.clear();
|
121
121
|
pinned_heap_handles.clear();
|
122
|
-
if (Allocator::SupportsFlush() && allocator &&
|
123
|
-
data_size > allocator->GetBufferManager().GetBufferPool().GetAllocatorBulkDeallocationFlushThreshold()) {
|
124
|
-
Allocator::FlushAll();
|
125
|
-
}
|
126
122
|
allocator.reset();
|
127
123
|
}
|
128
124
|
|
@@ -1314,7 +1314,7 @@ void LogicalType::Verify() const {
|
|
1314
1314
|
switch (id_) {
|
1315
1315
|
case LogicalTypeId::DECIMAL:
|
1316
1316
|
D_ASSERT(DecimalType::GetWidth(*this) >= 1 && DecimalType::GetWidth(*this) <= Decimal::MAX_WIDTH_DECIMAL);
|
1317
|
-
D_ASSERT(DecimalType::GetScale(*this)
|
1317
|
+
D_ASSERT(DecimalType::GetScale(*this) <= DecimalType::GetWidth(*this));
|
1318
1318
|
break;
|
1319
1319
|
case LogicalTypeId::STRUCT: {
|
1320
1320
|
// verify child types
|