diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28229d4b3..a808a1805 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -472,7 +472,7 @@ jobs: - name: Prepare repository run: | - [ -f duckdb.patch ] && cd submodules/duckdb && git apply ../../duckdb.patch || echo "No patching needed" + [ -f duckdb.patch ] && cd submodules/duckdb && git apply --3way ../../duckdb.patch || echo "No patching needed" - uses: mymindstorm/setup-emsdk@v14 with: diff --git a/duckdb.patch b/duckdb.patch index ccb197634..0b2245d8f 100644 --- a/duckdb.patch +++ b/duckdb.patch @@ -1,99 +1,653 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 7b1eaa7adf..036a07a56a 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -25,6 +25,7 @@ project(DuckDB) - find_package(Threads REQUIRED) +commit 9c4a294ed1b7a973d405295ecbefb92851c82101 +Author: Carlo Piovesan +Date: Wed May 22 16:32:18 2024 +0200 + + Move .ipp files to _ipp.hpp + +diff --git a/src/include/duckdb/common/enable_shared_from_this.ipp b/src/include/duckdb/common/enable_shared_from_this_ipp.hpp +similarity index 100% +rename from src/include/duckdb/common/enable_shared_from_this.ipp +rename to src/include/duckdb/common/enable_shared_from_this_ipp.hpp +diff --git a/src/include/duckdb/common/shared_ptr.hpp b/src/include/duckdb/common/shared_ptr.hpp +index 6d0910ca6b..eff60e3db2 100644 +--- a/src/include/duckdb/common/shared_ptr.hpp ++++ b/src/include/duckdb/common/shared_ptr.hpp +@@ -37,9 +37,9 @@ struct compatible_with_t : std::is_convertible {}; // NOLINT: invalid - set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -+set(DUCKDB_EXPLICIT_PLATFORM "nop") + } // namespace duckdb - set (CMAKE_CXX_STANDARD 11) +-#include "duckdb/common/shared_ptr.ipp" +-#include "duckdb/common/weak_ptr.ipp" +-#include "duckdb/common/enable_shared_from_this.ipp" ++#include "duckdb/common/shared_ptr_ipp.hpp" ++#include "duckdb/common/weak_ptr_ipp.hpp" ++#include "duckdb/common/enable_shared_from_this_ipp.hpp" -@@ -84,6 +85,14 @@ endif() + namespace duckdb { - option(DISABLE_UNITY "Disable unity builds." FALSE) +diff --git a/src/include/duckdb/common/shared_ptr.ipp b/src/include/duckdb/common/shared_ptr_ipp.hpp +similarity index 100% +rename from src/include/duckdb/common/shared_ptr.ipp +rename to src/include/duckdb/common/shared_ptr_ipp.hpp +diff --git a/src/include/duckdb/common/weak_ptr.ipp b/src/include/duckdb/common/weak_ptr_ipp.hpp +similarity index 100% +rename from src/include/duckdb/common/weak_ptr.ipp +rename to src/include/duckdb/common/weak_ptr_ipp.hpp +diff --git a/extension/json/CMakeLists.txt b/extension/json/CMakeLists.txt +index 4101111df8..3e035e80d3 100644 +--- a/extension/json/CMakeLists.txt ++++ b/extension/json/CMakeLists.txt +@@ -34,6 +34,7 @@ set(JSON_EXTENSION_FILES + build_static_extension(json ${JSON_EXTENSION_FILES}) + set(PARAMETERS "-warnings") + build_loadable_extension(json ${PARAMETERS} ${JSON_EXTENSION_FILES}) ++target_link_libraries(json_loadable_extension duckdb_yyjson) -+option(USE_WASM_THREADS "Should threads be used" FALSE) -+if (${USE_WASM_THREADS}) -+ set(WASM_THREAD_FLAGS -+ -pthread -+ -sSHARED_MEMORY=1 -+ ) -+endif() -+ - option(FORCE_COLORED_OUTPUT - "Always produce ANSI-colored output (GNU/Clang only)." FALSE) - if(${FORCE_COLORED_OUTPUT}) -@@ -711,6 +720,7 @@ if (NOT EXTENSION_CONFIG_BUILD AND NOT ${EXTENSION_TESTS_ONLY} AND NOT CLANG_TID - if (NOT Python3_FOUND) - MESSAGE(STATUS "Could not find python3, create extension directory step will be skipped") - else() -+ message(STATUS "hi from ${CMAKE_CURRENT_BINARY_DIR}") - add_custom_target( - duckdb_local_extension_repo ALL - COMMAND -@@ -813,7 +823,7 @@ function(build_loadable_extension_directory NAME OUTPUT_DIRECTORY EXTENSION_VERS - add_custom_command( - TARGET ${TARGET_NAME} - POST_BUILD -- COMMAND emcc $.lib -o $ -sSIDE_MODULE=1 -O3 -+ COMMAND emcc $.lib -o $ -O3 -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="_${NAME}_init" ${WASM_THREAD_FLAGS} - ) - endif() - add_custom_command( -@@ -1220,6 +1230,7 @@ if(BUILD_PYTHON) - add_extension_dependencies(duckdb_python) - endif() - -+message(STATUS "${DUCKDB_EXPLICIT_PLATFORM} is the platform") - if(NOT DUCKDB_EXPLICIT_PLATFORM) - set(VERSION_SOURCES tools/utils/test_platform.cpp) - -diff --git a/scripts/create_local_extension_repo.py b/scripts/create_local_extension_repo.py -index 8cf71abec0..9875f5fa23 100644 ---- a/scripts/create_local_extension_repo.py -+++ b/scripts/create_local_extension_repo.py -@@ -28,6 +28,7 @@ if os.name == 'nt': - - with open(duckdb_platform_out, 'r') as f: - lines = f.readlines() -+ print(lines) - duckdb_platform = lines[0] - - # Create destination path + install( + TARGETS json_extension +diff --git a/src/include/duckdb/common/enable_shared_from_this.ipp b/src/include/duckdb/common/enable_shared_from_this.ipp +deleted file mode 100644 +index 85cdd22054..0000000000 +--- a/src/include/duckdb/common/enable_shared_from_this.ipp ++++ /dev/null +@@ -1,42 +0,0 @@ +-namespace duckdb { +- +-template +-class enable_shared_from_this { // NOLINT: invalid case style +-public: +- template +- friend class shared_ptr; +- +-private: +- mutable weak_ptr __weak_this_; // NOLINT: __weak_this_ is reserved +- +-protected: +- constexpr enable_shared_from_this() noexcept { +- } +- enable_shared_from_this(enable_shared_from_this const &) noexcept { // NOLINT: not marked as explicit +- } +- enable_shared_from_this &operator=(enable_shared_from_this const &) noexcept { +- return *this; +- } +- ~enable_shared_from_this() { +- } +- +-public: +- shared_ptr shared_from_this() { // NOLINT: invalid case style +- return shared_ptr(__weak_this_); +- } +- shared_ptr shared_from_this() const { // NOLINT: invalid case style +- return shared_ptr(__weak_this_); +- } +- +-#if _LIBCPP_STD_VER >= 17 +- weak_ptr weak_from_this() noexcept { // NOLINT: invalid case style +- return __weak_this_; +- } +- +- weak_ptr weak_from_this() const noexcept { // NOLINT: invalid case style +- return __weak_this_; +- } +-#endif // _LIBCPP_STD_VER >= 17 +-}; +- +-} // namespace duckdb diff --git a/src/include/duckdb/common/file_open_flags.hpp b/src/include/duckdb/common/file_open_flags.hpp -index d0509a214b..f1689b2975 100644 +index d0509a214b..1b5107e849 100644 --- a/src/include/duckdb/common/file_open_flags.hpp +++ b/src/include/duckdb/common/file_open_flags.hpp -@@ -100,8 +100,8 @@ public: +@@ -100,8 +100,9 @@ public: return flags & FILE_FLAGS_PARALLEL_ACCESS; } -private: idx_t flags = 0; ++ +private: FileLockType lock = FileLockType::NO_LOCK; FileCompressionType compression = FileCompressionType::UNCOMPRESSED; }; +diff --git a/src/include/duckdb/common/shared_ptr.hpp b/src/include/duckdb/common/shared_ptr.hpp +index 6d0910ca6b..eff60e3db2 100644 +--- a/src/include/duckdb/common/shared_ptr.hpp ++++ b/src/include/duckdb/common/shared_ptr.hpp +@@ -37,9 +37,9 @@ struct compatible_with_t : std::is_convertible {}; // NOLINT: invalid + + } // namespace duckdb + +-#include "duckdb/common/shared_ptr.ipp" +-#include "duckdb/common/weak_ptr.ipp" +-#include "duckdb/common/enable_shared_from_this.ipp" ++#include "duckdb/common/shared_ptr_ipp.hpp" ++#include "duckdb/common/weak_ptr_ipp.hpp" ++#include "duckdb/common/enable_shared_from_this_ipp.hpp" + + namespace duckdb { + +diff --git a/src/include/duckdb/common/shared_ptr.ipp b/src/include/duckdb/common/shared_ptr.ipp +deleted file mode 100644 +index d046dc1412..0000000000 +--- a/src/include/duckdb/common/shared_ptr.ipp ++++ /dev/null +@@ -1,268 +0,0 @@ +-namespace duckdb { +- +-template +-class weak_ptr; +- +-template +-class enable_shared_from_this; +- +-template +-class shared_ptr { // NOLINT: invalid case style +-public: +- using original = std::shared_ptr; +- using element_type = typename original::element_type; +- using weak_type = weak_ptr; +- +-private: +- static inline void AssertNotNull(const bool null) { +-#if defined(DUCKDB_DEBUG_NO_SAFETY) || defined(DUCKDB_CLANG_TIDY) +- return; +-#else +- if (DUCKDB_UNLIKELY(null)) { +- throw duckdb::InternalException("Attempted to dereference shared_ptr that is NULL!"); +- } +-#endif +- } +- +-private: +- template +- friend class weak_ptr; +- +- template +- friend class shared_ptr; +- +- template +- friend shared_ptr shared_ptr_cast(shared_ptr src); // NOLINT: invalid case style +- +-private: +- original internal; +- +-public: +- // Constructors +- shared_ptr() : internal() { +- } +- shared_ptr(std::nullptr_t) : internal(nullptr) { // NOLINT: not marked as explicit +- } +- +- // From raw pointer of type U convertible to T +- template ::value, int>::type = 0> +- explicit shared_ptr(U *ptr) : internal(ptr) { +- __enable_weak_this(internal.get(), internal.get()); +- } +- // From raw pointer of type T with custom DELETER +- template +- shared_ptr(T *ptr, DELETER deleter) : internal(ptr, deleter) { +- __enable_weak_this(internal.get(), internal.get()); +- } +- // Aliasing constructor: shares ownership information with ref but contains ptr instead +- // When the created shared_ptr goes out of scope, it will call the DELETER of ref, will not delete ptr +- template +- shared_ptr(const shared_ptr &ref, T *ptr) noexcept : internal(ref.internal, ptr) { +- } +-#if _LIBCPP_STD_VER >= 20 +- template +- shared_ptr(shared_ptr &&ref, T *ptr) noexcept : internal(std::move(ref.internal), ptr) { +- } +-#endif +- +- // Copy constructor, share ownership with ref +- template ::value, int>::type = 0> +- shared_ptr(const shared_ptr &ref) noexcept : internal(ref.internal) { // NOLINT: not marked as explicit +- } +- shared_ptr(const shared_ptr &other) : internal(other.internal) { // NOLINT: not marked as explicit +- } +- // Move constructor, share ownership with ref +- template ::value, int>::type = 0> +-#ifdef DUCKDB_CLANG_TIDY +- [[clang::reinitializes]] +-#endif +- shared_ptr(shared_ptr &&ref) noexcept // NOLINT: not marked as explicit +- : internal(std::move(ref.internal)) { +- } +-#ifdef DUCKDB_CLANG_TIDY +- [[clang::reinitializes]] +-#endif +- shared_ptr(shared_ptr &&other) // NOLINT: not marked as explicit +- : internal(std::move(other.internal)) { +- } +- +- // Construct from std::shared_ptr +- explicit shared_ptr(std::shared_ptr other) : internal(other) { +- // FIXME: should we __enable_weak_this here? +- // *our* enable_shared_from_this hasn't initialized yet, so I think so? +- __enable_weak_this(internal.get(), internal.get()); +- } +- +- // Construct from weak_ptr +- template +- explicit shared_ptr(weak_ptr other) : internal(other.internal) { +- } +- +- // Construct from unique_ptr, takes over ownership of the unique_ptr +- template ::value && +- std::is_convertible::pointer, T *>::value, +- int>::type = 0> +-#ifdef DUCKDB_CLANG_TIDY +- [[clang::reinitializes]] +-#endif +- shared_ptr(unique_ptr &&other) // NOLINT: not marked as explicit +- : internal(std::move(other)) { +- __enable_weak_this(internal.get(), internal.get()); +- } +- +- // Destructor +- ~shared_ptr() = default; +- +- // Assign from shared_ptr copy +- shared_ptr &operator=(const shared_ptr &other) noexcept { +- if (this == &other) { +- return *this; +- } +- // Create a new shared_ptr using the copy constructor, then swap out the ownership to *this +- shared_ptr(other).swap(*this); +- return *this; +- } +- template ::value, int>::type = 0> +- shared_ptr &operator=(const shared_ptr &other) { +- shared_ptr(other).swap(*this); +- return *this; +- } +- +- // Assign from moved shared_ptr +- shared_ptr &operator=(shared_ptr &&other) noexcept { +- // Create a new shared_ptr using the move constructor, then swap out the ownership to *this +- shared_ptr(std::move(other)).swap(*this); +- return *this; +- } +- template ::value, int>::type = 0> +- shared_ptr &operator=(shared_ptr &&other) { +- shared_ptr(std::move(other)).swap(*this); +- return *this; +- } +- +- // Assign from moved unique_ptr +- template ::value && +- std::is_convertible::pointer, T *>::value, +- int>::type = 0> +- shared_ptr &operator=(unique_ptr &&ref) { +- shared_ptr(std::move(ref)).swap(*this); +- return *this; +- } +- +-#ifdef DUCKDB_CLANG_TIDY +- [[clang::reinitializes]] +-#endif +- void +- reset() { // NOLINT: invalid case style +- internal.reset(); +- } +- template +-#ifdef DUCKDB_CLANG_TIDY +- [[clang::reinitializes]] +-#endif +- void +- reset(U *ptr) { // NOLINT: invalid case style +- internal.reset(ptr); +- } +- template +-#ifdef DUCKDB_CLANG_TIDY +- [[clang::reinitializes]] +-#endif +- void +- reset(U *ptr, DELETER deleter) { // NOLINT: invalid case style +- internal.reset(ptr, deleter); +- } +- +- void swap(shared_ptr &r) noexcept { // NOLINT: invalid case style +- internal.swap(r.internal); +- } +- +- T *get() const { // NOLINT: invalid case style +- return internal.get(); +- } +- +- long use_count() const { // NOLINT: invalid case style +- return internal.use_count(); +- } +- +- explicit operator bool() const noexcept { +- return internal.operator bool(); +- } +- +- typename std::add_lvalue_reference::type operator*() const { +- if (MemorySafety::ENABLED) { +- const auto ptr = internal.get(); +- AssertNotNull(!ptr); +- return *ptr; +- } else { +- return *internal; +- } +- } +- +- T *operator->() const { +- if (MemorySafety::ENABLED) { +- const auto ptr = internal.get(); +- AssertNotNull(!ptr); +- return ptr; +- } else { +- return internal.operator->(); +- } +- } +- +- // Relational operators +- template +- bool operator==(const shared_ptr &other) const noexcept { +- return internal == other.internal; +- } +- template +- bool operator!=(const shared_ptr &other) const noexcept { +- return internal != other.internal; +- } +- +- bool operator==(std::nullptr_t) const noexcept { +- return internal == nullptr; +- } +- bool operator!=(std::nullptr_t) const noexcept { +- return internal != nullptr; +- } +- +- template +- bool operator<(const shared_ptr &other) const noexcept { +- return internal < other.internal; +- } +- template +- bool operator<=(const shared_ptr &other) const noexcept { +- return internal <= other.internal; +- } +- template +- bool operator>(const shared_ptr &other) const noexcept { +- return internal > other.internal; +- } +- template +- bool operator>=(const shared_ptr &other) const noexcept { +- return internal >= other.internal; +- } +- +-private: +- // This overload is used when the class inherits from 'enable_shared_from_this' +- template *>::value, +- int>::type = 0> +- void __enable_weak_this(const enable_shared_from_this *object, // NOLINT: invalid case style +- V *ptr) noexcept { +- typedef typename std::remove_cv::type non_const_u_t; +- if (object && object->__weak_this_.expired()) { +- // __weak_this__ is the mutable variable returned by 'shared_from_this' +- // it is initialized here +- auto non_const = const_cast(static_cast(ptr)); // NOLINT: const cast +- object->__weak_this_ = shared_ptr(*this, non_const); +- } +- } +- +- void __enable_weak_this(...) noexcept { // NOLINT: invalid case style +- } +-}; +- +-} // namespace duckdb +diff --git a/src/include/duckdb/common/weak_ptr.ipp b/src/include/duckdb/common/weak_ptr.ipp +deleted file mode 100644 +index 076fde9532..0000000000 +--- a/src/include/duckdb/common/weak_ptr.ipp ++++ /dev/null +@@ -1,117 +0,0 @@ +-namespace duckdb { +- +-template +-class weak_ptr { // NOLINT: invalid case style +-public: +- using original = std::weak_ptr; +- using element_type = typename original::element_type; +- +-private: +- template +- friend class shared_ptr; +- +-private: +- original internal; +- +-public: +- // Constructors +- weak_ptr() : internal() { +- } +- +- // NOLINTBEGIN +- template ::value, int>::type = 0> +- weak_ptr(shared_ptr const &ptr) noexcept : internal(ptr.internal) { +- } +- weak_ptr(weak_ptr const &other) noexcept : internal(other.internal) { +- } +- template ::value, int>::type = 0> +- weak_ptr(weak_ptr const &ptr) noexcept : internal(ptr.internal) { +- } +-#ifdef DUCKDB_CLANG_TIDY +- [[clang::reinitializes]] +-#endif +- weak_ptr(weak_ptr &&ptr) noexcept +- : internal(std::move(ptr.internal)) { +- } +- template ::value, int>::type = 0> +-#ifdef DUCKDB_CLANG_TIDY +- [[clang::reinitializes]] +-#endif +- weak_ptr(weak_ptr &&ptr) noexcept +- : internal(std::move(ptr.internal)) { +- } +- // NOLINTEND +- // Destructor +- ~weak_ptr() = default; +- +- // Assignment operators +- weak_ptr &operator=(const weak_ptr &other) { +- if (this == &other) { +- return *this; +- } +- internal = other.internal; +- return *this; +- } +- +- template ::value, int>::type = 0> +- weak_ptr &operator=(const shared_ptr &ptr) { +- internal = ptr.internal; +- return *this; +- } +- +- // Modifiers +-#ifdef DUCKDB_CLANG_TIDY +- // This is necessary to tell clang-tidy that it reinitializes the variable after a move +- [[clang::reinitializes]] +-#endif +- void +- reset() { // NOLINT: invalid case style +- internal.reset(); +- } +- +- // Observers +- long use_count() const { // NOLINT: invalid case style +- return internal.use_count(); +- } +- +- bool expired() const { // NOLINT: invalid case style +- return internal.expired(); +- } +- +- shared_ptr lock() const { // NOLINT: invalid case style +- return shared_ptr(internal.lock()); +- } +- +- // Relational operators +- template +- bool operator==(const weak_ptr &other) const noexcept { +- return internal == other.internal; +- } +- +- template +- bool operator!=(const weak_ptr &other) const noexcept { +- return internal != other.internal; +- } +- +- template +- bool operator<(const weak_ptr &other) const noexcept { +- return internal < other.internal; +- } +- +- template +- bool operator<=(const weak_ptr &other) const noexcept { +- return internal <= other.internal; +- } +- +- template +- bool operator>(const weak_ptr &other) const noexcept { +- return internal > other.internal; +- } +- +- template +- bool operator>=(const weak_ptr &other) const noexcept { +- return internal >= other.internal; +- } +-}; +- +-} // namespace duckdb +diff --git a/src/include/duckdb/main/extension_install_info.hpp b/src/include/duckdb/main/extension_install_info.hpp +index 64b7b520a7..b03f64b3aa 100644 +--- a/src/include/duckdb/main/extension_install_info.hpp ++++ b/src/include/duckdb/main/extension_install_info.hpp +@@ -49,9 +49,9 @@ public: + + struct ExtensionRepository { + //! All currently available repositories +- static constexpr const char *CORE_REPOSITORY_URL = "http://extensions.duckdb.org"; +- static constexpr const char *CORE_NIGHTLY_REPOSITORY_URL = "http://nightly-extensions.duckdb.org"; +- static constexpr const char *COMMUNITY_REPOSITORY_URL = "http://community-extensions.duckdb.org"; ++ static constexpr const char *CORE_REPOSITORY_URL = "https://extensions.duckdb.org"; ++ static constexpr const char *CORE_NIGHTLY_REPOSITORY_URL = "https://nightly-extensions.duckdb.org"; ++ static constexpr const char *COMMUNITY_REPOSITORY_URL = "https://community-extensions.duckdb.org"; + + //! 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/extension/extension_helper.cpp b/src/main/extension/extension_helper.cpp +index 3954e232b7..9679e18d05 100644 +--- a/src/main/extension/extension_helper.cpp ++++ b/src/main/extension/extension_helper.cpp +@@ -304,7 +304,6 @@ vector ExtensionHelper::UpdateExtensions(DatabaseInstance + + auto &config = DBConfig::GetConfig(db); + +-#ifndef WASM_LOADABLE_EXTENSIONS + case_insensitive_set_t seen_extensions; + + // scan the install directory for installed extensions +@@ -321,7 +320,6 @@ vector ExtensionHelper::UpdateExtensions(DatabaseInstance + + result.push_back(UpdateExtensionInternal(db, fs, fs.JoinPath(ext_directory, path), extension_name)); + }); +-#endif + + for (const auto &extension : db.LoadedExtensions()) { + if (seen_extensions.find(extension) != seen_extensions.end()) { +diff --git a/src/main/extension/extension_install.cpp b/src/main/extension/extension_install.cpp +index d188cb5dc3..d323fe9d7a 100644 +--- a/src/main/extension/extension_install.cpp ++++ b/src/main/extension/extension_install.cpp +@@ -194,7 +194,7 @@ string ExtensionHelper::ExtensionUrlTemplate(optional_ptr db_con + versioned_path = "/${REVISION}/${PLATFORM}/${NAME}.duckdb_extension"; + } + #ifdef WASM_LOADABLE_EXTENSIONS +- string default_endpoint = DEFAULT_REPOSITORY; ++ string default_endpoint = ExtensionRepository::DEFAULT_REPOSITORY_URL; + versioned_path = versioned_path + ".wasm"; + #else + string default_endpoint = ExtensionRepository::DEFAULT_REPOSITORY_URL; diff --git a/src/main/extension/extension_load.cpp b/src/main/extension/extension_load.cpp -index 002cf4aefe..5ef4b667a9 100644 +index 65438aa8ec..1185bccbc7 100644 --- a/src/main/extension/extension_load.cpp +++ b/src/main/extension/extension_load.cpp -@@ -143,6 +143,7 @@ bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileSystem &fs, const str - } else { +@@ -175,7 +175,8 @@ bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileSystem &fs, const str + direct_load = false; + string extension_name = ApplyExtensionAlias(extension); + #ifdef WASM_LOADABLE_EXTENSIONS +- string url_template = ExtensionUrlTemplate(&config, ""); ++ ExtensionRepository repository; ++ string url_template = ExtensionUrlTemplate(&config, repository, ""); + string url = ExtensionFinalizeUrlTemplate(url_template, extension_name); + + char *str = (char *)EM_ASM_PTR( +@@ -215,68 +216,223 @@ bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileSystem &fs, const str + direct_load = true; filename = fs.ExpandPath(filename); } -+#ifndef WASM_LOADABLE_EXTENSIONS - if (!fs.FileExists(filename)) { - string message; - bool exact_match = ExtensionHelper::CreateSuggestions(extension, message); -@@ -152,7 +153,183 @@ bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileSystem &fs, const str - error = StringUtil::Format("Extension \"%s\" not found.\n%s", filename, message); - return false; - } -+#endif +- if (!fs.FileExists(filename)) { +- string message; +- bool exact_match = ExtensionHelper::CreateSuggestions(extension, message); +- if (exact_match) { +- message += "\nInstall it first using \"INSTALL " + extension + "\"."; +- } +- error = StringUtil::Format("Extension \"%s\" not found.\n%s", filename, message); +- return false; +- } +- +- auto handle = fs.OpenFile(filename, FileFlags::FILE_FLAGS_READ); ++ /* if (!fs.FileExists(filename)) { ++ string message; ++ bool exact_match = ExtensionHelper::CreateSuggestions(extension, message); ++ if (exact_match) { ++ message += "\nInstall it first using \"INSTALL " + extension + "\"."; ++ } ++ error = StringUtil::Format("Extension \"%s\" not found.\n%s", filename, message); ++ return false; ++ } ++ */ ++ ++ /* auto handle = fs.OpenFile(filename, FileFlags::FILE_FLAGS_READ); ++ ++ // Parse the extension metadata from the extension binary ++ auto parsed_metadata = ParseExtensionMetaData(*handle); + ++ auto metadata_mismatch_error = parsed_metadata.GetInvalidMetadataError(); ++ ++ if (!metadata_mismatch_error.empty()) { ++ metadata_mismatch_error = StringUtil::Format("Failed to load '%s', %s", extension, metadata_mismatch_error); ++ } ++ ++ if (!config.options.allow_unsigned_extensions) { ++ bool signature_valid = ++ CheckExtensionSignature(*handle, parsed_metadata, config.options.allow_community_extensions); ++ ++ if (!signature_valid) { ++ throw IOException(config.error_manager->FormatException(ErrorType::UNSIGNED_EXTENSION, filename) + ++ metadata_mismatch_error); ++ } ++ ++ if (!metadata_mismatch_error.empty()) { ++ // Signed extensions perform the full check ++ throw InvalidInputException(metadata_mismatch_error); ++ } ++ } else if (!config.options.allow_extensions_metadata_mismatch) { ++ if (!metadata_mismatch_error.empty()) { ++ // Unsigned extensions AND configuration allowing n, loading allowed, mainly for ++ // debugging purposes ++ throw InvalidInputException(metadata_mismatch_error); ++ } ++ } ++ */ ++ auto filebase = fs.ExtractBaseName(filename); + +- // Parse the extension metadata from the extension binary +- auto parsed_metadata = ParseExtensionMetaData(*handle); +#ifdef WASM_LOADABLE_EXTENSIONS + auto basename = fs.ExtractBaseName(filename); + char *exe = NULL; @@ -101,74 +655,74 @@ index 002cf4aefe..5ef4b667a9 100644 + { + // Next few lines should argubly in separate JavaScript-land function call + // TODO: move them out / have them configurable + +- auto metadata_mismatch_error = parsed_metadata.GetInvalidMetadataError(); ++ var url = (UTF8ToString($0)); + -+var url =(UTF8ToString($0)); -+ -+ if (typeof XMLHttpRequest === "undefined" ) { -+ const os = require('os'); -+ const path = require('path'); -+ const fs = require('fs'); ++ if (typeof XMLHttpRequest === "undefined") { ++ const os = require('os'); ++ const path = require('path'); ++ const fs = require('fs'); + -+ var array = url.split("/"); -+ var l = array.length; ++ var array = url.split("/"); ++ var l = array.length; + -+ var folder = path.join(os.homedir(), ".duckdb/extensions/" + array[l - 4] + "/" + array[l - 3] + "/" + array[l - 2] + "/"); -+ var filePath = path.join(folder, array[l - 1]); ++ var folder = path.join(os.homedir(), ".duckdb/extensions/" + array[l - 4] + "/" + array[l - 3] + "/" + ++ array[l - 2] + "/"); ++ var filePath = path.join(folder, array[l - 1]); + -+ try { -+ if (!fs.existsSync(folder)) { -+ fs.mkdirSync(folder, { -+ recursive: true -+ }); -+ } ++ try { ++ if (!fs.existsSync(folder)) { ++ fs.mkdirSync(folder, {recursive : true}); ++ } + -+ if (!fs.existsSync(filePath)) { -+ const int32 = new Int32Array(new SharedArrayBuffer(8)); -+var Worker = require('node:worker_threads').Worker; -+ var worker = new Worker("const {Worker,isMainThread,parentPort,workerData,} = require('node:worker_threads');var times = 0;var SAB = 23;var Z = 0;async function ZZZ(e) {var x = await fetch(e);var res = await x.arrayBuffer();Atomics.store(SAB, 1, res.byteLength);Atomics.store(SAB, 0, 1);Atomics.notify(SAB, 1);Atomics.notify(SAB, 0);Z = res;};parentPort.on('message', function(event) {if (times == 0) {times++;SAB = event;} else if (times == 1) {times++;ZZZ(event);} else {const a = new Uint8Array(Z);const b = new Uint8Array(event.buffer);var K = Z.byteLength;for (var i = 0; i < K; i++) {b[i] = a[i];}Atomics.notify(event, 0);Atomics.store(SAB, 0, 2);Atomics.notify(SAB, 0);}});", { ++ if (!fs.existsSync(filePath)) { ++ const int32 = new Int32Array(new SharedArrayBuffer(8)); ++ var Worker = require('node:worker_threads').Worker; ++ var worker = new Worker("const {Worker,isMainThread,parentPort,workerData,} = require('node:worker_threads');var times = 0;var SAB = 23;var Z = 0; async function ZZZ(e) {var x = await fetch(e);var res = await x.arrayBuffer();Atomics.store(SAB, 1, res.byteLength);Atomics.store(SAB, 0, 1);Atomics.notify(SAB, 1);Atomics.notify(SAB, 0);Z = res;};parentPort.on('message', function(event) {if (times == 0) {times++;SAB = event;} else if (times == 1) {times++; ZZZ(event);} else {const a = new Uint8Array(Z);const b = new Uint8Array(event.buffer);var K = Z.byteLength;for (var i = 0; i < K; i++) {b[i] = a[i];}Atomics.notify(event, 0);Atomics.store(SAB, 0, 2);Atomics.notify(SAB, 0);}});", { + eval: true + }); -+ var uInt8Array; -+ -+ int32[0] = 0; -+ int32[2] = 4; -+ worker.postMessage(int32); -+ -+ worker.postMessage(url); -+ Atomics.wait(int32, 0, 0); -+ -+ const int32_2 = new Int32Array(new SharedArrayBuffer(int32[1] + 3 - ((int32[1] + 3) % 4))); -+ worker.postMessage(int32_2); -+ -+ Atomics.wait(int32, 0, 1); -+ -+ var x = new Uint8Array(int32_2.buffer, 0, int32[1]); -+ uInt8Array = x; -+ worker.terminate(); -+ fs.writeFileSync(filePath, uInt8Array); -+ -+ } else { -+ uInt8Array = fs.readFileSync(filePath); -+ } -+ } catch (e) { -+ console.log("Error fetching module", e); -+ return 0; -+ } -+ } else { -+ const xhr = new XMLHttpRequest(); -+ xhr.open("GET", url, false); -+ xhr.responseType = "arraybuffer"; -+ xhr.send(null); -+ if (xhr.status != 200) -+ return 0; -+ uInt8Array = xhr.response; -+ } ++ var uInt8Array; ++ ++ int32[0] = 0; ++ int32[2] = 4; ++ worker.postMessage(int32); ++ ++ worker.postMessage(url); ++ Atomics.wait(int32, 0, 0); ++ ++ const int32_2 = new Int32Array(new SharedArrayBuffer(int32[1] + 3 - ((int32[1] + 3) % 4))); ++ worker.postMessage(int32_2); ++ ++ Atomics.wait(int32, 0, 1); ++ ++ var x = new Uint8Array(int32_2.buffer, 0, int32[1]); ++ uInt8Array = x; ++ worker.terminate(); ++ fs.writeFileSync(filePath, uInt8Array); ++ ++ } else { ++ uInt8Array = fs.readFileSync(filePath); ++ } ++ } catch (e) { ++ console.log("Error fetching module", e); ++ return 0; ++ } ++ } else { ++ const xhr = new XMLHttpRequest(); ++ xhr.open("GET", url, false); ++ xhr.responseType = "arraybuffer"; ++ xhr.send(null); ++ if (xhr.status != 200) ++ return 0; ++ uInt8Array = xhr.response; ++ } + + var valid = WebAssembly.validate(uInt8Array); -+ var len = uInt8Array.byteLength; ++ var len = uInt8Array.byteLength; + var fileOnWasmHeap = _malloc(len + 4); + -+ var properArray = new Uint8Array(uInt8Array); ++ var properArray = new Uint8Array(uInt8Array); + + for (var iii = 0; iii < len; iii++) { + Module.HEAPU8[iii + fileOnWasmHeap + 4] = properArray[iii]; @@ -187,12 +741,14 @@ index 002cf4aefe..5ef4b667a9 100644 + len -= LEN123[3]; + len /= 256; + Module.HEAPU8.set(LEN123, fileOnWasmHeap); -+ //FIXME: found how to expose those to the logger interface -+ //console.log(LEN123); -+ //console.log(properArray); -+ //console.log(new Uint8Array(Module.HEAPU8, fileOnWasmHeap, len+4)); -+ // console.log('Loading extension ', UTF8ToString($1)); -+ ++ // FIXME: found how to expose those to the logger interface ++ // console.log(LEN123); ++ // console.log(properArray); ++ // console.log(new Uint8Array(Module.HEAPU8, fileOnWasmHeap, len+4)); ++ // console.log('Loading extension ', UTF8ToString($1)); + +- if (!metadata_mismatch_error.empty()) { +- metadata_mismatch_error = StringUtil::Format("Failed to load '%s', %s", extension, metadata_mismatch_error); + // Here we add the uInt8Array to Emscripten's filesystem, for it to be found by dlopen + FS.writeFile(UTF8ToString($1), new Uint8Array(uInt8Array)); + return fileOnWasmHeap; @@ -200,10 +756,12 @@ index 002cf4aefe..5ef4b667a9 100644 + filename.c_str(), basename.c_str()); + if (!exe) { + throw IOException("Extension %s is not available", filename); -+ } -+ + } + + auto dopen_from = basename; -+ if (!config.options.allow_unsigned_extensions) { + if (!config.options.allow_unsigned_extensions) { +- bool signature_valid = +- CheckExtensionSignature(*handle, parsed_metadata, config.options.allow_community_extensions); + // signature is the last 256 bytes of the file + + string signature; @@ -218,7 +776,7 @@ index 002cf4aefe..5ef4b667a9 100644 + LEN *= 256; + LEN += ((uint8_t *)exe)[1]; + LEN *= 256; -+ LEN += ((uint8_t *)exe)[0]; ++ LEN += ((uint8_t *)exe)[0]; + auto signature_offset = LEN - signature.size(); + + const idx_t maxLenChunks = 1024ULL * 1024ULL; @@ -239,20 +797,31 @@ index 002cf4aefe..5ef4b667a9 100644 + } + ComputeSHA256String(x, &hash_chunks[i]); + } -+ + +- if (!signature_valid) { +- throw IOException(config.error_manager->FormatException(ErrorType::UNSIGNED_EXTENSION, filename) + +- metadata_mismatch_error); + string hash_concatenation; + hash_concatenation.reserve(32 * numChunks); // 256 bits -> 32 bytes per chunk + + for (auto &hash_chunk : hash_chunks) { + hash_concatenation += hash_chunk; -+ } -+ + } + +- if (!metadata_mismatch_error.empty()) { +- // Signed extensions perform the full check +- throw InvalidInputException(metadata_mismatch_error); + string two_level_hash; + ComputeSHA256String(hash_concatenation, &two_level_hash); - ++ + for (idx_t j = 0; j < signature.size(); j++) { + signature[j] = ((uint8_t *)exe)[4 + signature_offset + j]; -+ } + } +- } else if (!config.options.allow_extensions_metadata_mismatch) { +- if (!metadata_mismatch_error.empty()) { +- // Unsigned extensions AND configuration allowing n, loading allowed, mainly for +- // debugging purposes +- throw InvalidInputException(metadata_mismatch_error); + bool any_valid = false; + for (auto &key : ExtensionHelper::GetPublicKeys()) { + if (duckdb_mbedtls::MbedTlsWrapper::IsValidSha256Signature(key, signature, two_level_hash)) { @@ -262,25 +831,12 @@ index 002cf4aefe..5ef4b667a9 100644 + } + if (!any_valid) { + throw IOException(config.error_manager->FormatException(ErrorType::UNSIGNED_EXTENSION, filename)); -+ } -+ } -+ if (exe) { -+ free(exe); -+ } -+std::string extension_version=""; -+#else - string metadata_segment; - metadata_segment.resize(512); - -@@ -279,27 +456,10 @@ bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileSystem &fs, const str - auto number_metadata_fields = 3; - D_ASSERT(number_metadata_fields == 3); // Currently hardcoded value - metadata_field.resize(number_metadata_fields + 1); + } + } - -+#endif - auto filebase = fs.ExtractBaseName(filename); - - #ifdef WASM_LOADABLE_EXTENSIONS +- auto filebase = fs.ExtractBaseName(filename); +- +-#ifdef WASM_LOADABLE_EXTENSIONS - EM_ASM( - { - // Next few lines should argubly in separate JavaScript-land function call @@ -298,6 +854,52 @@ index 002cf4aefe..5ef4b667a9 100644 - }, - filename.c_str(), filebase.c_str()); - auto dopen_from = filebase; ++ if (exe) { ++ free(exe); ++ } #else auto dopen_from = filename; #endif +@@ -294,25 +450,27 @@ bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileSystem &fs, const str + result.lib_hdl = lib_hdl; + + if (!direct_load) { +- auto info_file_name = filename + ".info"; +- +- result.install_info = ExtensionInstallInfo::TryReadInfoFile(fs, info_file_name, lowercase_extension_name); +- +- if (result.install_info->mode == ExtensionInstallMode::UNKNOWN) { +- // The info file was missing, we just set the version, since we have it from the parsed footer +- result.install_info->version = parsed_metadata.extension_version; +- } +- +- if (result.install_info->version != parsed_metadata.extension_version) { +- throw IOException("Metadata mismatch detected when loading extension '%s'\nPlease try reinstalling the " +- "extension using `FORCE INSTALL '%s'`", +- filename, extension); +- } ++ /* ++ auto info_file_name = filename + ".info"; ++ ++ result.install_info = ExtensionInstallInfo::TryReadInfoFile(fs, info_file_name, ++ lowercase_extension_name); ++ ++ if (result.install_info->mode == ExtensionInstallMode::UNKNOWN) { ++ // The info file was missing, we just set the version, since we have it from the parsed footer ++ result.install_info->version = parsed_metadata.extension_version; ++ } ++ ++ if (result.install_info->version != parsed_metadata.extension_version) { ++ throw IOException("Metadata mismatch detected when loading extension '%s'\nPlease try reinstalling ++ the " "extension using `FORCE INSTALL '%s'`", filename, extension); ++ } ++ */ + } else { + result.install_info = make_uniq(); + result.install_info->mode = ExtensionInstallMode::NOT_INSTALLED; + result.install_info->full_path = filename; +- result.install_info->version = parsed_metadata.extension_version; ++ result.install_info->version = ""; // parsed_metadata.extension_version; + } + + return true; diff --git a/lib/cmake/duckdb.cmake b/lib/cmake/duckdb.cmake index d7acea537..8c55064ae 100644 --- a/lib/cmake/duckdb.cmake +++ b/lib/cmake/duckdb.cmake @@ -54,6 +54,7 @@ ExternalProject_Add( /lib/libduckdb_hyperloglog.a /lib/libduckdb_miniz.a /lib/libduckdb_mbedtls.a + /lib/libduckdb_yyjson.a /lib/libduckdb_pg_query.a /lib/libduckdb_utf8proc.a /lib/libduckdb_fastpforlib.a @@ -86,6 +87,7 @@ target_link_libraries( INTERFACE ${install_dir}/lib/libduckdb_hyperloglog.a INTERFACE ${install_dir}/lib/libduckdb_miniz.a INTERFACE ${install_dir}/lib/libduckdb_mbedtls.a + INTERFACE ${install_dir}/lib/libduckdb_yyjson.a INTERFACE ${install_dir}/lib/libduckdb_pg_query.a INTERFACE ${install_dir}/lib/libduckdb_utf8proc.a INTERFACE ${install_dir}/lib/libduckdb_fastpforlib.a @@ -98,6 +100,7 @@ target_include_directories( INTERFACE ${DUCKDB_UTF8PROC_INCLUDE_DIR} INTERFACE ${DUCKDB_RE2_INCLUDE_DIR} INTERFACE ${DUCKDB_SOURCE_DIR}/third_party/parquet + INTERFACE ${DUCKDB_SOURCE_DIR}/third_party/yyjson INTERFACE ${DUCKDB_SOURCE_DIR}/third_party/snappy INTERFACE ${DUCKDB_SOURCE_DIR}/third_party/miniz INTERFACE ${DUCKDB_SOURCE_DIR}/third_party/thrift diff --git a/lib/include/duckdb/web/functions/table_function_relation.h b/lib/include/duckdb/web/functions/table_function_relation.h index 43656079c..8c0af4b71 100644 --- a/lib/include/duckdb/web/functions/table_function_relation.h +++ b/lib/include/duckdb/web/functions/table_function_relation.h @@ -7,8 +7,8 @@ namespace web { class TableFunctionRelation : public Relation { public: - TableFunctionRelation(const std::shared_ptr &context, string name, vector unnamed_parameters, - unordered_map named_parameters, + TableFunctionRelation(const duckdb::shared_ptr &context, string name, + vector unnamed_parameters, unordered_map named_parameters, shared_ptr input_relation_p = nullptr); string name; diff --git a/lib/include/duckdb/web/webdb.h b/lib/include/duckdb/web/webdb.h index a50e7e1cb..82428e9e9 100644 --- a/lib/include/duckdb/web/webdb.h +++ b/lib/include/duckdb/web/webdb.h @@ -40,18 +40,18 @@ class WebDB { duckdb::Connection connection_; /// The current pending query result (if any) - std::unique_ptr current_pending_query_result_ = nullptr; + duckdb::unique_ptr current_pending_query_result_ = nullptr; /// The current pending query was canceled bool current_pending_query_was_canceled_ = false; /// The current query result (if any) - std::unique_ptr current_query_result_ = nullptr; + duckdb::unique_ptr current_query_result_ = nullptr; /// The current arrow schema (if any) std::shared_ptr current_schema_ = nullptr; /// The current patched arrow schema (if any) std::shared_ptr current_schema_patched_ = nullptr; /// The currently active prepared statements - std::unordered_map> prepared_statements_ = {}; + std::unordered_map> prepared_statements_ = {}; /// The next prepared statement id size_t next_prepared_statement_id_ = 0; /// The current arrow ipc input stream @@ -61,12 +61,12 @@ class WebDB { // Fully materialize a given result set and return it as an Arrow Buffer arrow::Result> MaterializeQueryResult( - std::unique_ptr result); + duckdb::unique_ptr result); // Setup streaming of a result set and return the schema as an Arrow Buffer - arrow::Result> StreamQueryResult(std::unique_ptr result); + arrow::Result> StreamQueryResult(duckdb::unique_ptr result); // Execute a prepared statement by setting up all arguments and returning the query result - arrow::Result> ExecutePreparedStatement(size_t statement_id, - std::string_view args_json); + arrow::Result> ExecutePreparedStatement(size_t statement_id, + std::string_view args_json); // Call scalar UDF function arrow::Status CallScalarUDFFunction(UDFFunctionDeclaration& function, DataChunk& chunk, ExpressionState& state, Vector& vec); @@ -125,9 +125,9 @@ class WebDB { /// The buffered filesystem io::BufferedFileSystem* buffered_filesystem_; /// The (shared) database - std::shared_ptr database_; + duckdb::shared_ptr database_; /// The connections - std::unordered_map> connections_; + std::unordered_map> connections_; /// The file statistics (if any) std::shared_ptr file_stats_ = {}; @@ -135,13 +135,13 @@ class WebDB { std::unordered_map> pinned_web_files_ = {}; // Register custom extension options in DuckDB for options that are handled in DuckDB-WASM instead of DuckDB - void RegisterCustomExtensionOptions(std::shared_ptr database); + void RegisterCustomExtensionOptions(duckdb::shared_ptr database); public: /// Constructor WebDB(WebTag); /// Constructor - WebDB(NativeTag, std::unique_ptr fs = duckdb::FileSystem::CreateLocal()); + WebDB(NativeTag, duckdb::unique_ptr fs = duckdb::FileSystem::CreateLocal()); /// Destructor ~WebDB(); @@ -201,7 +201,7 @@ class WebDB { /// Get the static webdb instance static arrow::Result> Get(); /// Create the default webdb database - static std::unique_ptr Create(); + static duckdb::unique_ptr Create(); }; } // namespace web diff --git a/lib/src/functions/table_function_relation.cc b/lib/src/functions/table_function_relation.cc index 66d143c46..b60093977 100644 --- a/lib/src/functions/table_function_relation.cc +++ b/lib/src/functions/table_function_relation.cc @@ -14,7 +14,7 @@ namespace duckdb { namespace web { -TableFunctionRelation::TableFunctionRelation(const std::shared_ptr &context, string name, +TableFunctionRelation::TableFunctionRelation(const duckdb::shared_ptr &context, string name, vector unnamed_parameters, unordered_map named_parameters, shared_ptr input_relation_p) diff --git a/lib/src/webdb.cc b/lib/src/webdb.cc index 7b5d93240..c075288fd 100644 --- a/lib/src/webdb.cc +++ b/lib/src/webdb.cc @@ -74,17 +74,17 @@ namespace web { static constexpr int64_t DEFAULT_QUERY_POLLING_INTERVAL = 100; /// Create the default webdb database -std::unique_ptr WebDB::Create() { +duckdb::unique_ptr WebDB::Create() { if constexpr (ENVIRONMENT == Environment::WEB) { - return std::make_unique(WEB); + return duckdb::make_uniq(WEB); } else { auto fs = duckdb::FileSystem::CreateLocal(); - return std::make_unique(NATIVE, std::move(fs)); + return duckdb::make_uniq(NATIVE, std::move(fs)); } } /// Get the static webdb instance arrow::Result> WebDB::Get() { - static std::unique_ptr db = nullptr; + static duckdb::unique_ptr db = nullptr; if (db == nullptr) { db = Create(); } @@ -98,7 +98,7 @@ WebDB::Connection::Connection(WebDB& webdb) WebDB::Connection::~Connection() = default; arrow::Result> WebDB::Connection::MaterializeQueryResult( - std::unique_ptr result) { + duckdb::unique_ptr result) { current_query_result_.reset(); current_schema_.reset(); current_schema_patched_.reset(); @@ -133,7 +133,7 @@ arrow::Result> WebDB::Connection::MaterializeQuer } arrow::Result> WebDB::Connection::StreamQueryResult( - std::unique_ptr result) { + duckdb::unique_ptr result) { current_query_result_ = std::move(result); current_schema_.reset(); current_schema_patched_.reset(); @@ -230,7 +230,7 @@ bool WebDB::Connection::CancelPendingQuery() { arrow::Result> WebDB::Connection::FetchQueryResults() { try { // Fetch data if a query is active - std::unique_ptr chunk; + duckdb::unique_ptr chunk; if (current_query_result_ == nullptr) { return nullptr; } @@ -300,7 +300,7 @@ arrow::Result WebDB::Connection::CreatePreparedStatement(std::string_vie } } -arrow::Result> WebDB::Connection::ExecutePreparedStatement( +arrow::Result> WebDB::Connection::ExecutePreparedStatement( size_t statement_id, std::string_view args_json) { try { auto stmt = prepared_statements_.find(statement_id); @@ -363,7 +363,7 @@ arrow::Status WebDB::Connection::CreateScalarFunction(std::string_view def_json) // Read the function definiton rapidjson::Document def_doc; def_doc.Parse(def_json.begin(), def_json.size()); - auto def = std::make_shared(); + auto def = duckdb::make_shared_ptr(); ARROW_RETURN_NOT_OK(def->ReadFrom(def_doc)); // Read return type @@ -481,7 +481,7 @@ arrow::Status WebDB::Connection::CallScalarUDFFunction(UDFFunctionDeclaration& f } else { auto res_buf = reinterpret_cast(static_cast(res_arr[0])); - auto shared_buffer = std::make_shared(std::unique_ptr{res_buf}); + auto shared_buffer = duckdb::make_shared_ptr(std::unique_ptr{res_buf}); out.SetAuxiliary(shared_buffer); duckdb::FlatVector::SetData(out, (data_ptr_t)res_buf); } @@ -596,8 +596,8 @@ arrow::Status WebDB::Connection::InsertCSVFromPath(std::string_view path, std::s named_params.insert({"auto_detect", Value::BOOLEAN(options.auto_detect.value_or(true))}); /// Execute the csv scan - auto func = std::make_shared(connection_.context, "read_csv", std::move(unnamed_params), - named_params); + auto func = duckdb::make_shared_ptr(connection_.context, "read_csv", + std::move(unnamed_params), named_params); /// Create or insert if (options.create_new) { @@ -626,7 +626,7 @@ arrow::Status WebDB::Connection::InsertJSONFromPath(std::string_view path, std:: if (options.table_name.empty()) return arrow::Status::Invalid("missing 'name' option"); // Create the input file stream - auto ifs = std::make_unique(webdb_.file_page_buffer_, path); + auto ifs = duckdb::make_uniq(webdb_.file_page_buffer_, path); // Do we need to run the analyzer? json::TableType table_type; if (!options.table_shape || options.table_shape == json::JSONTableShape::UNRECOGNIZED || @@ -729,7 +729,7 @@ WebDB::WebDB(WebTag) } /// Constructor -WebDB::WebDB(NativeTag, std::unique_ptr fs) +WebDB::WebDB(NativeTag, duckdb::unique_ptr fs) : config_(std::make_shared()), file_page_buffer_(std::make_shared(std::move(fs))), buffered_filesystem_(nullptr), @@ -774,7 +774,7 @@ std::string_view WebDB::GetVersion() { return database_->LibraryVersion(); } /// Create a session WebDB::Connection* WebDB::Connect() { - auto conn = std::make_unique(*this); + auto conn = duckdb::make_uniq(*this); auto conn_ptr = conn.get(); connections_.insert({conn_ptr, std::move(conn)}); return conn_ptr; @@ -806,8 +806,8 @@ arrow::Status WebDB::Open(std::string_view args_json) { } try { // Setup new database - auto buffered_fs = buffered_filesystem_ ? std::make_unique(*buffered_filesystem_) - : std::make_unique(file_page_buffer_); + auto buffered_fs = buffered_filesystem_ ? duckdb::make_uniq(*buffered_filesystem_) + : duckdb::make_uniq(file_page_buffer_); auto buffered_fs_ptr = buffered_fs.get(); duckdb::DBConfig db_config; @@ -816,7 +816,7 @@ arrow::Status WebDB::Open(std::string_view args_json) { db_config.options.maximum_threads = config_->maximum_threads; db_config.options.use_temporary_directory = false; db_config.options.access_mode = access_mode; - auto db = std::make_shared(config_->path, &db_config); + auto db = make_shared_ptr(config_->path, &db_config); #ifndef WASM_LOADABLE_EXTENSIONS duckdb_web_parquet_init(db.get()); duckdb_web_fts_init(db.get()); diff --git a/submodules/arrow b/submodules/arrow index ca1c30f60..7dd1d3407 160000 --- a/submodules/arrow +++ b/submodules/arrow @@ -1 +1 @@ -Subproject commit ca1c30f60d6419849dbc2a533bd0bcaff310185f +Subproject commit 7dd1d34074af176d9e861a360e135ae57b21cf96 diff --git a/submodules/duckdb b/submodules/duckdb index 1601d94f9..70fd6a8a2 160000 --- a/submodules/duckdb +++ b/submodules/duckdb @@ -1 +1 @@ -Subproject commit 1601d94f94a7e0d2eb805a94803eb1e3afbbe4ed +Subproject commit 70fd6a8a2450c1e2a7d0547d4c0666a649dc378e