Bug #9222 mysqldump --single-transaction should turn off --add-locks
Submitted: 16 Mar 2005 15:06 Modified: 2 Apr 2005 21:32
Reporter: Michael Kofler Email Updates:
Status: Won't fix Impact on me:
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version: OS:
Assigned to: Guilhem Bichot CPU Architecture:Any

[16 Mar 2005 15:06] Michael Kofler
--single-transaction turns off --lock-tables

it should also turn off --add-locks

How to repeat:
mysqldump --single-transaction innodatabasename > backup.sql

the resulting backup.sql file contains LOCK TABLE commands, which make no sense for InnoDB tables and might cause trouble

LOCK TABLES `tablename` WRITE;
INSERT INTO `tablename` VALUES (...);
[2 Apr 2005 21:32] Guilhem Bichot
Hello Michael.
At restore time, usually some type of locking must be done. It does not make sense usually to insert data into tables while they are being updated. Which is why there are those LOCK TABLES printed by default. Could you please tell why it does not make sense and which problems they can cause?
--single-transaction just says that the backup will be done without locks, but the restore still usually needs locks to be meaningful.
So I am not sure there should be an implication, that if you use --single-transaction you should not have LOCK TABLES in the SQL output. I agree that --single-transaction should turn off --lock-tables (and it does) but not that it should turn off --add-locks.
If in some special case --add-locks is undesirable one can explicitely --disable-add-locks, but as this is for special, not general cases, this should not be the default behaviour, in my opinion.