Skip to content

Commit

Permalink
MDEV-30498 Rename mysql_upgrade state file to mariadb_upgrade
Browse files Browse the repository at this point in the history
Renames the upgrade state file, and ensures the old
file is properly removed when `mariadb-upgrade` tool is executed.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer
Amazon Web Services, Inc.
  • Loading branch information
christian7007 authored and LinuxJedi committed Feb 7, 2023
1 parent d6e3d89 commit 3622644
Show file tree
Hide file tree
Showing 34 changed files with 120 additions and 98 deletions.
25 changes: 17 additions & 8 deletions client/mysql_upgrade.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ static int get_upgrade_info_file_name(char* name)

dynstr_free(&ds_datadir);

fn_format(name, "mysql_upgrade_info", name, "", MYF(0));
fn_format(name, "mariadb_upgrade_info", name, "", MYF(0));
DBUG_PRINT("exit", ("name: %s", name));
DBUG_RETURN(0);
}
Expand All @@ -709,7 +709,7 @@ static char upgrade_info_file[FN_REFLEN]= {0};


/*
Open or create mysql_upgrade_info file in servers data dir.
Open or create mariadb_upgrade_info file in servers data dir.
Take a lock to ensure there cannot be any other mysql_upgrades
running concurrently
Expand All @@ -724,10 +724,19 @@ const char *create_error_message=
static void open_mysql_upgrade_file()
{
char errbuff[80];
char old_upgrade_info_file[FN_REFLEN]= {0};
size_t path_len;

if (get_upgrade_info_file_name(upgrade_info_file))
{
die("Upgrade failed");
}

// Delete old mysql_upgrade_info file
dirname_part(old_upgrade_info_file, upgrade_info_file, &path_len);
fn_format(old_upgrade_info_file, "mysql_upgrade_info", old_upgrade_info_file, "", MYF(0));
my_delete(old_upgrade_info_file, MYF(MY_IGNORE_ENOENT));

if ((info_file= my_create(upgrade_info_file, 0,
O_RDWR | O_NOFOLLOW,
MYF(0))) < 0)
Expand Down Expand Up @@ -784,7 +793,7 @@ static int faulty_server_versions(const char *version)
}

/*
Read the content of mysql_upgrade_info file and
Read the content of mariadb_upgrade_info file and
compare the version number form file against
version number which mysql_upgrade was compiled for
Expand Down Expand Up @@ -861,16 +870,16 @@ static int upgrade_already_done(int silent)
if (!silent)
{
verbose("This installation of MariaDB is already upgraded to %s.\n"
"There is no need to run mysql_upgrade again for %s.",
"There is no need to run mariadb-upgrade again for %s.",
upgrade_from_version, version);
if (!opt_check_upgrade)
verbose("You can use --force if you still want to run mysql_upgrade",
verbose("You can use --force if you still want to run mariadb-upgrade",
upgrade_from_version, version);
}
return 0;
}

static void finish_mysql_upgrade_info_file(void)
static void finish_mariadb_upgrade_info_file(void)
{
if (info_file < 0)
return;
Expand Down Expand Up @@ -1463,7 +1472,7 @@ int main(int argc, char **argv)
printf("The --upgrade-system-tables option was used, user tables won't be touched.\n");

/*
Read the mysql_upgrade_info file to check if mysql_upgrade
Read the mariadb_upgrade_info file to check if mysql_upgrade
already has been run for this installation of MariaDB
*/
if (!opt_force && !upgrade_already_done(0))
Expand Down Expand Up @@ -1495,7 +1504,7 @@ int main(int argc, char **argv)
verbose("OK");

/* Finish writing indicating upgrade has been performed */
finish_mysql_upgrade_info_file();
finish_mariadb_upgrade_info_file();

DBUG_ASSERT(phase == phases_total);

Expand Down
2 changes: 1 addition & 1 deletion debian/additions/mariadb.conf.d/50-mysql-clients.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[mysql]

[mysql_upgrade]
[mariadb-upgrade]

