Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[libcontacts] Limit queried IDs to avoid SQL binding limit. Fixes JB#…
…11956

If we query too many updated contact IDs at once, we cause qtcontacts-sqlite
to create statements that exceed the bound variable limit.
  • Loading branch information
matthewvogt committed Nov 5, 2013
1 parent 943a3b5 commit 74611c2
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/seasidecache.cpp
Expand Up @@ -943,9 +943,10 @@ SeasideCache::ContactIdType SeasideCache::selfContactId()

void SeasideCache::requestUpdate()
{
if (!m_updatesPending)
if (!m_updatesPending) {
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
m_updatesPending = true;
m_updatesPending = true;
}
}

bool SeasideCache::saveContact(const QContact &contact)
Expand Down Expand Up @@ -1462,13 +1463,22 @@ bool SeasideCache::event(QEvent *event)
m_fetchTypesChanged = false;
m_populateProgress = RefetchFavorites;
} else if (!m_changedContacts.isEmpty() && !m_fetchRequest.isActive()) {
// If we request too many IDs we will exceed the SQLite bound variables limit
// The actual limit is over 800, but we should reduce further to increase interactivity
const int maxRequestIds = 200;

#ifdef USING_QTPIM
QContactIdFilter filter;
#else
QContactLocalIdFilter filter;
#endif
filter.setIds(m_changedContacts);
m_changedContacts.clear();
if (m_changedContacts.count() > maxRequestIds) {
filter.setIds(m_changedContacts.mid(0, maxRequestIds));
m_changedContacts = m_changedContacts.mid(maxRequestIds);
} else {
filter.setIds(m_changedContacts);
m_changedContacts.clear();
}

// A local ID filter will fetch all contacts, rather than just aggregates;
// we only want to retrieve aggregate contacts that have changed
Expand Down Expand Up @@ -2686,7 +2696,7 @@ void SeasideCache::disaggregateContacts(const QContact &contact1, const QContact
saveContact(c);
}

QCoreApplication::postEvent(instancePtr, new QEvent(QEvent::UpdateRequest));
instancePtr->requestUpdate();
}

void SeasideCache::updateConstituentAggregations(const ContactIdType &contactId)
Expand Down

0 comments on commit 74611c2

Please sign in to comment.