Commit 3ef8c9d2 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #814

some function cleanup

git-svn-id: file:///svn/mysql/tokudb-engine/src@4932 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5bde8933
...@@ -1174,7 +1174,11 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -1174,7 +1174,11 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
} }
share->ref_length = ref_length; share->ref_length = ref_length;
get_status(); error = get_status();
if (error) {
__close(1);
TOKUDB_DBUG_RETURN(1);
}
} }
ref_length = share->ref_length; // If second open ref_length = share->ref_length; // If second open
...@@ -1760,12 +1764,12 @@ void ha_tokudb::init_hidden_prim_key_info() { ...@@ -1760,12 +1764,12 @@ void ha_tokudb::init_hidden_prim_key_info() {
/** @brief /** @brief
Get metadata info stored in status.tokudb Get metadata info stored in status.tokudb
*/ */
void ha_tokudb::get_status() { int ha_tokudb::get_status() {
TOKUDB_DBUG_ENTER("ha_tokudb::get_status"); TOKUDB_DBUG_ENTER("ha_tokudb::get_status");
// DB_TXN* txn = NULL;
// retrieve metadata from status_block DBT key, value;
// HA_METADATA_KEY curr_key;
int error;
// //
// open status.tokudb // open status.tokudb
// //
...@@ -1779,31 +1783,23 @@ void ha_tokudb::get_status() { ...@@ -1779,31 +1783,23 @@ void ha_tokudb::get_status() {
if (tokudb_debug & TOKUDB_DEBUG_OPEN) { if (tokudb_debug & TOKUDB_DEBUG_OPEN) {
TOKUDB_TRACE("open:%s\n", newname); TOKUDB_TRACE("open:%s\n", newname);
} }
if (!db_create(&share->status_block, db_env, 0)) { error = db_create(&share->status_block, db_env, 0);
if (share->status_block->open(share->status_block, NULL, name_buff, NULL, DB_BTREE, open_mode, 0)) { if (error) { goto cleanup; }
share->status_block->close(share->status_block, 0);
share->status_block = NULL; error = share->status_block->open(share->status_block, NULL, name_buff, NULL, DB_BTREE, open_mode, 0);
} if (error) { goto cleanup; }
}
} }
//
// get capabilities and version
//
// //
// transaction to be used for putting metadata into status.tokudb // transaction to be used for putting metadata into status.tokudb
// //
DB_TXN* txn = NULL;
DBT key, value;
HA_METADATA_KEY curr_key;
bzero(&key, sizeof(key)); bzero(&key, sizeof(key));
bzero(&value, sizeof(value)); bzero(&value, sizeof(value));
key.data = &curr_key; key.data = &curr_key;
key.size = sizeof(curr_key); key.size = sizeof(curr_key);
value.flags = DB_DBT_MALLOC; value.flags = DB_DBT_MALLOC;
int error = db_env->txn_begin(db_env, 0, &txn, 0); error = db_env->txn_begin(db_env, 0, &txn, 0);
if (error) { DBUG_VOID_RETURN; } if (error) { goto cleanup; }
if (share->status_block) { if (share->status_block) {
int error; int error;
...@@ -1825,7 +1821,7 @@ void ha_tokudb::get_status() { ...@@ -1825,7 +1821,7 @@ void ha_tokudb::get_status() {
share->version = *(uint *)value.data; share->version = *(uint *)value.data;
} }
else { else {
// error case goto cleanup;
} }
// //
// get capabilities // get capabilities
...@@ -1845,11 +1841,21 @@ void ha_tokudb::get_status() { ...@@ -1845,11 +1841,21 @@ void ha_tokudb::get_status() {
share->capabilities= *(uint *)value.data; share->capabilities= *(uint *)value.data;
} }
else { else {
// error case goto cleanup;
} }
} }
txn->commit(txn,0); error = 0;
DBUG_VOID_RETURN; cleanup:
if (txn) {
txn->commit(txn,0);
}
if (error) {
if (share->status_block) {
share->status_block->close(share->status_block, 0);
share->status_block = NULL;
}
}
TOKUDB_DBUG_RETURN(error);
} }
/** @brief /** @brief
......
...@@ -274,7 +274,7 @@ public: ...@@ -274,7 +274,7 @@ public:
THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to, enum thr_lock_type lock_type); THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to, enum thr_lock_type lock_type);
void get_status(); int get_status();
void init_hidden_prim_key_info(); void init_hidden_prim_key_info();
inline void get_auto_primary_key(uchar * to) { inline void get_auto_primary_key(uchar * to) {
pthread_mutex_lock(&share->mutex); pthread_mutex_lock(&share->mutex);
......
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