From: Mattias Jonsson Date: September 7 2010 3:56pm Subject: bzr commit into mysql-5.1-bugteam branch (mattias.jonsson:3481) Bug#55458 List-Archive: http://lists.mysql.com/commits/117717 X-Bug: 55458 Message-Id: <201009071559.o87CRNHf021875@acsinet15.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4552987673801127332==" --===============4552987673801127332== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///Users/mattiasj/mysql-bzr/b55458-51-bt/ based on revid:mattias.jonsson@stripped 3481 Mattias Jonsson 2010-09-07 Bug#55458: Partitioned MyISAM table gets crashed by multi-table update Updated according to reviewers comments. modified: sql/ha_partition.cc sql/ha_partition.h === modified file 'sql/ha_partition.cc' --- a/sql/ha_partition.cc 2010-08-10 08:43:12 +0000 +++ b/sql/ha_partition.cc 2010-09-07 15:56:43 +0000 @@ -233,6 +233,7 @@ void ha_partition::init_handler_variable m_extra_cache= FALSE; m_extra_cache_size= 0; m_extra_prepare_for_update= FALSE; + m_extra_cache_part_id= NO_CURRENT_PART_ID; m_handler_status= handler_not_initialized; m_low_byte_first= 1; m_part_field_array= NULL; @@ -5376,9 +5377,6 @@ void ha_partition::get_dynamic_partition when performing the sequential scan we will check this recorded value and call extra_opt whenever we start scanning a new partition. - monty: Neads to be fixed so that it's passed to all handlers when we - move to another partition during table scan. - HA_EXTRA_NO_CACHE: When performing a UNION SELECT HA_EXTRA_NO_CACHE is called from the flush method in the select_union class. @@ -5390,7 +5388,7 @@ void ha_partition::get_dynamic_partition for. If no cache is in use they will quickly return after finding this out. And we also ensure that all caches are disabled and no one is left by mistake. - In the future this call will probably be deleted an we will instead call + In the future this call will probably be deleted and we will instead call ::reset(); HA_EXTRA_WRITE_CACHE: @@ -5402,8 +5400,9 @@ void ha_partition::get_dynamic_partition This is called as part of a multi-table update. When the table to be updated is also scanned then this informs MyISAM handler to drop any caches if dynamic records are used (fixed size records do not care - about this call). We pass this along to all underlying MyISAM handlers - and ignore it for the rest. + about this call). We pass this along to the first partition to scan, and + flag that it is to be called after HA_EXTRA_CACHE when moving to the next + partition to scan. HA_EXTRA_PREPARE_FOR_DROP: Only used by MyISAM, called in preparation for a DROP TABLE. @@ -5559,6 +5558,7 @@ int ha_partition::extra(enum ha_extra_fu m_extra_prepare_for_update= TRUE; if (m_part_spec.start_part != NO_CURRENT_PART_ID) { + DBUG_ASSERT(m_extra_cache_part_id == m_part_spec.start_part); VOID(m_file[m_part_spec.start_part]->extra(HA_EXTRA_PREPARE_FOR_UPDATE)); } break; @@ -5586,11 +5586,22 @@ int ha_partition::extra(enum ha_extra_fu break; } case HA_EXTRA_NO_CACHE: + { + int ret= 0; + if (m_extra_cache_part_id != NO_CURRENT_PART_ID) + ret= m_file[m_extra_cache_part_id]->extra(HA_EXTRA_NO_CACHE); + m_extra_cache= FALSE; + m_extra_cache_size= 0; + m_extra_prepare_for_update= FALSE; + m_extra_cache_part_id= NO_CURRENT_PART_ID; + DBUG_RETURN(ret); + } case HA_EXTRA_WRITE_CACHE: { m_extra_cache= FALSE; m_extra_cache_size= 0; m_extra_prepare_for_update= FALSE; + m_extra_cache_part_id= NO_CURRENT_PART_ID; DBUG_RETURN(loop_extra(operation)); } case HA_EXTRA_IGNORE_NO_KEY: @@ -5777,16 +5788,18 @@ int ha_partition::loop_extra(enum ha_ext { int result= 0, tmp; handler **file; + bool is_select; DBUG_ENTER("ha_partition::loop_extra()"); - /* - TODO, 5.2: this is where you could possibly add optimisations to add the bitmap - _if_ a SELECT. - */ + is_select= (thd_sql_command(ha_thd()) == SQLCOM_SELECT); for (file= m_file; *file; file++) { - if ((tmp= (*file)->extra(operation))) - result= tmp; + if (!is_select || + bitmap_is_set(&(m_part_info->used_partitions), file - m_file)) + { + if ((tmp= (*file)->extra(operation))) + result= tmp; + } } DBUG_RETURN(result); } @@ -5822,6 +5835,7 @@ void ha_partition::late_extra_cache(uint DBUG_ASSERT(m_extra_cache); VOID(file->extra(HA_EXTRA_PREPARE_FOR_UPDATE)); } + m_extra_cache_part_id= partition_id; DBUG_VOID_RETURN; } @@ -5846,6 +5860,8 @@ void ha_partition::late_extra_no_cache(u DBUG_VOID_RETURN; file= m_file[partition_id]; VOID(file->extra(HA_EXTRA_NO_CACHE)); + DBUG_ASSERT(partition_id == m_extra_cache_part_id); + m_extra_cache_part_id= NO_CURRENT_PART_ID; DBUG_VOID_RETURN; } === modified file 'sql/ha_partition.h' --- a/sql/ha_partition.h 2010-08-10 08:43:12 +0000 +++ b/sql/ha_partition.h 2010-09-07 15:56:43 +0000 @@ -156,6 +156,8 @@ private: uint m_extra_cache_size; /* The same goes for HA_EXTRA_PREPARE_FOR_UPDATE */ bool m_extra_prepare_for_update; + /* Which partition has active cache */ + uint m_extra_cache_part_id; void init_handler_variables(); /* --===============4552987673801127332== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/mattias.jonsson@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: mattias.jonsson@stripped\ # lex6mcfwm40w0j0h # target_branch: file:///Users/mattiasj/mysql-bzr/b55458-51-bt/ # testament_sha1: 30ddb86b55340f61828cb1590a79f02d19263cac # timestamp: 2010-09-07 17:57:00 +0200 # base_revision_id: mattias.jonsson@stripped\ # 7pqozmh1gv90aq90 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWT9V1SsAAxlfgFQQeXf//3/3 /sq////+YAbPvF3YAOq03YHSKg3NrhJFEynoZKHtNU/VPaeoKe1RspptQDIAGhk9T1PSB6gyQKn6 p7RqYKbSAGgGgBoGQAAAAOMjTJiaDJkwmmQMhoDQGmTQwAmgMMSZI0qfiDUQeptQfqRkep6QyAxA A9QAMg4yNMmJoMmTCaZAyGgNAaZNDACaAwkkBNBME0IynkTU/RDUyn6SNN6oNk1G0INGepkjBHux Y80D6UvwZMxH1dG3c9l6XJl6N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