|
| 1 | +diff --git a/src/include/duckdb/main/database.hpp b/src/include/duckdb/main/database.hpp |
| 2 | +index 222a36c051..b2bcd97599 100644 |
| 3 | +--- a/src/include/duckdb/main/database.hpp |
| 4 | ++++ b/src/include/duckdb/main/database.hpp |
| 5 | +@@ -37,6 +37,7 @@ struct ExtensionInfo { |
| 6 | + }; |
| 7 | + |
| 8 | + class DatabaseInstance : public enable_shared_from_this<DatabaseInstance> { |
| 9 | ++ unordered_map<string, string> extensionsRepos; |
| 10 | + friend class DuckDB; |
| 11 | + |
| 12 | + public: |
| 13 | +@@ -46,6 +47,16 @@ public: |
| 14 | + DBConfig config; |
| 15 | + |
| 16 | + public: |
| 17 | ++ void SetPreferredRepository(const string& extension, const string &repository) { |
| 18 | ++ extensionsRepos[extension] = repository; |
| 19 | ++ } |
| 20 | ++ string GetPreferredRepository(const string& extension) const { |
| 21 | ++ auto it = extensionsRepos.find(extension); |
| 22 | ++ if (it != extensionsRepos.end()) { |
| 23 | ++ return it->second; |
| 24 | ++ } |
| 25 | ++ return ""; |
| 26 | ++ } |
| 27 | + BufferPool &GetBufferPool() const; |
| 28 | + DUCKDB_API SecretManager &GetSecretManager(); |
| 29 | + DUCKDB_API BufferManager &GetBufferManager(); |
| 30 | +diff --git a/src/main/extension/extension_install.cpp b/src/main/extension/extension_install.cpp |
| 31 | +index b0ca9fb775..4774e26450 100644 |
| 32 | +--- a/src/main/extension/extension_install.cpp |
| 33 | ++++ b/src/main/extension/extension_install.cpp |
| 34 | +@@ -144,6 +144,9 @@ bool ExtensionHelper::CreateSuggestions(const string &extension_name, string &me |
| 35 | + unique_ptr<ExtensionInstallInfo> ExtensionHelper::InstallExtension(DatabaseInstance &db, FileSystem &fs, |
| 36 | + const string &extension, |
| 37 | + ExtensionInstallOptions &options) { |
| 38 | ++ if (options.repository) { |
| 39 | ++ db.SetPreferredRepository(extension, options.repository->path); |
| 40 | ++ } |
| 41 | + #ifdef WASM_LOADABLE_EXTENSIONS |
| 42 | + // Install is currently a no-op |
| 43 | + return nullptr; |
| 44 | +@@ -154,11 +157,14 @@ unique_ptr<ExtensionInstallInfo> ExtensionHelper::InstallExtension(DatabaseInsta |
| 45 | + |
| 46 | + unique_ptr<ExtensionInstallInfo> ExtensionHelper::InstallExtension(ClientContext &context, const string &extension, |
| 47 | + ExtensionInstallOptions &options) { |
| 48 | ++ auto &db = DatabaseInstance::GetDatabase(context); |
| 49 | ++ if (options.repository) { |
| 50 | ++ db.SetPreferredRepository(extension, options.repository->path); |
| 51 | ++ } |
| 52 | + #ifdef WASM_LOADABLE_EXTENSIONS |
| 53 | + // Install is currently a no-op |
| 54 | + return nullptr; |
| 55 | + #endif |
| 56 | +- auto &db = DatabaseInstance::GetDatabase(context); |
| 57 | + auto &fs = FileSystem::GetFileSystem(context); |
| 58 | + string local_path = ExtensionDirectory(context); |
| 59 | + optional_ptr<HTTPLogger> http_logger = |
| 60 | +diff --git a/src/main/extension/extension_load.cpp b/src/main/extension/extension_load.cpp |
| 61 | +index c0a37ea97a..2916dc2611 100644 |
| 62 | +--- a/src/main/extension/extension_load.cpp |
| 63 | ++++ b/src/main/extension/extension_load.cpp |
| 64 | +@@ -301,7 +301,19 @@ bool ExtensionHelper::TryInitialLoad(DatabaseInstance &db, FileSystem &fs, const |
| 65 | + direct_load = false; |
| 66 | + string extension_name = ApplyExtensionAlias(extension); |
| 67 | + #ifdef WASM_LOADABLE_EXTENSIONS |
| 68 | +- string url_template = ExtensionUrlTemplate(&config, ""); |
| 69 | ++ ExtensionRepository repository; |
| 70 | ++ string custom_endpoint = db.config.options.custom_extension_repo; |
| 71 | ++ if (!custom_endpoint.empty()) { |
| 72 | ++ repository = ExtensionRepository("custom", custom_endpoint); |
| 73 | ++ } |
| 74 | ++ { |
| 75 | ++ auto preferredRepo = db.GetPreferredRepository(extension); |
| 76 | ++ if (!preferredRepo.empty()) { |
| 77 | ++ repository = ExtensionRepository("x", preferredRepo); |
| 78 | ++ } |
| 79 | ++ } |
| 80 | ++ |
| 81 | ++ string url_template = ExtensionUrlTemplate(db, repository, ""); |
| 82 | + string url = ExtensionFinalizeUrlTemplate(url_template, extension_name); |
| 83 | + |
| 84 | + char *str = (char *)EM_ASM_PTR( |
0 commit comments