Skip to content

Commit bfca726

Browse files
authored
Print a warning when the number of rows dumped does not match the expected count (#85)
1 parent 979d73c commit bfca726

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Webfactory/Slimdump/Database/Dumper.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public function dumpData($table, Table $tableConfig, Connection $db, bool $noPro
183183
/** @var PDOConnection $wrappedConnection */
184184
$wrappedConnection = $db->getWrappedConnection();
185185
$wrappedConnection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
186+
$actualRows = 0;
186187

187188
foreach ($db->query($s) as $row) {
188189
$b = $this->rowLengthEstimate($row);
@@ -222,6 +223,8 @@ public function dumpData($table, Table $tableConfig, Connection $db, bool $noPro
222223
if (null !== $progress) {
223224
$progress->advance();
224225
}
226+
227+
++$actualRows;
225228
}
226229

227230
if (null !== $progress) {
@@ -232,6 +235,10 @@ public function dumpData($table, Table $tableConfig, Connection $db, bool $noPro
232235
}
233236
}
234237

238+
if ($actualRows !== $numRows) {
239+
$this->output->getErrorOutput()->writeln(sprintf('<error>Expected %d rows, actually processed %d – verify results!</error>', $numRows, $actualRows));
240+
}
241+
235242
$wrappedConnection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
236243

237244
if ($bufferSize) {

0 commit comments

Comments
 (0)