Add lastmsgid limit on fetching backlog to SQLite
Copy lastmsgid fetch limit improvements from PostgreSQL to SQLite,
improving performance by not requiring scanning from the start of the
backlog table to the present.
This builds upon pull request #273, including the original intent of
improving performance for unread backlog fetching. The original pull
request left out these lines when applying the PostgreSQL changes to
SQLite.
NOTE: The client-side generating these invalid values should be
fixed in future commits.