Skip to content

Commit 16ad619

Browse files
MDBF-1112 - distro upgrades: mysql as a client in mariadb < 10.4
Pre mariadb 10.4 mysql is the db client.
1 parent 9122272 commit 16ad619

1 file changed

Lines changed: 34 additions & 26 deletions

File tree

scripts/bash_lib.sh

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ err() {
4040
exit 1
4141
}
4242

43+
# mariadb < 10.4 the client binary was mysql
44+
# needed in distro upgrade tests. Remove after rhel7, rocky/alma/rhel 8 are no longer supported
45+
get_db_client() {
46+
command -v mariadb || command -v mysql || {
47+
err "No MariaDB/MySQL client found"
48+
}
49+
}
50+
4351
manual_run_switch() {
4452
# check if we are in Buildbot CI or not
4553
if [[ $BB_CI != "True" ]]; then
@@ -505,17 +513,17 @@ get_columnstore_logs() {
505513
check_mariadb_server_and_create_structures() {
506514
# All the commands below should succeed
507515
set -e
508-
sudo mariadb -e "CREATE DATABASE db"
509-
sudo mariadb -e "CREATE TABLE db.t_innodb(a1 SERIAL, c1 CHAR(8)) ENGINE=InnoDB; INSERT INTO db.t_innodb VALUES (1,'foo'),(2,'bar')"
510-
sudo mariadb -e "CREATE TABLE db.t_myisam(a2 SERIAL, c2 CHAR(8)) ENGINE=MyISAM; INSERT INTO db.t_myisam VALUES (1,'foo'),(2,'bar')"
511-
sudo mariadb -e "CREATE TABLE db.t_aria(a3 SERIAL, c3 CHAR(8)) ENGINE=Aria; INSERT INTO db.t_aria VALUES (1,'foo'),(2,'bar')"
512-
sudo mariadb -e "CREATE TABLE db.t_memory(a4 SERIAL, c4 CHAR(8)) ENGINE=MEMORY; INSERT INTO db.t_memory VALUES (1,'foo'),(2,'bar')"
513-
sudo mariadb -e "CREATE ALGORITHM=MERGE VIEW db.v_merge AS SELECT * FROM db.t_innodb, db.t_myisam, db.t_aria"
514-
sudo mariadb -e "CREATE ALGORITHM=TEMPTABLE VIEW db.v_temptable AS SELECT * FROM db.t_innodb, db.t_myisam, db.t_aria"
515-
sudo mariadb -e "CREATE PROCEDURE db.p() SELECT * FROM db.v_merge"
516-
sudo mariadb -e "CREATE FUNCTION db.f() RETURNS INT DETERMINISTIC RETURN 1"
516+
sudo "$(get_db_client)" -e "CREATE DATABASE db"
517+
sudo "$(get_db_client)" -e "CREATE TABLE db.t_innodb(a1 SERIAL, c1 CHAR(8)) ENGINE=InnoDB; INSERT INTO db.t_innodb VALUES (1,'foo'),(2,'bar')"
518+
sudo "$(get_db_client)" -e "CREATE TABLE db.t_myisam(a2 SERIAL, c2 CHAR(8)) ENGINE=MyISAM; INSERT INTO db.t_myisam VALUES (1,'foo'),(2,'bar')"
519+
sudo "$(get_db_client)" -e "CREATE TABLE db.t_aria(a3 SERIAL, c3 CHAR(8)) ENGINE=Aria; INSERT INTO db.t_aria VALUES (1,'foo'),(2,'bar')"
520+
sudo "$(get_db_client)" -e "CREATE TABLE db.t_memory(a4 SERIAL, c4 CHAR(8)) ENGINE=MEMORY; INSERT INTO db.t_memory VALUES (1,'foo'),(2,'bar')"
521+
sudo "$(get_db_client)" -e "CREATE ALGORITHM=MERGE VIEW db.v_merge AS SELECT * FROM db.t_innodb, db.t_myisam, db.t_aria"
522+
sudo "$(get_db_client)" -e "CREATE ALGORITHM=TEMPTABLE VIEW db.v_temptable AS SELECT * FROM db.t_innodb, db.t_myisam, db.t_aria"
523+
sudo "$(get_db_client)" -e "CREATE PROCEDURE db.p() SELECT * FROM db.v_merge"
524+
sudo "$(get_db_client)" -e "CREATE FUNCTION db.f() RETURNS INT DETERMINISTIC RETURN 1"
517525
if [[ $test_mode == "columnstore" ]]; then
518-
if ! sudo mariadb -e "CREATE TABLE db.t_columnstore(a INT, c VARCHAR(8)) ENGINE=ColumnStore; SHOW CREATE TABLE db.t_columnstore; INSERT INTO db.t_columnstore VALUES (1,'foo'),(2,'bar')"; then
526+
if ! sudo "$(get_db_client)" -e "CREATE TABLE db.t_columnstore(a INT, c VARCHAR(8)) ENGINE=ColumnStore; SHOW CREATE TABLE db.t_columnstore; INSERT INTO db.t_columnstore VALUES (1,'foo'),(2,'bar')"; then
519527
get_columnstore_logs
520528
exit 1
521529
fi
@@ -525,24 +533,24 @@ check_mariadb_server_and_create_structures() {
525533

526534
check_mariadb_server_and_verify_structures() {
527535
# Print "have_xx" capabilitites for the new server
528-
sudo mariadb -e "select 'Stat' t, variable_name name, variable_value val from information_schema.global_status where variable_name like '%have%' union select 'Vars' t, variable_name name, variable_value val from information_schema.global_variables where variable_name like '%have%' order by t, name"
536+
sudo "$(get_db_client)" -e "select 'Stat' t, variable_name name, variable_value val from information_schema.global_status where variable_name like '%have%' union select 'Vars' t, variable_name name, variable_value val from information_schema.global_variables where variable_name like '%have%' order by t, name"
529537
# All the commands below should succeed
530538
set -e
531-
sudo mariadb -e "select @@version, @@version_comment"
532-
sudo mariadb -e "SHOW TABLES IN db"
533-
sudo mariadb -e "SELECT * FROM db.t_innodb; INSERT INTO db.t_innodb VALUES (3,'foo'),(4,'bar')"
534-
sudo mariadb -e "SELECT * FROM db.t_myisam; INSERT INTO db.t_myisam VALUES (3,'foo'),(4,'bar')"
535-
sudo mariadb -e "SELECT * FROM db.t_aria; INSERT INTO db.t_aria VALUES (3,'foo'),(4,'bar')"
539+
sudo "$(get_db_client)" -e "select @@version, @@version_comment"
540+
sudo "$(get_db_client)" -e "SHOW TABLES IN db"
541+
sudo "$(get_db_client)" -e "SELECT * FROM db.t_innodb; INSERT INTO db.t_innodb VALUES (3,'foo'),(4,'bar')"
542+
sudo "$(get_db_client)" -e "SELECT * FROM db.t_myisam; INSERT INTO db.t_myisam VALUES (3,'foo'),(4,'bar')"
543+
sudo "$(get_db_client)" -e "SELECT * FROM db.t_aria; INSERT INTO db.t_aria VALUES (3,'foo'),(4,'bar')"
536544
bb_log_info "If the next INSERT fails with a duplicate key error,"
537545
bb_log_info "it is likely because the server was not upgraded or restarted after upgrade"
538-
sudo mariadb -e "SELECT * FROM db.t_memory; INSERT INTO db.t_memory VALUES (1,'foo'),(2,'bar')"
539-
sudo mariadb -e "SELECT COUNT(*) FROM db.v_merge"
540-
sudo mariadb -e "SELECT COUNT(*) FROM db.v_temptable"
541-
sudo mariadb -e "CALL db.p()"
542-
sudo mariadb -e "SELECT db.f()"
546+
sudo "$(get_db_client)" -e "SELECT * FROM db.t_memory; INSERT INTO db.t_memory VALUES (1,'foo'),(2,'bar')"
547+
sudo "$(get_db_client)" -e "SELECT COUNT(*) FROM db.v_merge"
548+
sudo "$(get_db_client)" -e "SELECT COUNT(*) FROM db.v_temptable"
549+
sudo "$(get_db_client)" -e "CALL db.p()"
550+
sudo "$(get_db_client)" -e "SELECT db.f()"
543551

544552
if [[ $test_mode == "columnstore" ]]; then
545-
if ! sudo mariadb -e "SELECT * FROM db.t_columnstore; INSERT INTO db.t_columnstore VALUES (3,'foo'),(4,'bar')"; then
553+
if ! sudo "$(get_db_client)" -e "SELECT * FROM db.t_columnstore; INSERT INTO db.t_columnstore VALUES (3,'foo'),(4,'bar')"; then
546554
get_columnstore_logs
547555
exit 1
548556
fi
@@ -565,11 +573,11 @@ control_mariadb_server() {
565573
store_mariadb_server_info() {
566574
# We need sudo here because the mariadb local root configured this way, not because we want special write permissions for the resulting file.
567575
# pre-commit check has an issue with it, so instead of adding an exception before each line, we add a piped sort, which should be bogus,
568-
sudo mariadb --skip-column-names -e "select @@version" | awk -F'-' '{ print $1 }' >"/tmp/version.$1"
569-
sudo mariadb --skip-column-names -e "select engine, support, transactions, savepoints from information_schema.engines order by engine" | sort >"./engines.$1"
570-
sudo mariadb --skip-column-names -e "select plugin_name, plugin_status, plugin_type, plugin_library, plugin_license \
576+
sudo "$(get_db_client)" --skip-column-names -e "select @@version" | awk -F'-' '{ print $1 }' >"/tmp/version.$1"
577+
sudo "$(get_db_client)" --skip-column-names -e "select engine, support, transactions, savepoints from information_schema.engines order by engine" | sort >"./engines.$1"
578+
sudo "$(get_db_client)" --skip-column-names -e "select plugin_name, plugin_status, plugin_type, plugin_library, plugin_license \
571579
from information_schema.all_plugins order by plugin_name" | sort >"./plugins.$1"
572-
sudo mariadb --skip-column-names -e "select 'Stat' t, variable_name name, variable_value val
580+
sudo "$(get_db_client)" --skip-column-names -e "select 'Stat' t, variable_name name, variable_value val
573581
from information_schema.global_status where variable_name like '%have%' \
574582
union \
575583
select 'Vars' t, variable_name name, variable_value val \

0 commit comments

Comments
 (0)