mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
09ba29e539
Added basic per-thread time zone functionality (based on public domain elsie-code). Now user can select current time zone (from the list of time zones described in system tables). All NOW-like functions honor this time zone, values of TIMESTAMP type are interpreted as values in this time zone, so now our TIMESTAMP type behaves similar to Oracle's TIMESTAMP WITH LOCAL TIME ZONE (or proper PostgresSQL type). WL#1266 "CONVERT_TZ() - basic time with time zone conversion function". Fixed problems described in Bug #2336 (Different number of warnings when inserting bad datetime as string or as number). This required reworking of datetime realted warning hadling (they now generated at Field object level not in conversion functions). Optimization: Now Field class descendants use table->in_use member instead of current_thd macro.
84 lines
2.2 KiB
Text
84 lines
2.2 KiB
Text
# Test of replication of time zones.
|
|
source include/master-slave.inc;
|
|
|
|
# Some preparations
|
|
let $VERSION=`select version()`;
|
|
create table t1 (t timestamp);
|
|
create table t2 (t char(32));
|
|
|
|
#
|
|
# Let us check how well replication works when we are saving datetime
|
|
# value in TIMESTAMP field.
|
|
#
|
|
connection master;
|
|
select @@time_zone;
|
|
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;
|
|
select * from t1;
|
|
|
|
# Let us check also that setting of time_zone back to default also works
|
|
# well
|
|
connection master;
|
|
delete from t1;
|
|
set time_zone='Europe/Moscow';
|
|
insert into t1 values ('20040101000000'), ('20040611093902');
|
|
select * from t1;
|
|
sync_slave_with_master;
|
|
select * from t1;
|
|
connection master;
|
|
# We should not see SET ONE_SHOT time_zone before second insert
|
|
--replace_result $VERSION VERSION
|
|
show binlog events;
|
|
|
|
#
|
|
# Now let us check how well we replicate statments reading TIMESTAMP fields
|
|
# (We should see the same data on master and on slave but it should differ
|
|
# from originally inserted)
|
|
#
|
|
set time_zone='MET';
|
|
insert into t2 (select t from t1);
|
|
select * from t1;
|
|
sync_slave_with_master;
|
|
select * from t2;
|
|
|
|
#
|
|
# Now let us check how well we replicate various CURRENT_* functions
|
|
#
|
|
connection master;
|
|
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;
|
|
|
|
#
|
|
# At last let us check replication of FROM_UNIXTIME/UNIX_TIMESTAMP functions.
|
|
#
|
|
connection master;
|
|
delete from t2;
|
|
insert into t2 values (from_unixtime(1000000000)),
|
|
(unix_timestamp('2001-09-09 03:46:40'));
|
|
select * from t2;
|
|
sync_slave_with_master;
|
|
# We should get same result on slave as on master
|
|
select * from t2;
|
|
|
|
#
|
|
# Let us check that we are not allowing to set global time_zone with
|
|
# replication
|
|
#
|
|
connection master;
|
|
--error 1105
|
|
set global time_zone='MET';
|
|
|
|
# Clean up
|
|
drop table t1, t2;
|
|
sync_slave_with_master;
|