core: Add backlog trigger to update lastmsgid
authorShane Synan <digitalcircuit36939@gmail.com>
Sun, 16 Apr 2017 04:13:59 +0000 (23:13 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 24 Apr 2017 19:53:17 +0000 (21:53 +0200)
Add PostgreSQL function 'backlog_lastmsgid_update()' that sets the
'lastmsgid' of a buffer according to the latest message ID available.
Also add a PostgreSQL trigger 'backlog_lastmsgid_update' that acts
whenever a new message is inserted to or updated in the backlog
table.

Add two SQLite triggers, 'backlog_lastmsgid_update_trigger_insert'
for inserting messages into the backlog, and
'backlog_lastmsgid_update_trigger_update' for updating messages in
the backlog.  Both triggers update the 'lastmsgid' of a buffer
according to the latest message ID available.

Unfortunately, SQLite lacks niceties such as functions or complex
triggers, requiring two separate triggers to do the same thing.  Ah
well, SQLite is much easier to bundle and set up.

This fixes some cases where 'update_lastmsgid' was not being called
when it should, namely when inserting multiple messages.

NOTE:  Currently Quassel does not offer an option to delete
specific messages without deleting a buffer, nor to update the
message ID of existing messages (this would break many assumptions).
However, for completion-sake, the UPDATE triggers are included.
DELETE triggers should be added if individual message deletion is
added.

Thanks to justJanne for the suggestion and PostgreSQL code!


No differences found