From d37c7e5b97404cfb014a8c7dc8042b145be3a5c5 Mon Sep 17 00:00:00 2001 From: Zardosht Kasheff Date: Wed, 17 Apr 2013 00:02:05 -0400 Subject: [PATCH] [t:3400], fix usage of smartDBTs git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@30477 c7de825b-a66e-492c-adef-691d508d4ae1 --- storage/tokudb/ha_tokudb.cc | 5 ++++- storage/tokudb/hatoku_hton.cc | 15 ++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index cf251558390..9b054d60a93 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -2051,7 +2051,9 @@ 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; + stored_frm->data = (uchar *)my_malloc(row->size, MYF(MY_WME)); + assert(stored_frm->data); + memcpy(stored_frm->data, row->data, row->size); return 0; } @@ -2109,6 +2111,7 @@ cleanup: commit_txn(txn, 0); } my_free(mysql_frm_data, MYF(MY_ALLOW_ZERO_PTR)); + my_free(stored_frm.data, MYF(MY_ALLOW_ZERO_PTR)); TOKUDB_DBUG_RETURN(error); } diff --git a/storage/tokudb/hatoku_hton.cc b/storage/tokudb/hatoku_hton.cc index 427f5c9dbf0..18064223649 100644 --- a/storage/tokudb/hatoku_hton.cc +++ b/storage/tokudb/hatoku_hton.cc @@ -795,7 +795,9 @@ 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; + stored_frm->data = (uchar *)my_malloc(row->size, MYF(MY_WME)); + assert(stored_frm->data); + memcpy(stored_frm->data, row->data, row->size); return 0; } static int tokudb_discover(handlerton *hton, THD* thd, const char *db, @@ -808,10 +810,11 @@ static int tokudb_discover(handlerton *hton, THD* thd, const char *db, DB* status_db = NULL; DB_TXN* txn = NULL; char path[FN_REFLEN + 1]; - uchar* saved_frm_data = NULL; HA_METADATA_KEY curr_key = hatoku_frm_data; - DBT key, value; - + DBT key, value; + bzero(&key, sizeof(key)); + bzero(&value, sizeof(&value)); + error = db_env->txn_begin(db_env, 0, &txn, 0); if (error) { goto cleanup; } @@ -834,9 +837,7 @@ static int tokudb_discover(handlerton *hton, THD* thd, const char *db, goto cleanup; } - saved_frm_data = (uchar *)my_malloc(value.size, MYF(MY_WME)); - memcpy(saved_frm_data, value.data, value.size); - *frmblob = saved_frm_data; + *frmblob = (uchar *)value.data; *frmlen = value.size; error = 0;