From fe83763c365dfa2ba77ebd902810683cedd58ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20N=C3=B8klebye?= Date: Thu, 13 Apr 2017 12:07:06 +0200 Subject: [PATCH] PGSQL: Fixed a failing query in GroupsData for deleting groups messages older than 14 days. The little known abstime function could be used for a double cast. The field TMStamp should be changed to store the data as a proper timestamp. Related to Mantis #7848. Usually this would easily be solved using the to_timestamp function, but there is no support for it in NPGSQL as there are no very close functionality in .NET Signed-off-by: Michael Cerquoni --- OpenSim/Data/PGSQL/PGSQLGroupsData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs index 6ef576bccc..f398256863 100755 --- a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs +++ b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs @@ -435,7 +435,7 @@ namespace OpenSim.Data.PGSQL using (NpgsqlCommand cmd = new NpgsqlCommand()) { - cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); + cmd.CommandText = String.Format("delete from {0} where \"TMStamp\"::abstime::timestamp < now() - INTERVAL '2 week'", m_Realm); ExecuteNonQuery(cmd); } @@ -461,7 +461,7 @@ namespace OpenSim.Data.PGSQL using (NpgsqlCommand cmd = new NpgsqlCommand()) { - cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); + cmd.CommandText = String.Format("delete from {0} where \"TMStamp\"::abstime::timestamp < now() - INTERVAL '2 week'", m_Realm); ExecuteNonQuery(cmd); }