diff options
author | Mattias Jonsson <mattias.jonsson@oracle.com> | 2011-06-13 11:57:47 +0200 |
---|---|---|
committer | Mattias Jonsson <mattias.jonsson@oracle.com> | 2011-06-13 11:57:47 +0200 |
commit | 775770145c904f48949c5c0e95d594d8f222eb32 (patch) | |
tree | e9f7dcaea07cffd1d7bace5e923414f1430c3d19 /mysql-test | |
parent | e827b51fa0a8e7aefd7d38f19725452b15803dfe (diff) | |
parent | d53906e3872016cb06f48a80557fb8edda59b691 (diff) | |
download | mariadb-git-775770145c904f48949c5c0e95d594d8f222eb32.tar.gz |
merge
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/partition.result | 18 | ||||
-rw-r--r-- | mysql-test/r/partition_datatype.result | 1000 | ||||
-rw-r--r-- | mysql-test/t/partition.test | 6 | ||||
-rw-r--r-- | mysql-test/t/partition_datatype.test | 310 |
4 files changed, 1334 insertions, 0 deletions
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index af937a1496d..0febdbc38d0 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -218,6 +218,15 @@ a b 2007-07-30 17:35:48 p1 2009-07-14 17:35:55 pmax 2009-09-21 17:31:42 pmax +SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01'; +a b +2007-07-30 17:35:48 p1 +EXPLAIN PARTITIONS SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01'; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t1 p1 system PRIMARY NULL NULL NULL 1 +EXPLAIN PARTITIONS SELECT * FROM t1 where a = '2007-07-30 17:35:48'; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t1 p1 system PRIMARY NULL NULL NULL 1 ALTER TABLE t1 REORGANIZE PARTITION pmax INTO ( PARTITION p3 VALUES LESS THAN (1247688000), PARTITION pmax VALUES LESS THAN MAXVALUE); @@ -226,6 +235,15 @@ a b 2007-07-30 17:35:48 p1 2009-07-14 17:35:55 pmax 2009-09-21 17:31:42 pmax +SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01'; +a b +2007-07-30 17:35:48 p1 +EXPLAIN PARTITIONS SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01'; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t1 p1 system PRIMARY NULL NULL NULL 1 +EXPLAIN PARTITIONS SELECT * FROM t1 where a = '2007-07-30 17:35:48'; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t1 p1 system PRIMARY NULL NULL NULL 1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/r/partition_datatype.result b/mysql-test/r/partition_datatype.result index 47ea799f497..651d924d7e5 100644 --- a/mysql-test/r/partition_datatype.result +++ b/mysql-test/r/partition_datatype.result @@ -338,3 +338,1003 @@ select hex(a) from t1 where a = 7; hex(a) 7 drop table t1; +# +# Bug#28928: UNIX_TIMESTAMP() should be considered unary monotonic +# by partition pruning +SET @old_time_zone= @@session.time_zone; +SET @@session.time_zone = 'UTC'; +# Using MyISAM to get stable values on TABLE_ROWS in I_S.PARTITIONS +CREATE TABLE t1 +(a TIMESTAMP NULL, +tz varchar(16)) +ENGINE = MyISAM; +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 PARTITION BY RANGE (UNIX_TIMESTAMP(a)) +(PARTITION `p0` VALUES LESS THAN (0), +PARTITION `p-2000` VALUES LESS THAN (UNIX_TIMESTAMP('2000-01-01')), +PARTITION `p-2011-MSK` VALUES LESS THAN (UNIX_TIMESTAMP('2011-03-26 23:00:00')), +PARTITION `p-2011-MSD-1` VALUES LESS THAN (UNIX_TIMESTAMP('2011-10-29 22:00:00')), +PARTITION `p-2011-MSD-2` VALUES LESS THAN (UNIX_TIMESTAMP('2011-10-29 23:00:00')), +PARTITION `p-2012-MSK-1` VALUES LESS THAN (UNIX_TIMESTAMP('2011-10-30 00:00:00')), +PARTITION `p-2012-MSK-2` VALUES LESS THAN (UNIX_TIMESTAMP('2012-03-24 23:00:00')), +PARTITION `pEnd` VALUES LESS THAN (UNIX_TIMESTAMP('2038-01-19 03:14:07')), +PARTITION `pMax` VALUES LESS THAN MAXVALUE); +# Test 'odd' values +INSERT INTO t1 VALUES (NULL, 'UTC'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00', 'UTC'); +# Test invalid values +INSERT INTO t1 VALUES ('1901-01-01 00:00:00', 'UTCI'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1969-12-31 23:59:59', 'UTCI'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('2038-01-19 03:14:08', 'UTCI'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1970-01-01 00:00:00', 'UTCI'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +# Test start range +INSERT INTO t1 VALUES ('1970-01-01 00:00:01', 'UTC'); +INSERT INTO t1 VALUES ('1974-02-05 21:28:16', 'UTC'); +# Test end range +INSERT INTO t1 VALUES ('2038-01-19 03:14:06', 'UTC'); +INSERT INTO t1 VALUES ('2038-01-19 03:14:07', 'UTC'); +# Test Daylight saving shift +INSERT INTO t1 VALUES ('2011-03-26 22:59:59', 'UTC'); +INSERT INTO t1 VALUES ('2011-03-26 23:00:00', 'UTC'); +INSERT INTO t1 VALUES ('2011-03-26 23:00:01', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 21:59:59', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 22:00:00', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 22:00:01', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 22:59:59', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 23:00:00', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 23:00:01', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 23:59:59', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-30 00:00:00', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-30 00:00:01', 'UTC'); +SET @@session.time_zone = 'Europe/Moscow'; +# Test 'odd' values +INSERT INTO t1 VALUES (NULL, 'Moscow'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00', 'Moscow'); +# Test invalid values +INSERT INTO t1 VALUES ('0000-00-00 03:00:00', 'MoscowI'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t1 VALUES ('1901-01-01 00:00:00', 'MoscowI'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1969-12-31 23:59:59', 'MoscowI'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1970-01-01 02:29:29', 'MoscowI'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('2038-01-19 06:14:08', 'MoscowI'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1970-01-01 03:00:00', 'MoscowI'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +# values truncated to 03:00:00 due to daylight saving shift +INSERT INTO t1 VALUES ('2011-03-27 02:00:00', 'MoscowI'); +Warnings: +Warning 1299 Invalid TIMESTAMP value in column 'a' at row 1 +INSERT INTO t1 VALUES ('2011-03-27 02:00:01', 'MoscowI'); +Warnings: +Warning 1299 Invalid TIMESTAMP value in column 'a' at row 1 +INSERT INTO t1 VALUES ('2011-03-27 02:59:59', 'MoscowI'); +Warnings: +Warning 1299 Invalid TIMESTAMP value in column 'a' at row 1 +# Test start range +INSERT INTO t1 VALUES ('1970-01-01 03:00:01', 'Moscow'); +INSERT INTO t1 VALUES ('1974-02-05 21:28:16', 'Moscow'); +# Test end range +INSERT INTO t1 VALUES ('2038-01-19 06:14:06', 'Moscow'); +INSERT INTO t1 VALUES ('2038-01-19 06:14:07', 'Moscow'); +# Test Daylight saving shift +INSERT INTO t1 VALUES ('2011-03-27 01:59:59', 'Moscow'); +INSERT INTO t1 VALUES ('2011-03-27 03:00:00', 'Moscow'); +INSERT INTO t1 VALUES ('2011-03-27 03:00:01', 'Moscow'); +INSERT INTO t1 VALUES ('2011-10-30 01:59:59', 'Moscow'); +# All values between 02:00 and 02:59:59 will be interpretated as DST +INSERT INTO t1 VALUES ('2011-10-30 02:00:00', 'MoscowD'); +INSERT INTO t1 VALUES ('2011-10-30 02:00:01', 'MoscowD'); +INSERT INTO t1 VALUES ('2011-10-30 02:59:59', 'MoscowD'); +INSERT INTO t1 VALUES ('2011-10-30 03:00:00', 'Moscow'); +INSERT INTO t1 VALUES ('2011-10-30 03:00:01', 'Moscow'); +SET @@session.time_zone = 'UTC'; +INSERT INTO t2 SELECT * FROM t1; +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +PARTITION_NAME TABLE_ROWS +p0 2 +p-2000 16 +p-2011-MSK 2 +p-2011-MSD-1 9 +p-2011-MSD-2 6 +p-2012-MSK-1 3 +p-2012-MSK-2 4 +pEnd 2 +pMax 2 +SELECT * FROM t1 ORDER BY a, tz; +a tz +NULL Moscow +NULL UTC +0000-00-00 00:00:00 Moscow +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 UTC +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +1970-01-01 00:00:01 Moscow +1970-01-01 00:00:01 UTC +1974-02-05 18:28:16 Moscow +1974-02-05 21:28:16 UTC +2011-03-26 22:59:59 Moscow +2011-03-26 22:59:59 UTC +2011-03-26 23:00:00 Moscow +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 UTC +2011-03-26 23:00:01 Moscow +2011-03-26 23:00:01 UTC +2011-10-29 21:59:59 Moscow +2011-10-29 21:59:59 UTC +2011-10-29 22:00:00 MoscowD +2011-10-29 22:00:00 UTC +2011-10-29 22:00:01 MoscowD +2011-10-29 22:00:01 UTC +2011-10-29 22:59:59 MoscowD +2011-10-29 22:59:59 UTC +2011-10-29 23:00:00 UTC +2011-10-29 23:00:01 UTC +2011-10-29 23:59:59 UTC +2011-10-30 00:00:00 Moscow +2011-10-30 00:00:00 UTC +2011-10-30 00:00:01 Moscow +2011-10-30 00:00:01 UTC +2038-01-19 03:14:06 Moscow +2038-01-19 03:14:06 UTC +2038-01-19 03:14:07 Moscow +2038-01-19 03:14:07 UTC +SELECT * FROM t2 ORDER BY a, tz; +a tz +NULL Moscow +NULL UTC +0000-00-00 00:00:00 Moscow +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 UTC +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +1970-01-01 00:00:01 Moscow +1970-01-01 00:00:01 UTC +1974-02-05 18:28:16 Moscow +1974-02-05 21:28:16 UTC +2011-03-26 22:59:59 Moscow +2011-03-26 22:59:59 UTC +2011-03-26 23:00:00 Moscow +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 UTC +2011-03-26 23:00:01 Moscow +2011-03-26 23:00:01 UTC +2011-10-29 21:59:59 Moscow +2011-10-29 21:59:59 UTC +2011-10-29 22:00:00 MoscowD +2011-10-29 22:00:00 UTC +2011-10-29 22:00:01 MoscowD +2011-10-29 22:00:01 UTC +2011-10-29 22:59:59 MoscowD +2011-10-29 22:59:59 UTC +2011-10-29 23:00:00 UTC +2011-10-29 23:00:01 UTC +2011-10-29 23:59:59 UTC +2011-10-30 00:00:00 Moscow +2011-10-30 00:00:00 UTC +2011-10-30 00:00:01 Moscow +2011-10-30 00:00:01 UTC +2038-01-19 03:14:06 Moscow +2038-01-19 03:14:06 UTC +2038-01-19 03:14:07 Moscow +2038-01-19 03:14:07 UTC +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-26 23:00:00' ORDER BY a, tz; +a tz +2011-03-26 22:59:59 Moscow +2011-03-26 22:59:59 UTC +2011-03-26 23:00:00 Moscow +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-26 23:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSK,p-2011-MSD-1 ALL NULL NULL NULL NULL 11 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-26 22:59:59' ORDER BY a, tz; +a tz +2011-03-26 22:59:59 Moscow +2011-03-26 22:59:59 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-26 22:59:59' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSK ALL NULL NULL NULL NULL 2 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 22:59:59' and '2011-03-28 00:00:00' ORDER BY a, tz; +a tz +2011-03-26 22:59:59 Moscow +2011-03-26 22:59:59 UTC +2011-03-26 23:00:00 Moscow +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 UTC +2011-03-26 23:00:01 Moscow +2011-03-26 23:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 22:59:59' and '2011-03-28 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSK,p-2011-MSD-1 ALL NULL NULL NULL NULL 11 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 23:00:00' and '2011-03-28 00:00:00' ORDER BY a, tz; +a tz +2011-03-26 23:00:00 Moscow +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 UTC +2011-03-26 23:00:01 Moscow +2011-03-26 23:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 23:00:00' and '2011-03-28 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1 ALL NULL NULL NULL NULL 9 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 23:00:00' ORDER BY a, tz; +a tz +2011-10-29 21:59:59 Moscow +2011-10-29 21:59:59 UTC +2011-10-29 22:00:00 MoscowD +2011-10-29 22:00:00 UTC +2011-10-29 22:00:01 MoscowD +2011-10-29 22:00:01 UTC +2011-10-29 22:59:59 MoscowD +2011-10-29 22:59:59 UTC +2011-10-29 23:00:00 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 23:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1,p-2011-MSD-2,p-2012-MSK-1 ALL NULL NULL NULL NULL 18 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 22:59:59' ORDER BY a, tz; +a tz +2011-10-29 21:59:59 Moscow +2011-10-29 21:59:59 UTC +2011-10-29 22:00:00 MoscowD +2011-10-29 22:00:00 UTC +2011-10-29 22:00:01 MoscowD +2011-10-29 22:00:01 UTC +2011-10-29 22:59:59 MoscowD +2011-10-29 22:59:59 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 22:59:59' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1,p-2011-MSD-2 ALL NULL NULL NULL NULL 15 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 22:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; +a tz +2011-10-29 22:59:59 MoscowD +2011-10-29 22:59:59 UTC +2011-10-29 23:00:00 UTC +2011-10-29 23:00:01 UTC +2011-10-29 23:59:59 UTC +2011-10-30 00:00:00 Moscow +2011-10-30 00:00:00 UTC +2011-10-30 00:00:01 Moscow +2011-10-30 00:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 22:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-2,p-2012-MSK-1,p-2012-MSK-2 ALL NULL NULL NULL NULL 13 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 23:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; +a tz +2011-10-29 23:00:00 UTC +2011-10-29 23:00:01 UTC +2011-10-29 23:59:59 UTC +2011-10-30 00:00:00 Moscow +2011-10-30 00:00:00 UTC +2011-10-30 00:00:01 Moscow +2011-10-30 00:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 23:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2012-MSK-1,p-2012-MSK-2 ALL NULL NULL NULL NULL 7 Using where; Using filesort +# Test end range changes +DELETE FROM t2 WHERE a = 0; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00', 'UTC'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT COUNT(*) FROM t2; +COUNT(*) +35 +SELECT COUNT(*) FROM t2 WHERE a = 0; +COUNT(*) +1 +SELECT * FROM t2 ORDER BY a, tz LIMIT 3; +a tz +NULL Moscow +NULL UTC +0000-00-00 00:00:00 UTC +SELECT * FROM t2 ORDER BY a DESC, tz LIMIT 3; +a tz +2038-01-19 03:14:07 Moscow +2038-01-19 03:14:07 UTC +2038-01-19 03:14:06 Moscow +UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a); +Warnings: +Warning 1264 Out of range value for column 'a' at row 34 +Warning 1264 Out of range value for column 'a' at row 35 +SELECT MIN(a), MAX(a) FROM t2; +MIN(a) MAX(a) +0000-00-00 00:00:00 2038-01-19 03:14:07 +SELECT COUNT(*) FROM t2; +COUNT(*) +35 +SELECT COUNT(*) FROM t2 WHERE a = 0; +COUNT(*) +2 +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +PARTITION_NAME TABLE_ROWS +p0 3 +p-2000 6 +p-2011-MSK 0 +p-2011-MSD-1 9 +p-2011-MSD-2 6 +p-2012-MSK-1 4 +p-2012-MSK-2 5 +pEnd 0 +pMax 2 +SELECT * FROM t2 ORDER BY a, tz; +a tz +NULL Moscow +NULL UTC +NULL UTC +0000-00-00 00:00:00 Moscow +0000-00-00 00:00:00 UTC +1970-01-01 00:00:02 Moscow +1970-01-01 00:00:02 UTC +1974-02-05 18:28:17 Moscow +1974-02-05 21:28:17 UTC +2011-03-26 23:00:00 Moscow +2011-03-26 23:00:00 UTC +2011-03-26 23:00:01 Moscow +2011-03-26 23:00:01 MoscowI +2011-03-26 23:00:01 MoscowI +2011-03-26 23:00:01 MoscowI +2011-03-26 23:00:01 UTC +2011-03-26 23:00:02 Moscow +2011-03-26 23:00:02 UTC +2011-10-29 22:00:00 Moscow +2011-10-29 22:00:00 UTC +2011-10-29 22:00:01 MoscowD +2011-10-29 22:00:01 UTC +2011-10-29 22:00:02 MoscowD +2011-10-29 22:00:02 UTC +2011-10-29 23:00:00 MoscowD +2011-10-29 23:00:00 UTC +2011-10-29 23:00:01 UTC +2011-10-29 23:00:02 UTC +2011-10-30 00:00:00 UTC +2011-10-30 00:00:01 Moscow +2011-10-30 00:00:01 UTC +2011-10-30 00:00:02 Moscow +2011-10-30 00:00:02 UTC +2038-01-19 03:14:07 Moscow +2038-01-19 03:14:07 UTC +# Test start range changes +INSERT INTO t2 VALUES ('1970-01-01 00:00:00', 'UTC'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT COUNT(*) FROM t2; +COUNT(*) +36 +SELECT COUNT(*) FROM t2 WHERE a = 0; +COUNT(*) +3 +SELECT * FROM t2 ORDER BY a, tz LIMIT 3; +a tz +NULL Moscow +NULL UTC +NULL UTC +SELECT * FROM t2 ORDER BY a DESC, tz LIMIT 3; +a tz +2038-01-19 03:14:07 Moscow +2038-01-19 03:14:07 UTC +2011-10-30 00:00:02 Moscow +UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a); +SELECT MIN(a), MAX(a) FROM t2; +MIN(a) MAX(a) +1970-01-01 00:00:01 2038-01-19 03:14:06 +SELECT COUNT(*) FROM t2; +COUNT(*) +36 +SELECT COUNT(*) FROM t2 WHERE a = 0; +COUNT(*) +0 +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +PARTITION_NAME TABLE_ROWS +p0 6 +p-2000 4 +p-2011-MSK 2 +p-2011-MSD-1 9 +p-2011-MSD-2 6 +p-2012-MSK-1 3 +p-2012-MSK-2 4 +pEnd 2 +pMax 0 +SELECT * FROM t2 ORDER BY a, tz; +a tz +NULL Moscow +NULL Moscow +NULL UTC +NULL UTC +NULL UTC +NULL UTC +1970-01-01 00:00:01 Moscow +1970-01-01 00:00:01 UTC +1974-02-05 18:28:16 Moscow +1974-02-05 21:28:16 UTC +2011-03-26 22:59:59 Moscow +2011-03-26 22:59:59 UTC +2011-03-26 23:00:00 Moscow +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 MoscowI +2011-03-26 23:00:00 UTC +2011-03-26 23:00:01 Moscow +2011-03-26 23:00:01 UTC +2011-10-29 21:59:59 Moscow +2011-10-29 21:59:59 UTC +2011-10-29 22:00:00 MoscowD +2011-10-29 22:00:00 UTC +2011-10-29 22:00:01 MoscowD +2011-10-29 22:00:01 UTC +2011-10-29 22:59:59 MoscowD +2011-10-29 22:59:59 UTC +2011-10-29 23:00:00 UTC +2011-10-29 23:00:01 UTC +2011-10-29 23:59:59 UTC +2011-10-30 00:00:00 Moscow +2011-10-30 00:00:00 UTC +2011-10-30 00:00:01 Moscow +2011-10-30 00:00:01 UTC +2038-01-19 03:14:06 Moscow +2038-01-19 03:14:06 UTC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` timestamp NULL DEFAULT NULL, + `tz` varchar(16) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (UNIX_TIMESTAMP(a)) +(PARTITION p0 VALUES LESS THAN (0) ENGINE = MyISAM, + PARTITION `p-2000` VALUES LESS THAN (946684800) ENGINE = MyISAM, + PARTITION `p-2011-MSK` VALUES LESS THAN (1301180400) ENGINE = MyISAM, + PARTITION `p-2011-MSD-1` VALUES LESS THAN (1319925600) ENGINE = MyISAM, + PARTITION `p-2011-MSD-2` VALUES LESS THAN (1319929200) ENGINE = MyISAM, + PARTITION `p-2012-MSK-1` VALUES LESS THAN (1319932800) ENGINE = MyISAM, + PARTITION `p-2012-MSK-2` VALUES LESS THAN (1332630000) ENGINE = MyISAM, + PARTITION pEnd VALUES LESS THAN (2147483647) ENGINE = MyISAM, + PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ +TRUNCATE TABLE t2; +SET @@session.time_zone = 'Europe/Moscow'; +INSERT INTO t2 SELECT * FROM t1; +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +PARTITION_NAME TABLE_ROWS +p0 2 +p-2000 16 +p-2011-MSK 2 +p-2011-MSD-1 9 +p-2011-MSD-2 6 +p-2012-MSK-1 3 +p-2012-MSK-2 4 +pEnd 2 +pMax 2 +SELECT * FROM t1 ORDER BY a, tz; +a tz +NULL Moscow +NULL UTC +0000-00-00 00:00:00 Moscow +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 UTC +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +1970-01-01 03:00:01 Moscow +1970-01-01 03:00:01 UTC +1974-02-05 21:28:16 Moscow +1974-02-06 00:28:16 UTC +2011-03-27 01:59:59 Moscow +2011-03-27 01:59:59 UTC +2011-03-27 03:00:00 Moscow +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 UTC +2011-03-27 03:00:01 Moscow +2011-03-27 03:00:01 UTC +2011-10-30 01:59:59 Moscow +2011-10-30 01:59:59 UTC +2011-10-30 02:00:00 MoscowD +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 MoscowD +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 MoscowD +2011-10-30 02:59:59 UTC +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 UTC +2011-10-30 03:00:00 Moscow +2011-10-30 03:00:00 UTC +2011-10-30 03:00:01 Moscow +2011-10-30 03:00:01 UTC +2038-01-19 06:14:06 Moscow +2038-01-19 06:14:06 UTC +2038-01-19 06:14:07 Moscow +2038-01-19 06:14:07 UTC +SELECT * FROM t2 ORDER BY a, tz; +a tz +NULL Moscow +NULL UTC +0000-00-00 00:00:00 Moscow +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 MoscowI +0000-00-00 00:00:00 UTC +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +0000-00-00 00:00:00 UTCI +1970-01-01 03:00:01 Moscow +1970-01-01 03:00:01 UTC +1974-02-05 21:28:16 Moscow +1974-02-06 00:28:16 UTC +2011-03-27 01:59:59 Moscow +2011-03-27 01:59:59 UTC +2011-03-27 03:00:00 Moscow +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 UTC +2011-03-27 03:00:01 Moscow +2011-03-27 03:00:01 UTC +2011-10-30 01:59:59 Moscow +2011-10-30 01:59:59 UTC +2011-10-30 02:00:00 MoscowD +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 MoscowD +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 MoscowD +2011-10-30 02:59:59 UTC +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 UTC +2011-10-30 03:00:00 Moscow +2011-10-30 03:00:00 UTC +2011-10-30 03:00:01 Moscow +2011-10-30 03:00:01 UTC +2038-01-19 06:14:06 Moscow +2038-01-19 06:14:06 UTC +2038-01-19 06:14:07 Moscow +2038-01-19 06:14:07 UTC +# Testing the leap from 01:59:59 to 03:00:00 +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-27 03:00:00' ORDER BY a, tz; +a tz +2011-03-27 01:59:59 Moscow +2011-03-27 01:59:59 UTC +2011-03-27 03:00:00 Moscow +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-27 03:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSK,p-2011-MSD-1 ALL NULL NULL NULL NULL 11 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-27 01:59:59' ORDER BY a, tz; +a tz +2011-03-27 01:59:59 Moscow +2011-03-27 01:59:59 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-27 01:59:59' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSK ALL NULL NULL NULL NULL 2 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 01:59:59' and '2011-03-28 00:00:00' ORDER BY a, tz; +a tz +2011-03-27 01:59:59 Moscow +2011-03-27 01:59:59 UTC +2011-03-27 03:00:00 Moscow +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 UTC +2011-03-27 03:00:01 Moscow +2011-03-27 03:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 01:59:59' and '2011-03-28 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSK,p-2011-MSD-1 ALL NULL NULL NULL NULL 11 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 03:00:00' and '2011-03-28 00:00:00' ORDER BY a, tz; +a tz +2011-03-27 01:59:59 Moscow +2011-03-27 01:59:59 UTC +2011-03-27 03:00:00 Moscow +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 UTC +2011-03-27 03:00:01 Moscow +2011-03-27 03:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 03:00:00' and '2011-03-28 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSK,p-2011-MSD-1 ALL NULL NULL NULL NULL 11 Using where; Using filesort +# Testing the leap from 02:59:59 to 02:00:00 +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 02:00:00' ORDER BY a, tz; +a tz +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 02:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1 ALL NULL NULL NULL NULL 9 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 02:59:59' ORDER BY a, tz; +a tz +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 02:59:59' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1 ALL NULL NULL NULL NULL 9 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 03:00:00' ORDER BY a, tz; +a tz +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 03:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1 ALL NULL NULL NULL NULL 9 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 01:59:59' ORDER BY a, tz; +a tz +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 01:59:59' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1 ALL NULL NULL NULL NULL 9 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 02:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; +a tz +2011-10-30 01:59:59 Moscow +2011-10-30 01:59:59 UTC +2011-10-30 02:00:00 MoscowD +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 MoscowD +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 MoscowD +2011-10-30 02:59:59 UTC +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 UTC +2011-10-30 03:00:00 Moscow +2011-10-30 03:00:00 UTC +2011-10-30 03:00:01 Moscow +2011-10-30 03:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 02:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1,p-2011-MSD-2,p-2012-MSK-1,p-2012-MSK-2 ALL NULL NULL NULL NULL 22 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 02:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; +a tz +2011-10-30 01:59:59 Moscow +2011-10-30 01:59:59 UTC +2011-10-30 02:00:00 MoscowD +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 MoscowD +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 MoscowD +2011-10-30 02:59:59 UTC +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 UTC +2011-10-30 03:00:00 Moscow +2011-10-30 03:00:00 UTC +2011-10-30 03:00:01 Moscow +2011-10-30 03:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 02:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1,p-2011-MSD-2,p-2012-MSK-1,p-2012-MSK-2 ALL NULL NULL NULL NULL 22 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 03:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; +a tz +2011-10-30 01:59:59 Moscow +2011-10-30 01:59:59 UTC +2011-10-30 02:00:00 MoscowD +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 MoscowD +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 MoscowD +2011-10-30 02:59:59 UTC +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 UTC +2011-10-30 03:00:00 Moscow +2011-10-30 03:00:00 UTC +2011-10-30 03:00:01 Moscow +2011-10-30 03:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 03:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1,p-2011-MSD-2,p-2012-MSK-1,p-2012-MSK-2 ALL NULL NULL NULL NULL 22 Using where; Using filesort +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 01:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; +a tz +2011-10-30 01:59:59 Moscow +2011-10-30 01:59:59 UTC +2011-10-30 02:00:00 MoscowD +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 MoscowD +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 MoscowD +2011-10-30 02:59:59 UTC +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 UTC +2011-10-30 03:00:00 Moscow +2011-10-30 03:00:00 UTC +2011-10-30 03:00:01 Moscow +2011-10-30 03:00:01 UTC +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 01:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE t2 p-2011-MSD-1,p-2011-MSD-2,p-2012-MSK-1,p-2012-MSK-2 ALL NULL NULL NULL NULL 22 Using where; Using filesort +# Test end range changes +DELETE FROM t2 WHERE a = 0; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00', 'Moscow'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT COUNT(*) FROM t2; +COUNT(*) +35 +SELECT COUNT(*) FROM t2 WHERE a = 0; +COUNT(*) +1 +SELECT * FROM t2 ORDER BY a, tz LIMIT 3; +a tz +NULL Moscow +NULL UTC +0000-00-00 00:00:00 Moscow +SELECT * FROM t2 ORDER BY a DESC, tz LIMIT 3; +a tz +2038-01-19 06:14:07 Moscow +2038-01-19 06:14:07 UTC +2038-01-19 06:14:06 Moscow +UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a); +Warnings: +Warning 1299 Invalid TIMESTAMP value in column 'a' at row 8 +Warning 1299 Invalid TIMESTAMP value in column 'a' at row 9 +Warning 1264 Out of range value for column 'a' at row 34 +Warning 1264 Out of range value for column 'a' at row 35 +SELECT MIN(a), MAX(a) FROM t2; +MIN(a) MAX(a) +0000-00-00 00:00:00 2038-01-19 06:14:07 +SELECT COUNT(*) FROM t2; +COUNT(*) +35 +SELECT COUNT(*) FROM t2 WHERE a = 0; +COUNT(*) +2 +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +PARTITION_NAME TABLE_ROWS +p0 3 +p-2000 6 +p-2011-MSK 0 +p-2011-MSD-1 9 +p-2011-MSD-2 8 +p-2012-MSK-1 0 +p-2012-MSK-2 7 +pEnd 0 +pMax 2 +SELECT * FROM t2 ORDER BY a, tz; +a tz +NULL Moscow +NULL Moscow +NULL UTC +0000-00-00 00:00:00 Moscow +0000-00-00 00:00:00 UTC +1970-01-01 03:00:02 Moscow +1970-01-01 03:00:02 UTC +1974-02-05 21:28:17 Moscow +1974-02-06 00:28:17 UTC +2011-03-27 03:00:00 Moscow +2011-03-27 03:00:00 UTC +2011-03-27 03:00:01 Moscow +2011-03-27 03:00:01 MoscowI +2011-03-27 03:00:01 MoscowI +2011-03-27 03:00:01 MoscowI +2011-03-27 03:00:01 UTC +2011-03-27 03:00:02 Moscow +2011-03-27 03:00:02 UTC +2011-10-30 02:00:00 Moscow +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 MoscowD +2011-10-30 02:00:01 UTC +2011-10-30 02:00:01 UTC +2011-10-30 02:00:02 MoscowD +2011-10-30 02:00:02 UTC +2011-10-30 02:00:02 UTC +2011-10-30 03:00:00 MoscowD +2011-10-30 03:00:00 UTC +2011-10-30 03:00:00 UTC +2011-10-30 03:00:01 Moscow +2011-10-30 03:00:01 UTC +2011-10-30 03:00:02 Moscow +2011-10-30 03:00:02 UTC +2038-01-19 06:14:07 Moscow +2038-01-19 06:14:07 UTC +# Test start range changes +INSERT INTO t2 VALUES ('1970-01-01 00:00:00', 'Moscow'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT COUNT(*) FROM t2; +COUNT(*) +36 +SELECT COUNT(*) FROM t2 WHERE a = 0; +COUNT(*) +3 +SELECT * FROM t2 ORDER BY a, tz LIMIT 3; +a tz +NULL Moscow +NULL Moscow +NULL UTC +SELECT * FROM t2 ORDER BY a DESC, tz LIMIT 3; +a tz +2038-01-19 06:14:07 Moscow +2038-01-19 06:14:07 UTC +2011-10-30 03:00:02 Moscow +UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a); +Warnings: +Warning 1299 Invalid TIMESTAMP value in column 'a' at row 18 +Warning 1299 Invalid TIMESTAMP value in column 'a' at row 19 +SELECT MIN(a), MAX(a) FROM t2; +MIN(a) MAX(a) +1970-01-01 03:00:01 2038-01-19 06:14:06 +SELECT COUNT(*) FROM t2; +COUNT(*) +36 +SELECT COUNT(*) FROM t2 WHERE a = 0; +COUNT(*) +0 +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +PARTITION_NAME TABLE_ROWS +p0 6 +p-2000 4 +p-2011-MSK 0 +p-2011-MSD-1 11 +p-2011-MSD-2 9 +p-2012-MSK-1 0 +p-2012-MSK-2 4 +pEnd 2 +pMax 0 +SELECT * FROM t2 ORDER BY a, tz; +a tz +NULL Moscow +NULL Moscow +NULL Moscow +NULL Moscow +NULL UTC +NULL UTC +1970-01-01 03:00:01 Moscow +1970-01-01 03:00:01 UTC +1974-02-05 21:28:16 Moscow +1974-02-06 00:28:16 UTC +2011-03-27 03:00:00 Moscow +2011-03-27 03:00:00 Moscow +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 MoscowI +2011-03-27 03:00:00 UTC +2011-03-27 03:00:00 UTC +2011-03-27 03:00:01 Moscow +2011-03-27 03:00:01 UTC +2011-10-30 01:59:59 Moscow +2011-10-30 01:59:59 UTC +2011-10-30 02:00:00 MoscowD +2011-10-30 02:00:00 UTC +2011-10-30 02:00:00 UTC +2011-10-30 02:00:01 MoscowD +2011-10-30 02:00:01 UTC +2011-10-30 02:00:01 UTC +2011-10-30 02:59:59 MoscowD +2011-10-30 02:59:59 UTC +2011-10-30 02:59:59 UTC +2011-10-30 03:00:00 Moscow +2011-10-30 03:00:00 UTC +2011-10-30 03:00:01 Moscow +2011-10-30 03:00:01 UTC +2038-01-19 06:14:06 Moscow +2038-01-19 06:14:06 UTC +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` timestamp NULL DEFAULT NULL, + `tz` varchar(16) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (UNIX_TIMESTAMP(a)) +(PARTITION p0 VALUES LESS THAN (0) ENGINE = MyISAM, + PARTITION `p-2000` VALUES LESS THAN (946684800) ENGINE = MyISAM, + PARTITION `p-2011-MSK` VALUES LESS THAN (1301180400) ENGINE = MyISAM, + PARTITION `p-2011-MSD-1` VALUES LESS THAN (1319925600) ENGINE = MyISAM, + PARTITION `p-2011-MSD-2` VALUES LESS THAN (1319929200) ENGINE = MyISAM, + PARTITION `p-2012-MSK-1` VALUES LESS THAN (1319932800) ENGINE = MyISAM, + PARTITION `p-2012-MSK-2` VALUES LESS THAN (1332630000) ENGINE = MyISAM, + PARTITION pEnd VALUES LESS THAN (2147483647) ENGINE = MyISAM, + PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ +TRUNCATE TABLE t2; +DROP TABLE t1, t2; +SET @@session.time_zone= @old_time_zone; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 7d7b7a2cc54..2a8ba15d3f1 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -227,10 +227,16 @@ INSERT INTO t1 VALUES ('2009-07-14 17:35:55', 'pmax'); INSERT INTO t1 VALUES ('2009-09-21 17:31:42', 'pmax'); SELECT * FROM t1; +SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01'; +EXPLAIN PARTITIONS SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01'; +EXPLAIN PARTITIONS SELECT * FROM t1 where a = '2007-07-30 17:35:48'; ALTER TABLE t1 REORGANIZE PARTITION pmax INTO ( PARTITION p3 VALUES LESS THAN (1247688000), PARTITION pmax VALUES LESS THAN MAXVALUE); SELECT * FROM t1; +SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01'; +EXPLAIN PARTITIONS SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01'; +EXPLAIN PARTITIONS SELECT * FROM t1 where a = '2007-07-30 17:35:48'; SHOW CREATE TABLE t1; DROP TABLE t1; diff --git a/mysql-test/t/partition_datatype.test b/mysql-test/t/partition_datatype.test index 0a9fae15354..967e1cddb4e 100644 --- a/mysql-test/t/partition_datatype.test +++ b/mysql-test/t/partition_datatype.test @@ -7,6 +7,7 @@ # BUG#48164 limited size to 3072 bytes # -- source include/have_partition.inc +-- source include/have_innodb.inc --disable_warnings drop table if exists t1; @@ -233,3 +234,312 @@ show create table t1; insert into t1 values (1),(4),(7),(10),(13),(16),(19),(22),(25),(28),(31),(34); select hex(a) from t1 where a = 7; drop table t1; + +--echo # +--echo # Bug#28928: UNIX_TIMESTAMP() should be considered unary monotonic +--echo # by partition pruning +SET @old_time_zone= @@session.time_zone; +SET @@session.time_zone = 'UTC'; +--echo # Using MyISAM to get stable values on TABLE_ROWS in I_S.PARTITIONS +CREATE TABLE t1 +(a TIMESTAMP NULL, + tz varchar(16)) +ENGINE = MyISAM; +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 PARTITION BY RANGE (UNIX_TIMESTAMP(a)) +(PARTITION `p0` VALUES LESS THAN (0), + PARTITION `p-2000` VALUES LESS THAN (UNIX_TIMESTAMP('2000-01-01')), + PARTITION `p-2011-MSK` VALUES LESS THAN (UNIX_TIMESTAMP('2011-03-26 23:00:00')), + PARTITION `p-2011-MSD-1` VALUES LESS THAN (UNIX_TIMESTAMP('2011-10-29 22:00:00')), + PARTITION `p-2011-MSD-2` VALUES LESS THAN (UNIX_TIMESTAMP('2011-10-29 23:00:00')), + PARTITION `p-2012-MSK-1` VALUES LESS THAN (UNIX_TIMESTAMP('2011-10-30 00:00:00')), + PARTITION `p-2012-MSK-2` VALUES LESS THAN (UNIX_TIMESTAMP('2012-03-24 23:00:00')), + PARTITION `pEnd` VALUES LESS THAN (UNIX_TIMESTAMP('2038-01-19 03:14:07')), + PARTITION `pMax` VALUES LESS THAN MAXVALUE); + + +--echo # Test 'odd' values +INSERT INTO t1 VALUES (NULL, 'UTC'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00', 'UTC'); +--echo # Test invalid values +INSERT INTO t1 VALUES ('1901-01-01 00:00:00', 'UTCI'); +INSERT INTO t1 VALUES ('1969-12-31 23:59:59', 'UTCI'); +INSERT INTO t1 VALUES ('2038-01-19 03:14:08', 'UTCI'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00', 'UTCI'); +--echo # Test start range +INSERT INTO t1 VALUES ('1970-01-01 00:00:01', 'UTC'); +INSERT INTO t1 VALUES ('1974-02-05 21:28:16', 'UTC'); +--echo # Test end range +INSERT INTO t1 VALUES ('2038-01-19 03:14:06', 'UTC'); +INSERT INTO t1 VALUES ('2038-01-19 03:14:07', 'UTC'); +--echo # Test Daylight saving shift +INSERT INTO t1 VALUES ('2011-03-26 22:59:59', 'UTC'); +INSERT INTO t1 VALUES ('2011-03-26 23:00:00', 'UTC'); +INSERT INTO t1 VALUES ('2011-03-26 23:00:01', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 21:59:59', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 22:00:00', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 22:00:01', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 22:59:59', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 23:00:00', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 23:00:01', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-29 23:59:59', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-30 00:00:00', 'UTC'); +INSERT INTO t1 VALUES ('2011-10-30 00:00:01', 'UTC'); + +SET @@session.time_zone = 'Europe/Moscow'; + +--echo # Test 'odd' values +INSERT INTO t1 VALUES (NULL, 'Moscow'); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00', 'Moscow'); +--echo # Test invalid values +INSERT INTO t1 VALUES ('0000-00-00 03:00:00', 'MoscowI'); +INSERT INTO t1 VALUES ('1901-01-01 00:00:00', 'MoscowI'); +INSERT INTO t1 VALUES ('1969-12-31 23:59:59', 'MoscowI'); +INSERT INTO t1 VALUES ('1970-01-01 02:29:29', 'MoscowI'); +INSERT INTO t1 VALUES ('2038-01-19 06:14:08', 'MoscowI'); +INSERT INTO t1 VALUES ('1970-01-01 03:00:00', 'MoscowI'); +--echo # values truncated to 03:00:00 due to daylight saving shift +INSERT INTO t1 VALUES ('2011-03-27 02:00:00', 'MoscowI'); +INSERT INTO t1 VALUES ('2011-03-27 02:00:01', 'MoscowI'); +INSERT INTO t1 VALUES ('2011-03-27 02:59:59', 'MoscowI'); +--echo # Test start range +INSERT INTO t1 VALUES ('1970-01-01 03:00:01', 'Moscow'); +INSERT INTO t1 VALUES ('1974-02-05 21:28:16', 'Moscow'); +--echo # Test end range +INSERT INTO t1 VALUES ('2038-01-19 06:14:06', 'Moscow'); +INSERT INTO t1 VALUES ('2038-01-19 06:14:07', 'Moscow'); +--echo # Test Daylight saving shift +INSERT INTO t1 VALUES ('2011-03-27 01:59:59', 'Moscow'); +INSERT INTO t1 VALUES ('2011-03-27 03:00:00', 'Moscow'); +INSERT INTO t1 VALUES ('2011-03-27 03:00:01', 'Moscow'); +INSERT INTO t1 VALUES ('2011-10-30 01:59:59', 'Moscow'); +--echo # All values between 02:00 and 02:59:59 will be interpretated as DST +INSERT INTO t1 VALUES ('2011-10-30 02:00:00', 'MoscowD'); +INSERT INTO t1 VALUES ('2011-10-30 02:00:01', 'MoscowD'); +INSERT INTO t1 VALUES ('2011-10-30 02:59:59', 'MoscowD'); +INSERT INTO t1 VALUES ('2011-10-30 03:00:00', 'Moscow'); +INSERT INTO t1 VALUES ('2011-10-30 03:00:01', 'Moscow'); + + +SET @@session.time_zone = 'UTC'; + +INSERT INTO t2 SELECT * FROM t1; + +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; + +SELECT * FROM t1 ORDER BY a, tz; +SELECT * FROM t2 ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-26 23:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-26 23:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-26 22:59:59' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-26 22:59:59' ORDER BY a, tz; + + +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 22:59:59' and '2011-03-28 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 22:59:59' and '2011-03-28 00:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 23:00:00' and '2011-03-28 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 23:00:00' and '2011-03-28 00:00:00' ORDER BY a, tz; + + + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 23:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 23:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 22:59:59' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 22:59:59' ORDER BY a, tz; + + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 22:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 22:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 23:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 23:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; + + +--echo # Test end range changes +DELETE FROM t2 WHERE a = 0; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00', 'UTC'); +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t2 WHERE a = 0; +SELECT * FROM t2 ORDER BY a, tz LIMIT 3; +SELECT * FROM t2 ORDER BY a DESC, tz LIMIT 3; +UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a); +SELECT MIN(a), MAX(a) FROM t2; +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t2 WHERE a = 0; +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +SELECT * FROM t2 ORDER BY a, tz; + +--echo # Test start range changes +INSERT INTO t2 VALUES ('1970-01-01 00:00:00', 'UTC'); +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t2 WHERE a = 0; +SELECT * FROM t2 ORDER BY a, tz LIMIT 3; +SELECT * FROM t2 ORDER BY a DESC, tz LIMIT 3; +UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a); +SELECT MIN(a), MAX(a) FROM t2; +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t2 WHERE a = 0; +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +SELECT * FROM t2 ORDER BY a, tz; + +SHOW CREATE TABLE t2; +TRUNCATE TABLE t2; + +SET @@session.time_zone = 'Europe/Moscow'; + +INSERT INTO t2 SELECT * FROM t1; + +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; + +SELECT * FROM t1 ORDER BY a, tz; +SELECT * FROM t2 ORDER BY a, tz; + +--echo # Testing the leap from 01:59:59 to 03:00:00 +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-27 03:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-27 03:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-27 01:59:59' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-01 00:00:00' and '2011-03-27 01:59:59' ORDER BY a, tz; + + +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 01:59:59' and '2011-03-28 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 01:59:59' and '2011-03-28 00:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 03:00:00' and '2011-03-28 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-03-26 03:00:00' and '2011-03-28 00:00:00' ORDER BY a, tz; + + + +--echo # Testing the leap from 02:59:59 to 02:00:00 +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 02:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 02:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 02:59:59' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 02:59:59' ORDER BY a, tz; + + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 03:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 03:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 01:59:59' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-01 00:00:00' and '2011-10-29 01:59:59' ORDER BY a, tz; + + + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 02:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 02:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 02:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 02:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; + + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 03:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 03:00:00' and '2011-10-31 00:00:00' ORDER BY a, tz; + +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 01:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; +EXPLAIN PARTITIONS +SELECT * FROM t2 +WHERE a BETWEEN '2011-10-29 01:59:59' and '2011-10-31 00:00:00' ORDER BY a, tz; + + + +--echo # Test end range changes +DELETE FROM t2 WHERE a = 0; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00', 'Moscow'); +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t2 WHERE a = 0; +SELECT * FROM t2 ORDER BY a, tz LIMIT 3; +SELECT * FROM t2 ORDER BY a DESC, tz LIMIT 3; +UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a); +SELECT MIN(a), MAX(a) FROM t2; +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t2 WHERE a = 0; +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +SELECT * FROM t2 ORDER BY a, tz; + +--echo # Test start range changes +INSERT INTO t2 VALUES ('1970-01-01 00:00:00', 'Moscow'); +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t2 WHERE a = 0; +SELECT * FROM t2 ORDER BY a, tz LIMIT 3; +SELECT * FROM t2 ORDER BY a DESC, tz LIMIT 3; +UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a); +SELECT MIN(a), MAX(a) FROM t2; +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t2 WHERE a = 0; +SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_NAME = 't2'; +SELECT * FROM t2 ORDER BY a, tz; + +SHOW CREATE TABLE t2; +TRUNCATE TABLE t2; + +DROP TABLE t1, t2; +SET @@session.time_zone= @old_time_zone; |