From 48be04df1d804137a736d83de157265555a63d31 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 11 Jan 2008 17:00:21 +0000 Subject: * Do database implementation for prim inventory items in mysql * Properly clean up items when a region object is deleted * Update persisted prim when an inventory script is changed * No user functionality yet --- OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs | 51 +++++++++++++++-------- 1 file changed, 34 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework/Data.SQLite') diff --git a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs index 96dd5ac..dfd4535 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs @@ -61,6 +61,7 @@ namespace OpenSim.Framework.Data.SQLite private String m_connectionString; + // Temporary attribute while this is experimental private bool persistPrimInventories; /*********************************************************************** @@ -208,6 +209,7 @@ namespace OpenSim.Framework.Data.SQLite { DataTable prims = ds.Tables["prims"]; DataTable shapes = ds.Tables["primshapes"]; + DataTable items = ds.Tables["primitems"]; string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "'"; lock (ds) @@ -215,13 +217,28 @@ namespace OpenSim.Framework.Data.SQLite DataRow[] primRows = prims.Select(selectExp); foreach (DataRow row in primRows) { + // Remove shape rows LLUUID uuid = new LLUUID((string) row["UUID"]); DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(uuid)); if (shapeRow != null) { shapeRow.Delete(); } - row.Delete(); + + if (persistPrimInventories) + { + // Remove items rows + String sql = String.Format("primID = '{0}'", uuid); + DataRow[] itemRows = items.Select(sql); + + foreach (DataRow itemsRow in itemRows) + { + itemsRow.Delete(); + } + } + + // Remove prim row + row.Delete(); } } @@ -1444,6 +1461,20 @@ namespace OpenSim.Framework.Data.SQLite param.SourceColumn = name; param.SourceVersion = DataRowVersion.Current; return param; + } + + private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn) + { + da.InsertCommand = createInsertCommand("prims", ds.Tables["prims"]); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("prims", "UUID=:UUID", ds.Tables["prims"]); + da.UpdateCommand.Connection = conn; + + SqliteCommand delete = new SqliteCommand("delete from prims where UUID = :UUID"); + delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); + delete.Connection = conn; + da.DeleteCommand = delete; } private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn) @@ -1460,20 +1491,6 @@ namespace OpenSim.Framework.Data.SQLite da.DeleteCommand = delete; } - private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn) - { - da.InsertCommand = createInsertCommand("prims", ds.Tables["prims"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("prims", "UUID=:UUID", ds.Tables["prims"]); - da.UpdateCommand.Connection = conn; - - SqliteCommand delete = new SqliteCommand("delete from prims where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - private void setupTerrainCommands(SqliteDataAdapter da, SqliteConnection conn) { da.InsertCommand = createInsertCommand("terrain", ds.Tables["terrain"]); @@ -1656,8 +1673,8 @@ namespace OpenSim.Framework.Data.SQLite return false; } } - - // TODO Not restoring prim inventories quite yet + + // XXX primitems should probably go here eventually foreach (DataColumn col in createTerrainTable().Columns) { -- cgit v1.1