From 90d423c66f8a1d85806464767a8aa832ccbf3f7b Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Thu, 9 May 2013 18:18:18 +0200 Subject: [PATCH] DBBrowserDB: Don't export sqlite_stat1 table when dumping DB When creating a SQL dump of the database don't export the sqlite_stat1 table as it's impossible to import it later because SQLite generates it automatically. --- src/sqlitedb.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 7ab61961..cb318685 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -232,11 +232,21 @@ bool DBBrowserDB::dump(const QString& filename) // indices, views or triggers into account but compared to the number of rows those should be neglectable unsigned int numRecordsTotal = 0, numRecordsCurrent = 0; QList tables = objMap.values("table"); - for(QList::ConstIterator it=tables.begin();it!=tables.end();++it) + QMutableListIterator it(tables); + while(it.hasNext()) { - SqliteTableModel tableModel(0, this); - tableModel.setTable((*it).getname()); - numRecordsTotal += tableModel.totalRowCount(); + it.next(); + + // Remove the sqlite_stat1 table if there is one + if(it.value().getname() == "sqlite_stat1") + { + it.remove(); + } else { + // Otherwise get the number of records in this table + SqliteTableModel tableModel(0, this); + tableModel.setTable(it.value().getname()); + numRecordsTotal += tableModel.totalRowCount(); + } } QProgressDialog progress(QObject::tr("Exporting database to SQL file..."), QObject::tr("Cancel"), 0, numRecordsTotal);