mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
a few changes on mysql RemoveObject()
This commit is contained in:
@@ -30,6 +30,7 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using MySql.Data.MySqlClient;
|
||||
using OpenMetaverse;
|
||||
@@ -260,16 +261,7 @@ namespace OpenSim.Data.MySQL
|
||||
{
|
||||
// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID);
|
||||
|
||||
List<UUID> uuids = new List<UUID>();
|
||||
|
||||
// Formerly, this used to check the region UUID.
|
||||
// That makes no sense, as we remove the contents of a prim
|
||||
// unconditionally, but the prim dependent on the region ID.
|
||||
// So, we would destroy an object and cause hard to detect
|
||||
// issues if we delete the contents only. Deleting it all may
|
||||
// cause the loss of a prim, but is cleaner.
|
||||
// It's also faster because it uses the primary key.
|
||||
//
|
||||
List<string> uuids = new List<string>();
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
@@ -284,24 +276,49 @@ namespace OpenSim.Data.MySQL
|
||||
using (IDataReader reader = ExecuteReader(cmd))
|
||||
{
|
||||
while (reader.Read())
|
||||
uuids.Add(DBGuid.FromDB(reader["UUID"].ToString()));
|
||||
uuids.Add(reader["UUID"].ToString());
|
||||
}
|
||||
|
||||
if(uuids.Count == 0)
|
||||
{
|
||||
dbcon.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
// delete the main prims
|
||||
cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
dbcon.Close();
|
||||
}
|
||||
}
|
||||
|
||||
// there is no way this should be < 1 unless there is
|
||||
// a very corrupt database, but in that case be extra
|
||||
// safe anyway.
|
||||
if (uuids.Count > 0)
|
||||
{
|
||||
RemoveShapes(uuids);
|
||||
RemoveItems(uuids);
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
string sqlparams;
|
||||
if (uuids.Count > 1)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(uuids.Count * 37);
|
||||
sb.Append("IN (");
|
||||
for(int i = 0; i < uuids.Count - 1; ++i )
|
||||
{
|
||||
sb.Append("'");
|
||||
sb.Append(uuids[i]);
|
||||
sb.Append("',");
|
||||
}
|
||||
sb.Append("'");
|
||||
sb.Append(uuids[uuids.Count - 1]);
|
||||
sb.Append("')");
|
||||
sqlparams = sb.ToString();
|
||||
}
|
||||
else
|
||||
sqlparams = "='" + uuids[0] + "'";
|
||||
|
||||
cmd.CommandText = "delete from primshapes where UUID " + sqlparams;
|
||||
ExecuteNonQuery(cmd);
|
||||
|
||||
cmd.CommandText = "delete from primitems where PrimID " + sqlparams;
|
||||
ExecuteNonQuery(cmd);
|
||||
|
||||
dbcon.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user