#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<partition_element> 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<partition_element> subparts_it(el->subpartitions);
- partition_element *subel;
- while ((subel= (subparts_it++)))
+ List_iterator<partition_element> 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;
}
Attachment: [text/bzr-bundle] bzr/mattias.jonsson@oracle.com-20110125202600-lo8d2jwkkr28cowp.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk branch (mattias.jonsson:3212) WL#5217 | Mattias Jonsson | 25 Jan |