Commit 7b19170c authored by serg@serg.mylan's avatar serg@serg.mylan

BUG#9101 - RELEASE/ROLLBACK TO SAVEPOINT did not forget savepoints correctly

parent e272ab97
......@@ -262,7 +262,11 @@ n
5
6
7
rollback to savepoint `savept2`;
savepoint savept3;
rollback to savepoint savept2;
rollback to savepoint savept3;
ERROR 42000: SAVEPOINT savept3 does not exist
rollback to savepoint savept2;
release savepoint `my_savepoint`;
select n from t1;
n
......@@ -272,6 +276,8 @@ n
7
rollback to savepoint `my_savepoint`;
ERROR 42000: SAVEPOINT my_savepoint does not exist
rollback to savepoint savept2;
ERROR 42000: SAVEPOINT savept2 does not exist
insert into t1 values (8);
savepoint sv;
commit;
......
......@@ -130,17 +130,26 @@ insert into t1 values (6);
insert into t1 values (4);
select n from t1;
set autocommit=0;
#
# savepoints
#
begin;
savepoint `my_savepoint`;
insert into t1 values (7);
savepoint `savept2`;
insert into t1 values (3);
select n from t1;
rollback to savepoint `savept2`;
savepoint savept3;
rollback to savepoint savept2;
--error 1305
rollback to savepoint savept3;
rollback to savepoint savept2;
release savepoint `my_savepoint`;
select n from t1;
-- error 1305
rollback to savepoint `my_savepoint`;
--error 1305
rollback to savepoint savept2;
insert into t1 values (8);
savepoint sv;
commit;
......
......@@ -3805,21 +3805,21 @@ mysql_execute_command(THD *thd)
break;
case SQLCOM_RELEASE_SAVEPOINT:
{
SAVEPOINT **sv;
for (sv=&thd->transaction.savepoints; *sv; sv=&(*sv)->prev)
SAVEPOINT *sv;
for (sv=thd->transaction.savepoints; sv; sv=sv->prev)
{
if (my_strnncoll(system_charset_info,
(uchar *)lex->ident.str, lex->ident.length,
(uchar *)(*sv)->name, (*sv)->length) == 0)
(uchar *)sv->name, sv->length) == 0)
break;
}
if (*sv)
if (sv)
{
if (ha_release_savepoint(thd, *sv))
if (ha_release_savepoint(thd, sv))
res= TRUE; // cannot happen
else
send_ok(thd);
*sv=(*sv)->prev;
thd->transaction.savepoints=sv->prev;
}
else
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "SAVEPOINT", lex->ident.str);
......@@ -3827,17 +3827,17 @@ mysql_execute_command(THD *thd)
}
case SQLCOM_ROLLBACK_TO_SAVEPOINT:
{
SAVEPOINT **sv;
for (sv=&thd->transaction.savepoints; *sv; sv=&(*sv)->prev)
SAVEPOINT *sv;
for (sv=thd->transaction.savepoints; sv; sv=sv->prev)
{
if (my_strnncoll(system_charset_info,
(uchar *)lex->ident.str, lex->ident.length,
(uchar *)(*sv)->name, (*sv)->length) == 0)
(uchar *)sv->name, sv->length) == 0)
break;
}
if (*sv)
if (sv)
{
if (ha_rollback_to_savepoint(thd, *sv))
if (ha_rollback_to_savepoint(thd, sv))
res= TRUE; // cannot happen
else
{
......@@ -3848,7 +3848,7 @@ mysql_execute_command(THD *thd)
ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
send_ok(thd);
}
*sv=(*sv)->prev;
thd->transaction.savepoints=sv;
}
else
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "SAVEPOINT", lex->ident.str);
......
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