From: Mattias Jonsson Date: October 7 2011 8:31am Subject: bzr push into mysql-trunk branch (mattias.jonsson:3477 to 3478) Bug#13007154 List-Archive: http://lists.mysql.com/commits/141346 X-Bug: 13007154 Message-Id: <201110070830.p978Ujpp029352@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3478 Mattias Jonsson 2011-10-07 Bug#13007154: Crash in keys_to_use_for_scanning with ORDER BY and PARTITIONING The server could crash on a query that called ha_partition::keys_to_use_for_scanning when there was no partitions used.Due to the first used partition would then be out of bounds. The solution was to always use the first partitions handler since the function will return the same key_map for every partition, since they have the same engine and the same structure. This bug was introduced as a regression in WL#5217. modified: mysql-test/r/partition_innodb.result mysql-test/t/partition_innodb.test sql/ha_partition.cc 3477 Sergey Vojtovich 2011-10-07 [merge] Merge. added: mysql-test/std_data/bug48633.ARM mysql-test/std_data/bug48633.ARZ mysql-test/std_data/bug48633.frm modified: mysql-test/r/archive.result mysql-test/t/archive.test mysql-test/valgrind.supp sql/table.cc storage/archive/azio.c storage/archive/ha_archive.cc storage/archive/ha_archive.h === modified file 'mysql-test/r/partition_innodb.result' --- a/mysql-test/r/partition_innodb.result 2011-08-29 07:08:18 +0000 +++ b/mysql-test/r/partition_innodb.result 2011-10-07 08:30:01 +0000 @@ -1,5 +1,16 @@ drop table if exists t1, t2; # +# Bug#13007154: Crash in keys_to_use_for_scanning with ORDER BY +# and PARTITIONING +# +CREATE TABLE t1 (a INT, KEY(a)) +ENGINE = InnoDB +PARTITION BY KEY (a) PARTITIONS 1; +SELECT 1 FROM t1 WHERE a > (SELECT LAST_INSERT_ID() FROM t1 LIMIT 0) +ORDER BY a; +1 +DROP TABLE t1; +# # Bug#56287: crash when using Partition datetime in sub in query # CREATE TABLE t1 === modified file 'mysql-test/t/partition_innodb.test' --- a/mysql-test/t/partition_innodb.test 2011-08-29 07:08:18 +0000 +++ b/mysql-test/t/partition_innodb.test 2011-10-07 08:30:01 +0000 @@ -9,6 +9,17 @@ drop table if exists t1, t2; let $MYSQLD_DATADIR= `SELECT @@datadir`; --echo # +--echo # Bug#13007154: Crash in keys_to_use_for_scanning with ORDER BY +--echo # and PARTITIONING +--echo # +CREATE TABLE t1 (a INT, KEY(a)) +ENGINE = InnoDB +PARTITION BY KEY (a) PARTITIONS 1; +SELECT 1 FROM t1 WHERE a > (SELECT LAST_INSERT_ID() FROM t1 LIMIT 0) +ORDER BY a; +DROP TABLE t1; + +--echo # --echo # Bug#56287: crash when using Partition datetime in sub in query --echo # === modified file 'sql/ha_partition.cc' --- a/sql/ha_partition.cc 2011-10-06 09:50:40 +0000 +++ b/sql/ha_partition.cc 2011-10-07 08:30:01 +0000 @@ -6474,23 +6474,19 @@ void ha_partition::late_extra_no_cache(u MODULE optimiser support ****************************************************************************/ -/* - Get keys to use for scanning +/** + Get keys to use for scanning. - SYNOPSIS - keys_to_use_for_scanning() + @return key_map of keys usable for scanning - RETURN VALUE - key_map of keys usable for scanning + @note No need to use read_partitions here, since it does not depend on + which partitions is used, only which storage engine used. */ const key_map *ha_partition::keys_to_use_for_scanning() { - uint first_used_partition; DBUG_ENTER("ha_partition::keys_to_use_for_scanning"); - - first_used_partition= bitmap_get_first_set(&(m_part_info->read_partitions)); - DBUG_RETURN(m_file[first_used_partition]->keys_to_use_for_scanning()); + DBUG_RETURN(m_file[0]->keys_to_use_for_scanning()); } #define MAX_PARTS_FOR_OPTIMIZER_CALLS 10 No bundle (reason: useless for push emails).