diff options
author | Nirbhay Choubey <nirbhay@skysql.com> | 2014-02-14 11:38:46 -0500 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@skysql.com> | 2014-02-14 11:38:46 -0500 |
commit | 8e476e6cbe313fadb6e0cd4402ff8c9d2d487406 (patch) | |
tree | 9c3d55cd08893b821c355fded3d962bb79a0e67c | |
parent | e0f0f5f6d0b983619a67725c6a3351c31a547852 (diff) | |
download | mariadb-git-8e476e6cbe313fadb6e0cd4402ff8c9d2d487406.tar.gz |
MDEV#5534: mysql_tzinfo_to_sql generates wrong query
mysql_tzinfo_to_sql tries to set wsrep_replicate_myisam
as SESSION variable, while its a GLOBAL-only system variable,
and thus the resulting sql would fail to load.
Fixed by changing the scope to GLOBAL in the SET command.
Also added following include files to facilitate testing :
* include/have_wsrep.inc
* include/not_wsrep.inc
* include/have_wsrep_enabled.inc
-rw-r--r-- | mysql-test/include/have_wsrep.inc | 12 | ||||
-rw-r--r-- | mysql-test/include/have_wsrep_enabled.inc | 9 | ||||
-rw-r--r-- | mysql-test/include/not_wsrep.inc | 7 | ||||
-rw-r--r-- | mysql-test/r/mysql_tzinfo_to_sql_symlink.result | 4 | ||||
-rw-r--r-- | mysql-test/r/not_wsrep.require | 2 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/r/binlog_format.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result | 70 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/r/variables.result | 14 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/t/binlog_format.test | 5 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test | 40 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/t/variables.test | 19 | ||||
-rw-r--r-- | mysql-test/t/mysql_tzinfo_to_sql_symlink.test | 5 | ||||
-rw-r--r-- | sql/handler.cc | 2 | ||||
-rw-r--r-- | sql/tztime.cc | 9 |
14 files changed, 189 insertions, 11 deletions
diff --git a/mysql-test/include/have_wsrep.inc b/mysql-test/include/have_wsrep.inc index f8f7e7a82fc..a3ceae41d40 100644 --- a/mysql-test/include/have_wsrep.inc +++ b/mysql-test/include/have_wsrep.inc @@ -1,4 +1,8 @@ --- require r/have_wsrep.require -disable_query_log; -show variables like 'wsrep_on'; -enable_query_log; +# To be used in a test which requires server to be compiled with wsrep support +# (-DWITH_WSREP=ON) and wsrep plugin is ACTIVE. + +if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'wsrep' AND PLUGIN_STATUS='ACTIVE'`) +{ + --skip Test required wsrep plugin. +} + diff --git a/mysql-test/include/have_wsrep_enabled.inc b/mysql-test/include/have_wsrep_enabled.inc new file mode 100644 index 00000000000..edb919fd852 --- /dev/null +++ b/mysql-test/include/have_wsrep_enabled.inc @@ -0,0 +1,9 @@ +# To be used in a test which requires wsrep plugin to be ACTIVE and enabled +# (i.e. wsrep_on=ON). It includes have_wsrep.inc. + +--source include/have_wsrep.inc + +--require r/have_wsrep.require +disable_query_log; +SHOW VARIABLES LIKE 'wsrep_on'; +enable_query_log; diff --git a/mysql-test/include/not_wsrep.inc b/mysql-test/include/not_wsrep.inc new file mode 100644 index 00000000000..3314b5c8717 --- /dev/null +++ b/mysql-test/include/not_wsrep.inc @@ -0,0 +1,7 @@ +# To be used in a test which should be skipped if server is compiled with wsrep +# support (-DWITH_WSREP=ON) and wsrep plugin is ACTIVE. + +-- require r/not_wsrep.require +disable_query_log; +SELECT VERSION() LIKE '%wsrep%' AS 'HAVE_WSREP'; +enable_query_log; diff --git a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result index 1ff20da5b65..dda732937ee 100644 --- a/mysql-test/r/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/r/mysql_tzinfo_to_sql_symlink.result @@ -2,7 +2,6 @@ # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above # # Verbose run -SET SESSION wsrep_replicate_myisam=ON; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -27,7 +26,6 @@ Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid in 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 SESSION wsrep_replicate_myisam=ON; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -51,7 +49,6 @@ ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; # # Testing with explicit timezonefile # -SET SESSION wsrep_replicate_myisam=ON; 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); @@ -61,6 +58,5 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, # # Testing --leap # -SET SESSION wsrep_replicate_myisam=ON; TRUNCATE TABLE time_zone_leap_second; ALTER TABLE time_zone_leap_second ORDER BY Transition_time; diff --git a/mysql-test/r/not_wsrep.require b/mysql-test/r/not_wsrep.require new file mode 100644 index 00000000000..7c8e74af144 --- /dev/null +++ b/mysql-test/r/not_wsrep.require @@ -0,0 +1,2 @@ +HAVE_WSREP +0 diff --git a/mysql-test/suite/wsrep/r/binlog_format.result b/mysql-test/suite/wsrep/r/binlog_format.result index d87cd3bf1a8..5b8da51f829 100644 --- a/mysql-test/suite/wsrep/r/binlog_format.result +++ b/mysql-test/suite/wsrep/r/binlog_format.result @@ -1,3 +1,5 @@ +call mtr.add_suppression("WSREP: cannot get fake InnoDB transaction ID"); +call mtr.add_suppression("WSREP: Could not open saved state file for reading:.*"); SHOW VARIABLES LIKE 'binlog_format'; Variable_name Value binlog_format ROW 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 new file mode 100644 index 00000000000..f77a655773a --- /dev/null +++ b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result @@ -0,0 +1,70 @@ +# +# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above +# +# Verbose run +SET GLOBAL wsrep_replicate_myisam= ON; +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; +SET GLOBAL wsrep_replicate_myisam= OFF; +# Silent run +SET GLOBAL wsrep_replicate_myisam= ON; +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; +SET GLOBAL wsrep_replicate_myisam= OFF; +# +# Testing with explicit timezonefile +# +SET GLOBAL wsrep_replicate_myisam= ON; +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') +; +SET GLOBAL wsrep_replicate_myisam= OFF; +# +# Testing --leap +# +SET GLOBAL wsrep_replicate_myisam= ON; +TRUNCATE TABLE time_zone_leap_second; +ALTER TABLE time_zone_leap_second ORDER BY Transition_time; +SET GLOBAL wsrep_replicate_myisam= OFF; diff --git a/mysql-test/suite/wsrep/r/variables.result b/mysql-test/suite/wsrep/r/variables.result new file mode 100644 index 00000000000..01b5abe5661 --- /dev/null +++ b/mysql-test/suite/wsrep/r/variables.result @@ -0,0 +1,14 @@ + +# MDEV#5534: mysql_tzinfo_to_sql generates wrong query +# +# Testing wsrep_replicate_myisam variable. +SELECT @@session.wsrep_replicate_myisam; +ERROR HY000: Variable 'wsrep_replicate_myisam' is a GLOBAL variable +SELECT @@global.wsrep_replicate_myisam; +@@global.wsrep_replicate_myisam +0 +SET SESSION wsrep_replicate_myisam= ON; +ERROR HY000: Variable 'wsrep_replicate_myisam' is a GLOBAL variable and should be set with SET GLOBAL +SET GLOBAL wsrep_replicate_myisam= ON; +SET GLOBAL wsrep_replicate_myisam= OFF; +# End of test. diff --git a/mysql-test/suite/wsrep/t/binlog_format.test b/mysql-test/suite/wsrep/t/binlog_format.test index 907fae5f4fb..99d34873512 100644 --- a/mysql-test/suite/wsrep/t/binlog_format.test +++ b/mysql-test/suite/wsrep/t/binlog_format.test @@ -1,8 +1,11 @@ ---source include/have_wsrep.inc +--source include/have_wsrep_enabled.inc --source include/have_binlog_format_row.inc # # MDEV-4227: Galera server should stop crashing on setting binlog_format STATEMENT # +call mtr.add_suppression("WSREP: cannot get fake InnoDB transaction ID"); +call mtr.add_suppression("WSREP: Could not open saved state file for reading:.*"); + SHOW VARIABLES LIKE 'binlog_format'; -- error ER_WRONG_VALUE_FOR_VAR SET binlog_format=STATEMENT; diff --git a/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test new file mode 100644 index 00000000000..100e09d3afb --- /dev/null +++ b/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink.test @@ -0,0 +1,40 @@ +--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 $MYSQLTEST_VARDIR/zoneinfo 2>&1 + +--echo # Silent run +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1 + +--echo # +--echo # Testing with explicit timezonefile +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 + +--echo # +--echo # Testing --leap +--echo # + +--exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 + +# +# Cleanup +# + +--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo diff --git a/mysql-test/suite/wsrep/t/variables.test b/mysql-test/suite/wsrep/t/variables.test new file mode 100644 index 00000000000..306cdf9b2c9 --- /dev/null +++ b/mysql-test/suite/wsrep/t/variables.test @@ -0,0 +1,19 @@ +--source include/have_wsrep.inc + +--echo +--echo # MDEV#5534: mysql_tzinfo_to_sql generates wrong query +--echo # +--echo # Testing wsrep_replicate_myisam variable. + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.wsrep_replicate_myisam; +SELECT @@global.wsrep_replicate_myisam; + +--error ER_GLOBAL_VARIABLE +SET SESSION wsrep_replicate_myisam= ON; +SET GLOBAL wsrep_replicate_myisam= ON; + +# Reset it back. +SET GLOBAL wsrep_replicate_myisam= OFF; + +--echo # End of test. diff --git a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test index 1ba4e91be3c..61ae3d2bffd 100644 --- a/mysql-test/t/mysql_tzinfo_to_sql_symlink.test +++ b/mysql-test/t/mysql_tzinfo_to_sql_symlink.test @@ -1,6 +1,11 @@ --source include/have_symlink.inc --source include/not_windows.inc +# Note: The output of mysql_tzinfo_to_sql is different if server is compiled +# with wsrep. Hence a copy of this test has been placed under wsrep suite with +# the updated result. (lp:1161432) +--source include/not_wsrep.inc + --echo # --echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above --echo # diff --git a/sql/handler.cc b/sql/handler.cc index a392171ec18..5f12a6b5c96 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5407,7 +5407,7 @@ void ha_wsrep_fake_trx_id(THD *thd) } else { - WSREP_WARN("cannot get get fake InnoDB transaction ID"); + WSREP_WARN("cannot get fake InnoDB transaction ID"); } DBUG_VOID_RETURN; diff --git a/sql/tztime.cc b/sql/tztime.cc index 70a79f809df..405f5dd1f56 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2707,8 +2707,10 @@ main(int argc, char **argv) return 1; } +#ifdef WITH_WSREP // Replicate MyISAM DDL for this session, cf. lp:1161432 - printf("SET SESSION wsrep_replicate_myisam=ON;\n"); + printf("SET GLOBAL wsrep_replicate_myisam= ON;\n"); +#endif /* WITH_WSREP */ if (argc == 1 && !opt_leap) { @@ -2757,6 +2759,11 @@ main(int argc, char **argv) free_root(&tz_storage, MYF(0)); } +#ifdef WITH_WSREP + // Reset wsrep_replicate_myisam. lp:1161432 + printf("SET GLOBAL wsrep_replicate_myisam= OFF;\n"); +#endif /* WITH_WSREP */ + free_defaults(default_argv); my_end(0); return 0; |