--- a/sql/handler.cc	Sat Apr  7 12:23:32 2007
+++ b/sql/handler.cc	Sun Apr  8 22:56:49 2007
@@ -724,8 +724,12 @@
 end:
     if (is_real_trans)
       start_waiting_global_read_lock(thd);
   }
+  /* Always cleanup. Even if there nht==0. There may be savepoints */
+  if (all)
+    thd->transaction.cleanup();
+
 #endif /* USING_TRANSACTIONS */
   DBUG_RETURN(error);
 }
 
@@ -764,8 +768,9 @@
       if (thd->transaction.changed_tables)
         query_cache.invalidate(thd->transaction.changed_tables);
 #endif
       thd->variables.tx_isolation=thd->session_tx_isolation;
+      /* We will call cleaup again in ha_commit_trans */
       thd->transaction.cleanup();
     }
   }
 #endif /* USING_TRANSACTIONS */
@@ -816,11 +821,15 @@
       thd->transaction.xid_state.xid.null();
     if (all)
     {
       thd->variables.tx_isolation=thd->session_tx_isolation;
-      thd->transaction.cleanup();
+      // thd->transaction.cleanup();
     }
   }
+  /* Always cleanup. Even if there nht==0. There may be savepoints */
+  if (all)
+    thd->transaction.cleanup();
+
 #endif /* USING_TRANSACTIONS */
   /*
     If a non-transactional table was updated, warn; don't warn if this is a
     slave thread (because when a slave thread executes a ROLLBACK, it has
--- a/mysql-test/t/innodb_mysql.test	Sun Feb 11 07:55:54 2007
+++ b/mysql-test/t/innodb_mysql.test	Sun Apr  8 23:03:04 2007
@@ -412,4 +412,31 @@
 
 --source include/innodb_rollback_on_timeout.inc
 
 --echo End of 5.0 tests
+
+# BUG #26288: savepoint are not deleted on comit, if the transaction was otherwise empty
+
+begin;
+savepoint s1;
+commit;
+-- error 1305
+release savepoint s1;
+
+begin;
+savepoint s2;
+commit;
+-- error 1305
+rollback to savepoint s2;
+
+begin;
+savepoint s3;
+rollback;
+-- error 1305
+release savepoint s3;
+
+begin;
+savepoint s4;
+rollback;
+-- error 1305
+rollback to savepoint s4;
+
--- a/mysql-test/r/innodb_mysql.result	Sun Feb 11 07:55:54 2007
+++ b/mysql-test/r/innodb_mysql.result	Sun Apr  8 23:03:10 2007
@@ -446,4 +446,24 @@
 2
 5
 drop table t1;
 End of 5.0 tests
+begin;
+savepoint s1;
+commit;
+release savepoint s1;
+ERROR 42000: SAVEPOINT s1 does not exist
+begin;
+savepoint s2;
+commit;
+rollback to savepoint s2;
+ERROR 42000: SAVEPOINT s2 does not exist
+begin;
+savepoint s3;
+rollback;
+release savepoint s3;
+ERROR 42000: SAVEPOINT s3 does not exist
+begin;
+savepoint s4;
+rollback;
+rollback to savepoint s4;
+ERROR 42000: SAVEPOINT s4 does not exist