Skip to content

Commit 13c05f3

Browse files
committed
Add builtin_httpfs SQL option to allow keep using current in-build httpfs
Current default is `true`, that makes so no changes are done. Via `SET builtin_httpfs = false` then on explcit httpfs LOAD or on autoloading external httpfs will be used
1 parent b2915fe commit 13c05f3

File tree

3 files changed

+52
-9
lines changed

3 files changed

+52
-9
lines changed

lib/src/webdb.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "duckdb/common/arrow/arrow.hpp"
3333
#include "duckdb/common/arrow/arrow_converter.hpp"
3434
#include "duckdb/common/file_system.hpp"
35+
#include "duckdb/common/http_util.hpp"
3536
#include "duckdb/common/types.hpp"
3637
#include "duckdb/common/types/data_chunk.hpp"
3738
#include "duckdb/common/types/vector.hpp"
@@ -70,6 +71,9 @@
7071
#include "rapidjson/writer.h"
7172

7273
namespace duckdb {
74+
75+
bool preloaded_httpfs{true};
76+
7377
namespace web {
7478

7579
static constexpr int64_t DEFAULT_QUERY_POLLING_INTERVAL = 100;
@@ -753,6 +757,9 @@ void WebDB::RegisterCustomExtensionOptions(shared_ptr<duckdb::DuckDB> database)
753757

754758
// Register S3 Config parameters
755759
if (webfs) {
760+
auto callback_builtin_httpfs = [](ClientContext& context, SetScope scope, Value& parameter) {
761+
preloaded_httpfs = BooleanValue::Get(parameter);
762+
};
756763
auto callback_s3_region = [](ClientContext& context, SetScope scope, Value& parameter) {
757764
auto webfs = io::WebFileSystem::Get();
758765
webfs->Config()->duckdb_config_options.s3_region = StringValue::Get(parameter);
@@ -784,6 +791,8 @@ void WebDB::RegisterCustomExtensionOptions(shared_ptr<duckdb::DuckDB> database)
784791
webfs->IncrementCacheEpoch();
785792
};
786793

794+
config.AddExtensionOption("builtin_httpfs", "Use built-in HTTPS support", LogicalType::BOOLEAN, true,
795+
callback_builtin_httpfs);
787796
config.AddExtensionOption("s3_region", "S3 Region", LogicalType::VARCHAR, Value(), callback_s3_region);
788797
config.AddExtensionOption("s3_access_key_id", "S3 Access Key ID", LogicalType::VARCHAR, Value(),
789798
callback_s3_access_key_id);
@@ -961,6 +970,11 @@ arrow::Status WebDB::Open(std::string_view args_json) {
961970
#endif // WASM_LOADABLE_EXTENSIONS
962971
RegisterCustomExtensionOptions(db);
963972

973+
auto& config = duckdb::DBConfig::GetConfig(*db->instance);
974+
if (!config.http_util || config.http_util->GetName() != string("WasmHTTPUtils")) {
975+
config.http_util = make_shared_ptr<HTTPWasmUtil>();
976+
}
977+
964978
// Reset state that is specific to the old database
965979
connections_.clear();
966980
database_.reset();

patches/duckdb/extension_install_rework.patch

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
diff --git a/src/include/duckdb/main/database.hpp b/src/include/duckdb/main/database.hpp
2-
index d3c5fb9bd5..b3d0aaa09e 100644
2+
index d3c5fb9bd5..eace7b4af1 100644
33
--- a/src/include/duckdb/main/database.hpp
44
+++ b/src/include/duckdb/main/database.hpp
5-
@@ -100,6 +100,10 @@ private:
5+
@@ -100,6 +100,11 @@ private:
66
unique_ptr<ExternalFileCache> external_file_cache;
77

88
duckdb_ext_api_v1 (*create_api_v1)();
9+
+
910
+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;
11+
+ static void SetPreferredRepository(const string& extension, const string &repository);
12+
+ static string GetPreferredRepository(const string& extension);
13+
+ static unordered_map<string, string> extensionsRepos;
1314
};
1415

1516
//! The database object. This object holds the catalog and all the
@@ -31,10 +32,24 @@ index 6ccd1a1156..8040f537b6 100644
3132
//! Debugging repositories (target local, relative paths that are produced by DuckDB's build system)
3233
static constexpr const char *BUILD_DEBUG_REPOSITORY_PATH = "./build/debug/repository";
3334
diff --git a/src/main/database.cpp b/src/main/database.cpp
34-
index db6e1ed445..d495aab058 100644
35+
index 773f8d967a..fa089a47ee 100644
3536
--- a/src/main/database.cpp
3637
+++ b/src/main/database.cpp
37-
@@ -356,6 +356,28 @@ DuckDB::DuckDB(DatabaseInstance &instance_p) : instance(instance_p.shared_from_t
38+
@@ -1,5 +1,4 @@
39+
#include "duckdb/main/database.hpp"
40+
-
41+
#include "duckdb/catalog/catalog.hpp"
42+
#include "duckdb/common/virtual_file_system.hpp"
43+
#include "duckdb/execution/index/index_type_set.hpp"
44+
@@ -35,6 +34,7 @@
45+
#include "duckdb/common/thread.hpp"
46+
#endif
47+
48+
+
49+
namespace duckdb {
50+
51+
DBConfig::DBConfig() {
52+
@@ -357,6 +357,28 @@ DuckDB::DuckDB(DatabaseInstance &instance_p) : instance(instance_p.shared_from_t
3853
DuckDB::~DuckDB() {
3954
}
4055

@@ -63,11 +78,11 @@ index db6e1ed445..d495aab058 100644
6378
SecretManager &DatabaseInstance::GetSecretManager() {
6479
return *config.secret_manager;
6580
}
66-
@@ -507,6 +529,10 @@ idx_t DuckDB::NumberOfThreads() {
81+
@@ -508,6 +530,10 @@ idx_t DuckDB::NumberOfThreads() {
6782

6883
bool DatabaseInstance::ExtensionIsLoaded(const std::string &name) {
6984
auto extension_name = ExtensionHelper::GetExtensionName(name);
70-
+ if (extension_name == "httpfs") {
85+
+ if (extension_name == "httpfs" && preloaded_httpfs) {
7186
+ ExtensionInstallInfo info;
7287
+ SetExtensionLoaded(extension_name, info);
7388
+ }

patches/duckdb/preloaded_httpfs.patch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/src/include/duckdb/main/database.hpp b/src/include/duckdb/main/database.hpp
2+
index d3c5fb9bd5..adc2ac42e6 100644
3+
--- a/src/include/duckdb/main/database.hpp
4+
+++ b/src/include/duckdb/main/database.hpp
5+
@@ -17,6 +17,9 @@
6+
#include "duckdb/main/valid_checker.hpp"
7+
8+
namespace duckdb {
9+
+
10+
+extern bool preloaded_httpfs;
11+
+
12+
class BufferManager;
13+
class DatabaseManager;
14+
class StorageManager;

0 commit comments

Comments
 (0)