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

addresses #1619

fix bug in cmp_toku_int
create pack_field and integrate it into create_dbt_key_from_key

git-svn-id: file:///svn/mysql/tokudb-engine/src@10741 c7de825b-a66e-492c-adef-691d508d4ae1
parent 57177ff8
......@@ -1345,15 +1345,19 @@ u_int32_t ha_tokudb::place_key_into_dbt_buff(KEY* key_info, uchar * buff, const
*curr_buff++ = NONNULL_COL_VAL; // Store NOT NULL marker
}
//
// HOPEFULLY TEMPORARY
//
assert(table->s->db_low_byte_first);
//
// accessing field_offset(key_part->field) instead off key_part->offset
// because key_part->offset is SET INCORRECTLY in add_index
// filed ticket 862 to look into this
//
curr_buff = key_part->field->pack_key(
curr_buff,
curr_buff = pack_field(
curr_buff,
(uchar *) (record + field_offset(key_part->field, table)),
key_part->length,
table->s->db_low_byte_first
key_part->field,
key_part->length
);
key_length -= key_part->length;
}
......
......@@ -62,6 +62,44 @@ exit:
}
//
// at the moment, this returns new position in buffer
// I want to change this to be num_bytes_packed
// cannot do it until all functions converted, because until
// then, still relying on field->pack_cmp
//
uchar* pack_field(
uchar* to_tokudb,
uchar* from_mysql,
Field* field,
u_int32_t key_part_length //I really hope this is temporary as I phase out the pack_cmp stuff
)
{
uchar* new_pos = NULL;
TOKU_TYPE toku_type = mysql_to_toku_type(field->type());
switch(toku_type) {
case (toku_type_int):
assert(key_part_length == field->pack_length());
new_pos = pack_toku_int(
to_tokudb,
from_mysql,
field->pack_length()
);
goto exit;
default:
new_pos = field->pack_key(
to_tokudb,
from_mysql,
key_part_length,
TRUE
);
goto exit;
}
assert(false);
exit:
return new_pos;
}
//
// assuming MySQL in little endian, and we are storing in little endian
//
......@@ -73,6 +111,7 @@ uchar* pack_toku_int (uchar* to_tokudb, uchar* from_mysql, u_int32_t num_bytes)
case (4):
case (8):
memcpy(to_tokudb, from_mysql, num_bytes);
break;
default:
assert(false);
}
......@@ -90,6 +129,7 @@ uchar* unpack_toku_int(uchar* to_mysql, uchar* from_tokudb, u_int32_t num_bytes)
case (4):
case (8):
memcpy(to_mysql, from_tokudb, num_bytes);
break;
default:
assert(false);
}
......@@ -108,9 +148,13 @@ int cmp_toku_int (uchar* a_buf, uchar* b_buf, bool is_unsigned, u_int32_t num_by
case (1):
a_num = *a_buf;
b_num = *b_buf;
ret_val = a_num-b_num;
goto exit;
case (2):
a_num = uint2korr(a_buf);
b_num = uint2korr(b_buf);
ret_val = a_num-b_num;
goto exit;
case (3):
a_num = uint3korr(a_buf);
b_num = uint3korr(b_buf);
......@@ -154,9 +198,13 @@ int cmp_toku_int (uchar* a_buf, uchar* b_buf, bool is_unsigned, u_int32_t num_by
case (1):
a_num = *(signed char *)a_buf;
b_num = *(signed char *)b_buf;
ret_val = a_num-b_num;
goto exit;
case (2):
a_num = sint2korr(a_buf);
b_num = sint2korr(b_buf);
ret_val = a_num-b_num;
goto exit;
case (3):
a_num = sint3korr(a_buf);
b_num = sint3korr(b_buf);
......
......@@ -23,6 +23,12 @@ typedef enum {
inline TOKU_TYPE mysql_to_toku_type (enum_field_types mysql_type);
int compare_field(uchar* a_buf, Field* a_field, uchar* b_buf, Field* b_field);
uchar* pack_field(
uchar* to_tokudb,
uchar* from_mysql,
Field* field,
u_int32_t key_part_length //I really hope this is temporary as I phase out the pack_cmp stuff
);
uchar* pack_toku_int (uchar* to_tokudb, uchar* from_mysql, u_int32_t num_bytes);
......
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