Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is there a SET AUTOCOMMIT=0 in the SQL of a database export #15802

Closed
Mattie112 opened this issue Jan 16, 2020 · 8 comments
Closed

Why is there a SET AUTOCOMMIT=0 in the SQL of a database export #15802

Mattie112 opened this issue Jan 16, 2020 · 8 comments
Assignees
Labels
Bug A problem or regression with an existing feature has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete
Projects
Milestone

Comments

@Mattie112
Copy link

The first 4 lines of a database export with default settings in phpMyAdmin are:

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";

The last 4 lines contain:

COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

I see that the AUTOCOMMIT is disabled but never enabled. I have noticed because we imported a SQL (generated by phpMyAdmin) and in the same session also executed some INSERT statements. These rows where not visible in the database (because they where never committed).

In the MySQL docs I read this:

With START TRANSACTION, autocommit remains disabled until you end the transaction with COMMIT or ROLLBACK. The autocommit mode then reverts to its previous state.

This states that a SET AUTOCOMMIT = 0 automatically when starting a transaction. Is there a reason why phpMyAdmin disables the autocommit and then never enables it? Is it possible to remove the SET AUTOCOMMIT=0 or add a SET AUTOCOMMIT=1 on the last line of the export?

@williamdes
Copy link
Member

Seems like a bug, thank you for reporting it !

@williamdes williamdes added this to Needs triage in issues via automation Jan 16, 2020
@williamdes williamdes added the Bug A problem or regression with an existing feature label Jan 16, 2020
@williamdes williamdes moved this from Needs triage to Medium priority in issues Jan 16, 2020
@ibennetch
Copy link
Member

ibennetch commented Jan 16, 2020 via email

@kartik1000
Copy link
Contributor

@williamdes I am willing to work on this issue :)

@williamdes
Copy link
Member

@kartik1000 I assigned it to you for now

@kartik1000
Copy link
Contributor

What should I prefer removing SET AUTO COMMIT = 0 or Adding SET AUTO COMMIT = 1? @williamdes

@Mattie112
Copy link
Author

I would suggest removing the SET AUTOCOMMIT = 0 is it is already done according to the MySQL docs.
https://dev.mysql.com/doc/refman/8.0/en/commit.html

@kartik1000
Copy link
Contributor

ok @Mattie112

@Mattie112
Copy link
Author

And just to confirm:

The docs state this for 8.0, 5.7, 5.6 and 5.5

The MariaDB docks also state this:
(https://mariadb.com/kb/en/start-transaction/)

To disable autocommit mode for a single series of statements, use the START TRANSACTION statement.

@kartik1000 kartik1000 mentioned this issue Jan 17, 2020
6 tasks
@williamdes williamdes added this to the 5.0.2 milestone Jan 19, 2020
@williamdes williamdes assigned williamdes and unassigned kartik1000 Jan 19, 2020
@williamdes williamdes added the has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete label Jan 19, 2020
williamdes added a commit that referenced this issue Jan 19, 2020
Signed-off-by: William Desportes <williamdes@wdes.fr>
issues automation moved this from Medium priority to Closed Jan 19, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete
Projects
issues
  
Closed
Development

No branches or pull requests

4 participants