diff options
author | Rich Prohaska <prohaska@tokutek.com> | 2014-02-13 20:13:36 -0500 |
---|---|---|
committer | Rich Prohaska <prohaska@tokutek.com> | 2014-02-13 20:13:36 -0500 |
commit | a8ca3e2ab3a47ee93e1a7f88d14aae7a3b534a96 (patch) | |
tree | f395c88f410aa6da77c85969cd13df6b4279e1ea /storage/tokudb | |
parent | 4d04076ced98db0546256f6c2f403740415ca96c (diff) | |
download | mariadb-git-a8ca3e2ab3a47ee93e1a7f88d14aae7a3b534a96.tar.gz |
#184 fix mismatch between table_share->key_parts and the number really there. mysql increments key_parts for the extended keys.
Diffstat (limited to 'storage/tokudb')
-rw-r--r-- | storage/tokudb/ha_tokudb.cc | 17 | ||||
-rw-r--r-- | storage/tokudb/ha_tokudb_admin.cc | 16 | ||||
-rw-r--r-- | storage/tokudb/tokudb_card.h | 19 |
3 files changed, 33 insertions, 19 deletions
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index 8b0d8523057..b7bb36ea533 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -5944,14 +5944,15 @@ int ha_tokudb::info(uint flag) { } if ((flag & HA_STATUS_CONST)) { stats.max_data_file_length= 9223372036854775807ULL; - uint64_t rec_per_key[table_share->key_parts]; - error = tokudb::get_card_from_status(share->status_block, txn, table_share->key_parts, rec_per_key); + uint total_key_parts = tokudb::compute_total_key_parts(table_share); + uint64_t rec_per_key[total_key_parts]; + error = tokudb::get_card_from_status(share->status_block, txn, total_key_parts, rec_per_key); if (error == 0) { - tokudb::set_card_in_key_info(table, table_share->key_parts, rec_per_key); + tokudb::set_card_in_key_info(table, total_key_parts, rec_per_key); } else { - for (uint i = 0; i < table_share->key_parts; i++) + for (uint i = 0; i < total_key_parts; i++) rec_per_key[i] = 0; - tokudb::set_card_in_key_info(table, table_share->key_parts, rec_per_key); + tokudb::set_card_in_key_info(table, total_key_parts, rec_per_key); } } /* Don't return key if we got an error for the internal primary key */ @@ -6155,10 +6156,12 @@ static const char *lock_type_str(int lock_type) { // int ha_tokudb::external_lock(THD * thd, int lock_type) { TOKUDB_HANDLER_DBUG_ENTER("cmd %d lock %d %s %s", thd_sql_command(thd), lock_type, lock_type_str(lock_type), share->table_name); - if (tokudb_debug & TOKUDB_DEBUG_LOCK) + if (!(tokudb_debug & TOKUDB_DEBUG_ENTER) && (tokudb_debug & TOKUDB_DEBUG_LOCK)) { TOKUDB_HANDLER_TRACE("cmd %d lock %d %s %s", thd_sql_command(thd), lock_type, lock_type_str(lock_type), share->table_name); - if (0) + } + if (tokudb_debug & TOKUDB_DEBUG_LOCK) { TOKUDB_HANDLER_TRACE("q %s", thd->query()); + } int error = 0; tokudb_trx_data *trx = NULL; diff --git a/storage/tokudb/ha_tokudb_admin.cc b/storage/tokudb/ha_tokudb_admin.cc index 94f817fe66f..97e75f6cb8d 100644 --- a/storage/tokudb/ha_tokudb_admin.cc +++ b/storage/tokudb/ha_tokudb_admin.cc @@ -131,10 +131,11 @@ int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) { uint64_t rec_per_key[table_share->key_parts]; int result = HA_ADMIN_OK; DB_TXN *txn = transaction; - if (!txn) + if (!txn) { result = HA_ADMIN_FAILED; + } + uint total_key_parts = 0; if (result == HA_ADMIN_OK) { - uint next_key_part = 0; // compute cardinality for each key for (uint i = 0; result == HA_ADMIN_OK && i < table_share->keys; i++) { KEY *key_info = &table_share->key_info[i]; @@ -146,7 +147,7 @@ int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) { bool is_unique = false; if (i == primary_key || (key_info->flags & HA_NOSAME)) is_unique = true; - int error = tokudb::analyze_card(share->key_file[i], txn, is_unique, num_key_parts, &rec_per_key[next_key_part], + int error = tokudb::analyze_card(share->key_file[i], txn, is_unique, num_key_parts, &rec_per_key[total_key_parts], tokudb_cmp_dbt_key_parts, analyze_progress, &analyze_progress_extra); if (error != 0 && error != ETIME) { result = HA_ADMIN_FAILED; @@ -156,14 +157,15 @@ int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) { TOKUDB_HANDLER_TRACE("%s.%s.%s", table_share->db.str, table_share->table_name.str, i == primary_key ? "primary" : table_share->key_info[i].name); for (uint j = 0; j < num_key_parts; j++) - TOKUDB_HANDLER_TRACE("%lu", rec_per_key[next_key_part+j]); + TOKUDB_HANDLER_TRACE("%lu", rec_per_key[total_key_parts+j]); } } - next_key_part += num_key_parts; + total_key_parts += num_key_parts; } } - if (result == HA_ADMIN_OK) - tokudb::set_card_in_status(share->status_block, txn, table_share->key_parts, rec_per_key); + if (result == HA_ADMIN_OK) { + tokudb::set_card_in_status(share->status_block, txn, total_key_parts, rec_per_key); + } TOKUDB_HANDLER_DBUG_RETURN(result); } diff --git a/storage/tokudb/tokudb_card.h b/storage/tokudb/tokudb_card.h index d609ad71ee2..c22ae9b9c17 100644 --- a/storage/tokudb/tokudb_card.h +++ b/storage/tokudb/tokudb_card.h @@ -89,6 +89,13 @@ PATENT RIGHTS GRANT: #ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved." #ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it." namespace tokudb { + uint compute_total_key_parts(TABLE_SHARE *table_share) { + uint total_key_parts = 0; + for (uint i = 0; i < table_share->keys; i++) { + total_key_parts += get_key_parts(&table_share->key_info[i]); + } + return total_key_parts; + } // Set the key_info cardinality counters for the table. void set_card_in_key_info(TABLE *table, uint rec_per_keys, uint64_t rec_per_key[]) { @@ -171,11 +178,13 @@ namespace tokudb { void set_card_from_status(DB *status_db, DB_TXN *txn, TABLE_SHARE *table_share, TABLE_SHARE *altered_table_share) { int error; // read existing cardinality data from status - uint64_t rec_per_key[table_share->key_parts]; - error = get_card_from_status(status_db, txn, table_share->key_parts, rec_per_key); + uint table_total_key_parts = tokudb::compute_total_key_parts(table_share); + uint64_t rec_per_key[table_total_key_parts]; + error = get_card_from_status(status_db, txn, table_total_key_parts, rec_per_key); // set altered records per key to unknown - uint64_t altered_rec_per_key[altered_table_share->key_parts]; - for (uint i = 0; i < altered_table_share->key_parts; i++) + uint altered_table_total_key_parts = tokudb::compute_total_key_parts(altered_table_share); + uint64_t altered_rec_per_key[altered_table_total_key_parts]; + for (uint i = 0; i < altered_table_total_key_parts; i++) altered_rec_per_key[i] = 0; // compute the beginning of the key offsets in the original table uint orig_key_offset[table_share->keys]; @@ -197,7 +206,7 @@ namespace tokudb { } } if (error == 0) - set_card_in_status(status_db, txn, altered_table_share->key_parts, altered_rec_per_key); + set_card_in_status(status_db, txn, altered_table_total_key_parts, altered_rec_per_key); else delete_card_from_status(status_db, txn); } |