From: Mattias Jonsson Date: January 25 2011 8:26pm Subject: bzr commit into mysql-trunk branch (mattias.jonsson:3212) WL#5217 List-Archive: http://lists.mysql.com/commits/129597 Message-Id: <201101252026.p0PKQaBa008922@rcsinet13.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1252832385936921849==" --===============1252832385936921849== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///Users/mattiasj/mysql-bzr/topush-trunk-wl5217/ based on revid:mattias.jonsson@stripped 3212 Mattias Jonsson 2011-01-25 WL#5217: Add explicit partition selection Changes according to first code review. @ sql/ha_partition.cc Added DEFINE for easier code understandig of offset in .par file for engine type. Changed index in partition_name_hash for partitions to index in m_file (i.e. first subpartition for that partition). @ sql/partition_info.cc Changed index for partition to be equal to first subpartition, instead of partition number (without subpartitions). Renamed variable el to more specific p_elem. modified: sql/ha_partition.cc sql/partition_info.cc === modified file 'sql/ha_partition.cc' --- a/sql/ha_partition.cc 2010-12-14 20:03:21 +0000 +++ b/sql/ha_partition.cc 2011-01-25 20:26:00 +0000 @@ -64,6 +64,7 @@ #include "debug_sync.h" +#define PAR_FILE_ENGINE_OFFSET 12 static const char *ha_par_ext= ".par"; /**************************************************************************** @@ -2195,7 +2196,7 @@ bool ha_partition::create_handler_file(c tot_len_byte= 4 * tot_len_words; if (!(file_buffer= (uchar *) my_malloc(tot_len_byte, MYF(MY_ZEROFILL)))) DBUG_RETURN(TRUE); - engine_array= (file_buffer + 12); + engine_array= (file_buffer + PAR_FILE_ENGINE_OFFSET); name_buffer_ptr= (char*) (file_buffer + ((4 + tot_partition_words) * 4)); part_it.rewind(); for (i= 0; i < num_parts; i++) @@ -2235,7 +2236,8 @@ bool ha_partition::create_handler_file(c chksum= 0; int4store(file_buffer, tot_len_words); int4store(file_buffer + 8, tot_parts); - int4store(file_buffer + 12 + (tot_partition_words * 4), tot_name_len); + int4store(file_buffer + PAR_FILE_ENGINE_OFFSET + (tot_partition_words * 4), + tot_name_len); for (i= 0; i < tot_len_words; i++) chksum^= uint4korr(file_buffer + 4 * i); int4store(file_buffer + 4, chksum); @@ -2456,11 +2458,12 @@ bool ha_partition::get_from_handler_file m_tot_parts= uint4korr((file_buffer) + 8); DBUG_PRINT("info", ("No of parts = %u", m_tot_parts)); tot_partition_words= (m_tot_parts + 3) / 4; - first_db_type= (enum legacy_db_type) file_buffer[12]; + first_db_type= (enum legacy_db_type) file_buffer[PAR_FILE_ENGINE_OFFSET]; first_engine= ha_resolve_by_legacy_type(ha_thd(), first_db_type); if (!first_engine) goto err2; - address_tot_name_len= file_buffer + 12 + 4 * tot_partition_words; + address_tot_name_len= file_buffer + PAR_FILE_ENGINE_OFFSET + + 4 * tot_partition_words; tot_name_words= (uint4korr(address_tot_name_len) + 3) / 4; if (len_words != (tot_partition_words + tot_name_words + 4)) goto err2; @@ -2475,7 +2478,7 @@ bool ha_partition::get_from_handler_file for (i= 0; i < m_tot_parts; i++) { - db_type= (enum legacy_db_type) file_buffer[12 + i]; + db_type= (enum legacy_db_type) file_buffer[PAR_FILE_ENGINE_OFFSET + i]; if (db_type != first_db_type) { DBUG_PRINT("error", ("partition %u engine %d is not same as " @@ -2581,7 +2584,7 @@ bool ha_partition::populate_partition_na if (part_elem->part_state == PART_NORMAL) { if (insert_partition_name_in_hash(part_elem->partition_name, - i, false)) + i * num_subparts, false)) goto err; if (m_is_sub_partitioned) { === modified file 'sql/partition_info.cc' --- a/sql/partition_info.cc 2010-12-17 12:48:18 +0000 +++ b/sql/partition_info.cc 2011-01-25 20:26:00 +0000 @@ -139,7 +139,7 @@ bool partition_info::prune_partition_bit if (is_sub_partitioned()) { /* Mark all subpartitions in the partition */ - uint j, start= part_def->part_id * num_subparts; + uint j, start= part_def->part_id; uint end= start + num_subparts; for (j= start; j < end; j++) bitmap_set_bit(&read_partitions, j); @@ -642,7 +642,7 @@ char *partition_info::has_unique_names() const uchar *curr_name= NULL; size_t length; List_iterator parts_it(partitions); - partition_element *el; + partition_element *p_elem; DBUG_ENTER("partition_info::has_unique_names"); @@ -662,20 +662,20 @@ char *partition_info::has_unique_names() curr_name= (const uchar*) "Internal failure"; goto error; } - while ((el= (parts_it++))) + while ((p_elem= (parts_it++))) { - curr_name= (const uchar*) el->partition_name; - length= strlen(el->partition_name); + curr_name= (const uchar*) p_elem->partition_name; + length= strlen(p_elem->partition_name); if (my_hash_insert(&partition_names, curr_name)) goto error; - if (!el->subpartitions.is_empty()) + if (!p_elem->subpartitions.is_empty()) { - List_iterator subparts_it(el->subpartitions); - partition_element *subel; - while ((subel= (subparts_it++))) + List_iterator subparts_it(p_elem->subpartitions); + partition_element *subp_elem; + while ((subp_elem= (subparts_it++))) { - curr_name= (const uchar*) subel->partition_name; + curr_name= (const uchar*) subp_elem->partition_name; if (my_hash_insert(&partition_names, curr_name)) goto error; } --===============1252832385936921849== 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\ # lo8d2jwkkr28cowp # target_branch: file:///Users/mattiasj/mysql-bzr/topush-trunk-wl5217/ # testament_sha1: 1ce93ed32759643c48808f69843bb8f0e9ee386e # timestamp: 2011-01-25 21:26:30 +0100 # source_branch: file:///Users/mattiasj/mysql-bzr/wl5217-trunk/ # base_revision_id: mattias.jonsson@stripped\ # h1nuhzt1hnmi9keu # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWeb5VgUAAzL/gFRQBAB8f/// f7fcir////BgB030R6ABd83Zej0oDntRqDFCI1AD9Uep6aj9U9I9qg9ID0gBoAAADjJk0YhpoYCa GJo0yYgZGE0aaYQZMNEDSaQ2qaeU/UahoeiAAAAAAyaAEkminqJptIMQNBiAwgAAAAAAikmiaaan lJmp+iaaID0geoAHqAABpoeUEkiaaNAARMjCZGk1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