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
5 changes: 5 additions & 0 deletions cmake/make_dist.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ IF(GIT_EXECUTABLE)
IF(NOT RESULT EQUAL 0)
SET(GIT_EXECUTABLE)
ENDIF()
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" submodule foreach "${GIT_EXECUTABLE} checkout-index --all --prefix=${PACKAGE_DIR}/storage/duckdb/duckdb/$path/"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/storage/duckdb/duckdb
RESULT_VARIABLE RESULT
)
Comment thread
drrtuy marked this conversation as resolved.
ENDIF()

CONFIGURE_FILE(${CMAKE_BINARY_DIR}/include/source_revision.h
Expand Down
9 changes: 9 additions & 0 deletions debian/autobake-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ then
fi
fi

# Enable DuckDB storage engine plugin packaging
if [ -f storage/duckdb/duckdb/debian/control ] &&
grep -q "$architecture" storage/duckdb/duckdb/debian/control
then
cp -v storage/duckdb/duckdb/debian/mariadb-plugin-duckdb.* debian/
echo >> debian/control
cat storage/duckdb/duckdb/debian/control >> debian/control
fi
Comment thread
drrtuy marked this conversation as resolved.

if [ -n "${AUTOBAKE_PREP_CONTROL_RULES_ONLY:-}" ]
then
exit 0
Expand Down
30 changes: 15 additions & 15 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,19 @@ static int join_ft_read_first(JOIN_TAB *tab);
static int join_ft_read_next(READ_RECORD *info);
int join_read_always_key_or_null(JOIN_TAB *tab);
int join_read_next_same_or_null(READ_RECORD *info);
static COND *make_cond_for_table(THD *thd, Item *cond,table_map table,
table_map used_table,
int join_tab_idx_arg,
bool exclude_expensive_cond,
bool retain_ref_cond);
static COND *make_cond_for_table_from_pred(THD *thd, Item *root_cond,
Item *cond,
table_map tables,
table_map used_table,
int join_tab_idx_arg,
bool exclude_expensive_cond,
bool retain_ref_cond,
bool is_top_and_level);
COND *make_cond_for_table(THD *thd, Item *cond,table_map table,
table_map used_table,
int join_tab_idx_arg,
bool exclude_expensive_cond,
bool retain_ref_cond);
COND *make_cond_for_table_from_pred(THD *thd, Item *root_cond,
Item *cond,
table_map tables,
table_map used_table,
int join_tab_idx_arg,
bool exclude_expensive_cond,
bool retain_ref_cond,
bool is_top_and_level);

static Item* part_of_refkey(TABLE *form,Field *field);
static bool test_if_cheaper_ordering(bool in_join_optimizer,
Expand Down Expand Up @@ -26377,7 +26377,7 @@ bool test_if_ref(Item *root_cond, Item_field *left_item,Item *right_item)
make_cond_for_info_schema() uses similar algorithm as well.
*/

static Item *
Item *
make_cond_for_table(THD *thd, Item *cond, table_map tables,
table_map used_table,
int join_tab_idx_arg,
Expand All @@ -26391,7 +26391,7 @@ make_cond_for_table(THD *thd, Item *cond, table_map tables,
}


static Item *
Item *
make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond,
table_map tables, table_map used_table,
int join_tab_idx_arg,
Expand Down
14 changes: 14 additions & 0 deletions sql/sql_select.h
Original file line number Diff line number Diff line change
Expand Up @@ -2285,6 +2285,20 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select);
bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit,
select_result *result);

COND *make_cond_for_table(THD *thd, Item *cond, table_map tables,
table_map used_table,
int join_tab_idx_arg,
bool exclude_expensive_cond,
bool retain_ref_cond);
COND *make_cond_for_table_from_pred(THD *thd, Item *root_cond,
Item *cond,
table_map tables,
table_map used_table,
int join_tab_idx_arg,
bool exclude_expensive_cond,
bool retain_ref_cond,
bool is_top_and_level);

/*
General routine to change field->ptr of a NULL-terminated array of Field
objects. Useful when needed to call val_int, val_str or similar and the
Expand Down
2 changes: 2 additions & 0 deletions storage/duckdb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Fetched at configure time by FetchContent (see CMakeLists.txt).
duckdb/
107 changes: 107 additions & 0 deletions storage/duckdb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
IF("NO" STREQUAL "${PLUGIN_DUCKDB}")
return()
ENDIF()
Comment thread
drrtuy marked this conversation as resolved.

IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
return()
ENDIF()

IF(NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64"))
return()
ENDIF()

# Check C++17 compiler support
MY_CHECK_CXX_COMPILER_FLAG("-std=c++17")
IF(NOT have_CXX__std_c__17)
MESSAGE(STATUS "DuckDB: C++ compiler does not support -std=c++17, skipping")
RETURN()
ENDIF()

# libduckdb_bundle.a is built without debug STL wrappers.
# Mismatched _GLIBCXX_DEBUG changes sizeof(std::vector) → SIGSEGV.
SET(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -U_GLIBCXX_DEBUG -U_GLIBCXX_ASSERTIONS")

# Fetch the DuckDB engine plugin sources at configure time.
# Replaces the former git submodule at storage/duckdb/duckdb.
INCLUDE(FetchContent)
SET(DUCKDB_ENGINE_GIT_REPO "https://github.com/MariaDB/duckdb-engine"
CACHE STRING "DuckDB engine plugin git repository")
SET(DUCKDB_ENGINE_GIT_TAG "1639aebe79fdd471fc8848c3757a6b0427471534"
CACHE STRING "DuckDB engine plugin commit (full SHA)")

SET(DUCKDB_ENGINE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/duckdb")

IF(EXISTS "${DUCKDB_ENGINE_SOURCE_DIR}/CMakeLists.txt")
# Source tree already present — use it as-is, no git operations.
MESSAGE(STATUS "DuckDB engine: using existing sources in ${DUCKDB_ENGINE_SOURCE_DIR}")
SET(FETCHCONTENT_SOURCE_DIR_DUCKDB_ENGINE "${DUCKDB_ENGINE_SOURCE_DIR}"
CACHE PATH "Pre-populated DuckDB engine source" FORCE)
ENDIF()

FetchContent_Declare(duckdb_engine
GIT_REPOSITORY "${DUCKDB_ENGINE_GIT_REPO}"
GIT_TAG "${DUCKDB_ENGINE_GIT_TAG}"
GIT_SHALLOW TRUE
SOURCE_DIR "${DUCKDB_ENGINE_SOURCE_DIR}"
)
FetchContent_GetProperties(duckdb_engine)
IF(NOT duckdb_engine_POPULATED)
MESSAGE(STATUS "Fetching DuckDB engine plugin @ ${DUCKDB_ENGINE_GIT_TAG}")
FetchContent_Populate(duckdb_engine)
ENDIF()

IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/duckdb/CMakeLists.txt")
MESSAGE(WARNING "DuckDB engine sources missing after FetchContent; skipping")
RETURN()
ENDIF()

add_subdirectory(duckdb)

IF(TARGET duckdb)
# MTR discovers plugins at storage/<name>/, not storage/<name>/<submodule>/
SET_TARGET_PROPERTIES(duckdb PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
INSTALL_MYSQL_TEST("${CMAKE_CURRENT_SOURCE_DIR}/duckdb/mysql-test/"
"plugin/duckdb")
Comment thread
drrtuy marked this conversation as resolved.

# MYSQL_ADD_PLUGIN runs in storage/duckdb/duckdb/ and bumps CPACK_* vars
# one level up (here). Re-bump them to the root scope so include(CPack)
# sees them. Without this, no MariaDB-duckdb-engine.spec is generated.
SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} PARENT_SCOPE)
SET(CPACK_COMPONENT_DUCKDB-ENGINE_GROUP
${CPACK_COMPONENT_DUCKDB-ENGINE_GROUP} PARENT_SCOPE)
SET(CPACK_COMPONENT_DUCKDB-ENGINESYMLINKS_GROUP
${CPACK_COMPONENT_DUCKDB-ENGINESYMLINKS_GROUP} PARENT_SCOPE)
SET(CPACK_RPM_duckdb-engine_PACKAGE_REQUIRES
${CPACK_RPM_duckdb-engine_PACKAGE_REQUIRES} PARENT_SCOPE)

IF(RPM)
SET(CPACK_RPM_duckdb-engine_PACKAGE_SUMMARY
"MariaDB DuckDB storage engine" PARENT_SCOPE)
SET(CPACK_RPM_duckdb-engine_PACKAGE_DESCRIPTION
"The MariaDB DuckDB storage engine embeds DuckDB, an in-process analytical database, as a MariaDB storage engine for fast OLAP queries over local data." PARENT_SCOPE)

# Mark common parent directories as %ignore so the duckdb-engine RPM
# does not claim ownership of dirs owned by MariaDB-server/-common.
# The "%define ignore \#" macro is already set by cmake/cpack_rpm.cmake.
SET(CPACK_RPM_duckdb-engine_USER_FILELIST
"%ignore /etc"
"%ignore /etc/my.cnf.d"
"%ignore /usr"
"%ignore /usr/lib64"
"%ignore /usr/lib64/mysql"
"%ignore /usr/lib64/mysql/plugin"
"%ignore /usr/share"
"%ignore /usr/share/mysql"
PARENT_SCOPE)

# Apply DuckDB-specific CPack overrides at packaging time.
# CPACK_PROJECT_CONFIG_FILE is included by CPack after CPackConfig.cmake,
# letting these settings override the main project's.
SET(CPACK_PROJECT_CONFIG_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/duckdb/cmake/cpack_overrides.cmake"
CACHE FILEPATH "DuckDB CPack overrides" FORCE)
ENDIF()
ENDIF()