Commit d84abe9f 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 890d183f
...@@ -517,7 +517,7 @@ int ha_tokudb::open_secondary_table(DB** ptr, KEY* key_info, const char* name, i ...@@ -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); fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME);
*key_type = key_info->flags & HA_NOSAME ? DB_NOOVERWRITE : DB_YESOVERWRITE; *key_type = key_info->flags & HA_NOSAME ? DB_NOOVERWRITE : DB_YESOVERWRITE;
(*ptr)->app_private = (void *) (key_info); (*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)); 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 ...@@ -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)) { if (!(key_info->flags & HA_CLUSTERING)) {
(*ptr)->set_flags(*ptr, DB_DUP + DB_DUPSORT); (*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; (*ptr)->api_internal = share->file->app_private;
...@@ -676,7 +676,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -676,7 +676,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
else { else {
share->file->app_private = NULL; 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"); make_name(newname, name, "main");
fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME); fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME);
...@@ -1641,11 +1641,12 @@ int ha_tokudb::cmp_ref(const uchar * ref1, const uchar * ref2) { ...@@ -1641,11 +1641,12 @@ int ha_tokudb::cmp_ref(const uchar * ref1, const uchar * ref2) {
} }
key_info = &table->key_info[table_share->primary_key]; key_info = &table->key_info[table_share->primary_key];
ret_val = tokudb_compare_two_keys( ret_val = tokudb_compare_two_keys(
key_info,
ref1 + sizeof(u_int32_t), ref1 + sizeof(u_int32_t),
*(u_int32_t *)ref1, *(u_int32_t *)ref1,
ref2 + sizeof(u_int32_t), ref2 + sizeof(u_int32_t),
*(u_int32_t *)ref2, *(u_int32_t *)ref2,
(uchar *)share->file->descriptor.data + 4,
*(u_int32_t *)share->file->descriptor.data,
false false
); );
exit: exit:
...@@ -2517,7 +2518,7 @@ typedef struct heavi_info { ...@@ -2517,7 +2518,7 @@ typedef struct heavi_info {
// //
static int after_key_heavi(const DBT *key, const DBT *value, void *extra_h) { static int after_key_heavi(const DBT *key, const DBT *value, void *extra_h) {
HEAVI_INFO info = (HEAVI_INFO)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; return cmp>0 ? 1 : -1;
} }
...@@ -2547,7 +2548,7 @@ static int after_key_heavi(const DBT *key, const DBT *value, void *extra_h) { ...@@ -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) { static int prefix_last_or_prev_heavi(const DBT *key, const DBT *value, void *extra_h) {
HEAVI_INFO info = (HEAVI_INFO)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; return cmp;
} }
...@@ -2576,7 +2577,7 @@ static int prefix_last_or_prev_heavi(const DBT *key, const DBT *value, void *ext ...@@ -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) { static int before_key_heavi(const DBT *key, const DBT *value, void *extra_h) {
HEAVI_INFO info = (HEAVI_INFO)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; return (cmp<0) ? -1 : 1;
} }
...@@ -2626,7 +2627,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ ...@@ -2626,7 +2627,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
if (error == 0) { if (error == 0) {
DBT orig_key; DBT orig_key;
pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF); 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; error = DB_NOTFOUND;
} }
} }
...@@ -2661,7 +2662,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ ...@@ -2661,7 +2662,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
if (error == 0) { if (error == 0) {
DBT orig_key; DBT orig_key;
pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF); 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); 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( ...@@ -92,35 +92,22 @@ inline int tokudb_compare_two_hidden_keys(
); );
int tokudb_compare_two_keys( int tokudb_compare_two_keys(
KEY *key,
const void* new_key_data, const void* new_key_data,
const u_int32_t new_key_size, const u_int32_t new_key_size,
const void* saved_key_data, const void* saved_key_data,
const u_int32_t saved_key_size, const u_int32_t saved_key_size,
const void* row_desc,
const u_int32_t row_desc_size,
bool cmp_prefix 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_packed_key(DB *file, const DBT *keya, const DBT *keyb); int tokudb_cmp_dbt_key(DB *file, const DBT *keya, const DBT *keyb);
int tokudb_cmp_primary_key(DB *file, const DBT *keya, const DBT *keyb); int tokudb_cmp_dbt_data(DB *file, const DBT *keya, const DBT *keyb);
//TODO: QQQ Only do one direction for prefix. //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); 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