Commit 5bde8933 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #814

little bit of cleaning up

git-svn-id: file:///svn/mysql/tokudb-engine/src@4931 c7de825b-a66e-492c-adef-691d508d4ae1
parent 8cd2f2b5
...@@ -1029,6 +1029,9 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -1029,6 +1029,9 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
uint max_key_length; uint max_key_length;
int error; int error;
transaction = NULL;
cursor = NULL;
if (tokudb_init_flags & DB_INIT_TXN) if (tokudb_init_flags & DB_INIT_TXN)
open_flags += DB_AUTO_COMMIT; open_flags += DB_AUTO_COMMIT;
...@@ -1166,19 +1169,21 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -1166,19 +1169,21 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
share->fixed_length_primary_key = (ref_length == table->key_info[primary_key].key_length); share->fixed_length_primary_key = (ref_length == table->key_info[primary_key].key_length);
share->status |= STATUS_PRIMARY_KEY_INIT; share->status |= STATUS_PRIMARY_KEY_INIT;
} }
else {
init_hidden_prim_key_info();
}
share->ref_length = ref_length; share->ref_length = ref_length;
get_status();
} }
ref_length = share->ref_length; // If second open ref_length = share->ref_length; // If second open
pthread_mutex_unlock(&share->mutex); pthread_mutex_unlock(&share->mutex);
transaction = NULL;
cursor = NULL;
key_read = false; key_read = false;
stats.block_size = 1<<20; // QQQ Tokudb DB block size stats.block_size = 1<<20; // QQQ Tokudb DB block size
share->fixed_length_row = !(table_share->db_create_options & HA_OPTION_PACK_RECORD); share->fixed_length_row = !(table_share->db_create_options & HA_OPTION_PACK_RECORD);
// QQQ what happens if get_status fails
get_status();
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
TOKUDB_DBUG_RETURN(0); TOKUDB_DBUG_RETURN(0);
...@@ -1722,14 +1727,11 @@ int ha_tokudb::read_last() { ...@@ -1722,14 +1727,11 @@ int ha_tokudb::read_last() {
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
/** @brief //
Get status information that is stored in the 'status' sub database // get max used hidden primary key value
and the max used value for the hidden primary key. //
*/ void ha_tokudb::init_hidden_prim_key_info() {
void ha_tokudb::get_status() { TOKUDB_DBUG_ENTER("ha_tokudb::init_prim_key_info");
TOKUDB_DBUG_ENTER("ha_tokudb::get_status");
pthread_mutex_lock(&share->mutex);
if (!(share->status & STATUS_PRIMARY_KEY_INIT)) { if (!(share->status & STATUS_PRIMARY_KEY_INIT)) {
(void) extra(HA_EXTRA_KEYREAD); (void) extra(HA_EXTRA_KEYREAD);
int error = read_last(); int error = read_last();
...@@ -1749,8 +1751,17 @@ void ha_tokudb::get_status() { ...@@ -1749,8 +1751,17 @@ void ha_tokudb::get_status() {
} }
share->status |= STATUS_PRIMARY_KEY_INIT; share->status |= STATUS_PRIMARY_KEY_INIT;
} }
DBUG_VOID_RETURN;
}
/** @brief
Get metadata info stored in status.tokudb
*/
void ha_tokudb::get_status() {
TOKUDB_DBUG_ENTER("ha_tokudb::get_status");
// //
// retrieve metadata from status_block // retrieve metadata from status_block
// //
...@@ -1838,7 +1849,6 @@ void ha_tokudb::get_status() { ...@@ -1838,7 +1849,6 @@ void ha_tokudb::get_status() {
} }
} }
txn->commit(txn,0); txn->commit(txn,0);
pthread_mutex_unlock(&share->mutex);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -3541,7 +3551,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -3541,7 +3551,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
} }
/* Create the status block to save information from last status command */ /* Create status.tokudb and save relevant metadata */
DB *status_block = NULL; DB *status_block = NULL;
if (!(error = (db_create(&status_block, db_env, 0)))) { if (!(error = (db_create(&status_block, db_env, 0)))) {
make_name(newname, name, "status"); make_name(newname, name, "status");
......
...@@ -275,6 +275,7 @@ public: ...@@ -275,6 +275,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(); void get_status();
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);
share->auto_ident++; share->auto_ident++;
......
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