Commit 29b0f170 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1567, #1569

fix row descriptor for clustering keys to not include infinity byte for
second key, add comparison functions

git-svn-id: file:///svn/mysql/tokudb-engine/src@10980 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4c05646c
......@@ -517,7 +517,7 @@ int ha_tokudb::open_secondary_table(DB** ptr, KEY* key_info, const char* name, i
fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME);
*key_type = key_info->flags & HA_NOSAME ? DB_NOOVERWRITE : DB_YESOVERWRITE;
(*ptr)->app_private = (void *) (key_info);
(*ptr)->set_bt_compare(*ptr, tokudb_cmp_packed_key);
(*ptr)->set_bt_compare(*ptr, tokudb_cmp_dbt_key);
DBUG_PRINT("info", ("Setting DB_DUP+DB_DUPSORT for key %s\n", key_info->name));
//
......@@ -525,7 +525,7 @@ int ha_tokudb::open_secondary_table(DB** ptr, KEY* key_info, const char* name, i
//
if (!(key_info->flags & HA_CLUSTERING)) {
(*ptr)->set_flags(*ptr, DB_DUP + DB_DUPSORT);
(*ptr)->set_dup_compare(*ptr, hidden_primary_key ? tokudb_cmp_hidden_key : tokudb_cmp_primary_key);
(*ptr)->set_dup_compare(*ptr, tokudb_cmp_dbt_data);
}
(*ptr)->api_internal = share->file->app_private;
......@@ -676,7 +676,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
else {
share->file->app_private = NULL;
}
share->file->set_bt_compare(share->file, (hidden_primary_key ? tokudb_cmp_hidden_key : tokudb_cmp_packed_key));
share->file->set_bt_compare(share->file, tokudb_cmp_dbt_key);
make_name(newname, name, "main");
fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME);
......@@ -1641,11 +1641,12 @@ int ha_tokudb::cmp_ref(const uchar * ref1, const uchar * ref2) {
}
key_info = &table->key_info[table_share->primary_key];
ret_val = tokudb_compare_two_keys(
key_info,
ref1 + sizeof(u_int32_t),
*(u_int32_t *)ref1,
ref2 + sizeof(u_int32_t),
*(u_int32_t *)ref2,
(uchar *)share->file->descriptor.data + 4,
*(u_int32_t *)share->file->descriptor.data,
false
);
exit:
......@@ -2517,7 +2518,7 @@ typedef struct heavi_info {
//
static int after_key_heavi(const DBT *key, const DBT *value, void *extra_h) {
HEAVI_INFO info = (HEAVI_INFO)extra_h;
int cmp = tokudb_prefix_cmp_packed_key(info->db, key, info->key);
int cmp = tokudb_prefix_cmp_dbt_key(info->db, key, info->key);
return cmp>0 ? 1 : -1;
}
......@@ -2547,7 +2548,7 @@ static int after_key_heavi(const DBT *key, const DBT *value, void *extra_h) {
//
static int prefix_last_or_prev_heavi(const DBT *key, const DBT *value, void *extra_h) {
HEAVI_INFO info = (HEAVI_INFO)extra_h;
int cmp = tokudb_prefix_cmp_packed_key(info->db, key, info->key);
int cmp = tokudb_prefix_cmp_dbt_key(info->db, key, info->key);
return cmp;
}
......@@ -2576,7 +2577,7 @@ static int prefix_last_or_prev_heavi(const DBT *key, const DBT *value, void *ext
//
static int before_key_heavi(const DBT *key, const DBT *value, void *extra_h) {
HEAVI_INFO info = (HEAVI_INFO)extra_h;
int cmp = tokudb_prefix_cmp_packed_key(info->db, key, info->key);
int cmp = tokudb_prefix_cmp_dbt_key(info->db, key, info->key);
return (cmp<0) ? -1 : 1;
}
......@@ -2626,7 +2627,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
if (error == 0) {
DBT orig_key;
pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF);
if (tokudb_prefix_cmp_packed_key(share->key_file[active_index], &orig_key, &last_key)) {
if (tokudb_prefix_cmp_dbt_key(share->key_file[active_index], &orig_key, &last_key)) {
error = DB_NOTFOUND;
}
}
......@@ -2661,7 +2662,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
if (error == 0) {
DBT orig_key;
pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF);
if (tokudb_prefix_cmp_packed_key(share->key_file[active_index], &orig_key, &last_key) != 0) {
if (tokudb_prefix_cmp_dbt_key(share->key_file[active_index], &orig_key, &last_key) != 0) {
error = cursor->c_get(cursor, &last_key, &row, DB_PREV);
}
}
......
This diff is collapsed.
......@@ -92,35 +92,22 @@ inline int tokudb_compare_two_hidden_keys(
);
int tokudb_compare_two_keys(
KEY *key,
const void* new_key_data,
const u_int32_t new_key_size,
const void* saved_key_data,
const u_int32_t saved_key_size,
const void* row_desc,
const u_int32_t row_desc_size,
bool cmp_prefix
);
int tokudb_cmp_hidden_key(
DB* file,
const DBT* new_key,
const DBT* saved_key
);
int tokudb_compare_two_clustered_keys(
KEY *key,
KEY* primary_key,
const DBT * new_key,
const DBT * saved_key
);
int tokudb_cmp_dbt_key(DB *file, const DBT *keya, const DBT *keyb);
int tokudb_cmp_packed_key(DB *file, const DBT *keya, const DBT *keyb);
int tokudb_cmp_dbt_data(DB *file, const DBT *keya, const DBT *keyb);
int tokudb_cmp_primary_key(DB *file, const DBT *keya, const DBT *keyb);
//TODO: QQQ Only do one direction for prefix.
int tokudb_prefix_cmp_packed_key(DB *file, const DBT *keya, const DBT *keyb);
int tokudb_prefix_cmp_dbt_key(DB *file, const DBT *keya, const DBT *keyb);
int create_toku_key_descriptor(KEY* key, uchar* buf);
......
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