summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2007-01-29 10:40:26 +0100
committerunknown <serg@janus.mylan>2007-01-29 10:40:26 +0100
commit4e8b49d656828fbe2f84d9970a036db644185981 (patch)
treef14bd08181ddd81d2a41f06d9bf0f11d6edf53b5 /sql/ha_partition.cc
parent6e1ba88418887369ca71b49222c6fd66335bbe0c (diff)
downloadmariadb-git-4e8b49d656828fbe2f84d9970a036db644185981.tar.gz
WL#3700: Handler API change: all index search methods - that is,
index_read(), index_read_idx(), index_read_last(), and records_in_range() - instead of 'uint keylen' argument take 'ulonglong keypart_map', a bitmap showing which keyparts are present in the key value. Fallback method is provided for handlers that are lagging behind.
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc55
1 files changed, 14 insertions, 41 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 9d4cd69be12..8b20317d1e7 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -584,7 +584,6 @@ int ha_partition::drop_partitions(const char *path)
List_iterator<partition_element> part_it(m_part_info->partitions);
char part_name_buff[FN_REFLEN];
uint no_parts= m_part_info->partitions.elements;
- uint part_count= 0;
uint no_subparts= m_part_info->no_subparts;
uint i= 0;
uint name_variant;
@@ -1075,7 +1074,6 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
uint no_parts= m_part_info->no_parts;
uint no_subparts= m_part_info->no_subparts;
uint i= 0;
- LEX *lex= thd->lex;
int error;
DBUG_ENTER("ha_partition::handle_opt_partitions");
DBUG_PRINT("enter", ("all_parts %u, flag= %u", all_parts, flag));
@@ -1136,7 +1134,6 @@ int ha_partition::prepare_new_partition(TABLE *table,
{
int error;
bool create_flag= FALSE;
- bool open_flag= FALSE;
DBUG_ENTER("prepare_new_partition");
if ((error= set_up_table_before_create(table, part_name, create_info,
@@ -1245,7 +1242,6 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
handler **new_file_array;
int error= 1;
bool first;
- bool copy_parts= FALSE;
uint temp_partitions= m_part_info->temp_partitions.elements;
THD *thd= current_thd;
DBUG_ENTER("ha_partition::change_partitions");
@@ -2061,7 +2057,6 @@ bool ha_partition::new_handlers_from_part_info(MEM_ROOT *mem_root)
partition_element *part_elem;
uint alloc_len= (m_tot_parts + 1) * sizeof(handler*);
List_iterator_fast <partition_element> part_it(m_part_info->partitions);
- THD *thd= current_thd;
DBUG_ENTER("ha_partition::new_handlers_from_part_info");
if (!(m_file= (handler **) alloc_root(mem_root, alloc_len)))
@@ -3327,13 +3322,14 @@ int ha_partition::index_end()
*/
int ha_partition::index_read(byte * buf, const byte * key,
- uint key_len, enum ha_rkey_function find_flag)
+ ulonglong keypart_map,
+ enum ha_rkey_function find_flag)
{
DBUG_ENTER("ha_partition::index_read");
end_range= 0;
m_index_scan_type= partition_index_read;
- DBUG_RETURN(common_index_read(buf, key, key_len, find_flag));
+ DBUG_RETURN(common_index_read(buf, key, keypart_map, find_flag));
}
@@ -3346,14 +3342,17 @@ int ha_partition::index_read(byte * buf, const byte * key,
see index_read for rest
*/
-int ha_partition::common_index_read(byte *buf, const byte *key, uint key_len,
+int ha_partition::common_index_read(byte *buf, const byte *key,
+ ulonglong keypart_map,
enum ha_rkey_function find_flag)
{
int error;
bool reverse_order= FALSE;
+ 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;
@@ -3482,33 +3481,6 @@ int ha_partition::common_first_last(byte *buf)
/*
- Perform index read using index where always only one row is returned
-
- SYNOPSIS
- index_read_idx()
- see index_read for rest of parameters and return values
-
- DESCRIPTION
- Positions an index cursor to the index specified in key. Fetches the
- row if any. This is only used to read whole keys.
- TODO: Optimise this code to avoid index_init and index_end
-*/
-
-int ha_partition::index_read_idx(byte * buf, uint index, const byte * key,
- uint key_len,
- enum ha_rkey_function find_flag)
-{
- int res;
- DBUG_ENTER("ha_partition::index_read_idx");
-
- index_init(index, 0);
- res= index_read(buf, key, key_len, find_flag);
- index_end();
- DBUG_RETURN(res);
-}
-
-
-/*
Read last using key
SYNOPSIS
@@ -3526,14 +3498,15 @@ int ha_partition::index_read_idx(byte * buf, uint index, const byte * key,
Can only be used on indexes supporting HA_READ_ORDER
*/
-int ha_partition::index_read_last(byte *buf, const byte *key, uint keylen)
+int ha_partition::index_read_last(byte *buf, const byte *key,
+ ulonglong keypart_map)
{
DBUG_ENTER("ha_partition::index_read_last");
m_ordered= TRUE; // Safety measure
end_range= 0;
m_index_scan_type= partition_index_read_last;
- DBUG_RETURN(common_index_read(buf, key, keylen, HA_READ_PREFIX_LAST));
+ DBUG_RETURN(common_index_read(buf, key, keypart_map, HA_READ_PREFIX_LAST));
}
@@ -3679,7 +3652,7 @@ int ha_partition::read_range_first(const key_range *start_key,
m_index_scan_type= partition_index_read;
error= common_index_read(m_rec0,
start_key->key,
- start_key->length, start_key->flag);
+ start_key->keypart_map, start_key->flag);
}
DBUG_RETURN(error);
}
@@ -3878,7 +3851,7 @@ int ha_partition::handle_unordered_scan_next_partition(byte * buf)
case partition_index_read:
DBUG_PRINT("info", ("index_read on partition %d", i));
error= file->index_read(buf, m_start_key.key,
- m_start_key.length,
+ m_start_key.keypart_map,
m_start_key.flag);
break;
case partition_index_first:
@@ -3970,7 +3943,7 @@ int ha_partition::handle_ordered_index_scan(byte *buf, bool reverse_order)
case partition_index_read:
error= file->index_read(rec_buf_ptr,
m_start_key.key,
- m_start_key.length,
+ m_start_key.keypart_map,
m_start_key.flag);
break;
case partition_index_first:
@@ -3984,7 +3957,7 @@ int ha_partition::handle_ordered_index_scan(byte *buf, bool reverse_order)
case partition_index_read_last:
error= file->index_read_last(rec_buf_ptr,
m_start_key.key,
- m_start_key.length);
+ m_start_key.keypart_map);
reverse_order= TRUE;
break;
default: