1
#######################################
3
# Change Date: 2006-01-17
4
# Change: Added order by
5
#######################################
6
# Test of replication of time zones.
7
######################################
8
# There is currently some bug possibly in prepared statements (this
9
# test fails with --ps-protocol): sys_var_thd_time_zone::value_ptr()
10
# is called only at prepare time, not at execution time. So,
11
# thd->time_zone_used is not equal to 1 (it is back to 0, because of
12
# reset_thd_for_next_command called at execution time), so the
13
# timezone used in CONVERT_TZ is not binlogged. To debug (by Guilhem
14
# and possibly Konstantin).
18
source include/master-slave.inc;
20
# Save original timezone
21
set @my_time_zone= @@global.time_zone;
24
let $VERSION=`select version()`;
25
set timestamp=100000000; # for fixed output of mysqlbinlog
26
create table t1 (t timestamp, n int not null auto_increment, PRIMARY KEY(n));
27
create table t2 (t char(32), n int not null auto_increment, PRIMARY KEY(n));
34
# Let us check how well replication works when we are saving datetime
35
# value in TIMESTAMP field.
41
insert into t1 values ('20050101000000', NULL), ('20050611093902',NULL);
42
insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL);
43
SELECT * FROM t1 ORDER BY n;
44
sync_slave_with_master;
46
SELECT * FROM t1 ORDER BY n;
48
# Let us check also that setting of time_zone back to default also works
52
set time_zone='Europe/Moscow';
53
insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL);
54
SELECT * FROM t1 ORDER BY n;
55
sync_slave_with_master;
56
set time_zone='Europe/Moscow';
57
SELECT * FROM t1 ORDER BY n;
60
# Change Date: 2005-12-22
61
# Change: Comment out the exec of the binlog so test works for both SBR and RBR
62
#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
63
#--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001
65
# Let us check with LOAD DATA INFILE
66
# (we do it after mysqlbinlog because the temp files names are not constant)
70
load data infile '../std_data_ln/rpl_timezone2.dat' into table t1;
71
SELECT * FROM t1 ORDER BY n;
72
sync_slave_with_master;
74
SELECT * FROM t1 ORDER BY n;
75
set time_zone='Europe/Moscow';
77
# Put back values of before the LOAD
79
set time_zone='Europe/Moscow';
81
insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL);
84
# Now let us check how well we replicate statments reading TIMESTAMP fields
85
# (We should see the same data on master and on slave but it should differ
86
# from originally inserted)
89
insert into t2 (select * from t1);
90
SELECT * FROM t1 ORDER BY n;
91
sync_slave_with_master;
92
SELECT * FROM t2 ORDER BY n;
95
# Now let us check how well we replicate various CURRENT_* functions
99
set timestamp=1000072000;
100
insert into t2 values (current_timestamp,NULL), (current_date,NULL), (current_time,NULL);
101
sync_slave_with_master;
102
SELECT * FROM t2 ORDER BY n;
105
# At last let us check replication of FROM_UNIXTIME/UNIX_TIMESTAMP functions.
109
insert into t2 values (from_unixtime(1000000000),NULL),
110
(unix_timestamp('2001-09-09 03:46:40'),NULL);
111
SELECT * FROM t2 ORDER BY n;
112
sync_slave_with_master;
113
# We should get same result on slave as on master
114
SELECT * FROM t2 ORDER BY n;
117
# Let us check that we are allowing to set global time_zone with
121
set global time_zone='MET';
124
# Let us see if CONVERT_TZ(@@time_zone) replicates
128
insert into t2 values(convert_tz('2004-01-01 00:00:00','MET',@@time_zone),NULL);
129
insert into t2 values(convert_tz('2005-01-01 00:00:00','MET','Japan'),NULL);
130
SELECT * FROM t2 ORDER BY n;
131
sync_slave_with_master;
132
SELECT * FROM t2 ORDER BY n;
137
sync_slave_with_master;
140
# Restore original timezone
142
set global time_zone= @my_time_zone;
144
--echo End of 4.1 tests
147
# Bug #29536: timestamp inconsistent in replication around 1970
151
CREATE TABLE t1 (a INT, b TIMESTAMP);
152
INSERT INTO t1 VALUES (1, NOW());
154
SET @@session.time_zone='Japan';
155
UPDATE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1;
156
SELECT * FROM t1 ORDER BY a;
158
sync_slave_with_master;
159
SET @@session.time_zone='Japan';
160
# must procdure the same result as the SELECT on the master
161
SELECT * FROM t1 ORDER BY a;
163
SET @@session.time_zone = default;
166
SET @@session.time_zone = default;
169
--echo End of 5.0 tests