summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-03-16 16:24:36 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-03-16 16:24:36 +0200
commite5e95a287e2e449a63b3b8badfcc54f8fc84a072 (patch)
tree143e1d7abcd07c7afd2aaf0615f9a192409825c9
parent2b3f6ab417a116d213c24ed506b2ea468f24f413 (diff)
parentc7daabdb0579531a22c24697f9efbe2ea2759435 (diff)
downloadmariadb-git-e5e95a287e2e449a63b3b8badfcc54f8fc84a072.tar.gz
Merge 10.3 into 10.4
-rw-r--r--client/mysql_upgrade.c61
-rw-r--r--client/mysqlbinlog.cc14
m---------libmariadb0
-rw-r--r--mysql-test/main/rpl_mysql_upgrade_slave_repo_check.result33
-rw-r--r--mysql-test/main/rpl_mysql_upgrade_slave_repo_check.test127
-rw-r--r--mysql-test/suite/sys_vars/r/alter_algorithm_basic.result89
-rw-r--r--mysql-test/suite/sys_vars/t/alter_algorithm_basic.test58
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sql_time.cc2
-rw-r--r--storage/innobase/buf/buf0buf.cc5
-rw-r--r--storage/innobase/dict/dict0load.cc6
-rw-r--r--storage/innobase/handler/i_s.cc26
-rw-r--r--storage/innobase/include/buf0buf.h2
-rw-r--r--storage/innobase/include/dict0load.h10
-rw-r--r--storage/innobase/include/page0zip.h13
-rw-r--r--storage/innobase/page/page0zip.cc60
-rw-r--r--storage/maria/ma_page.c3
-rw-r--r--storage/myisammrg/myrg_open.c13
-rw-r--r--storage/perfschema/pfs_instr_class.cc2
20 files changed, 430 insertions, 98 deletions
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 85722343388..1bd408b3493 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -1005,6 +1005,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
@@ -1216,7 +1274,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/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index cb1b02de81c..c12f51457ea 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, 2019, 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
@@ -180,7 +180,7 @@ enum Exit_status {
*/
static Annotate_rows_log_event *annotate_event= NULL;
-void free_annotate_event()
+static void free_annotate_event()
{
if (annotate_event)
{
@@ -926,7 +926,7 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
}
}
- /*
+ /*
end of statement check:
i) destroy/free ignored maps
ii) if skip event
@@ -937,21 +937,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
diff --git a/libmariadb b/libmariadb
-Subproject 8e9c3116105d9a998a60991b7f4ba910d454d4b
+Subproject f9a50468cd7f35f2e22dc874c185e34b78766a2
diff --git a/mysql-test/main/rpl_mysql_upgrade_slave_repo_check.result b/mysql-test/main/rpl_mysql_upgrade_slave_repo_check.result
new file mode 100644
index 00000000000..87cc9ab5a24
--- /dev/null
+++ b/mysql-test/main/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/main/rpl_mysql_upgrade_slave_repo_check.test b/mysql-test/main/rpl_mysql_upgrade_slave_repo_check.test
new file mode 100644
index 00000000000..24b5f029e8d
--- /dev/null
+++ b/mysql-test/main/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
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;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index ca33a2a8f12..427c9a591fa 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -765,7 +765,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;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 53f990ffd1f..99feb1006fb 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5577,7 +5577,7 @@ make_join_statistics(JOIN *join, List<TABLE_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);
}
diff --git a/sql/sql_time.cc b/sql/sql_time.cc
index b128a7f7291..9584dfd5f63 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
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 4556411015c..810035acecc 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
-Copyright (c) 2013, 2019, MariaDB Corporation.
+Copyright (c) 2013, 2020, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -3983,7 +3983,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;
}
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index 7d58bffc46f..2889f5d83c8 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
@@ -786,7 +786,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)
{
@@ -844,7 +844,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<const char*>(field),
len);
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 05592fa9584..50f056fd2c8 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -8001,31 +8001,24 @@ i_s_dict_fill_sys_tablespaces(
OK(fields[SYS_TABLESPACES_ZIP_PAGE_SIZE]->store(
fil_space_t::physical_size(cflags), 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 "
@@ -8043,7 +8036,8 @@ i_s_dict_fill_sys_tablespaces(
break;
}
- ut_free(filepath);
+file_done:
+ s->release();
}
if (file.m_total_size == static_cast<os_offset_t>(~0)) {
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index dbccff263a5..a6119e38dfd 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2019, MariaDB Corporation.
+Copyright (c) 2013, 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
diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h
index df345e741ba..afc017fd9d1 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
@@ -79,14 +79,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
diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h
index 458fa166d8c..1637ea00330 100644
--- a/storage/innobase/include/page0zip.h
+++ b/storage/innobase/include/page0zip.h
@@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-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
@@ -493,12 +493,11 @@ page_zip_calc_checksum(
ulint size,
srv_checksum_algorithm_t algo);
-/** Verify a compressed page's checksum.
-@param[in] data compressed page
-@param[in] size size of compressed page
-@return whether the stored checksum is valid according to the value of
-innodb_checksum_algorithm */
-bool page_zip_verify_checksum(const void* data, ulint size);
+/** Validate the checksum on a ROW_FORMAT=COMPRESSED page.
+@param data ROW_FORMAT=COMPRESSED page
+@param size size of the page, in bytes
+@return whether the stored checksum matches innodb_checksum_algorithm */
+bool page_zip_verify_checksum(const void *data, size_t size);
#ifndef UNIV_INNOCHECKSUM
/**********************************************************************//**
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index a2f5095ea7c..ade9350dfa0 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -4988,55 +4988,30 @@ page_zip_calc_checksum(
return(0);
}
-/** Verify a compressed page's checksum.
-@param[in] data compressed page
-@param[in] size size of compressed page
-@return whether the stored checksum is valid according to the value of
-innodb_checksum_algorithm */
-bool page_zip_verify_checksum(const void* data, ulint size)
+/** Validate the checksum on a ROW_FORMAT=COMPRESSED page.
+@param data ROW_FORMAT=COMPRESSED page
+@param size size of the page, in bytes
+@return whether the stored checksum matches innodb_checksum_algorithm */
+bool page_zip_verify_checksum(const void *data, size_t size)
{
- const uint32_t stored = mach_read_from_4(
- static_cast<const byte*>(data) + FIL_PAGE_SPACE_OR_CHKSUM);
-
- compile_time_assert(!(FIL_PAGE_LSN % 8));
+ const srv_checksum_algorithm_t curr_algo =
+ static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
- /* Check if page is empty */
- if (stored == 0
- && *reinterpret_cast<const ib_uint64_t*>(static_cast<const char*>(
- data)
- + FIL_PAGE_LSN) == 0) {
- /* make sure that the page is really empty */
-#ifdef UNIV_INNOCHECKSUM
- ulint i;
- for (i = 0; i < size; i++) {
- if (*((const char*) data + i) != 0)
- break;
- }
- if (i >= size) {
- if (log_file) {
- fprintf(log_file, "Page::%llu is empty and"
- " uncorrupted\n", cur_page_num);
- }
+ if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) {
+ return true;
+ }
- return(TRUE);
+ for (size_t i = 0; i < size; i++) {
+ if (static_cast<const byte*>(data)[i] != 0) {
+ goto not_all_zeroes;
}
-#else
- for (ulint i = 0; i < size; i++) {
- if (*((const char*) data + i) != 0) {
- return(FALSE);
- }
- }
- /* Empty page */
- return(TRUE);
-#endif /* UNIV_INNOCHECKSUM */
}
- const srv_checksum_algorithm_t curr_algo =
- static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
+ return true;
- if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) {
- return(TRUE);
- }
+not_all_zeroes:
+ const uint32_t stored = mach_read_from_4(
+ static_cast<const byte*>(data) + FIL_PAGE_SPACE_OR_CHKSUM);
uint32_t calc = page_zip_calc_checksum(data, size, curr_algo);
@@ -5052,7 +5027,6 @@ bool page_zip_verify_checksum(const void* data, ulint size)
}
if (!strict_verify) {
-
const uint32_t crc32 = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32);
diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c
index 41278597b0c..13f5b7d698b 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);
diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c
index 06c71dec14a..903b4796e69 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
@@ -39,7 +40,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
uint files= 0, i, UNINIT_VAR(key_parts), min_keys= 0;
size_t length, dir_length;
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;
@@ -63,8 +64,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++;
}
@@ -72,8 +74,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] == '#')
diff --git a/storage/perfschema/pfs_instr_class.cc b/storage/perfschema/pfs_instr_class.cc
index d44644eee9d..31f100b92f1 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,
@@ -612,6 +613,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;