1
+ diff --git a/src/include/duckdb/main/database.hpp b/src/include/duckdb/main/database.hpp
2
+ index 222a36c051..fb895920ef 100644
3
+ --- a/src/include/duckdb/main/database.hpp
4
+ +++ b/src/include/duckdb/main/database.hpp
5
+ @@ -91,6 +91,10 @@ private:
6
+ ValidChecker db_validity;
7
+ unique_ptr<DatabaseFileSystem> db_file_system;
8
+ shared_ptr<DatabaseCacheEntry> db_cache_entry;
9
+ + public:
10
+ + static void SetPreferredRepository(const string& extension, const string &repository);
11
+ + static string GetPreferredRepository(const string& extension);
12
+ + static unordered_map<string, string> extensionsRepos;
13
+ };
14
+
15
+ //! The database object. This object holds the catalog and all the
1
16
diff --git a/src/include/duckdb/main/extension_install_info.hpp b/src/include/duckdb/main/extension_install_info.hpp
2
17
index 6ccd1a1156..8040f537b6 100644
3
18
--- a/src/include/duckdb/main/extension_install_info.hpp
@@ -15,19 +30,52 @@ index 6ccd1a1156..8040f537b6 100644
15
30
16
31
//! Debugging repositories (target local, relative paths that are produced by DuckDB's build system)
17
32
static constexpr const char *BUILD_DEBUG_REPOSITORY_PATH = "./build/debug/repository";
33
+ diff --git a/src/main/database.cpp b/src/main/database.cpp
34
+ index 4308c4a016..fe23c36ead 100644
35
+ --- a/src/main/database.cpp
36
+ +++ b/src/main/database.cpp
37
+ @@ -328,6 +328,28 @@ DuckDB::DuckDB(DatabaseInstance &instance_p) : instance(instance_p.shared_from_t
38
+ DuckDB::~DuckDB() {
39
+ }
40
+
41
+ + unordered_map<string, string> DatabaseInstance::extensionsRepos = {};
42
+ +
43
+ + void DatabaseInstance::SetPreferredRepository(const string& extension, const string &repository) {
44
+ + auto &x = extensionsRepos;
45
+ + auto it = x.find(extension);
46
+ + if (it != x.end()) {
47
+ + it->second=repository;
48
+ + } else {
49
+ + x.emplace(extension, repository);
50
+ + }
51
+ + }
52
+ +
53
+ + string DatabaseInstance::GetPreferredRepository(const string& extension) {
54
+ + const auto &x = extensionsRepos;
55
+ + auto it = x.find(extension);
56
+ + if (it != x.end()) {
57
+ + return it->second;
58
+ + }
59
+ + return "";
60
+ + }
61
+ +
62
+ +
63
+ SecretManager &DatabaseInstance::GetSecretManager() {
64
+ return *config.secret_manager;
65
+ }
18
66
diff --git a/src/main/extension/extension_helper.cpp b/src/main/extension/extension_helper.cpp
19
- index c821caedea..aae791b786 100644
67
+ index 494832417e..17a39d04b4 100644
20
68
--- a/src/main/extension/extension_helper.cpp
21
69
+++ b/src/main/extension/extension_helper.cpp
22
- @@ -319 ,7 +319 ,6 @@ vector<ExtensionUpdateResult> ExtensionHelper::UpdateExtensions(ClientContext &c
70
+ @@ -328 ,7 +328 ,6 @@ vector<ExtensionUpdateResult> ExtensionHelper::UpdateExtensions(ClientContext &c
23
71
vector<ExtensionUpdateResult> result;
24
72
DatabaseInstance &db = DatabaseInstance::GetDatabase(context);
25
73
26
74
- #ifndef WASM_LOADABLE_EXTENSIONS
27
75
case_insensitive_set_t seen_extensions;
28
76
29
77
// scan the install directory for installed extensions
30
- @@ -336 ,7 +335 ,6 @@ vector<ExtensionUpdateResult> ExtensionHelper::UpdateExtensions(ClientContext &c
78
+ @@ -345 ,7 +344 ,6 @@ vector<ExtensionUpdateResult> ExtensionHelper::UpdateExtensions(ClientContext &c
31
79
32
80
result.push_back(UpdateExtensionInternal(context, db, fs, fs.JoinPath(ext_directory, path), extension_name));
33
81
});
@@ -36,10 +84,30 @@ index c821caedea..aae791b786 100644
36
84
return result;
37
85
}
38
86
diff --git a/src/main/extension/extension_install.cpp b/src/main/extension/extension_install.cpp
39
- index d190ea197c..157db58641 100644
87
+ index b0ca9fb775..67dfcdfb26 100644
40
88
--- a/src/main/extension/extension_install.cpp
41
89
+++ b/src/main/extension/extension_install.cpp
42
- @@ -204,7 +204,7 @@ string ExtensionHelper::ExtensionUrlTemplate(optional_ptr<const DatabaseInstance
90
+ @@ -144,6 +144,9 @@ bool ExtensionHelper::CreateSuggestions(const string &extension_name, string &me
91
+ unique_ptr<ExtensionInstallInfo> ExtensionHelper::InstallExtension(DatabaseInstance &db, FileSystem &fs,
92
+ const string &extension,
93
+ ExtensionInstallOptions &options) {
94
+ + if (options.repository) {
95
+ + DatabaseInstance::SetPreferredRepository(extension, options.repository->path);
96
+ + }
97
+ #ifdef WASM_LOADABLE_EXTENSIONS
98
+ // Install is currently a no-op
99
+ return nullptr;
100
+ @@ -154,6 +157,9 @@ unique_ptr<ExtensionInstallInfo> ExtensionHelper::InstallExtension(DatabaseInsta
101
+
102
+ unique_ptr<ExtensionInstallInfo> ExtensionHelper::InstallExtension(ClientContext &context, const string &extension,
103
+ ExtensionInstallOptions &options) {
104
+ + if (options.repository) {
105
+ + DatabaseInstance::SetPreferredRepository(extension, options.repository->path);
106
+ + }
107
+ #ifdef WASM_LOADABLE_EXTENSIONS
108
+ // Install is currently a no-op
109
+ return nullptr;
110
+ @@ -198,7 +204,7 @@ string ExtensionHelper::ExtensionUrlTemplate(optional_ptr<const DatabaseInstance
43
111
versioned_path = "/${REVISION}/${PLATFORM}/${NAME}.duckdb_extension";
44
112
}
45
113
#ifdef WASM_LOADABLE_EXTENSIONS
@@ -49,10 +117,10 @@ index d190ea197c..157db58641 100644
49
117
#else
50
118
string default_endpoint = ExtensionRepository::DEFAULT_REPOSITORY_URL;
51
119
diff --git a/src/main/extension/extension_load.cpp b/src/main/extension/extension_load.cpp
52
- index 7fe4fcb3db..3bdedd191c 100644
120
+ index c0a37ea97a..6410048fc1 100644
53
121
--- a/src/main/extension/extension_load.cpp
54
122
+++ b/src/main/extension/extension_load.cpp
55
- @@ -295 ,7 +295,13 @@ bool ExtensionHelper::TryInitialLoad(DatabaseInstance &db, FileSystem &fs, const
123
+ @@ -301 ,7 +301,20 @@ bool ExtensionHelper::TryInitialLoad(DatabaseInstance &db, FileSystem &fs, const
56
124
direct_load = false;
57
125
string extension_name = ApplyExtensionAlias(extension);
58
126
#ifdef WASM_LOADABLE_EXTENSIONS
@@ -63,11 +131,18 @@ index 7fe4fcb3db..3bdedd191c 100644
63
131
+ if (!custom_endpoint.empty()) {
64
132
+ repository = ExtensionRepository("custom", custom_endpoint);
65
133
+ }
134
+ + {
135
+ + auto preferredRepo = DatabaseInstance::GetPreferredRepository(extension);
136
+ + if (!preferredRepo.empty()) {
137
+ + repository = ExtensionRepository("x", preferredRepo);
138
+ + }
139
+ + }
140
+ +
66
141
+ string url_template = ExtensionUrlTemplate(db, repository, "");
67
142
string url = ExtensionFinalizeUrlTemplate(url_template, extension_name);
68
143
69
144
char *str = (char *)EM_ASM_PTR(
70
- @@ -336 ,73 +342 ,223 @@ bool ExtensionHelper::TryInitialLoad(DatabaseInstance &db, FileSystem &fs, const
145
+ @@ -342 ,73 +355 ,223 @@ bool ExtensionHelper::TryInitialLoad(DatabaseInstance &db, FileSystem &fs, const
71
146
direct_load = true;
72
147
filename = fs.ExpandPath(filename);
73
148
}
@@ -345,7 +420,7 @@ index 7fe4fcb3db..3bdedd191c 100644
345
420
#else
346
421
auto dopen_from = filename;
347
422
#endif
348
- @@ -420 ,25 +576 ,27 @@ bool ExtensionHelper::TryInitialLoad(DatabaseInstance &db, FileSystem &fs, const
423
+ @@ -426 ,25 +589 ,27 @@ bool ExtensionHelper::TryInitialLoad(DatabaseInstance &db, FileSystem &fs, const
349
424
result.lib_hdl = lib_hdl;
350
425
351
426
if (!direct_load) {
0 commit comments