core: Separate SQL current and upgrade scripts Move the current SQL queries into the 'SQL/[database]' top folder, move all database schema upgrade scripts into the 'SQL/[database]/version/##' subfolders. This preserves repository history for the general SQL queries when adding a new schema version, and simplifies rebasing a branch if the master schema version changes in the meantime (e.g. managing multiple pull requests). Thanks to justJanne and others for the suggestion! Update 'sql.qrc' with the moved SQL files. Modify AbstractSqlStorage 'setupQueries()' and 'upgradeQueries()' to use these new folder locations, and modify 'queryString()' to pick either the current SQL schema folder or the versioned schema folder according to whether a version was specified when calling it. Update 'updateSQLResource.sh' with the new folder locations, including fixing the 'sort' command to sort independent of the current operating system language settings. Update 'upgradeSchema.sh' with the new locations and stop moving the non-upgrade '*.sql' scripts. Now, it just adds a new folder and prints a message on how to use it. Also send error messages to standard error. Add more documentation on schema upgrades. You can never have enough testing...
Fix lastseenmsgid updates in PostgreSQL GH-273 introduced a workaround for the issue where sometimes the lastseenmsgid for a buffer was set to a msgid not in that buffer. However, the workaround was incorrect as the "min()" function in PostgreSQL is an aggregate function for use on a column, not a function to return the least of a list of values passed in. The correct function for use here is "least()".
Port the previous PostgreSQL improvements to SQLite3.
Improve performance of PostgreSQL for large databases. This change requires a change to the database schema. Currently, in cases where buffers exist that have not had any activity for an extended period of time, during initial backlog fetching, Quassel will have to scan backwards through all activity in all buffers until it reaches activity for the buffer in question. This adds an additional field to the buffer table, "lastmsgid", which is the messageid of the most recent message added for that buffer. This improves performance by allowing Quassel to skip straight to where the most recent activity was, instead of scanning millions of rows (in large databases) in futility.