Commit 6d242245 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1619

clean up pack and unpack functions a bit before adding more stuff to them

git-svn-id: file:///svn/mysql/tokudb-engine/src@10721 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3ddf25c9
...@@ -1265,8 +1265,7 @@ void ha_tokudb::unpack_row(uchar * record, DBT const *row, DBT const *key, bool ...@@ -1265,8 +1265,7 @@ void ha_tokudb::unpack_row(uchar * record, DBT const *row, DBT const *key, bool
u_int32_t ha_tokudb::place_key_into_mysql_buff(uchar * record, uchar* data, uint index) { u_int32_t ha_tokudb::place_key_into_mysql_buff(KEY* key_info, uchar * record, uchar* data) {
KEY *key_info = table->key_info + index;
KEY_PART_INFO *key_part = key_info->key_part, *end = key_part + key_info->key_parts; KEY_PART_INFO *key_part = key_info->key_part, *end = key_part + key_info->key_parts;
uchar *pos = data; uchar *pos = data;
...@@ -1304,12 +1303,20 @@ u_int32_t ha_tokudb::place_key_into_mysql_buff(uchar * record, uchar* data, uint ...@@ -1304,12 +1303,20 @@ u_int32_t ha_tokudb::place_key_into_mysql_buff(uchar * record, uchar* data, uint
void ha_tokudb::unpack_key(uchar * record, DBT const *key, uint index) { void ha_tokudb::unpack_key(uchar * record, DBT const *key, uint index) {
u_int32_t bytes_read; u_int32_t bytes_read;
uchar *pos = (uchar *) key->data + 1; uchar *pos = (uchar *) key->data + 1;
bytes_read = place_key_into_mysql_buff(record,pos,index); bytes_read = place_key_into_mysql_buff(
&table->key_info[index],
record,
pos
);
if((table->key_info[index].flags & HA_CLUSTERING) && !hidden_primary_key) { if((table->key_info[index].flags & HA_CLUSTERING) && !hidden_primary_key) {
// //
// also unpack primary key // also unpack primary key
// //
place_key_into_mysql_buff(record,pos+bytes_read,primary_key); place_key_into_mysql_buff(
&table->key_info[primary_key],
record,
pos+bytes_read
);
} }
} }
...@@ -1329,8 +1336,7 @@ u_int32_t ha_tokudb::place_key_into_dbt_buff(KEY* key_info, uchar * buff, const ...@@ -1329,8 +1336,7 @@ u_int32_t ha_tokudb::place_key_into_dbt_buff(KEY* key_info, uchar * buff, const
// //
if (key_part->field->null_bit) { if (key_part->field->null_bit) {
/* Store 0 if the key part is a NULL part */ /* Store 0 if the key part is a NULL part */
uint null_offset = (uint) ((char*) key_part->field->null_ptr uint null_offset = get_null_offset(table, key_part->field);
- (char*) table->record[0]);
if (record[null_offset] & key_part->field->null_bit) { if (record[null_offset] & key_part->field->null_bit) {
*curr_buff++ = NULL_COL_VAL; *curr_buff++ = NULL_COL_VAL;
*has_null = true; *has_null = true;
......
...@@ -201,7 +201,7 @@ private: ...@@ -201,7 +201,7 @@ private:
ulong max_row_length(const uchar * buf); ulong max_row_length(const uchar * buf);
int pack_row(DBT * row, const uchar * record, bool strip_pk); int pack_row(DBT * row, const uchar * record, bool strip_pk);
u_int32_t place_key_into_mysql_buff(uchar * record, uchar* data, uint index); u_int32_t place_key_into_mysql_buff(KEY* key_info, uchar * record, uchar* data);
void unpack_key(uchar * record, DBT const *key, uint index); void unpack_key(uchar * record, DBT const *key, uint index);
u_int32_t place_key_into_dbt_buff(KEY* key_info, uchar * buff, const uchar * record, bool* has_null, int key_length); u_int32_t place_key_into_dbt_buff(KEY* key_info, uchar * buff, const uchar * record, bool* has_null, int key_length);
DBT* create_dbt_key_from_key(DBT * key, KEY* key_info, uchar * buff, const uchar * record, bool* has_null, int key_length = MAX_KEY_LENGTH); DBT* create_dbt_key_from_key(DBT * key, KEY* key_info, uchar * buff, const uchar * record, bool* has_null, int key_length = MAX_KEY_LENGTH);
......
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