Commit e6b505fd authored by Jan Lindström's avatar Jan Lindström

MDEV-18778: mysql_tzinfo_to_sql does not work correctly in MariaDB Galera

There were two problems:

(1) If user wanted same time zone information on all nodes in the Galera
cluster all updates were not replicated as time zone information was
stored on MyISAM tables. This is fixed on Galera by altering time zone
tables to InnoDB while they are modified.

(2) If user wanted different time zone information to nodes in the Galera
cluster TRUNCATE TABLE for time zone tables was replicated by Galera
destroying time zone information from other nodes. This is fixed
on Galera by introducing new option for mysql_tzinfo_to_sql_symlink
tool --skip-write-binlog to disable Galera replication while
time zone tables are modified.

Changes to be committed:
        modified:   mysql-test/r/mysql_tzinfo_to_sql_symlink.result
        modified:   mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result
        new file:   mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result
        new file:   mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test
        modified:   sql/tztime.cc

This is 10.4 version of commit fa740888
parent 136cf040
...@@ -2,9 +2,15 @@ ...@@ -2,9 +2,15 @@
# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
# #
# Verbose run # Verbose run
set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); \d |
prepare set_wsrep_myisam from @prep; IF (select count(*) from information_schema.global_variables where
set @toggle=1; execute set_wsrep_myisam using @toggle; variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB;
ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition; TRUNCATE TABLE time_zone_transition;
...@@ -28,11 +34,25 @@ Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zo ...@@ -28,11 +34,25 @@ Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zo
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion. Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
set @toggle=0; execute set_wsrep_myisam using @toggle; \d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria;
ALTER TABLE time_zone_transition_type ENGINE=Aria;
END IF|
\d ;
# Silent run # Silent run
set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); \d |
prepare set_wsrep_myisam from @prep; IF (select count(*) from information_schema.global_variables where
set @toggle=1; execute set_wsrep_myisam using @toggle; variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB;
ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition; TRUNCATE TABLE time_zone_transition;
...@@ -53,39 +73,83 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, ...@@ -53,39 +73,83 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
set @toggle=0; execute set_wsrep_myisam using @toggle; \d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria;
ALTER TABLE time_zone_transition_type ENGINE=Aria;
END IF|
\d ;
# #
# Testing with explicit timezonefile # Testing with explicit timezonefile
# #
set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
prepare set_wsrep_myisam from @prep;
set @toggle=1; execute set_wsrep_myisam using @toggle;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID(); SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT') (@time_zone_id, 0, 0, 0, 'GMT')
; ;
set @toggle=0; execute set_wsrep_myisam using @toggle; \d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria;
ALTER TABLE time_zone_transition_type ENGINE=Aria;
END IF|
\d ;
# #
# Testing --leap # Testing --leap
# #
set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); \d |
prepare set_wsrep_myisam from @prep; IF (select count(*) from information_schema.global_variables where
set @toggle=1; execute set_wsrep_myisam using @toggle; variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone_leap_second ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone_leap_second; TRUNCATE TABLE time_zone_leap_second;
\d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone_leap_second ENGINE=Aria;
END IF|
\d ;
ALTER TABLE time_zone_leap_second ORDER BY Transition_time; ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
set @toggle=0; execute set_wsrep_myisam using @toggle; \d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria;
ALTER TABLE time_zone_transition_type ENGINE=Aria;
END IF|
\d ;
# #
# MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL # MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL
# #
set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); \d |
prepare set_wsrep_myisam from @prep; IF (select count(*) from information_schema.global_variables where
set @toggle=1; execute set_wsrep_myisam using @toggle; variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB;
ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition; TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type; TRUNCATE TABLE time_zone_transition_type;
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
set @toggle=0; execute set_wsrep_myisam using @toggle; \d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria;
ALTER TABLE time_zone_transition_type ENGINE=Aria;
END IF|
\d ;
##############################################################################
#
# List the test cases that are to be disabled temporarily.
#
# Separate the test case name and the comment with ':'.
#
# <testcasename> : MDEV-<xxxx> <comment>
#
# Do not use any TAB characters for whitespace.
#
##############################################################################
MW-286 : MDEV-19992 Galera test failure on MW-286
GCF-1081 : MDEV-18283 Galera test failure on galera.GCF-1081
MW-329 : MDEV-19962 Galera test failure on MW-329
MW-360 : needs rewrite to be MariaDB gtid compatible
MW-388: MDEV-19803 Long semaphore wait error on galera.MW-388
galera_account_management : MariaDB 10.0 does not support ALTER USER
galera_as_master_gtid : Requires MySQL GTID
galera_as_master_gtid_change_master : Requires MySQL GTID
galera_as_slave_gtid_replicate_do_db_cc : Requires MySQL GTID
galera_as_slave_preordered : wsrep-preordered feature not merged to MariaDB
galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid_log_event::do_apply_event()
galera_autoinc_sst_mariabackup : MDEV-19926 Galera SST tests fail
galera_bf_abort_group_commit : MDEV-18282 Galera test failure on galera.galera_bf_abort_group_commit
galera_binlog_rows_query_log_events: MariaDB does not support binlog_rows_query_log_events
galera_binlog_stmt_autoinc: MDEV-19959 Galera test failure on galera_binlog_stmt_autoinc
galera_concurrent_ctas : MDEV-18180 Galera test failure on galera.galera_concurrent_ctas
galera_encrypt_tmp_files : Get error failed to enable encryption of temporary files
galera_flush : MariaDB does not have global.thread_statistics
galera_gcache_recover_manytrx : MDEV-18834 Galera test failure
galera_ist_mariabackup : MDEV-18829 test leaves port open
galera_ist_progress : MDEV-15236 fails when trying to read transfer status
galera_kill_largechanges : MDEV-18179 Galera test failure on galera.galera_kill_largechanges
galera_kill_nochanges : MDEV-18280 Galera test failure on galera_split_brain and galera_kill_nochanges
galera_many_tables_nopk : MDEV-18182 Galera test failure on galera.galera_many_tables_nopk
galera_migrate : MariaDB does not support START SLAVE USER
galera_pc_ignore_sb : MDEV-15811/MDEV-17357 Test failure
galera_split_brain : MDEV-18280 Galera test failure on galera_split_brain and galera_kill_nochanges
galera_ssl_upgrade : MDEV-13549 Galera test failures
galera_sst_mysqldump_with_key : MDEV-16890 Galera test failure
galera_var_node_address : MDEV-17151 Galera test failure
galera_var_notify_cmd : MDEV-13549 Galera test failures
galera_var_reject_queries : assertion in inline_mysql_socket_send
galera_var_retry_autocommit: MDEV-18181 Galera test failure on galera.galera_var_retry_autocommit
galera_sst_mariabackup_encrypt_with_key : MDEV-19926 Galera SST tests fail
galera_wan : MDEV-17259: Test failure on galera.galera_wan
mysql-wsrep#198 : MDEV-18935 Galera test mysql-wsrep#198 sporaric assertion transaction.cpp:362: int wsrep::transaction::before_commit(): Assertion `state() == s_executing || state() == s_committing || state() == s_must_abort || state() == s_replaying' failed.
partition : MDEV-19958 Galera test failure on galera.partition
...@@ -2,9 +2,15 @@ ...@@ -2,9 +2,15 @@
# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
# #
# Verbose run # Verbose run
set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); \d |
prepare set_wsrep_myisam from @prep; IF (select count(*) from information_schema.global_variables where
set @toggle=1; execute set_wsrep_myisam using @toggle; variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB;
ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition; TRUNCATE TABLE time_zone_transition;
...@@ -28,11 +34,25 @@ Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zo ...@@ -28,11 +34,25 @@ Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zo
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion. Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
set @toggle=0; execute set_wsrep_myisam using @toggle; \d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria;
ALTER TABLE time_zone_transition_type ENGINE=Aria;
END IF|
\d ;
# Silent run # Silent run
set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); \d |
prepare set_wsrep_myisam from @prep; IF (select count(*) from information_schema.global_variables where
set @toggle=1; execute set_wsrep_myisam using @toggle; variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB;
ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition; TRUNCATE TABLE time_zone_transition;
...@@ -53,26 +73,56 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, ...@@ -53,26 +73,56 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
set @toggle=0; execute set_wsrep_myisam using @toggle; \d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria;
ALTER TABLE time_zone_transition_type ENGINE=Aria;
END IF|
\d ;
# #
# Testing with explicit timezonefile # Testing with explicit timezonefile
# #
set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');
prepare set_wsrep_myisam from @prep;
set @toggle=1; execute set_wsrep_myisam using @toggle;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID(); SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT') (@time_zone_id, 0, 0, 0, 'GMT')
; ;
set @toggle=0; execute set_wsrep_myisam using @toggle; \d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria;
ALTER TABLE time_zone_transition_type ENGINE=Aria;
END IF|
\d ;
# #
# Testing --leap # Testing --leap
# #
set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); \d |
prepare set_wsrep_myisam from @prep; IF (select count(*) from information_schema.global_variables where
set @toggle=1; execute set_wsrep_myisam using @toggle; variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone_leap_second ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone_leap_second; TRUNCATE TABLE time_zone_leap_second;
\d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone_leap_second ENGINE=Aria;
END IF|
\d ;
ALTER TABLE time_zone_leap_second ORDER BY Transition_time; ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
set @toggle=0; execute set_wsrep_myisam using @toggle; \d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria;
ALTER TABLE time_zone_transition_type ENGINE=Aria;
END IF|
\d ;
#
# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
#
# Verbose run
set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
prepare set_wsrep_write_binlog from @prep1;
set @toggle=0; execute set_wsrep_write_binlog using @toggle;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it.
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/ignored.tab' as time zone. Skipping it.
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it.
Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
# Silent run
set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
prepare set_wsrep_write_binlog from @prep1;
set @toggle=0; execute set_wsrep_write_binlog using @toggle;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it.
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it.
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
#
# Testing with explicit timezonefile
#
set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
prepare set_wsrep_write_binlog from @prep1;
set @toggle=0; execute set_wsrep_write_binlog using @toggle;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id);
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES
(@time_zone_id, 0, 0, 0, 'GMT')
;
#
# Testing --leap
#
set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
prepare set_wsrep_write_binlog from @prep1;
set @toggle=0; execute set_wsrep_write_binlog using @toggle;
TRUNCATE TABLE time_zone_leap_second;
ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
--source include/have_wsrep.inc
--source include/have_symlink.inc
--source include/not_windows.inc
--echo #
--echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
--echo #
--exec mkdir $MYSQLTEST_VARDIR/zoneinfo
--exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix
--copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT
--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/garbage
--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/ignored.tab
--echo # Verbose run
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_TZINFO_TO_SQL --verbose --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1
--echo # Silent run
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1
--echo #
--echo # Testing with explicit timezonefile
--echo #
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1
--echo #
--echo # Testing --leap
--echo #
--exec $MYSQL_TZINFO_TO_SQL --leap --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1
#
# Cleanup
#
--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo
...@@ -147,6 +147,7 @@ typedef struct st_time_zone_info ...@@ -147,6 +147,7 @@ typedef struct st_time_zone_info
static my_bool prepare_tz_info(TIME_ZONE_INFO *sp, MEM_ROOT *storage); static my_bool prepare_tz_info(TIME_ZONE_INFO *sp, MEM_ROOT *storage);
my_bool opt_leap, opt_verbose, opt_skip_write_binlog;
#if defined(TZINFO2SQL) || defined(TESTTIME) #if defined(TZINFO2SQL) || defined(TESTTIME)
...@@ -2428,6 +2429,14 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp) ...@@ -2428,6 +2429,14 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp)
We are assuming that there are only one list of leap seconds We are assuming that there are only one list of leap seconds
For all timezones. For all timezones.
*/ */
if (!opt_skip_write_binlog)
printf("\\d |\n"
"IF (select count(*) from information_schema.global_variables where\n"
"variable_name='wsrep_on') = 1 THEN\n"
"ALTER TABLE time_zone_leap_second ENGINE=InnoDB;\n"
"END IF|\n"
"\\d ;\n");
printf("TRUNCATE TABLE time_zone_leap_second;\n"); printf("TRUNCATE TABLE time_zone_leap_second;\n");
if (sp->leapcnt) if (sp->leapcnt)
...@@ -2440,6 +2449,14 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp) ...@@ -2440,6 +2449,14 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp)
printf(";\n"); printf(";\n");
} }
if (!opt_skip_write_binlog)
printf("\\d |\n"
"IF (select count(*) from information_schema.global_variables where\n"
"variable_name='wsrep_on') = 1 THEN\n"
"ALTER TABLE time_zone_leap_second ENGINE=Aria;\n"
"END IF|\n"
"\\d ;\n");
printf("ALTER TABLE time_zone_leap_second ORDER BY Transition_time;\n"); printf("ALTER TABLE time_zone_leap_second ORDER BY Transition_time;\n");
} }
...@@ -2597,8 +2614,6 @@ scan_tz_dir(char * name_end, uint symlink_recursion_level, uint verbose) ...@@ -2597,8 +2614,6 @@ scan_tz_dir(char * name_end, uint symlink_recursion_level, uint verbose)
} }
my_bool opt_leap, opt_verbose;
static const char *load_default_groups[]= static const char *load_default_groups[]=
{ "mysql_tzinfo_to_sql", 0}; { "mysql_tzinfo_to_sql", 0};
...@@ -2619,6 +2634,8 @@ static struct my_option my_long_options[] = ...@@ -2619,6 +2634,8 @@ static struct my_option my_long_options[] =
&opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, &opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", {"version", 'V', "Output version information and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-write-binlog", 'S', "Do not replicate changes to time zone tables to other nodes in a Galera cluster",
&opt_skip_write_binlog,&opt_skip_write_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
...@@ -2687,11 +2704,14 @@ main(int argc, char **argv) ...@@ -2687,11 +2704,14 @@ main(int argc, char **argv)
return 1; return 1;
} }
// Replicate MyISAM DDL for this session, cf. lp:1161432 if (opt_skip_write_binlog)
// timezone info unfixable in XtraDB Cluster /* If skip_write_binlog is set and wsrep is compiled in we disable
printf("set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');\n" sql_log_bin and wsrep_on to avoid Galera replicating below
"prepare set_wsrep_myisam from @prep;\n" truncate table clauses. This will allow user to set different
"set @toggle=1; execute set_wsrep_myisam using @toggle;\n"); time zones to nodes in Galera cluster. */
printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n"
"prepare set_wsrep_write_binlog from @prep1;\n"
"set @toggle=0; execute set_wsrep_write_binlog using @toggle;\n");
if (argc == 1 && !opt_leap) if (argc == 1 && !opt_leap)
{ {
...@@ -2699,6 +2719,21 @@ main(int argc, char **argv) ...@@ -2699,6 +2719,21 @@ main(int argc, char **argv)
root_name_end= strmake_buf(fullname, argv[0]); root_name_end= strmake_buf(fullname, argv[0]);
if(!opt_skip_write_binlog)
{
// Alter time zone tables to InnoDB if wsrep_on is enabled
// to allow changes to them to replicate with Galera
printf("\\d |\n"
"IF (select count(*) from information_schema.global_variables where\n"
"variable_name='wsrep_on') = 1 THEN\n"
"ALTER TABLE time_zone ENGINE=InnoDB;\n"
"ALTER TABLE time_zone_name ENGINE=InnoDB;\n"
"ALTER TABLE time_zone_transition ENGINE=InnoDB;\n"
"ALTER TABLE time_zone_transition_type ENGINE=InnoDB;\n"
"END IF|\n"
"\\d ;\n");
}
printf("TRUNCATE TABLE time_zone;\n"); printf("TRUNCATE TABLE time_zone;\n");
printf("TRUNCATE TABLE time_zone_name;\n"); printf("TRUNCATE TABLE time_zone_name;\n");
printf("TRUNCATE TABLE time_zone_transition;\n"); printf("TRUNCATE TABLE time_zone_transition;\n");
...@@ -2740,8 +2775,19 @@ main(int argc, char **argv) ...@@ -2740,8 +2775,19 @@ main(int argc, char **argv)
free_root(&tz_storage, MYF(0)); free_root(&tz_storage, MYF(0));
} }
// Reset wsrep_replicate_myisam. lp:1161432 if(!opt_skip_write_binlog)
printf("set @toggle=0; execute set_wsrep_myisam using @toggle;\n"); {
// Fall back to Aria
printf("\\d |\n"
"IF (select count(*) from information_schema.global_variables where\n"
"variable_name='wsrep_on') = 1 THEN\n"
"ALTER TABLE time_zone ENGINE=Aria;\n"
"ALTER TABLE time_zone_name ENGINE=Aria;\n"
"ALTER TABLE time_zone_transition ENGINE=Aria;\n"
"ALTER TABLE time_zone_transition_type ENGINE=Aria;\n"
"END IF|\n"
"\\d ;\n");
}
free_defaults(default_argv); free_defaults(default_argv);
my_end(0); my_end(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment