Commit 9eacbf75 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1716

implement ha_tokudb::index_next_same because handler::index_next_same is broken

git-svn-id: file:///svn/mysql/tokudb-engine/src@11459 c7de825b-a66e-492c-adef-691d508d4ae1
parent 13d4ff49
...@@ -1160,6 +1160,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -1160,6 +1160,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
alloc_ptr = my_multi_malloc(MYF(MY_WME), alloc_ptr = my_multi_malloc(MYF(MY_WME),
&key_buff, max_key_length, &key_buff, max_key_length,
&key_buff2, max_key_length, &key_buff2, max_key_length,
&key_buff3, max_key_length,
&primary_key_buff, (hidden_primary_key ? 0 : max_key_length), &primary_key_buff, (hidden_primary_key ? 0 : max_key_length),
&fixed_cols_for_query, table_share->fields*sizeof(u_int32_t), &fixed_cols_for_query, table_share->fields*sizeof(u_int32_t),
&var_cols_for_query, table_share->fields*sizeof(u_int32_t), &var_cols_for_query, table_share->fields*sizeof(u_int32_t),
...@@ -3215,6 +3216,62 @@ static int before_key_heavi(const DBT *key, const DBT *value, void *extra_h) { ...@@ -3215,6 +3216,62 @@ static int before_key_heavi(const DBT *key, const DBT *value, void *extra_h) {
return (cmp<0) ? -1 : 1; return (cmp<0) ? -1 : 1;
} }
//
// Reads the next row matching to the key, on success, advances cursor
// Parameters:
// [out] buf - buffer for the next row, in MySQL format
// [in] key - key value
// keylen - length of key
// Returns:
// 0 on success
// HA_ERR_END_OF_FILE if not found
// error otherwise
//
int ha_tokudb::index_next_same(uchar * buf, const uchar * key, uint keylen) {
TOKUDB_DBUG_ENTER("ha_tokudb::index_next_same %p", this);
int error;
struct smart_dbt_info info;
DBT curr_key;
DBT found_key;
bool has_null;
int cmp;
HANDLE_INVALID_CURSOR();
statistic_increment(table->in_use->status_var.ha_read_next_count, &LOCK_status);
info.ha = this;
info.buf = buf;
info.keynr = active_index;
pack_key(&curr_key, active_index, key_buff2, key, keylen, COL_NEG_INF);
u_int32_t flags = SET_READ_FLAG(0);
error = handle_cursor_error(cursor->c_getf_next(cursor, flags, SMART_DBT_CALLBACK, &info),HA_ERR_END_OF_FILE,active_index);
if (error) {
goto cleanup;
}
if (!key_read && active_index != primary_key && !(table->key_info[active_index].flags & HA_CLUSTERING)) {
error = read_full_row(buf);
if (error) {
goto cleanup;
}
}
//
// now do the comparison
//
create_dbt_key_from_table(&found_key,active_index,key_buff3,buf,&has_null);
cmp = tokudb_prefix_cmp_dbt_key(share->key_file[active_index], &curr_key, &found_key);
if (cmp) {
error = HA_ERR_END_OF_FILE;
}
cleanup:
TOKUDB_DBUG_RETURN(error);
}
// //
// According to InnoDB handlerton: Positions an index cursor to the index // According to InnoDB handlerton: Positions an index cursor to the index
// specified in keynr. Fetches the row if any // specified in keynr. Fetches the row if any
......
...@@ -133,6 +133,7 @@ class ha_tokudb : public handler { ...@@ -133,6 +133,7 @@ class ha_tokudb : public handler {
// of more than one key // of more than one key
// //
uchar *key_buff2; uchar *key_buff2;
uchar *key_buff3;
// //
// buffer used to temporarily store a "packed key" // buffer used to temporarily store a "packed key"
// data pointer of a DBT will end up pointing to this // data pointer of a DBT will end up pointing to this
...@@ -336,6 +337,7 @@ class ha_tokudb : public handler { ...@@ -336,6 +337,7 @@ class ha_tokudb : public handler {
int prepare_index_scan(); int prepare_index_scan();
int index_init(uint index, bool sorted); int index_init(uint index, bool sorted);
int index_end(); int index_end();
int index_next_same(uchar * buf, const uchar * key, uint keylen);
int index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag); int index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag);
#if 0 #if 0
int index_read_last(uchar * buf, const uchar * key, uint key_len); int index_read_last(uchar * buf, const uchar * key, uint key_len);
......
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