diff --git a/patches/duckdb/extension_install_rework.patch b/patches/duckdb/extension_install_rework.patch index a689cabf6..ad04aeb74 100644 --- a/patches/duckdb/extension_install_rework.patch +++ b/patches/duckdb/extension_install_rework.patch @@ -1,3 +1,18 @@ +diff --git a/src/include/duckdb/main/database.hpp b/src/include/duckdb/main/database.hpp +index 222a36c051..fb895920ef 100644 +--- a/src/include/duckdb/main/database.hpp ++++ b/src/include/duckdb/main/database.hpp +@@ -91,6 +91,10 @@ private: + ValidChecker db_validity; + unique_ptr db_file_system; + shared_ptr db_cache_entry; ++public: ++ static void SetPreferredRepository(const string& extension, const string &repository); ++ static string GetPreferredRepository(const string& extension); ++ static unordered_map extensionsRepos; + }; + + //! The database object. This object holds the catalog and all the diff --git a/src/include/duckdb/main/extension_install_info.hpp b/src/include/duckdb/main/extension_install_info.hpp index 6ccd1a1156..8040f537b6 100644 --- a/src/include/duckdb/main/extension_install_info.hpp @@ -15,11 +30,44 @@ index 6ccd1a1156..8040f537b6 100644 //! Debugging repositories (target local, relative paths that are produced by DuckDB's build system) static constexpr const char *BUILD_DEBUG_REPOSITORY_PATH = "./build/debug/repository"; +diff --git a/src/main/database.cpp b/src/main/database.cpp +index 4308c4a016..fe23c36ead 100644 +--- a/src/main/database.cpp ++++ b/src/main/database.cpp +@@ -328,6 +328,28 @@ DuckDB::DuckDB(DatabaseInstance &instance_p) : instance(instance_p.shared_from_t + DuckDB::~DuckDB() { + } + ++unordered_map DatabaseInstance::extensionsRepos = {}; ++ ++void DatabaseInstance::SetPreferredRepository(const string& extension, const string &repository) { ++ auto &x = extensionsRepos; ++ auto it = x.find(extension); ++ if (it != x.end()) { ++ it->second=repository; ++ } else { ++ x.emplace(extension, repository); ++ } ++} ++ ++string DatabaseInstance::GetPreferredRepository(const string& extension) { ++ const auto &x = extensionsRepos; ++ auto it = x.find(extension); ++ if (it != x.end()) { ++ return it->second; ++ } ++ return ""; ++} ++ ++ + SecretManager &DatabaseInstance::GetSecretManager() { + return *config.secret_manager; + } diff --git a/src/main/extension/extension_helper.cpp b/src/main/extension/extension_helper.cpp -index c821caedea..aae791b786 100644 +index 494832417e..17a39d04b4 100644 --- a/src/main/extension/extension_helper.cpp +++ b/src/main/extension/extension_helper.cpp -@@ -319,7 +319,6 @@ vector ExtensionHelper::UpdateExtensions(ClientContext &c +@@ -328,7 +328,6 @@ vector ExtensionHelper::UpdateExtensions(ClientContext &c vector result; DatabaseInstance &db = DatabaseInstance::GetDatabase(context); @@ -27,7 +75,7 @@ index c821caedea..aae791b786 100644 case_insensitive_set_t seen_extensions; // scan the install directory for installed extensions -@@ -336,7 +335,6 @@ vector ExtensionHelper::UpdateExtensions(ClientContext &c +@@ -345,7 +344,6 @@ vector ExtensionHelper::UpdateExtensions(ClientContext &c result.push_back(UpdateExtensionInternal(context, db, fs, fs.JoinPath(ext_directory, path), extension_name)); }); @@ -36,10 +84,30 @@ index c821caedea..aae791b786 100644 return result; } diff --git a/src/main/extension/extension_install.cpp b/src/main/extension/extension_install.cpp -index d190ea197c..157db58641 100644 +index b0ca9fb775..67dfcdfb26 100644 --- a/src/main/extension/extension_install.cpp +++ b/src/main/extension/extension_install.cpp -@@ -204,7 +204,7 @@ string ExtensionHelper::ExtensionUrlTemplate(optional_ptr ExtensionHelper::InstallExtension(DatabaseInstance &db, FileSystem &fs, + const string &extension, + ExtensionInstallOptions &options) { ++ if (options.repository) { ++ DatabaseInstance::SetPreferredRepository(extension, options.repository->path); ++ } + #ifdef WASM_LOADABLE_EXTENSIONS + // Install is currently a no-op + return nullptr; +@@ -154,6 +157,9 @@ unique_ptr ExtensionHelper::InstallExtension(DatabaseInsta + + unique_ptr ExtensionHelper::InstallExtension(ClientContext &context, const string &extension, + ExtensionInstallOptions &options) { ++ if (options.repository) { ++ DatabaseInstance::SetPreferredRepository(extension, options.repository->path); ++ } + #ifdef WASM_LOADABLE_EXTENSIONS + // Install is currently a no-op + return nullptr; +@@ -198,7 +204,7 @@ string ExtensionHelper::ExtensionUrlTemplate(optional_ptr