[t:2027], move some common code to a function

git-svn-id: file:///svn/mysql/tokudb-engine/src@14819 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
Zardosht Kasheff 2009-09-29 21:47:37 +00:00 committed by Yoni Fogel
parent 612ceab448
commit 2bfe462b50
3 changed files with 22 additions and 12 deletions

View file

@ -982,6 +982,21 @@ cleanup:
return error;
}
int create_tokudb_trx_data_instance(tokudb_trx_data** out_trx) {
int error;
tokudb_trx_data* trx = NULL;
trx = (tokudb_trx_data *) my_malloc(sizeof(*trx), MYF(MY_ZEROFILL));
if (!trx) {
error = ENOMEM;
goto cleanup;
}
trx->iso_level = hatoku_iso_not_set;
*out_trx = trx;
cleanup:
return error;
}
ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg):handler(hton, table_arg)
// flags defined in sql\handler.h
@ -4440,12 +4455,8 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
if (!trx) {
trx = (tokudb_trx_data *) my_malloc(sizeof(*trx), MYF(MY_ZEROFILL));
if (!trx) {
error = 1;
goto cleanup;
}
trx->iso_level = hatoku_iso_not_set;
error = create_tokudb_trx_data_instance(&trx);
if (error) { goto cleanup; }
thd_data_set(thd, tokudb_hton->slot, trx);
}
if (trx->all == NULL) {

View file

@ -108,6 +108,9 @@ typedef enum {
lock_write
} TABLE_LOCK_TYPE;
int create_tokudb_trx_data_instance(tokudb_trx_data** out_trx);
class ha_tokudb : public handler {
private:
THR_LOCK_DATA lock; ///< MySQL lock

View file

@ -825,12 +825,8 @@ int tokudb_checkpoint_lock(THD * thd, stat_print_fn * stat_print) {
tokudb_trx_data* trx = NULL;
trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
if (!trx) {
trx = (tokudb_trx_data *) my_malloc(sizeof(*trx), MYF(MY_ZEROFILL));
if (!trx) {
error = ENOMEM;
goto cleanup;
}
trx->iso_level = hatoku_iso_not_set;
error = create_tokudb_trx_data_instance(&trx);
if (error) { goto cleanup; }
thd_data_set(thd, tokudb_hton->slot, trx);
}