~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_timezone.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#######################################
 
2
# Change Author: JBM
 
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).
 
15
 
 
16
--disable_ps_protocol
 
17
 
 
18
source include/master-slave.inc;
 
19
 
 
20
# Save original timezone
 
21
set @my_time_zone= @@global.time_zone;
 
22
 
 
23
# Some preparations
 
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));
 
28
 
 
29
connection slave;
 
30
select @@time_zone;
 
31
#set time_zone='UTC';
 
32
#select @@time_zone;
 
33
#
 
34
# Let us check how well replication works when we are saving datetime
 
35
# value in TIMESTAMP field.
 
36
#
 
37
connection master;
 
38
select @@time_zone;
 
39
#set time_zone='UTC';
 
40
#select @@time_zone;
 
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;
 
45
#set time_zone='UTC';
 
46
SELECT * FROM t1 ORDER BY n;
 
47
 
 
48
# Let us check also that setting of time_zone back to default also works
 
49
# well
 
50
connection master;
 
51
delete from t1;
 
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;
 
58
connection master;
 
59
# Change Author: JBM
 
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
 
64
 
 
65
# Let us check with LOAD DATA INFILE
 
66
# (we do it after mysqlbinlog because the temp files names are not constant)
 
67
connection master;
 
68
delete from t1;
 
69
set time_zone='UTC';
 
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;
 
73
set time_zone='UTC';
 
74
SELECT * FROM t1 ORDER BY n;
 
75
set time_zone='Europe/Moscow';
 
76
 
 
77
# Put back values of before the LOAD
 
78
connection master;
 
79
set time_zone='Europe/Moscow';
 
80
delete from t1;
 
81
insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL);
 
82
 
 
83
#
 
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)
 
87
#
 
88
set time_zone='MET';
 
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;
 
93
 
 
94
#
 
95
# Now let us check how well we replicate various CURRENT_* functions
 
96
#
 
97
connection master;
 
98
delete from t2;
 
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;
 
103
 
 
104
#
 
105
# At last let us check replication of FROM_UNIXTIME/UNIX_TIMESTAMP functions.
 
106
#
 
107
connection master;
 
108
delete from t2;
 
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;
 
115
 
 
116
#
 
117
# Let us check that we are allowing to set global time_zone with
 
118
# replication
 
119
#
 
120
connection master;
 
121
set global time_zone='MET';
 
122
 
 
123
#
 
124
# Let us see if CONVERT_TZ(@@time_zone) replicates
 
125
#
 
126
delete from t2;
 
127
set time_zone='UTC';
 
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;
 
133
 
 
134
# Clean up
 
135
connection master;
 
136
drop table t1, t2;
 
137
sync_slave_with_master;
 
138
 
 
139
 
 
140
# Restore original timezone
 
141
connection master;
 
142
set global time_zone= @my_time_zone;
 
143
 
 
144
--echo End of 4.1 tests
 
145
 
 
146
#
 
147
# Bug #29536: timestamp inconsistent in replication around 1970
 
148
#
 
149
connection master;
 
150
 
 
151
CREATE TABLE t1 (a INT, b TIMESTAMP);
 
152
INSERT INTO t1 VALUES (1, NOW());
 
153
 
 
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;
 
157
 
 
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;
 
162
 
 
163
SET @@session.time_zone = default;
 
164
connection master;
 
165
DROP TABLE t1;
 
166
SET @@session.time_zone = default;
 
167
 
 
168
 
 
169
--echo End of 5.0 tests