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.