Skip to content

Commit

Permalink
Restore the autocommit value at end of dump. (ifsnop#196)
Browse files Browse the repository at this point in the history
By default, autocommit is disabled so inserts are faster. This patch saves autocommit status to restore after dump, useful if you are reusing the connection.
  • Loading branch information
christiandavilakoobin authored Jul 17, 2020
1 parent 190aa83 commit f9f8a25
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Ifsnop/Mysqldump/Mysqldump.php
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,10 @@ public function backup_parameters()
"/*!40103 SET TIME_ZONE='+00:00' */;".PHP_EOL;
}

if ($this->dumpSettings['no-autocommit']) {
$ret .= "/*!40101 SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT */;".PHP_EOL;
}

$ret .= "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;".PHP_EOL.
"/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;".PHP_EOL.
"/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;".PHP_EOL.
Expand All @@ -2310,6 +2314,10 @@ public function restore_parameters()
$ret .= "/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;".PHP_EOL;
}

if ($this->dumpSettings['no-autocommit']) {
$ret .= "/*!40101 SET AUTOCOMMIT=@OLD_AUTOCOMMIT */;".PHP_EOL;
}

$ret .= "/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;".PHP_EOL.
"/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;".PHP_EOL.
"/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;".PHP_EOL.
Expand Down

0 comments on commit f9f8a25

Please sign in to comment.