summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Sanders <don.sanders@nokia.com>2012-03-02 18:54:23 +0200
committerDon Sanders <don.sanders@nokia.com>2012-03-02 18:54:23 +0200
commit589877fd5aa1681b06f6d3f2058a4b078d412c51 (patch)
tree17773161f702488a779a4faa3c0bb1c78a0740ca
parent4256ae33a7b5406d505968235f94d07f6510edf6 (diff)
Fix another regression introduced by merging in threading code.
Deleting thousands of messages could lead to the sqlite argument limit being exceeded. This time "updateThreads mailthreads delete" query was failing.
-rw-r--r--src/libraries/qmfclient/qmailstore_p.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/libraries/qmfclient/qmailstore_p.cpp b/src/libraries/qmfclient/qmailstore_p.cpp
index f0cf0e11..1aa8050a 100644
--- a/src/libraries/qmfclient/qmailstore_p.cpp
+++ b/src/libraries/qmfclient/qmailstore_p.cpp
@@ -3627,13 +3627,21 @@ QMailStorePrivate::AttemptResult QMailStorePrivate::updateThreadsValues(const QM
if (!threadsToDelete.isEmpty()) {
QString sql("DELETE FROM mailthreads WHERE id IN %1");
QVariantList bindValues;
- foreach (const QMailThreadId& threadId, threadsToDelete)
- {
+ foreach (const QMailThreadId& threadId, threadsToDelete) {
bindValues << threadId.toULongLong();
}
- QSqlQuery query = simpleQuery(sql.arg(expandValueList(bindValues)), bindValues, "updateThreads mailthreads delete");
- if (query.lastError().type() != QSqlError::NoError)
- return DatabaseFailure;
+ QVariantList bindValuesBatch;
+ while (!bindValues.isEmpty()) {
+ bindValuesBatch = bindValues.mid(0, 500);
+ if (bindValues.count() > 500) {
+ bindValues = bindValues.mid(500);
+ } else {
+ bindValues.clear();
+ }
+ QSqlQuery query = simpleQuery(sql.arg(expandValueList(bindValuesBatch)), bindValuesBatch, "updateThreads mailthreads delete");
+ if (query.lastError().type() != QSqlError::NoError)
+ return DatabaseFailure;
+ }
}
if (modifiedThreadsIds.isEmpty())
return Success;