Commit 009eceee authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #647

implement HA_READ_PREFIX_LAST

git-svn-id: file:///svn/mysql/tokudb-engine/src@6620 c7de825b-a66e-492c-adef-691d508d4ae1
parent 73547bc2
......@@ -983,6 +983,8 @@ static void smart_dbt_callback_rowread(DBT const *key, DBT const *row, void *co
// Smart DBT callback function in c_getf_heavi, in case where we have a covering index,
//
static void smart_dbt_callback_keyread_heavi(DBT const *key, DBT const *row, void *context, int r_h) {
SMART_DBT_INFO info = (SMART_DBT_INFO)context;
info->ha->heavi_ret_val = r_h;
smart_dbt_callback_keyread(key,row,context);
}
......@@ -990,6 +992,8 @@ static void smart_dbt_callback_keyread_heavi(DBT const *key, DBT const *row, vo
// Smart DBT callback function in c_getf_heavi, in case where we do NOT have a covering index
//
static void smart_dbt_callback_rowread_heavi(DBT const *key, DBT const *row, void *context, int r_h) {
SMART_DBT_INFO info = (SMART_DBT_INFO)context;
info->ha->heavi_ret_val = r_h;
smart_dbt_callback_rowread(key,row,context);
}
......@@ -3086,8 +3090,9 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
if (error == 0) {
DBT orig_key;
pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF);
if (tokudb_prefix_cmp_packed_key(share->key_file[active_index], &orig_key, &last_key))
if (tokudb_prefix_cmp_packed_key(share->key_file[active_index], &orig_key, &last_key)) {
error = DB_NOTFOUND;
}
}
break;
case HA_READ_AFTER_KEY: /* Find next rec. after key-record */
......@@ -3116,8 +3121,9 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
if (error == 0) {
DBT orig_key;
pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF);
if (tokudb_prefix_cmp_packed_key(share->key_file[active_index], &orig_key, &last_key) != 0)
if (tokudb_prefix_cmp_packed_key(share->key_file[active_index], &orig_key, &last_key) != 0) {
error = cursor->c_get(cursor, &last_key, &row, DB_PREV);
}
}
else if (error == DB_NOTFOUND)
error = cursor->c_get(cursor, &last_key, &row, DB_LAST);
......@@ -3131,6 +3137,18 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
);
do_read_row = false;
break;
case HA_READ_PREFIX_LAST:
error = cursor->c_getf_heavi(
cursor, 0,
key_read ? smart_dbt_callback_keyread_heavi : smart_dbt_callback_rowread_heavi, &info,
prefix_last_or_prev_heavi, &heavi_info,
-1
);
if (!error && heavi_ret_val != 0) {
error = DB_NOTFOUND;
}
do_read_row = false;
break;
default:
TOKUDB_TRACE("unsupported:%d\n", find_flag);
error = HA_ERR_UNSUPPORTED;
......
......@@ -338,6 +338,8 @@ class ha_tokudb : public handler {
int read_row(uchar * buf, uint keynr, DBT const *row, DBT const *found_key);
void unpack_row(uchar * record, DBT const *row, DBT const *key);
int heavi_ret_val;
private:
int read_full_row(uchar * buf);
int __close(int mutex_is_locked);
......
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