Skip to content

Commit 5fe87ac

Browse files
committed
Merge 10.2 into 10.3
2 parents 51e9381 + ed21202 commit 5fe87ac

File tree

18 files changed

+284
-105
lines changed

18 files changed

+284
-105
lines changed

client/mysql_upgrade.c

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

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

10101068
/*
10111069
Update all system tables in MySQL Server to current
@@ -1217,7 +1275,8 @@ int main(int argc, char **argv)
12171275
run_mysqlcheck_views() ||
12181276
run_sql_fix_privilege_tables() ||
12191277
run_mysqlcheck_fixnames() ||
1220-
run_mysqlcheck_upgrade(FALSE))
1278+
run_mysqlcheck_upgrade(FALSE) ||
1279+
check_slave_repositories())
12211280
die("Upgrade failed" );
12221281

12231282
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
@@ -182,7 +182,7 @@ enum Exit_status {
182182
*/
183183
static Annotate_rows_log_event *annotate_event= NULL;
184184

185-
void free_annotate_event()
185+
static void free_annotate_event()
186186
{
187187
if (annotate_event)
188188
{
@@ -928,7 +928,7 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
928928
}
929929
}
930930

931-
/*
931+
/*
932932
end of statement check:
933933
i) destroy/free ignored maps
934934
ii) if skip event
@@ -939,21 +939,21 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
939939
*/
940940
if (is_stmt_end)
941941
{
942-
/*
942+
/*
943943
Now is safe to clear ignored map (clear_tables will also
944944
delete original table map events stored in the map).
945945
*/
946946
if (print_event_info->m_table_map_ignored.count() > 0)
947947
print_event_info->m_table_map_ignored.clear_tables();
948948

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

956-
/*
956+
/*
957957
One needs to take into account an event that gets
958958
filtered but was last event in the statement. If this is
959959
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

sql/sql_class.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
730730
query_name_consts= 0;
731731
semisync_info= 0;
732732
db_charset= global_system_variables.collation_database;
733-
bzero(ha_data, sizeof(ha_data));
733+
bzero((void*) ha_data, sizeof(ha_data));
734734
mysys_var=0;
735735
binlog_evt_union.do_union= FALSE;
736736
enable_slow_log= 0;

sql/sql_select.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5168,7 +5168,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
51685168
for (i= 0; i < join->table_count ; i++)
51695169
if (double rr= join->best_positions[i].records_read)
51705170
records= COST_MULT(records, rr);
5171-
ha_rows rows= records > HA_ROWS_MAX ? HA_ROWS_MAX : (ha_rows) records;
5171+
ha_rows rows= records > (double) HA_ROWS_MAX ? HA_ROWS_MAX : (ha_rows) records;
51725172
set_if_smaller(rows, unit->select_limit_cnt);
51735173
join->select_lex->increase_derived_records(rows);
51745174
}

sql/sql_time.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
2-
Copyright (c) 2009, 2013 Monty Program Ab.
2+
Copyright (c) 2009, 2020, MariaDB Corporation.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -476,7 +476,7 @@ bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime,
476476
if (neg)
477477
value= -value;
478478

479-
if (value > LONGLONG_MAX)
479+
if (value > static_cast<double>(LONGLONG_MAX))
480480
value= static_cast<double>(LONGLONG_MAX);
481481

482482
longlong nr= static_cast<ulonglong>(floor(value));

storage/innobase/buf/buf0buf.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4013,7 +4013,8 @@ buf_zip_decompress(
40134013
frame, size, SRV_CHECKSUM_ALGORITHM_INNODB)
40144014
<< ", none: "
40154015
<< page_zip_calc_checksum(
4016-
frame, size, SRV_CHECKSUM_ALGORITHM_NONE);
4016+
frame, size, SRV_CHECKSUM_ALGORITHM_NONE)
4017+
<< " (algorithm: " << srv_checksum_algorithm << ")";
40174018

40184019
goto err_exit;
40194020
}

storage/innobase/dict/dict0load.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2016, 2019, MariaDB Corporation.
4+
Copyright (c) 2016, 2020, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -784,7 +784,7 @@ dict_process_sys_datafiles(
784784
@param[in] space_id Tablespace ID
785785
@return First filepath (caller must invoke ut_free() on it)
786786
@retval NULL if no SYS_DATAFILES entry was found. */
787-
char*
787+
static char*
788788
dict_get_first_path(
789789
ulint space_id)
790790
{
@@ -842,7 +842,7 @@ dict_get_first_path(
842842
ut_ad(len > 0);
843843
ut_ad(len < OS_FILE_MAX_PATH);
844844

845-
if (len > 0 && len != UNIV_SQL_NULL) {
845+
if (len > 0 && len < UNIV_SQL_NULL) {
846846
filepath = mem_strdupl(
847847
reinterpret_cast<const char*>(field),
848848
len);

0 commit comments

Comments
 (0)