Commit 7a053c7d authored by unknown's avatar unknown

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


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