[mysqladmin]

Expand Down
2 changes: 1 addition & 1 deletion debian/mariadb-server.README.Debian
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ The privilege tables are automatically updated so all there is left is read
the release notes on https://mariadb.com/kb/en/release-notes/ to see if any
changes affect custom apps.

There should not be any need to run 'mysql_upgrade' manually, as the upgrade
There should not be any need to run 'mariadb-upgrade' manually, as the upgrade
scripts do that automatically.


Expand Down
2 changes: 1 addition & 1 deletion mysql-test/include/check-testcase.test
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ select count(*) from mysql.proc;
call mtr.check_testcase();

let $datadir=`select @@datadir`;
list_files $datadir mysql_upgrade_info;
list_files $datadir mariadb_upgrade_info;
list_files $datadir/test #sql*;
list_files $datadir/mysql #sql*;

Expand Down
2 changes: 1 addition & 1 deletion mysql-test/include/load_dump_and_upgrade.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ SELECT COUNT(*) > 0 AS `mysql.user has data` FROM mysql.user;

# It will fail if the file doesn't exist, which is good,
# which is an extra check that it was written
--remove_file $ddir/mysql_upgrade_info
--remove_file $ddir/mariadb_upgrade_info
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_upgrade.test
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ SELECT GROUP_CONCAT(a ORDER BY BINARY a) FROM maria100004_xxx_croatian_ci GROUP
SHOW CREATE TABLE mysql050614_xxx_croatian_ci;
SELECT GROUP_CONCAT(a ORDER BY BINARY a) FROM mysql050614_xxx_croatian_ci GROUP BY a;

remove_file $MYSQLD_DATADIR/mysql_upgrade_info;
remove_file $MYSQLD_DATADIR/mariadb_upgrade_info;
DROP TABLE maria050313_ucs2_croatian_ci_def;
DROP TABLE maria050313_utf8_croatian_ci;
DROP TABLE maria050533_xxx_croatian_ci;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/log_tables_upgrade.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ RENAME TABLE test.bug49823 TO general_log;
DROP TABLE general_log;
RENAME TABLE renamed_general_log TO general_log;
SET GLOBAL general_log = @saved_general_log;
remove_file $MYSQLD_DATADIR/mysql_upgrade_info;
remove_file $MYSQLD_DATADIR/mariadb_upgrade_info;
USE test;
2 changes: 1 addition & 1 deletion mysql-test/main/lowercase_fs_off.test
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ show triggers like '%T1%';
drop table t1;

let $datadir= `select @@datadir`;
remove_file $datadir/mysql_upgrade_info;
remove_file $datadir/mariadb_upgrade_info;

set GLOBAL sql_mode=default;

Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/mysql_json_mysql_upgrade.test
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let $MYSQLD_DATADIR= `select @@datadir`;
show create table mysql_json_test;

--exec $MYSQL_UPGRADE --force 2>&1
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info
--remove_file $MYSQLD_DATADIR/mariadb_upgrade_info

show create table mysql_json_test;
select * from mysql_json_test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let $MYSQLD_DATADIR= `select @@datadir`;
show create table mysql_json_test;

--exec $MYSQL_UPGRADE --force 2>&1
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info
--remove_file $MYSQLD_DATADIR/mariadb_upgrade_info

show create table mysql_json_test;
show create table mysql_json_test_big;
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/mysql_upgrade-20228.test
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ WHERE TABLE_SCHEMA='mysql' AND TABLE_NAME='user';

--echo # Running mysql_upgrade
--exec $MYSQL_UPGRADE --default-character-set=utf8mb4 --force 2>&1
--file_exists $MYSQLD_DATADIR/mysql_upgrade_info
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info
--file_exists $MYSQLD_DATADIR/mariadb_upgrade_info
--remove_file $MYSQLD_DATADIR/mariadb_upgrade_info

--echo #
--echo # Restoring character_set_client and collation_connection back
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/mysql_upgrade-6984.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

