X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fsqlitestorage.cpp;h=fb9045241c88077054d274a31a92b848e76f0454;hp=3176ec4b05318d8a8f472499504fc43f98cbda70;hb=5319f3fbe69a63d1599107e0fc77ae325e4a9b6d;hpb=3e350f6ae66b8c5550909b140f81010df999c494;ds=sidebyside diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 3176ec4b..fb904524 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -619,13 +619,17 @@ QList SqliteStorage::requestMsgs(UserId user, BufferId bufferId, int la if(!bufferInfo.isValid()) return messagelist; - // we have to determine the real offset first - QSqlQuery *offsetQuery = cachedQuery("select_messagesOffset"); - offsetQuery->bindValue(":bufferid", bufferId.toInt()); - offsetQuery->bindValue(":messageid", offset); - offsetQuery->exec(); - offsetQuery->first(); - offset = offsetQuery->value(0).toInt(); + if(offset == -1) { + offset = 0; + } else { + // we have to determine the real offset first + QSqlQuery *offsetQuery = cachedQuery("select_messagesOffset"); + offsetQuery->bindValue(":bufferid", bufferId.toInt()); + offsetQuery->bindValue(":messageid", offset); + offsetQuery->exec(); + offsetQuery->first(); + offset = offsetQuery->value(0).toInt(); + } // now let's select the messages QSqlQuery *msgQuery = cachedQuery("select_messages");