From 01728fb19e1c23e878197753cb788f94883e5838 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 21 Jun 2010 17:06:05 +0200 Subject: Ensure no UUID.Zero region ID is ever written to presence. Add a Migration to add a LastSeen field of type "Timestamp" to Presence for MySQL --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 4 +++- OpenSim/Data/MySQL/Resources/Presence.migrations | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 71caa1a..7b0016b 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -78,6 +78,9 @@ namespace OpenSim.Data.MySQL if (pd.Length == 0) return false; + if (regionID == UUID.Zero) + return; + MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm); @@ -90,6 +93,5 @@ namespace OpenSim.Data.MySQL return true; } - } } diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations index 91f7de5..1075a15 100644 --- a/OpenSim/Data/MySQL/Resources/Presence.migrations +++ b/OpenSim/Data/MySQL/Resources/Presence.migrations @@ -13,3 +13,11 @@ CREATE UNIQUE INDEX SessionID ON Presence(SessionID); CREATE INDEX UserID ON Presence(UserID); COMMIT; + +:VERSION 1 # -------------------------- + +BEGIN; + +ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp; + +COMMIT; -- cgit v1.1 From ccd5610997020df4ba1aafd73b6717bafecb025b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 21 Jun 2010 23:26:27 +0200 Subject: Correctly update the LastSeen field --- OpenSim/Data/MySQL/MySQLPresenceData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 7b0016b..81a48a8 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -83,7 +83,7 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm); + cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); -- cgit v1.1