diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:24:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:24:36 +0000 |
commit | 06eaf7232e9a920468c0f8d74dcf2fe8b555501c (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/include/diff_servers.inc | |
parent | Initial commit. (diff) | |
download | mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.tar.xz mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/include/diff_servers.inc')
-rw-r--r-- | mysql-test/include/diff_servers.inc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/mysql-test/include/diff_servers.inc b/mysql-test/include/diff_servers.inc new file mode 100644 index 00000000..5ec7efc3 --- /dev/null +++ b/mysql-test/include/diff_servers.inc @@ -0,0 +1,67 @@ +# ==== Purpose ==== +# +# Check that two or more servers have identical databases; fail if not. +# +# ==== Usage ==== +# +# --let $diff_servers= 1 2 +# [--let $databases= db1 db2 ...] +# [--let $rpl_debug= 1] +# --source include/diff_servers.inc + +# pretty-print header +--let $_ds_info= servers=$diff_servers +if ($databases != '') +{ + --let $_ds_info= $_ds_info databases=$databases +} +--let $include_filename= diff_servers.inc [$_ds_info] +--source include/begin_include_file.inc + +# get databases +--let $_ds_databases= $diff_database +if ($_ds_databases == '') +{ + --let $_ds_databases= `SELECT GROUP_CONCAT(SCHEMA_NAME SEPARATOR ' ') FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'mtr', 'mysql', 'performance_schema')` +} + +# generate command line +--let $_ds_arg= --defaults-group-suffix=. +--let $_ds_number_pos= `SELECT LOCATE('$_ds_arg', '$MYSQL_DUMP') + LENGTH('$_ds_arg')` +--let $_ds_pre_command= `SELECT SUBSTR('$MYSQL_DUMP', 1, $_ds_number_pos - 1)` +--let $_ds_post_command= `SELECT SUBSTR('$MYSQL_DUMP', $_ds_number_pos + 1)` +--let $_ds_post_command= $_ds_post_command --compact --order-by-primary --skip-extended-insert --no-create-info --databases $_ds_databases +--let $_ds_prev_outfile= + +# iterate over servers +--let $_ds_servers= $diff_servers +while ($_ds_servers != '') +{ + --let $_ds_server_number= `SELECT SUBSTRING_INDEX('$_ds_servers', ' ', 1)` + --let $_ds_servers= `SELECT TRIM(SUBSTRING('$_ds_servers', 1 + LENGTH('_$ds_server_number')))` + --let $_ds_outfile= $MYSQLTEST_VARDIR/tmp/diff_servers_$_ds_server_number + + if ($rpl_debug) + { + --echo generating dump from server '$_ds_server_number' using command '$_ds_pre_command$_ds_server_number $_ds_post_command > $_ds_outfile' + --echo remaining servers: '$_ds_servers' + } + --exec $_ds_pre_command$_ds_server_number $_ds_post_command > $_ds_outfile + + if ($_ds_prev_outfile != '') + { + if ($rpl_debug) + { + --echo diffing files '$_ds_prev_outfile' and '$_ds_outfile' + } + --diff_files $_ds_prev_outfile $_ds_outfile + + --remove_file $_ds_prev_outfile + } + --let $_ds_prev_outfile= $_ds_outfile +} + +--remove_file $_ds_prev_outfile + +--let $include_filename= diff_servers.inc [servers=$_ds_info] +--source include/end_include_file.inc |