duckdb 1.3.1-dev6.0 → 1.3.1
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/package.json +1 -1
- package/src/duckdb/extension/core_functions/aggregate/distributive/arg_min_max.cpp +27 -39
- package/src/duckdb/extension/core_functions/aggregate/holistic/quantile.cpp +2 -3
- package/src/duckdb/extension/core_functions/include/core_functions/aggregate/quantile_sort_tree.hpp +1 -1
- package/src/duckdb/extension/core_functions/lambda_functions.cpp +16 -14
- package/src/duckdb/extension/core_functions/scalar/list/list_filter.cpp +3 -2
- package/src/duckdb/extension/core_functions/scalar/list/list_reduce.cpp +46 -10
- package/src/duckdb/extension/core_functions/scalar/list/list_transform.cpp +3 -2
- package/src/duckdb/extension/core_functions/scalar/random/random.cpp +3 -1
- package/src/duckdb/extension/icu/icu-datefunc.cpp +5 -3
- package/src/duckdb/extension/icu/icu-strptime.cpp +6 -1
- package/src/duckdb/extension/icu/icu-timezone.cpp +4 -0
- package/src/duckdb/extension/icu/icu_extension.cpp +7 -2
- package/src/duckdb/extension/icu/include/icu-datefunc.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-helpers.hpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/uloc.cpp +5 -5
- package/src/duckdb/extension/json/include/json_common.hpp +19 -0
- package/src/duckdb/extension/json/include/json_deserializer.hpp +1 -4
- package/src/duckdb/extension/json/include/json_functions.hpp +4 -4
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +38 -17
- package/src/duckdb/extension/json/json_functions/json_table_in_out.cpp +11 -7
- package/src/duckdb/extension/json/json_functions.cpp +4 -4
- package/src/duckdb/extension/json/json_reader.cpp +1 -1
- package/src/duckdb/extension/parquet/column_reader.cpp +7 -1
- package/src/duckdb/extension/parquet/include/parquet_bss_decoder.hpp +2 -2
- package/src/duckdb/extension/parquet/include/parquet_dbp_encoder.hpp +2 -2
- package/src/duckdb/extension/parquet/include/parquet_reader.hpp +2 -1
- package/src/duckdb/extension/parquet/include/parquet_statistics.hpp +1 -1
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +3 -0
- package/src/duckdb/extension/parquet/include/writer/parquet_write_operators.hpp +3 -1
- package/src/duckdb/extension/parquet/include/writer/templated_column_writer.hpp +1 -1
- package/src/duckdb/extension/parquet/parquet_crypto.cpp +9 -5
- package/src/duckdb/extension/parquet/parquet_extension.cpp +26 -0
- package/src/duckdb/extension/parquet/parquet_float16.cpp +4 -2
- package/src/duckdb/extension/parquet/parquet_metadata.cpp +3 -3
- package/src/duckdb/extension/parquet/parquet_multi_file_info.cpp +12 -0
- package/src/duckdb/extension/parquet/parquet_reader.cpp +5 -4
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +13 -3
- package/src/duckdb/extension/parquet/parquet_writer.cpp +1 -1
- package/src/duckdb/extension/parquet/reader/decimal_column_reader.cpp +1 -1
- package/src/duckdb/extension/parquet/reader/string_column_reader.cpp +1 -1
- package/src/duckdb/extension/parquet/reader/struct_column_reader.cpp +13 -4
- package/src/duckdb/extension/parquet/serialize_parquet.cpp +2 -0
- package/src/duckdb/src/catalog/catalog.cpp +10 -4
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +4 -10
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +1 -2
- package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_search_path.cpp +7 -1
- package/src/duckdb/src/catalog/catalog_set.cpp +21 -1
- package/src/duckdb/src/common/adbc/adbc.cpp +1 -1
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +17 -5
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +23 -15
- package/src/duckdb/src/common/box_renderer.cpp +1 -2
- package/src/duckdb/src/common/enum_util.cpp +4 -3
- package/src/duckdb/src/common/local_file_system.cpp +13 -12
- package/src/duckdb/src/common/multi_file/multi_file_column_mapper.cpp +35 -12
- package/src/duckdb/src/common/multi_file/multi_file_reader.cpp +13 -3
- package/src/duckdb/src/common/string_util.cpp +7 -5
- package/src/duckdb/src/common/tree_renderer/graphviz_tree_renderer.cpp +4 -4
- package/src/duckdb/src/common/tree_renderer/html_tree_renderer.cpp +4 -4
- package/src/duckdb/src/common/tree_renderer/json_tree_renderer.cpp +4 -4
- package/src/duckdb/src/common/tree_renderer/text_tree_renderer.cpp +4 -4
- package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +1 -1
- package/src/duckdb/src/common/types/uuid.cpp +5 -1
- package/src/duckdb/src/common/types.cpp +28 -0
- package/src/duckdb/src/common/virtual_file_system.cpp +5 -0
- package/src/duckdb/src/execution/column_binding_resolver.cpp +49 -30
- package/src/duckdb/src/execution/index/fixed_size_allocator.cpp +4 -0
- package/src/duckdb/src/execution/join_hashtable.cpp +10 -7
- package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +3 -3
- package/src/duckdb/src/execution/operator/csv_scanner/encode/csv_encoder.cpp +1 -1
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/column_count_scanner.cpp +2 -1
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/skip_scanner.cpp +1 -4
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +53 -1
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +58 -59
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +10 -5
- package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +4 -0
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +18 -8
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +1 -0
- package/src/duckdb/src/execution/physical_plan_generator.cpp +5 -5
- package/src/duckdb/src/function/cast/vector_cast_helpers.cpp +2 -1
- package/src/duckdb/src/function/function.cpp +4 -0
- package/src/duckdb/src/function/scalar/operator/arithmetic.cpp +6 -0
- package/src/duckdb/src/function/scalar/struct/remap_struct.cpp +10 -1
- package/src/duckdb/src/function/table/copy_csv.cpp +1 -0
- package/src/duckdb/src/function/table/version/pragma_version.cpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +1 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/file_buffer.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/helper.hpp +9 -9
- package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/multi_file/multi_file_column_mapper.hpp +3 -5
- package/src/duckdb/src/include/duckdb/common/multi_file/multi_file_reader.hpp +7 -0
- package/src/duckdb/src/include/duckdb/common/multi_file/multi_file_states.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/shadow_forbidden_functions.hpp +40 -0
- package/src/duckdb/src/include/duckdb/common/string.hpp +25 -2
- package/src/duckdb/src/include/duckdb/common/types/hugeint.hpp +20 -24
- package/src/duckdb/src/include/duckdb/common/types/uhugeint.hpp +20 -24
- package/src/duckdb/src/include/duckdb/common/types.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/unique_ptr.hpp +34 -8
- package/src/duckdb/src/include/duckdb/execution/column_binding_resolver.hpp +1 -0
- package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +3 -2
- 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/encode/csv_encoder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/sniffer/csv_sniffer.hpp +15 -3
- package/src/duckdb/src/include/duckdb/function/cast/vector_cast_helpers.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/copy_function.hpp +7 -3
- package/src/duckdb/src/include/duckdb/function/function.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/function_binder.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +20 -12
- package/src/duckdb/src/include/duckdb/function/lambda_functions.hpp +4 -3
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -1
- package/src/duckdb/src/include/duckdb/logging/log_type.hpp +17 -0
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/client_properties.hpp +22 -6
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +4 -1
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +27 -13
- package/src/duckdb/src/include/duckdb/main/secret/secret_manager.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +11 -0
- package/src/duckdb/src/include/duckdb/optimizer/topn_optimizer.hpp +7 -1
- package/src/duckdb/src/include/duckdb/original/std/locale.hpp +10 -0
- package/src/duckdb/src/include/duckdb/original/std/memory.hpp +12 -0
- package/src/duckdb/src/include/duckdb/original/std/sstream.hpp +11 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +5 -3
- package/src/duckdb/src/include/duckdb/storage/buffer/buffer_pool.hpp +4 -2
- package/src/duckdb/src/logging/log_manager.cpp +1 -0
- package/src/duckdb/src/logging/log_types.cpp +40 -0
- package/src/duckdb/src/main/attached_database.cpp +4 -0
- package/src/duckdb/src/main/client_context.cpp +1 -0
- package/src/duckdb/src/main/config.cpp +1 -0
- package/src/duckdb/src/main/database.cpp +1 -0
- package/src/duckdb/src/main/database_manager.cpp +19 -2
- package/src/duckdb/src/main/extension/extension_helper.cpp +4 -3
- package/src/duckdb/src/main/query_profiler.cpp +2 -2
- package/src/duckdb/src/main/query_result.cpp +1 -1
- package/src/duckdb/src/main/secret/secret_manager.cpp +2 -0
- package/src/duckdb/src/main/settings/autogenerated_settings.cpp +7 -0
- package/src/duckdb/src/main/settings/custom_settings.cpp +106 -34
- package/src/duckdb/src/optimizer/optimizer.cpp +1 -1
- package/src/duckdb/src/optimizer/topn_optimizer.cpp +18 -8
- package/src/duckdb/src/parallel/executor.cpp +5 -0
- package/src/duckdb/src/parser/parsed_data/create_sequence_info.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_interval.cpp +5 -1
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +21 -24
- package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +10 -8
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +3 -2
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +0 -4
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +3 -0
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +3 -0
- package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +3 -0
- package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_function_expression.cpp +0 -1
- package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder.cpp +4 -2
- package/src/duckdb/src/planner/logical_operator.cpp +2 -1
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +4 -1
- package/src/duckdb/src/storage/buffer/block_handle.cpp +8 -0
- package/src/duckdb/src/storage/buffer/buffer_pool.cpp +44 -18
- package/src/duckdb/src/storage/caching_file_system.cpp +7 -7
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +4 -3
- package/src/duckdb/src/storage/storage_info.cpp +2 -0
- package/src/duckdb/src/storage/wal_replay.cpp +9 -4
- package/src/duckdb/third_party/fmt/include/fmt/format.h +8 -1
- package/src/duckdb/third_party/fsst/libfsst.cpp +4 -3
- package/src/duckdb/third_party/httplib/httplib.hpp +25 -22
- package/src/duckdb/third_party/hyperloglog/sds.cpp +7 -3
- package/src/duckdb/third_party/libpg_query/src_common_keywords.cpp +8 -1
- package/src/duckdb/third_party/re2/re2/filtered_re2.h +8 -2
- package/src/duckdb/third_party/re2/re2/pod_array.h +7 -1
- package/src/duckdb/third_party/re2/re2/re2.cc +6 -2
- package/src/duckdb/third_party/re2/re2/set.cc +1 -1
- package/src/duckdb/third_party/re2/re2/set.h +7 -1
- package/src/duckdb/ub_src_logging.cpp +4 -4
@@ -1,5 +1,6 @@
|
|
1
1
|
#include "duckdb/planner/logical_operator.hpp"
|
2
2
|
|
3
|
+
#include "duckdb/original/std/sstream.hpp"
|
3
4
|
#include "duckdb/common/enum_util.hpp"
|
4
5
|
#include "duckdb/common/printer.hpp"
|
5
6
|
#include "duckdb/common/serializer/binary_deserializer.hpp"
|
@@ -126,7 +127,7 @@ vector<ColumnBinding> LogicalOperator::MapBindings(const vector<ColumnBinding> &
|
|
126
127
|
|
127
128
|
string LogicalOperator::ToString(ExplainFormat format) const {
|
128
129
|
auto renderer = TreeRenderer::CreateRenderer(format);
|
129
|
-
stringstream ss;
|
130
|
+
duckdb::stringstream ss;
|
130
131
|
auto tree = RenderTree::CreateRenderTree(*this);
|
131
132
|
renderer->ToStream(*tree, ss);
|
132
133
|
return ss.str();
|
@@ -423,7 +423,8 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
|
|
423
423
|
}
|
424
424
|
|
425
425
|
base_binding.table_index = proj.table_index;
|
426
|
-
|
426
|
+
base_binding.column_index = plan->expressions.size() - correlated_columns.size();
|
427
|
+
this->delim_offset = base_binding.column_index;
|
427
428
|
this->data_offset = 0;
|
428
429
|
return plan;
|
429
430
|
}
|
@@ -656,6 +657,7 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
|
|
656
657
|
// push into both sides
|
657
658
|
plan->children[0] =
|
658
659
|
PushDownDependentJoinInternal(std::move(plan->children[0]), parent_propagate_null_values, lateral_depth);
|
660
|
+
auto left_delim_offset = delim_offset;
|
659
661
|
auto left_binding = this->base_binding;
|
660
662
|
plan->children[1] =
|
661
663
|
PushDownDependentJoinInternal(std::move(plan->children[1]), parent_propagate_null_values, lateral_depth);
|
@@ -665,6 +667,7 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
|
|
665
667
|
// because the RIGHT binding might contain NULL values
|
666
668
|
if (join.join_type == JoinType::LEFT) {
|
667
669
|
this->base_binding = left_binding;
|
670
|
+
delim_offset = left_delim_offset;
|
668
671
|
} else if (join.join_type == JoinType::RIGHT) {
|
669
672
|
this->base_binding = right_binding;
|
670
673
|
delim_offset += plan->children[0]->GetColumnBindings().size();
|
@@ -206,6 +206,14 @@ bool BlockHandle::CanUnload() const {
|
|
206
206
|
void BlockHandle::ConvertToPersistent(BlockLock &l, BlockHandle &new_block, unique_ptr<FileBuffer> new_buffer) {
|
207
207
|
VerifyMutex(l);
|
208
208
|
|
209
|
+
D_ASSERT(tag == memory_charge.tag);
|
210
|
+
if (tag != new_block.tag) {
|
211
|
+
const auto memory_charge_size = memory_charge.size;
|
212
|
+
memory_charge.Resize(0);
|
213
|
+
memory_charge.tag = new_block.tag;
|
214
|
+
memory_charge.Resize(memory_charge_size);
|
215
|
+
}
|
216
|
+
|
209
217
|
// move the data from the old block into data for the new block
|
210
218
|
new_block.state = BlockState::BLOCK_LOADED;
|
211
219
|
new_block.buffer = std::move(new_buffer);
|
@@ -10,6 +10,33 @@
|
|
10
10
|
|
11
11
|
namespace duckdb {
|
12
12
|
|
13
|
+
static idx_t FileBufferTypeToEvictionQueueTypeIdx(const FileBufferType &type) {
|
14
|
+
switch (type) {
|
15
|
+
case FileBufferType::BLOCK:
|
16
|
+
case FileBufferType::EXTERNAL_FILE:
|
17
|
+
return 0; // Evict these first (cheap, just free)
|
18
|
+
case FileBufferType::MANAGED_BUFFER:
|
19
|
+
return 1; // Then these (have to write to storage)
|
20
|
+
case FileBufferType::TINY_BUFFER:
|
21
|
+
return 2; // Evict tiny buffers last (last resort)
|
22
|
+
default:
|
23
|
+
throw InternalException("Unknown FileBufferType in FileBufferTypeToEvictionQueueTypeIdx");
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
static vector<FileBufferType> EvictionQueueTypeIdxToFileBufferTypes(const idx_t &queue_type_idx) {
|
28
|
+
switch (queue_type_idx) {
|
29
|
+
case 0:
|
30
|
+
return {FileBufferType::BLOCK, FileBufferType::EXTERNAL_FILE};
|
31
|
+
case 1:
|
32
|
+
return {FileBufferType::MANAGED_BUFFER};
|
33
|
+
case 2:
|
34
|
+
return {FileBufferType::TINY_BUFFER};
|
35
|
+
default:
|
36
|
+
throw InternalException("Unknown queue type index in EvictionQueueTypeIdxToFileBufferTypes");
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
13
40
|
BufferEvictionNode::BufferEvictionNode(weak_ptr<BlockHandle> handle_p, idx_t eviction_seq_num)
|
14
41
|
: handle(std::move(handle_p)), handle_sequence_number(eviction_seq_num) {
|
15
42
|
D_ASSERT(!handle.expired());
|
@@ -41,8 +68,8 @@ typedef duckdb_moodycamel::ConcurrentQueue<BufferEvictionNode> eviction_queue_t;
|
|
41
68
|
|
42
69
|
struct EvictionQueue {
|
43
70
|
public:
|
44
|
-
explicit EvictionQueue(const FileBufferType
|
45
|
-
:
|
71
|
+
explicit EvictionQueue(const vector<FileBufferType> &file_buffer_types_p)
|
72
|
+
: file_buffer_types(file_buffer_types_p), evict_queue_insertions(0), total_dead_nodes(0) {
|
46
73
|
}
|
47
74
|
|
48
75
|
public:
|
@@ -70,8 +97,11 @@ private:
|
|
70
97
|
void PurgeIteration(const idx_t purge_size);
|
71
98
|
|
72
99
|
public:
|
73
|
-
//! The type of the buffers in this queue
|
74
|
-
const FileBufferType
|
100
|
+
//! The type of the buffers in this queue and helper function (both for verification only)
|
101
|
+
const vector<FileBufferType> file_buffer_types;
|
102
|
+
bool HasFileBufferType(const FileBufferType &type) const {
|
103
|
+
return std::find(file_buffer_types.begin(), file_buffer_types.end(), type) != file_buffer_types.end();
|
104
|
+
}
|
75
105
|
//! The concurrent queue
|
76
106
|
eviction_queue_t q;
|
77
107
|
|
@@ -199,16 +229,16 @@ void EvictionQueue::PurgeIteration(const idx_t purge_size) {
|
|
199
229
|
|
200
230
|
BufferPool::BufferPool(idx_t maximum_memory, bool track_eviction_timestamps,
|
201
231
|
idx_t allocator_bulk_deallocation_flush_threshold)
|
202
|
-
: eviction_queue_sizes({
|
232
|
+
: eviction_queue_sizes({BLOCK_AND_EXTERNAL_FILE_QUEUE_SIZE, MANAGED_BUFFER_QUEUE_SIZE, TINY_BUFFER_QUEUE_SIZE}),
|
203
233
|
maximum_memory(maximum_memory),
|
204
234
|
allocator_bulk_deallocation_flush_threshold(allocator_bulk_deallocation_flush_threshold),
|
205
235
|
track_eviction_timestamps(track_eviction_timestamps),
|
206
236
|
temporary_memory_manager(make_uniq<TemporaryMemoryManager>()) {
|
207
|
-
for (
|
208
|
-
const auto
|
209
|
-
const auto &type_queue_size = eviction_queue_sizes[
|
237
|
+
for (idx_t queue_type_idx = 0; queue_type_idx < EVICTION_QUEUE_TYPES; queue_type_idx++) {
|
238
|
+
const auto types = EvictionQueueTypeIdxToFileBufferTypes(queue_type_idx);
|
239
|
+
const auto &type_queue_size = eviction_queue_sizes[queue_type_idx];
|
210
240
|
for (idx_t queue_idx = 0; queue_idx < type_queue_size; queue_idx++) {
|
211
|
-
queues.push_back(make_uniq<EvictionQueue>(
|
241
|
+
queues.push_back(make_uniq<EvictionQueue>(types));
|
212
242
|
}
|
213
243
|
}
|
214
244
|
}
|
@@ -243,23 +273,19 @@ EvictionQueue &BufferPool::GetEvictionQueueForBlockHandle(const BlockHandle &han
|
|
243
273
|
|
244
274
|
// Get offset into eviction queues for this FileBufferType
|
245
275
|
idx_t queue_index = 0;
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
break;
|
250
|
-
}
|
251
|
-
const auto &type_queue_size = eviction_queue_sizes[type_idx];
|
252
|
-
queue_index += type_queue_size;
|
276
|
+
const auto handle_queue_type_idx = FileBufferTypeToEvictionQueueTypeIdx(handle_buffer_type);
|
277
|
+
for (idx_t type_idx = 0; type_idx < handle_queue_type_idx; type_idx++) {
|
278
|
+
queue_index += eviction_queue_sizes[type_idx];
|
253
279
|
}
|
254
280
|
|
255
|
-
const auto &queue_size = eviction_queue_sizes[
|
281
|
+
const auto &queue_size = eviction_queue_sizes[handle_queue_type_idx];
|
256
282
|
// Adjust if eviction_queue_idx is set (idx == 0 -> add at back, idx >= queue_size -> add at front)
|
257
283
|
auto eviction_queue_idx = handle.GetEvictionQueueIndex();
|
258
284
|
if (eviction_queue_idx < queue_size) {
|
259
285
|
queue_index += queue_size - eviction_queue_idx - 1;
|
260
286
|
}
|
261
287
|
|
262
|
-
D_ASSERT(queues[queue_index]->
|
288
|
+
D_ASSERT(queues[queue_index]->HasFileBufferType(handle_buffer_type));
|
263
289
|
return *queues[queue_index];
|
264
290
|
}
|
265
291
|
|
@@ -113,7 +113,7 @@ BufferHandle CachingFileHandle::Read(data_ptr_t &buffer, idx_t &nr_bytes) {
|
|
113
113
|
|
114
114
|
// If we can't seek, we can't use the cache for these calls,
|
115
115
|
// because we won't be able to seek over any parts we skipped by reading from the cache
|
116
|
-
if (!external_file_cache.IsEnabled() || !
|
116
|
+
if (!external_file_cache.IsEnabled() || !CanSeek()) {
|
117
117
|
result = external_file_cache.GetBufferManager().Allocate(MemoryTag::EXTERNAL_FILE_CACHE, nr_bytes);
|
118
118
|
buffer = result.Ptr();
|
119
119
|
nr_bytes = NumericCast<idx_t>(GetFileHandle().Read(buffer, nr_bytes));
|
@@ -285,11 +285,16 @@ BufferHandle CachingFileHandle::TryInsertFileRange(BufferHandle &pin, data_ptr_t
|
|
285
285
|
auto &ranges = cached_file.Ranges(guard);
|
286
286
|
|
287
287
|
// Start at lower_bound (first range with location not less than location of newly created range)
|
288
|
+
const auto this_end = location + nr_bytes;
|
288
289
|
auto it = ranges.lower_bound(location);
|
289
290
|
if (it != ranges.begin()) {
|
290
291
|
--it;
|
291
292
|
}
|
292
293
|
while (it != ranges.end()) {
|
294
|
+
if (it->second->location >= this_end) {
|
295
|
+
// We're past the requested location
|
296
|
+
break;
|
297
|
+
}
|
293
298
|
if (it->second->GetOverlap(*new_file_range) == CachedFileRangeOverlap::FULL) {
|
294
299
|
// Another thread has read a range that fully contains the requested range in the meantime
|
295
300
|
auto other_pin = TryReadFromFileRange(guard, *it->second, buffer, nr_bytes, location);
|
@@ -300,11 +305,9 @@ BufferHandle CachingFileHandle::TryInsertFileRange(BufferHandle &pin, data_ptr_t
|
|
300
305
|
continue;
|
301
306
|
}
|
302
307
|
// Check if the new range overlaps with a cached one
|
303
|
-
bool break_loop = false;
|
304
308
|
switch (new_file_range->GetOverlap(*it->second)) {
|
305
309
|
case CachedFileRangeOverlap::NONE:
|
306
|
-
|
307
|
-
break;
|
310
|
+
break; // No overlap, still useful
|
308
311
|
case CachedFileRangeOverlap::PARTIAL:
|
309
312
|
break; // The newly created range does not fully contain this range, so it is still useful
|
310
313
|
case CachedFileRangeOverlap::FULL:
|
@@ -315,9 +318,6 @@ BufferHandle CachingFileHandle::TryInsertFileRange(BufferHandle &pin, data_ptr_t
|
|
315
318
|
default:
|
316
319
|
throw InternalException("Unknown CachedFileRangeOverlap");
|
317
320
|
}
|
318
|
-
if (break_loop) {
|
319
|
-
break;
|
320
|
-
}
|
321
321
|
|
322
322
|
++it;
|
323
323
|
}
|
@@ -168,9 +168,10 @@ shared_ptr<BlockHandle> StandardBufferManager::RegisterMemory(MemoryTag tag, idx
|
|
168
168
|
StringUtil::BytesToHumanReadableString(alloc_size));
|
169
169
|
|
170
170
|
// Create a new buffer and a block to hold the buffer.
|
171
|
-
auto
|
172
|
-
|
173
|
-
|
171
|
+
const auto file_buffer_type =
|
172
|
+
tag == MemoryTag::EXTERNAL_FILE_CACHE ? FileBufferType::EXTERNAL_FILE : FileBufferType::MANAGED_BUFFER;
|
173
|
+
auto buffer = ConstructManagedBuffer(block_size, block_header_size, std::move(reusable_buffer), file_buffer_type);
|
174
|
+
const auto destroy_buffer_upon = can_destroy ? DestroyBufferUpon::EVICTION : DestroyBufferUpon::BLOCK;
|
174
175
|
return make_shared_ptr<BlockHandle>(*temp_block_manager, ++temporary_id, tag, std::move(buffer),
|
175
176
|
destroy_buffer_upon, alloc_size, std::move(res));
|
176
177
|
}
|
@@ -80,6 +80,7 @@ static const StorageVersionInfo storage_version_info[] = {
|
|
80
80
|
{"v1.2.1", 65},
|
81
81
|
{"v1.2.2", 65},
|
82
82
|
{"v1.3.0", 66},
|
83
|
+
{"v1.3.1", 66},
|
83
84
|
{nullptr, 0}
|
84
85
|
};
|
85
86
|
// END OF STORAGE VERSION INFO
|
@@ -102,6 +103,7 @@ static const SerializationVersionInfo serialization_version_info[] = {
|
|
102
103
|
{"v1.2.1", 4},
|
103
104
|
{"v1.2.2", 4},
|
104
105
|
{"v1.3.0", 5},
|
106
|
+
{"v1.3.1", 5},
|
105
107
|
{"latest", 5},
|
106
108
|
{nullptr, 0}
|
107
109
|
};
|
@@ -816,19 +816,24 @@ void WriteAheadLogDeserializer::ReplayDelete() {
|
|
816
816
|
return;
|
817
817
|
}
|
818
818
|
if (!state.current_table) {
|
819
|
-
throw
|
819
|
+
throw SerializationException("delete without a table");
|
820
820
|
}
|
821
821
|
|
822
822
|
D_ASSERT(chunk.ColumnCount() == 1 && chunk.data[0].GetType() == LogicalType::ROW_TYPE);
|
823
823
|
row_t row_ids[1];
|
824
824
|
Vector row_identifiers(LogicalType::ROW_TYPE, data_ptr_cast(row_ids));
|
825
|
-
|
826
825
|
auto source_ids = FlatVector::GetData<row_t>(chunk.data[0]);
|
827
|
-
|
826
|
+
|
827
|
+
// Delete the row IDs from the current table.
|
828
|
+
auto &storage = state.current_table->GetStorage();
|
829
|
+
auto total_rows = storage.GetTotalRows();
|
828
830
|
TableDeleteState delete_state;
|
829
831
|
for (idx_t i = 0; i < chunk.size(); i++) {
|
832
|
+
if (source_ids[i] >= UnsafeNumericCast<row_t>(total_rows)) {
|
833
|
+
throw SerializationException("invalid row ID delete in WAL");
|
834
|
+
}
|
830
835
|
row_ids[0] = source_ids[i];
|
831
|
-
|
836
|
+
storage.Delete(delete_state, context, row_identifiers, 1);
|
832
837
|
}
|
833
838
|
}
|
834
839
|
|
@@ -34,6 +34,7 @@
|
|
34
34
|
#define FMT_FORMAT_H_
|
35
35
|
|
36
36
|
#include "duckdb/common/exception.hpp"
|
37
|
+
#include "duckdb/original/std/memory.hpp"
|
37
38
|
#include "fmt/core.h"
|
38
39
|
|
39
40
|
#include <algorithm>
|
@@ -44,6 +45,12 @@
|
|
44
45
|
#include <memory>
|
45
46
|
#include <stdexcept>
|
46
47
|
|
48
|
+
#ifndef DUCKDB_BASE_STD
|
49
|
+
namespace duckdb_base_std {
|
50
|
+
using ::std::unique_ptr;
|
51
|
+
}
|
52
|
+
#endif
|
53
|
+
|
47
54
|
#ifdef __clang__
|
48
55
|
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
|
49
56
|
#else
|
@@ -3052,7 +3059,7 @@ typename Context::iterator vformat_to(
|
|
3052
3059
|
// Example:
|
3053
3060
|
// auto s = format("{}", ptr(p));
|
3054
3061
|
template <typename T> inline const void* ptr(const T* p) { return p; }
|
3055
|
-
template <typename T> inline const void* ptr(const
|
3062
|
+
template <typename T> inline const void* ptr(const duckdb_base_std::unique_ptr<T>& p) {
|
3056
3063
|
return p.get();
|
3057
3064
|
}
|
3058
3065
|
template <typename T> inline const void* ptr(const std::shared_ptr<T>& p) {
|
@@ -16,6 +16,7 @@
|
|
16
16
|
//
|
17
17
|
// You can contact the authors via the FSST source repository : https://github.com/cwida/fsst
|
18
18
|
#include "libfsst.hpp"
|
19
|
+
#include "duckdb/common/unique_ptr.hpp"
|
19
20
|
|
20
21
|
Symbol concat(Symbol a, Symbol b) {
|
21
22
|
Symbol s;
|
@@ -320,7 +321,7 @@ static inline size_t compressBulk(SymbolTable &symbolTable, size_t nlines, size_
|
|
320
321
|
|
321
322
|
// quickly select a uniformly random set of lines such that we have between [FSST_SAMPLETARGET,FSST_SAMPLEMAXSZ) string bytes
|
322
323
|
vector<u8*> makeSample(u8* sampleBuf, u8* strIn[], size_t *lenIn, size_t nlines,
|
323
|
-
unique_ptr<vector<size_t>>& sample_len_out) {
|
324
|
+
duckdb::unique_ptr<vector<size_t>>& sample_len_out) {
|
324
325
|
size_t totSize = 0;
|
325
326
|
vector<u8*> sample;
|
326
327
|
|
@@ -333,7 +334,7 @@ vector<u8*> makeSample(u8* sampleBuf, u8* strIn[], size_t *lenIn, size_t nlines,
|
|
333
334
|
size_t sampleRnd = FSST_HASH(4637947);
|
334
335
|
u8* sampleLim = sampleBuf + FSST_SAMPLETARGET;
|
335
336
|
|
336
|
-
sample_len_out = unique_ptr<vector<size_t>>(new vector<size_t>());
|
337
|
+
sample_len_out = duckdb::unique_ptr<vector<size_t>>(new vector<size_t>());
|
337
338
|
sample_len_out->reserve(nlines + FSST_SAMPLEMAXSZ/FSST_SAMPLELINE);
|
338
339
|
|
339
340
|
// This fails if we have a lot of small strings and a few big ones?
|
@@ -363,7 +364,7 @@ vector<u8*> makeSample(u8* sampleBuf, u8* strIn[], size_t *lenIn, size_t nlines,
|
|
363
364
|
|
364
365
|
extern "C" duckdb_fsst_encoder_t* duckdb_fsst_create(size_t n, size_t lenIn[], u8 *strIn[], int zeroTerminated) {
|
365
366
|
u8* sampleBuf = new u8[FSST_SAMPLEMAXSZ];
|
366
|
-
unique_ptr<vector<size_t>> sample_sizes;
|
367
|
+
duckdb::unique_ptr<vector<size_t>> sample_sizes;
|
367
368
|
vector<u8*> sample = makeSample(sampleBuf, strIn, lenIn, n?n:1, sample_sizes); // careful handling of input to get a right-size and representative sample
|
368
369
|
Encoder *encoder = new Encoder();
|
369
370
|
size_t* sampleLen = sample_sizes ? sample_sizes->data() : &lenIn[0];
|
@@ -13,6 +13,9 @@
|
|
13
13
|
|
14
14
|
#define CPPHTTPLIB_VERSION "0.14.3"
|
15
15
|
|
16
|
+
#include "duckdb/original/std/memory.hpp"
|
17
|
+
#include "duckdb/common/string.hpp"
|
18
|
+
|
16
19
|
/*
|
17
20
|
* Configuration
|
18
21
|
*/
|
@@ -317,16 +320,16 @@ namespace detail {
|
|
317
320
|
*/
|
318
321
|
|
319
322
|
template <class T, class... Args>
|
320
|
-
typename std::enable_if<!std::is_array<T>::value,
|
323
|
+
typename std::enable_if<!std::is_array<T>::value, duckdb::unique_ptr<T>>::type
|
321
324
|
make_unique(Args &&...args) {
|
322
|
-
return
|
325
|
+
return duckdb::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
323
326
|
}
|
324
327
|
|
325
328
|
template <class T>
|
326
|
-
typename std::enable_if<std::is_array<T>::value,
|
329
|
+
typename std::enable_if<std::is_array<T>::value, duckdb::unique_ptr<T>>::type
|
327
330
|
make_unique(std::size_t n) {
|
328
331
|
typedef typename std::remove_extent<T>::type RT;
|
329
|
-
return
|
332
|
+
return duckdb::unique_ptr<T>(new RT[n]);
|
330
333
|
}
|
331
334
|
|
332
335
|
struct ci {
|
@@ -947,7 +950,7 @@ private:
|
|
947
950
|
using HandlersForContentReader =
|
948
951
|
std::vector<std::pair<Regex, HandlerWithContentReader>>;
|
949
952
|
|
950
|
-
static
|
953
|
+
static duckdb::unique_ptr<detail::MatcherBase>
|
951
954
|
make_matcher(const std::string &pattern);
|
952
955
|
|
953
956
|
socket_t create_server_socket(const std::string &host, int port,
|
@@ -1060,7 +1063,7 @@ std::ostream &operator<<(std::ostream &os, const Error &obj);
|
|
1060
1063
|
class Result {
|
1061
1064
|
public:
|
1062
1065
|
Result() = default;
|
1063
|
-
Result(
|
1066
|
+
Result(duckdb::unique_ptr<Response> &&res, Error err,
|
1064
1067
|
Headers &&request_headers = Headers{})
|
1065
1068
|
: res_(std::move(res)), err_(err),
|
1066
1069
|
request_headers_(std::move(request_headers)) {}
|
@@ -1087,7 +1090,7 @@ public:
|
|
1087
1090
|
size_t get_request_header_value_count(const std::string &key) const;
|
1088
1091
|
|
1089
1092
|
private:
|
1090
|
-
|
1093
|
+
duckdb::unique_ptr<Response> res_;
|
1091
1094
|
Error err_ = Error::Unknown;
|
1092
1095
|
Headers request_headers_;
|
1093
1096
|
};
|
@@ -1445,7 +1448,7 @@ private:
|
|
1445
1448
|
bool redirect(Request &req, Response &res, Error &error);
|
1446
1449
|
bool handle_request(Stream &strm, Request &req, Response &res,
|
1447
1450
|
bool close_connection, Error &error);
|
1448
|
-
|
1451
|
+
duckdb::unique_ptr<Response> send_with_content_provider(
|
1449
1452
|
Request &req, const char *body, size_t content_length,
|
1450
1453
|
ContentProvider content_provider,
|
1451
1454
|
ContentProviderWithoutLength content_provider_without_length,
|
@@ -1710,7 +1713,7 @@ public:
|
|
1710
1713
|
#endif
|
1711
1714
|
|
1712
1715
|
private:
|
1713
|
-
|
1716
|
+
duckdb::unique_ptr<ClientImpl> cli_;
|
1714
1717
|
|
1715
1718
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
1716
1719
|
bool is_ssl_ = false;
|
@@ -3953,7 +3956,7 @@ bool prepare_content_receiver(T &x, int &status,
|
|
3953
3956
|
bool decompress, U callback) {
|
3954
3957
|
if (decompress) {
|
3955
3958
|
std::string encoding = x.get_header_value("Content-Encoding");
|
3956
|
-
|
3959
|
+
duckdb::unique_ptr<decompressor> decompressor;
|
3957
3960
|
|
3958
3961
|
if (encoding == "gzip" || encoding == "deflate") {
|
3959
3962
|
#ifdef CPPHTTPLIB_ZLIB_SUPPORT
|
@@ -4860,7 +4863,7 @@ inline bool has_crlf(const std::string &s) {
|
|
4860
4863
|
|
4861
4864
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
4862
4865
|
inline std::string message_digest(const std::string &s, const EVP_MD *algo) {
|
4863
|
-
auto context =
|
4866
|
+
auto context = duckdb::unique_ptr<EVP_MD_CTX, decltype(&EVP_MD_CTX_free)>(
|
4864
4867
|
EVP_MD_CTX_new(), EVP_MD_CTX_free);
|
4865
4868
|
|
4866
4869
|
unsigned int hash_length = 0;
|
@@ -4870,7 +4873,7 @@ inline std::string message_digest(const std::string &s, const EVP_MD *algo) {
|
|
4870
4873
|
EVP_DigestUpdate(context.get(), s.c_str(), s.size());
|
4871
4874
|
EVP_DigestFinal_ex(context.get(), hash, &hash_length);
|
4872
4875
|
|
4873
|
-
|
4876
|
+
duckdb::stringstream ss;
|
4874
4877
|
for (auto i = 0u; i < hash_length; ++i) {
|
4875
4878
|
ss << std::hex << std::setw(2) << std::setfill('0')
|
4876
4879
|
<< static_cast<unsigned int>(hash[i]);
|
@@ -4924,7 +4927,7 @@ inline bool load_system_certs_on_windows(X509_STORE *store) {
|
|
4924
4927
|
#if TARGET_OS_OSX
|
4925
4928
|
template <typename T>
|
4926
4929
|
using CFObjectPtr =
|
4927
|
-
|
4930
|
+
duckdb::unique_ptr<typename std::remove_pointer<T>::type, void (*)(CFTypeRef)>;
|
4928
4931
|
|
4929
4932
|
inline void cf_object_ptr_deleter(CFTypeRef obj) {
|
4930
4933
|
if (obj) { CFRelease(obj); }
|
@@ -5038,7 +5041,7 @@ inline std::pair<std::string, std::string> make_digest_authentication_header(
|
|
5038
5041
|
const std::string &password, bool is_proxy = false) {
|
5039
5042
|
std::string nc;
|
5040
5043
|
{
|
5041
|
-
|
5044
|
+
duckdb::stringstream ss;
|
5042
5045
|
ss << std::setfill('0') << std::setw(8) << std::hex << cnonce_count;
|
5043
5046
|
nc = ss.str();
|
5044
5047
|
}
|
@@ -5627,7 +5630,7 @@ inline Server::Server()
|
|
5627
5630
|
|
5628
5631
|
inline Server::~Server() = default;
|
5629
5632
|
|
5630
|
-
inline
|
5633
|
+
inline duckdb::unique_ptr<detail::MatcherBase>
|
5631
5634
|
Server::make_matcher(const std::string &pattern) {
|
5632
5635
|
if (pattern.find("/:") != std::string::npos) {
|
5633
5636
|
return detail::make_unique<detail::PathParamsMatcher>(pattern);
|
@@ -5965,7 +5968,7 @@ inline bool Server::write_response_core(Stream &strm, bool close_connection,
|
|
5965
5968
|
if (close_connection || req.get_header_value("Connection") == "close") {
|
5966
5969
|
res.set_header("Connection", "close");
|
5967
5970
|
} else {
|
5968
|
-
|
5971
|
+
duckdb::stringstream ss;
|
5969
5972
|
ss << "timeout=" << keep_alive_timeout_sec_
|
5970
5973
|
<< ", max=" << keep_alive_max_count_;
|
5971
5974
|
res.set_header("Keep-Alive", ss.str());
|
@@ -6053,7 +6056,7 @@ Server::write_content_with_provider(Stream &strm, const Request &req,
|
|
6053
6056
|
if (res.is_chunked_content_provider_) {
|
6054
6057
|
auto type = detail::encoding_type(req, res);
|
6055
6058
|
|
6056
|
-
|
6059
|
+
duckdb::unique_ptr<detail::compressor> compressor;
|
6057
6060
|
if (type == detail::EncodingType::Gzip) {
|
6058
6061
|
#ifdef CPPHTTPLIB_ZLIB_SUPPORT
|
6059
6062
|
compressor = detail::make_unique<detail::gzip_compressor>();
|
@@ -6194,7 +6197,7 @@ inline bool Server::handle_file_request(const Request &req, Response &res,
|
|
6194
6197
|
res.set_header(kv.first, kv.second);
|
6195
6198
|
}
|
6196
6199
|
|
6197
|
-
auto mm =
|
6200
|
+
auto mm = duckdb::make_shared_ptr<detail::mmap>(path.c_str());
|
6198
6201
|
if (!mm->is_open()) { return false; }
|
6199
6202
|
|
6200
6203
|
res.set_content_provider(
|
@@ -6266,7 +6269,7 @@ inline bool Server::listen_internal() {
|
|
6266
6269
|
auto se = detail::scope_exit([&]() { is_running_ = false; });
|
6267
6270
|
|
6268
6271
|
{
|
6269
|
-
|
6272
|
+
duckdb::unique_ptr<TaskQueue> task_queue(new_task_queue());
|
6270
6273
|
|
6271
6274
|
while (svr_sock_ != INVALID_SOCKET) {
|
6272
6275
|
#ifndef _WIN32
|
@@ -6510,7 +6513,7 @@ inline void Server::apply_ranges(const Request &req, Response &res,
|
|
6510
6513
|
}
|
6511
6514
|
|
6512
6515
|
if (type != detail::EncodingType::None) {
|
6513
|
-
|
6516
|
+
duckdb::unique_ptr<detail::compressor> compressor;
|
6514
6517
|
std::string content_encoding;
|
6515
6518
|
|
6516
6519
|
if (type == detail::EncodingType::Gzip) {
|
@@ -7127,7 +7130,7 @@ inline bool ClientImpl::write_content_with_provider(Stream &strm,
|
|
7127
7130
|
|
7128
7131
|
if (req.is_chunked_content_provider_) {
|
7129
7132
|
// TODO: Brotli support
|
7130
|
-
|
7133
|
+
duckdb::unique_ptr<detail::compressor> compressor;
|
7131
7134
|
#ifdef CPPHTTPLIB_ZLIB_SUPPORT
|
7132
7135
|
if (compress_) {
|
7133
7136
|
compressor = detail::make_unique<detail::gzip_compressor>();
|
@@ -7263,7 +7266,7 @@ inline bool ClientImpl::write_request(Stream &strm, Request &req,
|
|
7263
7266
|
return true;
|
7264
7267
|
}
|
7265
7268
|
|
7266
|
-
inline
|
7269
|
+
inline duckdb::unique_ptr<Response> ClientImpl::send_with_content_provider(
|
7267
7270
|
Request &req, const char *body, size_t content_length,
|
7268
7271
|
ContentProvider content_provider,
|
7269
7272
|
ContentProviderWithoutLength content_provider_without_length,
|
@@ -40,6 +40,10 @@
|
|
40
40
|
|
41
41
|
namespace duckdb_hll {
|
42
42
|
|
43
|
+
static bool CharacterIsSpace(char c) {
|
44
|
+
return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
|
45
|
+
}
|
46
|
+
|
43
47
|
static inline int sdsHdrSize(char type) {
|
44
48
|
switch(type&SDS_TYPE_MASK) {
|
45
49
|
case SDS_TYPE_5:
|
@@ -956,7 +960,7 @@ sds *sdssplitargs(const char *line, int *argc) {
|
|
956
960
|
*argc = 0;
|
957
961
|
while(1) {
|
958
962
|
/* skip blanks */
|
959
|
-
while(*p &&
|
963
|
+
while(*p && CharacterIsSpace(*p)) p++;
|
960
964
|
if (*p) {
|
961
965
|
/* get a token */
|
962
966
|
int inq=0; /* set to 1 if we are in "quotes" */
|
@@ -992,7 +996,7 @@ sds *sdssplitargs(const char *line, int *argc) {
|
|
992
996
|
} else if (*p == '"') {
|
993
997
|
/* closing quote must be followed by a space or
|
994
998
|
* nothing at all. */
|
995
|
-
if (*(p+1) && !
|
999
|
+
if (*(p+1) && !CharacterIsSpace(*(p+1))) goto err;
|
996
1000
|
done=1;
|
997
1001
|
} else if (!*p) {
|
998
1002
|
/* unterminated quotes */
|
@@ -1007,7 +1011,7 @@ sds *sdssplitargs(const char *line, int *argc) {
|
|
1007
1011
|
} else if (*p == '\'') {
|
1008
1012
|
/* closing quote must be followed by a space or
|
1009
1013
|
* nothing at all. */
|
1010
|
-
if (*(p+1) && !
|
1014
|
+
if (*(p+1) && !CharacterIsSpace(*(p+1))) goto err;
|
1011
1015
|
done=1;
|
1012
1016
|
} else if (!*p) {
|
1013
1017
|
/* unterminated quotes */
|
@@ -27,6 +27,13 @@
|
|
27
27
|
#include <memory>
|
28
28
|
#include "parser/gramparse.hpp"
|
29
29
|
|
30
|
+
#define DUCKDB_BASE_STD
|
31
|
+
|
32
|
+
namespace duckdb_base_std {
|
33
|
+
using ::std::unique_ptr;
|
34
|
+
} // namespace duckdb_base_std
|
35
|
+
|
36
|
+
|
30
37
|
#include "parser/kwlist.hpp"
|
31
38
|
|
32
39
|
namespace duckdb_libpgquery {
|
@@ -52,7 +59,7 @@ const PGScanKeyword *ScanKeywordLookup(const char *text, const PGScanKeyword *ke
|
|
52
59
|
const PGScanKeyword *high;
|
53
60
|
|
54
61
|
len = strlen(text);
|
55
|
-
auto data =
|
62
|
+
auto data = duckdb_base_std::unique_ptr<char[]>(new char[len + 1]);
|
56
63
|
auto word = data.get();
|
57
64
|
/* We assume all keywords are shorter than NAMEDATALEN. */
|
58
65
|
|
@@ -24,9 +24,15 @@
|
|
24
24
|
#include <memory>
|
25
25
|
#include <string>
|
26
26
|
#include <vector>
|
27
|
-
|
28
27
|
#include "re2/re2.h"
|
29
28
|
|
29
|
+
#ifndef DUCKDB_BASE_STD
|
30
|
+
namespace duckdb_base_std {
|
31
|
+
using ::std::unique_ptr;
|
32
|
+
} // namespace duckdb_base_std
|
33
|
+
#endif
|
34
|
+
|
35
|
+
|
30
36
|
namespace duckdb_re2 {
|
31
37
|
|
32
38
|
class PrefilterTree;
|
@@ -106,7 +112,7 @@ class FilteredRE2 {
|
|
106
112
|
bool compiled_;
|
107
113
|
|
108
114
|
// An AND-OR tree of string atoms used for filtering regexps.
|
109
|
-
|
115
|
+
duckdb_base_std::unique_ptr<PrefilterTree> prefilter_tree_;
|
110
116
|
};
|
111
117
|
|
112
118
|
} // namespace re2
|
@@ -8,6 +8,12 @@
|
|
8
8
|
#include <memory>
|
9
9
|
#include <type_traits>
|
10
10
|
|
11
|
+
#ifndef DUCKDB_BASE_STD
|
12
|
+
namespace duckdb_base_std {
|
13
|
+
using ::std::unique_ptr;
|
14
|
+
} // namespace duckdb_base_std
|
15
|
+
#endif
|
16
|
+
|
11
17
|
namespace duckdb_re2 {
|
12
18
|
|
13
19
|
template <typename T>
|
@@ -47,7 +53,7 @@ class PODArray {
|
|
47
53
|
int len_;
|
48
54
|
};
|
49
55
|
|
50
|
-
|
56
|
+
duckdb_base_std::unique_ptr<T[], Deleter> ptr_;
|
51
57
|
};
|
52
58
|
|
53
59
|
} // namespace re2
|
@@ -36,6 +36,10 @@
|
|
36
36
|
|
37
37
|
namespace duckdb_re2 {
|
38
38
|
|
39
|
+
static bool CharacterIsSpace(char c) {
|
40
|
+
return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
|
41
|
+
}
|
42
|
+
|
39
43
|
// Controls the maximum count permitted by GlobalReplace(); -1 is unlimited.
|
40
44
|
static int maximum_global_replace_count = -1;
|
41
45
|
|
@@ -1121,13 +1125,13 @@ static const char* TerminateNumber(char* buf, size_t nbuf, const char* str,
|
|
1121
1125
|
size_t* np, bool accept_spaces) {
|
1122
1126
|
size_t n = *np;
|
1123
1127
|
if (n == 0) return "";
|
1124
|
-
if (n > 0 &&
|
1128
|
+
if (n > 0 && CharacterIsSpace(*str)) {
|
1125
1129
|
// We are less forgiving than the strtoxxx() routines and do not
|
1126
1130
|
// allow leading spaces. We do allow leading spaces for floats.
|
1127
1131
|
if (!accept_spaces) {
|
1128
1132
|
return "";
|
1129
1133
|
}
|
1130
|
-
while (n > 0 &&
|
1134
|
+
while (n > 0 && CharacterIsSpace(*str)) {
|
1131
1135
|
n--;
|
1132
1136
|
str++;
|
1133
1137
|
}
|