aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/PGSQL')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLAssetData.cs35
-rw-r--r--OpenSim/Data/PGSQL/PGSQLXAssetData.cs37
2 files changed, 65 insertions, 7 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLAssetData.cs b/OpenSim/Data/PGSQL/PGSQLAssetData.cs
index ab74856..ca18dc9 100644
--- a/OpenSim/Data/PGSQL/PGSQLAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLAssetData.cs
@@ -231,17 +231,38 @@ namespace OpenSim.Data.PGSQL
231// } 231// }
232 232
233 /// <summary> 233 /// <summary>
234 /// Check if asset exist in m_database 234 /// Check if the assets exist in the database.
235 /// </summary> 235 /// </summary>
236 /// <param name="uuid"></param> 236 /// <param name="uuids">The assets' IDs</param>
237 /// <returns>true if exist.</returns> 237 /// <returns>For each asset: true if it exists, false otherwise</returns>
238 override public bool ExistsAsset(UUID uuid) 238 public override bool[] AssetsExist(UUID[] uuids)
239 { 239 {
240 if (GetAsset(uuid) != null) 240 if (uuids.Length == 0)
241 return new bool[0];
242
243 HashSet<UUID> exist = new HashSet<UUID>();
244
245 string ids = "'" + string.Join("','", uuids) + "'";
246 string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
247
248 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
249 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
241 { 250 {
242 return true; 251 conn.Open();
252 using (NpgsqlDataReader reader = cmd.ExecuteReader())
253 {
254 while (reader.Read())
255 {
256 UUID id = DBGuid.FromDB(reader["id"]);
257 exist.Add(id);
258 }
259 }
243 } 260 }
244 return false; 261
262 bool[] results = new bool[uuids.Length];
263 for (int i = 0; i < uuids.Length; i++)
264 results[i] = exist.Contains(uuids[i]);
265 return results;
245 } 266 }
246 267
247 /// <summary> 268 /// <summary>
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
index e959619..c6cebff 100644
--- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
@@ -407,6 +407,43 @@ namespace OpenSim.Data.PGSQL
407 } 407 }
408 408
409 /// <summary> 409 /// <summary>
410 /// Check if the assets exist in the database.
411 /// </summary>
412 /// <param name="uuids">The assets' IDs</param>
413 /// <returns>For each asset: true if it exists, false otherwise</returns>
414 public bool[] AssetsExist(UUID[] uuids)
415 {
416 if (uuids.Length == 0)
417 return new bool[0];
418
419 HashSet<UUID> exist = new HashSet<UUID>();
420
421 string ids = "'" + string.Join("','", uuids) + "'";
422 string sql = string.Format(@"SELECT ""ID"" FROM XAssetsMeta WHERE ""ID"" IN ({0})", ids);
423
424 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
425 {
426 conn.Open();
427 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
428 {
429 using (NpgsqlDataReader reader = cmd.ExecuteReader())
430 {
431 while (reader.Read())
432 {
433 UUID id = DBGuid.FromDB(reader["id"]);
434 exist.Add(id);
435 }
436 }
437 }
438 }
439
440 bool[] results = new bool[uuids.Length];
441 for (int i = 0; i < uuids.Length; i++)
442 results[i] = exist.Contains(uuids[i]);
443 return results;
444 }
445
446 /// <summary>
410 /// Check if the asset exists in the database 447 /// Check if the asset exists in the database
411 /// </summary> 448 /// </summary>
412 /// <param name="uuid">The asset UUID</param> 449 /// <param name="uuid">The asset UUID</param>