Bug #47326 Spurious warning for rollback to savepoint
Submitted: 15 Sep 2009 13:04
Reporter: Sven Sandberg Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1, 6.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: rollback, savepoint, warning

[15 Sep 2009 13:04] Sven Sandberg
Description:
When a non-transactional update is made in the scope of a transaction, and the transaction is rolled back, the server generates the following warning:

ER_WARNING_NOT_COMPLETE_ROLLBACK "Some non-transactional changed tables couldn't be rolled back"

When rolling back to a savepoint, the warning is issued if there is a non-transactional update in the current transaction, even if it is not in the scope of the savepoint.

How to repeat:
--source include/have_innodb.inc

create table t1 (a int) engine=myisam;
create table t2 (a int) engine=innodb;

show create table t1;
show create table t2;

begin;
  insert into t1 values (1);
  savepoint s1;
    insert into t2 values (1);
  rollback to s1; # <-- generates spurious warning!
commit;

Suggested fix:
In sql_parse.cc, inside 'case SQLCOM_ROLLBACK_TO_SAVEPOINT', the warning is generated as follows:

        if (((thd->options & OPTION_KEEP_LOG) || 
             thd->transaction.all.modified_non_trans_table) &&
            !thd->slave_thread)
          push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                       ER_WARNING_NOT_COMPLETE_ROLLBACK,
                       ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));

Instead of remembering the existence of a non-transactional update (one bit), we should remember the *position* of the last modification of a non-trans table. Then, we should give a warning only if the last modification of a non-transactional table was after the savepoint.
[15 Jul 2010 9:57] Alfranio Tavares Correia Junior
See also BUG#54562.
[15 Jul 2010 10:09] Alfranio Tavares Correia Junior
See also BUG#47327.