Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,31 @@ foreach(LINK_LIB ${DUCKDB_LINK_LIBS})
list(APPEND LINK_OBJECTS $<TARGET_OBJECTS:${LINK_LIB}>)
endforeach(LINK_LIB)

add_library(duckdb_static STATIC ${ALL_OBJECT_FILES} ${LINK_OBJECTS})
add_library(duckdb_static STATIC ${ALL_OBJECT_FILES}
$<TARGET_OBJECTS:duckdb_bind_extension_load>
${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} $<TARGET_OBJECTS:duckdb_bind_extension_load_testload>
${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)
# set_property(TARGET duckdb_static PROPERTY IMPORTED_LOCATION
# ${CMAKE_CURRENT_BINARY_DIR}/libduckdb_static.a)
#

add_library(duckdb SHARED ${ALL_OBJECT_FILES} ${LINK_OBJECTS})
add_library(duckdb SHARED ${ALL_OBJECT_FILES}
$<TARGET_OBJECTS:duckdb_bind_extension_load>
${LINK_OBJECTS})
target_link_libraries(duckdb PUBLIC ${DUCKDB_SYSTEM_LIBS})
link_extension_libraries(duckdb PRIVATE)

Expand Down
13 changes: 11 additions & 2 deletions src/planner/binder/statement/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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} $<TARGET_OBJECTS:duckdb_bind_statement>
PARENT_SCOPE)
27 changes: 27 additions & 0 deletions src/planner/binder/statement/bind_load.cpp
Original file line number Diff line number Diff line change
@@ -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 <algorithm>
#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<LogicalSimple>(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";
Expand All @@ -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
26 changes: 26 additions & 0 deletions src/planner/binder/statement/bind_update_extensions.cpp
Original file line number Diff line number Diff line change
@@ -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 <algorithm>
#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<LogicalSimple>(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
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down