Commit f481a6a8 authored by unknown's avatar unknown

BUG#20770: Added some more test cases


mysql-test/r/partition_range.result:
  New test case
mysql-test/t/partition_range.test:
  New test case
sql/partition_info.cc:
  No changes
parent 43179555
......@@ -519,3 +519,115 @@ partition p3 values less than (1998),
partition p4 values less than (1999),
partition p5 values less than (2000));
drop table t1;
CREATE TABLE t1 (a date)
PARTITION BY RANGE (TO_DAYS(a))
(PARTITION p3xx VALUES LESS THAN (TO_DAYS('2004-01-01')),
PARTITION p401 VALUES LESS THAN (TO_DAYS('2004-02-01')),
PARTITION p402 VALUES LESS THAN (TO_DAYS('2004-03-01')),
PARTITION p403 VALUES LESS THAN (TO_DAYS('2004-04-01')),
PARTITION p404 VALUES LESS THAN (TO_DAYS('2004-05-01')),
PARTITION p405 VALUES LESS THAN (TO_DAYS('2004-06-01')),
PARTITION p406 VALUES LESS THAN (TO_DAYS('2004-07-01')),
PARTITION p407 VALUES LESS THAN (TO_DAYS('2004-08-01')),
PARTITION p408 VALUES LESS THAN (TO_DAYS('2004-09-01')),
PARTITION p409 VALUES LESS THAN (TO_DAYS('2004-10-01')),
PARTITION p410 VALUES LESS THAN (TO_DAYS('2004-11-01')),
PARTITION p411 VALUES LESS THAN (TO_DAYS('2004-12-01')),
PARTITION p412 VALUES LESS THAN (TO_DAYS('2005-01-01')),
PARTITION p501 VALUES LESS THAN (TO_DAYS('2005-02-01')),
PARTITION p502 VALUES LESS THAN (TO_DAYS('2005-03-01')),
PARTITION p503 VALUES LESS THAN (TO_DAYS('2005-04-01')),
PARTITION p504 VALUES LESS THAN (TO_DAYS('2005-05-01')),
PARTITION p505 VALUES LESS THAN (TO_DAYS('2005-06-01')),
PARTITION p506 VALUES LESS THAN (TO_DAYS('2005-07-01')),
PARTITION p507 VALUES LESS THAN (TO_DAYS('2005-08-01')),
PARTITION p508 VALUES LESS THAN (TO_DAYS('2005-09-01')),
PARTITION p509 VALUES LESS THAN (TO_DAYS('2005-10-01')),
PARTITION p510 VALUES LESS THAN (TO_DAYS('2005-11-01')),
PARTITION p511 VALUES LESS THAN (TO_DAYS('2005-12-01')),
PARTITION p512 VALUES LESS THAN (TO_DAYS('2006-01-01')),
PARTITION p601 VALUES LESS THAN (TO_DAYS('2006-02-01')),
PARTITION p602 VALUES LESS THAN (TO_DAYS('2006-03-01')),
PARTITION p603 VALUES LESS THAN (TO_DAYS('2006-04-01')),
PARTITION p604 VALUES LESS THAN (TO_DAYS('2006-05-01')),
PARTITION p605 VALUES LESS THAN (TO_DAYS('2006-06-01')),
PARTITION p606 VALUES LESS THAN (TO_DAYS('2006-07-01')),
PARTITION p607 VALUES LESS THAN (TO_DAYS('2006-08-01')));
INSERT INTO t1 VALUES ('2003-01-13'),('2003-06-20'),('2003-08-30');
INSERT INTO t1 VALUES ('2003-04-13'),('2003-07-20'),('2003-10-30');
INSERT INTO t1 VALUES ('2003-05-13'),('2003-11-20'),('2003-12-30');
INSERT INTO t1 VALUES ('2004-01-13'),('2004-01-20'),('2004-01-30');
INSERT INTO t1 VALUES ('2004-02-13'),('2004-02-20'),('2004-02-28');
INSERT INTO t1 VALUES ('2004-03-13'),('2004-03-20'),('2004-03-30');
INSERT INTO t1 VALUES ('2004-04-13'),('2004-04-20'),('2004-04-30');
INSERT INTO t1 VALUES ('2004-05-13'),('2004-05-20'),('2004-05-30');
INSERT INTO t1 VALUES ('2004-06-13'),('2004-06-20'),('2004-06-30');
INSERT INTO t1 VALUES ('2004-07-13'),('2004-07-20'),('2004-07-30');
INSERT INTO t1 VALUES ('2004-08-13'),('2004-08-20'),('2004-08-30');
INSERT INTO t1 VALUES ('2004-09-13'),('2004-09-20'),('2004-09-30');
INSERT INTO t1 VALUES ('2004-10-13'),('2004-10-20'),('2004-10-30');
INSERT INTO t1 VALUES ('2004-11-13'),('2004-11-20'),('2004-11-30');
INSERT INTO t1 VALUES ('2004-12-13'),('2004-12-20'),('2004-12-30');
INSERT INTO t1 VALUES ('2005-01-13'),('2005-01-20'),('2005-01-30');
INSERT INTO t1 VALUES ('2005-02-13'),('2005-02-20'),('2005-02-28');
INSERT INTO t1 VALUES ('2005-03-13'),('2005-03-20'),('2005-03-30');
INSERT INTO t1 VALUES ('2005-04-13'),('2005-04-20'),('2005-04-30');
INSERT INTO t1 VALUES ('2005-05-13'),('2005-05-20'),('2005-05-30');
INSERT INTO t1 VALUES ('2005-06-13'),('2005-06-20'),('2005-06-30');
INSERT INTO t1 VALUES ('2005-07-13'),('2005-07-20'),('2005-07-30');
INSERT INTO t1 VALUES ('2005-08-13'),('2005-08-20'),('2005-08-30');
INSERT INTO t1 VALUES ('2005-09-13'),('2005-09-20'),('2005-09-30');
INSERT INTO t1 VALUES ('2005-10-13'),('2005-10-20'),('2005-10-30');
INSERT INTO t1 VALUES ('2005-11-13'),('2005-11-20'),('2005-11-30');
INSERT INTO t1 VALUES ('2005-12-13'),('2005-12-20'),('2005-12-30');
INSERT INTO t1 VALUES ('2006-01-13'),('2006-01-20'),('2006-01-30');
INSERT INTO t1 VALUES ('2006-02-13'),('2006-02-20'),('2006-02-28');
INSERT INTO t1 VALUES ('2006-03-13'),('2006-03-20'),('2006-03-30');
INSERT INTO t1 VALUES ('2006-04-13'),('2006-04-20'),('2006-04-30');
INSERT INTO t1 VALUES ('2006-05-13'),('2006-05-20'),('2006-05-30');
INSERT INTO t1 VALUES ('2006-06-13'),('2006-06-20'),('2006-06-30');
INSERT INTO t1 VALUES ('2006-07-13'),('2006-07-20'),('2006-07-30');
SELECT * FROM t1
WHERE a >= '2004-07-01' AND a <= '2004-09-30';
a
2004-07-13
2004-07-20
2004-07-30
2004-08-13
2004-08-20
2004-08-30
2004-09-13
2004-09-20
2004-09-30
EXPLAIN PARTITIONS SELECT * FROM t1
WHERE a >= '2004-07-01' AND a <= '2004-09-30';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p407,p408,p409 ALL NULL NULL NULL NULL 9 Using where
SELECT * from t1
WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
(a >= '2005-07-01' AND a <= '2005-09-30');
a
2004-07-13
2004-07-20
2004-07-30
2004-08-13
2004-08-20
2004-08-30
2004-09-13
2004-09-20
2004-09-30
2005-07-13
2005-07-20
2005-07-30
2005-08-13
2005-08-20
2005-08-30
2005-09-13
2005-09-20
2005-09-30
EXPLAIN PARTITIONS SELECT * from t1
WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
(a >= '2005-07-01' AND a <= '2005-09-30');
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p407,p408,p409,p507,p508,p509 ALL NULL NULL NULL NULL 18 Using where
DROP TABLE t1;
......@@ -555,3 +555,90 @@ reorganize partition p5 into
drop table t1;
#
# New test cases for date based partitioning
#
CREATE TABLE t1 (a date)
PARTITION BY RANGE (TO_DAYS(a))
(PARTITION p3xx VALUES LESS THAN (TO_DAYS('2004-01-01')),
PARTITION p401 VALUES LESS THAN (TO_DAYS('2004-02-01')),
PARTITION p402 VALUES LESS THAN (TO_DAYS('2004-03-01')),
PARTITION p403 VALUES LESS THAN (TO_DAYS('2004-04-01')),
PARTITION p404 VALUES LESS THAN (TO_DAYS('2004-05-01')),
PARTITION p405 VALUES LESS THAN (TO_DAYS('2004-06-01')),
PARTITION p406 VALUES LESS THAN (TO_DAYS('2004-07-01')),
PARTITION p407 VALUES LESS THAN (TO_DAYS('2004-08-01')),
PARTITION p408 VALUES LESS THAN (TO_DAYS('2004-09-01')),
PARTITION p409 VALUES LESS THAN (TO_DAYS('2004-10-01')),
PARTITION p410 VALUES LESS THAN (TO_DAYS('2004-11-01')),
PARTITION p411 VALUES LESS THAN (TO_DAYS('2004-12-01')),
PARTITION p412 VALUES LESS THAN (TO_DAYS('2005-01-01')),
PARTITION p501 VALUES LESS THAN (TO_DAYS('2005-02-01')),
PARTITION p502 VALUES LESS THAN (TO_DAYS('2005-03-01')),
PARTITION p503 VALUES LESS THAN (TO_DAYS('2005-04-01')),
PARTITION p504 VALUES LESS THAN (TO_DAYS('2005-05-01')),
PARTITION p505 VALUES LESS THAN (TO_DAYS('2005-06-01')),
PARTITION p506 VALUES LESS THAN (TO_DAYS('2005-07-01')),
PARTITION p507 VALUES LESS THAN (TO_DAYS('2005-08-01')),
PARTITION p508 VALUES LESS THAN (TO_DAYS('2005-09-01')),
PARTITION p509 VALUES LESS THAN (TO_DAYS('2005-10-01')),
PARTITION p510 VALUES LESS THAN (TO_DAYS('2005-11-01')),
PARTITION p511 VALUES LESS THAN (TO_DAYS('2005-12-01')),
PARTITION p512 VALUES LESS THAN (TO_DAYS('2006-01-01')),
PARTITION p601 VALUES LESS THAN (TO_DAYS('2006-02-01')),
PARTITION p602 VALUES LESS THAN (TO_DAYS('2006-03-01')),
PARTITION p603 VALUES LESS THAN (TO_DAYS('2006-04-01')),
PARTITION p604 VALUES LESS THAN (TO_DAYS('2006-05-01')),
PARTITION p605 VALUES LESS THAN (TO_DAYS('2006-06-01')),
PARTITION p606 VALUES LESS THAN (TO_DAYS('2006-07-01')),
PARTITION p607 VALUES LESS THAN (TO_DAYS('2006-08-01')));
INSERT INTO t1 VALUES ('2003-01-13'),('2003-06-20'),('2003-08-30');
INSERT INTO t1 VALUES ('2003-04-13'),('2003-07-20'),('2003-10-30');
INSERT INTO t1 VALUES ('2003-05-13'),('2003-11-20'),('2003-12-30');
INSERT INTO t1 VALUES ('2004-01-13'),('2004-01-20'),('2004-01-30');
INSERT INTO t1 VALUES ('2004-02-13'),('2004-02-20'),('2004-02-28');
INSERT INTO t1 VALUES ('2004-03-13'),('2004-03-20'),('2004-03-30');
INSERT INTO t1 VALUES ('2004-04-13'),('2004-04-20'),('2004-04-30');
INSERT INTO t1 VALUES ('2004-05-13'),('2004-05-20'),('2004-05-30');
INSERT INTO t1 VALUES ('2004-06-13'),('2004-06-20'),('2004-06-30');
INSERT INTO t1 VALUES ('2004-07-13'),('2004-07-20'),('2004-07-30');
INSERT INTO t1 VALUES ('2004-08-13'),('2004-08-20'),('2004-08-30');
INSERT INTO t1 VALUES ('2004-09-13'),('2004-09-20'),('2004-09-30');
INSERT INTO t1 VALUES ('2004-10-13'),('2004-10-20'),('2004-10-30');
INSERT INTO t1 VALUES ('2004-11-13'),('2004-11-20'),('2004-11-30');
INSERT INTO t1 VALUES ('2004-12-13'),('2004-12-20'),('2004-12-30');
INSERT INTO t1 VALUES ('2005-01-13'),('2005-01-20'),('2005-01-30');
INSERT INTO t1 VALUES ('2005-02-13'),('2005-02-20'),('2005-02-28');
INSERT INTO t1 VALUES ('2005-03-13'),('2005-03-20'),('2005-03-30');
INSERT INTO t1 VALUES ('2005-04-13'),('2005-04-20'),('2005-04-30');
INSERT INTO t1 VALUES ('2005-05-13'),('2005-05-20'),('2005-05-30');
INSERT INTO t1 VALUES ('2005-06-13'),('2005-06-20'),('2005-06-30');
INSERT INTO t1 VALUES ('2005-07-13'),('2005-07-20'),('2005-07-30');
INSERT INTO t1 VALUES ('2005-08-13'),('2005-08-20'),('2005-08-30');
INSERT INTO t1 VALUES ('2005-09-13'),('2005-09-20'),('2005-09-30');
INSERT INTO t1 VALUES ('2005-10-13'),('2005-10-20'),('2005-10-30');
INSERT INTO t1 VALUES ('2005-11-13'),('2005-11-20'),('2005-11-30');
INSERT INTO t1 VALUES ('2005-12-13'),('2005-12-20'),('2005-12-30');
INSERT INTO t1 VALUES ('2006-01-13'),('2006-01-20'),('2006-01-30');
INSERT INTO t1 VALUES ('2006-02-13'),('2006-02-20'),('2006-02-28');
INSERT INTO t1 VALUES ('2006-03-13'),('2006-03-20'),('2006-03-30');
INSERT INTO t1 VALUES ('2006-04-13'),('2006-04-20'),('2006-04-30');
INSERT INTO t1 VALUES ('2006-05-13'),('2006-05-20'),('2006-05-30');
INSERT INTO t1 VALUES ('2006-06-13'),('2006-06-20'),('2006-06-30');
INSERT INTO t1 VALUES ('2006-07-13'),('2006-07-20'),('2006-07-30');
SELECT * FROM t1
WHERE a >= '2004-07-01' AND a <= '2004-09-30';
EXPLAIN PARTITIONS SELECT * FROM t1
WHERE a >= '2004-07-01' AND a <= '2004-09-30';
SELECT * from t1
WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
(a >= '2005-07-01' AND a <= '2005-09-30');
EXPLAIN PARTITIONS SELECT * from t1
WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
(a >= '2005-07-01' AND a <= '2005-09-30');
DROP TABLE t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment