mirror of
https://github.com/MariaDB/server.git
synced 2025-02-17 19:05:37 +01:00
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.
This commit is contained in:
parent
75ab3274c8
commit
2005f3c72c
3 changed files with 66 additions and 3 deletions
|
@ -1267,4 +1267,28 @@ CREATE INDEX i1 on t1 (a(3));
|
||||||
SELECT * FROM t1 WHERE a = 'abcde';
|
SELECT * FROM t1 WHERE a = 'abcde';
|
||||||
a
|
a
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# BUG #26288: savepoint are not deleted on comit, if the transaction
|
||||||
|
# was otherwise empty
|
||||||
|
#
|
||||||
|
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
|
||||||
End of 5.0 tests
|
End of 5.0 tests
|
||||||
|
|
|
@ -1025,4 +1025,33 @@ CREATE INDEX i1 on t1 (a(3));
|
||||||
SELECT * FROM t1 WHERE a = 'abcde';
|
SELECT * FROM t1 WHERE a = 'abcde';
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # BUG #26288: savepoint are not deleted on comit, if the transaction
|
||||||
|
--echo # was otherwise empty
|
||||||
|
--echo #
|
||||||
|
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;
|
||||||
|
|
||||||
--echo End of 5.0 tests
|
--echo End of 5.0 tests
|
||||||
|
|
|
@ -730,6 +730,16 @@ end:
|
||||||
if (is_real_trans)
|
if (is_real_trans)
|
||||||
start_waiting_global_read_lock(thd);
|
start_waiting_global_read_lock(thd);
|
||||||
}
|
}
|
||||||
|
else if (all)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
A COMMIT of an empty transaction. There may be savepoints.
|
||||||
|
Destroy them. If the transaction is not empty
|
||||||
|
savepoints are cleared in ha_commit_one_phase()
|
||||||
|
or ha_rollback_trans().
|
||||||
|
*/
|
||||||
|
thd->transaction.cleanup();
|
||||||
|
}
|
||||||
#endif /* USING_TRANSACTIONS */
|
#endif /* USING_TRANSACTIONS */
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
@ -825,11 +835,11 @@ int ha_rollback_trans(THD *thd, bool all)
|
||||||
thd->transaction.xid_state.xid.null();
|
thd->transaction.xid_state.xid.null();
|
||||||
}
|
}
|
||||||
if (all)
|
if (all)
|
||||||
{
|
|
||||||
thd->variables.tx_isolation=thd->session_tx_isolation;
|
thd->variables.tx_isolation=thd->session_tx_isolation;
|
||||||
|
}
|
||||||
|
/* Always cleanup. Even if there nht==0. There may be savepoints. */
|
||||||
|
if (all)
|
||||||
thd->transaction.cleanup();
|
thd->transaction.cleanup();
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* USING_TRANSACTIONS */
|
#endif /* USING_TRANSACTIONS */
|
||||||
if (all)
|
if (all)
|
||||||
thd->transaction_rollback_request= FALSE;
|
thd->transaction_rollback_request= FALSE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue