diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLDataStore.cs | 121 | ||||
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs | 107 |
2 files changed, 117 insertions, 111 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 | ||
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs index 76848cf..ba50dca 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs | |||
@@ -1258,63 +1258,66 @@ namespace OpenSim.Framework.Data.SQLite | |||
1258 | 1258 | ||
1259 | MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID); | 1259 | MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID); |
1260 | 1260 | ||
1261 | // Find all existing inventory rows for this prim | 1261 | lock (ds) |
1262 | DataTable dbItems = ds.Tables["primitems"]; | ||
1263 | |||
1264 | String sql = String.Format("primID = '{0}'", primID); | ||
1265 | DataRow[] dbItemRows = dbItems.Select(sql); | ||
1266 | |||
1267 | // Build structures for manipulation purposes | ||
1268 | IDictionary<String, DataRow> dbItemsToRemove = new Dictionary<String, DataRow>(); | ||
1269 | ICollection<TaskInventoryItem> itemsToAdd | ||
1270 | = new List<TaskInventoryItem>(); | ||
1271 | |||
1272 | foreach (DataRow row in dbItemRows) | ||
1273 | { | ||
1274 | dbItemsToRemove.Add((String)row["itemID"], row); | ||
1275 | } | ||
1276 | |||
1277 | // Eliminate rows from the deletion set which already exist for this prim's inventory | ||
1278 | // TODO Very temporary, need to take account of simple metadata changes soon | ||
1279 | lock (items) | ||
1280 | { | 1262 | { |
1281 | foreach (LLUUID itemId in items.Keys) | 1263 | // Find all existing inventory rows for this prim |
1264 | DataTable dbItems = ds.Tables["primitems"]; | ||
1265 | |||
1266 | String sql = String.Format("primID = '{0}'", primID); | ||
1267 | DataRow[] dbItemRows = dbItems.Select(sql); | ||
1268 | |||
1269 | // Build structures for manipulation purposes | ||
1270 | IDictionary<String, DataRow> dbItemsToRemove = new Dictionary<String, DataRow>(); | ||
1271 | ICollection<TaskInventoryItem> itemsToAdd | ||
1272 | = new List<TaskInventoryItem>(); | ||
1273 | |||
1274 | foreach (DataRow row in dbItemRows) | ||
1282 | { | 1275 | { |
1283 | String rawItemId = itemId.ToString(); | 1276 | dbItemsToRemove.Add((String)row["itemID"], row); |
1284 | 1277 | } | |
1285 | if (dbItemsToRemove.ContainsKey(rawItemId)) | 1278 | |
1286 | { | 1279 | // Eliminate rows from the deletion set which already exist for this prim's inventory |
1287 | dbItemsToRemove.Remove(rawItemId); | 1280 | // TODO Very temporary, need to take account of simple metadata changes soon |
1288 | } | 1281 | lock (items) |
1289 | else | 1282 | { |
1283 | foreach (LLUUID itemId in items.Keys) | ||
1290 | { | 1284 | { |
1291 | itemsToAdd.Add(items[itemId]); | 1285 | String rawItemId = itemId.ToString(); |
1292 | } | 1286 | |
1293 | } | 1287 | if (dbItemsToRemove.ContainsKey(rawItemId)) |
1294 | } | 1288 | { |
1295 | 1289 | dbItemsToRemove.Remove(rawItemId); | |
1296 | // Delete excess rows | 1290 | } |
1297 | foreach (DataRow row in dbItemsToRemove.Values) | 1291 | else |
1298 | { | 1292 | { |
1299 | MainLog.Instance.Verbose( | 1293 | itemsToAdd.Add(items[itemId]); |
1300 | "DATASTORE", | 1294 | } |
1301 | "Removing item {0}, {1} from prim ID {2}", | 1295 | } |
1302 | row["name"], row["itemID"], row["primID"]); | 1296 | } |
1303 | 1297 | ||
1304 | row.Delete(); | 1298 | // Delete excess rows |
1305 | } | 1299 | foreach (DataRow row in dbItemsToRemove.Values) |
1306 | 1300 | { | |
1307 | // Insert items not already present | 1301 | MainLog.Instance.Verbose( |
1308 | foreach (TaskInventoryItem newItem in itemsToAdd) | 1302 | "DATASTORE", |
1309 | { | 1303 | "Removing item {0}, {1} from prim ID {2}", |
1310 | MainLog.Instance.Verbose( | 1304 | row["name"], row["itemID"], row["primID"]); |
1311 | "DATASTORE", | 1305 | |
1312 | "Adding item {0}, {1} to prim ID {2}", | 1306 | row.Delete(); |
1313 | newItem.Name, newItem.ItemID, newItem.ParentPartID); | 1307 | } |
1314 | 1308 | ||
1315 | DataRow newItemRow = dbItems.NewRow(); | 1309 | // Insert items not already present |
1316 | fillItemRow(newItemRow, newItem); | 1310 | foreach (TaskInventoryItem newItem in itemsToAdd) |
1317 | dbItems.Rows.Add(newItemRow); | 1311 | { |
1312 | MainLog.Instance.Verbose( | ||
1313 | "DATASTORE", | ||
1314 | "Adding item {0}, {1} to prim ID {2}", | ||
1315 | newItem.Name, newItem.ItemID, newItem.ParentPartID); | ||
1316 | |||
1317 | DataRow newItemRow = dbItems.NewRow(); | ||
1318 | fillItemRow(newItemRow, newItem); | ||
1319 | dbItems.Rows.Add(newItemRow); | ||
1320 | } | ||
1318 | } | 1321 | } |
1319 | } | 1322 | } |
1320 | 1323 | ||