Skip to content

Commit ad94790

Browse files
committed
MDEV-9453 mysql_upgrade.exe error when mysql is migrated to mariadb
mysqlcheck tool can be used even if opt_systables_only is true (to upgrade views from mysql - that overrides opt_systables_only)
1 parent 0a76ad5 commit ad94790

File tree

4 files changed

+47
-12
lines changed

4 files changed

+47
-12
lines changed

client/mysql_upgrade.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,16 +1051,11 @@ int main(int argc, char **argv)
10511051
/* Find mysql */
10521052
find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"), self_name);
10531053

1054-
if (!opt_systables_only)
1055-
{
1056-
/* Find mysqlcheck */
1057-
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
1058-
}
1059-
else
1060-
{
1061-
if (!opt_silent)
1062-
printf("The --upgrade-system-tables option was used, databases won't be touched.\n");
1063-
}
1054+
/* Find mysqlcheck */
1055+
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
1056+
1057+
if (opt_systables_only && !opt_silent)
1058+
printf("The --upgrade-system-tables option was used, user tables won't be touched.\n");
10641059

10651060
/*
10661061
Read the mysql_upgrade_info file to check if mysql_upgrade

mysql-test/r/mysql_upgrade.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ GRANT USAGE ON *.* TO 'user3'@'%'
250250
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'
251251
DROP USER 'user3'@'%';
252252
End of 5.1 tests
253-
The --upgrade-system-tables option was used, databases won't be touched.
253+
The --upgrade-system-tables option was used, user tables won't be touched.
254254
Phase 1/4: Fixing views... Skipped
255255
Phase 2/4: Fixing table and database names ... Skipped
256256
Phase 3/4: Checking and upgrading tables... Skipped

mysql-test/r/mysql_upgrade_view.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,19 @@ master-bin.000001 # Query # # use `test`; REPAIR VIEW `v3` FROM MYSQL
266266
master-bin.000001 # Query # # use `test`; REPAIR VIEW `v4` FROM MYSQL
267267
drop table if exists kv;
268268
drop view v1,v2,v3,v4;
269+
rename table mysql.event to mysql.ev_bk;
270+
flush tables;
271+
The --upgrade-system-tables option was used, user tables won't be touched.
272+
MySQL upgrade detected
273+
Phase 1/4: Fixing views from mysql
274+
test.v1 OK
275+
test.v2 OK
276+
test.v3 OK
277+
Phase 2/4: Fixing table and database names ... Skipped
278+
Phase 3/4: Checking and upgrading tables... Skipped
279+
Phase 4/4: Running 'mysql_fix_privilege_tables'
280+
OK
281+
drop table mysql.event;
282+
rename table mysql.ev_bk to mysql.event;
283+
drop view v1,v2,v3;
269284
drop table t1;

mysql-test/t/mysql_upgrade_view.test

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,30 @@ rename table mysql.ev_bk to mysql.event;
157157

158158
drop table if exists kv;
159159
drop view v1,v2,v3,v4;
160-
drop table t1;
161160

161+
#
162+
# MDEV-9453 mysql_upgrade.exe error when mysql is migrated to mariadb
163+
# (mysql_upgrade.exe --upgrade-system-tables fails on fixing views)
164+
#
165+
166+
# Make it look like a MySQL directory again
167+
168+
rename table mysql.event to mysql.ev_bk;
169+
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.MYI $MYSQLD_DATADIR/mysql/event.MYI
170+
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.MYD $MYSQLD_DATADIR/mysql/event.MYD
171+
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.frm $MYSQLD_DATADIR/mysql/event.frm
172+
173+
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v1.frm $MYSQLD_DATADIR/test/v1.frm
174+
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v2.frm $MYSQLD_DATADIR/test/v2.frm
175+
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v3.frm $MYSQLD_DATADIR/test/v3.frm
176+
177+
flush tables;
178+
179+
--replace_result $MYSQLTEST_VARDIR var
180+
--exec $MYSQL_UPGRADE --force --upgrade-system-tables 2>&1
181+
182+
# back to mariadb default
183+
drop table mysql.event;
184+
rename table mysql.ev_bk to mysql.event;
185+
drop view v1,v2,v3;
186+
drop table t1;

0 commit comments

Comments
 (0)