From 207c85783b2c7831e1851fe9d0a4228b18d3d3fd Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Fri, 19 Jan 2024 10:31:45 -0700 Subject: [PATCH 1/4] MDEV-33283: Binlog Checksum is Zeroed by Zlib if Part of Event Data is Empty An existing binlog checksum can be overridden to 0 if writing a NULL payload when using Zlib for the computation. That is, calling into Zlib's crc32 with empty data initializes an incremental CRC computation to 0. This patch changes the Log_event_writer::write_data() to exit immediately if there is nothing to write, thereby bypassing the checksum computation. This follows the pattern of Log_event_writer::encrypt_and_write(), which also exits immediately if there is no data to write. Reviewed By: ============ Andrei Elkin --- sql/log_event_server.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 2a22021cc95..f51f5b7deec 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -916,6 +916,10 @@ int Log_event_writer::write_header(uchar *pos, size_t len) int Log_event_writer::write_data(const uchar *pos, size_t len) { DBUG_ENTER("Log_event_writer::write_data"); + + if (!len) + DBUG_RETURN(0); + if (checksum_len) crc= my_checksum(crc, pos, len); From 117388225c1361c0a5b67d6115db1a6b54b43c2c Mon Sep 17 00:00:00 2001 From: Rex Date: Fri, 12 Jan 2024 09:32:34 +1200 Subject: [PATCH 2/4] MDEV-33165 Incorrect result interceptor passed to mysql_explain_union() Statements affect by this bug are all SQL statements that 1) prefixed with "EXPLAIN" 2) have a lower level join structure created for a union subquery. A bug in select_describe() passed an incorrect "result" object to mysql_explain_union(), resulting in unpredictable behaviour and out of context calls. Reviewed by: Oleksandr Byelkin, sanja@mariadb.com --- mysql-test/main/explain.result | 40 ++++++++++++++++++++++++++++++++++ mysql-test/main/explain.test | 23 +++++++++++++++++++ sql/sql_select.cc | 3 +-- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/explain.result b/mysql-test/main/explain.result index 8a9fd3c5390..85d889a8c5f 100644 --- a/mysql-test/main/explain.result +++ b/mysql-test/main/explain.result @@ -459,3 +459,43 @@ id select_type table type possible_keys key key_len ref rows Extra NULL UNION RESULT ALL NULL NULL NULL NULL NULL Warnings: Note 1249 Select 4 was reduced during optimization +# +# End of 10.4 tests +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); +EXPLAIN SELECT * FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +prepare stmt from "EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6)"; +execute stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +execute stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +DROP TABLE t1, t2; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/explain.test b/mysql-test/main/explain.test index fc789601788..a546242d6aa 100644 --- a/mysql-test/main/explain.test +++ b/mysql-test/main/explain.test @@ -370,3 +370,26 @@ drop table t1; explain VALUES ( (VALUES (2))) UNION VALUES ( (SELECT 3)); + +--echo # +--echo # End of 10.4 tests +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); + +EXPLAIN SELECT * FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6); +prepare stmt from "EXPLAIN DELETE t2 FROM t1, t2 WHERE t2.b IN (SELECT 5 UNION SELECT 6)"; +execute stmt; +execute stmt; + +# Cleanup + +DROP TABLE t1, t2; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 21132651b07..2794c8d51e9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -27953,7 +27953,6 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, bool distinct,const char *message) { THD *thd=join->thd; - select_result *result=join->result; DBUG_ENTER("select_describe"); if (join->select_lex->pushdown_select) @@ -27988,7 +27987,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, if (unit->explainable()) { - if (mysql_explain_union(thd, unit, result)) + if (mysql_explain_union(thd, unit, unit->result)) DBUG_VOID_RETURN; } } From 13e49b783f4572d89badadb05f793d4333c881ac Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 19 Jan 2024 18:40:53 +0700 Subject: [PATCH 3/4] sql_test.cc compile fix --- sql/sql_test.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 1474099c030..47acdaf8d7c 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -29,14 +29,17 @@ #include #include "sql_connect.h" #include "thread_cache.h" -#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) + #if defined(HAVE_MALLOC_H) #include -#elif defined(HAVE_SYS_MALLOC_H) -#include -#elif defined(HAVE_MALLOC_ZONE) -#include #endif + +#if defined(HAVE_SYS_MALLOC_H) +#include +#endif + +#if defined(HAVE_MALLOC_ZONE) +#include #endif #ifdef HAVE_EVENT_SCHEDULER From 5ce6a352b6e7b84b96dadebb943132c8b2f97391 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 22 Jan 2024 14:23:44 +1100 Subject: [PATCH 4/4] MDEV-33290: Disable ColumnStore based on boost version MCOL-5611 supporting with Boost-1.80, the version "next_prime" disappears from https://github.com/boostorg/unordered/blob/boost-1.79.0/include/boost/unordered/detail/implementation.hpp makes it the currenly highest supported versions. Lets check this version. While CMake-3.19+ supports version ranges in package determinations this isn't supported for Boost in Cmake-3.28. So we check for the 1.80 and don't compile ColumnStore. --- storage/columnstore/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/storage/columnstore/CMakeLists.txt b/storage/columnstore/CMakeLists.txt index 81690f14b15..644f0ca8984 100644 --- a/storage/columnstore/CMakeLists.txt +++ b/storage/columnstore/CMakeLists.txt @@ -15,6 +15,13 @@ IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") add_subdirectory(columnstore) + # https://jira.mariadb.org/browse/MCOL-5611 + FIND_PACKAGE(Boost 1.80.0 COMPONENTS system filesystem thread regex date_time chrono atomic) + IF (Boost_FOUND) + MESSAGE_ONCE(CS_NO_BOOST "Boost Libraries >= 1.80.0 not supported!") + return() + ENDIF() + IF(TARGET columnstore) # Needed to bump the component changes up to the main scope APPEND_FOR_CPACK(CPACK_COMPONENTS_ALL)