move from index based to exists strategy here
parent
a27352010a
commit
7d6426f156
|
@ -117,13 +117,6 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
setupUserFriendsCommands(daf, conn);
|
setupUserFriendsCommands(daf, conn);
|
||||||
daf.Fill(ds.Tables["userfriends"]);
|
daf.Fill(ds.Tables["userfriends"]);
|
||||||
|
|
||||||
string Unique = "create unique index friend_unique on userfriends (ownerID,friendID)";
|
|
||||||
using (SqliteCommand cmd = new SqliteCommand(Unique, g_conn))
|
|
||||||
{
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -209,6 +202,36 @@ namespace OpenSim.Data.SQLite
|
||||||
|
|
||||||
#region User Friends List Data
|
#region User Friends List Data
|
||||||
|
|
||||||
|
private bool ExistsFriend(UUID owner, UUID friend)
|
||||||
|
{
|
||||||
|
string FindFriends = "select * from userfriends where (ownerID=:ownerID and friendID=:friendID) or (ownerID=:friendID and friendID=:ownerID)";
|
||||||
|
using (SqliteCommand cmd = new SqliteCommand(FindFriends, g_conn))
|
||||||
|
{
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":ownerID", owner.ToString()));
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString()));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (IDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
if(reader.Read())
|
||||||
|
{
|
||||||
|
reader.Close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
m_log.Error("[USER DB]: Exception getting friends list for user: " + ex.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a new friend in the friendlist
|
/// Add a new friend in the friendlist
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -217,7 +240,10 @@ namespace OpenSim.Data.SQLite
|
||||||
/// <param name="perms">permission flag</param>
|
/// <param name="perms">permission flag</param>
|
||||||
override public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
|
override public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
|
||||||
{
|
{
|
||||||
string InsertFriends = "insert or ignore into userfriends(ownerID, friendID, friendPerms) values(:ownerID, :friendID, :perms)";
|
if (ExistsFriend(friendlistowner, friend))
|
||||||
|
return;
|
||||||
|
|
||||||
|
string InsertFriends = "insert into userfriends(ownerID, friendID, friendPerms) values(:ownerID, :friendID, :perms)";
|
||||||
using (SqliteCommand cmd = new SqliteCommand(InsertFriends, g_conn))
|
using (SqliteCommand cmd = new SqliteCommand(InsertFriends, g_conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString()));
|
cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString()));
|
||||||
|
|
Loading…
Reference in New Issue