mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Last part of WL#1062: better replication of timezones: no more use
of SET ONE_SHOT; storing tz info directly in event (if this info is needed), it's now allowed to have different global tz on master and slave. client/mysqlbinlog.cc: we need MAX_TIME_ZONE_NAME_LENGTH when processing log_event.h, and it's declared in mysql_priv.h mysql-test/r/rpl_timezone.result: result update mysql-test/t/rpl_timezone-slave.opt: Now that we can have different global value of timezone on master and slave, let's test it. mysql-test/t/rpl_timezone.test: Tests of the new replication of timezones: checking the output of mysqlbinlog, replication of CONVERT_TZ(). sql/ha_innodb.cc: No very fast shutdown on Netware (anyway it's disabled on all platforms, but this is so that we don't forget to keep it disabled on Netware in the future). sql/log.cc: No more need to write SET ONE_SHOT to binlog for character set and timezone (as we store this info directly nin the Query_log_event now). sql/log_event.cc: Exclude ::write() methods if MYSQL_CLIENT. Storing timezone info in the Query_log_event in master. Re-reading it in slave. Small code cleanups. I plan to not store the end 0 of catalog in binlog events soon. sql/log_event.h: replication of time zones: a place for tz info in Query_log_event, in LAST_EVENT_INFO. Plus if we are compiling a client, we don't need the ::write() methods, so keeping them out (of mysqlbinlog.cc; keeping them in, resulted in problem that mysqlbinlog does not know Timezone structure). sql/mysql_priv.h: moving this define from tztime.h (tztime.h has things which are too much for a client like mysqlbinlog). sql/set_var.cc: It's now allowed to change global value of charset or timezone even if using binlogging or if being a slave. Making CONVERT_TZ(,,@@session.time_zone) replicate. sql/set_var.h: these ::check()s are not needed anymore (changing global charset or timezone is now allowed even if binlogging or slave) sql/slave.cc: No more need to check for same global timezone if master is 5.x (ok, strictly speaking if it is > 5.0.3 but this is alpha). sql/slave.h: a function to wrap settings of charset to default. sql/tztime.cc: Adaptation of my_tz_find() to the case where it's not called from inside a query (i.e. cannot join its tz tables to the query's ones): this variant opens the tz tables itself, reads from them, and closes them. This is presently only used by the slave SQL thread (when it sets the tz before executing a query). sql/tztime.h: declaration of new function, plus moving symbol to mysql_priv.h for easier usage in mysqlbinlog (Dmitri, pardon me). BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
This commit is contained in:
@@ -3,21 +3,25 @@ source include/master-slave.inc;
|
||||
|
||||
# Some preparations
|
||||
let $VERSION=`select version()`;
|
||||
set timestamp=100000000; # for fixed output of mysqlbinlog
|
||||
create table t1 (t timestamp);
|
||||
create table t2 (t char(32));
|
||||
|
||||
connection slave;
|
||||
select @@time_zone;
|
||||
|
||||
#
|
||||
# Let us check how well replication works when we are saving datetime
|
||||
# value in TIMESTAMP field.
|
||||
#
|
||||
connection master;
|
||||
select @@time_zone;
|
||||
insert into t1 values ('20050101000000'), ('20050611093902');
|
||||
set time_zone='UTC';
|
||||
insert into t1 values ('20040101000000'), ('20040611093902');
|
||||
select * from t1;
|
||||
# On slave we still in 'Europe/Moscow' so we should see equivalent but
|
||||
# textually different values.
|
||||
sync_slave_with_master;
|
||||
set time_zone='UTC';
|
||||
select * from t1;
|
||||
|
||||
# Let us check also that setting of time_zone back to default also works
|
||||
@@ -28,12 +32,11 @@ set time_zone='Europe/Moscow';
|
||||
insert into t1 values ('20040101000000'), ('20040611093902');
|
||||
select * from t1;
|
||||
sync_slave_with_master;
|
||||
set time_zone='Europe/Moscow';
|
||||
select * from t1;
|
||||
connection master;
|
||||
# We should not see SET ONE_SHOT time_zone before second insert
|
||||
--replace_result $VERSION VERSION
|
||||
--replace_column 2 # 5 #
|
||||
show binlog events;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001
|
||||
|
||||
#
|
||||
# Now let us check how well we replicate statments reading TIMESTAMP fields
|
||||
@@ -54,10 +57,6 @@ delete from t2;
|
||||
set timestamp=1000072000;
|
||||
insert into t2 values (current_timestamp), (current_date), (current_time);
|
||||
sync_slave_with_master;
|
||||
# Values in ouput of these to queries should differ because we are in
|
||||
# in 'MET' on master and in 'Europe/Moscow on slave...
|
||||
set timestamp=1000072000;
|
||||
select current_timestamp, current_date, current_time;
|
||||
select * from t2;
|
||||
|
||||
#
|
||||
@@ -73,13 +72,24 @@ sync_slave_with_master;
|
||||
select * from t2;
|
||||
|
||||
#
|
||||
# Let us check that we are not allowing to set global time_zone with
|
||||
# Let us check that we are allowing to set global time_zone with
|
||||
# replication
|
||||
#
|
||||
connection master;
|
||||
--error 1387
|
||||
set global time_zone='MET';
|
||||
|
||||
#
|
||||
# Let us see if CONVERT_TZ(@@time_zone) replicates
|
||||
#
|
||||
delete from t2;
|
||||
set time_zone='UTC';
|
||||
insert into t2 values(convert_tz('2004-01-01 00:00:00','MET',@@time_zone));
|
||||
insert into t2 values(convert_tz('2005-01-01 00:00:00','MET','Japan'));
|
||||
select * from t2;
|
||||
sync_slave_with_master;
|
||||
select * from t2;
|
||||
|
||||
# Clean up
|
||||
connection master;
|
||||
drop table t1, t2;
|
||||
sync_slave_with_master;
|
||||
|
||||
Reference in New Issue
Block a user