From d85c9dce1b30b5eda8cb11f669c6c7f27bb5778d Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Thu, 13 Oct 2016 13:13:51 +0200 Subject: [PATCH] added/fixed tests --- localtests/datetime-to-timestamp/create.sql | 31 +++++++++++++++++ localtests/datetime-to-timestamp/extra_args | 1 + localtests/datetime/create.sql | 37 +++++++++++++++++++++ localtests/timestamp-datetime/create.sql | 33 ++++++++++++++++++ localtests/timestamp-to-datetime/create.sql | 31 +++++++++++++++++ localtests/timestamp-to-datetime/extra_args | 1 + localtests/timestamp/create.sql | 37 +++++++++++++++++++++ localtests/tz-datetime-ts/create.sql | 12 +++---- 8 files changed, 177 insertions(+), 6 deletions(-) create mode 100644 localtests/datetime-to-timestamp/create.sql create mode 100644 localtests/datetime-to-timestamp/extra_args create mode 100644 localtests/datetime/create.sql create mode 100644 localtests/timestamp-datetime/create.sql create mode 100644 localtests/timestamp-to-datetime/create.sql create mode 100644 localtests/timestamp-to-datetime/extra_args create mode 100644 localtests/timestamp/create.sql diff --git a/localtests/datetime-to-timestamp/create.sql b/localtests/datetime-to-timestamp/create.sql new file mode 100644 index 0000000..bc571ca --- /dev/null +++ b/localtests/datetime-to-timestamp/create.sql @@ -0,0 +1,31 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + i int not null, + ts0 timestamp default current_timestamp, + ts1 timestamp, + dt2 datetime, + t datetime, + updated tinyint unsigned default 0, + primary key(id), + key i_idx(i) +) auto_increment=1; + +drop event if exists gh_ost_test; +delimiter ;; +create event gh_ost_test + on schedule every 1 second + starts current_timestamp + ends current_timestamp + interval 60 second + on completion not preserve + enable + do +begin + insert into gh_ost_test values (null, 7, null, now(), now(), '2010-10-20 10:20:30', 0); + + insert into gh_ost_test values (null, 11, null, now(), now(), '2010-10-20 10:20:30', 0); + update gh_ost_test set dt2=now() + interval 1 minute, updated = 1 where i = 11 order by id desc limit 1; + + insert into gh_ost_test values (null, 13, null, now(), now(), '2010-10-20 10:20:30', 0); + update gh_ost_test set t=t + interval 1 minute, updated = 1 where i = 13 order by id desc limit 1; +end ;; diff --git a/localtests/datetime-to-timestamp/extra_args b/localtests/datetime-to-timestamp/extra_args new file mode 100644 index 0000000..6b3f977 --- /dev/null +++ b/localtests/datetime-to-timestamp/extra_args @@ -0,0 +1 @@ +--alter="change column t t timestamp not null" diff --git a/localtests/datetime/create.sql b/localtests/datetime/create.sql new file mode 100644 index 0000000..def50fb --- /dev/null +++ b/localtests/datetime/create.sql @@ -0,0 +1,37 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + i int not null, + dt0 datetime default current_timestamp, + dt1 datetime, + dt2 datetime, + updated tinyint unsigned default 0, + primary key(id), + key i_idx(i) +) auto_increment=1; + +drop event if exists gh_ost_test; +delimiter ;; +create event gh_ost_test + on schedule every 1 second + starts current_timestamp + ends current_timestamp + interval 60 second + on completion not preserve + enable + do +begin + insert into gh_ost_test values (null, 11, null, now(), now(), 0); + update gh_ost_test set dt2=now() + interval 1 minute, updated = 1 where i = 11 order by id desc limit 1; + + insert into gh_ost_test values (null, 13, null, now(), now(), 0); + update gh_ost_test set dt2=now() + interval 1 minute, updated = 1 where i = 13 order by id desc limit 1; + + insert into gh_ost_test values (null, 17, null, now(), now(), 0); + update gh_ost_test set dt2=now() + interval 1 minute, updated = 1 where i = 17 order by id desc limit 1; + + insert into gh_ost_test values (null, 19, null, now(), now(), 0); + update gh_ost_test set dt2=now() + interval 1 minute, updated = 1 where i = 19 order by id desc limit 1; + + insert into gh_ost_test values (null, 23, null, now(), now(), 0); + update gh_ost_test set dt2=now() + interval 1 minute, updated = 1 where i = 23 order by id desc limit 1; +end ;; diff --git a/localtests/timestamp-datetime/create.sql b/localtests/timestamp-datetime/create.sql new file mode 100644 index 0000000..a021dbe --- /dev/null +++ b/localtests/timestamp-datetime/create.sql @@ -0,0 +1,33 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + i int not null, + ts timestamp default current_timestamp, + dt datetime, + ts2ts timestamp null, + ts2dt datetime null, + dt2ts timestamp null, + dt2dt datetime null, + updated tinyint unsigned default 0, + primary key(id) +) auto_increment=1; + +drop event if exists gh_ost_test; +delimiter ;; +create event gh_ost_test + on schedule every 1 second + starts current_timestamp + ends current_timestamp + interval 60 second + on completion not preserve + enable + do +begin + insert into gh_ost_test values (null, 11, now(), now(),null, null, null, null, 0); + update gh_ost_test set ts2ts=ts, ts2dt=ts, dt2ts=dt, dt2dt=dt where i = 11 order by id desc limit 1; + + insert into gh_ost_test values (null, 13, null, now(), now(), 0); + update gh_ost_test set ts2ts=ts, ts2dt=ts, dt2ts=dt, dt2dt=dt where i = 13 order by id desc limit 1; + + insert into gh_ost_test values (null, 17, null, '2016-07-06 10:20:30', '2016-07-06 10:20:30', 0); + update gh_ost_test set ts2ts=ts, ts2dt=ts, dt2ts=dt, dt2dt=dt where i = 17 order by id desc limit 1; +end ;; diff --git a/localtests/timestamp-to-datetime/create.sql b/localtests/timestamp-to-datetime/create.sql new file mode 100644 index 0000000..10c83d6 --- /dev/null +++ b/localtests/timestamp-to-datetime/create.sql @@ -0,0 +1,31 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + i int not null, + ts0 timestamp default current_timestamp, + ts1 timestamp, + dt2 datetime, + t datetime, + updated tinyint unsigned default 0, + primary key(id), + key i_idx(i) +) auto_increment=1; + +drop event if exists gh_ost_test; +delimiter ;; +create event gh_ost_test + on schedule every 1 second + starts current_timestamp + ends current_timestamp + interval 60 second + on completion not preserve + enable + do +begin + insert into gh_ost_test values (null, 7, null, now(), now(), '2010-10-20 10:20:30', 0); + + insert into gh_ost_test values (null, 11, null, now(), now(), '2010-10-20 10:20:30', 0); + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 11 order by id desc limit 1; + + insert into gh_ost_test values (null, 13, null, now(), now(), '2010-10-20 10:20:30', 0); + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 13 order by id desc limit 1; +end ;; diff --git a/localtests/timestamp-to-datetime/extra_args b/localtests/timestamp-to-datetime/extra_args new file mode 100644 index 0000000..0b949f0 --- /dev/null +++ b/localtests/timestamp-to-datetime/extra_args @@ -0,0 +1 @@ +--alter="change column t t datetime not null" diff --git a/localtests/timestamp/create.sql b/localtests/timestamp/create.sql new file mode 100644 index 0000000..2377ebf --- /dev/null +++ b/localtests/timestamp/create.sql @@ -0,0 +1,37 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + i int not null, + ts0 timestamp default current_timestamp, + ts1 timestamp, + ts2 timestamp, + updated tinyint unsigned default 0, + primary key(id), + key i_idx(i) +) auto_increment=1; + +drop event if exists gh_ost_test; +delimiter ;; +create event gh_ost_test + on schedule every 1 second + starts current_timestamp + ends current_timestamp + interval 60 second + on completion not preserve + enable + do +begin + insert into gh_ost_test values (null, 11, null, now(), now(), 0); + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 11 order by id desc limit 1; + + insert into gh_ost_test values (null, 13, null, now(), now(), 0); + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 13 order by id desc limit 1; + + insert into gh_ost_test values (null, 17, null, now(), now(), 0); + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 17 order by id desc limit 1; + + insert into gh_ost_test values (null, 19, null, now(), now(), 0); + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 19 order by id desc limit 1; + + insert into gh_ost_test values (null, 23, null, now(), now(), 0); + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 23 order by id desc limit 1; +end ;; diff --git a/localtests/tz-datetime-ts/create.sql b/localtests/tz-datetime-ts/create.sql index 6d2ca2a..510a065 100644 --- a/localtests/tz-datetime-ts/create.sql +++ b/localtests/tz-datetime-ts/create.sql @@ -4,7 +4,7 @@ create table gh_ost_test ( i int not null, ts0 timestamp default current_timestamp, ts1 timestamp, - ts2 datetime, + dt2 datetime, t datetime, updated tinyint unsigned default 0, primary key(id), @@ -24,21 +24,21 @@ begin insert into gh_ost_test values (null, 7, null, now(), now(), '2010-10-20 10:20:30', 0); insert into gh_ost_test values (null, 11, null, now(), now(), '2010-10-20 10:20:30', 0); - update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 11 order by id desc limit 1; + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 11 order by id desc limit 1; set session time_zone='system'; insert into gh_ost_test values (null, 13, null, now(), now(), '2010-10-20 10:20:30', 0); - update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 13 order by id desc limit 1; + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 13 order by id desc limit 1; set session time_zone='+00:00'; insert into gh_ost_test values (null, 17, null, now(), now(), '2010-10-20 10:20:30', 0); - update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 17 order by id desc limit 1; + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 17 order by id desc limit 1; set session time_zone='-03:00'; insert into gh_ost_test values (null, 19, null, now(), now(), '2010-10-20 10:20:30', 0); - update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 19 order by id desc limit 1; + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 19 order by id desc limit 1; set session time_zone='+05:00'; insert into gh_ost_test values (null, 23, null, now(), now(), '2010-10-20 10:20:30', 0); - update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 23 order by id desc limit 1; + update gh_ost_test set ts2=now() + interval 1 minute, updated = 1 where i = 23 order by id desc limit 1; end ;;