Below is the list of changes that have just been committed into a local
5.1 repository of mikron. When mikron does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-07-04 19:53:54+02:00, mikron@stripped +7 -0
BUG#29550: EXPLAIN PARTITIONS gives wrong output for PARTITION BY KEY-tables
sql/ha_ndbcluster.cc@stripped, 2007-07-04 19:27:29+02:00,
mikron@stripped +103 -31
Introduce m_user_defined_partitioning and m_use_partition_pruning
instead of m_use_partition_function
m_user_defined_partitioning
is set when not PARTITION BY KEY without subpartitioning is used
m_use_partition_pruning is set in all cases except when the user
have used a default NDB table without primary key, this is equal to
using PARTITION BY KEY() on a table without primary key in NDB.
The calculation of these variables are performed in set_part_info in the
new late phase introduced to enable this calculation.
Add calculate_key_hash_value to calculate hash value for PARTITION BY KEY
tables.
sql/ha_ndbcluster.h@stripped, 2007-07-04 19:27:29+02:00,
mikron@stripped +4 -2
Changes to interface of set_part_info, new method and
changes to partition variables.
sql/ha_partition.cc@stripped, 2007-07-04 19:27:29+02:00, mikron@stripped
+38 -6
Fix for missing if (index_read_flag)
Add new method to handler to calculate hash value
sql/ha_partition.h@stripped, 2007-07-04 19:27:29+02:00, mikron@stripped
+3 -2
New method and changed interface
sql/handler.h@stripped, 2007-07-04 19:27:29+02:00, mikron@stripped +5
-1
New method and changed interface
sql/partition_info.h@stripped, 2007-07-04 19:27:29+02:00,
mikron@stripped +2 -0
Keep table object reference on partition info for quick access to handler
to calculate hash value
sql/sql_partition.cc@stripped, 2007-07-04 19:27:30+02:00,
mikron@stripped +66 -68
Moved calculation of hash value to handler
Updated comments
Added new set_part_info method
More debug stuff
Updated interfaces to various methods to send handler reference
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: mikron
# Host: mikael-ronstr-ms-dator.local
# Root: /Users/mikron/mysql_clones/bug29550
--- 1.259/sql/handler.h 2007-05-28 14:42:52 +02:00
+++ 1.260/sql/handler.h 2007-07-04 19:27:29 +02:00
@@ -1306,6 +1306,8 @@
virtual int info(uint)=0; // see my_base.h for full description
virtual void get_dynamic_partition_info(PARTITION_INFO *stat_info,
uint part_id);
+ virtual uint32 calculate_key_hash_value(Field **field_array)
+ { DBUG_ASSERT(0); }
virtual int extra(enum ha_extra_function operation)
{ return 0; }
virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
@@ -1499,7 +1501,9 @@
*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;
--- 1.461/sql/ha_ndbcluster.cc 2007-07-03 17:23:33 +02:00
+++ 1.462/sql/ha_ndbcluster.cc 2007-07-04 19:27:29 +02:00
@@ -1762,8 +1762,13 @@
if ((res= define_read_attrs(buf, op)))
DBUG_RETURN(res);
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
{
+ /*
+ We only need have a proper part_id if it is user defined
+ partitioning. Otherwise this could be unitialised
+ */
+ DBUG_ASSERT(part_id < MAX_PARTITIONS);
op->setPartitionId(part_id);
// If table has user defined partitioning
// and no indexes, we need to read the partition id
@@ -1823,7 +1828,7 @@
ERR_RETURN(op->getNdbError());
}
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
op->setPartitionId(old_part_id);
// Read all unreferenced non-key field(s)
@@ -1981,7 +1986,7 @@
if ((res= set_primary_key_from_record(op, record)))
ERR_RETURN(trans->getNdbError());
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
{
uint32 part_id;
int error;
@@ -1994,7 +1999,8 @@
m_part_info->err_value= func_value;
DBUG_RETURN(error);
}
- op->setPartitionId(part_id);
+ if (m_user_defined_partitioning)
+ op->setPartitionId(part_id);
}
}
/*
@@ -2447,7 +2453,7 @@
m_table)) ||
op->readTuples(lm, 0, parallelism, sorted, descending, FALSE, need_pk))
ERR_RETURN(trans->getNdbError());
- if (m_use_partition_function && part_spec != NULL &&
+ if (m_use_partition_pruning && part_spec != NULL &&
part_spec->start_part == part_spec->end_part)
op->setPartitionId(part_spec->start_part);
m_active_cursor= op;
@@ -2455,7 +2461,7 @@
restart= TRUE;
op= (NdbIndexScanOperation*)m_active_cursor;
- if (m_use_partition_function && part_spec != NULL &&
+ if (m_use_partition_pruning && part_spec != NULL &&
part_spec->start_part == part_spec->end_part)
op->setPartitionId(part_spec->start_part);
DBUG_ASSERT(op->getSorted() == sorted);
@@ -2485,7 +2491,7 @@
// If table has user defined partitioning
// and no primary key, we need to read the partition id
// to support ORDER BY queries
- if (m_use_partition_function &&
+ if (m_user_defined_partitioning &&
(table_share->primary_key == MAX_KEY) &&
(get_ndb_partition_id(op)))
ERR_RETURN(trans->getNdbError());
@@ -2547,7 +2553,6 @@
ERR_RETURN(trans->getNdbError());
m_active_cursor= op;
- if (m_use_partition_function)
{
part_spec.start_part= 0;
part_spec.end_part= m_part_info->get_tot_partitions() - 1;
@@ -2622,7 +2627,7 @@
ERR_RETURN(trans->getNdbError());
m_active_cursor= op;
- if (m_use_partition_function)
+ if (m_use_partition_pruning)
{
part_spec.start_part= 0;
part_spec.end_part= m_part_info->get_tot_partitions() - 1;
@@ -2730,7 +2735,7 @@
if (res != 0)
ERR_RETURN(trans->getNdbError());
- if (m_use_partition_function)
+ if (m_use_partition_pruning)
{
uint32 part_id;
int error;
@@ -2794,7 +2799,7 @@
}
dbug_tmp_restore_column_map(table->read_set, old_map);
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
{
/*
We need to set the value of the partition function value in
@@ -2963,7 +2968,7 @@
bitmap_set_bit(table->write_set, table->timestamp_field->field_index);
}
- if (m_use_partition_function &&
+ if (m_use_partition_pruning &&
(error= get_parts_for_update(old_data, new_data, table->record[0],
m_part_info, &old_part_id, &new_part_id,
&func_value)))
@@ -3040,7 +3045,7 @@
m_ops_pending++;
if (uses_blob_value())
m_blobs_pending= TRUE;
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
cursor->setPartitionId(new_part_id);
}
else
@@ -3049,7 +3054,7 @@
op->updateTuple() != 0)
ERR_RETURN(trans->getNdbError());
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
op->setPartitionId(new_part_id);
if (table_share->primary_key == MAX_KEY)
{
@@ -3088,7 +3093,7 @@
}
dbug_tmp_restore_column_map(table->read_set, old_map);
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
{
if (func_value >= INT_MAX32)
func_value= INT_MAX32;
@@ -3139,7 +3144,7 @@
ha_statistic_increment(&SSV::ha_delete_count);
m_rows_changed++;
- if (m_use_partition_function &&
+ if (m_use_partition_pruning &&
(error= get_part_for_delete(record, table->record[0], m_part_info,
&part_id)))
{
@@ -3161,7 +3166,7 @@
m_lock_tuple= FALSE;
m_ops_pending++;
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
cursor->setPartitionId(part_id);
no_uncommitted_rows_update(-1);
@@ -3186,7 +3191,7 @@
op->deleteTuple() != 0)
ERR_RETURN(trans->getNdbError());
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
op->setPartitionId(part_id);
no_uncommitted_rows_update(-1);
@@ -3579,7 +3584,7 @@
DBUG_ENTER("ha_ndbcluster::read_range_first_to_buf");
DBUG_PRINT("info", ("desc: %d, sorted: %d", desc, sorted));
- if (m_use_partition_function)
+ if (m_use_partition_pruning)
{
get_partition_set(table, buf, active_index, start_key, &part_spec);
DBUG_PRINT("info", ("part_spec.start_part: %u part_spec.end_part: %u",
@@ -3767,7 +3772,7 @@
{
part_id_range part_spec;
uint key_length= ref_length;
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
{
if (table_share->primary_key == MAX_KEY)
{
@@ -3866,7 +3871,7 @@
// No primary key, get hidden key
DBUG_PRINT("info", ("Getting hidden key"));
// If table has user defined partition save the partition id as well
- if(m_use_partition_function)
+ if(m_user_defined_partitioning)
{
DBUG_PRINT("info", ("Saving partition id %u", m_part_id));
key_length= ref_length - sizeof(m_part_id);
@@ -3885,7 +3890,7 @@
memcpy(ref, m_ref, key_length);
}
#ifndef DBUG_OFF
- if (table_share->primary_key == MAX_KEY && m_use_partition_function)
+ if (table_share->primary_key == MAX_KEY && m_user_defined_partitioning)
DBUG_DUMP("key+part", (char*)ref, key_length+sizeof(m_part_id));
#endif
DBUG_DUMP("ref", (char*)ref, key_length);
@@ -6148,7 +6153,8 @@
m_table_flags(HA_NDBCLUSTER_TABLE_FLAGS),
m_share(0),
m_part_info(NULL),
- m_use_partition_function(FALSE),
+ m_use_partition_pruning(FALSE),
+ m_user_defined_partitioning(FALSE),
m_sorted(FALSE),
m_use_write(FALSE),
m_ignore_dup_key(FALSE),
@@ -6275,7 +6281,7 @@
}
else // (table_share->primary_key == MAX_KEY)
{
- if (m_use_partition_function)
+ if (m_user_defined_partitioning)
{
ref_length+= sizeof(m_part_id);
}
@@ -6350,13 +6356,44 @@
Set up partition info when handler object created
*/
-void ha_ndbcluster::set_part_info(partition_info *part_info)
+void ha_ndbcluster::set_part_info(partition_info *part_info, bool early)
{
+ DBUG_ENTER("ha_ndbcluster::set_part_info");
m_part_info= part_info;
- if (!(m_part_info->part_type == HASH_PARTITION &&
+ if (!early)
+ {
+ m_use_partition_pruning= TRUE;
+ if (!(m_part_info->part_type == HASH_PARTITION &&
+ m_part_info->list_of_part_fields &&
+ !m_part_info->is_sub_partitioned()))
+ {
+ /*
+ PARTITION BY HASH, RANGE and LIST plus all subpartitioning variants
+ all use MySQL defined partitioning. PARTITION BY KEY uses NDB native
+ partitioning scheme.
+ */
+ m_user_defined_partitioning= TRUE;
+ }
+ if (m_part_info->part_type == HASH_PARTITION &&
m_part_info->list_of_part_fields &&
- !m_part_info->is_sub_partitioned()))
- m_use_partition_function= TRUE;
+ m_part_info->no_full_part_fields == 0)
+ {
+ /*
+ CREATE TABLE t (....) ENGINE NDB PARTITON BY KEY();
+ where no primary key is defined uses a hidden key as partition field
+ and this makes it impossible to use any partition pruning. Partition
+ pruning requires partitioning based on real fields, also the lack of
+ a primary key means that all accesses to tables are based on either
+ full table scans or index scans and they can never be pruned those
+ scans given that the hidden key is unknown. In write_row, update_row,
+ and delete_row the normal hidden key handling will fix things.
+ */
+ m_use_partition_pruning= FALSE;
+ }
+ DBUG_PRINT("info", ("m_use_partition_pruning = %d",
+ m_use_partition_pruning));
+ }
+ DBUG_VOID_RETURN;
}
/*
@@ -8539,13 +8576,15 @@
const NDBTAB *tab= m_table;
const NDBINDEX *unique_idx= m_index[active_index].unique_index;
const NDBINDEX *idx= m_index[active_index].index;
- const NdbOperation* lastOp= m_active_trans->getLastDefinedOperation();
NdbIndexScanOperation* scanOp= 0;
+ const NdbOperation* lastOp= m_active_trans ?
+ m_active_trans->getLastDefinedOperation() : 0;
for (; multi_range_curr<multi_range_end && curr+reclength <=
end_of_buffer;
multi_range_curr++)
{
part_id_range part_spec;
- if (m_use_partition_function)
+ if (m_user_defined_partitioning ||
+ (m_use_partition_pruning && !m_active_trans))
{
get_partition_set(table, curr, active_index,
&multi_range_curr->start_key,
@@ -8580,7 +8619,7 @@
!op->readTuple(lm) &&
!set_primary_key(op, multi_range_curr->start_key.key) &&
!define_read_attrs(curr, op) &&
- (!m_use_partition_function ||
+ (!m_user_defined_partitioning ||
(op->setPartitionId(part_spec.start_part), TRUE)))
curr += reclength;
else
@@ -9410,6 +9449,39 @@
return (int)reported_frags;
}
+uint32 ha_ndbcluster::calculate_key_hash_value(Field **field_array)
+{
+ Uint32 hash_value;
+ struct Ndb::Key_part_ptr key_data[MAX_REF_PARTS];
+ struct Ndb::Key_part_ptr *key_data_ptr= &key_data[0];
+ Uint32 i= 0;
+ int ret_val;
+ Uint64 tmp[4096];
+ void *buf= (void*)&tmp[0];
+ Ndb *ndb;
+ DBUG_ENTER("ha_ndbcluster::calculate_key_hash_value");
+
+ ndb= check_ndb_in_thd(current_thd);
+ do
+ {
+ Field *field= *field_array;
+ uint len= field->data_length();
+ DBUG_ASSERT(!field->is_real_null());
+ if (field->real_type() == MYSQL_TYPE_VARCHAR)
+ len+= ((Field_varstring*)field)->length_bytes;
+ key_data[i].ptr= field->ptr;
+ key_data[i++].len= len;
+ } while (*(++field_array));
+ key_data[i].ptr= 0;
+ if ((ret_val= ndb->computeHash(&hash_value, m_table,
+ key_data_ptr, buf, sizeof(tmp))))
+ {
+ DBUG_PRINT("info", ("ret_val = %d", ret_val));
+ DBUG_ASSERT(FALSE);
+ abort();
+ }
+ DBUG_RETURN(hash_value);
+}
/*
Set-up auto-partitioning for NDB Cluster
--- 1.181/sql/ha_ndbcluster.h 2007-06-17 19:47:17 +02:00
+++ 1.182/sql/ha_ndbcluster.h 2007-07-04 19:27:29 +02:00
@@ -270,6 +270,7 @@
{ return HA_POS_ERROR; }
int info(uint);
void get_dynamic_partition_info(PARTITION_INFO *stat_info, uint part_id);
+ uint32 calculate_key_hash_value(Field **field_array);
int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size);
int reset();
@@ -284,7 +285,7 @@
int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
int prepare_drop_index(TABLE *table_arg, uint *key_num, uint num_of_keys);
int final_drop_index(TABLE *table_arg);
- void set_part_info(partition_info *part_info);
+ void set_part_info(partition_info *part_info, bool early);
ulong index_flags(uint idx, uint part, bool all_parts) const;
uint max_supported_record_length() const;
uint max_supported_keys() const;
@@ -515,7 +516,8 @@
uint32 m_part_id;
byte *m_rec0;
Field **m_part_field_array;
- bool m_use_partition_function;
+ bool m_user_defined_partitioning;
+ bool m_use_partition_pruning;
bool m_sorted;
bool m_use_write;
bool m_ignore_dup_key;
--- 1.91/sql/ha_partition.cc 2007-04-27 19:03:48 +02:00
+++ 1.92/sql/ha_partition.cc 2007-07-04 19:27:29 +02:00
@@ -3378,15 +3378,18 @@
{
int error;
bool reverse_order= FALSE;
+ bool index_read_flag= !(key == NULL);
uint key_len= calculate_key_len(table, active_index, key, keypart_map);
DBUG_ENTER("ha_partition::common_index_read");
- memcpy((void*)m_start_key.key, key, key_len);
- m_start_key.keypart_map= keypart_map;
- m_start_key.length= key_len;
- m_start_key.flag= find_flag;
-
- if ((error= partition_scan_set_up(buf, TRUE)))
+ if (index_read_flag)
+ {
+ memcpy((void*)m_start_key.key, key, key_len);
+ m_start_key.keypart_map= keypart_map;
+ m_start_key.length= key_len;
+ m_start_key.flag= find_flag;
+ }
+ if ((error= partition_scan_set_up(buf, index_read_flag)))
{
DBUG_RETURN(error);
}
@@ -5193,6 +5196,35 @@
DBUG_ENTER("ha_partition::table_cache_type");
DBUG_RETURN(m_file[0]->table_cache_type());
+}
+
+
+/*
+ Calculate hash value for KEY partitioning using an array of fields.
+
+ SYNOPSIS
+ calculate_key_hash_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.
+*/
+
+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;
}
--- 1.36/sql/ha_partition.h 2007-04-15 18:45:07 +02:00
+++ 1.37/sql/ha_partition.h 2007-07-04 19:27:29 +02:00
@@ -143,7 +143,7 @@
bool is_clone;
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();
@@ -530,7 +530,8 @@
underlying handlers must have the same implementation for it to work.
*/
virtual uint8 table_cache_type();
-
+ /* Calculate hash value for PARTITION BY KEY tables. */
+ uint32 calculate_key_hash_value(Field **field_array);
/*
-------------------------------------------------------------------------
MODULE print messages
--- 1.103/sql/sql_partition.cc 2007-05-15 15:44:39 +02:00
+++ 1.104/sql/sql_partition.cc 2007-07-04 19:27:30 +02:00
@@ -305,7 +305,7 @@
the partition ids of the old and the new record.
SYNOPSIS
- get_part_for_update()
+ get_parts_for_update()
old_data Buffer of old record
new_data Buffer of new record
rec0 Reference to table->record[0]
@@ -1422,13 +1422,14 @@
uint no_parts)
{
uint32 part_id= (uint32)(hash_value & mask);
+ DBUG_ENTER("get_part_id_from_linear_hash");
if (part_id >= no_parts)
{
uint new_mask= ((mask + 1) >> 1) - 1;
part_id= (uint32)(hash_value & new_mask);
}
- return part_id;
+ DBUG_RETURN(part_id);
}
@@ -1679,6 +1680,7 @@
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;
@@ -2217,7 +2219,6 @@
return value;
}
-
/*
The next set of functions are used to calculate the partition identity.
A handler sets up a variable that corresponds to one of these functions
@@ -2230,41 +2231,15 @@
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
- value based on an array of fields. The linear hash variants uses the
+ 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.
+ Handlers can implement their own calculate_key_hash_value function or use the
+ method defined in ha_partition.cc
*/
-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.
@@ -2347,20 +2322,23 @@
SYNOPSIS
get_part_id_key()
+ file Handle to storage engine
field_array Array of fields for PARTTION KEY
no_parts Number of KEY partitions
+ func_value Returns hash value calculated
RETURN VALUE
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 no_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 % no_parts));
}
@@ -2387,7 +2365,7 @@
{
DBUG_ENTER("get_partition_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,
no_parts));
@@ -2556,13 +2534,14 @@
longlong *func_value)
{
int res;
+ DBUG_ENTER("get_part_id_charset_func_subpart");
copy_to_part_field_buffers(part_info->subpart_charset_field_array,
part_info->subpart_field_buffers,
part_info->restore_subpart_field_ptrs);
res= part_info->get_partition_id_charset(part_info, part_id, func_value);
restore_part_field_pointers(part_info->subpart_charset_field_array,
part_info->restore_subpart_field_ptrs);
- return res;
+ DBUG_RETURN(res);
}
@@ -2571,13 +2550,14 @@
longlong *func_value)
{
int res;
+ DBUG_ENTER("get_part_id_charset_func_part");
copy_to_part_field_buffers(part_info->part_charset_field_array,
part_info->part_field_buffers,
part_info->restore_part_field_ptrs);
res= part_info->get_partition_id_charset(part_info, part_id, func_value);
restore_part_field_pointers(part_info->part_charset_field_array,
part_info->restore_part_field_ptrs);
- return res;
+ DBUG_RETURN(res);
}
@@ -2586,13 +2566,14 @@
longlong *func_value)
{
int res;
+ DBUG_ENTER("get_part_id_charset_func_all");
copy_to_part_field_buffers(part_info->full_part_field_array,
part_info->full_part_field_buffers,
part_info->restore_full_part_field_ptrs);
res= part_info->get_partition_id_charset(part_info, part_id, func_value);
restore_part_field_pointers(part_info->full_part_field_array,
part_info->restore_full_part_field_ptrs);
- return res;
+ DBUG_RETURN(res);
}
@@ -2601,6 +2582,7 @@
longlong *func_value)
{
int res;
+ DBUG_ENTER("get_part_part_id_charset_func");
copy_to_part_field_buffers(part_info->part_charset_field_array,
part_info->part_field_buffers,
part_info->restore_part_field_ptrs);
@@ -2608,20 +2590,21 @@
part_id, func_value);
restore_part_field_pointers(part_info->part_charset_field_array,
part_info->restore_part_field_ptrs);
- return res;
+ DBUG_RETURN(res);
}
static uint32 get_subpart_id_charset_func(partition_info *part_info)
{
int res;
+ DBUG_ENTER("get_subpart_id_charset_func");
copy_to_part_field_buffers(part_info->subpart_charset_field_array,
part_info->subpart_field_buffers,
part_info->restore_subpart_field_ptrs);
res= part_info->get_subpartition_id_charset(part_info);
restore_part_field_pointers(part_info->subpart_charset_field_array,
part_info->restore_subpart_field_ptrs);
- return res;
+ DBUG_RETURN(res);
}
@@ -2717,6 +2700,7 @@
bool include_endpoint)
{
uint32 res;
+ DBUG_ENTER("get_list_array_idx_for_endpoint_charset");
copy_to_part_field_buffers(part_info->part_field_array,
part_info->part_field_buffers,
part_info->restore_part_field_ptrs);
@@ -2724,7 +2708,7 @@
include_endpoint);
restore_part_field_pointers(part_info->part_field_array,
part_info->restore_part_field_ptrs);
- return res;
+ DBUG_RETURN(res);
}
uint32 get_list_array_idx_for_endpoint(partition_info *part_info,
@@ -2862,6 +2846,7 @@
bool include_endpoint)
{
uint32 res;
+ DBUG_ENTER("get_partition_id_range_for_endpoint_charset");
copy_to_part_field_buffers(part_info->part_field_array,
part_info->part_field_buffers,
part_info->restore_part_field_ptrs);
@@ -2869,7 +2854,7 @@
include_endpoint);
restore_part_field_pointers(part_info->part_field_array,
part_info->restore_part_field_ptrs);
- return res;
+ DBUG_RETURN(res);
}
uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
@@ -2928,8 +2913,8 @@
int get_partition_id_hash_nosub(partition_info *part_info,
- uint32 *part_id,
- longlong *func_value)
+ uint32 *part_id,
+ longlong *func_value)
{
*part_id= get_part_id_hash(part_info->no_parts, part_info->part_expr,
func_value);
@@ -2938,8 +2923,8 @@
int get_partition_id_linear_hash_nosub(partition_info *part_info,
- uint32 *part_id,
- longlong *func_value)
+ uint32 *part_id,
+ longlong *func_value)
{
*part_id= get_part_id_linear_hash(part_info, part_info->no_parts,
part_info->part_expr, func_value);
@@ -2951,7 +2936,8 @@
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->no_parts, func_value);
return 0;
}
@@ -3031,7 +3017,8 @@
DBUG_RETURN(error);
}
no_subparts= part_info->no_subparts;
- sub_part_id= get_part_id_key(part_info->subpart_field_array,
+ sub_part_id= get_part_id_key(part_info->table->file,
+ part_info->subpart_field_array,
no_subparts, &local_func_value);
*part_id= get_part_id_for_sub(loc_part_id, sub_part_id, no_subparts);
DBUG_RETURN(0);
@@ -3125,7 +3112,8 @@
DBUG_RETURN(error);
}
no_subparts= part_info->no_subparts;
- sub_part_id= get_part_id_key(part_info->subpart_field_array,
+ sub_part_id= get_part_id_key(part_info->table->file,
+ part_info->subpart_field_array,
no_subparts, &local_func_value);
*part_id= get_part_id_for_sub(loc_part_id, sub_part_id, no_subparts);
DBUG_RETURN(0);
@@ -3199,7 +3187,8 @@
uint32 get_partition_id_key_sub(partition_info *part_info)
{
longlong func_value;
- return get_part_id_key(part_info->subpart_field_array,
+ return get_part_id_key(part_info->table->file,
+ part_info->subpart_field_array,
part_info->no_subparts, &func_value);
}
@@ -3509,7 +3498,7 @@
part_spec->start_part= 0;
part_spec->end_part= no_parts - 1;
if ((index < MAX_KEY) &&
- key_spec->flag == (uint)HA_READ_KEY_EXACT &&
+ key_spec && key_spec->flag == (uint)HA_READ_KEY_EXACT &&
part_info->some_fields_in_PF.is_set(index))
{
key_info= table->key_info+index;
@@ -3815,7 +3804,8 @@
}
}
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);
@@ -6698,11 +6688,12 @@
uint flags,
PARTITION_ITERATOR *part_iter)
{
- DBUG_ASSERT(!is_subpart);
Field *field= part_info->part_field_array[0];
uint32 max_endpoint_val;
get_endpoint_func get_endpoint;
uint field_len= field->pack_length_in_rec();
+ DBUG_ENTER("get_part_iter_for_interval_via_mapping");
+ DBUG_ASSERT(!is_subpart);
if (part_info->part_type == RANGE_PARTITION)
{
@@ -6734,7 +6725,7 @@
part_iter->part_nums.start= part_iter->part_nums.end= 0;
part_iter->part_nums.cur= 0;
part_iter->ret_null_part= part_iter->ret_null_part_orig= TRUE;
- return -1;
+ DBUG_RETURN(-1);
}
}
else
@@ -6753,7 +6744,7 @@
{
/* The right bound is X <= NULL, i.e. it is a "X IS NULL" interval */
part_iter->part_nums.end= 0;
- return 1;
+ DBUG_RETURN(1);
}
}
else
@@ -6774,7 +6765,9 @@
part_iter->part_nums.start= get_endpoint(part_info, 1, include_endp);
part_iter->part_nums.cur= part_iter->part_nums.start;
if (part_iter->part_nums.start == max_endpoint_val)
- return 0; /* No partitions */
+ {
+ DBUG_RETURN(0); /* No partitions */
+ }
}
}
@@ -6789,9 +6782,11 @@
part_iter->part_nums.end= get_endpoint(part_info, 0, include_endp);
if (part_iter->part_nums.start == part_iter->part_nums.end &&
!part_iter->ret_null_part)
- return 0; /* No partitions */
+ {
+ DBUG_RETURN(0); /* No partitions */
+ }
}
- return 1; /* Ok, iterator initialized */
+ DBUG_RETURN(1); /* Ok, iterator initialized */
}
@@ -6857,6 +6852,7 @@
Field *field;
uint total_parts;
partition_iter_func get_next_func;
+ DBUG_ENTER("get_part_iter_for_interval_via_walking");
if (is_subpart)
{
field= part_info->subpart_field_array[0];
@@ -6885,7 +6881,7 @@
{
part_id= part_info->get_subpartition_id(part_info);
init_single_partition_iterator(part_id, part_iter);
- return 1; /* Ok, iterator initialized */
+ DBUG_RETURN(1); /* Ok, iterator initialized */
}
else
{
@@ -6897,10 +6893,10 @@
if (!res)
{
init_single_partition_iterator(part_id, part_iter);
- return 1; /* Ok, iterator initialized */
+ DBUG_RETURN(1); /* Ok, iterator initialized */
}
}
- return 0; /* No partitions match */
+ DBUG_RETURN(0); /* No partitions match */
}
if ((field->real_maybe_null() &&
@@ -6908,7 +6904,7 @@
(!(flags & NO_MAX_RANGE) && *max_value))) || // X <? NULL
(flags & (NO_MIN_RANGE | NO_MAX_RANGE))) // -inf at any bound
{
- return -1; /* Can't handle this interval, have to use all partitions */
+ DBUG_RETURN(-1); /* Can't handle this interval, have to use all partitions */
}
/* Get integers for left and right interval bound */
@@ -6927,20 +6923,22 @@
an empty interval by "wrapping around" a + 4G-1 + 1 = a.
*/
if ((ulonglong)b - (ulonglong)a == ~0ULL)
- return -1;
-
+ {
+ DBUG_RETURN(-1);
+ }
a += test(flags & NEAR_MIN);
b += test(!(flags & NEAR_MAX));
ulonglong n_values= b - a;
if (n_values > total_parts || n_values > MAX_RANGE_TO_WALK)
- return -1;
-
+ {
+ DBUG_RETURN(-1);
+ }
part_iter->field_vals.start= part_iter->field_vals.cur= a;
part_iter->field_vals.end= b;
part_iter->part_info= part_info;
part_iter->get_next= get_next_func;
- return 1;
+ DBUG_RETURN(1);
}
--- 1.22/sql/partition_info.h 2007-03-27 19:09:51 +02:00
+++ 1.23/sql/partition_info.h 2007-07-04 19:27:29 +02:00
@@ -160,6 +160,8 @@
partition_element *curr_part_elem;
partition_element *current_partition;
+
+ 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
| Thread |
|---|
| • bk commit into 5.1 tree (mikron:1.2553) BUG#29550 | mikael | 4 Jul |