mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +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:
@ -4,21 +4,31 @@ reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
set timestamp=100000000;
|
||||
create table t1 (t timestamp);
|
||||
create table t2 (t char(32));
|
||||
select @@time_zone;
|
||||
@@time_zone
|
||||
Japan
|
||||
select @@time_zone;
|
||||
@@time_zone
|
||||
Europe/Moscow
|
||||
insert into t1 values ('20050101000000'), ('20050611093902');
|
||||
set time_zone='UTC';
|
||||
insert into t1 values ('20040101000000'), ('20040611093902');
|
||||
select * from t1;
|
||||
t
|
||||
2004-12-31 21:00:00
|
||||
2005-06-11 05:39:02
|
||||
2004-01-01 00:00:00
|
||||
2004-06-11 09:39:02
|
||||
set time_zone='UTC';
|
||||
select * from t1;
|
||||
t
|
||||
2004-01-01 03:00:00
|
||||
2004-06-11 13:39:02
|
||||
2004-12-31 21:00:00
|
||||
2005-06-11 05:39:02
|
||||
2004-01-01 00:00:00
|
||||
2004-06-11 09:39:02
|
||||
delete from t1;
|
||||
set time_zone='Europe/Moscow';
|
||||
insert into t1 values ('20040101000000'), ('20040611093902');
|
||||
@ -26,19 +36,35 @@ select * from t1;
|
||||
t
|
||||
2004-01-01 00:00:00
|
||||
2004-06-11 09:39:02
|
||||
set time_zone='Europe/Moscow';
|
||||
select * from t1;
|
||||
t
|
||||
2004-01-01 00:00:00
|
||||
2004-06-11 09:39:02
|
||||
show binlog events;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4
|
||||
master-bin.000001 # Query 1 # use `test`; create table t1 (t timestamp)
|
||||
master-bin.000001 # Query 1 # use `test`; create table t2 (t char(32))
|
||||
master-bin.000001 # Query 1 # use `test`; SET ONE_SHOT TIME_ZONE='UTC'
|
||||
master-bin.000001 # Query 1 # use `test`; insert into t1 values ('20040101000000'), ('20040611093902')
|
||||
master-bin.000001 # Query 1 # use `test`; delete from t1
|
||||
master-bin.000001 # Query 1 # use `test`; insert into t1 values ('20040101000000'), ('20040611093902')
|
||||
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
|
||||
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
|
||||
ROLLBACK;
|
||||
use test;
|
||||
SET TIMESTAMP=100000000;
|
||||
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
|
||||
SET @@session.sql_mode=0;
|
||||
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
|
||||
create table t1 (t timestamp);
|
||||
SET TIMESTAMP=100000000;
|
||||
create table t2 (t char(32));
|
||||
SET TIMESTAMP=100000000;
|
||||
SET @@session.time_zone='Europe/Moscow';
|
||||
insert into t1 values ('20050101000000'), ('20050611093902');
|
||||
SET TIMESTAMP=100000000;
|
||||
SET @@session.time_zone='UTC';
|
||||
insert into t1 values ('20040101000000'), ('20040611093902');
|
||||
SET TIMESTAMP=100000000;
|
||||
delete from t1;
|
||||
SET TIMESTAMP=100000000;
|
||||
SET @@session.time_zone='Europe/Moscow';
|
||||
insert into t1 values ('20040101000000'), ('20040611093902');
|
||||
ROLLBACK;
|
||||
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
|
||||
set time_zone='MET';
|
||||
insert into t2 (select t from t1);
|
||||
select * from t1;
|
||||
@ -52,10 +78,6 @@ t
|
||||
delete from t2;
|
||||
set timestamp=1000072000;
|
||||
insert into t2 values (current_timestamp), (current_date), (current_time);
|
||||
set timestamp=1000072000;
|
||||
select current_timestamp, current_date, current_time;
|
||||
current_timestamp current_date current_time
|
||||
2001-09-10 01:46:40 2001-09-10 01:46:40
|
||||
select * from t2;
|
||||
t
|
||||
2001-09-09 23:46:40
|
||||
@ -73,5 +95,16 @@ t
|
||||
2001-09-09 03:46:40
|
||||
1000000000
|
||||
set global time_zone='MET';
|
||||
ERROR HY000: Binary logging and replication forbid changing the global server time zone
|
||||
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;
|
||||
t
|
||||
2003-12-31 23:00:00
|
||||
2005-01-01 08:00:00
|
||||
select * from t2;
|
||||
t
|
||||
2003-12-31 23:00:00
|
||||
2005-01-01 08:00:00
|
||||
drop table t1, t2;
|
||||
|
Reference in New Issue
Block a user