diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index fc0266b65c1..7ddb2344a0b 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -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; diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h index bb261a1048f..8e6504d1323 100644 --- a/storage/tokudb/ha_tokudb.h +++ b/storage/tokudb/ha_tokudb.h @@ -338,6 +338,8 @@ public: 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);