aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLDataStore.cs')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLDataStore.cs121
1 files changed, 62 insertions, 59 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
index 698569a..a752236 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
@@ -1203,72 +1203,75 @@ namespace OpenSim.Framework.Data.MySQL
1203 1203
1204 MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID); 1204 MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID);
1205 1205
1206 // Find all existing inventory rows for this prim 1206 lock (m_dataSet)
1207 DataTable dbItems = m_itemsTable; 1207 {
1208 1208 // Find all existing inventory rows for this prim
1209 String sql = String.Format("primID = '{0}'", primID); 1209 DataTable dbItems = m_itemsTable;
1210 DataRow[] dbItemRows = dbItems.Select(sql); 1210
1211 1211 String sql = String.Format("primID = '{0}'", primID);
1212 // Build structures for manipulation purposes 1212 DataRow[] dbItemRows = dbItems.Select(sql);
1213 IDictionary<String, DataRow> dbItemsToRemove = new Dictionary<String, DataRow>();
1214 ICollection<TaskInventoryItem> itemsToAdd = new List<TaskInventoryItem>();
1215
1216 foreach (DataRow row in dbItemRows)
1217 {
1218// MainLog.Instance.Verbose(
1219// "DATASTORE",
1220// "Found item {0}, {1} in prim id {2}",
1221// row["name"], row["itemID"], primID);
1222 1213
1223 dbItemsToRemove.Add((String)row["itemID"], row); 1214 // Build structures for manipulation purposes
1224 } 1215 IDictionary<String, DataRow> dbItemsToRemove = new Dictionary<String, DataRow>();
1225 1216 ICollection<TaskInventoryItem> itemsToAdd = new List<TaskInventoryItem>();
1226 // Eliminate rows from the deletion set which already exist for this prim's inventory 1217
1227 // TODO Very temporary, need to take account of simple metadata changes soon 1218 foreach (DataRow row in dbItemRows)
1228 lock (items)
1229 {
1230 foreach (LLUUID itemId in items.Keys)
1231 { 1219 {
1232 String rawItemId = itemId.ToString(); 1220 // MainLog.Instance.Verbose(
1221 // "DATASTORE",
1222 // "Found item {0}, {1} in prim id {2}",
1223 // row["name"], row["itemID"], primID);
1233 1224
1234 if (dbItemsToRemove.ContainsKey(rawItemId)) 1225 dbItemsToRemove.Add((String)row["itemID"], row);
1226 }
1227
1228 // Eliminate rows from the deletion set which already exist for this prim's inventory
1229 // TODO Very temporary, need to take account of simple metadata changes soon
1230 lock (items)
1231 {
1232 foreach (LLUUID itemId in items.Keys)
1235 { 1233 {
1236// MainLog.Instance.Verbose( 1234 String rawItemId = itemId.ToString();
1237// "DATASTORE",
1238// "Discarding item {0}, {1} from remove candidates for prim id {2}",
1239// items[itemId].Name, rawItemId, primID);
1240 1235
1241 dbItemsToRemove.Remove(rawItemId); 1236 if (dbItemsToRemove.ContainsKey(rawItemId))
1242 } 1237 {
1243 else 1238 // MainLog.Instance.Verbose(
1244 { 1239 // "DATASTORE",
1245 itemsToAdd.Add(items[itemId]); 1240 // "Discarding item {0}, {1} from remove candidates for prim id {2}",
1246 } 1241 // items[itemId].Name, rawItemId, primID);
1247 } 1242
1248 } 1243 dbItemsToRemove.Remove(rawItemId);
1249 1244 }
1250 // Delete excess rows 1245 else
1251 foreach (DataRow row in dbItemsToRemove.Values) 1246 {
1252 { 1247 itemsToAdd.Add(items[itemId]);
1253 MainLog.Instance.Verbose( 1248 }
1254 "DATASTORE", 1249 }
1255 "Removing item {0}, {1} from prim ID {2}", 1250 }
1256 row["name"], row["itemID"], row["primID"]);
1257 1251
1258 row.Delete(); 1252 // Delete excess rows
1259 } 1253 foreach (DataRow row in dbItemsToRemove.Values)
1260 1254 {
1261 // Insert items not already present 1255 MainLog.Instance.Verbose(
1262 foreach (TaskInventoryItem newItem in itemsToAdd) 1256 "DATASTORE",
1263 { 1257 "Removing item {0}, {1} from prim ID {2}",
1264 MainLog.Instance.Verbose( 1258 row["name"], row["itemID"], row["primID"]);
1265 "DATASTORE", 1259
1266 "Adding item {0}, {1} to prim ID {2}", 1260 row.Delete();
1267 newItem.Name, newItem.ItemID, newItem.ParentPartID); 1261 }
1268 1262
1269 DataRow newItemRow = dbItems.NewRow(); 1263 // Insert items not already present
1270 fillItemRow(newItemRow, newItem); 1264 foreach (TaskInventoryItem newItem in itemsToAdd)
1271 dbItems.Rows.Add(newItemRow); 1265 {
1266 MainLog.Instance.Verbose(
1267 "DATASTORE",
1268 "Adding item {0}, {1} to prim ID {2}",
1269 newItem.Name, newItem.ItemID, newItem.ParentPartID);
1270
1271 DataRow newItemRow = dbItems.NewRow();
1272 fillItemRow(newItemRow, newItem);
1273 dbItems.Rows.Add(newItemRow);
1274 }
1272 } 1275 }
1273 } 1276 }
1274 1277