From 5e3bcda8c341dbe6846d4723afe7096acca8f304 Mon Sep 17 00:00:00 2001 From: Michael Marley Date: Thu, 9 Mar 2017 10:46:14 -0500 Subject: [PATCH 1/1] 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()". --- src/core/SQL/PostgreSQL/20/update_buffer_lastseen.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/SQL/PostgreSQL/20/update_buffer_lastseen.sql b/src/core/SQL/PostgreSQL/20/update_buffer_lastseen.sql index 98218a64..14e5c58d 100644 --- a/src/core/SQL/PostgreSQL/20/update_buffer_lastseen.sql +++ b/src/core/SQL/PostgreSQL/20/update_buffer_lastseen.sql @@ -1,3 +1,3 @@ UPDATE buffer -SET lastseenmsgid = min(:lastseenmsgid, buffer.lastmsgid) +SET lastseenmsgid = least(:lastseenmsgid, buffer.lastmsgid) WHERE userid = :userid AND bufferid = :bufferid -- 2.20.1