Fix lastseenmsgid updates in PostgreSQL 277/head
authorMichael Marley <michael@michaelmarley.com>
Thu, 9 Mar 2017 15:46:14 +0000 (10:46 -0500)
committerMichael Marley <michael@michaelmarley.com>
Thu, 9 Mar 2017 15:51:16 +0000 (10:51 -0500)
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()".

src/core/SQL/PostgreSQL/20/update_buffer_lastseen.sql

index 98218a6..14e5c58 100644 (file)
@@ -1,3 +1,3 @@
 UPDATE buffer
 UPDATE buffer
-SET lastseenmsgid = min(:lastseenmsgid, buffer.lastmsgid)
+SET lastseenmsgid = least(:lastseenmsgid, buffer.lastmsgid)
 WHERE userid = :userid AND bufferid = :bufferid
 WHERE userid = :userid AND bufferid = :bufferid