From 8a0c5d14d45571c3e7529fdacea6f0483af482e5 Mon Sep 17 00:00:00 2001 From: AlexRa Date: Tue, 18 May 2010 14:28:12 +0300 Subject: All (?) MySQL stores fixed to use DBGuid.FromDB() This was needed if we want to update to the latest MySQL connector dll. It automatically converts CHAR(36) to Guids, so getting them as strings no longer works. By using DBGuid.FromDB(), we unlink from any particular storage format of GUIDs, could even make them BINARY(16) if we like. Actually not all MySql units are touched, but the remaining ones don't seem to be affected (they don't read GUIDs from DB) --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 33 +++++++++++++------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLInventoryData.cs') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index e0e9b9c..8fbe7a8 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -32,6 +32,7 @@ using log4net; using MySql.Data.MySqlClient; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Data; namespace OpenSim.Data.MySQL { @@ -285,31 +286,23 @@ namespace OpenSim.Data.MySQL InventoryItemBase item = new InventoryItemBase(); // TODO: this is to handle a case where NULLs creep in there, which we are not sure is endemic to the system, or legacy. It would be nice to live fix these. - if (reader["creatorID"] == null) - { - item.CreatorId = UUID.Zero.ToString(); - } - else - { - item.CreatorId = (string)reader["creatorID"]; - } + // ( DBGuid.FromDB() reads db NULLs as well, returns UUID.Zero ) + item.CreatorId = DBGuid.FromDB(reader["creatorID"]).ToString(); // Be a bit safer in parsing these because the // database doesn't enforce them to be not null, and // the inventory still works if these are weird in the // db - UUID Owner = UUID.Zero; - UUID GroupID = UUID.Zero; - UUID.TryParse((string)reader["avatarID"], out Owner); - UUID.TryParse((string)reader["groupID"], out GroupID); - item.Owner = Owner; - item.GroupID = GroupID; + + // (Empty is Ok, but "weird" will throw!) + item.Owner = DBGuid.FromDB(reader["avatarID"]); + item.GroupID = DBGuid.FromDB(reader["groupID"]); // Rest of the parsing. If these UUID's fail, we're dead anyway - item.ID = new UUID((string) reader["inventoryID"]); - item.AssetID = new UUID((string) reader["assetID"]); + item.ID = DBGuid.FromDB(reader["inventoryID"]); + item.AssetID = DBGuid.FromDB(reader["assetID"]); item.AssetType = (int) reader["assetType"]; - item.Folder = new UUID((string) reader["parentFolderID"]); + item.Folder = DBGuid.FromDB(reader["parentFolderID"]); item.Name = (string)(reader["inventoryName"] ?? String.Empty); item.Description = (string)(reader["inventoryDescription"] ?? String.Empty); item.NextPermissions = (uint) reader["inventoryNextPermissions"]; @@ -382,9 +375,9 @@ namespace OpenSim.Data.MySQL try { InventoryFolderBase folder = new InventoryFolderBase(); - folder.Owner = new UUID((string) reader["agentID"]); - folder.ParentID = new UUID((string) reader["parentFolderID"]); - folder.ID = new UUID((string) reader["folderID"]); + folder.Owner = DBGuid.FromDB(reader["agentID"]); + folder.ParentID = DBGuid.FromDB(reader["parentFolderID"]); + folder.ID = DBGuid.FromDB(reader["folderID"]); folder.Name = (string) reader["folderName"]; folder.Type = (short) reader["type"]; folder.Version = (ushort) ((int) reader["version"]); -- cgit v1.1 From deae0301456a169540aafc4ff1a574e1304e327d Mon Sep 17 00:00:00 2001 From: AlexRa Date: Wed, 19 May 2010 02:28:19 +0300 Subject: Some more corrections after MySQL connector update --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL/MySQLInventoryData.cs') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 8fbe7a8..0aea30f 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -287,7 +287,7 @@ namespace OpenSim.Data.MySQL // TODO: this is to handle a case where NULLs creep in there, which we are not sure is endemic to the system, or legacy. It would be nice to live fix these. // ( DBGuid.FromDB() reads db NULLs as well, returns UUID.Zero ) - item.CreatorId = DBGuid.FromDB(reader["creatorID"]).ToString(); + item.CreatorId = reader["creatorID"].ToString(); // Be a bit safer in parsing these because the // database doesn't enforce them to be not null, and -- cgit v1.1