Commit 6a1ef8d9 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1925, make all metadata retrieval from status.tokudb not use DB_DBT_MALLOC

git-svn-id: file:///svn/mysql/tokudb-engine/src@13846 c7de825b-a66e-492c-adef-691d508d4ae1
parent 526e1c83
...@@ -2263,7 +2263,7 @@ int ha_tokudb::get_status() { ...@@ -2263,7 +2263,7 @@ int ha_tokudb::get_status() {
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_USERMEM;
error = db_env->txn_begin(db_env, 0, &txn, 0); error = db_env->txn_begin(db_env, 0, &txn, 0);
if (error) { goto cleanup; } if (error) { goto cleanup; }
...@@ -2272,6 +2272,8 @@ int ha_tokudb::get_status() { ...@@ -2272,6 +2272,8 @@ int ha_tokudb::get_status() {
// //
// get version // get version
// //
value.ulen = sizeof(share->version);
value.data = &share->version;
curr_key = hatoku_version; curr_key = hatoku_version;
error = share->status_block->get( error = share->status_block->get(
share->status_block, share->status_block,
...@@ -2283,18 +2285,18 @@ int ha_tokudb::get_status() { ...@@ -2283,18 +2285,18 @@ int ha_tokudb::get_status() {
if (error == DB_NOTFOUND) { if (error == DB_NOTFOUND) {
share->version = 0; share->version = 0;
} }
else if (error == 0 && value.size == sizeof(share->version)) { else if (error || value.size != sizeof(share->version)) {
share->version = *(uint *)value.data; if (error == 0) {
free(value.data); error = HA_ERR_INTERNAL_ERROR;
value.data = NULL;
} }
else {
goto cleanup; goto cleanup;
} }
// //
// get capabilities // get capabilities
// //
curr_key = hatoku_capabilities; curr_key = hatoku_capabilities;
value.ulen = sizeof(share->capabilities);
value.data = &share->capabilities;
error = share->status_block->get( error = share->status_block->get(
share->status_block, share->status_block,
txn, txn,
...@@ -2305,12 +2307,10 @@ int ha_tokudb::get_status() { ...@@ -2305,12 +2307,10 @@ int ha_tokudb::get_status() {
if (error == DB_NOTFOUND) { if (error == DB_NOTFOUND) {
share->capabilities= 0; share->capabilities= 0;
} }
else if (error == 0 && value.size == sizeof(share->version)) { else if (error || value.size != sizeof(share->version)) {
share->capabilities= *(uint *)value.data; if (error == 0) {
free(value.data); error = HA_ERR_INTERNAL_ERROR;
value.data = NULL;
} }
else {
goto cleanup; goto cleanup;
} }
} }
...@@ -5108,7 +5108,7 @@ void ha_tokudb::init_auto_increment() { ...@@ -5108,7 +5108,7 @@ void ha_tokudb::init_auto_increment() {
bzero(&value, sizeof(value)); bzero(&value, sizeof(value));
key.data = &key_val; key.data = &key_val;
key.size = sizeof(key_val); key.size = sizeof(key_val);
value.flags = DB_DBT_MALLOC; value.flags = DB_DBT_USERMEM;
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
error = db_env->txn_begin(db_env, 0, &txn, 0); error = db_env->txn_begin(db_env, 0, &txn, 0);
...@@ -5121,6 +5121,8 @@ void ha_tokudb::init_auto_increment() { ...@@ -5121,6 +5121,8 @@ void ha_tokudb::init_auto_increment() {
// column so far, the max value could have been auto generated (e.g. insert (NULL)) // column so far, the max value could have been auto generated (e.g. insert (NULL))
// or it could have been manually inserted by user (e.g. insert (345)) // or it could have been manually inserted by user (e.g. insert (345))
// //
value.ulen = sizeof(share->last_auto_increment);
value.data = &share->last_auto_increment;
error = share->status_block->get( error = share->status_block->get(
share->status_block, share->status_block,
txn, txn,
...@@ -5129,12 +5131,7 @@ void ha_tokudb::init_auto_increment() { ...@@ -5129,12 +5131,7 @@ void ha_tokudb::init_auto_increment() {
0 0
); );
if (error == 0 && value.size == sizeof(share->last_auto_increment)) { if (error || value.size != sizeof(share->last_auto_increment)) {
share->last_auto_increment = *(ulonglong *)value.data;
free(value.data);
value.data = NULL;
}
else {
share->last_auto_increment = 0; share->last_auto_increment = 0;
} }
if (is_auto_inc_first_column(&auto_inc_keynr)) { if (is_auto_inc_first_column(&auto_inc_keynr)) {
...@@ -5162,6 +5159,8 @@ void ha_tokudb::init_auto_increment() { ...@@ -5162,6 +5159,8 @@ void ha_tokudb::init_auto_increment() {
// then the value 100 should be stored here // then the value 100 should be stored here
// //
key_val = hatoku_ai_create_value; key_val = hatoku_ai_create_value;
value.ulen = sizeof(share->auto_inc_create_value);
value.data = &share->auto_inc_create_value;
error = share->status_block->get( error = share->status_block->get(
share->status_block, share->status_block,
txn, txn,
...@@ -5170,12 +5169,7 @@ void ha_tokudb::init_auto_increment() { ...@@ -5170,12 +5169,7 @@ void ha_tokudb::init_auto_increment() {
0 0
); );
if (error == 0 && value.size == sizeof(share->auto_inc_create_value)) { if (error || value.size != sizeof(share->auto_inc_create_value)) {
share->auto_inc_create_value = *(ulonglong *)value.data;
free(value.data);
value.data = NULL;
}
else {
share->auto_inc_create_value = 0; share->auto_inc_create_value = 0;
} }
......
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