From 2e7891080667c59ac80f788eef4d59d447595772 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 2 Jun 2021 08:40:30 -0700 Subject: [PATCH 1/7] MDEV-25635 Assertion failure when pushing from HAVING into WHERE of view This bug could manifest itself after pushing a where condition over a mergeable derived table / view / CTE DT into a grouping view / derived table / CTE V whose item list contained set functions with constant arguments such as MIN(2), SUM(1) etc. In such cases the field references used in the condition pushed into the view V that correspond set functions are wrapped into Item_direct_view_ref wrappers. Due to a wrong implementation of the virtual method const_item() for the class Item_direct_view_ref the wrapped set functions with constant arguments could be erroneously taken for constant items. This could lead to a wrong result set returned by the main select query in 10.2. In 10.4 where a possibility of pushing condition from HAVING into WHERE had been added this could cause a crash. Approved by Sergey Petrunya --- mysql-test/r/derived_cond_pushdown.result | 39 +++++++++++++++++++++++ mysql-test/t/derived_cond_pushdown.test | 25 +++++++++++++++ sql/item.h | 5 ++- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index 25237aa11a9..28532ae88a4 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -10634,4 +10634,43 @@ m 7 drop view v1; drop table t1; +# +# MDEV-25635: pushdown into grouping view using aggregate functions +# with constant arguments via a mergeable derived table +# +create table t1 (a int); +insert into t1 values (3), (7), (1), (3), (7), (7), (3); +create view v1 as select a, sum(1) as f, sum(1) as g from t1 group by a; +select * from v1; +a f g +1 1 1 +3 3 3 +7 3 3 +select * from (select * from v1) as dt where a=f and a=g; +a f g +1 1 1 +3 3 3 +explain extended select * from (select * from v1) as dt where a=f and a=g; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL NULL NULL NULL NULL 7 100.00 Using where +3 DERIVED t1 ALL NULL NULL NULL NULL 7 100.00 Using temporary; Using filesort +Warnings: +Note 1003 select `v1`.`a` AS `a`,`v1`.`f` AS `f`,`v1`.`g` AS `g` from `test`.`v1` where `v1`.`a` = `v1`.`f` and `v1`.`a` = `v1`.`g` +create view v2 as select a, min(1) as f, min(1) as g from t1 group by a; +select * from v2; +a f g +1 1 1 +3 1 1 +7 1 1 +select * from (select * from v2) as dt where a=f and a=g; +a f g +1 1 1 +explain extended select * from (select * from v2) as dt where a=f and a=g; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL NULL NULL NULL NULL 7 100.00 Using where +3 DERIVED t1 ALL NULL NULL NULL NULL 7 100.00 Using temporary; Using filesort +Warnings: +Note 1003 select `v2`.`a` AS `a`,`v2`.`f` AS `f`,`v2`.`g` AS `g` from `test`.`v2` where `v2`.`f` = `v2`.`a` and `v2`.`g` = `v2`.`a` +drop view v1,v2; +drop table t1; # End of 10.2 tests diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index 31b49047bf1..58f38ac1e5a 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -2212,4 +2212,29 @@ select * from v1 where m > 0; drop view v1; drop table t1; +--echo # +--echo # MDEV-25635: pushdown into grouping view using aggregate functions +--echo # with constant arguments via a mergeable derived table +--echo # + +create table t1 (a int); +insert into t1 values (3), (7), (1), (3), (7), (7), (3); + +create view v1 as select a, sum(1) as f, sum(1) as g from t1 group by a; +select * from v1; +let $q1= +select * from (select * from v1) as dt where a=f and a=g; +eval $q1; +eval explain extended $q1; + +create view v2 as select a, min(1) as f, min(1) as g from t1 group by a; +select * from v2; +let $q2= +select * from (select * from v2) as dt where a=f and a=g; +eval $q2; +eval explain extended $q2; + +drop view v1,v2; +drop table t1; + --echo # End of 10.2 tests diff --git a/sql/item.h b/sql/item.h index c94709c733e..76be66d2a7c 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4952,7 +4952,10 @@ public: table_map used_tables() const; void update_used_tables(); table_map not_null_tables() const; - bool const_item() const { return used_tables() == 0; } + bool const_item() const + { + return (*ref)->const_item() && (null_ref_table == NO_NULL_TABLE); + } TABLE *get_null_ref_table() const { return null_ref_table; } bool walk(Item_processor processor, bool walk_subquery, void *arg) { From 5c896472b6cb315fc54091a342ec37a7c4b5421d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 Jun 2021 23:10:21 +0200 Subject: [PATCH 2/7] MDEV-25672 table alias from previous statement interferes later commands only perform the "correct table name" check for *new* generated columns, but not for already existing ones - they're guaranteed to be valid --- mysql-test/suite/vcol/r/vcol_syntax.result | 11 ++++++++++- mysql-test/suite/vcol/t/vcol_syntax.test | 17 +++++++++++++---- sql/item.h | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/vcol/r/vcol_syntax.result b/mysql-test/suite/vcol/r/vcol_syntax.result index c8983f34c93..0063f38ea36 100644 --- a/mysql-test/suite/vcol/r/vcol_syntax.result +++ b/mysql-test/suite/vcol/r/vcol_syntax.result @@ -1,4 +1,3 @@ -drop table if exists t1; set @OLD_SQL_MODE=@@SESSION.SQL_MODE; create table t1 (a int, b int generated always as (a+1)); show create table t1; @@ -88,3 +87,13 @@ create table t1 (x int, y int default test2.t1.x); ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'DEFAULT' create table t1 (x int, check (test2.t1.x > 0)); ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'CHECK' +# +# MDEV-25672 table alias from previous statement interferes later commands +# +create table t1 (a int, v_a int generated always as (a)); +update t1 as x set a = 1; +alter table t1 force; +drop table t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/vcol/t/vcol_syntax.test b/mysql-test/suite/vcol/t/vcol_syntax.test index f425b52ab79..3c8a50a7f36 100644 --- a/mysql-test/suite/vcol/t/vcol_syntax.test +++ b/mysql-test/suite/vcol/t/vcol_syntax.test @@ -1,10 +1,6 @@ # # test syntax # ---disable_warnings -drop table if exists t1; ---enable_warnings - set @OLD_SQL_MODE=@@SESSION.SQL_MODE; create table t1 (a int, b int generated always as (a+1)); show create table t1; @@ -72,3 +68,16 @@ create table t1 (x int, y int check (y > test2.t1.x)); create table t1 (x int, y int default test2.t1.x); --error ER_BAD_FIELD_ERROR create table t1 (x int, check (test2.t1.x > 0)); + +--echo # +--echo # MDEV-25672 table alias from previous statement interferes later commands +--echo # +create table t1 (a int, v_a int generated always as (a)); +update t1 as x set a = 1; +alter table t1 force; +drop table t1; + + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/sql/item.h b/sql/item.h index 76be66d2a7c..cc1914a7ad4 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2841,7 +2841,7 @@ public: bool check_table_name_processor(void *arg) { Check_table_name_prm &p= *(Check_table_name_prm *) arg; - if (p.table_name.length && table_name) + if (!field && p.table_name.length && table_name) { DBUG_ASSERT(p.db.length); if ((db_name && From 7eed97ed9fe2b0c1e69167576be12759dffcd926 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Wed, 26 May 2021 14:15:26 +0200 Subject: [PATCH 3/7] MDEV-25777: JAVA_INCLUDE_PATH and JAVA_INCLUDE_PATH2 not found with out of source configuration and Ninja generator - As solution `PLUGIN_CONNECT=NO` use early check to disable plugin: Solution suggested by wlad@mariadb.com - `JNI_FOUND` is a internal result variable and should be set with cached library and header variables (like `JAVA_INCLUDE_PATH`) defined. * Note: wrapper cmake/FindJNI.cmake runs first time and cmake native Find returns only cached variable, like `JAVA_INCLUDE_PATH`, results variable are not cached). Reviewed by: serg@mariadb.com --- cmake/FindJNI.cmake | 2 +- storage/connect/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/FindJNI.cmake b/cmake/FindJNI.cmake index 12305d7c86d..b2c6f849c87 100644 --- a/cmake/FindJNI.cmake +++ b/cmake/FindJNI.cmake @@ -1,4 +1,4 @@ -if(JAVA_AWT_LIBRARY) +if(JAVA_AWT_LIBRARY AND JAVA_INCLUDE_PATH) set(JNI_FOUND TRUE) return() endif() diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index e9533e8f3e5..d3632b689fe 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -13,6 +13,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA +IF(WITHOUT_DYNAMIC_PLUGINS OR WITH_NONE OR ("${PLUGIN_CONNECT}" STREQUAL "NO")) + RETURN() +ENDIF() + SET(CONNECT_PLUGIN_STATIC "connect") SET(CONNECT_PLUGIN_DYNAMIC "connect") From cebc435592043a83d5f430aec8bdaa79cd7c1d44 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 5 Jun 2021 16:57:10 +0200 Subject: [PATCH 4/7] MDEV-25859 - HeidiSQL 11.3 --- win/packaging/heidisql.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake index 6de033eacb2..c57282ce90a 100644 --- a/win/packaging/heidisql.cmake +++ b/win/packaging/heidisql.cmake @@ -1,4 +1,4 @@ -SET(HEIDISQL_BASE_NAME "HeidiSQL_11.2_32_Portable") +SET(HEIDISQL_BASE_NAME "HeidiSQL_11.3_32_Portable") SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip") SET(HEIDISQL_URL "http://www.heidisql.com/downloads/releases/${HEIDISQL_ZIP}") SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME}) From 9f9a925c399b9d960f095be0886f56f51396eb04 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 6 Jun 2021 08:46:59 +0200 Subject: [PATCH 5/7] MDEV-23815 Windows : mysql_upgrade_wizard fails, if service name has spaces The fix is to quote service name parameter, when it is passed to mysql_upgrade_service subprocess. --- win/upgrade_wizard/upgradeDlg.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/win/upgrade_wizard/upgradeDlg.cpp b/win/upgrade_wizard/upgradeDlg.cpp index d996c0ebe5d..d0dd6a3fa75 100644 --- a/win/upgrade_wizard/upgradeDlg.cpp +++ b/win/upgrade_wizard/upgradeDlg.cpp @@ -367,7 +367,10 @@ void CUpgradeDlg::UpgradeOneService(const string& servicename) ErrorExit("Stdout SetHandleInformation"); string commandline("mysql_upgrade_service.exe --service="); + commandline += "\""; commandline += servicename; + commandline += "\""; + si.cb = sizeof(si); si.hStdInput= GetStdHandle(STD_INPUT_HANDLE); si.hStdOutput= hPipeWrite; @@ -397,7 +400,7 @@ void CUpgradeDlg::UpgradeOneService(const string& servicename) else { /* - Creating a process with CREATE_BREAKAWAY_FROM_JOB, reset this flag + Creating a process with CREATE_BREAKAWAY_FROM_JOB failed, reset this flag and retry. */ if (!CreateProcess(NULL, (LPSTR)commandline.c_str(), NULL, NULL, TRUE, From 3c922d6defcfa6be819fe33794abcf507bb70c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Fri, 28 May 2021 22:04:17 -0700 Subject: [PATCH 6/7] Revert "CONNECT: move jar files to /usr/share and include them in DEBs" This partially reverts commit d7321893d8c50071632a102e17a7869da9cb03a5. The *.jar files are not being built and all Debian builds are failing as dh_install stops on missing files. To build them we would need to also add new Java build dependencies. In a stable release (10.2->10.5) we shouldn't add new files and certainly not any new build dependencies, so reverting commit. Also, the files are located in a different path, and already included in the mariadb-test-data package: /usr/share/mysql/mysql-test/plugin/connect/connect/std_data/JavaWrappers.jar /usr/share/mysql/mysql-test/plugin/connect/connect/std_data/JdbcMariaDB.jar /usr/share/mysql/mysql-test/plugin/connect/connect/std_data/Mongo2.jar /usr/share/mysql/mysql-test/plugin/connect/connect/std_data/Mongo3.jar This change needs to be redesigned and applies only on 10.6 or newer. --- debian/mariadb-plugin-connect.install | 4 ---- 1 file changed, 4 deletions(-) diff --git a/debian/mariadb-plugin-connect.install b/debian/mariadb-plugin-connect.install index 7b5a5f0633e..8a7aee412df 100644 --- a/debian/mariadb-plugin-connect.install +++ b/debian/mariadb-plugin-connect.install @@ -1,6 +1,2 @@ etc/mysql/conf.d/connect.cnf usr/lib/mysql/plugin/ha_connect.so -usr/share/mysql/Mongo2.jar -usr/share/mysql/Mongo3.jar -usr/share/mysql/JavaWrappers.jar -usr/share/mysql/JdbcInterface.jar From dfa2d0bc13362b949b1b1699955583f74e7db90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 7 Jun 2021 17:46:59 +0300 Subject: [PATCH 7/7] MDEV-25869 Change buffer entries are lost on InnoDB restart buf_read_ibuf_merge_pages(): If space->size is 0, invoke fil_space_get_size() to determine the size of the tablespace by reading the header page. Only after that proceed to delete any entries that are beyond the end of the tablespace. Otherwise, we could be deleting valid entries that actually need to be applied. This fixes a regression that had been introduced in commit b80df9eba23b4eb9694e770a41135127c6dbc5df (MDEV-21069), which aimed to avoid crashes during DROP TABLE of corrupted tables. --- storage/innobase/buf/buf0rea.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index ad583e577c4..6b68e9f8fa5 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2020, MariaDB Corporation. +Copyright (c) 2015, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -806,13 +806,18 @@ tablespace_deleted: continue; } - if (UNIV_UNLIKELY(page_nos[i] >= space->size)) { + ulint size = space->size; + if (!size) { + size = fil_space_get_size(space->id); + } + + if (UNIV_UNLIKELY(page_nos[i] >= size)) { do { ibuf_delete_recs(page_id_t(space_ids[i], page_nos[i])); } while (++i < n_stored && space_ids[i - 1] == space_ids[i] - && page_nos[i] >= space->size); + && page_nos[i] >= size); i--; next: fil_space_release(space);