| 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 |
source include/master-slave.inc; |
| 17 |
|
| 18 |
--disable_query_log |
| 19 |
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); |
| 20 |
--enable_query_log |
| 21 |
|
| 22 |
--disable_ps_protocol |
| 23 |
|
| 24 |
# Save original timezone |
| 25 |
set @my_time_zone= @@global.time_zone; |
| 26 |
|
| 27 |
# Some preparations |
| 28 |
let $VERSION=`select version()`; |
| 29 |
set timestamp=100000000; # for fixed output of mysqlbinlog |
| 30 |
create table t1 (t timestamp, n int not null auto_increment, PRIMARY KEY(n)); |
| 31 |
create table t2 (t char(32), n int not null auto_increment, PRIMARY KEY(n)); |
| 32 |
|
| 33 |
connection slave; |
| 34 |
select @@time_zone; |
| 35 |
#set time_zone='UTC'; |
| 36 |
#select @@time_zone; |
| 37 |
# |
| 38 |
# Let us check how well replication works when we are saving datetime |
| 39 |
# value in TIMESTAMP field. |
| 40 |
# |
| 41 |
connection master; |
| 42 |
select @@time_zone; |
| 43 |
#set time_zone='UTC'; |
| 44 |
#select @@time_zone; |
| 45 |
insert into t1 values ('20050101000000', NULL), ('20050611093902',NULL); |
| 46 |
insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL); |
| 47 |
SELECT * FROM t1 ORDER BY n; |
| 48 |
sync_slave_with_master; |
| 49 |
#set time_zone='UTC'; |
| 50 |
SELECT * FROM t1 ORDER BY n; |
| 51 |
|
| 52 |
# Let us check also that setting of time_zone back to default also works |
| 53 |
# well |
| 54 |
connection master; |
| 55 |
delete from t1; |
| 56 |
set time_zone='Europe/Moscow'; |
| 57 |
insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL); |
| 58 |
SELECT * FROM t1 ORDER BY n; |
| 59 |
sync_slave_with_master; |
| 60 |
set time_zone='Europe/Moscow'; |
| 61 |
SELECT * FROM t1 ORDER BY n; |
| 62 |
connection master; |
| 63 |
# Change Author: JBM |
| 64 |
# Change Date: 2005-12-22 |
| 65 |
# Change: Comment out the exec of the binlog so test works for both SBR and RBR |
| 66 |
#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 67 |
#--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 |
| 68 |
|
| 69 |
# Let us check with LOAD DATA INFILE |
| 70 |
# (we do it after mysqlbinlog because the temp files names are not constant) |
| 71 |
connection master; |
| 72 |
delete from t1; |
| 73 |
set time_zone='UTC'; |
| 74 |
load data infile '../../std_data/rpl_timezone2.dat' ignore into table t1; |
| 75 |
SELECT * FROM t1 ORDER BY n; |
| 76 |
sync_slave_with_master; |
| 77 |
set time_zone='UTC'; |
| 78 |
SELECT * FROM t1 ORDER BY n; |
| 79 |
set time_zone='Europe/Moscow'; |
| 80 |
|
| 81 |
# Put back values of before the LOAD |
| 82 |
connection master; |
| 83 |
set time_zone='Europe/Moscow'; |
| 84 |
delete from t1; |
| 85 |
insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL); |
| 86 |
|
| 87 |
# |
| 88 |
# Now let us check how well we replicate statments reading TIMESTAMP fields |
| 89 |
# (We should see the same data on master and on slave but it should differ |
| 90 |
# from originally inserted) |
| 91 |
# |
| 92 |
set time_zone='MET'; |
| 93 |
--disable_warnings ONCE |
| 94 |
insert into t2 (select * from t1); |
| 95 |
SELECT * FROM t1 ORDER BY n; |
| 96 |
sync_slave_with_master; |
| 97 |
SELECT * FROM t2 ORDER BY n; |
| 98 |
|
| 99 |
# |
| 100 |
# Now let us check how well we replicate various CURRENT_* functions |
| 101 |
# |
| 102 |
connection master; |
| 103 |
delete from t2; |
| 104 |
set timestamp=1000072000; |
| 105 |
insert into t2 values (current_timestamp,NULL), (current_date,NULL), (current_time,NULL); |
| 106 |
sync_slave_with_master; |
| 107 |
SELECT * FROM t2 ORDER BY n; |
| 108 |
|
| 109 |
# |
| 110 |
# At last let us check replication of FROM_UNIXTIME/UNIX_TIMESTAMP functions. |
| 111 |
# |
| 112 |
connection master; |
| 113 |
delete from t2; |
| 114 |
insert into t2 values (from_unixtime(1000000000),NULL), |
| 115 |
(unix_timestamp('2001-09-09 03:46:40'),NULL); |
| 116 |
SELECT * FROM t2 ORDER BY n; |
| 117 |
sync_slave_with_master; |
| 118 |
# We should get same result on slave as on master |
| 119 |
SELECT * FROM t2 ORDER BY n; |
| 120 |
|
| 121 |
# |
| 122 |
# Let us check that we are allowing to set global time_zone with |
| 123 |
# replication |
| 124 |
# |
| 125 |
connection master; |
| 126 |
set global time_zone='MET'; |
| 127 |
|
| 128 |
# |
| 129 |
# Let us see if CONVERT_TZ(@@time_zone) replicates |
| 130 |
# |
| 131 |
delete from t2; |
| 132 |
set time_zone='UTC'; |
| 133 |
insert into t2 values(convert_tz('2004-01-01 00:00:00','MET',@@time_zone),NULL); |
| 134 |
insert into t2 values(convert_tz('2005-01-01 00:00:00','MET','Japan'),NULL); |
| 135 |
SELECT * FROM t2 ORDER BY n; |
| 136 |
sync_slave_with_master; |
| 137 |
SELECT * FROM t2 ORDER BY n; |
| 138 |
|
| 139 |
# Clean up |
| 140 |
connection master; |
| 141 |
drop table t1, t2; |
| 142 |
sync_slave_with_master; |
| 143 |
|
| 144 |
|
| 145 |
# Restore original timezone |
| 146 |
connection master; |
| 147 |
set global time_zone= @my_time_zone; |
| 148 |
|
| 149 |
--echo End of 4.1 tests |
| 150 |
|
| 151 |
# |
| 152 |
# Bug #29536: timestamp inconsistent in replication around 1970 |
| 153 |
# |
| 154 |
connection master; |
| 155 |
|
| 156 |
CREATE TABLE t1 (a INT, b TIMESTAMP); |
| 157 |
INSERT INTO t1 VALUES (1, NOW()); |
| 158 |
|
| 159 |
SET @@session.time_zone='Japan'; |
| 160 |
--disable_warnings |
| 161 |
UPDATE IGNORE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1; |
| 162 |
--enable_warnings |
| 163 |
SELECT * FROM t1 ORDER BY a; |
| 164 |
|
| 165 |
sync_slave_with_master; |
| 166 |
SET @@session.time_zone='Japan'; |
| 167 |
# must procdure the same result as the SELECT on the master |
| 168 |
SELECT * FROM t1 ORDER BY a; |
| 169 |
|
| 170 |
SET @@session.time_zone = default; |
| 171 |
connection master; |
| 172 |
DROP TABLE t1; |
| 173 |
SET @@session.time_zone = default; |
| 174 |
--sync_slave_with_master |
| 175 |
--source include/stop_slave.inc |
| 176 |
|
| 177 |
# Bug#41719 delayed INSERT into timestamp col needs set time_zone for concurrent binlogging |
| 178 |
# To test that time_zone is correctly binloging for 'insert delayed' statement |
| 179 |
# Insert 2 values into timestamp col with different time_zone. Check result. |
| 180 |
|
| 181 |
--connection master |
| 182 |
reset master; |
| 183 |
CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL); |
| 184 |
|
| 185 |
SET @@session.time_zone='+01:00'; |
| 186 |
insert into t1 values('2008-12-23 19:39:39',1); |
| 187 |
|
| 188 |
--connection master1 |
| 189 |
SET @@session.time_zone='+02:00'; |
| 190 |
insert delayed into t1 values ('2008-12-23 19:39:39',2); |
| 191 |
|
| 192 |
# wait for the delayed insert to be executed |
| 193 |
let $wait_condition= SELECT date FROM t1 WHERE a=2; |
| 194 |
--source include/wait_condition.inc |
| 195 |
|
| 196 |
flush table t1; |
| 197 |
flush logs; |
| 198 |
select * from t1; |
| 199 |
DROP TABLE t1; |
| 200 |
|
| 201 |
let $MYSQLD_DATADIR= `select @@datadir;`; |
| 202 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 | $MYSQL |
| 203 |
--connection master1 |
| 204 |
select * from t1 order by a; |
| 205 |
DROP TABLE t1; |
| 206 |
SET @@session.time_zone = default; |
| 207 |
|
| 208 |
--let $rpl_only_running_threads= 1 |
| 209 |
--source include/rpl_end.inc |
| 210 |
|
| 211 |
--echo End of 5.0 tests |