diff options
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLFSAssetData.cs | 27 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLXAssetData.cs | 48 | ||||
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLXAssetData.cs | 52 |
3 files changed, 66 insertions, 61 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 | ||
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs index 4f682f0..d3518cf 100644 --- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs +++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs | |||
@@ -518,40 +518,42 @@ namespace OpenSim.Data.PGSQL | |||
518 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | 518 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) |
519 | { | 519 | { |
520 | dbcon.Open(); | 520 | dbcon.Open(); |
521 | NpgsqlCommand cmd = new NpgsqlCommand( @"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid | 521 | using(NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid |
522 | FROM XAssetsMeta | 522 | FROM XAssetsMeta |
523 | LIMIT :start, :count", dbcon); | 523 | LIMIT :start, :count",dbcon)) |
524 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); | ||
525 | cmd.Parameters.Add(m_database.CreateParameter("count", count)); | ||
526 | |||
527 | try | ||
528 | { | 524 | { |
529 | using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) | 525 | cmd.Parameters.Add(m_database.CreateParameter("start",start)); |
526 | cmd.Parameters.Add(m_database.CreateParameter("count", count)); | ||
527 | |||
528 | try | ||
530 | { | 529 | { |
531 | while (dbReader.Read()) | 530 | using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) |
532 | { | 531 | { |
533 | AssetMetadata metadata = new AssetMetadata(); | 532 | while (dbReader.Read()) |
534 | metadata.Name = (string)dbReader["name"]; | 533 | { |
535 | metadata.Description = (string)dbReader["description"]; | 534 | AssetMetadata metadata = new AssetMetadata(); |
536 | metadata.Type = Convert.ToSByte(dbReader["AssetType"]); | 535 | metadata.Name = (string)dbReader["name"]; |
537 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); | 536 | metadata.Description = (string)dbReader["description"]; |
538 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 537 | metadata.Type = Convert.ToSByte(dbReader["AssetType"]); |
539 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 538 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); |
540 | metadata.CreatorID = dbReader["creatorid"].ToString(); | 539 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); |
540 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | ||
541 | metadata.CreatorID = dbReader["creatorid"].ToString(); | ||
541 | 542 | ||
542 | // We'll ignore this for now - it appears unused! | 543 | // We'll ignore this for now - it appears unused! |
543 | // metadata.SHA1 = dbReader["hash"]); | 544 | // metadata.SHA1 = dbReader["hash"]); |
544 | 545 | ||
545 | UpdateAccessTime(metadata, (int)dbReader["access_time"]); | 546 | UpdateAccessTime(metadata, (int)dbReader["access_time"]); |
546 | 547 | ||
547 | retList.Add(metadata); | 548 | retList.Add(metadata); |
549 | } | ||
548 | } | 550 | } |
549 | } | 551 | } |
550 | } | 552 | catch (Exception e) |
551 | catch (Exception e) | 553 | { |
552 | { | 554 | m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString()); |
553 | m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString()); | 555 | } |
554 | } | 556 | } |
555 | } | 557 | } |
556 | } | 558 | } |
557 | 559 | ||