diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Data/MSSQL/MSSQLFriendsData.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLFriendsData.cs (renamed from OpenSim/Data/MSSQL/MSSQLFriendsData.cs) | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs b/OpenSim/Data/PGSQL/PGSQLFriendsData.cs index fef6978..a841353 100644 --- a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs +++ b/OpenSim/Data/PGSQL/PGSQLFriendsData.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -31,18 +31,18 @@ using System.Collections.Generic; | |||
31 | using System.Data; | 31 | using System.Data; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using System.Data.SqlClient; | ||
35 | using System.Reflection; | 34 | using System.Reflection; |
36 | using System.Text; | 35 | using System.Text; |
36 | using Npgsql; | ||
37 | 37 | ||
38 | namespace OpenSim.Data.MSSQL | 38 | namespace OpenSim.Data.PGSQL |
39 | { | 39 | { |
40 | public class MSSQLFriendsData : MSSQLGenericTableHandler<FriendsData>, IFriendsData | 40 | public class PGSQLFriendsData : PGSQLGenericTableHandler<FriendsData>, IFriendsData |
41 | { | 41 | { |
42 | public MSSQLFriendsData(string connectionString, string realm) | 42 | public PGSQLFriendsData(string connectionString, string realm) |
43 | : base(connectionString, realm, "FriendsStore") | 43 | : base(connectionString, realm, "FriendsStore") |
44 | { | 44 | { |
45 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 45 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
46 | { | 46 | { |
47 | conn.Open(); | 47 | conn.Open(); |
48 | Migration m = new Migration(conn, GetType().Assembly, "FriendsStore"); | 48 | Migration m = new Migration(conn, GetType().Assembly, "FriendsStore"); |
@@ -50,19 +50,27 @@ namespace OpenSim.Data.MSSQL | |||
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | public bool Delete(UUID principalID, string friend) | 53 | |
54 | public override bool Delete(string principalID, string friend) | ||
54 | { | 55 | { |
55 | return Delete(principalID.ToString(), friend); | 56 | UUID princUUID = UUID.Zero; |
57 | |||
58 | bool ret = UUID.TryParse(principalID, out princUUID); | ||
59 | |||
60 | if (ret) | ||
61 | return Delete(princUUID, friend); | ||
62 | else | ||
63 | return false; | ||
56 | } | 64 | } |
57 | 65 | ||
58 | public bool Delete(string principalID, string friend) | 66 | public bool Delete(UUID principalID, string friend) |
59 | { | 67 | { |
60 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 68 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
61 | using (SqlCommand cmd = new SqlCommand()) | 69 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
62 | { | 70 | { |
63 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = @PrincipalID and Friend = @Friend", m_Realm); | 71 | cmd.CommandText = String.Format("delete from {0} where \"PrincipalID\" = :PrincipalID and \"Friend\" = :Friend", m_Realm); |
64 | cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); | 72 | cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString())); |
65 | cmd.Parameters.Add(m_database.CreateParameter("@Friend", friend)); | 73 | cmd.Parameters.Add(m_database.CreateParameter("Friend", friend)); |
66 | cmd.Connection = conn; | 74 | cmd.Connection = conn; |
67 | conn.Open(); | 75 | conn.Open(); |
68 | cmd.ExecuteNonQuery(); | 76 | cmd.ExecuteNonQuery(); |
@@ -71,19 +79,28 @@ namespace OpenSim.Data.MSSQL | |||
71 | } | 79 | } |
72 | } | 80 | } |
73 | 81 | ||
74 | public FriendsData[] GetFriends(UUID principalID) | 82 | public FriendsData[] GetFriends(string principalID) |
75 | { | 83 | { |
76 | return GetFriends(principalID.ToString()); | 84 | UUID princUUID = UUID.Zero; |
85 | |||
86 | bool ret = UUID.TryParse(principalID, out princUUID); | ||
87 | |||
88 | if (ret) | ||
89 | return GetFriends(princUUID); | ||
90 | else | ||
91 | return new FriendsData[0]; | ||
77 | } | 92 | } |
78 | 93 | ||
79 | public FriendsData[] GetFriends(string principalID) | 94 | public FriendsData[] GetFriends(UUID principalID) |
80 | { | 95 | { |
81 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 96 | using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) |
82 | using (SqlCommand cmd = new SqlCommand()) | 97 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
83 | { | 98 | { |
84 | 99 | ||
85 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = @PrincipalID", m_Realm); | 100 | cmd.CommandText = String.Format("select a.*,case when b.\"Flags\" is null then '-1' else b.\"Flags\" end as \"TheirFlags\" from {0} as a " + |
86 | cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); | 101 | " left join {0} as b on a.\"PrincipalID\" = b.\"Friend\" and a.\"Friend\" = b.\"PrincipalID\" " + |
102 | " where a.\"PrincipalID\" = :PrincipalID", m_Realm); | ||
103 | cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString())); | ||
87 | cmd.Connection = conn; | 104 | cmd.Connection = conn; |
88 | conn.Open(); | 105 | conn.Open(); |
89 | return DoQuery(cmd); | 106 | return DoQuery(cmd); |
@@ -92,7 +109,7 @@ namespace OpenSim.Data.MSSQL | |||
92 | 109 | ||
93 | public FriendsData[] GetFriends(Guid principalID) | 110 | public FriendsData[] GetFriends(Guid principalID) |
94 | { | 111 | { |
95 | return GetFriends(principalID.ToString()); | 112 | return GetFriends(principalID); |
96 | } | 113 | } |
97 | 114 | ||
98 | } | 115 | } |