duckdb 0.7.2-dev3402.0 → 0.7.2-dev3515.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/package.json +2 -2
- package/src/duckdb/extension/json/json_functions/json_create.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_functions.cpp +1 -0
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +4 -4
- package/src/duckdb/src/common/compressed_file_system.cpp +2 -2
- package/src/duckdb/src/common/file_system.cpp +2 -2
- package/src/duckdb/src/common/row_operations/row_gather.cpp +2 -2
- package/src/duckdb/src/common/serializer/binary_deserializer.cpp +1 -1
- package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +1 -1
- package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +1 -1
- package/src/duckdb/src/common/serializer/buffered_serializer.cpp +4 -3
- package/src/duckdb/src/common/serializer.cpp +1 -1
- package/src/duckdb/src/common/sort/radix_sort.cpp +5 -5
- package/src/duckdb/src/common/string_util.cpp +2 -2
- package/src/duckdb/src/common/types/bit.cpp +2 -2
- package/src/duckdb/src/common/types/blob.cpp +2 -2
- package/src/duckdb/src/common/types/data_chunk.cpp +2 -2
- package/src/duckdb/src/common/types/date.cpp +1 -1
- package/src/duckdb/src/common/types/decimal.cpp +2 -2
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +14 -2
- package/src/duckdb/src/common/types/selection_vector.cpp +1 -1
- package/src/duckdb/src/common/types/time.cpp +1 -1
- package/src/duckdb/src/common/types/vector.cpp +7 -7
- package/src/duckdb/src/common/virtual_file_system.cpp +4 -0
- package/src/duckdb/src/common/windows_util.cpp +2 -2
- package/src/duckdb/src/core_functions/aggregate/distributive/string_agg.cpp +6 -3
- package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +2 -5
- package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +10 -7
- package/src/duckdb/src/core_functions/scalar/string/printf.cpp +1 -1
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +1 -1
- package/src/duckdb/src/execution/expression_executor/execute_between.cpp +3 -0
- package/src/duckdb/src/execution/join_hashtable.cpp +3 -3
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +2 -2
- package/src/duckdb/src/execution/operator/join/outer_join_marker.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +2 -0
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -7
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +4 -41
- package/src/duckdb/src/execution/operator/persistent/csv_file_handle.cpp +158 -0
- package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +1 -1
- package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +2 -2
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +3 -4
- package/src/duckdb/src/execution/window_segment_tree.cpp +1 -1
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +1 -1
- package/src/duckdb/src/function/scalar/strftime_format.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/concat.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/like.cpp +2 -2
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -5
- package/src/duckdb/src/function/table/copy_csv.cpp +1 -1
- package/src/duckdb/src/function/table/read_csv.cpp +43 -35
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/compressed_file_system.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/constants.hpp +0 -5
- package/src/duckdb/src/include/duckdb/common/helper.hpp +22 -9
- package/src/duckdb/src/include/duckdb/common/memory_safety.hpp +15 -0
- package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_serializer.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +2 -3
- package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +11 -6
- package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +4 -4
- package/src/duckdb/src/include/duckdb/common/unique_ptr.hpp +53 -22
- package/src/duckdb/src/include/duckdb/common/vector.hpp +5 -2
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +4 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/outer_join_marker.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_range_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +0 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +27 -127
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/perfect_aggregate_hashtable.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +2 -4
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +3 -3
- package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +5 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/buffer/buffer_handle.hpp +9 -2
- package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table_storage_info.hpp +2 -0
- package/src/duckdb/src/main/client_context.cpp +1 -0
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -1
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +25 -1
- package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +5 -5
- package/src/duckdb/src/optimizer/unnest_rewriter.cpp +14 -6
- package/src/duckdb/src/parser/statement/insert_statement.cpp +4 -1
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +10 -0
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +64 -42
- package/src/duckdb/src/storage/arena_allocator.cpp +1 -1
- package/src/duckdb/src/storage/buffer/buffer_handle.cpp +2 -11
- package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +1 -1
- package/src/duckdb/src/storage/compression/string_uncompressed.cpp +2 -2
- package/src/duckdb/src/storage/statistics/list_stats.cpp +1 -1
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +1 -1
- package/src/duckdb/src/storage/table/row_group.cpp +2 -2
- package/src/duckdb/src/storage/table/row_group_collection.cpp +41 -25
- package/src/duckdb/src/storage/table/update_segment.cpp +7 -6
- package/src/duckdb/third_party/fsst/libfsst.cpp +1 -2
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +9 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +13 -12
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +2 -1
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +13050 -12885
- package/src/duckdb/ub_src_execution_operator_persistent.cpp +2 -0
- package/src/statement.cpp +15 -13
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "duckdb",
|
3
3
|
"main": "./lib/duckdb.js",
|
4
4
|
"types": "./lib/duckdb.d.ts",
|
5
|
-
"version": "0.7.2-
|
5
|
+
"version": "0.7.2-dev3515.0",
|
6
6
|
"description": "DuckDB node.js API",
|
7
7
|
"gypfile": true,
|
8
8
|
"dependencies": {
|
@@ -19,7 +19,7 @@
|
|
19
19
|
"install": "node-pre-gyp install --fallback-to-build",
|
20
20
|
"pretest": "node test/support/createdb.js",
|
21
21
|
"test": "mocha -R spec --timeout 480000 --expose-gc",
|
22
|
-
"test-path": "mocha -R spec --timeout 480000 --exclude 'test/*.ts'",
|
22
|
+
"test-path": "mocha -R spec --timeout 480000 --expose-gc --exclude 'test/*.ts'",
|
23
23
|
"pack": "node-pre-gyp package"
|
24
24
|
},
|
25
25
|
"directories": {
|
@@ -721,9 +721,9 @@ TableStorageInfo DuckTableEntry::GetStorageInfo(ClientContext &context) {
|
|
721
721
|
storage->info->indexes.Scan([&](Index &index) {
|
722
722
|
IndexInfo info;
|
723
723
|
info.is_primary = index.IsPrimary();
|
724
|
-
info.is_unique = index.IsUnique();
|
724
|
+
info.is_unique = index.IsUnique() || info.is_primary;
|
725
725
|
info.is_foreign = index.IsForeign();
|
726
|
-
|
726
|
+
info.column_set = index.column_id_set;
|
727
727
|
result.index_info.push_back(std::move(info));
|
728
728
|
return false;
|
729
729
|
});
|
@@ -621,7 +621,7 @@ void CatalogSet::Undo(CatalogEntry &entry) {
|
|
621
621
|
auto &dependency_manager = catalog.GetDependencyManager();
|
622
622
|
dependency_manager.EraseObject(to_be_removed_node);
|
623
623
|
}
|
624
|
-
if (entry.name
|
624
|
+
if (!StringUtil::CIEquals(entry.name, to_be_removed_node.name)) {
|
625
625
|
// rename: clean up the new name when the rename is rolled back
|
626
626
|
auto removed_entry = mapping.find(to_be_removed_node.name);
|
627
627
|
if (removed_entry->second->child) {
|
@@ -92,6 +92,7 @@ static DefaultMacro internal_macros[] = {
|
|
92
92
|
{DEFAULT_SCHEMA, "array_pop_front", {"arr", nullptr}, "arr[2:]"},
|
93
93
|
{DEFAULT_SCHEMA, "array_push_back", {"arr", "e", nullptr}, "list_concat(arr, list_value(e))"},
|
94
94
|
{DEFAULT_SCHEMA, "array_push_front", {"arr", "e", nullptr}, "list_concat(list_value(e), arr)"},
|
95
|
+
{DEFAULT_SCHEMA, "array_to_string", {"arr", "sep", nullptr}, "list_aggr(arr, 'string_agg', sep)"},
|
95
96
|
{DEFAULT_SCHEMA, "generate_subscripts", {"arr", "dim", nullptr}, "unnest(generate_series(1, array_length(arr, dim)))"},
|
96
97
|
{DEFAULT_SCHEMA, "fdiv", {"x", "y", nullptr}, "floor(x/y)"},
|
97
98
|
{DEFAULT_SCHEMA, "fmod", {"x", "y", nullptr}, "(x-y*floor(x/y))"},
|
@@ -33,7 +33,7 @@ struct DuckDBArrowSchemaHolder {
|
|
33
33
|
std::list<vector<ArrowSchema>> nested_children;
|
34
34
|
std::list<vector<ArrowSchema *>> nested_children_ptr;
|
35
35
|
//! This holds strings created to represent decimal types
|
36
|
-
vector<
|
36
|
+
vector<unsafe_array_ptr<char>> owned_type_names;
|
37
37
|
};
|
38
38
|
|
39
39
|
static void ReleaseDuckDBArrowSchema(ArrowSchema *schema) {
|
@@ -131,7 +131,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
|
|
131
131
|
break;
|
132
132
|
case LogicalTypeId::TIMESTAMP_TZ: {
|
133
133
|
string format = "tsu:" + config_timezone;
|
134
|
-
|
134
|
+
auto format_ptr = make_unsafe_array<char>(format.size() + 1);
|
135
135
|
for (size_t i = 0; i < format.size(); i++) {
|
136
136
|
format_ptr[i] = format[i];
|
137
137
|
}
|
@@ -156,7 +156,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
|
|
156
156
|
uint8_t width, scale;
|
157
157
|
type.GetDecimalProperties(width, scale);
|
158
158
|
string format = "d:" + to_string(width) + "," + to_string(scale);
|
159
|
-
|
159
|
+
auto format_ptr = make_unsafe_array<char>(format.size() + 1);
|
160
160
|
for (size_t i = 0; i < format.size(); i++) {
|
161
161
|
format_ptr[i] = format[i];
|
162
162
|
}
|
@@ -204,7 +204,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
|
|
204
204
|
InitializeChild(*child.children[type_idx]);
|
205
205
|
|
206
206
|
auto &struct_col_name = child_types[type_idx].first;
|
207
|
-
|
207
|
+
auto name_ptr = make_unsafe_array<char>(struct_col_name.size() + 1);
|
208
208
|
for (size_t i = 0; i < struct_col_name.size(); i++) {
|
209
209
|
name_ptr[i] = struct_col_name[i];
|
210
210
|
}
|
@@ -19,10 +19,10 @@ void CompressedFile::Initialize(bool write) {
|
|
19
19
|
this->write = write;
|
20
20
|
stream_data.in_buf_size = compressed_fs.InBufferSize();
|
21
21
|
stream_data.out_buf_size = compressed_fs.OutBufferSize();
|
22
|
-
stream_data.in_buff =
|
22
|
+
stream_data.in_buff = make_unsafe_array<data_t>(stream_data.in_buf_size);
|
23
23
|
stream_data.in_buff_start = stream_data.in_buff.get();
|
24
24
|
stream_data.in_buff_end = stream_data.in_buff.get();
|
25
|
-
stream_data.out_buff =
|
25
|
+
stream_data.out_buff = make_unsafe_array<data_t>(stream_data.out_buf_size);
|
26
26
|
stream_data.out_buff_start = stream_data.out_buff.get();
|
27
27
|
stream_data.out_buff_end = stream_data.out_buff.get();
|
28
28
|
|
@@ -78,7 +78,7 @@ idx_t FileSystem::GetAvailableMemory() {
|
|
78
78
|
}
|
79
79
|
|
80
80
|
string FileSystem::GetWorkingDirectory() {
|
81
|
-
auto buffer =
|
81
|
+
auto buffer = make_unsafe_array<char>(PATH_MAX);
|
82
82
|
char *ret = getcwd(buffer.get(), PATH_MAX);
|
83
83
|
if (!ret) {
|
84
84
|
throw IOException("Could not get working directory!");
|
@@ -138,7 +138,7 @@ string FileSystem::GetWorkingDirectory() {
|
|
138
138
|
if (count == 0) {
|
139
139
|
throw IOException("Could not get working directory!");
|
140
140
|
}
|
141
|
-
auto buffer =
|
141
|
+
auto buffer = make_unsafe_array<char>(count);
|
142
142
|
idx_t ret = GetCurrentDirectory(count, buffer.get());
|
143
143
|
if (count != ret + 1) {
|
144
144
|
throw IOException("Could not get working directory!");
|
@@ -95,8 +95,8 @@ static void GatherNestedVector(Vector &rows, const SelectionVector &row_sel, Vec
|
|
95
95
|
auto ptrs = FlatVector::GetData<data_ptr_t>(rows);
|
96
96
|
|
97
97
|
// Build the gather locations
|
98
|
-
auto data_locations =
|
99
|
-
auto mask_locations =
|
98
|
+
auto data_locations = make_unsafe_array<data_ptr_t>(count);
|
99
|
+
auto mask_locations = make_unsafe_array<data_ptr_t>(count);
|
100
100
|
for (idx_t i = 0; i < count; i++) {
|
101
101
|
auto row_idx = row_sel.get_index(i);
|
102
102
|
auto row = ptrs[row_idx];
|
@@ -123,7 +123,7 @@ string BinaryDeserializer::ReadString() {
|
|
123
123
|
if (size == 0) {
|
124
124
|
return string();
|
125
125
|
}
|
126
|
-
auto buffer =
|
126
|
+
auto buffer = make_unsafe_array<data_t>(size);
|
127
127
|
ReadData(buffer.get(), size);
|
128
128
|
return string((char *)buffer.get(), size);
|
129
129
|
}
|
@@ -9,7 +9,7 @@ namespace duckdb {
|
|
9
9
|
|
10
10
|
BufferedFileReader::BufferedFileReader(FileSystem &fs, const char *path, optional_ptr<ClientContext> context,
|
11
11
|
FileLockType lock_type, optional_ptr<FileOpener> opener)
|
12
|
-
: fs(fs), data(
|
12
|
+
: fs(fs), data(make_unsafe_array<data_t>(FILE_BUFFER_SIZE)), offset(0), read_data(0), total_read(0),
|
13
13
|
context(context) {
|
14
14
|
handle = fs.OpenFile(path, FileFlags::FILE_FLAGS_READ, lock_type, FileSystem::DEFAULT_COMPRESSION, opener.get());
|
15
15
|
file_size = fs.GetFileSize(*handle);
|
@@ -9,7 +9,7 @@ namespace duckdb {
|
|
9
9
|
constexpr uint8_t BufferedFileWriter::DEFAULT_OPEN_FLAGS;
|
10
10
|
|
11
11
|
BufferedFileWriter::BufferedFileWriter(FileSystem &fs, const string &path_p, uint8_t open_flags)
|
12
|
-
: fs(fs), path(path_p), data(
|
12
|
+
: fs(fs), path(path_p), data(make_unsafe_array<data_t>(FILE_BUFFER_SIZE)), offset(0), total_written(0) {
|
13
13
|
handle = fs.OpenFile(path, open_flags, FileLockType::WRITE_LOCK);
|
14
14
|
}
|
15
15
|
|
@@ -5,10 +5,11 @@
|
|
5
5
|
namespace duckdb {
|
6
6
|
|
7
7
|
BufferedSerializer::BufferedSerializer(idx_t maximum_size)
|
8
|
-
: BufferedSerializer(
|
8
|
+
: BufferedSerializer(make_unsafe_array<data_t>(maximum_size), maximum_size) {
|
9
9
|
}
|
10
10
|
|
11
|
-
BufferedSerializer::BufferedSerializer(
|
11
|
+
BufferedSerializer::BufferedSerializer(unsafe_array_ptr<data_t> data, idx_t size)
|
12
|
+
: maximum_size(size), data(data.get()) {
|
12
13
|
blob.size = 0;
|
13
14
|
blob.data = std::move(data);
|
14
15
|
}
|
@@ -25,7 +26,7 @@ void BufferedSerializer::WriteData(const_data_ptr_t buffer, idx_t write_size) {
|
|
25
26
|
auto new_data = new data_t[maximum_size];
|
26
27
|
memcpy(new_data, data, blob.size);
|
27
28
|
data = new_data;
|
28
|
-
blob.data =
|
29
|
+
blob.data = unsafe_array_ptr<data_t>(new_data);
|
29
30
|
}
|
30
31
|
|
31
32
|
memcpy(data + blob.size, buffer, write_size);
|
@@ -17,7 +17,7 @@ static void SortTiedBlobs(BufferManager &buffer_manager, const data_ptr_t datapt
|
|
17
17
|
return;
|
18
18
|
}
|
19
19
|
// Fill pointer array for sorting
|
20
|
-
auto ptr_block =
|
20
|
+
auto ptr_block = make_unsafe_array<data_ptr_t>(end - start);
|
21
21
|
auto entry_ptrs = (data_ptr_t *)ptr_block.get();
|
22
22
|
for (idx_t i = start; i < end; i++) {
|
23
23
|
entry_ptrs[i - start] = row_ptr;
|
@@ -158,7 +158,7 @@ inline void InsertionSort(const data_ptr_t orig_ptr, const data_ptr_t temp_ptr,
|
|
158
158
|
const data_ptr_t target_ptr = swap ? orig_ptr : temp_ptr;
|
159
159
|
if (count > 1) {
|
160
160
|
const idx_t total_offset = col_offset + offset;
|
161
|
-
auto temp_val =
|
161
|
+
auto temp_val = make_unsafe_array<data_t>(row_width);
|
162
162
|
const data_ptr_t val = temp_val.get();
|
163
163
|
const auto comp_width = total_comp_width - offset;
|
164
164
|
for (idx_t i = 1; i < count; i++) {
|
@@ -249,7 +249,7 @@ void RadixSort(BufferManager &buffer_manager, const data_ptr_t &dataptr, const i
|
|
249
249
|
RadixSortLSD(buffer_manager, dataptr, count, col_offset, sort_layout.entry_size, sorting_size);
|
250
250
|
} else {
|
251
251
|
auto temp_block = buffer_manager.Allocate(MaxValue(count * sort_layout.entry_size, (idx_t)Storage::BLOCK_SIZE));
|
252
|
-
auto preallocated_array =
|
252
|
+
auto preallocated_array = make_unsafe_array<idx_t>(sorting_size * SortConstants::MSD_RADIX_LOCATIONS);
|
253
253
|
RadixSortMSD(dataptr, temp_block.Ptr(), count, col_offset, sort_layout.entry_size, sorting_size, 0,
|
254
254
|
preallocated_array.get(), false);
|
255
255
|
}
|
@@ -291,7 +291,7 @@ void LocalSortState::SortInMemory() {
|
|
291
291
|
// Radix sort and break ties until no more ties, or until all columns are sorted
|
292
292
|
idx_t sorting_size = 0;
|
293
293
|
idx_t col_offset = 0;
|
294
|
-
|
294
|
+
unsafe_array_ptr<bool> ties_ptr;
|
295
295
|
bool *ties = nullptr;
|
296
296
|
bool contains_string = false;
|
297
297
|
for (idx_t i = 0; i < sort_layout->column_count; i++) {
|
@@ -305,7 +305,7 @@ void LocalSortState::SortInMemory() {
|
|
305
305
|
if (!ties) {
|
306
306
|
// This is the first sort
|
307
307
|
RadixSort(*buffer_manager, dataptr, count, col_offset, sorting_size, *sort_layout, contains_string);
|
308
|
-
ties_ptr =
|
308
|
+
ties_ptr = make_unsafe_array<bool>(count);
|
309
309
|
ties = ties_ptr.get();
|
310
310
|
std::fill_n(ties, count - 1, true);
|
311
311
|
ties[count - 1] = false;
|
@@ -277,7 +277,7 @@ vector<string> StringUtil::TopNStrings(vector<pair<string, idx_t>> scores, idx_t
|
|
277
277
|
|
278
278
|
struct LevenshteinArray {
|
279
279
|
LevenshteinArray(idx_t len1, idx_t len2) : len1(len1) {
|
280
|
-
dist =
|
280
|
+
dist = make_unsafe_array<idx_t>(len1 * len2);
|
281
281
|
}
|
282
282
|
|
283
283
|
idx_t &Score(idx_t i, idx_t j) {
|
@@ -286,7 +286,7 @@ struct LevenshteinArray {
|
|
286
286
|
|
287
287
|
private:
|
288
288
|
idx_t len1;
|
289
|
-
|
289
|
+
unsafe_array_ptr<idx_t> dist;
|
290
290
|
|
291
291
|
idx_t GetIndex(idx_t i, idx_t j) {
|
292
292
|
return j * len1 + i;
|
@@ -78,7 +78,7 @@ void Bit::ToString(string_t bits, char *output) {
|
|
78
78
|
|
79
79
|
string Bit::ToString(string_t str) {
|
80
80
|
auto len = BitLength(str);
|
81
|
-
auto buffer =
|
81
|
+
auto buffer = make_unsafe_array<char>(len);
|
82
82
|
ToString(str, buffer.get());
|
83
83
|
return string(buffer.get(), len);
|
84
84
|
}
|
@@ -140,7 +140,7 @@ void Bit::ToBit(string_t str, string_t &output_str) {
|
|
140
140
|
|
141
141
|
string Bit::ToBit(string_t str) {
|
142
142
|
auto bit_len = GetBitSize(str);
|
143
|
-
auto buffer =
|
143
|
+
auto buffer = make_unsafe_array<char>(bit_len);
|
144
144
|
string_t output_str(buffer.get(), bit_len);
|
145
145
|
Bit::ToBit(str, output_str);
|
146
146
|
return output_str.GetString();
|
@@ -64,7 +64,7 @@ void Blob::ToString(string_t blob, char *output) {
|
|
64
64
|
|
65
65
|
string Blob::ToString(string_t blob) {
|
66
66
|
auto str_len = GetStringSize(blob);
|
67
|
-
auto buffer =
|
67
|
+
auto buffer = make_unsafe_array<char>(str_len);
|
68
68
|
Blob::ToString(blob, buffer.get());
|
69
69
|
return string(buffer.get(), str_len);
|
70
70
|
}
|
@@ -136,7 +136,7 @@ void Blob::ToBlob(string_t str, data_ptr_t output) {
|
|
136
136
|
|
137
137
|
string Blob::ToBlob(string_t str) {
|
138
138
|
auto blob_len = GetBlobSize(str);
|
139
|
-
auto buffer =
|
139
|
+
auto buffer = make_unsafe_array<char>(blob_len);
|
140
140
|
Blob::ToBlob(str, (data_ptr_t)buffer.get());
|
141
141
|
return string(buffer.get(), blob_len);
|
142
142
|
}
|
@@ -291,8 +291,8 @@ void DataChunk::Slice(DataChunk &other, const SelectionVector &sel, idx_t count_
|
|
291
291
|
}
|
292
292
|
}
|
293
293
|
|
294
|
-
|
295
|
-
auto orrified_data =
|
294
|
+
unsafe_array_ptr<UnifiedVectorFormat> DataChunk::ToUnifiedFormat() {
|
295
|
+
auto orrified_data = make_unsafe_array<UnifiedVectorFormat>(ColumnCount());
|
296
296
|
for (idx_t col_idx = 0; col_idx < ColumnCount(); col_idx++) {
|
297
297
|
data[col_idx].ToUnifiedFormat(size(), orrified_data[col_idx]);
|
298
298
|
}
|
@@ -362,7 +362,7 @@ string Date::ToString(date_t date) {
|
|
362
362
|
Date::Convert(date, date_units[0], date_units[1], date_units[2]);
|
363
363
|
|
364
364
|
auto length = DateToStringCast::Length(date_units, year_length, add_bc);
|
365
|
-
auto buffer =
|
365
|
+
auto buffer = make_unsafe_array<char>(length);
|
366
366
|
DateToStringCast::Format(buffer.get(), date_units, year_length, add_bc);
|
367
367
|
return string(buffer.get(), length);
|
368
368
|
}
|
@@ -6,7 +6,7 @@ namespace duckdb {
|
|
6
6
|
template <class SIGNED, class UNSIGNED>
|
7
7
|
string TemplatedDecimalToString(SIGNED value, uint8_t width, uint8_t scale) {
|
8
8
|
auto len = DecimalToString::DecimalLength<SIGNED, UNSIGNED>(value, width, scale);
|
9
|
-
auto data =
|
9
|
+
auto data = make_unsafe_array<char>(len + 1);
|
10
10
|
DecimalToString::FormatDecimal<SIGNED, UNSIGNED>(value, width, scale, data.get(), len);
|
11
11
|
return string(data.get(), len);
|
12
12
|
}
|
@@ -25,7 +25,7 @@ string Decimal::ToString(int64_t value, uint8_t width, uint8_t scale) {
|
|
25
25
|
|
26
26
|
string Decimal::ToString(hugeint_t value, uint8_t width, uint8_t scale) {
|
27
27
|
auto len = HugeintToStringCast::DecimalLength(value, width, scale);
|
28
|
-
auto data =
|
28
|
+
auto data = make_unsafe_array<char>(len + 1);
|
29
29
|
HugeintToStringCast::FormatDecimal(value, width, scale, data.get(), len);
|
30
30
|
return string(data.get(), len);
|
31
31
|
}
|
@@ -1,7 +1,7 @@
|
|
1
|
+
#include "duckdb/common/enum_util.hpp"
|
1
2
|
#include "duckdb/common/fast_mem.hpp"
|
2
3
|
#include "duckdb/common/types/null_value.hpp"
|
3
4
|
#include "duckdb/common/types/row/tuple_data_collection.hpp"
|
4
|
-
#include "duckdb/common/enum_util.hpp"
|
5
5
|
|
6
6
|
namespace duckdb {
|
7
7
|
|
@@ -314,6 +314,19 @@ void TupleDataCollection::ListWithinListComputeHeapSizes(Vector &heap_sizes_v, c
|
|
314
314
|
const auto child_list_entries = (list_entry_t *)child_list_data.data;
|
315
315
|
const auto &child_list_validity = child_list_data.validity;
|
316
316
|
|
317
|
+
// Figure out actual child list size (differs from ListVector::GetListSize if dict/const vector)
|
318
|
+
idx_t child_list_child_count = ListVector::GetListSize(source_v);
|
319
|
+
for (idx_t i = 0; i < append_count; i++) {
|
320
|
+
const auto list_idx = list_sel.get_index(append_sel.get_index(i));
|
321
|
+
if (!list_validity.RowIsValid(list_idx)) {
|
322
|
+
continue;
|
323
|
+
}
|
324
|
+
const auto &list_entry = list_entries[list_idx];
|
325
|
+
const auto &list_offset = list_entry.offset;
|
326
|
+
const auto &list_length = list_entry.length;
|
327
|
+
child_list_child_count = MaxValue<idx_t>(child_list_child_count, list_offset + list_length);
|
328
|
+
}
|
329
|
+
|
317
330
|
// Target
|
318
331
|
auto heap_sizes = FlatVector::GetData<idx_t>(heap_sizes_v);
|
319
332
|
|
@@ -322,7 +335,6 @@ void TupleDataCollection::ListWithinListComputeHeapSizes(Vector &heap_sizes_v, c
|
|
322
335
|
child_format.combined_list_data = make_uniq<CombinedListData>();
|
323
336
|
auto &combined_list_data = *child_format.combined_list_data;
|
324
337
|
auto &combined_list_entries = combined_list_data.combined_list_entries;
|
325
|
-
const auto child_list_child_count = ListVector::GetListSize(source_v);
|
326
338
|
SelectionVector combined_sel(child_list_child_count);
|
327
339
|
for (idx_t i = 0; i < child_list_child_count; i++) {
|
328
340
|
combined_sel.set_index(i, 0);
|
@@ -5,7 +5,7 @@
|
|
5
5
|
namespace duckdb {
|
6
6
|
|
7
7
|
SelectionData::SelectionData(idx_t count) {
|
8
|
-
owned_data =
|
8
|
+
owned_data = make_unsafe_array<sel_t>(count);
|
9
9
|
#ifdef DEBUG
|
10
10
|
for (idx_t i = 0; i < count; i++) {
|
11
11
|
owned_data[i] = std::numeric_limits<sel_t>::max();
|
@@ -158,7 +158,7 @@ string Time::ToString(dtime_t time) {
|
|
158
158
|
|
159
159
|
char micro_buffer[6];
|
160
160
|
auto length = TimeToStringCast::Length(time_units, micro_buffer);
|
161
|
-
auto buffer =
|
161
|
+
auto buffer = make_unsafe_array<char>(length);
|
162
162
|
TimeToStringCast::Format(buffer.get(), length, time_units, micro_buffer);
|
163
163
|
return string(buffer.get(), length);
|
164
164
|
}
|
@@ -297,7 +297,7 @@ void Vector::Resize(idx_t cur_size, idx_t new_size) {
|
|
297
297
|
}
|
298
298
|
for (auto &data_to_resize : to_resize) {
|
299
299
|
if (!data_to_resize.is_nested) {
|
300
|
-
auto new_data =
|
300
|
+
auto new_data = make_unsafe_array<data_t>(new_size * data_to_resize.type_size);
|
301
301
|
memcpy(new_data.get(), data_to_resize.data, cur_size * data_to_resize.type_size * sizeof(data_t));
|
302
302
|
data_to_resize.buffer->SetData(std::move(new_data));
|
303
303
|
data_to_resize.vec.data = data_to_resize.buffer->GetData();
|
@@ -920,7 +920,7 @@ void Vector::Serialize(idx_t count, Serializer &serializer) {
|
|
920
920
|
if (TypeIsConstantSize(type.InternalType())) {
|
921
921
|
// constant size type: simple copy
|
922
922
|
idx_t write_size = GetTypeIdSize(type.InternalType()) * count;
|
923
|
-
auto ptr =
|
923
|
+
auto ptr = make_unsafe_array<data_t>(write_size);
|
924
924
|
VectorOperations::WriteToStorage(*this, count, ptr.get());
|
925
925
|
serializer.WriteData(ptr.get(), write_size);
|
926
926
|
} else {
|
@@ -947,7 +947,7 @@ void Vector::Serialize(idx_t count, Serializer &serializer) {
|
|
947
947
|
auto list_size = ListVector::GetListSize(*this);
|
948
948
|
|
949
949
|
// serialize the list entries in a flat array
|
950
|
-
auto data =
|
950
|
+
auto data = make_unsafe_array<list_entry_t>(count);
|
951
951
|
auto source_array = (list_entry_t *)vdata.data;
|
952
952
|
for (idx_t i = 0; i < count; i++) {
|
953
953
|
auto idx = vdata.sel->get_index(i);
|
@@ -988,7 +988,7 @@ void Vector::FormatSerialize(FormatSerializer &serializer, idx_t count) {
|
|
988
988
|
if (TypeIsConstantSize(logical_type.InternalType())) {
|
989
989
|
// constant size type: simple copy
|
990
990
|
idx_t write_size = GetTypeIdSize(logical_type.InternalType()) * count;
|
991
|
-
auto ptr =
|
991
|
+
auto ptr = make_unsafe_array<data_t>(write_size);
|
992
992
|
VectorOperations::WriteToStorage(*this, count, ptr.get());
|
993
993
|
serializer.WriteProperty("data", ptr.get(), write_size);
|
994
994
|
} else {
|
@@ -1027,7 +1027,7 @@ void Vector::FormatSerialize(FormatSerializer &serializer, idx_t count) {
|
|
1027
1027
|
auto list_size = ListVector::GetListSize(*this);
|
1028
1028
|
|
1029
1029
|
// serialize the list entries in a flat array
|
1030
|
-
auto entries =
|
1030
|
+
auto entries = make_unsafe_array<list_entry_t>(count);
|
1031
1031
|
auto source_array = (list_entry_t *)vdata.data;
|
1032
1032
|
for (idx_t i = 0; i < count; i++) {
|
1033
1033
|
auto idx = vdata.sel->get_index(i);
|
@@ -1071,7 +1071,7 @@ void Vector::FormatDeserialize(FormatDeserializer &deserializer, idx_t count) {
|
|
1071
1071
|
if (TypeIsConstantSize(logical_type.InternalType())) {
|
1072
1072
|
// constant size type: read fixed amount of data
|
1073
1073
|
auto column_size = GetTypeIdSize(logical_type.InternalType()) * count;
|
1074
|
-
auto ptr =
|
1074
|
+
auto ptr = make_unsafe_array<data_t>(column_size);
|
1075
1075
|
deserializer.ReadProperty("data", ptr.get(), column_size);
|
1076
1076
|
|
1077
1077
|
VectorOperations::ReadFromStorage(ptr.get(), count, *this);
|
@@ -1158,7 +1158,7 @@ void Vector::Deserialize(idx_t count, Deserializer &source) {
|
|
1158
1158
|
if (TypeIsConstantSize(type.InternalType())) {
|
1159
1159
|
// constant size type: read fixed amount of data from
|
1160
1160
|
auto column_size = GetTypeIdSize(type.InternalType()) * count;
|
1161
|
-
auto ptr =
|
1161
|
+
auto ptr = make_unsafe_array<data_t>(column_size);
|
1162
1162
|
source.ReadData(ptr.get(), column_size);
|
1163
1163
|
|
1164
1164
|
VectorOperations::ReadFromStorage(ptr.get(), count, *this);
|
@@ -15,6 +15,10 @@ unique_ptr<FileHandle> VirtualFileSystem::OpenFile(const string &path, uint8_t f
|
|
15
15
|
if (compression == FileCompressionType::AUTO_DETECT) {
|
16
16
|
// auto detect compression settings based on file name
|
17
17
|
auto lower_path = StringUtil::Lower(path);
|
18
|
+
if (StringUtil::EndsWith(lower_path, ".tmp")) {
|
19
|
+
// strip .tmp
|
20
|
+
lower_path = lower_path.substr(0, lower_path.length() - 4);
|
21
|
+
}
|
18
22
|
if (StringUtil::EndsWith(lower_path, ".gz")) {
|
19
23
|
compression = FileCompressionType::GZIP;
|
20
24
|
} else if (StringUtil::EndsWith(lower_path, ".zst")) {
|
@@ -11,7 +11,7 @@ std::wstring WindowsUtil::UTF8ToUnicode(const char *input) {
|
|
11
11
|
if (result_size == 0) {
|
12
12
|
throw IOException("Failure in MultiByteToWideChar");
|
13
13
|
}
|
14
|
-
auto buffer =
|
14
|
+
auto buffer = make_unsafe_array<wchar_t>(result_size);
|
15
15
|
result_size = MultiByteToWideChar(CP_UTF8, 0, input, -1, buffer.get(), result_size);
|
16
16
|
if (result_size == 0) {
|
17
17
|
throw IOException("Failure in MultiByteToWideChar");
|
@@ -26,7 +26,7 @@ static string WideCharToMultiByteWrapper(LPCWSTR input, uint32_t code_page) {
|
|
26
26
|
if (result_size == 0) {
|
27
27
|
throw IOException("Failure in WideCharToMultiByte");
|
28
28
|
}
|
29
|
-
auto buffer =
|
29
|
+
auto buffer = make_unsafe_array<char>(result_size);
|
30
30
|
result_size = WideCharToMultiByte(code_page, 0, input, -1, buffer.get(), result_size, 0, 0);
|
31
31
|
if (result_size == 0) {
|
32
32
|
throw IOException("Failure in WideCharToMultiByte");
|
@@ -131,18 +131,21 @@ unique_ptr<FunctionData> StringAggBind(ClientContext &context, AggregateFunction
|
|
131
131
|
throw BinderException("Separator argument to StringAgg must be a constant");
|
132
132
|
}
|
133
133
|
auto separator_val = ExpressionExecutor::EvaluateScalar(context, *arguments[1]);
|
134
|
+
string separator_string = ",";
|
134
135
|
if (separator_val.IsNull()) {
|
135
136
|
arguments[0] = make_uniq<BoundConstantExpression>(Value(LogicalType::VARCHAR));
|
137
|
+
} else {
|
138
|
+
separator_string = separator_val.ToString();
|
136
139
|
}
|
137
140
|
Function::EraseArgument(function, arguments, arguments.size() - 1);
|
138
|
-
return make_uniq<StringAggBindData>(
|
141
|
+
return make_uniq<StringAggBindData>(std::move(separator_string));
|
139
142
|
}
|
140
143
|
|
141
144
|
static void StringAggSerialize(FieldWriter &writer, const FunctionData *bind_data_p,
|
142
145
|
const AggregateFunction &function) {
|
143
146
|
D_ASSERT(bind_data_p);
|
144
|
-
auto bind_data = (
|
145
|
-
writer.WriteString(bind_data
|
147
|
+
auto bind_data = bind_data_p->Cast<StringAggBindData>();
|
148
|
+
writer.WriteString(bind_data.sep);
|
146
149
|
}
|
147
150
|
|
148
151
|
unique_ptr<FunctionData> StringAggDeserialize(ClientContext &context, FieldReader &reader,
|
@@ -179,7 +179,7 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
|
|
179
179
|
|
180
180
|
// state_buffer holds the state for each list of this chunk
|
181
181
|
idx_t size = aggr.function.state_size();
|
182
|
-
auto state_buffer =
|
182
|
+
auto state_buffer = make_unsafe_array<data_t>(size * count);
|
183
183
|
|
184
184
|
// state vector for initialize and finalize
|
185
185
|
StateVector state_vector(count, info.aggr_expr->Copy());
|
@@ -344,19 +344,16 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
|
|
344
344
|
}
|
345
345
|
|
346
346
|
static void ListAggregateFunction(DataChunk &args, ExpressionState &state, Vector &result) {
|
347
|
-
|
348
|
-
D_ASSERT(args.ColumnCount() == 2);
|
347
|
+
D_ASSERT(args.ColumnCount() >= 2);
|
349
348
|
ListAggregatesFunction<AggregateFunctor, true>(args, state, result);
|
350
349
|
}
|
351
350
|
|
352
351
|
static void ListDistinctFunction(DataChunk &args, ExpressionState &state, Vector &result) {
|
353
|
-
|
354
352
|
D_ASSERT(args.ColumnCount() == 1);
|
355
353
|
ListAggregatesFunction<DistinctFunctor>(args, state, result);
|
356
354
|
}
|
357
355
|
|
358
356
|
static void ListUniqueFunction(DataChunk &args, ExpressionState &state, Vector &result) {
|
359
|
-
|
360
357
|
D_ASSERT(args.ColumnCount() == 1);
|
361
358
|
ListAggregatesFunction<UniqueFunctor>(args, state, result);
|
362
359
|
}
|
@@ -60,11 +60,15 @@ static void AppendFilteredToResult(Vector &lambda_vector, list_entry_t *result_e
|
|
60
60
|
|
61
61
|
idx_t true_count = 0;
|
62
62
|
SelectionVector true_sel(elem_cnt);
|
63
|
-
|
64
|
-
|
63
|
+
UnifiedVectorFormat lambda_data;
|
64
|
+
lambda_vector.ToUnifiedFormat(elem_cnt, lambda_data);
|
65
|
+
|
66
|
+
auto lambda_values = (bool *)lambda_data.data;
|
67
|
+
auto &lambda_validity = lambda_data.validity;
|
65
68
|
|
66
69
|
// compute the new lengths and offsets, and create a selection vector
|
67
70
|
for (idx_t i = 0; i < elem_cnt; i++) {
|
71
|
+
auto entry = lambda_data.sel->get_index(i);
|
68
72
|
|
69
73
|
while (appended_lists_cnt < lists_len.size() && lists_len[appended_lists_cnt] == 0) {
|
70
74
|
result_entries[appended_lists_cnt].offset = curr_list_offset;
|
@@ -73,12 +77,11 @@ static void AppendFilteredToResult(Vector &lambda_vector, list_entry_t *result_e
|
|
73
77
|
}
|
74
78
|
|
75
79
|
// found a true value
|
76
|
-
if (lambda_validity.RowIsValid(
|
77
|
-
|
78
|
-
|
79
|
-
curr_list_len++;
|
80
|
-
}
|
80
|
+
if (lambda_validity.RowIsValid(entry) && lambda_values[entry] > 0) {
|
81
|
+
true_sel.set_index(true_count++, i);
|
82
|
+
curr_list_len++;
|
81
83
|
}
|
84
|
+
|
82
85
|
curr_original_list_len++;
|
83
86
|
|
84
87
|
if (lists_len[appended_lists_cnt] == curr_original_list_len) {
|
@@ -94,7 +94,7 @@ static void PrintfFunction(DataChunk &args, ExpressionState &state, Vector &resu
|
|
94
94
|
|
95
95
|
// now gather all the format arguments
|
96
96
|
vector<duckdb_fmt::basic_format_arg<CTX>> format_args;
|
97
|
-
vector<
|
97
|
+
vector<unsafe_array_ptr<data_t>> string_args;
|
98
98
|
|
99
99
|
for (idx_t col_idx = 1; col_idx < args.ColumnCount(); col_idx++) {
|
100
100
|
auto &col = args.data[col_idx];
|
@@ -390,7 +390,7 @@ idx_t GroupedAggregateHashTable::FindOrCreateGroupsInternal(AggregateHTAppendSta
|
|
390
390
|
}
|
391
391
|
TupleDataCollection::ToUnifiedFormat(state.chunk_state, state.group_chunk);
|
392
392
|
if (!state.group_data) {
|
393
|
-
state.group_data =
|
393
|
+
state.group_data = make_unsafe_array<UnifiedVectorFormat>(state.group_chunk.ColumnCount());
|
394
394
|
}
|
395
395
|
TupleDataCollection::GetVectorData(state.chunk_state, state.group_data.get());
|
396
396
|
|
@@ -74,6 +74,9 @@ static idx_t BetweenLoopTypeSwitch(Vector &input, Vector &lower, Vector &upper,
|
|
74
74
|
case PhysicalType::VARCHAR:
|
75
75
|
return TernaryExecutor::Select<string_t, string_t, string_t, OP>(input, lower, upper, sel, count, true_sel,
|
76
76
|
false_sel);
|
77
|
+
case PhysicalType::INTERVAL:
|
78
|
+
return TernaryExecutor::Select<interval_t, interval_t, interval_t, OP>(input, lower, upper, sel, count,
|
79
|
+
true_sel, false_sel);
|
77
80
|
default:
|
78
81
|
throw InvalidTypeException(input.GetType(), "Invalid type for BETWEEN");
|
79
82
|
}
|