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

[t:3400], fix usage of smartDBTs

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@30477 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2af613ff
...@@ -2051,7 +2051,9 @@ static int ...@@ -2051,7 +2051,9 @@ static int
smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) { smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) {
DBT* stored_frm = (DBT *)context; DBT* stored_frm = (DBT *)context;
stored_frm->size = row->size; 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; return 0;
} }
...@@ -2109,6 +2111,7 @@ cleanup: ...@@ -2109,6 +2111,7 @@ cleanup:
commit_txn(txn, 0); commit_txn(txn, 0);
} }
my_free(mysql_frm_data, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql_frm_data, MYF(MY_ALLOW_ZERO_PTR));
my_free(stored_frm.data, MYF(MY_ALLOW_ZERO_PTR));
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
......
...@@ -795,7 +795,9 @@ static int ...@@ -795,7 +795,9 @@ static int
smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) { smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) {
DBT* stored_frm = (DBT *)context; DBT* stored_frm = (DBT *)context;
stored_frm->size = row->size; 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; return 0;
} }
static int tokudb_discover(handlerton *hton, THD* thd, const char *db, 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, ...@@ -808,10 +810,11 @@ static int tokudb_discover(handlerton *hton, THD* thd, const char *db,
DB* status_db = NULL; DB* status_db = NULL;
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
char path[FN_REFLEN + 1]; char path[FN_REFLEN + 1];
uchar* saved_frm_data = NULL;
HA_METADATA_KEY curr_key = hatoku_frm_data; 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); error = db_env->txn_begin(db_env, 0, &txn, 0);
if (error) { goto cleanup; } if (error) { goto cleanup; }
...@@ -834,9 +837,7 @@ static int tokudb_discover(handlerton *hton, THD* thd, const char *db, ...@@ -834,9 +837,7 @@ static int tokudb_discover(handlerton *hton, THD* thd, const char *db,
goto cleanup; goto cleanup;
} }
saved_frm_data = (uchar *)my_malloc(value.size, MYF(MY_WME)); *frmblob = (uchar *)value.data;
memcpy(saved_frm_data, value.data, value.size);
*frmblob = saved_frm_data;
*frmlen = value.size; *frmlen = value.size;
error = 0; error = 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