diff options
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--] | OpenSim/Data/PGSQL/PGSQLPresenceData.cs (renamed from OpenSim/Data/MSSQL/MSSQLPresenceData.cs) | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs b/OpenSim/Data/PGSQL/PGSQLPresenceData.cs index 0c71e79..0376585 100644..100755 --- a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs +++ b/OpenSim/Data/PGSQL/PGSQLPresenceData.cs | |||
@@ -33,27 +33,26 @@ using System.Threading; | |||
33 | using log4net; | 33 | using log4net; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using System.Data.SqlClient; | 36 | using Npgsql; |
37 | 37 | ||
38 | namespace OpenSim.Data.MSSQL | 38 | namespace OpenSim.Data.PGSQL |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// A MySQL Interface for the Presence Server | 41 | /// A PGSQL Interface for the Presence Server |
42 | /// </summary> | 42 | /// </summary> |
43 | public class MSSQLPresenceData : MSSQLGenericTableHandler<PresenceData>, | 43 | public class PGSQLPresenceData : PGSQLGenericTableHandler<PresenceData>, |
44 | IPresenceData | 44 | IPresenceData |
45 | { | 45 | { |
46 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | public MSSQLPresenceData(string connectionString, string realm) : | 48 | public PGSQLPresenceData(string connectionString, string realm) : |
49 | base(connectionString, realm, "Presence") | 49 | base(connectionString, realm, "Presence") |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | public PresenceData Get(UUID sessionID) | 53 | public PresenceData Get(UUID sessionID) |
54 | { | 54 | { |
55 | PresenceData[] ret = Get("SessionID", | 55 | PresenceData[] ret = Get("SessionID", sessionID.ToString()); |
56 | sessionID.ToString()); | ||
57 | 56 | ||
58 | if (ret.Length == 0) | 57 | if (ret.Length == 0) |
59 | return null; | 58 | return null; |
@@ -63,13 +62,13 @@ namespace OpenSim.Data.MSSQL | |||
63 | 62 | ||
64 | public void LogoutRegionAgents(UUID regionID) | 63 | public void LogoutRegionAgents(UUID regionID) |
65 | { | 64 | { |
66 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 65 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
67 | using (SqlCommand cmd = new SqlCommand()) | 66 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
68 | { | 67 | { |
69 | 68 | ||
70 | cmd.CommandText = String.Format("DELETE FROM {0} WHERE [RegionID]=@RegionID", m_Realm); | 69 | cmd.CommandText = String.Format("DELETE FROM {0} WHERE \"RegionID\" = :regionID", m_Realm); |
71 | 70 | ||
72 | cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); | 71 | cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID)); |
73 | cmd.Connection = conn; | 72 | cmd.Connection = conn; |
74 | conn.Open(); | 73 | conn.Open(); |
75 | cmd.ExecuteNonQuery(); | 74 | cmd.ExecuteNonQuery(); |
@@ -81,17 +80,18 @@ namespace OpenSim.Data.MSSQL | |||
81 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); | 80 | PresenceData[] pd = Get("SessionID", sessionID.ToString()); |
82 | if (pd.Length == 0) | 81 | if (pd.Length == 0) |
83 | return false; | 82 | return false; |
83 | |||
84 | if (regionID == UUID.Zero) | ||
85 | return false; | ||
84 | 86 | ||
85 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 87 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
86 | using (SqlCommand cmd = new SqlCommand()) | 88 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
87 | { | 89 | { |
88 | 90 | ||
89 | cmd.CommandText = String.Format(@"UPDATE {0} SET | 91 | cmd.CommandText = String.Format("UPDATE {0} SET \"RegionID\" = :regionID, \"LastSeen\" = now() WHERE \"SessionID\" = :sessionID", m_Realm); |
90 | [RegionID] = @RegionID | ||
91 | WHERE [SessionID] = @SessionID", m_Realm); | ||
92 | 92 | ||
93 | cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString())); | 93 | cmd.Parameters.Add(m_database.CreateParameter("SessionID", sessionID)); |
94 | cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); | 94 | cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID)); |
95 | cmd.Connection = conn; | 95 | cmd.Connection = conn; |
96 | conn.Open(); | 96 | conn.Open(); |
97 | if (cmd.ExecuteNonQuery() == 0) | 97 | if (cmd.ExecuteNonQuery() == 0) |
@@ -102,8 +102,7 @@ namespace OpenSim.Data.MSSQL | |||
102 | 102 | ||
103 | public bool VerifyAgent(UUID agentId, UUID secureSessionID) | 103 | public bool VerifyAgent(UUID agentId, UUID secureSessionID) |
104 | { | 104 | { |
105 | PresenceData[] ret = Get("SecureSessionID", | 105 | PresenceData[] ret = Get("SecureSessionID", secureSessionID.ToString()); |
106 | secureSessionID.ToString()); | ||
107 | 106 | ||
108 | if (ret.Length == 0) | 107 | if (ret.Length == 0) |
109 | return false; | 108 | return false; |