summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2022-02-24 23:25:41 +0100
committerGitHub <noreply@github.com>2022-02-24 23:25:41 +0100
commitabbbae1fc83635e331a750d77062644a54631f93 (patch)
tree06066453b3b165cd82c7d738492817c214a3f303
parentd7e55e272e70f4d3b3b4e74d51ab2001f4d037a7 (diff)
parentdb6927ee0530d2e352725dc0f6d75e8db8723587 (diff)
downloadnextcloud-server-abbbae1fc83635e331a750d77062644a54631f93.tar.gz
nextcloud-server-abbbae1fc83635e331a750d77062644a54631f93.zip
Merge pull request #31219 from nextcloud/fix/performance-db-convert
Improve performance when converting between DBs
-rw-r--r--core/Command/Db/ConvertType.php40
1 files changed, 25 insertions, 15 deletions
diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php
index 27f3147b81d..754cbd08812 100644
--- a/core/Command/Db/ConvertType.php
+++ b/core/Command/Db/ConvertType.php
@@ -353,27 +353,37 @@ class ConvertType extends Command implements CompletionAwareInterface {
$result = $query->execute();
- while ($row = $result->fetch()) {
- $progress->advance();
- if (!$parametersCreated) {
- foreach ($row as $key => $value) {
- $insertQuery->setValue($key, $insertQuery->createParameter($key));
+ try {
+ $toDB->beginTransaction();
+
+ while ($row = $result->fetch()) {
+ $progress->advance();
+ if (!$parametersCreated) {
+ foreach ($row as $key => $value) {
+ $insertQuery->setValue($key, $insertQuery->createParameter($key));
+ }
+ $parametersCreated = true;
}
- $parametersCreated = true;
- }
- foreach ($row as $key => $value) {
- $type = $this->getColumnType($table, $key);
- if ($type !== false) {
- $insertQuery->setParameter($key, $value, $type);
- } else {
- $insertQuery->setParameter($key, $value);
+ foreach ($row as $key => $value) {
+ $type = $this->getColumnType($table, $key);
+ if ($type !== false) {
+ $insertQuery->setParameter($key, $value, $type);
+ } else {
+ $insertQuery->setParameter($key, $value);
+ }
}
+ $insertQuery->execute();
}
- $insertQuery->execute();
+ $result->closeCursor();
+
+ $toDB->commit();
+ } catch (\Throwable $e) {
+ $toDB->rollBack();
+ throw $e;
}
- $result->closeCursor();
}
+
$progress->finish();
$output->writeln('');
}