Commit d37da476 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1852, #1334

prelock ranges that are read in reverse order

git-svn-id: file:///svn/mysql/tokudb-engine/src@13150 c7de825b-a66e-492c-adef-691d508d4ae1
parent d67cf0dd
......@@ -3886,37 +3886,20 @@ int ha_tokudb::rnd_pos(uchar * buf, uchar * pos) {
}
int ha_tokudb::read_range_first(
const key_range *start_key,
const key_range *end_key,
bool eq_range,
bool sorted)
{
int ha_tokudb::prelock_range( const key_range *start_key, const key_range *end_key) {
TOKUDB_DBUG_ENTER("ha_tokudb::read_range_first");
int error;
DBT start_dbt_key;
const DBT* start_dbt_data = NULL;
DBT end_dbt_key;
const DBT* end_dbt_data = NULL;
uchar* start_key_buff = NULL;
uchar* end_key_buff = NULL;
start_key_buff = (uchar *)my_malloc(table_share->max_key_length + MAX_REF_PARTS * 3 + sizeof(uchar), MYF(MY_WME));
if (start_key_buff == NULL) {
error = ENOMEM;
goto cleanup;
}
end_key_buff = (uchar *)my_malloc(table_share->max_key_length + MAX_REF_PARTS * 3 + sizeof(uchar), MYF(MY_WME));
if (end_key_buff == NULL) {
error = ENOMEM;
goto cleanup;
}
uchar* start_key_buff = key_buff2;
uchar* end_key_buff = key_buff3;
bzero((void *) &start_dbt_key, sizeof(start_dbt_key));
bzero((void *) &end_dbt_key, sizeof(end_dbt_key));
range_lock_grabbed = false;
if (start_key) {
switch (start_key->flag) {
case HA_READ_AFTER_KEY:
......@@ -3971,14 +3954,31 @@ int ha_tokudb::read_range_first(
}
goto cleanup;
}
range_lock_grabbed = true;
error = handler::read_range_first(start_key, end_key, eq_range, sorted);
cleanup:
my_free(start_key_buff, MYF(MY_ALLOW_ZERO_PTR));
my_free(end_key_buff, MYF(MY_ALLOW_ZERO_PTR));
TOKUDB_DBUG_RETURN(error);
}
int ha_tokudb::prepare_range_scan( const key_range *start_key, const key_range *end_key) {
return prelock_range(start_key, end_key);
}
int ha_tokudb::read_range_first(
const key_range *start_key,
const key_range *end_key,
bool eq_range,
bool sorted)
{
int error;
error = prelock_range(start_key, end_key);
if (error) { goto cleanup; }
range_lock_grabbed = true;
error = handler::read_range_first(start_key, end_key, eq_range, sorted);
cleanup:
return error;
}
int ha_tokudb::read_range_next()
{
TOKUDB_DBUG_ENTER("ha_tokudb::read_range_next");
......
......@@ -265,6 +265,7 @@ class ha_tokudb : public handler {
);
void set_query_columns(uint keynr);
int prelock_range ( const key_range *start_key, const key_range *end_key);
public:
......@@ -336,6 +337,7 @@ class ha_tokudb : public handler {
int prepare_index_scan();
int prepare_index_key_scan( const uchar * key, uint key_len );
int prepare_range_scan( const key_range *start_key, const key_range *end_key);
void column_bitmaps_signal();
int index_init(uint index, bool sorted);
int index_end();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment