Skip to content

Commit e5e95a2

Browse files
committed
Merge 10.3 into 10.4
2 parents 2b3f6ab + c7daabd commit e5e95a2

File tree

20 files changed

+431
-99
lines changed

20 files changed

+431
-99
lines changed

client/mysql_upgrade.c

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,64 @@ static int install_used_engines(void)
10051005
return 0;
10061006
}
10071007

1008+
static int check_slave_repositories(void)
1009+
{
1010+
DYNAMIC_STRING ds_result;
1011+
int row_count= 0;
1012+
int error= 0;
1013+
const char *query = "SELECT COUNT(*) AS c1 FROM mysql.slave_master_info";
1014+
1015+
if (init_dynamic_string(&ds_result, "", 512, 512))
1016+
die("Out of memory");
1017+
1018+
run_query(query, &ds_result, TRUE);
1019+
1020+
if (ds_result.length)
1021+
{
1022+
row_count= atoi((char *)ds_result.str);
1023+
if (row_count)
1024+
{
1025+
fprintf(stderr,"Slave info repository compatibility check:"
1026+
" Found data in `mysql`.`slave_master_info` table.\n");
1027+
fprintf(stderr,"Warning: Content of `mysql`.`slave_master_info` table"
1028+
" will be ignored as MariaDB supports file based info "
1029+
"repository.\n");
1030+
error= 1;
1031+
}
1032+
}
1033+
dynstr_free(&ds_result);
1034+
1035+
query = "SELECT COUNT(*) AS c1 FROM mysql.slave_relay_log_info";
1036+
1037+
if (init_dynamic_string(&ds_result, "", 512, 512))
1038+
die("Out of memory");
1039+
1040+
run_query(query, &ds_result, TRUE);
1041+
1042+
if (ds_result.length)
1043+
{
1044+
row_count= atoi((char *)ds_result.str);
1045+
if (row_count)
1046+
{
1047+
fprintf(stderr, "Slave info repository compatibility check:"
1048+
" Found data in `mysql`.`slave_relay_log_info` table.\n");
1049+
fprintf(stderr, "Warning: Content of `mysql`.`slave_relay_log_info` "
1050+
"table will be ignored as MariaDB supports file based "
1051+
"repository.\n");
1052+
error= 1;
1053+
}
1054+
}
1055+
dynstr_free(&ds_result);
1056+
if (error)
1057+
{
1058+
fprintf(stderr,"Slave server may not possess the correct replication "
1059+
"metadata.\n");
1060+
fprintf(stderr, "Execution of CHANGE MASTER as per "
1061+
"`mysql`.`slave_master_info` and `mysql`.`slave_relay_log_info` "
1062+
"table content is recommended.\n");
1063+
}
1064+
return 0;
1065+
}
10081066

10091067
/*
10101068
Update all system tables in MySQL Server to current
@@ -1216,7 +1274,8 @@ int main(int argc, char **argv)
12161274
run_mysqlcheck_views() ||
12171275
run_sql_fix_privilege_tables() ||
12181276
run_mysqlcheck_fixnames() ||
1219-
run_mysqlcheck_upgrade(FALSE))
1277+
run_mysqlcheck_upgrade(FALSE) ||
1278+
check_slave_repositories())
12201279
die("Upgrade failed" );
12211280

12221281
verbose("Phase %d/%d: Running 'FLUSH PRIVILEGES'", ++phase, phases_total);

client/mysqlbinlog.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2000, 2014, Oracle and/or its affiliates.
3-
Copyright (c) 2009, 2019, MariaDB
3+
Copyright (c) 2009, 2020, MariaDB
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -180,7 +180,7 @@ enum Exit_status {
180180
*/
181181
static Annotate_rows_log_event *annotate_event= NULL;
182182

183-
void free_annotate_event()
183+
static void free_annotate_event()
184184
{
185185
if (annotate_event)
186186
{
@@ -926,7 +926,7 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
926926
}
927927
}
928928

929-
/*
929+
/*
930930
end of statement check:
931931
i) destroy/free ignored maps
932932
ii) if skip event
@@ -937,21 +937,21 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
937937
*/
938938
if (is_stmt_end)
939939
{
940-
/*
940+
/*
941941
Now is safe to clear ignored map (clear_tables will also
942942
delete original table map events stored in the map).
943943
*/
944944
if (print_event_info->m_table_map_ignored.count() > 0)
945945
print_event_info->m_table_map_ignored.clear_tables();
946946

947-
/*
947+
/*
948948
If there is a kept Annotate event and all corresponding
949949
rbr-events were filtered away, the Annotate event was not
950950
freed and it is just the time to do it.
951951
*/
952-
free_annotate_event();
952+
free_annotate_event();
953953

954-
/*
954+
/*
955955
One needs to take into account an event that gets
956956
filtered but was last event in the statement. If this is
957957
the case, previous rows events that were written into

libmariadb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
include/master-slave.inc
2+
[connection master]
3+
********************************************************************
4+
* Test case1: Upgrade when repository tables have data. *
5+
* mysql_upgrade script should report warnings. *
6+
********************************************************************
7+
connection master;
8+
Slave info repository compatibility check: Found data in `mysql`.`slave_master_info` table.
9+
Warning: Content of `mysql`.`slave_master_info` table will be ignored as MariaDB supports file based info repository.
10+
Slave info repository compatibility check: Found data in `mysql`.`slave_relay_log_info` table.
11+
Warning: Content of `mysql`.`slave_relay_log_info` table will be ignored as MariaDB supports file based repository.
12+
Slave server may not possess the correct replication metadata.
13+
Execution of CHANGE MASTER as per `mysql`.`slave_master_info` and `mysql`.`slave_relay_log_info` table content is recommended.
14+
connection slave;
15+
Slave info repository compatibility check: Found data in `mysql`.`slave_master_info` table.
16+
Warning: Content of `mysql`.`slave_master_info` table will be ignored as MariaDB supports file based info repository.
17+
Slave info repository compatibility check: Found data in `mysql`.`slave_relay_log_info` table.
18+
Warning: Content of `mysql`.`slave_relay_log_info` table will be ignored as MariaDB supports file based repository.
19+
Slave server may not possess the correct replication metadata.
20+
Execution of CHANGE MASTER as per `mysql`.`slave_master_info` and `mysql`.`slave_relay_log_info` table content is recommended.
21+
connection master;
22+
TRUNCATE TABLE `mysql`.`slave_master_info`;
23+
TRUNCATE TABLE `mysql`.`slave_relay_log_info`;
24+
********************************************************************
25+
* Test case2: Upgrade when repository tables are empty. *
26+
* mysql_upgrade script should not report any warning. *
27+
********************************************************************
28+
connection master;
29+
connection slave;
30+
"====== Clean up ======"
31+
connection master;
32+
DROP TABLE `mysql`.`slave_master_info`, `mysql`.`slave_relay_log_info`;
33+
include/rpl_end.inc
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# ==== Purpose ====
2+
#
3+
# While upgrading from "mysql" to "mariadb" if slave info repositories are
4+
# configured to be tables then appropriate warnings should be reported.
5+
#
6+
# ==== Implementation ====
7+
#
8+
# Steps:
9+
# 1 - On MariaDB server create `mysql`.`slave_master_info` and
10+
# `mysql.slave_relay_log_info` tables to simulate upgrade from "mysql"
11+
# to "mariadb" server. Insert data into these tables.
12+
# 2 - Execute "mysql_upgrade" script and verify that appropriate warning
13+
# is reported. i.e Warning is to alert user that the data present in
14+
# repository tables will be ignored.
15+
# 3 - Truncate these tables. This simulates repositories being file and
16+
# the tables are empty.
17+
# 4 - Execute "mysql_upgrade" script and verify that no warnings are
18+
# reported.
19+
#
20+
# ==== References ====
21+
#
22+
# MDEV-10047: table-based master info repository
23+
#
24+
25+
--source include/have_innodb.inc
26+
--source include/mysql_upgrade_preparation.inc
27+
--source include/have_binlog_format_mixed.inc
28+
--source include/master-slave.inc
29+
30+
--write_file $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql
31+
--disable_query_log
32+
--disable_result_log
33+
SET SQL_LOG_BIN=0;
34+
# Table structure extracted from MySQL-5.6.47
35+
CREATE TABLE `mysql`.`slave_master_info` (
36+
`Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file.',
37+
`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.',
38+
`Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last read event.',
39+
`Host` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'The host name of the master.',
40+
`User_name` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',
41+
`User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',
42+
`Port` int(10) unsigned NOT NULL COMMENT 'The network port used to connect to the master.',
43+
`Connect_retry` int(10) unsigned NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',
44+
`Enabled_ssl` tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.',
45+
`Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',
46+
`Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',
47+
`Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',
48+
`Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',
49+
`Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',
50+
`Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.',
51+
`Heartbeat` float NOT NULL,
52+
`Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',
53+
`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',
54+
`Uuid` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',
55+
`Retry_count` bigint(20) unsigned NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.',
56+
`Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',
57+
`Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',
58+
`Enabled_auto_position` tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',
59+
PRIMARY KEY (`Host`,`Port`)
60+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';
61+
62+
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 );
63+
64+
# Table structure extracted from MySQL-5.6.47
65+
CREATE TABLE `mysql`.`slave_relay_log_info` (
66+
`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.',
67+
`Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the current relay log file.',
68+
`Relay_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The relay log position of the last executed event.',
69+
`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.',
70+
`Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last executed event.',
71+
`Sql_delay` int(11) NOT NULL COMMENT 'The number of seconds that the slave must lag behind the master.',
72+
`Number_of_workers` int(10) unsigned NOT NULL,
73+
`Id` int(10) unsigned NOT NULL COMMENT 'Internal Id that uniquely identifies this record.',
74+
PRIMARY KEY (`Id`)
75+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Relay Log Information';
76+
77+
INSERT INTO `mysql`.`slave_relay_log_info` VALUES (7,'./slave-relay-bin.000001',4 ," ",0, 0 ,0 , 1);
78+
SET SQL_LOG_BIN=1;
79+
--enable_query_log
80+
--enable_result_log
81+
EOF
82+
83+
--echo ********************************************************************
84+
--echo * Test case1: Upgrade when repository tables have data. *
85+
--echo * mysql_upgrade script should report warnings. *
86+
--echo ********************************************************************
87+
--connection master
88+
--source $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql
89+
--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log 2>&1
90+
--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log
91+
92+
--connection slave
93+
--source $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql
94+
--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log 2>&1
95+
--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log
96+
97+
--connection master
98+
let $datadir= `select @@datadir`;
99+
remove_file $datadir/mysql_upgrade_info;
100+
TRUNCATE TABLE `mysql`.`slave_master_info`;
101+
TRUNCATE TABLE `mysql`.`slave_relay_log_info`;
102+
--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log
103+
--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log
104+
105+
--echo ********************************************************************
106+
--echo * Test case2: Upgrade when repository tables are empty. *
107+
--echo * mysql_upgrade script should not report any warning. *
108+
--echo ********************************************************************
109+
--connection master
110+
--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log 2>&1
111+
--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log
112+
113+
--connection slave
114+
--exec $MYSQL_UPGRADE --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log 2>&1
115+
--cat_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log
116+
117+
--echo "====== Clean up ======"
118+
--connection master
119+
let $datadir= `select @@datadir`;
120+
remove_file $datadir/mysql_upgrade_info;
121+
DROP TABLE `mysql`.`slave_master_info`, `mysql`.`slave_relay_log_info`;
122+
123+
--remove_file $MYSQLTEST_VARDIR/tmp/slave_table_repo_init.sql
124+
--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_master.log
125+
--remove_file $MYSQLTEST_VARDIR/log/mysql_upgrade_slave.log
126+
127+
--source include/rpl_end.inc
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
SET @start_global_value = @@global.alter_algorithm;
2+
SET GLOBAL alter_algorithm=1.1;
3+
ERROR 42000: Incorrect argument type to variable 'alter_algorithm'
4+
SET GLOBAL alter_algorithm=-1;
5+
ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '-1'
6+
SET GLOBAL alter_algorithm=weird;
7+
ERROR 42000: Variable 'alter_algorithm' can't be set to the value of 'weird'
8+
SET GLOBAL alter_algorithm=4;
9+
SELECT @@global.alter_algorithm;
10+
@@global.alter_algorithm
11+
INSTANT
12+
SET GLOBAL alter_algorithm=3;
13+
SELECT @@global.alter_algorithm;
14+
@@global.alter_algorithm
15+
NOCOPY
16+
SET GLOBAL alter_algorithm=0;
17+
SELECT @@global.alter_algorithm;
18+
@@global.alter_algorithm
19+
DEFAULT
20+
SET GLOBAL alter_algorithm=1;
21+
SELECT @@global.alter_algorithm;
22+
@@global.alter_algorithm
23+
COPY
24+
SET GLOBAL alter_algorithm=2;
25+
SELECT @@global.alter_algorithm;
26+
@@global.alter_algorithm
27+
INPLACE
28+
SET GLOBAL alter_algorithm=5;
29+
ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '5'
30+
SELECT @@global.alter_algorithm;
31+
@@global.alter_algorithm
32+
INPLACE
33+
SET GLOBAL alter_algorithm=NOCOPY;
34+
SET alter_algorithm=1.1;
35+
ERROR 42000: Incorrect argument type to variable 'alter_algorithm'
36+
SET alter_algorithm=-1;
37+
ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '-1'
38+
SET alter_algorithm=weird;
39+
ERROR 42000: Variable 'alter_algorithm' can't be set to the value of 'weird'
40+
SET alter_algorithm=4;
41+
SELECT @@alter_algorithm;
42+
@@alter_algorithm
43+
INSTANT
44+
SET alter_algorithm=3;
45+
SELECT @@alter_algorithm;
46+
@@alter_algorithm
47+
NOCOPY
48+
SET alter_algorithm=0;
49+
SELECT @@alter_algorithm;
50+
@@alter_algorithm
51+
DEFAULT
52+
SET alter_algorithm=1;
53+
SELECT @@alter_algorithm;
54+
@@alter_algorithm
55+
COPY
56+
SET alter_algorithm=2;
57+
SELECT @@alter_algorithm;
58+
@@alter_algorithm
59+
INPLACE
60+
SET alter_algorithm=5;
61+
ERROR 42000: Variable 'alter_algorithm' can't be set to the value of '5'
62+
SELECT @@alter_algorithm;
63+
@@alter_algorithm
64+
INPLACE
65+
SET SESSION alter_algorithm=INSTANT;
66+
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
67+
Variable_name Value
68+
alter_algorithm INSTANT
69+
SET SESSION alter_algorithm=DEFAULT;
70+
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
71+
Variable_name Value
72+
alter_algorithm NOCOPY
73+
SET SESSION alter_algorithm='DEFAULT';
74+
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
75+
Variable_name Value
76+
alter_algorithm DEFAULT
77+
SET SESSION alter_algorithm=DEFAULT;
78+
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
79+
Variable_name Value
80+
alter_algorithm NOCOPY
81+
SET GLOBAL alter_algorithm=DEFAULT;
82+
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
83+
Variable_name Value
84+
alter_algorithm NOCOPY
85+
SET SESSION alter_algorithm=DEFAULT;
86+
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
87+
Variable_name Value
88+
alter_algorithm DEFAULT
89+
SET GLOBAL alter_algorithm = @start_global_value;

0 commit comments

Comments
 (0)