Bug #70588 | Index merge used on partitionned table can return wrong result set | ||
---|---|---|---|
Submitted: | 10 Oct 2013 12:09 | Modified: | 5 Nov 2013 17:05 |
Reporter: | Joffrey MICHAIE | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Partitions | Severity: | S2 (Serious) |
Version: | 5.6.14,5.5 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | index merge, intersect, partition, wrong resultset |
[10 Oct 2013 12:09]
Joffrey MICHAIE
[10 Oct 2013 12:30]
MySQL Verification Team
Thank you for the bug report. C:\dbs>c:\dbs\5.6\bin\mysql -uroot --port=3560 --prompt="mysql 5.6 > " Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.6.15 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql 5.6 > use xd Database changed mysql 5.6 > CREATE TABLE `poll` ( -> `id_key` int(10) unsigned NOT NULL AUTO_INCREMENT, -> `id` int(6) NOT NULL DEFAULT '0', -> `id_poll` int(6) NOT NULL DEFAULT '0', -> `date_long` datetime NOT NULL, -> `date_short` date NOT NULL, -> PRIMARY KEY (`id_key`,`id_poll`), -> KEY `id` (`id`), -> KEY `date_creation` (`date_short`) -> ) ENGINE=InnoDB AUTO_INCREMENT=14101389 DEFAULT CHARSET=latin1 -> /*!50100 PARTITION BY HASH (id_poll) -> PARTITIONS 20 */; Query OK, 0 rows affected (4.76 sec) mysql 5.6 > mysql 5.6 > INSERT INTO `poll` VALUES (NULL,1718848,580660,'2013-10-09 18:21:00','2013-10-09'); Query OK, 1 row affected (0.20 sec) <CUT> mysql 5.6 > SELECT date_short FROM poll WHERE id =70 AND date_short = '2013-10-10'; Empty set (0.00 sec) mysql 5.6 > alter table poll remove partitioning; Query OK, 13 rows affected (3.76 sec) Records: 13 Duplicates: 0 Warnings: 0 mysql 5.6 > SELECT date_short FROM poll WHERE id =70 AND date_short = '2013-10-10'; +------------+ | date_short | +------------+ | 2013-10-10 | +------------+ 1 row in set (0.02 sec) mysql 5.6 >
[10 Oct 2013 12:55]
Joffrey MICHAIE
From: http://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-14.html For partitioned tables, queries could return different results depending on whether Index Merge was used. (Bug #16862316)
[5 Nov 2013 17:05]
Jon Stephens
Fixed in 5.5+. Documented in the 5.5.36, 5.6.16, and 5.7.4 changelogs, as follows: Queries using index_merge optimization (see http://dev.mysql.com/doc/refman/5.5/en/index-merge-optimization.html) could return invalid results when run against tables that were partitioned by HASH. Closed.
[2 Feb 2014 17:20]
Laurynas Biveinis
5.5$ bzr log -r 4538 ------------------------------------------------------------ revno: 4538 committer: Aditya A <aditya.a@oracle.com> branch nick: mysql-5.5 timestamp: Tue 2013-11-05 19:25:26 +0530 message: Bug#17588348: INDEX MERGE USED ON PARTITIONED TABLE CAN RETURN WRONG RESULT SET PROBLEM ------- In ha_partition::cmp_ref() we were only calling the underlying cmp_ref() of storage engine if the records are in the same partiton,else we sort by partition and returns the result.But the index merge intersect algorithm expects first to sort by row-id first and then by partition id. FIX --- Compare the refernces first using storage engine cmp_ref and then if references are equal(only happens if non clustered index is used) then sort it by partition id. [Approved by Mattiasj #rb3755] -