diff options
author | Daniel Black <daniel@mariadb.org> | 2020-08-10 20:08:22 +1000 |
---|---|---|
committer | Daniel Black <daniel@mariadb.org> | 2021-01-15 08:56:30 +1100 |
commit | 5b382a920c5b20c48c78947483b8772a02685313 (patch) | |
tree | 6ee7990ae7d9acf8213480f4ab781b881e5dc987 | |
parent | db9b54f16365465deda047a3d5da9696606162a0 (diff) | |
download | mariadb-git-bb-10.2-danielblack-MDEV-23326-mysql_tzinfo_to_sql.tar.gz |
MDEV-23326: mysql_tzinfo_to_sql add --skip-wsrep-checkbb-10.2-danielblack-MDEV-23326-mysql_tzinfo_to_sql
The --skip-write-binary-log added to mysql_tzinfo_to_sql in
MDEV-18778 was only effective if galera was enabled on the server.
This is because it tied together three concepts under on option,
binary logging wsrep replication and using innodb as a transitional
table type.
There are two scenarios where the behaviour of --skip-write-binary-log
would be very useful without being dependant on galera.
1) For loading timezones in to a classical async replication master
without the timezones being written to a binary log. Here we'd
like the --skip-write-binary-log, binary logs are explictly
skipped, but without the wsrep checks..
2) Loading timezone tables with innodb is signifcantly faster
than Aria (with TRANSACTIONAL=1). Slow storage particularly
in container environments (the main MDEV-23326 problem) can
cause excessive initialization time. We'd like to improve
the speed here regardless of if its a Galera environment or not.
To address case 2), the lack of checking the wsrep status also
make it possible to use mysql_tzinfo_to_sql in the mysqld --bootstrap
input allowing for a single initialization of all system tables.
In cleaning up part of MDEV-18778, when changing back from InnoDB
to MyISAM, include the ORDER BY, and don't include this if only
loading leap seconds.
-rw-r--r-- | mysql-test/r/mysql_tzinfo_to_sql_symlink.result | 181 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result | 44 | ||||
-rw-r--r-- | mysql-test/t/mysql_tzinfo_to_sql_symlink.test | 60 | ||||
-rw-r--r-- | sql/tztime.cc | 108 |
4 files changed, 268 insertions, 125 deletions
diff --git a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result index f56a2df2012..e380d55730e 100644 --- a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result @@ -41,11 +41,11 @@ IF (select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_time; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_type_id; END IF| \d ; -# Silent run +# Run on zoneinfo directory \d | IF (select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON') = 1 THEN @@ -82,52 +82,143 @@ IF (select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_time; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_type_id; END IF| \d ; # -# Testing with explicit timezonefile +# Run on zoneinfo directory --skip-write-binlog +# +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='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; +START TRANSACTION; +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. +COMMIT; +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; +# +# Run on zoneinfo directory --skip-write-binlog --skip-wsrep-checks +# +SET SESSION SQL_LOG_BIN=0, WSREP_ON=OFF; +TRUNCATE TABLE time_zone; +TRUNCATE TABLE time_zone_name; +TRUNCATE TABLE time_zone_transition; +TRUNCATE TABLE time_zone_transition_type; +START TRANSACTION; +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. +COMMIT; +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; +# +# Run on zoneinfo directory --skip-wsrep-checks # -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='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_name; +TRUNCATE TABLE time_zone_transition; +TRUNCATE TABLE time_zone_transition_type; +START TRANSACTION; 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_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') ; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN +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. +COMMIT; +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 ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; -END IF| -\d ; +ALTER TABLE time_zone_transition ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_time; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_type_id; +# +# Testing with explicit timezonefile +# +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 with explicit timezonefile --skip-write-binlog +# +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='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 with explicit timezonefile --skip-write-binlog --skip-wsrep-checks +# +SET SESSION SQL_LOG_BIN=0, WSREP_ON=OFF; +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 with explicit timezonefile --skip-wsrep-checks +# +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 # \d | IF (select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='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 ; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone_leap_second ENGINE=InnoDB; END IF| \d ; @@ -139,15 +230,27 @@ ALTER TABLE time_zone_leap_second ENGINE=MyISAM; END IF| \d ; ALTER TABLE time_zone_leap_second ORDER BY Transition_time; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=MyISAM; -ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; -END IF| -\d ; +# +# Testing --skip-write-binlog --leap +# +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='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; +# +# Testing --skip-write-binlog --skip-wsrep-checks --leap +# +SET SESSION SQL_LOG_BIN=0, WSREP_ON=OFF; +TRUNCATE TABLE time_zone_leap_second; +ALTER TABLE time_zone_leap_second ORDER BY Transition_time; +# +# Testing --skip-wsrep-checks --leap +# +ALTER TABLE time_zone_leap_second ENGINE=InnoDB; +TRUNCATE TABLE time_zone_leap_second; +ALTER TABLE time_zone_leap_second ENGINE=MyISAM; +ALTER TABLE time_zone_leap_second ORDER BY Transition_time; # # MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL # @@ -173,7 +276,7 @@ IF (select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_time; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_type_id; END IF| \d ; diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result index bcd96b86516..bf0bc0c2ed2 100644 --- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result @@ -41,8 +41,8 @@ IF (select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_time; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_type_id; END IF| \d ; # Silent run @@ -82,52 +82,25 @@ IF (select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone ENGINE=MyISAM; ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_time; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_type_id; END IF| \d ; # # Testing with explicit timezonefile # -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='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 ; 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') ; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=MyISAM; -ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; -END IF| -\d ; # # Testing --leap # \d | IF (select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='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 ; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone_leap_second ENGINE=InnoDB; END IF| \d ; @@ -139,12 +112,3 @@ ALTER TABLE time_zone_leap_second ENGINE=MyISAM; END IF| \d ; ALTER TABLE time_zone_leap_second ORDER BY Transition_time; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=MyISAM; -ALTER TABLE time_zone_name ENGINE=MyISAM; -ALTER TABLE time_zone_transition ENGINE=MyISAM; -ALTER TABLE time_zone_transition_type ENGINE=MyISAM; -END IF| -\d ; diff --git a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test index 8ca82b87e30..d27c4b6867a 100644 --- a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test +++ b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test @@ -15,11 +15,32 @@ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --exec $MYSQL_TZINFO_TO_SQL --verbose $MYSQLTEST_VARDIR/zoneinfo 2>&1 ---echo # Silent run +--echo # Run on zoneinfo directory --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1 --echo # +--echo # Run on zoneinfo directory --skip-write-binlog +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1 + +--echo # +--echo # Run on zoneinfo directory --skip-write-binlog --skip-wsrep-checks +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --skip-wsrep-checks $MYSQLTEST_VARDIR/zoneinfo 2>&1 + +--echo # +--echo # Run on zoneinfo directory --skip-wsrep-checks +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --skip-wsrep-checks $MYSQLTEST_VARDIR/zoneinfo 2>&1 + +--echo # --echo # Testing with explicit timezonefile --echo # @@ -27,11 +48,48 @@ --exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 --echo # +--echo # Testing with explicit timezonefile --skip-write-binlog +--echo # + +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 + +--echo # +--echo # Testing with explicit timezonefile --skip-write-binlog --skip-wsrep-checks +--echo # + +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --skip-wsrep-checks $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 + +--echo # +--echo # Testing with explicit timezonefile --skip-wsrep-checks +--echo # + +--exec $MYSQL_TZINFO_TO_SQL --skip-wsrep-checks $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 + +--echo # --echo # Testing --leap --echo # --exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 +--echo # +--echo # Testing --skip-write-binlog --leap +--echo # + +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 + +--echo # +--echo # Testing --skip-write-binlog --skip-wsrep-checks --leap +--echo # + +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --skip-wsrep-checks --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 + +--echo # +--echo # Testing --skip-wsrep-checks --leap +--echo # + +--exec $MYSQL_TZINFO_TO_SQL --skip-wsrep-checks --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 + +# # # Cleanup # diff --git a/sql/tztime.cc b/sql/tztime.cc index 067348dccab..b774c69d87b 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -148,7 +148,7 @@ typedef struct st_time_zone_info static my_bool prepare_tz_info(TIME_ZONE_INFO *sp, MEM_ROOT *storage); -my_bool opt_leap, opt_verbose, opt_skip_write_binlog; +my_bool opt_leap, opt_verbose, opt_skip_write_binlog, opt_skip_wsrep_check; #if defined(TZINFO2SQL) || defined(TESTTIME) @@ -2439,12 +2439,16 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp) For all timezones. */ if (!opt_skip_write_binlog) + { + if (!opt_skip_wsrep_check) printf("\\d |\n" - "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" - "ALTER TABLE time_zone_leap_second ENGINE=InnoDB;\n" - "END IF|\n" - "\\d ;\n"); + "IF (select count(*) from information_schema.global_variables where\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n"); + printf("ALTER TABLE time_zone_leap_second ENGINE=InnoDB;\n"); + if (!opt_skip_wsrep_check) + printf("END IF|\n" + "\\d ;\n"); + } printf("TRUNCATE TABLE time_zone_leap_second;\n"); @@ -2459,12 +2463,16 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp) } if (!opt_skip_write_binlog) + { + if (!opt_skip_wsrep_check) printf("\\d |\n" - "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" - "ALTER TABLE time_zone_leap_second ENGINE=MyISAM;\n" - "END IF|\n" - "\\d ;\n"); + "IF (select count(*) from information_schema.global_variables where\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n"); + printf("ALTER TABLE time_zone_leap_second ENGINE=MyISAM;\n"); + if (!opt_skip_wsrep_check) + printf("END IF|\n" + "\\d ;\n"); + } printf("ALTER TABLE time_zone_leap_second ORDER BY Transition_time;\n"); } @@ -2642,8 +2650,10 @@ static struct my_option my_long_options[] = &opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 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", + {"skip-write-binlog", 'S', "Do not replicate changes to time zone tables to the binary log, or to other nodes in a Galera cluster (if wsrep_on=ON)", &opt_skip_write_binlog,&opt_skip_write_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"skip-wsrep-checks", 'G', "Do not check Galera status (wsrep_on=ON) for the --skip-write-binlog option. This also forces Innodb to be use for table loading if --skip-write-binlog is not specified (changing back to MyISAM upon completion).", + &opt_skip_wsrep_check,&opt_skip_wsrep_check, 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} }; @@ -2714,34 +2724,36 @@ main(int argc, char **argv) if (opt_skip_write_binlog) { - /* If skip_write_binlog is set and wsrep is compiled in we disable - sql_log_bin and wsrep_on to avoid Galera replicating below - truncate table clauses. This will allow user to set different - time zones to nodes in Galera cluster. */ - printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='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"); - } - else - { - // 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' and variable_value='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"); + /* If skip_write_binlog we disable sql_log_bin and wsrep_on to avoid Galera + replicating the TRUNCATE TABLE clauses below. This will allow user to set + different time zones to nodes in Galera cluster. + If skip_wsrep_check is enabled, we unconditionally do this. This is useful + in a traditional replication mode as the loading using ENGINE=Innodb is + faster than Aria. Otherwise we do this only if WSREP_ON=ON. */ + if (opt_skip_wsrep_check) + printf("SET SESSION SQL_LOG_BIN=0, WSREP_ON=OFF;\n"); + else + printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='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) { - /* Argument is timezonedir */ - - root_name_end= strmake_buf(fullname, argv[0]); + if (!opt_skip_write_binlog) + { + if (!opt_skip_wsrep_check) + printf("\\d |\n" + "IF (select count(*) from information_schema.global_variables where\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n"); + printf("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"); + if (!opt_skip_wsrep_check) + printf("END IF|\n" + "\\d ;\n"); + } printf("TRUNCATE TABLE time_zone;\n"); printf("TRUNCATE TABLE time_zone_name;\n"); @@ -2749,6 +2761,9 @@ main(int argc, char **argv) printf("TRUNCATE TABLE time_zone_transition_type;\n"); printf("START TRANSACTION;\n"); + /* Argument is timezonedir */ + + root_name_end= strmake_buf(fullname, argv[0]); if (scan_tz_dir(root_name_end, 0, opt_verbose)) { printf("ROLLBACK;\n"); @@ -2787,18 +2802,21 @@ main(int argc, char **argv) free_root(&tz_storage, MYF(0)); } - if(!opt_skip_write_binlog) + if (argc == 1 && !opt_skip_write_binlog && !opt_leap) { - // Fall back to MyISAM + // Fall back to MyISAM + if (!opt_skip_wsrep_check) printf("\\d |\n" "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" - "ALTER TABLE time_zone ENGINE=MyISAM;\n" - "ALTER TABLE time_zone_name ENGINE=MyISAM;\n" - "ALTER TABLE time_zone_transition ENGINE=MyISAM;\n" - "ALTER TABLE time_zone_transition_type ENGINE=MyISAM;\n" - "END IF|\n" - "\\d ;\n"); + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n"); + printf( + "ALTER TABLE time_zone ENGINE=MyISAM;\n" + "ALTER TABLE time_zone_name ENGINE=MyISAM;\n" + "ALTER TABLE time_zone_transition ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_time;\n" + "ALTER TABLE time_zone_transition_type ENGINE=MyISAM, ORDER BY Time_zone_id, Transition_type_id;\n"); + if (!opt_skip_wsrep_check) + printf("END IF|\n" + "\\d ;\n"); } free_defaults(default_argv); |