Commit a95eb950 authored by Rich Prohaska's avatar Rich Prohaska

#200 handle errors when writing cardinality data

parent f7eac23d
......@@ -164,7 +164,9 @@ int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) {
}
}
if (result == HA_ADMIN_OK) {
tokudb::set_card_in_status(share->status_block, txn, total_key_parts, rec_per_key);
int error = tokudb::set_card_in_status(share->status_block, txn, total_key_parts, rec_per_key);
if (error)
result = HA_ADMIN_FAILED;
}
TOKUDB_HANDLER_DBUG_RETURN(result);
}
......
......@@ -508,8 +508,9 @@ bool ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha
if (error == 0 && ctx->expand_blob_update_needed)
error = alter_table_expand_blobs(altered_table, ha_alter_info);
if (error == 0 && ctx->reset_card)
tokudb::set_card_from_status(share->status_block, ctx->alter_txn, table->s, altered_table->s);
if (error == 0 && ctx->reset_card) {
error = tokudb::set_card_from_status(share->status_block, ctx->alter_txn, table->s, altered_table->s);
}
#if (50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50699) || \
(50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799)
......
......@@ -88,6 +88,7 @@ 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;
......@@ -114,7 +115,7 @@ namespace tokudb {
}
// Put the cardinality counters into the status dictionary.
void set_card_in_status(DB *status_db, DB_TXN *txn, uint rec_per_keys, uint64_t rec_per_key[]) {
int set_card_in_status(DB *status_db, DB_TXN *txn, uint rec_per_keys, uint64_t rec_per_key[]) {
// encode cardinality into the buffer
tokudb::buffer b;
size_t s;
......@@ -126,7 +127,7 @@ namespace tokudb {
}
// write cardinality to status
int error = write_to_status(status_db, hatoku_cardinality, b.data(), b.size(), txn);
assert(error == 0);
return error;
}
// Get the cardinality counters from the status dictionary.
......@@ -158,9 +159,9 @@ namespace tokudb {
}
// Delete the cardinality counters from the status dictionary.
void delete_card_from_status(DB *status_db, DB_TXN *txn) {
int delete_card_from_status(DB *status_db, DB_TXN *txn) {
int error = remove_from_status(status_db, hatoku_cardinality, txn);
assert(error == 0);
return error;
}
bool find_index_of_key(const char *key_name, TABLE_SHARE *table_share, uint *index_offset_ptr) {
......@@ -175,7 +176,7 @@ namespace tokudb {
// Altered table cardinality = select cardinality data from current table cardinality for keys that exist
// in the altered table and the current table.
void set_card_from_status(DB *status_db, DB_TXN *txn, TABLE_SHARE *table_share, TABLE_SHARE *altered_table_share) {
int 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
uint table_total_key_parts = tokudb::compute_total_key_parts(table_share);
......@@ -206,9 +207,10 @@ namespace tokudb {
}
}
if (error == 0)
set_card_in_status(status_db, txn, altered_table_total_key_parts, altered_rec_per_key);
error = set_card_in_status(status_db, txn, altered_table_total_key_parts, altered_rec_per_key);
else
delete_card_from_status(status_db, txn);
error = delete_card_from_status(status_db, txn);
return error;
}
// Compute records per key for all key parts of the ith key of the table.
......
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