Bug #26288 savepoint not deleted, commit on empty transaction
Submitted: 12 Feb 2007 15:40 Modified: 12 May 3:56
Reporter: Martin Friebe (Gold Quality Contributor) (SCA)
Status: Closed
Category:Server Severity:S3 (Non-critical)
Version:5.0.36bk, 5.1 BK OS:Linux (Linux)
Assigned to: Ramil Kalimullin Target Version:5.0+
Tags: qc, savepoint, transaction, Contribution
Triage: Triaged: D3 (Medium) / R2 (Low) / E2 (Low)

[12 Feb 2007 15:40] Martin Friebe
Description:
commit should delete all savepoint that were made in the transaction.

That does only happen, if the transaction made any changes to any tables (with
transaction support).
Otherwise the savepoint remains

How to repeat:
begin;
savepoint s1;
commit;

rollback to savepoint s1; # no error, but should not exist
release savepoint s1; # no error?

Suggested fix:
-
[12 Feb 2007 16:03] Martin Friebe
similiar with rollback to savepoint, which produces an error, even so the savepoint does
exist...

drop table if exists t1;
create table t1 (a int not null, b int not null, index (a,b)) engine=innodb;
insert into t1 values (1,2), (1,3), (2,3), (2,4);

drop trigger if exists tr1;
delimiter |
create trigger tr1 after update on t1 for each row begin
  set @a = 1;
  rollback to savepoint s1;
  set @b = 1;
end
|
delimiter ;

start transaction;
savepoint s1;
select @a, @b;
update t1 set a= 21 where b = 2;
#ERROR 1305 (42000): SAVEPOINT s1 does not exist
select @a, @b;
[12 Feb 2007 16:07] Martin Friebe
sorry last comment was for bug #26287
[13 Feb 2007 11:19] Sveta Smirnova
Thank you for the report.

Verified as described. Version 5.1 is affected too.
[9 Apr 2007 0:22] Martin Friebe
patch + test

Attachment: savepoint.patch (text/x-patch), 2.40 KiB.

[23 Jun 2008 13:53] Ramil Kalimullin
http://lists.mysql.com/commits/48321
[26 Mar 16:07] Konstantin Osipov
Approved a slightly changed version (see the last commit message) over email.
[26 Mar 16:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/70554

2846 Konstantin Osipov	2009-03-26
      Bug#26288 "savepoint not deleted, comit on empty transaction",
      commit the reviewing version for archiving purposes.
      Ramil will commit and push into 5.0
      modified:
        mysql-test/r/innodb_mysql.result
        mysql-test/t/innodb_mysql.test
        sql/handler.cc
[27 Mar 7:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/70624

2716 Ramil Kalimullin	2009-03-27
      Fix for bug #26288: savepoint not deleted, comit on empty transaction
      
      Problem: commit doesn't delete savepoints if there are no changes 
      in the transaction.
      
      Fix: delete them in such cases.
     @ mysql-test/r/innodb_mysql.result
        Fix for bug #26288: savepoint not deleted, comit on empty transaction
          - test result.
     @ mysql-test/t/innodb_mysql.test
        Fix for bug #26288: savepoint not deleted, comit on empty transaction
          - test case.
     @ sql/handler.cc
        Fix for bug #26288: savepoint not deleted, comit on empty transaction
          - call transaction.cleanup() even if nht is 0 to delete 
        possible savepoints.
[30 Mar 9:04] Ramil Kalimullin
Pushed to {5.x, 6.0}-bugteam trees.
[5 May 20:53] Bugs System
Pushed into 5.0.82 (revid:davi.arnaut@sun.com-20090505184158-dvmedh8n472y8np5) (version
source revid:davi.arnaut@sun.com-20090505184158-dvmedh8n472y8np5) (merge vers: 5.0.82)
(pib:6)
[5 May 21:42] Bugs System
Pushed into 5.1.35 (revid:davi.arnaut@sun.com-20090505190206-9xmh7dlc6kom8exp) (version
source revid:davi.arnaut@sun.com-20090505190206-9xmh7dlc6kom8exp) (merge vers: 5.1.35)
(pib:6)
[6 May 16:06] Bugs System
Pushed into 6.0.12-alpha (revid:svoj@sun.com-20090506125450-yokcmvqf2g7jhujq) (version
source revid:horst@mysql.com-20090327184517-25eq077q2beocs6y) (merge vers: 6.0.11-alpha)
(pib:6)
[12 May 3:56] Paul DuBois
Noted in 5.0.82, 5.1.35, 6.0.12 changelogs.

COMMIT did not delete savepoints if there were no changes in the
transaction.
[15 Jun 10:28] Bugs System
Pushed into 5.1.35-ndb-6.3.26 (revid:jonas@mysql.com-20090615074202-0r5r2jmi83tww6sf)
(version source revid:jonas@mysql.com-20090615070837-9pccutgc7repvb4d) (merge vers:
5.1.35-ndb-6.3.26) (pib:6)
[15 Jun 11:08] Bugs System
Pushed into 5.1.35-ndb-7.0.7 (revid:jonas@mysql.com-20090615074335-9hcltksp5cu5fucn)
(version source revid:jonas@mysql.com-20090615072714-rmfkvrbbipd9r32c) (merge vers:
5.1.35-ndb-7.0.7) (pib:6)
[15 Jun 11:49] Bugs System
Pushed into 5.1.35-ndb-6.2.19 (revid:jonas@mysql.com-20090615061520-sq7ds4yw299ggugm)
(version source revid:jonas@mysql.com-20090615054654-ebgpz7elwu1xj36j) (merge vers:
5.1.35-ndb-6.2.19) (pib:6)