diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a86798fde87..60b5fc7f8b67 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -85,10 +85,21 @@ foreach(LINK_LIB ${DUCKDB_LINK_LIBS}) list(APPEND LINK_OBJECTS $) endforeach(LINK_LIB) -add_library(duckdb_static STATIC ${ALL_OBJECT_FILES} ${LINK_OBJECTS}) +add_library(duckdb_static STATIC ${ALL_OBJECT_FILES} + $ + ${LINK_OBJECTS}) target_link_libraries(duckdb_static PUBLIC ${DUCKDB_SYSTEM_LIBS}) link_threads(duckdb_static PUBLIC) +if(BUILD_UNITTESTS) + add_library( + duckdb_static_testload STATIC + ${ALL_OBJECT_FILES} $ + ${LINK_OBJECTS}) + target_link_libraries(duckdb_static_testload PUBLIC ${DUCKDB_SYSTEM_LIBS}) + link_threads(duckdb_static_testload PUBLIC) +endif() + # # FIXME file(COPY ${CMAKE_SOURCE_DIR}/libduckdb_static.a DESTINATION # ${CMAKE_CURRENT_BINARY_DIR}) add_library(duckdb_static STATIC IMPORTED GLOBAL) @@ -96,7 +107,9 @@ link_threads(duckdb_static PUBLIC) # ${CMAKE_CURRENT_BINARY_DIR}/libduckdb_static.a) # -add_library(duckdb SHARED ${ALL_OBJECT_FILES} ${LINK_OBJECTS}) +add_library(duckdb SHARED ${ALL_OBJECT_FILES} + $ + ${LINK_OBJECTS}) target_link_libraries(duckdb PUBLIC ${DUCKDB_SYSTEM_LIBS}) link_extension_libraries(duckdb PRIVATE) diff --git a/src/planner/binder/statement/CMakeLists.txt b/src/planner/binder/statement/CMakeLists.txt index d9fb9cf7bceb..2332f30d6f0c 100644 --- a/src/planner/binder/statement/CMakeLists.txt +++ b/src/planner/binder/statement/CMakeLists.txt @@ -16,7 +16,6 @@ add_library_unity( bind_export.cpp bind_extension.cpp bind_insert.cpp - bind_load.cpp bind_logical_plan.cpp bind_merge_into.cpp bind_pragma.cpp @@ -27,8 +26,18 @@ add_library_unity( bind_simple.cpp bind_summarize.cpp bind_update.cpp - bind_update_extensions.cpp bind_vacuum.cpp) + +add_library(duckdb_bind_extension_load OBJECT bind_load.cpp + bind_update_extensions.cpp) + +if(BUILD_UNITTESTS) + add_library(duckdb_bind_extension_load_testload OBJECT + bind_load.cpp bind_update_extensions.cpp) + target_compile_definitions(duckdb_bind_extension_load_testload + PRIVATE SDB_ENABLE_TEST_EXTENSION_LOAD) +endif() + set(ALL_OBJECT_FILES ${ALL_OBJECT_FILES} $ PARENT_SCOPE) diff --git a/src/planner/binder/statement/bind_load.cpp b/src/planner/binder/statement/bind_load.cpp index 29ce6f238802..06d53a969667 100644 --- a/src/planner/binder/statement/bind_load.cpp +++ b/src/planner/binder/statement/bind_load.cpp @@ -1,9 +1,35 @@ #include "duckdb/parser/statement/load_statement.hpp" #include "duckdb/planner/binder.hpp" +#ifdef SDB_ENABLE_TEST_EXTENSION_LOAD +#include "duckdb/planner/operator/logical_simple.hpp" +#include "duckdb/main/extension_install_info.hpp" +#include +#endif namespace duckdb { BoundStatement Binder::Bind(LoadStatement &stmt) { +#ifdef SDB_ENABLE_TEST_EXTENSION_LOAD + BoundStatement result; + result.types = {LogicalType::BOOLEAN}; + result.names = {"Success"}; + + if (!stmt.info->repository.empty() && stmt.info->repo_is_alias) { + auto repository_url = ExtensionRepository::TryGetRepositoryUrl(stmt.info->repository); + if (repository_url.empty()) { + throw BinderException("'%s' is not a known repository name. Are you trying to query from a repository by " + "path? Use single quotes: `FROM '%s'`", + stmt.info->repository, stmt.info->repository); + } + } + + result.plan = make_uniq(LogicalOperatorType::LOGICAL_LOAD, std::move(stmt.info)); + + auto &properties = GetStatementProperties(); + properties.output_type = QueryResultOutputType::FORCE_MATERIALIZED; + properties.return_type = StatementReturnType::NOTHING; + return result; +#else const bool is_install = stmt.info->load_type == LoadType::INSTALL || stmt.info->load_type == LoadType::FORCE_INSTALL; const string action = is_install ? "INSTALL" : "LOAD"; @@ -12,6 +38,7 @@ BoundStatement Binder::Bind(LoadStatement &stmt) { action + " is not supported by SereneDB: extensions are compiled into the server binary and cannot be " + verb + " at runtime.\nIf you need the \"" + stmt.info->filename + "\" extension, please open an issue at https://github.com/serenedb/serenedb/issues."); +#endif } } // namespace duckdb diff --git a/src/planner/binder/statement/bind_update_extensions.cpp b/src/planner/binder/statement/bind_update_extensions.cpp index d4c887a7602b..c55073a915d5 100644 --- a/src/planner/binder/statement/bind_update_extensions.cpp +++ b/src/planner/binder/statement/bind_update_extensions.cpp @@ -1,13 +1,39 @@ #include "duckdb/planner/binder.hpp" #include "duckdb/parser/statement/update_extensions_statement.hpp" +#ifdef SDB_ENABLE_TEST_EXTENSION_LOAD +#include "duckdb/parser/statement/load_statement.hpp" +#include "duckdb/planner/operator/logical_simple.hpp" +#include +#endif namespace duckdb { +#ifdef SDB_ENABLE_TEST_EXTENSION_LOAD +BoundStatement Binder::Bind(UpdateExtensionsStatement &stmt) { + BoundStatement result; + + result.names.emplace_back("extension_name"); + result.types.emplace_back(LogicalType::VARCHAR); + result.names.emplace_back("repository"); + result.types.emplace_back(LogicalType::VARCHAR); + result.names.emplace_back("update_result"); + result.types.emplace_back(LogicalType::VARCHAR); + result.names.emplace_back("previous_version"); + result.types.emplace_back(LogicalType::VARCHAR); + result.names.emplace_back("current_version"); + result.types.emplace_back(LogicalType::VARCHAR); + + result.plan = make_uniq(LogicalOperatorType::LOGICAL_UPDATE_EXTENSIONS, std::move(stmt.info)); + + return result; +} +#else BoundStatement Binder::Bind(UpdateExtensionsStatement &) { throw NotImplementedException( "UPDATE EXTENSIONS is not supported by SereneDB: extensions are compiled into the server binary and cannot " "be updated at runtime.\n" "If you are missing an extension, please open an issue at https://github.com/serenedb/serenedb/issues."); } +#endif } // namespace duckdb diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0f8a23f9b3b7..9da7ea88ded8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -54,7 +54,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(unittest PRIVATE -Wno-error=maybe-uninitialized) endif() -target_link_libraries(unittest duckdb_static test_helpers) +target_link_libraries(unittest duckdb_static_testload test_helpers) link_extension_libraries(unittest "") if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")