MDEV-40166 fix: Time functions, data reclaim scenarios and tests#5339
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces several enhancements and compatibility fixes for the DuckDB storage engine integration. Key changes include adding access control to the run_in_duckdb() function (requiring the SUPER privilege and a new global system variable duckdb_allow_run_in_duckdb), pinning the default storage format version to v1.5.2 to leverage modern column compression, and implementing several MySQL-compatible date/time function overloads (WEEK, YEARWEEK, TO_DAYS, DAYOFWEEK, and WEEKDAY) to ensure consistent behavior during pushdown. Additionally, comprehensive documentation and tests for space reclamation and access control have been added. Feedback on the code changes highlights a potential bug in mc_calc_weekday where negative day numbers (e.g., for BC dates) can result in negative weekday values, leading to incorrect week calculations when cast to unsigned integers.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
0be7752 to
97d8312
Compare
Add MySQL-compatible time functions, storage v1.5.2, and secure run_in_duckdb()
What
Bundles several DuckDB storage-engine improvements: fills gaps in
MariaDB↔DuckDB time-function compatibility, upgrades the on-disk storage
format to unlock better compression, and hardens the run_in_duckdb() UDF.
Key changes
duckdb_mysql_compat.cc,duckdb_manager.cc): 2-argWEEK/YEARWEEKported from MariaDB week logic, plusutc_time/utc_timestamp/utc_date,unix_timestamp,time_to_secmacros.duckdb_manager.cc): pinserialization_compatibilitytov1.5.2so new DBs use advanced column compression (e.g. DICT_FSST), shrinking file size.duckdb_udf.cc,ha_duckdb.cc):run_in_duckdb()now requiresSUPERprivilege and the new--duckdb-allow-run-in-duckdbsysvar.fiber_context.c→.cpp.duckdb_time_func,duckdb_time_func_unsupported,run_in_duckdb_access,space_reclaimtests + space-reclaim docs.How to test
Run the DuckDB suite:
mysql-test-run --suite=duckdb duckdb_time_func run_in_duckdb_access space_reclaim.