Commit 86901216 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-5102 : MySQL Bug 69851

- Backport MySQL's fix: do set ha_partition::m_pkey_is_clustered for ha_partition 
  objects created with handler->clone() call.
- Also, include a testcase.
parent e6ac94a6
...@@ -594,4 +594,49 @@ a b c ...@@ -594,4 +594,49 @@ a b c
4 2 1 4 2 1
5 1 1 5 1 1
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-5102 : MySQL Bug 69851
#
CREATE TABLE t1 (
`col1` bigint(20) unsigned NOT NULL ,
`col2` bigint(20) unsigned NOT NULL ,
`col3` datetime NOT NULL ,
PRIMARY KEY (`col3`),
KEY (`col1`),
KEY (`col2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY RANGE (TO_DAYS(col3))
(
PARTITION p_20130310 VALUES LESS THAN (735303) ENGINE = InnoDB,
PARTITION p_20130311 VALUES LESS THAN (735304) ENGINE = InnoDB,
PARTITION p_20130312 VALUES LESS THAN (735305) ENGINE = InnoDB
);
INSERT INTO `t1` VALUES (2,96,'2013-03-08 16:28:05');
INSERT INTO `t1` VALUES (1,2,'2013-03-08 16:47:39');
INSERT INTO `t1` VALUES (1,2,'2013-03-08 16:50:27');
INSERT INTO `t1` VALUES (1,2,'2013-03-11 16:33:04');
INSERT INTO `t1` VALUES (1,2,'2013-03-11 16:33:24');
INSERT INTO `t1` VALUES (2,2,'2013-03-12 10:11:48');
SELECT * FROM t1 WHERE col1 = 1 AND col2 = 2
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
GROUP BY 1, 2, 3;
col1 col2 col3
1 2 2013-03-08 16:47:39
1 2 2013-03-08 16:50:27
1 2 2013-03-11 16:33:04
1 2 2013-03-11 16:33:24
EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col2 = 2
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
GROUP BY 1, 2, 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,col1,col2 col1,col2 8,8 NULL # Using intersect(col1,col2); Using where; Using index; Using filesort
SELECT * FROM t1 USE INDEX () WHERE col1 = 1 AND col2 = 2
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
GROUP BY 1, 2, 3;
col1 col2 col3
1 2 2013-03-08 16:47:39
1 2 2013-03-08 16:50:27
1 2 2013-03-11 16:33:04
1 2 2013-03-11 16:33:24
DROP TABLE t1;
set global default_storage_engine=default; set global default_storage_engine=default;
...@@ -678,4 +678,43 @@ UPDATE t1 SET b = 0, c=1 WHERE a <=>0; ...@@ -678,4 +678,43 @@ UPDATE t1 SET b = 0, c=1 WHERE a <=>0;
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-5102 : MySQL Bug 69851
--echo #
CREATE TABLE t1 (
`col1` bigint(20) unsigned NOT NULL ,
`col2` bigint(20) unsigned NOT NULL ,
`col3` datetime NOT NULL ,
PRIMARY KEY (`col3`),
KEY (`col1`),
KEY (`col2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY RANGE (TO_DAYS(col3))
(
PARTITION p_20130310 VALUES LESS THAN (735303) ENGINE = InnoDB,
PARTITION p_20130311 VALUES LESS THAN (735304) ENGINE = InnoDB,
PARTITION p_20130312 VALUES LESS THAN (735305) ENGINE = InnoDB
);
INSERT INTO `t1` VALUES (2,96,'2013-03-08 16:28:05');
INSERT INTO `t1` VALUES (1,2,'2013-03-08 16:47:39');
INSERT INTO `t1` VALUES (1,2,'2013-03-08 16:50:27');
INSERT INTO `t1` VALUES (1,2,'2013-03-11 16:33:04');
INSERT INTO `t1` VALUES (1,2,'2013-03-11 16:33:24');
INSERT INTO `t1` VALUES (2,2,'2013-03-12 10:11:48');
SELECT * FROM t1 WHERE col1 = 1 AND col2 = 2
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
GROUP BY 1, 2, 3;
--replace_column 9 #
EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col2 = 2
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
GROUP BY 1, 2, 3;
SELECT * FROM t1 USE INDEX () WHERE col1 = 1 AND col2 = 2
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
GROUP BY 1, 2, 3;
DROP TABLE t1;
set global default_storage_engine=default; set global default_storage_engine=default;
...@@ -226,6 +226,7 @@ ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share, ...@@ -226,6 +226,7 @@ ha_partition::ha_partition(handlerton *hton, TABLE_SHARE *share,
m_is_sub_partitioned= m_part_info->is_sub_partitioned(); m_is_sub_partitioned= m_part_info->is_sub_partitioned();
m_is_clone_of= clone_arg; m_is_clone_of= clone_arg;
m_clone_mem_root= clone_mem_root_arg; m_clone_mem_root= clone_mem_root_arg;
m_pkey_is_clustered= clone_arg->primary_key_is_clustered();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
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