diff options
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLManager.cs | 86 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserData.cs | 48 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql | 63 |
3 files changed, 109 insertions, 88 deletions
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 7e1b405..4b11739 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs | |||
@@ -191,6 +191,12 @@ namespace OpenSim.Data.MySQL | |||
191 | cmd.ExecuteNonQuery(); | 191 | cmd.ExecuteNonQuery(); |
192 | } | 192 | } |
193 | 193 | ||
194 | public void ExecuteSql(string sql) | ||
195 | { | ||
196 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | ||
197 | cmd.ExecuteNonQuery(); | ||
198 | } | ||
199 | |||
194 | /// <summary> | 200 | /// <summary> |
195 | /// Given a list of tables, return the version of the tables, as seen in the database | 201 | /// Given a list of tables, return the version of the tables, as seen in the database |
196 | /// </summary> | 202 | /// </summary> |
@@ -532,38 +538,42 @@ namespace OpenSim.Data.MySQL | |||
532 | 538 | ||
533 | public AvatarAppearance readAppearanceRow(IDataReader reader) | 539 | public AvatarAppearance readAppearanceRow(IDataReader reader) |
534 | { | 540 | { |
535 | AvatarAppearance appearance = new AvatarAppearance(); | 541 | AvatarAppearance appearance = null; |
536 | appearance.Owner = new LLUUID((string)reader["owner"]); | 542 | if (reader.Read()) |
537 | appearance.Serial = Convert.ToInt32(reader["serial"]); | 543 | { |
538 | appearance.VisualParams = (byte[])reader["visual_params"]; | 544 | appearance = new AvatarAppearance(); |
539 | appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); | 545 | appearance.Owner = new LLUUID((string)reader["owner"]); |
540 | appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); | 546 | appearance.Serial = Convert.ToInt32(reader["serial"]); |
541 | appearance.BodyItem = new LLUUID((string)reader["body_item"]); | 547 | appearance.VisualParams = (byte[])reader["visual_params"]; |
542 | appearance.BodyAsset = new LLUUID((string)reader["body_asset"]); | 548 | appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length); |
543 | appearance.SkinItem = new LLUUID((string)reader["skin_item"]); | 549 | appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]); |
544 | appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]); | 550 | appearance.BodyItem = new LLUUID((string)reader["body_item"]); |
545 | appearance.HairItem = new LLUUID((string)reader["hair_item"]); | 551 | appearance.BodyAsset = new LLUUID((string)reader["body_asset"]); |
546 | appearance.HairAsset = new LLUUID((string)reader["hair_asset"]); | 552 | appearance.SkinItem = new LLUUID((string)reader["skin_item"]); |
547 | appearance.EyesItem = new LLUUID((string)reader["eyes_item"]); | 553 | appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]); |
548 | appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]); | 554 | appearance.HairItem = new LLUUID((string)reader["hair_item"]); |
549 | appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]); | 555 | appearance.HairAsset = new LLUUID((string)reader["hair_asset"]); |
550 | appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]); | 556 | appearance.EyesItem = new LLUUID((string)reader["eyes_item"]); |
551 | appearance.PantsItem = new LLUUID((string)reader["pants_item"]); | 557 | appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]); |
552 | appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]); | 558 | appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]); |
553 | appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]); | 559 | appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]); |
554 | appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]); | 560 | appearance.PantsItem = new LLUUID((string)reader["pants_item"]); |
555 | appearance.SocksItem = new LLUUID((string)reader["socks_item"]); | 561 | appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]); |
556 | appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]); | 562 | appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]); |
557 | appearance.JacketItem = new LLUUID((string)reader["jacket_item"]); | 563 | appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]); |
558 | appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]); | 564 | appearance.SocksItem = new LLUUID((string)reader["socks_item"]); |
559 | appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]); | 565 | appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]); |
560 | appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]); | 566 | appearance.JacketItem = new LLUUID((string)reader["jacket_item"]); |
561 | appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]); | 567 | appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]); |
562 | appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]); | 568 | appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]); |
563 | appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]); | 569 | appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]); |
564 | appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]); | 570 | appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]); |
565 | appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]); | 571 | appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]); |
566 | appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]); | 572 | appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]); |
573 | appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]); | ||
574 | appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]); | ||
575 | appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]); | ||
576 | } | ||
567 | return appearance; | 577 | return appearance; |
568 | } | 578 | } |
569 | 579 | ||
@@ -1007,10 +1017,10 @@ namespace OpenSim.Data.MySQL | |||
1007 | MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); | 1017 | MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); |
1008 | cmd.CommandText = sql; | 1018 | cmd.CommandText = sql; |
1009 | cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); | 1019 | cmd.Parameters.AddWithValue("?owner", appearance.Owner.ToString()); |
1010 | cmd.Parameters.AddWithValue("?serial", appearance.Serial.ToString()); | 1020 | cmd.Parameters.AddWithValue("?serial", appearance.Serial); |
1011 | cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); | 1021 | cmd.Parameters.AddWithValue("?visual_params", appearance.VisualParams); |
1012 | cmd.Parameters.AddWithValue("?texture", appearance.Texture.ToBytes()); | 1022 | cmd.Parameters.AddWithValue("?texture", appearance.Texture.ToBytes()); |
1013 | cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight.ToString()); | 1023 | cmd.Parameters.AddWithValue("?avatar_height", appearance.AvatarHeight); |
1014 | cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); | 1024 | cmd.Parameters.AddWithValue("?body_item", appearance.BodyItem.ToString()); |
1015 | cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); | 1025 | cmd.Parameters.AddWithValue("?body_asset", appearance.BodyAsset.ToString()); |
1016 | cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); | 1026 | cmd.Parameters.AddWithValue("?skin_item", appearance.SkinItem.ToString()); |
@@ -1037,12 +1047,10 @@ namespace OpenSim.Data.MySQL | |||
1037 | cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); | 1047 | cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); |
1038 | cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); | 1048 | cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); |
1039 | cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); | 1049 | cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); |
1040 | 1050 | ||
1041 | int x; | 1051 | if (cmd.ExecuteNonQuery() > 0) |
1042 | if ((x = cmd.ExecuteNonQuery()) > 0) | ||
1043 | { | ||
1044 | returnval = true; | 1052 | returnval = true; |
1045 | } | 1053 | |
1046 | cmd.Dispose(); | 1054 | cmd.Dispose(); |
1047 | } | 1055 | } |
1048 | catch (Exception e) | 1056 | catch (Exception e) |
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 56bdcbf..35bcb1d 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs | |||
@@ -34,8 +34,6 @@ using libsecondlife; | |||
34 | using log4net; | 34 | using log4net; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Data.Base; | 36 | using OpenSim.Data.Base; |
37 | using OpenSim.Data.MapperFactory; | ||
38 | using OpenSim.Data.MySQLMapper; | ||
39 | 37 | ||
40 | namespace OpenSim.Data.MySQL | 38 | namespace OpenSim.Data.MySQL |
41 | { | 39 | { |
@@ -56,8 +54,6 @@ namespace OpenSim.Data.MySQL | |||
56 | private string m_userFriendsTableName; | 54 | private string m_userFriendsTableName; |
57 | private string m_appearanceTableName = "avatarappearance"; | 55 | private string m_appearanceTableName = "avatarappearance"; |
58 | private string m_connectString; | 56 | private string m_connectString; |
59 | private BaseDatabaseConnector m_databaseMapper; | ||
60 | private AppearanceTableMapper m_appearanceMapper; | ||
61 | 57 | ||
62 | /// <summary> | 58 | /// <summary> |
63 | /// Loads and initialises the MySQL storage plugin | 59 | /// Loads and initialises the MySQL storage plugin |
@@ -107,15 +103,6 @@ namespace OpenSim.Data.MySQL | |||
107 | database = new MySQLManager(m_connectString); | 103 | database = new MySQLManager(m_connectString); |
108 | } | 104 | } |
109 | 105 | ||
110 | string mapperTypeStr = "MySQL"; | ||
111 | DataMapperFactory.MAPPER_TYPE mapperType = | ||
112 | (DataMapperFactory.MAPPER_TYPE) | ||
113 | Enum.Parse(typeof (DataMapperFactory.MAPPER_TYPE), mapperTypeStr); | ||
114 | |||
115 | m_databaseMapper = DataMapperFactory.GetDataBaseMapper(mapperType, m_connectString); | ||
116 | |||
117 | m_appearanceMapper = new AppearanceTableMapper(m_databaseMapper, "AvatarAppearance"); | ||
118 | |||
119 | TestTables(); | 106 | TestTables(); |
120 | } | 107 | } |
121 | 108 | ||
@@ -203,6 +190,12 @@ namespace OpenSim.Data.MySQL | |||
203 | { | 190 | { |
204 | database.ExecuteResourceSql("CreateAvatarAppearance.sql"); | 191 | database.ExecuteResourceSql("CreateAvatarAppearance.sql"); |
205 | return; | 192 | return; |
193 | } | ||
194 | else if (oldVersion.Contains("Rev.1")) | ||
195 | { | ||
196 | database.ExecuteSql("drop table avatarappearance"); | ||
197 | database.ExecuteResourceSql("CreateAvatarAppearance.sql"); | ||
198 | return; | ||
206 | } | 199 | } |
207 | } | 200 | } |
208 | 201 | ||
@@ -676,18 +669,35 @@ namespace OpenSim.Data.MySQL | |||
676 | // override | 669 | // override |
677 | override public AvatarAppearance GetUserAppearance(LLUUID user) | 670 | override public AvatarAppearance GetUserAppearance(LLUUID user) |
678 | { | 671 | { |
679 | AvatarAppearance appearance = null; | 672 | try { |
680 | if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance)) | 673 | lock (database) |
674 | { | ||
675 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
676 | param["?owner"] = user.ToString(); | ||
677 | |||
678 | IDbCommand result = database.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); | ||
679 | IDataReader reader = result.ExecuteReader(); | ||
680 | |||
681 | AvatarAppearance appearance = database.readAppearanceRow(reader); | ||
682 | |||
683 | reader.Close(); | ||
684 | result.Dispose(); | ||
685 | |||
686 | return appearance; | ||
687 | } | ||
688 | } | ||
689 | catch (Exception e) | ||
681 | { | 690 | { |
682 | appearance = null; | 691 | database.Reconnect(); |
692 | m_log.Error(e.ToString()); | ||
693 | return null; | ||
683 | } | 694 | } |
684 | return appearance; | ||
685 | } | 695 | } |
686 | |||
687 | // override | 696 | // override |
688 | override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) | 697 | override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) |
689 | { | 698 | { |
690 | m_appearanceMapper.Update(user.UUID, appearance); | 699 | appearance.Owner = user; |
700 | database.insertAppearanceRow(appearance); | ||
691 | } | 701 | } |
692 | 702 | ||
693 | override public void AddAttachment(LLUUID user, LLUUID item) | 703 | override public void AddAttachment(LLUUID user, LLUUID item) |
diff --git a/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql b/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql index 0deb099..475c933 100644 --- a/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql +++ b/OpenSim/Data/MySQL/Resources/CreateAvatarAppearance.sql | |||
@@ -4,36 +4,39 @@ | |||
4 | 4 | ||
5 | DROP TABLE IF EXISTS `avatarappearance`; | 5 | DROP TABLE IF EXISTS `avatarappearance`; |
6 | CREATE TABLE `avatarappearance` ( | 6 | CREATE TABLE `avatarappearance` ( |
7 | `UUID` char(36) NOT NULL, | 7 | Owner char(36) NOT NULL, |
8 | `Serial` int(10) unsigned NOT NULL, | 8 | Serial int(10) unsigned NOT NULL, |
9 | `WearableItem0` char(36) NOT NULL, | 9 | Visual_Params blob NOT NULL, |
10 | `WearableAsset0` char(36) NOT NULL, | 10 | Texture blob NOT NULL, |
11 | `WearableItem1` char(36) NOT NULL, | 11 | Avatar_Height float NOT NULL, |
12 | `WearableAsset1` char(36) NOT NULL, | 12 | Body_Item char(36) NOT NULL, |
13 | `WearableItem2` char(36) NOT NULL, | 13 | Body_Asset char(36) NOT NULL, |
14 | `WearableAsset2` char(36) NOT NULL, | 14 | Skin_Item char(36) NOT NULL, |
15 | `WearableItem3` char(36) NOT NULL, | 15 | Skin_Asset char(36) NOT NULL, |
16 | `WearableAsset3` char(36) NOT NULL, | 16 | Hair_Item char(36) NOT NULL, |
17 | `WearableItem4` char(36) NOT NULL, | 17 | Hair_Asset char(36) NOT NULL, |
18 | `WearableAsset4` char(36) NOT NULL, | 18 | Eyes_Item char(36) NOT NULL, |
19 | `WearableItem5` char(36) NOT NULL, | 19 | Eyes_Asset char(36) NOT NULL, |
20 | `WearableAsset5` char(36) NOT NULL, | 20 | Shirt_Item char(36) NOT NULL, |
21 | `WearableItem6` char(36) NOT NULL, | 21 | Shirt_Asset char(36) NOT NULL, |
22 | `WearableAsset6` char(36) NOT NULL, | 22 | Pants_Item char(36) NOT NULL, |
23 | `WearableItem7` char(36) NOT NULL, | 23 | Pants_Asset char(36) NOT NULL, |
24 | `WearableAsset7` char(36) NOT NULL, | 24 | Shoes_Item char(36) NOT NULL, |
25 | `WearableItem8` char(36) NOT NULL, | 25 | Shoes_Asset char(36) NOT NULL, |
26 | `WearableAsset8` char(36) NOT NULL, | 26 | Socks_Item char(36) NOT NULL, |
27 | `WearableItem9` char(36) NOT NULL, | 27 | Socks_Asset char(36) NOT NULL, |
28 | `WearableAsset9` char(36) NOT NULL, | 28 | Jacket_Item char(36) NOT NULL, |
29 | `WearableItem10` char(36) NOT NULL, | 29 | Jacket_Asset char(36) NOT NULL, |
30 | `WearableAsset10` char(36) NOT NULL, | 30 | Gloves_Item char(36) NOT NULL, |
31 | `WearableItem11` char(36) NOT NULL, | 31 | Gloves_Asset char(36) NOT NULL, |
32 | `WearableAsset11` char(36) NOT NULL, | 32 | Undershirt_Item char(36) NOT NULL, |
33 | `WearableItem12` char(36) NOT NULL, | 33 | Undershirt_Asset char(36) NOT NULL, |
34 | `WearableAsset12` char(36) NOT NULL, | 34 | Underpants_Item char(36) NOT NULL, |
35 | Underpants_Asset char(36) NOT NULL, | ||
36 | Skirt_Item char(36) NOT NULL, | ||
37 | Skirt_Asset char(36) NOT NULL, | ||
35 | 38 | ||
36 | 39 | ||
37 | PRIMARY KEY (`UUID`) | 40 | PRIMARY KEY (`Owner`) |
38 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.1'; | 41 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev.2'; |
39 | 42 | ||