diff options
Diffstat (limited to 'mysql-test/t/type_timestamp.test')
-rw-r--r-- | mysql-test/t/type_timestamp.test | 92 |
1 files changed, 80 insertions, 12 deletions
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index 602f6f089c2..cd4ba18455b 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -67,17 +67,6 @@ INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000); SELECT * FROM t1; drop table t1; -create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6), - t8 timestamp(8), t10 timestamp(10), t12 timestamp(12), - t14 timestamp(14)); -insert t1 values (0,0,0,0,0,0,0), -("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59", -"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59", -"1997-12-31 23:47:59"); -select * from t1; -select * from t1; -drop table t1; - # # Let us check if we properly treat wrong datetimes and produce proper warnings # (for both strings and numbers) @@ -298,7 +287,7 @@ drop table t1; # mode regardless of whether a display width is given. # set sql_mode='maxdb'; -create table t1 (a timestamp, b timestamp(19)); +create table t1 (a timestamp, b timestamp); show create table t1; # restore default mode set sql_mode=''; @@ -373,4 +362,83 @@ SELECT a FROM t1 WHERE a >= '20000101000000'; DROP TABLE t1; +--echo # +--echo # Bug#50774: failed to get the correct resultset when timestamp values +--echo # are appended with .0 +--echo # +CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) ); + +INSERT INTO t1 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t1 VALUES( '2010-02-01 09:31:04' ); + +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a; +SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0'; +SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a; + +--replace_column 1 x 2 x 3 x 5 x 6 x 7 x 8 x 9 x 10 x +EXPLAIN +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; +SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0'; + +CREATE TABLE t2 ( a TIMESTAMP, KEY ( a DESC ) ); + +INSERT INTO t2 VALUES( '2010-02-01 09:31:01' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:02' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:03' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:04' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:05' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:06' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:07' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:08' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:09' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:10' ); +INSERT INTO t2 VALUES( '2010-02-01 09:31:11' ); + +--echo # The bug would cause the range optimizer's comparison to use an open +--echo # interval here. This reveals itself only in the number of reads +--echo # performed. +FLUSH STATUS; +--replace_column 1 x 2 x 3 x 5 x 6 x 7 x 8 x 9 x 10 x +EXPLAIN +SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0'; +SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0'; +SHOW STATUS LIKE 'Handler_read_next'; + +DROP TABLE t1, t2; + --echo End of 5.1 tests + +--echo +--echo Bug#50888 valgrind warnings in Field_timestamp::val_str +--echo + +SET TIMESTAMP=0; +CREATE TABLE t1(a timestamp); +INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02'); +FLUSH TABLES t1; +SELECT MAX(a) FROM t1; +SELECT a FROM t1; +DROP TABLE t1; + +--echo End of Bug#50888 + +--echo # +--echo # Bug59330: Incorrect result when comparing an aggregate +--echo # function with TIMESTAMP +--echo # +CREATE TABLE t1 (dt DATETIME, ts TIMESTAMP); +INSERT INTO t1 VALUES('2011-01-06 12:34:30', '2011-01-06 12:34:30'); +SELECT MAX(dt), MAX(ts) FROM t1; +SELECT MAX(ts) < '2010-01-01 00:00:00' FROM t1; +SELECT MAX(dt) < '2010-01-01 00:00:00' FROM t1; +SELECT MAX(ts) > '2010-01-01 00:00:00' FROM t1; +SELECT MAX(dt) > '2010-01-01 00:00:00' FROM t1; +SELECT MAX(ts) = '2011-01-06 12:34:30' FROM t1; +SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1; +DROP TABLE t1; + +--echo End of 5.5 tests + |