aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r--OpenSim/Data/MySQL/MySQLFSAssetData.cs27
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs48
2 files changed, 39 insertions, 36 deletions
diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs
index 2fb81ae..ce40c03 100644
--- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs
@@ -316,15 +316,16 @@ namespace OpenSim.Data.MySQL
316 return 0; 316 return 0;
317 } 317 }
318 318
319 MySqlCommand cmd = conn.CreateCommand(); 319 using(MySqlCommand cmd = conn.CreateCommand())
320
321 cmd.CommandText = String.Format("select count(*) as count from {0}", m_Table);
322
323 using (IDataReader reader = cmd.ExecuteReader())
324 { 320 {
325 reader.Read(); 321 cmd.CommandText = String.Format("select count(*) as count from {0}",m_Table);
322
323 using (IDataReader reader = cmd.ExecuteReader())
324 {
325 reader.Read();
326 326
327 count = Convert.ToInt32(reader["count"]); 327 count = Convert.ToInt32(reader["count"]);
328 }
328 } 329 }
329 } 330 }
330 331
@@ -333,15 +334,15 @@ namespace OpenSim.Data.MySQL
333 334
334 public bool Delete(string id) 335 public bool Delete(string id)
335 { 336 {
336 MySqlCommand cmd = new MySqlCommand(); 337 using(MySqlCommand cmd = new MySqlCommand())
337 338 {
338 cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table);
339 339
340 cmd.Parameters.AddWithValue("?id", id); 340 cmd.CommandText = String.Format("delete from {0} where id = ?id",m_Table);
341 341
342 ExecuteNonQuery(cmd); 342 cmd.Parameters.AddWithValue("?id", id);
343 343
344 cmd.Dispose(); 344 ExecuteNonQuery(cmd);
345 }
345 346
346 return true; 347 return true;
347 } 348 }
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index 68e1a5a..ec2bcc6 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -440,37 +440,39 @@ namespace OpenSim.Data.MySQL
440 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 440 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
441 { 441 {
442 dbcon.Open(); 442 dbcon.Open();
443 MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); 443 using(MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count",dbcon))
444 cmd.Parameters.AddWithValue("?start", start);
445 cmd.Parameters.AddWithValue("?count", count);
446
447 try
448 { 444 {
449 using (MySqlDataReader dbReader = cmd.ExecuteReader()) 445 cmd.Parameters.AddWithValue("?start",start);
446 cmd.Parameters.AddWithValue("?count", count);
447
448 try
450 { 449 {
451 while (dbReader.Read()) 450 using (MySqlDataReader dbReader = cmd.ExecuteReader())
452 { 451 {
453 AssetMetadata metadata = new AssetMetadata(); 452 while (dbReader.Read())
454 metadata.Name = (string)dbReader["Name"]; 453 {
455 metadata.Description = (string)dbReader["Description"]; 454 AssetMetadata metadata = new AssetMetadata();
456 metadata.Type = (sbyte)dbReader["AssetType"]; 455 metadata.Name = (string)dbReader["Name"];
457 metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. 456 metadata.Description = (string)dbReader["Description"];
458 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); 457 metadata.Type = (sbyte)dbReader["AssetType"];
459 metadata.FullID = DBGuid.FromDB(dbReader["ID"]); 458 metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
460 metadata.CreatorID = dbReader["CreatorID"].ToString(); 459 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
460 metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
461 metadata.CreatorID = dbReader["CreatorID"].ToString();
461 462
462 // We'll ignore this for now - it appears unused! 463 // We'll ignore this for now - it appears unused!
463// metadata.SHA1 = dbReader["hash"]); 464 // metadata.SHA1 = dbReader["hash"]);
464 465
465 UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); 466 UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
466 467
467 retList.Add(metadata); 468 retList.Add(metadata);
469 }
468 } 470 }
469 } 471 }
470 } 472 catch (Exception e)
471 catch (Exception e) 473 {
472 { 474 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
473 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); 475 }
474 } 476 }
475 } 477 }
476 478