aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLRegionData.cs
diff options
context:
space:
mode:
authorSean Dague2008-12-08 16:29:48 +0000
committerSean Dague2008-12-08 16:29:48 +0000
commita260466147b47de1d51539b5c23429440d94124f (patch)
tree6552f23a3865baa1fcc755feb063b83e67ad3fec /OpenSim/Data/MySQL/MySQLRegionData.cs
parent* Killed off OpenSimExport. One project less to maintain. (diff)
downloadopensim-SC-a260466147b47de1d51539b5c23429440d94124f.zip
opensim-SC-a260466147b47de1d51539b5c23429440d94124f.tar.gz
opensim-SC-a260466147b47de1d51539b5c23429440d94124f.tar.bz2
opensim-SC-a260466147b47de1d51539b5c23429440d94124f.tar.xz
fix an issue I found where primshapes weren't every being removed
because of a logic error. attempt to speed up deletes a bit by batching up all the primitem deletes and primshape deletes into single delete statements. This removes the lock/release/lock/release/lock/release for loop.
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLRegionData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs91
1 files changed, 82 insertions, 9 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 8c49531..4dc0685 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -300,20 +300,22 @@ namespace OpenSim.Data.MySQL
300 reader.Close(); 300 reader.Close();
301 } 301 }
302 302
303 foreach (UUID uuid in uuids) 303 // delete the main prims
304 RemoveItems(uuid);
305
306 cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; 304 cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
307
308 ExecuteNonQuery(cmd);
309
310 cmd.CommandText = "delete from primshapes where UUID = ?UUID";
311
312 ExecuteNonQuery(cmd); 305 ExecuteNonQuery(cmd);
313 cmd.Dispose(); 306 cmd.Dispose();
307
308 // there is no way this should be < 1 unless there is
309 // a very corrupt database, but in that case be extra
310 // safe anyway.
311 if (uuids.Count > 0)
312 {
313 RemoveShapes(uuids);
314 RemoveItems(uuids);
315 }
314 } 316 }
315 } 317 }
316 318
317 /// <summary> 319 /// <summary>
318 /// Remove all persisted items of the given prim. 320 /// Remove all persisted items of the given prim.
319 /// The caller must acquire the necessrary synchronization locks 321 /// The caller must acquire the necessrary synchronization locks
@@ -335,6 +337,77 @@ namespace OpenSim.Data.MySQL
335 } 337 }
336 } 338 }
337 339
340
341 /// <summary>
342 /// Remove all persisted shapes for a list of prims
343 /// The caller must acquire the necessrary synchronization locks
344 /// </summary>
345 /// <param name="uuids">the list of UUIDs</param>
346 private void RemoveShapes(List<UUID> uuids)
347 {
348 lock (m_Connection)
349 {
350 string sql = "delete from primshapes where ";
351 MySqlCommand cmd = m_Connection.CreateCommand();
352
353 for (int i = 0; i < uuids.Count; i++)
354 {
355 if ((i + 1) == uuids.Count)
356 {// end of the list
357 sql += "(UUID = ?UUID" + i + ")";
358 }
359 else
360 {
361 sql += "(UUID = ?UUID" + i + ") or ";
362 }
363 }
364 cmd.CommandText = sql;
365
366 for (int i = 0; i < uuids.Count; i++)
367 {
368 cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString());
369 }
370
371 ExecuteNonQuery(cmd);
372 cmd.Dispose();
373 }
374 }
375
376 /// <summary>
377 /// Remove all persisted items for a list of prims
378 /// The caller must acquire the necessrary synchronization locks
379 /// </summary>
380 /// <param name="uuids">the list of UUIDs</param>
381 private void RemoveItems(List<UUID> uuids)
382 {
383 lock (m_Connection)
384 {
385 string sql = "delete from primitems where ";
386 MySqlCommand cmd = m_Connection.CreateCommand();
387
388 for (int i = 0; i < uuids.Count; i++)
389 {
390 if ((i + 1) == uuids.Count)
391 {// end of the list
392 sql += "(PrimID = ?PrimID" + i + ")";
393 }
394 else
395 {
396 sql += "(PrimID = ?PrimID" + i + ") or ";
397 }
398 }
399 cmd.CommandText = sql;
400
401 for (int i = 0; i < uuids.Count; i++)
402 {
403 cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString());
404 }
405
406 ExecuteNonQuery(cmd);
407 cmd.Dispose();
408 }
409 }
410
338 public List<SceneObjectGroup> LoadObjects(UUID regionUUID) 411 public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
339 { 412 {
340 UUID lastGroupID = UUID.Zero; 413 UUID lastGroupID = UUID.Zero;