diff options
Diffstat (limited to 'trx/trx0roll.c')
-rw-r--r-- | trx/trx0roll.c | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/trx/trx0roll.c b/trx/trx0roll.c index b1079eff01d..5f3cb15a254 100644 --- a/trx/trx0roll.c +++ b/trx/trx0roll.c @@ -1,8 +1,24 @@ +/***************************************************************************** + +Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA + +*****************************************************************************/ + /****************************************************** Transaction rollback -(c) 1996 Innobase Oy - Created 3/26/1996 Heikki Tuuri *******************************************************/ @@ -171,9 +187,27 @@ trx_rollback_last_sql_stat_for_mysql( } /*********************************************************************** -Frees savepoint structs. */ +Frees a single savepoint struct. */ UNIV_INTERN void +trx_roll_savepoint_free( +/*=====================*/ + trx_t* trx, /* in: transaction handle */ + trx_named_savept_t* savep) /* in: savepoint to free */ +{ + ut_a(savep != NULL); + ut_a(UT_LIST_GET_LEN(trx->trx_savepoints) > 0); + + UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep); + mem_free(savep->name); + mem_free(savep); +} + +/*********************************************************************** +Frees savepoint structs starting from savep, if savep == NULL then +free all savepoints. */ + +void trx_roll_savepoints_free( /*=====================*/ trx_t* trx, /* in: transaction handle */ @@ -192,9 +226,7 @@ trx_roll_savepoints_free( while (savep != NULL) { next_savep = UT_LIST_GET_NEXT(trx_savepoints, savep); - UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep); - mem_free(savep->name); - mem_free(savep); + trx_roll_savepoint_free(trx, savep); savep = next_savep; } @@ -329,8 +361,8 @@ trx_savepoint_for_mysql( } /*********************************************************************** -Releases a named savepoint. Savepoints which -were set after this savepoint are deleted. */ +Releases only the named savepoint. Savepoints which were set after this +savepoint are left as is. */ UNIV_INTERN ulint trx_release_savepoint_for_mysql( @@ -346,31 +378,16 @@ trx_release_savepoint_for_mysql( savep = UT_LIST_GET_FIRST(trx->trx_savepoints); + /* Search for the savepoint by name and free if found. */ while (savep != NULL) { if (0 == ut_strcmp(savep->name, savepoint_name)) { - /* Found */ - break; + trx_roll_savepoint_free(trx, savep); + return(DB_SUCCESS); } savep = UT_LIST_GET_NEXT(trx_savepoints, savep); } - if (savep == NULL) { - - return(DB_NO_SAVEPOINT); - } - - /* We can now free all savepoints strictly later than this one */ - - trx_roll_savepoints_free(trx, savep); - - /* Now we can free this savepoint too */ - - UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep); - - mem_free(savep->name); - mem_free(savep); - - return(DB_SUCCESS); + return(DB_NO_SAVEPOINT); } /*********************************************************************** |