duckdb 0.8.2-dev5080.0 → 0.8.2-dev5154.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/duckdb/extension/icu/icu-dateadd.cpp +11 -19
- package/src/duckdb/extension/icu/icu-datepart.cpp +44 -53
- package/src/duckdb/extension/icu/icu-datesub.cpp +10 -15
- package/src/duckdb/extension/icu/icu-datetrunc.cpp +6 -8
- package/src/duckdb/extension/icu/icu-list-range.cpp +6 -8
- package/src/duckdb/extension/icu/icu-makedate.cpp +8 -10
- package/src/duckdb/extension/icu/icu-strptime.cpp +30 -32
- package/src/duckdb/extension/icu/icu-table-range.cpp +6 -9
- package/src/duckdb/extension/icu/icu-timebucket.cpp +5 -7
- package/src/duckdb/extension/icu/icu-timezone.cpp +18 -29
- package/src/duckdb/extension/icu/icu_extension.cpp +18 -25
- package/src/duckdb/extension/icu/include/icu-dateadd.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-datepart.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-datesub.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-datetrunc.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-list-range.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-makedate.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-strptime.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-table-range.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-timebucket.hpp +1 -1
- package/src/duckdb/extension/icu/include/icu-timezone.hpp +1 -1
- package/src/duckdb/extension/json/json_functions/read_json.cpp +15 -0
- package/src/duckdb/src/catalog/catalog.cpp +4 -0
- package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +75 -27
- package/src/duckdb/src/core_functions/function_list.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/struct/struct_pack.cpp +22 -18
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +4 -1
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/core_functions/scalar/struct_functions.hpp +5 -2
- package/src/duckdb/src/include/duckdb/main/config.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +26 -0
- package/src/duckdb/src/include/duckdb/main/extension_util.hpp +14 -0
- package/src/duckdb/src/include/duckdb/planner/extension_callback.hpp +26 -0
- package/src/duckdb/src/main/database.cpp +6 -0
- package/src/duckdb/src/main/extension/extension_util.cpp +56 -0
- package/src/duckdb/src/main/settings/settings.cpp +4 -0
- package/src/duckdb/src/storage/single_file_block_manager.cpp +11 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
2
|
-
#define DUCKDB_VERSION "0.8.2-
|
2
|
+
#define DUCKDB_VERSION "0.8.2-dev5154"
|
3
3
|
#endif
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
5
|
+
#define DUCKDB_SOURCE_ID "78bea4f92a"
|
6
6
|
#endif
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
8
8
|
#include "duckdb/main/database.hpp"
|
@@ -34,9 +34,12 @@ struct StructPackFun {
|
|
34
34
|
};
|
35
35
|
|
36
36
|
struct RowFun {
|
37
|
-
using ALIAS = StructPackFun;
|
38
|
-
|
39
37
|
static constexpr const char *Name = "row";
|
38
|
+
static constexpr const char *Parameters = "any";
|
39
|
+
static constexpr const char *Description = "Creates an unnamed STRUCT containing the argument values.";
|
40
|
+
static constexpr const char *Example = "row(4, 'hello')";
|
41
|
+
|
42
|
+
static ScalarFunction GetFunction();
|
40
43
|
};
|
41
44
|
|
42
45
|
} // namespace duckdb
|
@@ -39,6 +39,7 @@ class CompressionFunction;
|
|
39
39
|
class TableFunctionRef;
|
40
40
|
class OperatorExtension;
|
41
41
|
class StorageExtension;
|
42
|
+
class ExtensionCallback;
|
42
43
|
|
43
44
|
struct CompressionFunctionSet;
|
44
45
|
struct DBConfig;
|
@@ -212,6 +213,8 @@ public:
|
|
212
213
|
case_insensitive_map_t<duckdb::unique_ptr<StorageExtension>> storage_extensions;
|
213
214
|
//! A buffer pool can be shared across multiple databases (if desired).
|
214
215
|
shared_ptr<BufferPool> buffer_pool;
|
216
|
+
//! Set of callbacks that can be installed by extensions
|
217
|
+
vector<unique_ptr<ExtensionCallback>> extension_callbacks;
|
215
218
|
|
216
219
|
public:
|
217
220
|
DUCKDB_API static DBConfig &GetConfig(ClientContext &context);
|
@@ -218,6 +218,32 @@ static constexpr ExtensionEntry EXTENSION_COPY_FUNCTIONS[] = {{"parquet", "parqu
|
|
218
218
|
static constexpr ExtensionEntry EXTENSION_TYPES[] = {
|
219
219
|
{"json", "json"}, {"inet", "inet"}, {"geometry", "spatial"}}; // END_OF_EXTENSION_TYPES
|
220
220
|
|
221
|
+
// Note: these are currently hardcoded in scripts/generate_extensions_function.py
|
222
|
+
// TODO: automate by passing though to script via duckdb
|
223
|
+
static constexpr ExtensionEntry EXTENSION_COLLATIONS[] = {
|
224
|
+
{"af", "icu"}, {"am", "icu"}, {"ar", "icu"}, {"ar_sa", "icu"}, {"as", "icu"}, {"az", "icu"},
|
225
|
+
{"be", "icu"}, {"bg", "icu"}, {"bn", "icu"}, {"bo", "icu"}, {"br", "icu"}, {"bs", "icu"},
|
226
|
+
{"ca", "icu"}, {"ceb", "icu"}, {"chr", "icu"}, {"cs", "icu"}, {"cy", "icu"}, {"da", "icu"},
|
227
|
+
{"de", "icu"}, {"de_at", "icu"}, {"dsb", "icu"}, {"dz", "icu"}, {"ee", "icu"}, {"el", "icu"},
|
228
|
+
{"en", "icu"}, {"en_us", "icu"}, {"eo", "icu"}, {"es", "icu"}, {"et", "icu"}, {"fa", "icu"},
|
229
|
+
{"fa_af", "icu"}, {"ff", "icu"}, {"fi", "icu"}, {"fil", "icu"}, {"fo", "icu"}, {"fr", "icu"},
|
230
|
+
{"fr_ca", "icu"}, {"fy", "icu"}, {"ga", "icu"}, {"gl", "icu"}, {"gu", "icu"}, {"ha", "icu"},
|
231
|
+
{"haw", "icu"}, {"he", "icu"}, {"he_il", "icu"}, {"hi", "icu"}, {"hr", "icu"}, {"hsb", "icu"},
|
232
|
+
{"hu", "icu"}, {"hy", "icu"}, {"id", "icu"}, {"id_id", "icu"}, {"ig", "icu"}, {"is", "icu"},
|
233
|
+
{"it", "icu"}, {"ja", "icu"}, {"ka", "icu"}, {"kk", "icu"}, {"kl", "icu"}, {"km", "icu"},
|
234
|
+
{"kn", "icu"}, {"ko", "icu"}, {"kok", "icu"}, {"ku", "icu"}, {"ky", "icu"}, {"lb", "icu"},
|
235
|
+
{"lkt", "icu"}, {"ln", "icu"}, {"lo", "icu"}, {"lt", "icu"}, {"lv", "icu"}, {"mk", "icu"},
|
236
|
+
{"ml", "icu"}, {"mn", "icu"}, {"mr", "icu"}, {"ms", "icu"}, {"mt", "icu"}, {"my", "icu"},
|
237
|
+
{"nb", "icu"}, {"nb_no", "icu"}, {"ne", "icu"}, {"nl", "icu"}, {"nn", "icu"}, {"om", "icu"},
|
238
|
+
{"or", "icu"}, {"pa", "icu"}, {"pa_in", "icu"}, {"pl", "icu"}, {"ps", "icu"}, {"pt", "icu"},
|
239
|
+
{"ro", "icu"}, {"ru", "icu"}, {"sa", "icu"}, {"se", "icu"}, {"si", "icu"}, {"sk", "icu"},
|
240
|
+
{"sl", "icu"}, {"smn", "icu"}, {"sq", "icu"}, {"sr", "icu"}, {"sr_ba", "icu"}, {"sr_me", "icu"},
|
241
|
+
{"sr_rs", "icu"}, {"sv", "icu"}, {"sw", "icu"}, {"ta", "icu"}, {"te", "icu"}, {"th", "icu"},
|
242
|
+
{"tk", "icu"}, {"to", "icu"}, {"tr", "icu"}, {"ug", "icu"}, {"uk", "icu"}, {"ur", "icu"},
|
243
|
+
{"uz", "icu"}, {"vi", "icu"}, {"wae", "icu"}, {"wo", "icu"}, {"xh", "icu"}, {"yi", "icu"},
|
244
|
+
{"yo", "icu"}, {"yue", "icu"}, {"yue_cn", "icu"}, {"zh", "icu"}, {"zh_cn", "icu"}, {"zh_hk", "icu"},
|
245
|
+
{"zh_mo", "icu"}, {"zh_sg", "icu"}, {"zh_tw", "icu"}, {"zu", "icu"}}; // END_OF_EXTENSION_COLLATIONS
|
246
|
+
|
221
247
|
// Note: these are currently hardcoded in scripts/generate_extensions_function.py
|
222
248
|
// TODO: automate by passing though to script via duckdb
|
223
249
|
static constexpr ExtensionEntry EXTENSION_FILE_PREFIXES[] = {
|
@@ -14,6 +14,7 @@
|
|
14
14
|
|
15
15
|
namespace duckdb {
|
16
16
|
struct CreateMacroInfo;
|
17
|
+
struct CreateCollationInfo;
|
17
18
|
class DatabaseInstance;
|
18
19
|
|
19
20
|
//! The ExtensionUtil class contains methods that are useful for extensions
|
@@ -40,6 +41,19 @@ public:
|
|
40
41
|
//! Register a new macro function - throw an exception if the function already exists
|
41
42
|
DUCKDB_API static void RegisterFunction(DatabaseInstance &db, CreateMacroInfo &info);
|
42
43
|
|
44
|
+
//! Register a new collation
|
45
|
+
DUCKDB_API static void RegisterCollation(DatabaseInstance &db, CreateCollationInfo &info);
|
46
|
+
|
47
|
+
//! Returns a reference to the function in the catalog - throws an exception if it does not exist
|
48
|
+
DUCKDB_API static ScalarFunctionCatalogEntry &GetFunction(DatabaseInstance &db, const string &name);
|
49
|
+
DUCKDB_API static TableFunctionCatalogEntry &GetTableFunction(DatabaseInstance &db, const string &name);
|
50
|
+
|
51
|
+
//! Add a function overload
|
52
|
+
DUCKDB_API static void AddFunctionOverload(DatabaseInstance &db, ScalarFunction function);
|
53
|
+
DUCKDB_API static void AddFunctionOverload(DatabaseInstance &db, ScalarFunctionSet function);
|
54
|
+
|
55
|
+
DUCKDB_API static void AddFunctionOverload(DatabaseInstance &db, TableFunctionSet function);
|
56
|
+
|
43
57
|
//! Registers a new type
|
44
58
|
DUCKDB_API static void RegisterType(DatabaseInstance &db, string type_name, LogicalType type);
|
45
59
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
2
|
+
// DuckDB
|
3
|
+
//
|
4
|
+
// duckdb/planner/extension_callback.hpp
|
5
|
+
//
|
6
|
+
//
|
7
|
+
//===----------------------------------------------------------------------===//
|
8
|
+
|
9
|
+
#pragma once
|
10
|
+
|
11
|
+
#include "duckdb/common/common.hpp"
|
12
|
+
|
13
|
+
namespace duckdb {
|
14
|
+
class DatabaseInstance;
|
15
|
+
|
16
|
+
class ExtensionCallback {
|
17
|
+
public:
|
18
|
+
virtual ~ExtensionCallback() {
|
19
|
+
}
|
20
|
+
|
21
|
+
//! Called after an extension is finished loading
|
22
|
+
virtual void OnExtensionLoaded(DatabaseInstance &db, const string &name) {
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
} // namespace duckdb
|
@@ -19,6 +19,7 @@
|
|
19
19
|
#include "duckdb/storage/storage_extension.hpp"
|
20
20
|
#include "duckdb/storage/storage_manager.hpp"
|
21
21
|
#include "duckdb/transaction/transaction_manager.hpp"
|
22
|
+
#include "duckdb/planner/extension_callback.hpp"
|
22
23
|
|
23
24
|
#ifndef DUCKDB_NO_THREADS
|
24
25
|
#include "duckdb/common/thread.hpp"
|
@@ -381,6 +382,11 @@ bool DuckDB::ExtensionIsLoaded(const std::string &name) {
|
|
381
382
|
void DatabaseInstance::SetExtensionLoaded(const std::string &name) {
|
382
383
|
auto extension_name = ExtensionHelper::GetExtensionName(name);
|
383
384
|
loaded_extensions.insert(extension_name);
|
385
|
+
|
386
|
+
auto &callbacks = DBConfig::GetConfig(*this).extension_callbacks;
|
387
|
+
for (auto &callback : callbacks) {
|
388
|
+
callback->OnExtensionLoaded(*this, name);
|
389
|
+
}
|
384
390
|
}
|
385
391
|
|
386
392
|
bool DatabaseInstance::TryGetCurrentSetting(const std::string &key, Value &result) {
|
@@ -7,6 +7,9 @@
|
|
7
7
|
#include "duckdb/parser/parsed_data/create_scalar_function_info.hpp"
|
8
8
|
#include "duckdb/parser/parsed_data/create_table_function_info.hpp"
|
9
9
|
#include "duckdb/parser/parsed_data/create_macro_info.hpp"
|
10
|
+
#include "duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp"
|
11
|
+
#include "duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp"
|
12
|
+
#include "duckdb/parser/parsed_data/create_collation_info.hpp"
|
10
13
|
#include "duckdb/catalog/catalog.hpp"
|
11
14
|
#include "duckdb/main/config.hpp"
|
12
15
|
|
@@ -86,6 +89,59 @@ void ExtensionUtil::RegisterFunction(DatabaseInstance &db, CreateMacroInfo &info
|
|
86
89
|
system_catalog.CreateFunction(data, info);
|
87
90
|
}
|
88
91
|
|
92
|
+
void ExtensionUtil::RegisterCollation(DatabaseInstance &db, CreateCollationInfo &info) {
|
93
|
+
auto &system_catalog = Catalog::GetSystemCatalog(db);
|
94
|
+
auto data = CatalogTransaction::GetSystemTransaction(db);
|
95
|
+
info.on_conflict = OnCreateConflict::IGNORE_ON_CONFLICT;
|
96
|
+
system_catalog.CreateCollation(data, info);
|
97
|
+
}
|
98
|
+
|
99
|
+
void ExtensionUtil::AddFunctionOverload(DatabaseInstance &db, ScalarFunction function) {
|
100
|
+
auto &scalar_function = ExtensionUtil::GetFunction(db, function.name);
|
101
|
+
scalar_function.functions.AddFunction(std::move(function));
|
102
|
+
}
|
103
|
+
|
104
|
+
void ExtensionUtil::AddFunctionOverload(DatabaseInstance &db, ScalarFunctionSet functions) { // NOLINT
|
105
|
+
D_ASSERT(!functions.name.empty());
|
106
|
+
auto &scalar_function = ExtensionUtil::GetFunction(db, functions.name);
|
107
|
+
for (auto &function : functions.functions) {
|
108
|
+
function.name = functions.name;
|
109
|
+
scalar_function.functions.AddFunction(std::move(function));
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
void ExtensionUtil::AddFunctionOverload(DatabaseInstance &db, TableFunctionSet functions) { // NOLINT
|
114
|
+
auto &table_function = ExtensionUtil::GetTableFunction(db, functions.name);
|
115
|
+
for (auto &function : functions.functions) {
|
116
|
+
function.name = functions.name;
|
117
|
+
table_function.functions.AddFunction(std::move(function));
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
ScalarFunctionCatalogEntry &ExtensionUtil::GetFunction(DatabaseInstance &db, const string &name) {
|
122
|
+
D_ASSERT(!name.empty());
|
123
|
+
auto &system_catalog = Catalog::GetSystemCatalog(db);
|
124
|
+
auto data = CatalogTransaction::GetSystemTransaction(db);
|
125
|
+
auto &schema = system_catalog.GetSchema(data, DEFAULT_SCHEMA);
|
126
|
+
auto catalog_entry = schema.GetEntry(data, CatalogType::SCALAR_FUNCTION_ENTRY, name);
|
127
|
+
if (!catalog_entry) {
|
128
|
+
throw InvalidInputException("Function with name \"%s\" not found in ExtensionUtil::GetFunction", name);
|
129
|
+
}
|
130
|
+
return catalog_entry->Cast<ScalarFunctionCatalogEntry>();
|
131
|
+
}
|
132
|
+
|
133
|
+
TableFunctionCatalogEntry &ExtensionUtil::GetTableFunction(DatabaseInstance &db, const string &name) {
|
134
|
+
D_ASSERT(!name.empty());
|
135
|
+
auto &system_catalog = Catalog::GetSystemCatalog(db);
|
136
|
+
auto data = CatalogTransaction::GetSystemTransaction(db);
|
137
|
+
auto &schema = system_catalog.GetSchema(data, DEFAULT_SCHEMA);
|
138
|
+
auto catalog_entry = schema.GetEntry(data, CatalogType::TABLE_FUNCTION_ENTRY, name);
|
139
|
+
if (!catalog_entry) {
|
140
|
+
throw InvalidInputException("Function with name \"%s\" not found in ExtensionUtil::GetTableFunction", name);
|
141
|
+
}
|
142
|
+
return catalog_entry->Cast<TableFunctionCatalogEntry>();
|
143
|
+
}
|
144
|
+
|
89
145
|
void ExtensionUtil::RegisterType(DatabaseInstance &db, string type_name, LogicalType type) {
|
90
146
|
D_ASSERT(!type_name.empty());
|
91
147
|
CreateTypeInfo info(std::move(type_name), std::move(type));
|
@@ -21,6 +21,10 @@ namespace duckdb {
|
|
21
21
|
// Access Mode
|
22
22
|
//===--------------------------------------------------------------------===//
|
23
23
|
void AccessModeSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &input) {
|
24
|
+
if (db) {
|
25
|
+
throw InvalidInputException("Cannot change access_mode setting while database is running - it must be set when "
|
26
|
+
"opening or attaching the database");
|
27
|
+
}
|
24
28
|
auto parameter = StringUtil::Lower(input.ToString());
|
25
29
|
if (parameter == "automatic") {
|
26
30
|
config.options.access_mode = AccessMode::AUTOMATIC;
|
@@ -8,6 +8,7 @@
|
|
8
8
|
#include "duckdb/storage/metadata/metadata_writer.hpp"
|
9
9
|
#include "duckdb/storage/buffer_manager.hpp"
|
10
10
|
#include "duckdb/main/config.hpp"
|
11
|
+
#include "duckdb/main/database.hpp"
|
11
12
|
|
12
13
|
#include <algorithm>
|
13
14
|
#include <cstring>
|
@@ -16,12 +17,22 @@ namespace duckdb {
|
|
16
17
|
|
17
18
|
const char MainHeader::MAGIC_BYTES[] = "DUCK";
|
18
19
|
|
20
|
+
void SerializeVersionNumber(WriteStream &ser, const string &version_str) {
|
21
|
+
constexpr const idx_t MAX_VERSION_SIZE = 32;
|
22
|
+
data_t version[MAX_VERSION_SIZE];
|
23
|
+
memset(version, 0, MAX_VERSION_SIZE);
|
24
|
+
memcpy(version, version_str.c_str(), MinValue<idx_t>(version_str.size(), MAX_VERSION_SIZE));
|
25
|
+
ser.WriteData(version, MAX_VERSION_SIZE);
|
26
|
+
}
|
27
|
+
|
19
28
|
void MainHeader::Write(WriteStream &ser) {
|
20
29
|
ser.WriteData(const_data_ptr_cast(MAGIC_BYTES), MAGIC_BYTE_SIZE);
|
21
30
|
ser.Write<uint64_t>(version_number);
|
22
31
|
for (idx_t i = 0; i < FLAG_COUNT; i++) {
|
23
32
|
ser.Write<uint64_t>(flags[i]);
|
24
33
|
}
|
34
|
+
SerializeVersionNumber(ser, DuckDB::LibraryVersion());
|
35
|
+
SerializeVersionNumber(ser, DuckDB::SourceID());
|
25
36
|
}
|
26
37
|
|
27
38
|
void MainHeader::CheckMagicBytes(FileHandle &handle) {
|