Bug #31598 set autocommit=1. Does it always commits transaction implicitely?
Submitted: 15 Oct 2007 9:41 Modified: 5 Nov 2007 20:17
Reporter: Valeriy Kravchuk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:4.1.22, any? OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: autocommit

[15 Oct 2007 9:41] Valeriy Kravchuk
Description:
http://dev.mysql.com/doc/refman/5.0/en/innodb-implicit-commit.html says:

"Each of the following statements (and any synonyms for them) implicitly end a transaction, as if you had done a COMMIT before executing the statement:

    - ALTER TABLE, BEGIN, CREATE INDEX, DROP INDEX, DROP TABLE, LOAD MASTER DATA, LOCK TABLES, LOAD DATA INFILE, RENAME TABLE, SET AUTOCOMMIT=1, START TRANSACTION, UNLOCK TABLES."

At the same time, this page, http://dev.mysql.com/doc/refman/5.0/en/set-option.html, says:

"- AUTOCOMMIT = {0 | 1}

Set the autocommit mode. If set to 1, all changes to a table take effect immediately. If set to 0 you have to use COMMIT to accept a transaction or ROLLBACK to cancel it. By default, client connections begin with AUTOCOMMIT set to 1. If you change AUTOCOMMIT mode from 0 to 1, MySQL performs an automatic COMMIT of any open transaction. Another way to begin a transaction is to use a START TRANSACTION or BEGIN statement. See Section 12.4.1, “START TRANSACTION, COMMIT, and ROLLBACK Syntax”."

Note "If you change AUTOCOMMIT mode from 0 to 1, MySQL performs an automatic COMMIT of any open transaction.". In other case, when AUTOCOMMIT=1 already, SET AUTOMMIT=1 does NOT perform implicit commit. 

So, looks like we should change http://dev.mysql.com/doc/refman/5.0/en/innodb-implicit-commit.html accordingly.

How to repeat:
SET AUTOCOMMIT=1;
BEGIN
change data...
SET AUTOCOMMIT=1;

Check that data changes are NOT commited.

Suggested fix:
Clarify http://dev.mysql.com/doc/refman/5.0/en/innodb-implicit-commit.html and similar pages for other versions.
[5 Nov 2007 20:17] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.