From 74c6e600ba72ecf929a24220cf6987a1ec72e02d Mon Sep 17 00:00:00 2001 From: Carlo Piovesan Date: Wed, 25 Sep 2024 14:13:39 +0200 Subject: [PATCH 1/2] Remove patch already absorbed --- patches/duckdb/file_open_flags.patch | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 patches/duckdb/file_open_flags.patch diff --git a/patches/duckdb/file_open_flags.patch b/patches/duckdb/file_open_flags.patch deleted file mode 100644 index 484d2a5b0..000000000 --- a/patches/duckdb/file_open_flags.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/src/include/duckdb/common/file_open_flags.hpp b/src/include/duckdb/common/file_open_flags.hpp -index c4a0f8df7d..b469e338cf 100644 ---- a/src/include/duckdb/common/file_open_flags.hpp -+++ b/src/include/duckdb/common/file_open_flags.hpp -@@ -107,6 +107,9 @@ public: - inline bool ReturnNullIfExists() const { - return flags & FILE_FLAGS_NULL_IF_EXISTS; - } -+ inline idx_t GetFlagsInternal() const { -+ return flags; -+ } - - private: - idx_t flags = 0; From d9f9bcd0e49a20e21fadfccc62e2479042df98f7 Mon Sep 17 00:00:00 2001 From: Carlo Piovesan Date: Wed, 25 Sep 2024 14:17:08 +0200 Subject: [PATCH 2/2] Add patch to specify via INSTALL the repository from where to load extensions --- ...ension_install_rework_with_community.patch | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 patches/duckdb/extension_install_rework_with_community.patch diff --git a/patches/duckdb/extension_install_rework_with_community.patch b/patches/duckdb/extension_install_rework_with_community.patch new file mode 100644 index 000000000..833177d58 --- /dev/null +++ b/patches/duckdb/extension_install_rework_with_community.patch @@ -0,0 +1,84 @@ +diff --git a/src/include/duckdb/main/database.hpp b/src/include/duckdb/main/database.hpp +index 222a36c051..b2bcd97599 100644 +--- a/src/include/duckdb/main/database.hpp ++++ b/src/include/duckdb/main/database.hpp +@@ -37,6 +37,7 @@ struct ExtensionInfo { + }; + + class DatabaseInstance : public enable_shared_from_this { ++ unordered_map extensionsRepos; + friend class DuckDB; + + public: +@@ -46,6 +47,16 @@ public: + DBConfig config; + + public: ++ void SetPreferredRepository(const string& extension, const string &repository) { ++ extensionsRepos[extension] = repository; ++ } ++ string GetPreferredRepository(const string& extension) const { ++ auto it = extensionsRepos.find(extension); ++ if (it != extensionsRepos.end()) { ++ return it->second; ++ } ++ return ""; ++ } + BufferPool &GetBufferPool() const; + DUCKDB_API SecretManager &GetSecretManager(); + DUCKDB_API BufferManager &GetBufferManager(); +diff --git a/src/main/extension/extension_install.cpp b/src/main/extension/extension_install.cpp +index b0ca9fb775..4774e26450 100644 +--- a/src/main/extension/extension_install.cpp ++++ b/src/main/extension/extension_install.cpp +@@ -144,6 +144,9 @@ bool ExtensionHelper::CreateSuggestions(const string &extension_name, string &me + unique_ptr ExtensionHelper::InstallExtension(DatabaseInstance &db, FileSystem &fs, + const string &extension, + ExtensionInstallOptions &options) { ++ if (options.repository) { ++ db.SetPreferredRepository(extension, options.repository->path); ++ } + #ifdef WASM_LOADABLE_EXTENSIONS + // Install is currently a no-op + return nullptr; +@@ -154,11 +157,14 @@ unique_ptr ExtensionHelper::InstallExtension(DatabaseInsta + + unique_ptr ExtensionHelper::InstallExtension(ClientContext &context, const string &extension, + ExtensionInstallOptions &options) { ++ auto &db = DatabaseInstance::GetDatabase(context); ++ if (options.repository) { ++ db.SetPreferredRepository(extension, options.repository->path); ++ } + #ifdef WASM_LOADABLE_EXTENSIONS + // Install is currently a no-op + return nullptr; + #endif +- auto &db = DatabaseInstance::GetDatabase(context); + auto &fs = FileSystem::GetFileSystem(context); + string local_path = ExtensionDirectory(context); + optional_ptr http_logger = +diff --git a/src/main/extension/extension_load.cpp b/src/main/extension/extension_load.cpp +index c0a37ea97a..2916dc2611 100644 +--- a/src/main/extension/extension_load.cpp ++++ b/src/main/extension/extension_load.cpp +@@ -301,7 +301,19 @@ bool ExtensionHelper::TryInitialLoad(DatabaseInstance &db, FileSystem &fs, const + direct_load = false; + string extension_name = ApplyExtensionAlias(extension); + #ifdef WASM_LOADABLE_EXTENSIONS +- string url_template = ExtensionUrlTemplate(&config, ""); ++ ExtensionRepository repository; ++ string custom_endpoint = db.config.options.custom_extension_repo; ++ if (!custom_endpoint.empty()) { ++ repository = ExtensionRepository("custom", custom_endpoint); ++ } ++ { ++ auto preferredRepo = db.GetPreferredRepository(extension); ++ if (!preferredRepo.empty()) { ++ repository = ExtensionRepository("x", preferredRepo); ++ } ++ } ++ ++ string url_template = ExtensionUrlTemplate(db, repository, ""); + string url = ExtensionFinalizeUrlTemplate(url_template, extension_name); + + char *str = (char *)EM_ASM_PTR(