#At file:///Users/mattiasj/mysql-bzr/topush-trunk/ based on revid:mattias.jonsson@stripped
3557 Mattias Jonsson 2011-01-26 [merge]
merge of bug#56438 into mysql-trunk
modified:
sql/ha_partition.cc
sql/ha_partition.h
sql/handler.h
sql/partition_info.h
sql/sql_partition.cc
=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc 2011-01-26 13:57:04 +0000
+++ b/sql/ha_partition.cc 2011-01-26 21:12:56 +0000
@@ -6348,6 +6348,31 @@ uint8 ha_partition::table_cache_type()
}
+/**
+ Calculate hash value for KEY partitioning using an array of fields.
+
+ @param field_array An array of the fields in KEY partitioning
+
+ @return hash_value calculated
+
+ @note Uses the hash function on the character set of the field.
+ Integer and floating point fields use the binary character set by default.
+*/
+
+uint32 ha_partition::calculate_key_hash_value(Field **field_array)
+{
+ ulong nr1= 1;
+ ulong nr2= 4;
+
+ do
+ {
+ Field *field= *field_array;
+ field->hash(&nr1, &nr2);
+ } while (*(++field_array));
+ return (uint32) nr1;
+}
+
+
/****************************************************************************
MODULE print messages
****************************************************************************/
=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h 2010-12-03 10:05:56 +0000
+++ b/sql/ha_partition.h 2011-01-26 21:12:56 +0000
@@ -166,7 +166,7 @@ private:
enum_monotonicity_info m_part_func_monotonicity_info;
public:
handler *clone(MEM_ROOT *mem_root);
- virtual void set_part_info(partition_info *part_info)
+ virtual void set_part_info(partition_info *part_info, bool early)
{
m_part_info= part_info;
m_is_sub_partitioned= part_info->is_sub_partitioned();
@@ -599,6 +599,9 @@ public:
virtual uint8 table_cache_type();
virtual ha_rows records();
+ /* Calculate hash value for PARTITION BY KEY tables. */
+ uint32 calculate_key_hash_value(Field **field_array);
+
/*
-------------------------------------------------------------------------
MODULE print messages
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2011-01-26 13:57:04 +0000
+++ b/sql/handler.h 2011-01-26 21:12:56 +0000
@@ -1887,6 +1887,8 @@ public:
virtual int info(uint)=0; // see my_base.h for full description
virtual void get_dynamic_partition_info(PARTITION_STATS *stat_info,
uint part_id);
+ virtual uint32 calculate_key_hash_value(Field **field_array)
+ { DBUG_ASSERT(0); return 0; }
virtual int extra(enum ha_extra_function operation)
{ return 0; }
virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
@@ -2024,7 +2026,7 @@ public:
*no_parts= 0;
return 0;
}
- virtual void set_part_info(partition_info *part_info) {return;}
+ virtual void set_part_info(partition_info *part_info, bool early) {return;}
virtual ulong index_flags(uint idx, uint part, bool all_parts) const =0;
=== modified file 'sql/partition_info.h'
--- a/sql/partition_info.h 2010-10-21 09:49:16 +0000
+++ b/sql/partition_info.h 2011-01-26 21:12:56 +0000
@@ -157,6 +157,7 @@ public:
uint curr_list_object;
uint num_columns;
+ TABLE *table;
/*
These key_map's are used for Partitioning to enable quick decisions
on whether we can derive more information about which partition to
=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc 2011-01-26 20:13:31 +0000
+++ b/sql/sql_partition.cc 2011-01-26 21:12:56 +0000
@@ -1889,6 +1889,7 @@ bool fix_partition_func(THD *thd, TABLE
set_up_partition_key_maps(table, part_info);
set_up_partition_func_pointers(part_info);
set_up_range_analysis_info(part_info);
+ table->file->set_part_info(part_info, FALSE);
result= FALSE;
end:
thd->mark_used_columns= save_mark_used_columns;
@@ -2719,42 +2720,13 @@ static inline int part_val_int(Item *ite
We have a set of support functions for these 14 variants. There are 4
variants of hash functions and there is a function for each. The KEY
- partitioning uses the function calculate_key_value to calculate the hash
+ partitioning uses the function calculate_key_hash_value to calculate the hash
value based on an array of fields. The linear hash variants uses the
method get_part_id_from_linear_hash to get the partition id using the
hash value and some parameters calculated from the number of partitions.
*/
/*
- Calculate hash value for KEY partitioning using an array of fields.
-
- SYNOPSIS
- calculate_key_value()
- field_array An array of the fields in KEY partitioning
-
- RETURN VALUE
- hash_value calculated
-
- DESCRIPTION
- Uses the hash function on the character set of the field. Integer and
- floating point fields use the binary character set by default.
-*/
-
-static uint32 calculate_key_value(Field **field_array)
-{
- ulong nr1= 1;
- ulong nr2= 4;
-
- do
- {
- Field *field= *field_array;
- field->hash(&nr1, &nr2);
- } while (*(++field_array));
- return (uint32) nr1;
-}
-
-
-/*
A simple support function to calculate part_id given local part and
sub part.
@@ -2841,25 +2813,25 @@ static int get_part_id_linear_hash(parti
}
-/*
+/**
Calculate part_id for (SUB)PARTITION BY KEY
- SYNOPSIS
- get_part_id_key()
- field_array Array of fields for PARTTION KEY
- num_parts Number of KEY partitions
+ @param file Handler to storage engine
+ @param field_array Array of fields for PARTTION KEY
+ @param num_parts Number of KEY partitions
+ @param func_value[out] Returns calculated hash value
- RETURN VALUE
- Calculated partition id
+ @return Calculated partition id
*/
inline
-static uint32 get_part_id_key(Field **field_array,
+static uint32 get_part_id_key(handler *file,
+ Field **field_array,
uint num_parts,
longlong *func_value)
{
DBUG_ENTER("get_part_id_key");
- *func_value= calculate_key_value(field_array);
+ *func_value= file->calculate_key_hash_value(field_array);
DBUG_RETURN((uint32) (*func_value % num_parts));
}
@@ -2886,7 +2858,7 @@ static uint32 get_part_id_linear_key(par
{
DBUG_ENTER("get_part_id_linear_key");
- *func_value= calculate_key_value(field_array);
+ *func_value= part_info->table->file->calculate_key_hash_value(field_array);
DBUG_RETURN(get_part_id_from_linear_hash(*func_value,
part_info->linear_hash_mask,
num_parts));
@@ -3574,7 +3546,8 @@ int get_partition_id_key_nosub(partition
uint32 *part_id,
longlong *func_value)
{
- *part_id= get_part_id_key(part_info->part_field_array,
+ *part_id= get_part_id_key(part_info->table->file,
+ part_info->part_field_array,
part_info->num_parts, func_value);
return 0;
}
@@ -3664,7 +3637,8 @@ int get_partition_id_key_sub(partition_i
uint32 *part_id)
{
longlong func_value;
- *part_id= get_part_id_key(part_info->subpart_field_array,
+ *part_id= get_part_id_key(part_info->table->file,
+ part_info->subpart_field_array,
part_info->num_subparts, &func_value);
return FALSE;
}
@@ -4366,7 +4340,8 @@ bool mysql_unpack_partition(THD *thd,
*work_part_info_used= true;
}
table->part_info= part_info;
- table->file->set_part_info(part_info);
+ part_info->table= table;
+ table->file->set_part_info(part_info, TRUE);
if (!part_info->default_engine_type)
part_info->default_engine_type= default_db_type;
DBUG_ASSERT(part_info->default_engine_type == default_db_type);
No bundle (reason: revision is a merge).
| Thread |
|---|
| • bzr commit into mysql-trunk branch (mattias.jonsson:3557) Bug#56438 | Mattias Jonsson | 26 Jan |