From b8398ee1fd54cb4d6673e6aaf5d1b1fa55123ef7 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 20 Apr 2022 13:11:33 +1000 Subject: [PATCH] MDEV-21208: mysql_tzinfo_to_sql does not work in strict mode Remove Warning that occured by doing an ALTER TABLE ... ORDER BY on an InnoDB table. Reviewed by Brandon Nesterenko --- .../main/mysql_tzinfo_to_sql_symlink.result | 19 +++++++++++-------- .../galera/r/mariadb_tzinfo_to_sql.result | 8 ++------ sql/tztime.cc | 12 ++++++++---- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result index 7c5387b4f17..e9bfef604e8 100644 --- a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result @@ -46,8 +46,8 @@ 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. UNLOCK TABLES; 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; +execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time'); +execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id'); execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone ENGINE=', @time_zone_engine), 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_name ENGINE=', @time_zone_name_engine), 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition ENGINE=', @time_zone_transition_engine, ', ORDER BY Time_zone_id, Transition_time'), 'do 0'); @@ -92,8 +92,8 @@ 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. UNLOCK TABLES; 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; +execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time'); +execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id'); execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone ENGINE=', @time_zone_engine), 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_name ENGINE=', @time_zone_name_engine), 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition ENGINE=', @time_zone_transition_engine, ', ORDER BY Time_zone_id, Transition_time'), 'do 0'); @@ -122,6 +122,7 @@ set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select sum(VARIABLE_NAME='wsrep execute immediate if(@wsrep_is_on, 'SET @save_wsrep_on=@@WSREP_ON, WSREP_ON=OFF', 'do 0'); SET @save_sql_log_bin=@@SQL_LOG_BIN; SET SESSION SQL_LOG_BIN=0; +SET @wsrep_cannot_replicate_tz=0; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -147,8 +148,8 @@ 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. UNLOCK TABLES; 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; +execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time'); +execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id'); SET SESSION SQL_LOG_BIN=@save_sql_log_bin; execute immediate if(@wsrep_is_on, 'SET SESSION WSREP_ON=@save_wsrep_on', 'do 0'); SELECT COUNT(*) FROM time_zone; @@ -257,6 +258,7 @@ set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select sum(VARIABLE_NAME='wsrep execute immediate if(@wsrep_is_on, 'SET @save_wsrep_on=@@WSREP_ON, WSREP_ON=OFF', 'do 0'); SET @save_sql_log_bin=@@SQL_LOG_BIN; SET SESSION SQL_LOG_BIN=0; +SET @wsrep_cannot_replicate_tz=0; LOCK TABLES time_zone WRITE, time_zone_leap_second WRITE, time_zone_name WRITE, @@ -377,6 +379,7 @@ set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select sum(VARIABLE_NAME='wsrep execute immediate if(@wsrep_is_on, 'SET @save_wsrep_on=@@WSREP_ON, WSREP_ON=OFF', 'do 0'); SET @save_sql_log_bin=@@SQL_LOG_BIN; SET SESSION SQL_LOG_BIN=0; +SET @wsrep_cannot_replicate_tz=0; LOCK TABLES time_zone WRITE, time_zone_leap_second WRITE, time_zone_name WRITE, @@ -441,8 +444,8 @@ TRUNCATE TABLE time_zone_transition_type; time_zone_transition_type WRITE')*/; UNLOCK TABLES; 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; +execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time'); +execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id'); execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone ENGINE=', @time_zone_engine), 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_name ENGINE=', @time_zone_name_engine), 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition ENGINE=', @time_zone_transition_engine, ', ORDER BY Time_zone_id, Transition_time'), 'do 0'); diff --git a/mysql-test/suite/galera/r/mariadb_tzinfo_to_sql.result b/mysql-test/suite/galera/r/mariadb_tzinfo_to_sql.result index 087b3174006..d47cec0992f 100644 --- a/mysql-test/suite/galera/r/mariadb_tzinfo_to_sql.result +++ b/mysql-test/suite/galera/r/mariadb_tzinfo_to_sql.result @@ -29,7 +29,7 @@ Warning 1478 Table storage engine 'MyISAM' does not support the create option 'T 'binlog stationary as expected' SELECT @wsrep_is_on, @wsrep_cannot_replicate_tz, @save_wsrep_on, @save_sql_log_bin, @@WSREP_ON, @@SQL_LOG_BIN; @wsrep_is_on @wsrep_cannot_replicate_tz @save_wsrep_on @save_sql_log_bin @@WSREP_ON @@SQL_LOG_BIN -1 1 1 1 1 1 +1 0 1 1 1 1 SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff FROM information_schema.global_status g JOIN baseline b USING (VARIABLE_NAME) @@ -197,10 +197,6 @@ TRUNCATE TABLE time_zone_leap_second; connection node_1; SET GLOBAL WSREP_MODE=''; Warnings: -Warning 1105 ORDER BY ignored as there is a user-defined clustered index in the table 'time_zone_transition' -Warnings: -Warning 1105 ORDER BY ignored as there is a user-defined clustered index in the table 'time_zone_transition_type' -Warnings: Warning 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=1' Warnings: Warning 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=1' @@ -213,7 +209,7 @@ FROM information_schema.global_status g JOIN baseline b USING (VARIABLE_NAME) ORDER BY g.VARIABLE_NAME; VARIABLE_NAME diff -COM_ALTER_TABLE 10 +COM_ALTER_TABLE 8 COM_BEGIN 1 COM_INSERT 6 COM_LOCK_TABLES 0 diff --git a/sql/tztime.cc b/sql/tztime.cc index ec41ad988da..e121790ab93 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2785,6 +2785,7 @@ main(int argc, char **argv) printf("execute immediate if(@wsrep_is_on, 'SET @save_wsrep_on=@@WSREP_ON, WSREP_ON=OFF', 'do 0');\n" "SET @save_sql_log_bin=@@SQL_LOG_BIN;\n" "SET SESSION SQL_LOG_BIN=0;\n" + "SET @wsrep_cannot_replicate_tz=0;\n" "%s%s;\n", trunc_tables, lock_tables); else // Alter time zone tables to InnoDB if wsrep_on is enabled @@ -2820,10 +2821,13 @@ main(int argc, char **argv) printf("UNLOCK TABLES;\n" "COMMIT;\n"); - printf("ALTER TABLE time_zone_transition " - "ORDER BY Time_zone_id, Transition_time;\n"); - printf("ALTER TABLE time_zone_transition_type " - "ORDER BY Time_zone_id, Transition_type_id;\n"); + printf( + "execute immediate if(@wsrep_cannot_replicate_tz, 'do 0'," + "'ALTER TABLE time_zone_transition " + "ORDER BY Time_zone_id, Transition_time');\n" + "execute immediate if(@wsrep_cannot_replicate_tz, 'do 0'," + "'ALTER TABLE time_zone_transition_type " + "ORDER BY Time_zone_id, Transition_type_id');\n"); } else {