Commit 477163bf authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1400

abstract the conversion functions of the hidden primary key

git-svn-id: file:///svn/mysql/tokudb-engine/src@10665 c7de825b-a66e-492c-adef-691d508d4ae1
parent c694757d
......@@ -224,8 +224,8 @@ ulong ha_tokudb::index_flags(uint idx, uint part, bool all_parts) const {
static int tokudb_cmp_hidden_key(DB * file, const DBT * new_key, const DBT * saved_key) {
ulonglong a = uint8korr((char *) new_key->data);
ulonglong b = uint8korr((char *) saved_key->data);
ulonglong a = hpk_char_to_num((uchar *) new_key->data);
ulonglong b = hpk_char_to_num((uchar *) saved_key->data);
return a < b ? -1 : (a > b ? 1 : 0);
}
......@@ -357,8 +357,8 @@ static int tokudb_compare_two_clustered_keys(KEY *key, KEY* primary_key, const D
//
// primary key hidden
//
ulonglong a = uint8korr((char *) new_key_ptr);
ulonglong b = uint8korr((char *) saved_key_ptr);
ulonglong a = hpk_char_to_num((uchar *) new_key_ptr);
ulonglong b = hpk_char_to_num((uchar *) saved_key_ptr);
ret_val = a < b ? -1 : (a > b ? 1 : 0);
}
else {
......@@ -1738,7 +1738,7 @@ void ha_tokudb::init_hidden_prim_key_info() {
int error = read_last();
(void) extra(HA_EXTRA_NO_KEYREAD);
if (error == 0) {
share->auto_ident = uint8korr(current_ident);
share->auto_ident = hpk_char_to_num(current_ident);
}
share->status |= STATUS_PRIMARY_KEY_INIT;
......
......@@ -46,6 +46,26 @@ typedef struct st_tokudb_share {
uint ai_field_index;
} TOKUDB_SHARE;
//
// information for hidden primary keys
//
#define TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH 8
//
// function to convert a hidden primary key into a byte stream that can be stored in DBT
//
inline void hpk_num_to_char(uchar* to, ulonglong num) {
int8store(to, num);
}
//
// function that takes a byte stream of a hidden primary key and returns a ulonglong
//
inline ulonglong hpk_char_to_num(uchar* val) {
return uint8korr(val);
}
#define HA_TOKU_VERSION 2
//
// no capabilities yet
......@@ -208,7 +228,6 @@ private:
char write_status_msg[200]; //buffer of 200 should be a good upper bound.
bool fix_rec_buff_for_blob(ulong length);
#define TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH 8
uchar current_ident[TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH];
ulong max_row_length(const uchar * buf);
......@@ -344,7 +363,7 @@ public:
inline void get_auto_primary_key(uchar * to) {
pthread_mutex_lock(&share->mutex);
share->auto_ident++;
int8store(to, share->auto_ident);
hpk_num_to_char(to, share->auto_ident);
pthread_mutex_unlock(&share->mutex);
}
virtual void get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong * first_value, ulonglong * nb_reserved_values);
......
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