Commit b207cfc7 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:3400], fix a memory leak

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@30230 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7b16d5c1
...@@ -2044,23 +2044,28 @@ int ha_tokudb::write_frm_data(DB* db, DB_TXN* txn, const char* frm_name) { ...@@ -2044,23 +2044,28 @@ int ha_tokudb::write_frm_data(DB* db, DB_TXN* txn, const char* frm_name) {
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
static int
smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) {
DBT* stored_frm = (DBT *)context;
stored_frm->size = row->size;
stored_frm->data = row->data;
return 0;
}
int ha_tokudb::verify_frm_data(const char* frm_name) { int ha_tokudb::verify_frm_data(const char* frm_name) {
uchar* mysql_frm_data = NULL; uchar* mysql_frm_data = NULL;
size_t mysql_frm_len = 0; size_t mysql_frm_len = 0;
uchar* stored_frm_data = NULL; DBT key, stored_frm;
size_t stored_frm_len = 0;
DBT key, value;
int error = 0; int error = 0;
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
HA_METADATA_KEY curr_key = hatoku_frm_data; HA_METADATA_KEY curr_key = hatoku_frm_data;
TOKUDB_DBUG_ENTER("ha_tokudb::verify_frm_data %s", frm_name); TOKUDB_DBUG_ENTER("ha_tokudb::verify_frm_data %s", frm_name);
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; }
bzero(&key, sizeof(key)); bzero(&key, sizeof(key));
bzero(&value, sizeof(value)); bzero(&stored_frm, sizeof(&stored_frm));
// get the frm data from MySQL // get the frm data from MySQL
error = readfrm(frm_name,&mysql_frm_data,&mysql_frm_len); error = readfrm(frm_name,&mysql_frm_data,&mysql_frm_len);
if (error) { goto cleanup; } if (error) { goto cleanup; }
...@@ -2068,13 +2073,13 @@ int ha_tokudb::verify_frm_data(const char* frm_name) { ...@@ -2068,13 +2073,13 @@ int ha_tokudb::verify_frm_data(const char* frm_name) {
// TODO: get the frm data that we have stored // TODO: get the frm data that we have stored
key.data = &curr_key; key.data = &curr_key;
key.size = sizeof(curr_key); key.size = sizeof(curr_key);
value.flags = DB_DBT_MALLOC; error = share->status_block->getf_set(
error = share->status_block->get(
share->status_block, share->status_block,
txn, txn,
0,
&key, &key,
&value, smart_dbt_callback_verify_frm,
0 &stored_frm
); );
if (error == DB_NOTFOUND) { if (error == DB_NOTFOUND) {
// if not found, write it // if not found, write it
...@@ -2088,11 +2093,9 @@ int ha_tokudb::verify_frm_data(const char* frm_name) { ...@@ -2088,11 +2093,9 @@ int ha_tokudb::verify_frm_data(const char* frm_name) {
else if (error) { else if (error) {
goto cleanup; goto cleanup;
} }
stored_frm_len = value.size;
stored_frm_data = (uchar *)value.data;
if (stored_frm_len != mysql_frm_len || if (stored_frm.size != mysql_frm_len ||
memcmp(stored_frm_data, mysql_frm_data, stored_frm_len)) memcmp(stored_frm.data, mysql_frm_data, stored_frm.size))
{ {
error = HA_ERR_TABLE_DEF_CHANGED; error = HA_ERR_TABLE_DEF_CHANGED;
goto cleanup; goto cleanup;
......
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