duckdb 0.7.2-dev3666.0 → 0.7.2-dev3763.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 +1 -1
- package/src/database.cpp +0 -1
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/read_json.cpp +4 -4
- package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +1 -1
- package/src/duckdb/extension/json/json_scan.cpp +16 -12
- 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/exception.cpp +17 -0
- package/src/duckdb/src/common/exception_format_value.cpp +14 -0
- package/src/duckdb/src/common/file_system.cpp +53 -31
- package/src/duckdb/src/common/local_file_system.cpp +5 -3
- 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 +3 -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 +6 -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/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/types.cpp +1 -1
- package/src/duckdb/src/common/windows_util.cpp +2 -2
- package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +1 -1
- 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/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_range_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +91 -30
- package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +1 -1
- package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +2 -2
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +3 -3
- package/src/duckdb/src/execution/window_segment_tree.cpp +1 -1
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +2 -2
- 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 +3 -0
- package/src/duckdb/src/function/table/table_scan.cpp +7 -3
- package/src/duckdb/src/function/table/version/pragma_version.cpp +4 -6
- package/src/duckdb/src/include/duckdb/common/compressed_file_system.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/exception_format_value.hpp +26 -0
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +6 -0
- package/src/duckdb/src/include/duckdb/common/helper.hpp +9 -9
- package/src/duckdb/src/include/duckdb/common/http_state.hpp +2 -2
- 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 +2 -2
- package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +10 -10
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +20 -0
- package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +1 -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 +8 -8
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +3 -3
- 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/buffered_csv_reader.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -3
- 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 +1 -1
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +3 -3
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/keyword_helper.hpp +5 -0
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +4 -0
- 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/row_group.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +5 -5
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -2
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +1 -1
- package/src/duckdb/src/main/client_context.cpp +4 -4
- package/src/duckdb/src/main/db_instance_cache.cpp +5 -3
- package/src/duckdb/src/main/extension/extension_install.cpp +22 -18
- package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +5 -5
- package/src/duckdb/src/parser/expression/collate_expression.cpp +1 -1
- package/src/duckdb/src/parser/keyword_helper.cpp +11 -1
- package/src/duckdb/src/parser/query_node/select_node.cpp +1 -1
- package/src/duckdb/src/parser/statement/copy_statement.cpp +2 -2
- package/src/duckdb/src/parser/tableref.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +7 -1
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +1 -1
- 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/data_table.cpp +75 -44
- package/src/duckdb/src/storage/local_storage.cpp +1 -1
- 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/storage_manager.cpp +3 -0
- package/src/duckdb/src/storage/table/row_group.cpp +11 -11
- package/src/duckdb/src/storage/table/scan_state.cpp +1 -1
- package/src/duckdb/src/storage/table/update_segment.cpp +6 -6
@@ -207,7 +207,7 @@ struct IndexScanGlobalState : public GlobalTableFunctionState {
|
|
207
207
|
Vector row_ids;
|
208
208
|
ColumnFetchState fetch_state;
|
209
209
|
TableScanState local_storage_state;
|
210
|
-
vector<
|
210
|
+
vector<storage_t> column_ids;
|
211
211
|
bool finished;
|
212
212
|
};
|
213
213
|
|
@@ -219,8 +219,12 @@ static unique_ptr<GlobalTableFunctionState> IndexScanInitGlobal(ClientContext &c
|
|
219
219
|
}
|
220
220
|
auto result = make_uniq<IndexScanGlobalState>(row_id_data);
|
221
221
|
auto &local_storage = LocalStorage::Get(context, bind_data.table.catalog);
|
222
|
-
|
223
|
-
result->
|
222
|
+
|
223
|
+
result->column_ids.reserve(input.column_ids.size());
|
224
|
+
for (auto &id : input.column_ids) {
|
225
|
+
result->column_ids.push_back(GetStorageIndex(bind_data.table, id));
|
226
|
+
}
|
227
|
+
result->local_storage_state.Initialize(result->column_ids, input.filters.get());
|
224
228
|
local_storage.InitializeScan(bind_data.table.GetStorage(), result->local_storage_state.local_state, input.filters);
|
225
229
|
|
226
230
|
result->finished = false;
|
@@ -1,16 +1,14 @@
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
2
|
-
#define DUCKDB_VERSION "0.7.2-
|
2
|
+
#define DUCKDB_VERSION "0.7.2-dev3763"
|
3
3
|
#endif
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
5
|
+
#define DUCKDB_SOURCE_ID "d3562b54ee"
|
6
6
|
#endif
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
8
8
|
#include "duckdb/main/database.hpp"
|
9
9
|
|
10
10
|
#include <cstdint>
|
11
11
|
|
12
|
-
#define DUCKDB_STRINGIFY(x) #x
|
13
|
-
|
14
12
|
namespace duckdb {
|
15
13
|
|
16
14
|
struct PragmaVersionData : public GlobalTableFunctionState {
|
@@ -93,8 +91,8 @@ string DuckDB::Platform() {
|
|
93
91
|
postfix = "_mingw";
|
94
92
|
#endif
|
95
93
|
// this is used for the windows R builds which use a separate build environment
|
96
|
-
#ifdef
|
97
|
-
postfix =
|
94
|
+
#ifdef DUCKDB_PLATFORM_RTOOLS
|
95
|
+
postfix = "_rtools";
|
98
96
|
#endif
|
99
97
|
return os + "_" + arch + postfix;
|
100
98
|
}
|
@@ -18,8 +18,8 @@ struct StreamData {
|
|
18
18
|
// various buffers & pointers
|
19
19
|
bool write = false;
|
20
20
|
bool refresh = false;
|
21
|
-
|
22
|
-
|
21
|
+
unsafe_unique_array<data_t> in_buff;
|
22
|
+
unsafe_unique_array<data_t> out_buff;
|
23
23
|
data_ptr_t out_buff_start = nullptr;
|
24
24
|
data_ptr_t out_buff_end = nullptr;
|
25
25
|
data_ptr_t in_buff_start = nullptr;
|
@@ -15,6 +15,28 @@
|
|
15
15
|
|
16
16
|
namespace duckdb {
|
17
17
|
|
18
|
+
// Helper class to support custom overloading
|
19
|
+
// Escaping " and quoting the value with "
|
20
|
+
class SQLIdentifier {
|
21
|
+
public:
|
22
|
+
SQLIdentifier(const string &raw_string) : raw_string(raw_string) {
|
23
|
+
}
|
24
|
+
|
25
|
+
public:
|
26
|
+
string raw_string;
|
27
|
+
};
|
28
|
+
|
29
|
+
// Helper class to support custom overloading
|
30
|
+
// Escaping ' and quoting the value with '
|
31
|
+
class SQLString {
|
32
|
+
public:
|
33
|
+
SQLString(const string &raw_string) : raw_string(raw_string) {
|
34
|
+
}
|
35
|
+
|
36
|
+
public:
|
37
|
+
string raw_string;
|
38
|
+
};
|
39
|
+
|
18
40
|
enum class PhysicalType : uint8_t;
|
19
41
|
struct LogicalType;
|
20
42
|
|
@@ -47,6 +69,10 @@ public:
|
|
47
69
|
template <>
|
48
70
|
DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(PhysicalType value);
|
49
71
|
template <>
|
72
|
+
DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(SQLString value);
|
73
|
+
template <>
|
74
|
+
DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(SQLIdentifier value);
|
75
|
+
template <>
|
50
76
|
DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(LogicalType value);
|
51
77
|
template <>
|
52
78
|
DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(float value);
|
@@ -178,6 +178,9 @@ public:
|
|
178
178
|
DUCKDB_API static string PathSeparator();
|
179
179
|
//! Checks if path is starts with separator (i.e., '/' on UNIX '\\' on Windows)
|
180
180
|
DUCKDB_API static bool IsPathAbsolute(const string &path);
|
181
|
+
//! Normalize an absolute path - the goal of normalizing is converting "\test.db" and "C:/test.db" into "C:\test.db"
|
182
|
+
//! so that the database system cache can correctly
|
183
|
+
DUCKDB_API static string NormalizeAbsolutePath(const string &path);
|
181
184
|
//! Join two paths together
|
182
185
|
DUCKDB_API static string JoinPath(const string &a, const string &path);
|
183
186
|
//! Convert separators in a path to the local separators (e.g. convert "/" into \\ on windows)
|
@@ -187,6 +190,9 @@ public:
|
|
187
190
|
//! Extract the name of a file (e.g if the input is lib/example.dll the name is 'example.dll')
|
188
191
|
DUCKDB_API static string ExtractName(const string &path);
|
189
192
|
|
193
|
+
//! Returns the value of an environment variable - or the empty string if it is not set
|
194
|
+
DUCKDB_API static string GetEnvVariable(const string &name);
|
195
|
+
|
190
196
|
//! Whether there is a glob in the string
|
191
197
|
DUCKDB_API static bool HasGlob(const string &str);
|
192
198
|
//! Runs a glob on the file system, returning a list of matching files
|
@@ -40,7 +40,7 @@ namespace duckdb {
|
|
40
40
|
template<class _Tp, bool SAFE = true>
|
41
41
|
struct __unique_if
|
42
42
|
{
|
43
|
-
typedef unique_ptr<_Tp, SAFE> __unique_single;
|
43
|
+
typedef unique_ptr<_Tp, std::default_delete<_Tp>, SAFE> __unique_single;
|
44
44
|
};
|
45
45
|
|
46
46
|
template<class _Tp>
|
@@ -60,7 +60,7 @@ inline
|
|
60
60
|
typename __unique_if<_Tp, true>::__unique_single
|
61
61
|
make_uniq(_Args&&... __args)
|
62
62
|
{
|
63
|
-
return unique_ptr<_Tp, true>(new _Tp(std::forward<_Args>(__args)...));
|
63
|
+
return unique_ptr<_Tp, std::default_delete<_Tp>, true>(new _Tp(std::forward<_Args>(__args)...));
|
64
64
|
}
|
65
65
|
|
66
66
|
template<class _Tp, class... _Args>
|
@@ -68,21 +68,21 @@ inline
|
|
68
68
|
typename __unique_if<_Tp, false>::__unique_single
|
69
69
|
make_unsafe_uniq(_Args&&... __args)
|
70
70
|
{
|
71
|
-
return unique_ptr<_Tp, false>(new _Tp(std::forward<_Args>(__args)...));
|
71
|
+
return unique_ptr<_Tp, std::default_delete<_Tp>, false>(new _Tp(std::forward<_Args>(__args)...));
|
72
72
|
}
|
73
73
|
|
74
74
|
template<class _Tp>
|
75
|
-
inline unique_ptr<_Tp[], true>
|
76
|
-
|
75
|
+
inline unique_ptr<_Tp[], std::default_delete<_Tp>, true>
|
76
|
+
make_uniq_array(size_t __n)
|
77
77
|
{
|
78
|
-
return unique_ptr<_Tp[], true>(new _Tp[__n]());
|
78
|
+
return unique_ptr<_Tp[], std::default_delete<_Tp>, true>(new _Tp[__n]());
|
79
79
|
}
|
80
80
|
|
81
81
|
template<class _Tp>
|
82
|
-
inline unique_ptr<_Tp[], false>
|
83
|
-
|
82
|
+
inline unique_ptr<_Tp[], std::default_delete<_Tp>, false>
|
83
|
+
make_unsafe_uniq_array(size_t __n)
|
84
84
|
{
|
85
|
-
return unique_ptr<_Tp[], false>(new _Tp[__n]());
|
85
|
+
return unique_ptr<_Tp[], std::default_delete<_Tp>, false>(new _Tp[__n]());
|
86
86
|
}
|
87
87
|
|
88
88
|
template<class _Tp, class... _Args>
|
@@ -49,10 +49,10 @@ public:
|
|
49
49
|
}
|
50
50
|
|
51
51
|
//! helper function to get the HTTP
|
52
|
-
static
|
52
|
+
static shared_ptr<HTTPState> TryGetState(FileOpener *opener) {
|
53
53
|
auto client_context = FileOpener::TryGetClientContext(opener);
|
54
54
|
if (client_context) {
|
55
|
-
return client_context->client_data->http_state
|
55
|
+
return client_context->client_data->http_state;
|
56
56
|
}
|
57
57
|
return nullptr;
|
58
58
|
}
|
@@ -18,7 +18,7 @@ public:
|
|
18
18
|
FileLockType lock_type = FileLockType::READ_LOCK, optional_ptr<FileOpener> opener = nullptr);
|
19
19
|
|
20
20
|
FileSystem &fs;
|
21
|
-
|
21
|
+
unsafe_unique_array<data_t> data;
|
22
22
|
idx_t offset;
|
23
23
|
idx_t read_data;
|
24
24
|
unique_ptr<FileHandle> handle;
|
@@ -16,7 +16,7 @@ namespace duckdb {
|
|
16
16
|
#define SERIALIZER_DEFAULT_SIZE 1024
|
17
17
|
|
18
18
|
struct BinaryData {
|
19
|
-
|
19
|
+
unsafe_unique_array<data_t> data;
|
20
20
|
idx_t size;
|
21
21
|
};
|
22
22
|
|
@@ -26,7 +26,7 @@ public:
|
|
26
26
|
//! writing past the initial threshold
|
27
27
|
DUCKDB_API explicit BufferedSerializer(idx_t maximum_size = SERIALIZER_DEFAULT_SIZE);
|
28
28
|
//! Serializes to a provided (owned) data pointer
|
29
|
-
BufferedSerializer(
|
29
|
+
BufferedSerializer(unsafe_unique_array<data_t> data, idx_t size);
|
30
30
|
BufferedSerializer(data_ptr_t data, idx_t size);
|
31
31
|
|
32
32
|
idx_t maximum_size;
|
@@ -39,10 +39,10 @@ using duckdb::idx_t;
|
|
39
39
|
using duckdb::data_t;
|
40
40
|
using duckdb::data_ptr_t;
|
41
41
|
using duckdb::unique_ptr;
|
42
|
-
using duckdb::
|
43
|
-
using duckdb::
|
44
|
-
using duckdb::
|
45
|
-
using duckdb::
|
42
|
+
using duckdb::unique_array;
|
43
|
+
using duckdb::unsafe_unique_array;
|
44
|
+
using duckdb::make_uniq_array;
|
45
|
+
using duckdb::make_unsafe_uniq_array;
|
46
46
|
using duckdb::FastMemcpy;
|
47
47
|
using duckdb::FastMemcmp;
|
48
48
|
|
@@ -78,9 +78,9 @@ inline int log2(T n) {
|
|
78
78
|
struct PDQConstants {
|
79
79
|
PDQConstants(idx_t entry_size, idx_t comp_offset, idx_t comp_size, data_ptr_t end)
|
80
80
|
: entry_size(entry_size), comp_offset(comp_offset), comp_size(comp_size),
|
81
|
-
tmp_buf_ptr(
|
82
|
-
iter_swap_buf_ptr(
|
83
|
-
swap_offsets_buf_ptr(
|
81
|
+
tmp_buf_ptr(make_unsafe_uniq_array<data_t>(entry_size)), tmp_buf(tmp_buf_ptr.get()),
|
82
|
+
iter_swap_buf_ptr(make_unsafe_uniq_array<data_t>(entry_size)), iter_swap_buf(iter_swap_buf_ptr.get()),
|
83
|
+
swap_offsets_buf_ptr(make_unsafe_uniq_array<data_t>(entry_size)),
|
84
84
|
swap_offsets_buf(swap_offsets_buf_ptr.get()), end(end) {
|
85
85
|
}
|
86
86
|
|
@@ -88,13 +88,13 @@ struct PDQConstants {
|
|
88
88
|
const idx_t comp_offset;
|
89
89
|
const idx_t comp_size;
|
90
90
|
|
91
|
-
|
91
|
+
unsafe_unique_array<data_t> tmp_buf_ptr;
|
92
92
|
const data_ptr_t tmp_buf;
|
93
93
|
|
94
|
-
|
94
|
+
unsafe_unique_array<data_t> iter_swap_buf_ptr;
|
95
95
|
const data_ptr_t iter_swap_buf;
|
96
96
|
|
97
|
-
|
97
|
+
unsafe_unique_array<data_t> swap_offsets_buf_ptr;
|
98
98
|
const data_ptr_t swap_offsets_buf;
|
99
99
|
|
100
100
|
const data_ptr_t end;
|
@@ -15,6 +15,7 @@
|
|
15
15
|
#include <cstring>
|
16
16
|
|
17
17
|
namespace duckdb {
|
18
|
+
|
18
19
|
/**
|
19
20
|
* String Utility Functions
|
20
21
|
* Note that these are not the most efficient implementations (i.e., they copy
|
@@ -85,6 +86,23 @@ public:
|
|
85
86
|
return false;
|
86
87
|
}
|
87
88
|
|
89
|
+
template <class TO>
|
90
|
+
static vector<TO> ConvertStrings(const vector<string> &strings) {
|
91
|
+
vector<TO> result;
|
92
|
+
for (auto &string : strings) {
|
93
|
+
result.emplace_back(string);
|
94
|
+
}
|
95
|
+
return result;
|
96
|
+
}
|
97
|
+
|
98
|
+
static vector<SQLIdentifier> ConvertToSQLIdentifiers(const vector<string> &strings) {
|
99
|
+
return ConvertStrings<SQLIdentifier>(strings);
|
100
|
+
}
|
101
|
+
|
102
|
+
static vector<SQLString> ConvertToSQLStrings(const vector<string> &strings) {
|
103
|
+
return ConvertStrings<SQLString>(strings);
|
104
|
+
}
|
105
|
+
|
88
106
|
//! Returns true if the needle string exists in the haystack
|
89
107
|
DUCKDB_API static bool Contains(const string &haystack, const string &needle);
|
90
108
|
|
@@ -145,6 +163,8 @@ public:
|
|
145
163
|
//! Convert a string to lowercase
|
146
164
|
DUCKDB_API static string Lower(const string &str);
|
147
165
|
|
166
|
+
DUCKDB_API static bool IsLower(const string &str);
|
167
|
+
|
148
168
|
//! Case insensitive hash
|
149
169
|
DUCKDB_API static uint64_t CIHash(const string &str);
|
150
170
|
|
@@ -125,7 +125,7 @@ public:
|
|
125
125
|
DUCKDB_API void Flatten();
|
126
126
|
|
127
127
|
// FIXME: this is DUCKDB_API, might need conversion back to regular unique ptr?
|
128
|
-
DUCKDB_API
|
128
|
+
DUCKDB_API unsafe_unique_array<UnifiedVectorFormat> ToUnifiedFormat();
|
129
129
|
|
130
130
|
DUCKDB_API void Slice(const SelectionVector &sel_vector, idx_t count);
|
131
131
|
|
@@ -24,7 +24,7 @@ struct TemplatedValidityData {
|
|
24
24
|
public:
|
25
25
|
inline explicit TemplatedValidityData(idx_t count) {
|
26
26
|
auto entry_count = EntryCount(count);
|
27
|
-
owned_data =
|
27
|
+
owned_data = make_unsafe_uniq_array<V>(entry_count);
|
28
28
|
for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
|
29
29
|
owned_data[entry_idx] = MAX_ENTRY;
|
30
30
|
}
|
@@ -32,13 +32,13 @@ public:
|
|
32
32
|
inline TemplatedValidityData(const V *validity_mask, idx_t count) {
|
33
33
|
D_ASSERT(validity_mask);
|
34
34
|
auto entry_count = EntryCount(count);
|
35
|
-
owned_data =
|
35
|
+
owned_data = make_unsafe_uniq_array<V>(entry_count);
|
36
36
|
for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
|
37
37
|
owned_data[entry_idx] = validity_mask[entry_idx];
|
38
38
|
}
|
39
39
|
}
|
40
40
|
|
41
|
-
|
41
|
+
unsafe_unique_array<V> owned_data;
|
42
42
|
|
43
43
|
public:
|
44
44
|
static inline idx_t EntryCount(idx_t count) {
|
@@ -71,10 +71,10 @@ public:
|
|
71
71
|
}
|
72
72
|
explicit VectorBuffer(idx_t data_size) : buffer_type(VectorBufferType::STANDARD_BUFFER) {
|
73
73
|
if (data_size > 0) {
|
74
|
-
data =
|
74
|
+
data = make_unsafe_uniq_array<data_t>(data_size);
|
75
75
|
}
|
76
76
|
}
|
77
|
-
explicit VectorBuffer(
|
77
|
+
explicit VectorBuffer(unsafe_unique_array<data_t> data_p)
|
78
78
|
: buffer_type(VectorBufferType::STANDARD_BUFFER), data(std::move(data_p)) {
|
79
79
|
}
|
80
80
|
virtual ~VectorBuffer() {
|
@@ -87,7 +87,7 @@ public:
|
|
87
87
|
return data.get();
|
88
88
|
}
|
89
89
|
|
90
|
-
void SetData(
|
90
|
+
void SetData(unsafe_unique_array<data_t> new_data) {
|
91
91
|
data = std::move(new_data);
|
92
92
|
}
|
93
93
|
|
@@ -120,7 +120,7 @@ public:
|
|
120
120
|
protected:
|
121
121
|
VectorBufferType buffer_type;
|
122
122
|
unique_ptr<VectorAuxiliaryData> aux_data;
|
123
|
-
|
123
|
+
unsafe_unique_array<data_t> data;
|
124
124
|
};
|
125
125
|
|
126
126
|
//! The DictionaryBuffer holds a selection vector
|
@@ -9,10 +9,10 @@
|
|
9
9
|
|
10
10
|
namespace duckdb {
|
11
11
|
|
12
|
-
template <class _Tp, bool SAFE = true>
|
13
|
-
class unique_ptr : public std::unique_ptr<_Tp,
|
12
|
+
template <class _Tp, class _Dp = std::default_delete<_Tp>, bool SAFE = true>
|
13
|
+
class unique_ptr : public std::unique_ptr<_Tp, _Dp> {
|
14
14
|
public:
|
15
|
-
using original = std::unique_ptr<_Tp,
|
15
|
+
using original = std::unique_ptr<_Tp, _Dp>;
|
16
16
|
using original::original;
|
17
17
|
|
18
18
|
private:
|
@@ -53,8 +53,8 @@ public:
|
|
53
53
|
}
|
54
54
|
};
|
55
55
|
|
56
|
-
template <class _Tp, bool SAFE>
|
57
|
-
class unique_ptr<_Tp[], SAFE> : public std::unique_ptr<_Tp[], std::default_delete<_Tp[]>> {
|
56
|
+
template <class _Tp, class _Dp, bool SAFE>
|
57
|
+
class unique_ptr<_Tp[], _Dp, SAFE> : public std::unique_ptr<_Tp[], std::default_delete<_Tp[]>> {
|
58
58
|
public:
|
59
59
|
using original = std::unique_ptr<_Tp[], std::default_delete<_Tp[]>>;
|
60
60
|
using original::original;
|
@@ -81,12 +81,12 @@ public:
|
|
81
81
|
};
|
82
82
|
|
83
83
|
template <typename T>
|
84
|
-
using
|
84
|
+
using unique_array = unique_ptr<T[], std::default_delete<T>, true>;
|
85
85
|
|
86
86
|
template <typename T>
|
87
|
-
using
|
87
|
+
using unsafe_unique_array = unique_ptr<T[], std::default_delete<T>, false>;
|
88
88
|
|
89
89
|
template <typename T>
|
90
|
-
using unsafe_unique_ptr = unique_ptr<T, false>;
|
90
|
+
using unsafe_unique_ptr = unique_ptr<T, std::default_delete<T>, false>;
|
91
91
|
|
92
92
|
} // namespace duckdb
|
@@ -73,7 +73,7 @@ struct AggregateHTAppendState {
|
|
73
73
|
SelectionVector empty_vector;
|
74
74
|
SelectionVector new_groups;
|
75
75
|
Vector addresses;
|
76
|
-
|
76
|
+
unsafe_unique_array<UnifiedVectorFormat> group_data;
|
77
77
|
DataChunk group_chunk;
|
78
78
|
|
79
79
|
TupleDataChunkState chunk_state;
|
@@ -65,12 +65,12 @@ public:
|
|
65
65
|
//! returned by the JoinHashTable::Scan function and can be used to resume a
|
66
66
|
//! probe.
|
67
67
|
struct ScanStructure {
|
68
|
-
|
68
|
+
unsafe_unique_array<UnifiedVectorFormat> key_data;
|
69
69
|
Vector pointers;
|
70
70
|
idx_t count;
|
71
71
|
SelectionVector sel_vector;
|
72
72
|
// whether or not the given tuple has found a match
|
73
|
-
|
73
|
+
unsafe_unique_array<bool> found_match;
|
74
74
|
JoinHashTable &ht;
|
75
75
|
bool finished;
|
76
76
|
|
@@ -212,7 +212,7 @@ private:
|
|
212
212
|
//! Insert the given set of locations into the HT with the given set of hashes
|
213
213
|
void InsertHashes(Vector &hashes, idx_t count, data_ptr_t key_locations[], bool parallel);
|
214
214
|
|
215
|
-
idx_t PrepareKeys(DataChunk &keys,
|
215
|
+
idx_t PrepareKeys(DataChunk &keys, unsafe_unique_array<UnifiedVectorFormat> &key_data,
|
216
216
|
const SelectionVector *¤t_sel, SelectionVector &sel, bool build_side);
|
217
217
|
|
218
218
|
//! Lock for combining data_collection when merging HTs
|
package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp
CHANGED
@@ -68,7 +68,7 @@ private:
|
|
68
68
|
//! Build and probe statistics
|
69
69
|
PerfectHashJoinStats perfect_join_statistics;
|
70
70
|
//! Stores the occurences of each value in the build side
|
71
|
-
|
71
|
+
unsafe_unique_array<bool> bitmap_build_idx;
|
72
72
|
//! Stores the number of unique keys in the build side
|
73
73
|
idx_t unique_keys = 0;
|
74
74
|
};
|
@@ -83,7 +83,7 @@ public:
|
|
83
83
|
//! The total number of rows in the RHS
|
84
84
|
atomic<idx_t> count;
|
85
85
|
//! A bool indicating for each tuple in the RHS if they found a match (only used in FULL OUTER JOIN)
|
86
|
-
|
86
|
+
unsafe_unique_array<bool> found_match;
|
87
87
|
//! Memory usage per thread
|
88
88
|
idx_t memory_per_thread;
|
89
89
|
};
|
@@ -60,12 +60,12 @@ public:
|
|
60
60
|
virtual ~BufferedCSVReader() {
|
61
61
|
}
|
62
62
|
|
63
|
-
|
63
|
+
unsafe_unique_array<char> buffer;
|
64
64
|
idx_t buffer_size;
|
65
65
|
idx_t position;
|
66
66
|
idx_t start = 0;
|
67
67
|
|
68
|
-
vector<
|
68
|
+
vector<unsafe_unique_array<char>> cached_buffers;
|
69
69
|
|
70
70
|
unique_ptr<CSVFileHandle> file_handle;
|
71
71
|
|
@@ -67,7 +67,7 @@ struct CSVBufferRead {
|
|
67
67
|
} else {
|
68
68
|
// 3) It starts in the current buffer and ends in the next buffer
|
69
69
|
D_ASSERT(next_buffer);
|
70
|
-
auto intersection =
|
70
|
+
auto intersection = make_unsafe_uniq_array<char>(length);
|
71
71
|
idx_t cur_pos = 0;
|
72
72
|
auto buffer_ptr = buffer->Ptr();
|
73
73
|
for (idx_t i = start_buffer; i < buffer->GetBufferSize(); i++) {
|
@@ -85,7 +85,7 @@ struct CSVBufferRead {
|
|
85
85
|
|
86
86
|
shared_ptr<CSVBuffer> buffer;
|
87
87
|
shared_ptr<CSVBuffer> next_buffer;
|
88
|
-
vector<
|
88
|
+
vector<unsafe_unique_array<char>> intersections;
|
89
89
|
optional_ptr<LineInfo> line_info;
|
90
90
|
|
91
91
|
idx_t buffer_start;
|
@@ -115,10 +115,9 @@ protected:
|
|
115
115
|
void CombineExistingAndInsertTuples(DataChunk &result, DataChunk &scan_chunk, DataChunk &input_chunk,
|
116
116
|
ClientContext &client) const;
|
117
117
|
//! Returns the amount of updated tuples
|
118
|
+
void CreateUpdateChunk(ExecutionContext &context, DataChunk &chunk, TableCatalogEntry &table, Vector &row_ids,
|
119
|
+
DataChunk &result) const;
|
118
120
|
idx_t OnConflictHandling(TableCatalogEntry &table, ExecutionContext &context, InsertLocalState &lstate) const;
|
119
|
-
idx_t PerformOnConflictAction(ExecutionContext &context, DataChunk &chunk, TableCatalogEntry &table,
|
120
|
-
Vector &row_ids) const;
|
121
|
-
void RegisterUpdatedRows(InsertLocalState &lstate, const Vector &row_ids, idx_t count) const;
|
122
121
|
};
|
123
122
|
|
124
123
|
} // namespace duckdb
|
@@ -46,9 +46,9 @@ protected:
|
|
46
46
|
// The actual pointer to the data
|
47
47
|
data_ptr_t data;
|
48
48
|
//! The owned data of the HT
|
49
|
-
|
49
|
+
unsafe_unique_array<data_t> owned_data;
|
50
50
|
//! Information on whether or not a specific group has any entries
|
51
|
-
|
51
|
+
unsafe_unique_array<bool> group_is_set;
|
52
52
|
|
53
53
|
//! The minimum values for each of the group columns
|
54
54
|
vector<Value> group_minima;
|
@@ -113,7 +113,7 @@ private:
|
|
113
113
|
Vector statev;
|
114
114
|
|
115
115
|
//! The actual window segment tree: an array of aggregate states that represent all the intermediate nodes
|
116
|
-
|
116
|
+
unsafe_unique_array<data_t> levels_flat_native;
|
117
117
|
//! For each level, the starting location in the levels_flat_native array
|
118
118
|
vector<idx_t> levels_flat_start;
|
119
119
|
|
@@ -55,7 +55,7 @@ struct WriteCSVData : public BaseCSVData {
|
|
55
55
|
//! The size of the CSV file (in bytes) that we buffer before we flush it to disk
|
56
56
|
idx_t flush_size = 4096 * 8;
|
57
57
|
//! For each byte whether or not the CSV file requires quotes when containing the byte
|
58
|
-
|
58
|
+
unsafe_unique_array<bool> requires_quotes;
|
59
59
|
};
|
60
60
|
|
61
61
|
struct ColumnInfo {
|
@@ -27,12 +27,12 @@ struct SingleJoinRelation {
|
|
27
27
|
|
28
28
|
//! Set of relations, used in the join graph.
|
29
29
|
struct JoinRelationSet {
|
30
|
-
JoinRelationSet(
|
30
|
+
JoinRelationSet(unsafe_unique_array<idx_t> relations, idx_t count) : relations(std::move(relations)), count(count) {
|
31
31
|
}
|
32
32
|
|
33
33
|
string ToString() const;
|
34
34
|
|
35
|
-
|
35
|
+
unsafe_unique_array<idx_t> relations;
|
36
36
|
idx_t count;
|
37
37
|
|
38
38
|
static bool IsSubset(JoinRelationSet &super, JoinRelationSet &sub);
|
@@ -55,7 +55,7 @@ public:
|
|
55
55
|
//! Create or get a JoinRelationSet from a set of relation bindings
|
56
56
|
JoinRelationSet &GetJoinRelation(unordered_set<idx_t> &bindings);
|
57
57
|
//! Create or get a JoinRelationSet from a (sorted, duplicate-free!) list of relations
|
58
|
-
JoinRelationSet &GetJoinRelation(
|
58
|
+
JoinRelationSet &GetJoinRelation(unsafe_unique_array<idx_t> relations, idx_t count);
|
59
59
|
//! Union two sets of relations together and create a new relation set
|
60
60
|
JoinRelationSet &Union(JoinRelationSet &left, JoinRelationSet &right);
|
61
61
|
// //! Create the set difference of left \ right (i.e. all elements in left that are not in right)
|
@@ -92,7 +92,7 @@ public:
|
|
92
92
|
result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
|
93
93
|
return child->alias.empty() || !add_alias
|
94
94
|
? child->ToString()
|
95
|
-
:
|
95
|
+
: StringUtil::Format("%s := %s", SQLIdentifier(child->alias), child->ToString());
|
96
96
|
});
|
97
97
|
// ordered aggregate
|
98
98
|
if (order_bys && !order_bys->orders.empty()) {
|
@@ -96,8 +96,8 @@ public:
|
|
96
96
|
auto child_string = entry.children[1]->ToString();
|
97
97
|
D_ASSERT(child_string.size() >= 3);
|
98
98
|
D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
|
99
|
-
return "("
|
100
|
-
|
99
|
+
return StringUtil::Format("(%s).%s", entry.children[0]->ToString(),
|
100
|
+
SQLIdentifier(child_string.substr(1, child_string.size() - 2)));
|
101
101
|
}
|
102
102
|
case ExpressionType::ARRAY_CONSTRUCTOR: {
|
103
103
|
string result = "(ARRAY[";
|
@@ -17,9 +17,14 @@ public:
|
|
17
17
|
//! Returns true if the given text matches a keyword of the parser
|
18
18
|
static bool IsKeyword(const string &text);
|
19
19
|
|
20
|
+
static string EscapeQuotes(const string &text, char quote = '"');
|
21
|
+
|
20
22
|
//! Returns true if the given string needs to be quoted when written as an identifier
|
21
23
|
static bool RequiresQuotes(const string &text, bool allow_caps = true);
|
22
24
|
|
25
|
+
//! Writes a string that is quoted
|
26
|
+
static string WriteQuoted(const string &text, char quote = '\'');
|
27
|
+
|
23
28
|
//! Writes a string that is optionally quoted + escaped so it can be used as an identifier
|
24
29
|
static string WriteOptionallyQuoted(const string &text, char quote = '"', bool allow_caps = true);
|
25
30
|
};
|