aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteUserData.cs
diff options
context:
space:
mode:
authorSean Dague2008-10-14 20:07:11 +0000
committerSean Dague2008-10-14 20:07:11 +0000
commit7d6426f156a428d9d2b0b0478845b25bec87a1ff (patch)
tree742d83b77d3d5d38960a589af9483cdf6964295a /OpenSim/Data/SQLite/SQLiteUserData.cs
parentMerge commit 'arthur/master' (diff)
downloadopensim-SC-7d6426f156a428d9d2b0b0478845b25bec87a1ff.zip
opensim-SC-7d6426f156a428d9d2b0b0478845b25bec87a1ff.tar.gz
opensim-SC-7d6426f156a428d9d2b0b0478845b25bec87a1ff.tar.bz2
opensim-SC-7d6426f156a428d9d2b0b0478845b25bec87a1ff.tar.xz
move from index based to exists strategy here
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserData.cs46
1 files changed, 36 insertions, 10 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs
index 4beae07..420b6e5 100644
--- a/OpenSim/Data/SQLite/SQLiteUserData.cs
+++ b/OpenSim/Data/SQLite/SQLiteUserData.cs
@@ -117,13 +117,6 @@ namespace OpenSim.Data.SQLite
117 117
118 setupUserFriendsCommands(daf, conn); 118 setupUserFriendsCommands(daf, conn);
119 daf.Fill(ds.Tables["userfriends"]); 119 daf.Fill(ds.Tables["userfriends"]);
120
121 string Unique = "create unique index friend_unique on userfriends (ownerID,friendID)";
122 using (SqliteCommand cmd = new SqliteCommand(Unique, g_conn))
123 {
124 cmd.ExecuteNonQuery();
125 }
126
127 } 120 }
128 121
129 return; 122 return;
@@ -206,9 +199,39 @@ namespace OpenSim.Data.SQLite
206 } 199 }
207 } 200 }
208 } 201 }
209 202
210 #region User Friends List Data 203 #region User Friends List Data
211 204
205 private bool ExistsFriend(UUID owner, UUID friend)
206 {
207 string FindFriends = "select * from userfriends where (ownerID=:ownerID and friendID=:friendID) or (ownerID=:friendID and friendID=:ownerID)";
208 using (SqliteCommand cmd = new SqliteCommand(FindFriends, g_conn))
209 {
210 cmd.Parameters.Add(new SqliteParameter(":ownerID", owner.ToString()));
211 cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString()));
212 try
213 {
214 using (IDataReader reader = cmd.ExecuteReader())
215 {
216 if(reader.Read())
217 {
218 reader.Close();
219 return true;
220 }
221 else
222 {
223 reader.Close();
224 return false;
225 }
226 }
227 }
228 catch (Exception ex)
229 {
230 m_log.Error("[USER DB]: Exception getting friends list for user: " + ex.ToString());
231 return false;
232 }
233 }
234 }
212 /// <summary> 235 /// <summary>
213 /// Add a new friend in the friendlist 236 /// Add a new friend in the friendlist
214 /// </summary> 237 /// </summary>
@@ -217,7 +240,10 @@ namespace OpenSim.Data.SQLite
217 /// <param name="perms">permission flag</param> 240 /// <param name="perms">permission flag</param>
218 override public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) 241 override public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
219 { 242 {
220 string InsertFriends = "insert or ignore into userfriends(ownerID, friendID, friendPerms) values(:ownerID, :friendID, :perms)"; 243 if (ExistsFriend(friendlistowner, friend))
244 return;
245
246 string InsertFriends = "insert into userfriends(ownerID, friendID, friendPerms) values(:ownerID, :friendID, :perms)";
221 using (SqliteCommand cmd = new SqliteCommand(InsertFriends, g_conn)) 247 using (SqliteCommand cmd = new SqliteCommand(InsertFriends, g_conn))
222 { 248 {
223 cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString())); 249 cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString()));