aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs42
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs40
2 files changed, 39 insertions, 43 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 21362b9..c96139d 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -257,46 +257,44 @@ namespace OpenSim.Data.MySQL
257 } 257 }
258 258
259 /// <summary> 259 /// <summary>
260 /// Check if the asset exists in the database 260 /// Check if the assets exist in the database.
261 /// </summary> 261 /// </summary>
262 /// <param name="uuid">The asset UUID</param> 262 /// <param name="uuidss">The assets' IDs</param>
263 /// <returns>true if it exists, false otherwise.</returns> 263 /// <returns>For each asset: true if it exists, false otherwise</returns>
264 override public bool ExistsAsset(UUID uuid) 264 public override bool[] AssetsExist(UUID[] uuids)
265 { 265 {
266// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); 266 if (uuids.Length == 0)
267 return new bool[0];
267 268
268 bool assetExists = false; 269 HashSet<UUID> exist = new HashSet<UUID>();
270
271 string ids = "'" + string.Join("','", uuids) + "'";
272 string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
269 273
270 lock (m_dbLock) 274 lock (m_dbLock)
271 { 275 {
272 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 276 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
273 { 277 {
274 dbcon.Open(); 278 dbcon.Open();
275 using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon)) 279 using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
276 { 280 {
277 cmd.Parameters.AddWithValue("?id", uuid.ToString()); 281 using (MySqlDataReader dbReader = cmd.ExecuteReader())
278
279 try
280 { 282 {
281 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 283 while (dbReader.Read())
282 { 284 {
283 if (dbReader.Read()) 285 UUID id = DBGuid.FromDB(dbReader["id"]);
284 { 286 exist.Add(id);
285// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
286 assetExists = true;
287 }
288 } 287 }
289 } 288 }
290 catch (Exception e)
291 {
292 m_log.Error(
293 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", uuid), e);
294 }
295 } 289 }
296 } 290 }
297 } 291 }
298 292
299 return assetExists; 293 bool[] results = new bool[uuids.Length];
294 for (int i = 0; i < uuids.Length; i++)
295 results[i] = exist.Contains(uuids[i]);
296
297 return results;
300 } 298 }
301 299
302 /// <summary> 300 /// <summary>
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index 91389ce..1bf6a9a 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -397,45 +397,43 @@ namespace OpenSim.Data.MySQL
397 } 397 }
398 398
399 /// <summary> 399 /// <summary>
400 /// Check if the asset exists in the database 400 /// Check if the assets exist in the database.
401 /// </summary> 401 /// </summary>
402 /// <param name="uuid">The asset UUID</param> 402 /// <param name="uuids">The asset UUID's</param>
403 /// <returns>true if it exists, false otherwise.</returns> 403 /// <returns>For each asset: true if it exists, false otherwise</returns>
404 public bool ExistsAsset(UUID uuid) 404 public bool[] AssetsExist(UUID[] uuids)
405 { 405 {
406// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); 406 if (uuids.Length == 0)
407 return new bool[0];
408
409 HashSet<UUID> exists = new HashSet<UUID>();
407 410
408 bool assetExists = false; 411 string ids = "'" + string.Join("','", uuids) + "'";
412 string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids);
409 413
410 lock (m_dbLock) 414 lock (m_dbLock)
411 { 415 {
412 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 416 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
413 { 417 {
414 dbcon.Open(); 418 dbcon.Open();
415 using (MySqlCommand cmd = new MySqlCommand("SELECT ID FROM XAssetsMeta WHERE ID=?ID", dbcon)) 419 using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
416 { 420 {
417 cmd.Parameters.AddWithValue("?ID", uuid.ToString()); 421 using (MySqlDataReader dbReader = cmd.ExecuteReader())
418
419 try
420 { 422 {
421 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 423 while (dbReader.Read())
422 { 424 {
423 if (dbReader.Read()) 425 UUID id = DBGuid.FromDB(dbReader["ID"]);
424 { 426 exists.Add(id);
425// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
426 assetExists = true;
427 }
428 } 427 }
429 } 428 }
430 catch (Exception e)
431 {
432 m_log.Error(string.Format("[XASSETS DB]: MySql failure fetching asset {0}", uuid), e);
433 }
434 } 429 }
435 } 430 }
436 } 431 }
437 432
438 return assetExists; 433 bool[] results = new bool[uuids.Length];
434 for (int i = 0; i < uuids.Length; i++)
435 results[i] = exists.Contains(uuids[i]);
436 return results;
439 } 437 }
440 438
441 439