From 069bad5e6be752b2259a994fb2c0a176fc56757a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 11 Mar 2020 12:10:49 +0200 Subject: [PATCH 01/16] Add galera debug sync to galera_slave_replay test. --- mysql-test/suite/galera/t/galera_slave_replay.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/t/galera_slave_replay.test b/mysql-test/suite/galera/t/galera_slave_replay.test index 1d133e90e88..96f6a3e26fc 100644 --- a/mysql-test/suite/galera/t/galera_slave_replay.test +++ b/mysql-test/suite/galera/t/galera_slave_replay.test @@ -7,13 +7,14 @@ # --source include/have_innodb.inc +--source include/have_debug.inc --source include/have_debug_sync.inc --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 --connection node_2a --source include/galera_cluster.inc -#--source suite/galera/include/galera_have_debug_sync.inc +--source include/galera_have_debug_sync.inc # # node 1 is native MariaDB server operating as async replication master From b30446c85dbf0fd402a7833e1042bc13be7fece2 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 11 Mar 2020 13:46:57 +0300 Subject: [PATCH 02/16] Fix compile warning: It was: implicit conversion from 'ha_rows' (aka 'unsigned long long') to 'double' changes value from 18446744073709551615 to 18446744073709551616 Follow what JOIN::get_examined_rows() does for similar code. --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2358615affc..647dee80188 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4267,7 +4267,7 @@ make_join_statistics(JOIN *join, List &tables_list, for (i= 0; i < join->table_count ; i++) if (double rr= join->best_positions[i].records_read) records= COST_MULT(records, rr); - ha_rows rows= records > HA_ROWS_MAX ? HA_ROWS_MAX : (ha_rows) records; + ha_rows rows= records > (double) HA_ROWS_MAX ? HA_ROWS_MAX : (ha_rows) records; set_if_smaller(rows, unit->select_limit_cnt); join->select_lex->increase_derived_records(rows); } From 3ab33c6c929ca615e73465f638a96bdec74adfcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 11 Mar 2020 14:27:16 +0200 Subject: [PATCH 03/16] Cleanup: clang-10 -Wmisleading-indentation Also, remove some trailing white space and add missing static qualifier to free_annotate_event(). --- client/mysqlbinlog.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 979b82463b0..a88c93516b5 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, MariaDB + Copyright (c) 2009, 2020, MariaDB 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 @@ -151,7 +151,7 @@ enum Exit_status { */ static Annotate_rows_log_event *annotate_event= NULL; -void free_annotate_event() +static void free_annotate_event() { if (annotate_event) { @@ -854,7 +854,7 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, print_event_info->m_table_map_ignored.get_table(table_id); bool skip_event= (ignored_map != NULL); - /* + /* end of statement check: i) destroy/free ignored maps ii) if skip event @@ -865,21 +865,21 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, */ if (is_stmt_end) { - /* + /* Now is safe to clear ignored map (clear_tables will also delete original table map events stored in the map). */ if (print_event_info->m_table_map_ignored.count() > 0) print_event_info->m_table_map_ignored.clear_tables(); - /* + /* If there is a kept Annotate event and all corresponding rbr-events were filtered away, the Annotate event was not freed and it is just the time to do it. */ - free_annotate_event(); + free_annotate_event(); - /* + /* One needs to take into account an event that gets filtered but was last event in the statement. If this is the case, previous rows events that were written into From df88e7cefaa7dcffdc52359b73a1087e8569e000 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 11 Mar 2020 16:27:37 +0300 Subject: [PATCH 04/16] fix typedef-related warning and cleanup using namespace std --- storage/innobase/btr/btr0defragment.cc | 3 +++ storage/innobase/include/buf0buf.h | 4 ++-- storage/innobase/include/page0types.h | 4 +--- storage/innobase/page/page0zip.cc | 3 --- storage/innobase/row/row0mysql.cc | 2 +- storage/xtradb/include/buf0buf.h | 4 ++-- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc index 070f6a9cc0a..f679f22dfe4 100644 --- a/storage/innobase/btr/btr0defragment.cc +++ b/storage/innobase/btr/btr0defragment.cc @@ -38,6 +38,9 @@ Modified 30/07/2014 Jan Lindström jan.lindstrom@mariadb.com #include +using std::list; +using std::min; + /* When there's no work, either because defragment is disabled, or because no query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/ #define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000 diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index bcb2252e7dc..b6ad0b85b19 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1504,7 +1504,7 @@ buf_page_encrypt_before_write( NOTE! The definition appears here only for other modules of this directory (buf) to see it. Do not use from outside! */ -typedef struct { +struct buf_tmp_buffer_t { private: int32 reserved; /*!< true if this slot is reserved */ @@ -1534,7 +1534,7 @@ public: return !my_atomic_fas32_explicit(&reserved, true, MY_MEMORY_ORDER_RELAXED); } -} buf_tmp_buffer_t; +}; /** The common buffer control block structure for compressed and uncompressed frames */ diff --git a/storage/innobase/include/page0types.h b/storage/innobase/include/page0types.h index cba2d7a7a8b..3f7a653f8f8 100644 --- a/storage/innobase/include/page0types.h +++ b/storage/innobase/include/page0types.h @@ -26,8 +26,6 @@ Created 2/2/1994 Heikki Tuuri #ifndef page0types_h #define page0types_h -using namespace std; - #include #include "univ.i" @@ -110,7 +108,7 @@ struct page_zip_stat_t { }; /** Compression statistics types */ -typedef map page_zip_stat_per_index_t; +typedef std::map page_zip_stat_per_index_t; /** Statistics on compression, indexed by page_zip_des_t::ssize - 1 */ extern page_zip_stat_t page_zip_stat[PAGE_ZIP_SSIZE_MAX]; diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 233ccaa6a90..1b0fcea326a 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -28,9 +28,6 @@ Created June 2005 by Marko Makela // First include (the generated) my_config.h, to get correct platform defines. #include "my_config.h" -#include -using namespace std; - #define THIS_MODULE #include "page0zip.h" #ifdef UNIV_NONINL diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 55befe42b13..7df9629294a 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -807,7 +807,7 @@ row_create_prebuilt( temp_index->fields[i].fixed_len; } } - srch_key_len = max(srch_key_len,temp_len); + srch_key_len = std::max(srch_key_len,temp_len); } ut_a(srch_key_len <= MAX_SRCH_KEY_VAL_BUFFER); diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index e8a82f2e3e4..39fceeef384 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -1528,7 +1528,7 @@ buf_page_encrypt_before_write( NOTE! The definition appears here only for other modules of this directory (buf) to see it. Do not use from outside! */ -typedef struct { +struct buf_tmp_buffer_t { private: int32 reserved; /*!< true if this slot is reserved */ @@ -1558,7 +1558,7 @@ public: return !my_atomic_fas32_explicit(&reserved, true, MY_MEMORY_ORDER_RELAXED); } -} buf_tmp_buffer_t; +}; /** The common buffer control block structure for compressed and uncompressed frames */ From 7f36300df56da317a46aff1f58b6cdc0e5727cf6 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 11 Mar 2020 16:40:34 +0300 Subject: [PATCH 05/16] MDEV-21918 improve page_zip_verify_checksum() actually, page_zip_verify_checksum() generally allows all-zeroes checksums because our CRC32 checksum is something like crc_1 ^ crc_2 ^ crc_3 Also, all zeroes page is considered correct. As a side effect fix nasty reinterpret_cast<> UB Also, since c0f47a4a5842 innodb_checksum_algorithm=full_crc32 exists which computes CRC32 in one go (without bitwise arithmetic) --- storage/innobase/page/page0zip.cc | 39 +++++++++++++------------------ storage/xtradb/page/page0zip.cc | 39 +++++++++++++------------------ 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 1b0fcea326a..6f1c19799b5 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -4918,35 +4918,28 @@ page_zip_verify_checksum( ib_uint32_t crc32 = 0 /* silence bogus warning */; ib_uint32_t innodb = 0 /* silence bogus warning */; - stored = static_cast(mach_read_from_4( - static_cast(data) + FIL_PAGE_SPACE_OR_CHKSUM)); - -#if FIL_PAGE_LSN % 8 -#error "FIL_PAGE_LSN must be 64 bit aligned" -#endif - - /* Check if page is empty */ - if (stored == 0 - && *reinterpret_cast(static_cast( - data) - + FIL_PAGE_LSN) == 0) { - /* make sure that the page is really empty */ - for (ulint i = 0; i < size; i++) { - if (*((const char*) data + i) != 0) { - return(FALSE); - } - } - /* Empty page */ - return(TRUE); - } - const srv_checksum_algorithm_t curr_algo = static_cast(srv_checksum_algorithm); if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) { - return(TRUE); + return true; } + bool all_zeroes = true; + for (size_t i = 0; i < size; i++) { + if (static_cast(data)[i] != 0) { + all_zeroes = false; + break; + } + } + + if (all_zeroes) { + return true; + } + + stored = static_cast(mach_read_from_4( + static_cast(data) + FIL_PAGE_SPACE_OR_CHKSUM)); + calc = static_cast(page_zip_calc_checksum( data, size, curr_algo)); diff --git a/storage/xtradb/page/page0zip.cc b/storage/xtradb/page/page0zip.cc index 0c7f9b6feff..d85594c5ce3 100644 --- a/storage/xtradb/page/page0zip.cc +++ b/storage/xtradb/page/page0zip.cc @@ -4927,35 +4927,28 @@ page_zip_verify_checksum( ib_uint32_t crc32 = 0 /* silence bogus warning */; ib_uint32_t innodb = 0 /* silence bogus warning */; - stored = static_cast(mach_read_from_4( - static_cast(data) + FIL_PAGE_SPACE_OR_CHKSUM)); - -#if FIL_PAGE_LSN % 8 -#error "FIL_PAGE_LSN must be 64 bit aligned" -#endif - - /* Check if page is empty */ - if (stored == 0 - && *reinterpret_cast(static_cast( - data) - + FIL_PAGE_LSN) == 0) { - /* make sure that the page is really empty */ - for (ulint i = 0; i < size; i++) { - if (*((const char*) data + i) != 0) { - return(FALSE); - } - } - /* Empty page */ - return(TRUE); - } - const srv_checksum_algorithm_t curr_algo = static_cast(srv_checksum_algorithm); if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) { - return(TRUE); + return true; } + bool all_zeroes = true; + for (size_t i = 0; i < size; i++) { + if (static_cast(data)[i] != 0) { + all_zeroes = false; + break; + } + } + + if (all_zeroes) { + return true; + } + + stored = static_cast(mach_read_from_4( + static_cast(data) + FIL_PAGE_SPACE_OR_CHKSUM)); + calc = static_cast(page_zip_calc_checksum( data, size, curr_algo)); From cebf43e166650570182276e30670cd4f97acfedb Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 11 Mar 2020 22:04:06 +0200 Subject: [PATCH 06/16] Fixed wrong assert (found by clang) --- storage/maria/ma_page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index 41278597b0c..2c628184b28 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -112,7 +112,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, if (lock != PAGECACHE_LOCK_LEFT_UNLOCKED) { - DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE || PAGECACHE_LOCK_READ); + DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE || lock == PAGECACHE_LOCK_READ); page_link.unlock= (lock == PAGECACHE_LOCK_WRITE ? PAGECACHE_LOCK_WRITE_UNLOCK : PAGECACHE_LOCK_READ_UNLOCK); From 51e9381dcc01ebd72d4f0adc057a64213f850d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 11 Mar 2020 12:10:49 +0200 Subject: [PATCH 07/16] Add galera debug sync to galera_slave_replay test. --- mysql-test/suite/galera/t/galera_slave_replay.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/t/galera_slave_replay.test b/mysql-test/suite/galera/t/galera_slave_replay.test index 1d133e90e88..96f6a3e26fc 100644 --- a/mysql-test/suite/galera/t/galera_slave_replay.test +++ b/mysql-test/suite/galera/t/galera_slave_replay.test @@ -7,13 +7,14 @@ # --source include/have_innodb.inc +--source include/have_debug.inc --source include/have_debug_sync.inc --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 --connection node_2a --source include/galera_cluster.inc -#--source suite/galera/include/galera_have_debug_sync.inc +--source include/galera_have_debug_sync.inc # # node 1 is native MariaDB server operating as async replication master From 5257bcfc7afad9068ccb7f5f1777c03aa5bedb12 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 12 Mar 2020 14:47:38 +0300 Subject: [PATCH 08/16] InnoDB: improve error message for checksum mismatch --- storage/innobase/buf/buf0buf.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index b47c1175c35..d80eadcfc70 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -3970,7 +3970,8 @@ buf_zip_decompress( frame, size, SRV_CHECKSUM_ALGORITHM_INNODB) << ", none: " << page_zip_calc_checksum( - frame, size, SRV_CHECKSUM_ALGORITHM_NONE); + frame, size, SRV_CHECKSUM_ALGORITHM_NONE) + << " (algorithm: " << srv_checksum_algorithm << ")"; goto err_exit; } From 2c8fa28f40315c237896980ea5fcc1801f7ba140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Mar 2020 07:21:40 +0200 Subject: [PATCH 09/16] Update libmariadb This fixes GCC 10.0.1 -Wstringop-truncation and some typos. --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 8e9c3116105..f9a50468cd7 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 8e9c3116105d9a998a60991b7f4ba910d454d4b1 +Subproject commit f9a50468cd7f35f2e22dc874c185e34b78766a2e From a8566f727f4f6e0e0169e32706dd25f74fe2539a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Mar 2020 07:39:14 +0200 Subject: [PATCH 10/16] Fix GCC 10 -Wstringop-truncation --- storage/perfschema/pfs_instr_class.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/perfschema/pfs_instr_class.cc b/storage/perfschema/pfs_instr_class.cc index c0a9adb6f2c..c75418b28e9 100644 --- a/storage/perfschema/pfs_instr_class.cc +++ b/storage/perfschema/pfs_instr_class.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -619,6 +620,7 @@ static void init_instr_class(PFS_instr_class *klass, DBUG_ASSERT(name_length <= PFS_MAX_INFO_NAME_LENGTH); memset(klass, 0, sizeof(PFS_instr_class)); strncpy(klass->m_name, name, name_length); + klass->m_name[PFS_MAX_INFO_NAME_LENGTH - 1]= '\0'; klass->m_name_length= name_length; klass->m_flags= flags; klass->m_enabled= true; From 47382a2f8c8a6ddd9a363963fcdc75c4eb6a6583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Mar 2020 07:53:41 +0200 Subject: [PATCH 11/16] Fix GCC 10 -Wclass-memaccess --- sql/sql_class.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7364bd6788d..5cb788296c4 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -727,7 +727,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) query_name_consts= 0; semisync_info= 0; db_charset= global_system_variables.collation_database; - bzero(ha_data, sizeof(ha_data)); + bzero((void*) ha_data, sizeof(ha_data)); mysys_var=0; binlog_evt_union.do_union= FALSE; enable_slow_log= 0; From 2e8b0c56a0f78508e62d1527eda2d7c3d9ebdf9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Mar 2020 08:07:02 +0200 Subject: [PATCH 12/16] MDEV-21933 INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES accesses SYS_DATAFILES All tablespace metadata is buffered in fil_system. There is a LRU mechanism, but that only controls the opening and closing of fil_node_t::handle. It is much more efficient and less error-prone to access data file names by looking up the fil_space_t object rather than by essentially joining each row with an access to SYS_DATAFILES via the InnoDB internal SQL parser. dict_get_first_path(): Declare static. The function may only be needed when loading or updating the data dictionary. Also, change a condition in order to avoid a bogus GCC 10 -Wstringop-overflow warning for mem_strdupl() about len==ULINT_UNDEFINED. i_s_sys_tablespaces_fill_table(): Do not access other InnoDB internal dictionary tables than SYS_TABLESPACES. --- storage/innobase/dict/dict0load.cc | 6 +++--- storage/innobase/handler/i_s.cc | 26 ++++++++++---------------- storage/innobase/include/dict0load.h | 10 +--------- 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 8ed947f04cf..486f3c1081c 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2020, 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 @@ -805,7 +805,7 @@ err_len: @param[in] space_id Tablespace ID @return First filepath (caller must invoke ut_free() on it) @retval NULL if no SYS_DATAFILES entry was found. */ -char* +static char* dict_get_first_path( ulint space_id) { @@ -863,7 +863,7 @@ dict_get_first_path( ut_ad(len > 0); ut_ad(len < OS_FILE_MAX_PATH); - if (len > 0 && len != UNIV_SQL_NULL) { + if (len > 0 && len < UNIV_SQL_NULL) { filepath = mem_strdupl( reinterpret_cast(field), len); diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index b32d703f79e..960bd8113db 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -8057,31 +8057,24 @@ i_s_dict_fill_sys_tablespaces( OK(fields[SYS_TABLESPACES_ZIP_PAGE_SIZE]->store( page_size.physical(), true)); - char* filepath = NULL; - if (FSP_FLAGS_HAS_DATA_DIR(cflags)) { - mutex_enter(&dict_sys->mutex); - filepath = dict_get_first_path(space); - mutex_exit(&dict_sys->mutex); - } - - if (filepath == NULL) { - filepath = fil_make_filepath(NULL, name, IBD, false); - } - os_file_stat_t stat; os_file_size_t file; memset(&file, 0xff, sizeof(file)); memset(&stat, 0x0, sizeof(stat)); - if (filepath != NULL) { + if (fil_space_t* s = fil_space_acquire_silent(space)) { + const char *filepath = s->chain.start + ? s->chain.start->name : NULL; + if (!filepath) { + goto file_done; + } file = os_file_get_size(filepath); /* Get the file system (or Volume) block size. */ - dberr_t err = os_file_get_status(filepath, &stat, false, false); - - switch(err) { + switch (dberr_t err = os_file_get_status(filepath, &stat, + false, false)) { case DB_FAIL: ib::warn() << "File '" << filepath << "', failed to get " @@ -8099,7 +8092,8 @@ i_s_dict_fill_sys_tablespaces( break; } - ut_free(filepath); +file_done: + fil_space_release(s); } if (file.m_total_size == static_cast(~0)) { diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index 79440533ab2..b288c0b337a 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2020, 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 @@ -88,14 +88,6 @@ dict_get_first_table_name_in_db( /*============================*/ const char* name); /*!< in: database name which ends to '/' */ -/** Get the first filepath from SYS_DATAFILES for a given space_id. -@param[in] space_id Tablespace ID -@return First filepath (caller must invoke ut_free() on it) -@retval NULL if no SYS_DATAFILES entry was found. */ -char* -dict_get_first_path( - ulint space_id); - /** Make sure the data_file_name is saved in dict_table_t if needed. Try to read it from the fil_system first, then from SYS_DATAFILES. @param[in] table Table object From 9f858f38c03d2671a94d3ff8e8d726f0d2f7023c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Mar 2020 08:37:22 +0200 Subject: [PATCH 13/16] Fix clang 10 warnings _ma_fetch_keypage(): Correct an assertion that used to always hold. Thanks to clang -Wint-in-bool-context for flagging this. double_to_datetime_with_warn(): Suppress -Wimplicit-int-float-conversion by adding a cast. LONGLONG_MAX converted to double will actually be LONGLONG_MAX+1. --- sql/sql_time.cc | 4 ++-- storage/maria/ma_page.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/sql_time.cc b/sql/sql_time.cc index 5a251cfd733..a6fe937df4b 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. - Copyright (c) 2009, 2013 Monty Program Ab. + Copyright (c) 2009, 2020, 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 @@ -403,7 +403,7 @@ bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime, if (neg) value= -value; - if (value > LONGLONG_MAX) + if (value > static_cast(LONGLONG_MAX)) value= static_cast(LONGLONG_MAX); longlong nr= static_cast(floor(value)); diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index 9cd68a208b9..e55c5288d1d 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -1,4 +1,5 @@ /* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + Copyright (c) 2020, 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 @@ -112,7 +113,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, if (lock != PAGECACHE_LOCK_LEFT_UNLOCKED) { - DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE || PAGECACHE_LOCK_READ); + DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE || lock == PAGECACHE_LOCK_READ); page_link.unlock= (lock == PAGECACHE_LOCK_WRITE ? PAGECACHE_LOCK_WRITE_UNLOCK : PAGECACHE_LOCK_READ_UNLOCK); From d9d3c222caefd77fabe172f8396dc42041066ccf Mon Sep 17 00:00:00 2001 From: Sujatha Date: Thu, 12 Mar 2020 17:47:54 +0530 Subject: [PATCH 14/16] MDEV-10047: table-based master info repository Problem: ======= When we upgrade from "mysql" to "mariadb" if slave is using repositories as tables their data is completely ignored and no warning is issued in error log. Fix: === "mysql_upgrade" test should check for the presence of data in "mysql.slave_master_info" and "mysql.slave_relay_log_info" tables. When tables have some data the upgrade script should report a warning which hints users that the data in repository tables will be ignored. --- client/mysql_upgrade.c | 61 ++++++++- .../rpl_mysql_upgrade_slave_repo_check.result | 33 +++++ .../t/rpl_mysql_upgrade_slave_repo_check.test | 127 ++++++++++++++++++ 3 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/rpl_mysql_upgrade_slave_repo_check.result create mode 100644 mysql-test/t/rpl_mysql_upgrade_slave_repo_check.test diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 835dd9fd00d..0bbb8a149ff 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -999,6 +999,64 @@ static int install_used_engines(void) return 0; } +static int check_slave_repositories(void) +{ + DYNAMIC_STRING ds_result; + int row_count= 0; + int error= 0; + const char *query = "SELECT COUNT(*) AS c1 FROM mysql.slave_master_info"; + + if (init_dynamic_string(&ds_result, "", 512, 512)) + die("Out of memory"); + + run_query(query, &ds_result, TRUE); + + if (ds_result.length) + { + row_count= atoi((char *)ds_result.str); + if (row_count) + { + fprintf(stderr,"Slave info repository compatibility check:" + " Found data in `mysql`.`slave_master_info` table.\n"); + fprintf(stderr,"Warning: Content of `mysql`.`slave_master_info` table" + " will be ignored as MariaDB supports file based info " + "repository.\n"); + error= 1; + } + } + dynstr_free(&ds_result); + + query = "SELECT COUNT(*) AS c1 FROM mysql.slave_relay_log_info"; + + if (init_dynamic_string(&ds_result, "", 512, 512)) + die("Out of memory"); + + run_query(query, &ds_result, TRUE); + + if (ds_result.length) + { + row_count= atoi((char *)ds_result.str); + if (row_count) + { + fprintf(stderr, "Slave info repository compatibility check:" + " Found data in `mysql`.`slave_relay_log_info` table.\n"); + fprintf(stderr, "Warning: Content of `mysql`.`slave_relay_log_info` " + "table will be ignored as MariaDB supports file based " + "repository.\n"); + error= 1; + } + } + dynstr_free(&ds_result); + if (error) + { + fprintf(stderr,"Slave server may not possess the correct replication " + "metadata.\n"); + fprintf(stderr, "Execution of CHANGE MASTER as per " + "`mysql`.`slave_master_info` and `mysql`.`slave_relay_log_info` " + "table content is recommended.\n"); + } + return 0; +} /* Update all system tables in MySQL Server to current @@ -1210,7 +1268,8 @@ int main(int argc, char **argv) run_mysqlcheck_views() || run_sql_fix_privilege_tables() || run_mysqlcheck_fixnames() || - run_mysqlcheck_upgrade(FALSE)) + run_mysqlcheck_upgrade(FALSE) || + check_slave_repositories()) die("Upgrade failed" ); verbose("Phase %d/%d: Running 'FLUSH PRIVILEGES'", ++phase, phases_total); diff --git a/mysql-test/r/rpl_mysql_upgrade_slave_repo_check.result b/mysql-test/r/rpl_mysql_upgrade_slave_repo_check.result new file mode 100644 index 00000000000..87cc9ab5a24 --- /dev/null +++ b/mysql-test/r/rpl_mysql_upgrade_slave_repo_check.result @@ -0,0 +1,33 @@ +include/master-slave.inc +[connection master] +******************************************************************** +* Test case1: Upgrade when repository tables have data. * +* mysql_upgrade script should report warnings. * +******************************************************************** +connection master; +Slave info repository compatibility check: Found data in `mysql`.`slave_master_info` table. +Warning: Content of `mysql`.`slave_master_info` table will be ignored as MariaDB supports file based info repository. +Slave info repository compatibility check: Found data in `mysql`.`slave_relay_log_info` table. +Warning: Content of `mysql`.`slave_relay_log_info` table will be ignored as MariaDB supports file based repository. +Slave server may not possess the correct replication metadata. +Execution of CHANGE MASTER as per `mysql`.`slave_master_info` and `mysql`.`slave_relay_log_info` table content is recommended. +connection slave; +Slave info repository compatibility check: Found data in `mysql`.`slave_master_info` table. +Warning: Content of `mysql`.`slave_master_info` table will be ignored as MariaDB supports file based info repository. +Slave info repository compatibility check: Found data in `mysql`.`slave_relay_log_info` table. +Warning: Content of `mysql`.`slave_relay_log_info` table will be ignored as MariaDB supports file based repository. +Slave server may not possess the correct replication metadata. +Execution of CHANGE MASTER as per `mysql`.`slave_master_info` and `mysql`.`slave_relay_log_info` table content is recommended. +connection master; +TRUNCATE TABLE `mysql`.`slave_master_info`; +TRUNCATE TABLE `mysql`.`slave_relay_log_info`; +******************************************************************** +* Test case2: Upgrade when repository tables are empty. * +* mysql_upgrade script should not report any warning. * +******************************************************************** +connection master; +connection slave; +"====== Clean up ======" +connection master; +DROP TABLE `mysql`.`slave_master_info`, `mysql`.`slave_relay_log_info`; +include/rpl_end.inc diff --git a/mysql-test/t/rpl_mysql_upgrade_slave_repo_check.test b/mysql-test/t/rpl_mysql_upgrade_slave_repo_check.test new file mode 100644 index 00000000000..24b5f029e8d --- /dev/null +++ b/mysql-test/t/rpl_mysql_upgrade_slave_repo_check.test @@ -0,0 +1,127 @@ +# ==== Purpose ==== +# +# While upgrading from "mysql" to "mariadb" if slave info repositories are +# configured to be tables then appropriate warnings should be reported. +# +# ==== Implementation ==== +# +# Steps: +# 1 - On MariaDB server create `mysql`.`slave_master_info` and +# `mysql.slave_relay_log_info` tables to simulate upgrade from "mysql" +# to "mariadb" server. Insert data into these tables. +# 2 - Execute "mysql_upgrade" script and verify that appropriate warning +# is reported. i.e Warning is to alert user that the data present in +# repository tables will be ignored. +# 3 - Truncate these tables. This simulates repositories being file and +# the tables are empty. +# 4 - Execute "mysql_upgrade" script and verify that no warnings are +# reported. +# +# ==== References ==== +# +# MDEV-10047: table-based master info repository +# + +--source include/have_innodb.inc +--source include/mysql_upgrade_preparation.inc +--source include/have_binlog_format_mixed.inc +--source include/master-slave.inc + +--write_file $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql +--disable_query_log +--disable_result_log +SET SQL_LOG_BIN=0; +# Table structure extracted from MySQL-5.6.47 +CREATE TABLE `mysql`.`slave_master_info` ( + `Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file.', + `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log currently being read from the master.', + `Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last read event.', + `Host` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'The host name of the master.', + `User_name` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.', + `User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.', + `Port` int(10) unsigned NOT NULL COMMENT 'The network port used to connect to the master.', + `Connect_retry` int(10) unsigned NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.', + `Enabled_ssl` tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.', + `Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.', + `Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.', + `Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.', + `Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.', + `Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.', + `Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.', + `Heartbeat` float NOT NULL, + `Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server', + `Ignored_server_ids` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored, followed by the actual server IDs', + `Uuid` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.', + `Retry_count` bigint(20) unsigned NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.', + `Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)', + `Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files', + `Enabled_auto_position` tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.', + PRIMARY KEY (`Host`,`Port`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information'; + +INSERT INTO `mysql`.`slave_master_info` VALUES (23,'master-bin.000001', 120, 'localhost', 'root'," ", 13000, 60, 0," "," "," "," "," ",0 , 60," ", " ", '28e10fdd-6289-11ea-aab9-207918567a34',10," "," ", 0 ); + +# Table structure extracted from MySQL-5.6.47 +CREATE TABLE `mysql`.`slave_relay_log_info` ( + `Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file or rows in the table. Used to version table definitions.', + `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the current relay log file.', + `Relay_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The relay log position of the last executed event.', + `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log file from which the events in the relay log file were read.', + `Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last executed event.', + `Sql_delay` int(11) NOT NULL COMMENT 'The number of seconds that the slave must lag behind the master.', + `Number_of_workers` int(10) unsigned NOT NULL, + `Id` int(10) unsigned NOT NULL COMMENT 'Internal Id that uniquely identifies this record.', + PRIMARY KEY (`Id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Relay Log Information'; + +INSERT INTO `mysql`.`slave_relay_log_info` VALUES (7,'./slave-relay-bin.000001',4 ," ",0, 0 ,0 , 1); +SET SQL_LOG_BIN=1; +--enable_query_log +--enable_result_log +EOF + +--echo ******************************************************************** +--echo * Test case1: Upgrade when repository tables have data. * +--echo * mysql_upgrade script should report warnings. * +--echo ******************************************************************** +--connection master +--source $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql +--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log 2>&1 +--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log + +--connection slave +--source $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql +--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log 2>&1 +--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log + +--connection master +let $datadir= `select @@datadir`; +remove_file $datadir/mysql_upgrade_info; +TRUNCATE TABLE `mysql`.`slave_master_info`; +TRUNCATE TABLE `mysql`.`slave_relay_log_info`; +--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log +--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log + +--echo ******************************************************************** +--echo * Test case2: Upgrade when repository tables are empty. * +--echo * mysql_upgrade script should not report any warning. * +--echo ******************************************************************** +--connection master +--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log 2>&1 +--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log + +--connection slave +--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log 2>&1 +--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log + +--echo "====== Clean up ======" +--connection master +let $datadir= `select @@datadir`; +remove_file $datadir/mysql_upgrade_info; +DROP TABLE `mysql`.`slave_master_info`, `mysql`.`slave_relay_log_info`; + +--remove_file $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql +--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log +--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log + +--source include/rpl_end.inc From ed21202a14e981a997061db12b2a377910fb02d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Mar 2020 12:09:19 +0200 Subject: [PATCH 15/16] Fix GCC 10.0 -Wstringop-overflow myrg_open(): Reduce the scope of the variable 'end' and simplify the code. For some reason, I got no warning for this code in the 10.2 branch, only 10.3 or later. The ENGINE=MERGE is covered by the tests main.merge, main.merge_debug, and main.merge-big. --- storage/myisammrg/myrg_open.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index 46a801802a1..bf91213dbb0 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2010, 2020, 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 @@ -38,7 +39,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) int save_errno,errpos=0; uint files= 0, i, dir_length, length, UNINIT_VAR(key_parts), min_keys= 0; ulonglong file_offset=0; - char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; + char name_buff[FN_REFLEN*2],buff[FN_REFLEN]; MYRG_INFO *m_info=0; File fd; IO_CACHE file; @@ -62,8 +63,9 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) dir_length=dirname_part(name_buff, name, &name_buff_length); while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { - if ((end=buff+length)[-1] == '\n') - end[-1]='\0'; + char *end= &buff[length - 1]; + if (*end == '\n') + *end= '\0'; if (buff[0] && buff[0] != '#') files++; } @@ -71,8 +73,9 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) my_b_seek(&file, 0); while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { - if ((end=buff+length)[-1] == '\n') - *--end='\0'; + char *end= &buff[length - 1]; + if (*end == '\n') + *end= '\0'; if (!buff[0]) continue; /* Skip empty lines */ if (buff[0] == '#') From c7daabdb0579531a22c24697f9efbe2ea2759435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 16 Mar 2020 10:10:11 +0200 Subject: [PATCH 16/16] MDEV-13134/MDEV-21855: Add a test case --- .../sys_vars/r/alter_algorithm_basic.result | 89 +++++++++++++++++++ .../sys_vars/t/alter_algorithm_basic.test | 58 ++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 mysql-test/suite/sys_vars/r/alter_algorithm_basic.result create mode 100644 mysql-test/suite/sys_vars/t/alter_algorithm_basic.test diff --git a/mysql-test/suite/sys_vars/r/alter_algorithm_basic.result b/mysql-test/suite/sys_vars/r/alter_algorithm_basic.result new file mode 100644 index 00000000000..39cfad4d35c --- /dev/null +++ b/mysql-test/suite/sys_vars/r/alter_algorithm_basic.result @@ -0,0 +1,89 @@ +SET @start_global_value = @@global.alter_algorithm; +SET GLOBAL alter_algorithm=1.1; +ERROR 42000: Incorrect argument type to variable 'alter_algorithm' +SET GLOBAL alter_algorithm=-1; +ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '-1' +SET GLOBAL alter_algorithm=weird; +ERROR 42000: Variable 'alter_algorithm' can't be set to the value of 'weird' +SET GLOBAL alter_algorithm=4; +SELECT @@global.alter_algorithm; +@@global.alter_algorithm +INSTANT +SET GLOBAL alter_algorithm=3; +SELECT @@global.alter_algorithm; +@@global.alter_algorithm +NOCOPY +SET GLOBAL alter_algorithm=0; +SELECT @@global.alter_algorithm; +@@global.alter_algorithm +DEFAULT +SET GLOBAL alter_algorithm=1; +SELECT @@global.alter_algorithm; +@@global.alter_algorithm +COPY +SET GLOBAL alter_algorithm=2; +SELECT @@global.alter_algorithm; +@@global.alter_algorithm +INPLACE +SET GLOBAL alter_algorithm=5; +ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '5' +SELECT @@global.alter_algorithm; +@@global.alter_algorithm +INPLACE +SET GLOBAL alter_algorithm=NOCOPY; +SET alter_algorithm=1.1; +ERROR 42000: Incorrect argument type to variable 'alter_algorithm' +SET alter_algorithm=-1; +ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '-1' +SET alter_algorithm=weird; +ERROR 42000: Variable 'alter_algorithm' can't be set to the value of 'weird' +SET alter_algorithm=4; +SELECT @@alter_algorithm; +@@alter_algorithm +INSTANT +SET alter_algorithm=3; +SELECT @@alter_algorithm; +@@alter_algorithm +NOCOPY +SET alter_algorithm=0; +SELECT @@alter_algorithm; +@@alter_algorithm +DEFAULT +SET alter_algorithm=1; +SELECT @@alter_algorithm; +@@alter_algorithm +COPY +SET alter_algorithm=2; +SELECT @@alter_algorithm; +@@alter_algorithm +INPLACE +SET alter_algorithm=5; +ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '5' +SELECT @@alter_algorithm; +@@alter_algorithm +INPLACE +SET SESSION alter_algorithm=INSTANT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +Variable_name Value +alter_algorithm INSTANT +SET SESSION alter_algorithm=DEFAULT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +Variable_name Value +alter_algorithm NOCOPY +SET SESSION alter_algorithm='DEFAULT'; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +Variable_name Value +alter_algorithm DEFAULT +SET SESSION alter_algorithm=DEFAULT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +Variable_name Value +alter_algorithm NOCOPY +SET GLOBAL alter_algorithm=DEFAULT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +Variable_name Value +alter_algorithm NOCOPY +SET SESSION alter_algorithm=DEFAULT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +Variable_name Value +alter_algorithm DEFAULT +SET GLOBAL alter_algorithm = @start_global_value; diff --git a/mysql-test/suite/sys_vars/t/alter_algorithm_basic.test b/mysql-test/suite/sys_vars/t/alter_algorithm_basic.test new file mode 100644 index 00000000000..69a5320a98c --- /dev/null +++ b/mysql-test/suite/sys_vars/t/alter_algorithm_basic.test @@ -0,0 +1,58 @@ +SET @start_global_value = @@global.alter_algorithm; + +--error ER_WRONG_TYPE_FOR_VAR +SET GLOBAL alter_algorithm=1.1; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL alter_algorithm=-1; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL alter_algorithm=weird; +SET GLOBAL alter_algorithm=4; +SELECT @@global.alter_algorithm; +SET GLOBAL alter_algorithm=3; +SELECT @@global.alter_algorithm; +SET GLOBAL alter_algorithm=0; +SELECT @@global.alter_algorithm; +SET GLOBAL alter_algorithm=1; +SELECT @@global.alter_algorithm; +SET GLOBAL alter_algorithm=2; +SELECT @@global.alter_algorithm; +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL alter_algorithm=5; +SELECT @@global.alter_algorithm; + +SET GLOBAL alter_algorithm=NOCOPY; + +--error ER_WRONG_TYPE_FOR_VAR +SET alter_algorithm=1.1; +--error ER_WRONG_VALUE_FOR_VAR +SET alter_algorithm=-1; +--error ER_WRONG_VALUE_FOR_VAR +SET alter_algorithm=weird; +SET alter_algorithm=4; +SELECT @@alter_algorithm; +SET alter_algorithm=3; +SELECT @@alter_algorithm; +SET alter_algorithm=0; +SELECT @@alter_algorithm; +SET alter_algorithm=1; +SELECT @@alter_algorithm; +SET alter_algorithm=2; +SELECT @@alter_algorithm; +--error ER_WRONG_VALUE_FOR_VAR +SET alter_algorithm=5; +SELECT @@alter_algorithm; + +SET SESSION alter_algorithm=INSTANT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +SET SESSION alter_algorithm=DEFAULT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +SET SESSION alter_algorithm='DEFAULT'; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +SET SESSION alter_algorithm=DEFAULT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +SET GLOBAL alter_algorithm=DEFAULT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; +SET SESSION alter_algorithm=DEFAULT; +SHOW SESSION VARIABLES LIKE 'alter_algorithm'; + +SET GLOBAL alter_algorithm = @start_global_value;