Commit 2bb84c71 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #922

cosmetic change, make external_lock have only one return pt

git-svn-id: file:///svn/mysql/tokudb-engine/src@4751 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1b79c32b
......@@ -2996,16 +2996,19 @@ int ha_tokudb::reset(void) {
int ha_tokudb::external_lock(THD * thd, int lock_type) {
TOKUDB_DBUG_ENTER("ha_tokudb::external_lock %d", thd_sql_command(thd));
// QQQ this is here to allow experiments without transactions
int error = 0;
tokudb_trx_data *trx = NULL;
if ((tokudb_init_flags & DB_INIT_TXN) == 0) {
TOKUDB_DBUG_RETURN(0);
error = 0;
goto cleanup;
}
int error = 0;
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
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) {
TOKUDB_DBUG_RETURN(1);
error = 1;
goto cleanup;
}
thd_data_set(thd, tokudb_hton->slot, trx);
}
......@@ -3022,7 +3025,7 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
DBUG_PRINT("trans", ("starting transaction all: options: 0x%lx", (ulong) thd->options));
if ((error = db_env->txn_begin(db_env, NULL, &trx->all, 0))) {
trx->tokudb_lock_count--; // We didn't get the lock
TOKUDB_DBUG_RETURN(error);
goto cleanup;
}
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("master:%p\n", trx->all);
......@@ -3030,7 +3033,8 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
trx->sp_level = trx->all;
trans_register_ha(thd, TRUE, tokudb_hton);
if (thd->in_lock_tables) {
TOKUDB_DBUG_RETURN(0); // Don't create stmt trans
error = 0;
goto cleanup;
}
}
DBUG_PRINT("trans", ("starting transaction stmt"));
......@@ -3042,7 +3046,7 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
if ((error = db_env->txn_begin(db_env, trx->sp_level, &trx->stmt, 0))) {
/* We leave the possible master transaction open */
trx->tokudb_lock_count--; // We didn't get the lock
TOKUDB_DBUG_RETURN(error);
goto cleanup;
}
if (tokudb_debug & TOKUDB_DEBUG_TXN) {
TOKUDB_TRACE("stmt:%p:%p\n", trx->sp_level, trx->stmt);
......@@ -3070,6 +3074,7 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
}
}
}
cleanup:
TOKUDB_DBUG_RETURN(error);
}
......
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