Commit 25f931c6 authored by Rich Prohaska's avatar Rich Prohaska

#202 allow non-null AND null key index cursor operations (2nd try)

parent 5d2d9bfd
...@@ -2848,7 +2848,7 @@ DBT *ha_tokudb::pack_key( ...@@ -2848,7 +2848,7 @@ DBT *ha_tokudb::pack_key(
int8_t inf_byte int8_t inf_byte
) )
{ {
TOKUDB_HANDLER_DBUG_ENTER("%u null=%u inf=%d", key_length, key_length > 0 ? key_ptr[0] : 0, inf_byte); TOKUDB_HANDLER_DBUG_ENTER("key %p %u:%2.2x inf=%d", key_ptr, key_length, key_length > 0 ? key_ptr[0] : 0, inf_byte);
#if TOKU_INCLUDE_EXTENDED_KEYS #if TOKU_INCLUDE_EXTENDED_KEYS
if (keynr != primary_key && !tokudb_test(hidden_primary_key)) { if (keynr != primary_key && !tokudb_test(hidden_primary_key)) {
DBUG_RETURN(pack_ext_key(key, keynr, buff, key_ptr, key_length, inf_byte)); DBUG_RETURN(pack_ext_key(key, keynr, buff, key_ptr, key_length, inf_byte));
...@@ -4527,7 +4527,6 @@ int ha_tokudb::index_init(uint keynr, bool sorted) { ...@@ -4527,7 +4527,6 @@ int ha_tokudb::index_init(uint keynr, bool sorted) {
remove_from_trx_handler_list(); remove_from_trx_handler_list();
} }
active_index = keynr; active_index = keynr;
index_init_sorted = sorted;
if (active_index < MAX_KEY) { if (active_index < MAX_KEY) {
DBUG_ASSERT(keynr <= table->s->keys); DBUG_ASSERT(keynr <= table->s->keys);
...@@ -4833,9 +4832,11 @@ int ha_tokudb::index_next_same(uchar * buf, const uchar * key, uint keylen) { ...@@ -4833,9 +4832,11 @@ int ha_tokudb::index_next_same(uchar * buf, const uchar * key, uint keylen) {
// error otherwise // error otherwise
// //
int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag) { int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag) {
TOKUDB_HANDLER_DBUG_ENTER("%p %u null=%u find=%u", key, key_len, key ? key[0] : 0, find_flag); TOKUDB_HANDLER_DBUG_ENTER("key %p %u:%2.2x find=%u", key, key_len, key ? key[0] : 0, find_flag);
invalidate_bulk_fetch(); invalidate_bulk_fetch();
// TOKUDB_DBUG_DUMP("key=", key, key_len); if (tokudb_debug & TOKUDB_DEBUG_INDEX_KEY) {
TOKUDB_DBUG_DUMP("mysql key=", key, key_len);
}
DBT row; DBT row;
DBT lookup_key; DBT lookup_key;
int error = 0; int error = 0;
...@@ -4847,11 +4848,10 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ ...@@ -4847,11 +4848,10 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
HANDLE_INVALID_CURSOR(); HANDLE_INVALID_CURSOR();
// if we locked a non-null key range and we now have a null key, then get a new cursor without any bounds on the cursor's key range // if we locked a non-null key range and we now have a null key, then remove the bounds from the cursor
if (range_lock_grabbed && !range_lock_grabbed_null && index_key_is_null(table, tokudb_active_index, key, key_len)) { if (range_lock_grabbed && !range_lock_grabbed_null && index_key_is_null(table, tokudb_active_index, key, key_len)) {
error = index_init(active_index, index_init_sorted); range_lock_grabbed = range_lock_grabbed_null = false;
if (error) cursor->c_remove_restriction(cursor);
goto cleanup;
} }
ha_statistic_increment(&SSV::ha_read_key_count); ha_statistic_increment(&SSV::ha_read_key_count);
...@@ -4868,10 +4868,11 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ ...@@ -4868,10 +4868,11 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
switch (find_flag) { switch (find_flag) {
case HA_READ_KEY_EXACT: /* Find first record else error */ case HA_READ_KEY_EXACT: /* Find first record else error */
pack_key(&lookup_key, tokudb_active_index, key_buff3, key, key_len, COL_NEG_INF); pack_key(&lookup_key, tokudb_active_index, key_buff3, key, key_len, COL_NEG_INF);
if (tokudb_debug & TOKUDB_DEBUG_INDEX_KEY) {
TOKUDB_DBUG_DUMP("tokudb key=", lookup_key.data, lookup_key.size);
}
ir_info.orig_key = &lookup_key; ir_info.orig_key = &lookup_key;
error = cursor->c_getf_set_range(cursor, flags, &lookup_key, SMART_DBT_IR_CALLBACK(key_read), &ir_info);
error = cursor->c_getf_set_range(cursor, flags,
&lookup_key, SMART_DBT_IR_CALLBACK(key_read), &ir_info);
if (ir_info.cmp) { if (ir_info.cmp) {
error = DB_NOTFOUND; error = DB_NOTFOUND;
} }
......
...@@ -494,7 +494,6 @@ class ha_tokudb : public handler { ...@@ -494,7 +494,6 @@ class ha_tokudb : public handler {
// 0 <= active_index < table_share->keys || active_index == MAX_KEY // 0 <= active_index < table_share->keys || active_index == MAX_KEY
// tokudb_active_index = active_index if active_index < table_share->keys, else tokudb_active_index = primary_key = table_share->keys // tokudb_active_index = active_index if active_index < table_share->keys, else tokudb_active_index = primary_key = table_share->keys
uint tokudb_active_index; uint tokudb_active_index;
bool index_init_sorted;
public: public:
ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg); ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg);
......
...@@ -237,6 +237,7 @@ extern ulong tokudb_debug; ...@@ -237,6 +237,7 @@ extern ulong tokudb_debug;
#define TOKUDB_DEBUG_ERROR 16 #define TOKUDB_DEBUG_ERROR 16
#define TOKUDB_DEBUG_TXN 32 #define TOKUDB_DEBUG_TXN 32
#define TOKUDB_DEBUG_AUTO_INCREMENT 64 #define TOKUDB_DEBUG_AUTO_INCREMENT 64
#define TOKUDB_DEBUG_INDEX_KEY 128
#define TOKUDB_DEBUG_LOCK 256 #define TOKUDB_DEBUG_LOCK 256
#define TOKUDB_DEBUG_CHECK_KEY 1024 #define TOKUDB_DEBUG_CHECK_KEY 1024
#define TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS 2048 #define TOKUDB_DEBUG_HIDE_DDL_LOCK_ERRORS 2048
......
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