update mysql.global_priv set priv=json_set(priv, '$.plugin', 'mysql_native_password', '$.authentication_string', password('foo')) where user='root';

--replace_regex /[^ ]*mysql_upgrade_info/...mysql_upgrade_info/
--replace_regex /[^ ]*mariadb_upgrade_info/...mariadb_upgrade_info/
--exec $MYSQL_UPGRADE

connect(con1,localhost,root,foo,,,);
Expand All @@ -25,7 +25,7 @@ flush privileges;
set global event_scheduler=OFF;

let MYSQLD_DATADIR= `select @@datadir`;
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info
--remove_file $MYSQLD_DATADIR/mariadb_upgrade_info

# --skip-grant-tables state may changed during the test. Need to restart the server
# to restore the --skip-grant-tables state. Otherwise MTR's internal check will fail
Expand Down
20 changes: 10 additions & 10 deletions mysql-test/main/mysql_upgrade.result
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ test
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
Run it again - should say already completed
This installation of MariaDB is already upgraded to VERSION.There is no need to run mysql_upgrade again for VERSION.
You can use --force if you still want to run mysql_upgrade
This installation of MariaDB is already upgraded to VERSION.There is no need to run mariadb-upgrade again for VERSION.
You can use --force if you still want to run mariadb-upgrade
Force should run it regardless of whether it has been run before
Phase 1/7: Checking and upgrading mysql database
Processing databases
Expand Down Expand Up @@ -975,7 +975,7 @@ OK
# Bug#11827359 60223: MYSQL_UPGRADE PROBLEM WITH OPTION
# SKIP-WRITE-BINLOG
#
# Droping the previously created mysql_upgrade_info file..
# Droping the previously created mariadb_upgrade_info file..
# Running mysql_upgrade with --skip-write-binlog..
Phase 1/7: Checking and upgrading mysql database
Processing databases
Expand Down Expand Up @@ -1323,7 +1323,7 @@ length(table_name)
drop table extralongname_extralongname_extralongname_extralongname_ext;
# End of 10.0 tests
set sql_mode=default;
# Droping the previously created mysql_upgrade_info file..
# Droping the previously created mariadb_upgrade_info file..
create table test.t1(a int) engine=MyISAM;
# Trying to enforce InnoDB for all tables
SET GLOBAL enforce_storage_engine=InnoDB;
Expand Down Expand Up @@ -1896,24 +1896,24 @@ FLUSH PRIVILEGES;
# MDEV-27279: mariadb_upgrade add --check-if-upgrade-is-needed
#
This installation of MariaDB is already upgraded to MariaDB .
There is no need to run mysql_upgrade again for MariaDB .
There is no need to run mariadb-upgrade again for MariaDB .
Looking for 'mariadb' as: mariadb
This installation of MariaDB is already upgraded to MariaDB .
There is no need to run mysql_upgrade again for MariaDB .
There is no need to run mariadb-upgrade again for MariaDB .
#
# MDEV-27279: mariadb_upgrade check-if-upgrade absence is do it
#
Looking for 'mariadb' as: mariadb
Empty or non existent ...mysql_upgrade_info. Assuming mysql_upgrade has to be run!
Empty or non existent ...mariadb_upgrade_info. Assuming mysql_upgrade has to be run!
#
# MDEV-27279: mariadb_upgrade check-if-upgrade with minor version change
#
Looking for 'mariadb' as: mariadb
This installation of MariaDB is already upgraded to MariaDB .
There is no need to run mysql_upgrade again for MariaDB .
There is no need to run mariadb-upgrade again for MariaDB .
This installation of MariaDB is already upgraded to MariaDB .
There is no need to run mysql_upgrade again for MariaDB .
You can use --force if you still want to run mysql_upgrade
There is no need to run mariadb-upgrade again for MariaDB .
You can use --force if you still want to run mariadb-upgrade
#
# MDEV-27279: mariadb_upgrade check-if-upgrade with major version change
#
Expand Down
Loading

0 comments on commit 3622644

Please sign in to comment.