aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLRegionData.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-02-19 18:09:10 +0000
committerJustin Clarke Casey2009-02-19 18:09:10 +0000
commit07609565617aa7936758acba5fd625877564a10d (patch)
tree73123e37f14fea5f171cbe04753c21758f25afc1 /OpenSim/Data/MSSQL/MSSQLRegionData.cs
parent* Okay, so finally got my head around this. Problem is that upstream Prebuild... (diff)
downloadopensim-SC_OLD-07609565617aa7936758acba5fd625877564a10d.zip
opensim-SC_OLD-07609565617aa7936758acba5fd625877564a10d.tar.gz
opensim-SC_OLD-07609565617aa7936758acba5fd625877564a10d.tar.bz2
opensim-SC_OLD-07609565617aa7936758acba5fd625877564a10d.tar.xz
* Apply http://opensimulator.org/mantis/view.php?id=3142
* Changes varchar(36) columns to UUID type in MSSQL - this will be much more efficient * ===As always, please, please backup your database before applying this patch=== * Thanks Ruud Lathrop (for the patch) and StrawberryFride (for the review)
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLRegionData.cs')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLRegionData.cs105
1 files changed, 54 insertions, 51 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs
index 44b042e..d9565d4 100644
--- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs
@@ -128,7 +128,7 @@ namespace OpenSim.Data.MSSQL
128 sceneObjectPart.FolderID = sceneObjectPart.UUID; 128 sceneObjectPart.FolderID = sceneObjectPart.UUID;
129 sceneObjectParts.Add(sceneObjectPart); 129 sceneObjectParts.Add(sceneObjectPart);
130 130
131 UUID groupID = new UUID(reader["SceneGroupID"].ToString()); 131 UUID groupID = new UUID((Guid)reader["SceneGroupID"]);
132 132
133 if (groupID != lastGroupID) // New SOG 133 if (groupID != lastGroupID) // New SOG
134 { 134 {
@@ -198,7 +198,7 @@ namespace OpenSim.Data.MSSQL
198 } 198 }
199 else 199 else
200 { 200 {
201 command.Parameters["@PrimID"].Value = objectPart.UUID.ToString(); 201 command.Parameters["@PrimID"].Value = objectPart.UUID.Guid; //.ToString(); //TODO check if this works
202 } 202 }
203 203
204 List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); 204 List<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
@@ -418,15 +418,16 @@ ELSE
418 _Log.InfoFormat("[MSSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID); 418 _Log.InfoFormat("[MSSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID);
419 419
420 //Remove from prims and primsitem table 420 //Remove from prims and primsitem table
421 string sqlPrims = string.Format("DELETE FROM PRIMS WHERE SceneGroupID = '{0}'", objectID); 421 string sqlPrims = "DELETE FROM PRIMS WHERE SceneGroupID = @objectID";
422 string sqlPrimItems = string.Format("DELETE FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE SceneGroupID = '{0}')", objectID); 422 string sqlPrimItems = "DELETE FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)";
423 string sqlPrimShapes = string.Format("DELETE FROM PRIMSHAPES WHERE uuid in (SELECT UUID FROM PRIMS WHERE SceneGroupID = '{0}')", objectID); 423 string sqlPrimShapes = "DELETE FROM PRIMSHAPES WHERE uuid in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)";
424 424
425 lock (_Database) 425 lock (_Database)
426 { 426 {
427 //Using the non transaction mode. 427 //Using the non transaction mode.
428 using (AutoClosingSqlCommand cmd = _Database.Query(sqlPrimShapes)) 428 using (AutoClosingSqlCommand cmd = _Database.Query(sqlPrimShapes))
429 { 429 {
430 cmd.Parameters.Add(_Database.CreateParameter("objectID", objectID));
430 cmd.ExecuteNonQuery(); 431 cmd.ExecuteNonQuery();
431 432
432 cmd.CommandText = sqlPrimItems; 433 cmd.CommandText = sqlPrimItems;
@@ -495,7 +496,7 @@ ELSE
495 using (AutoClosingSqlCommand cmd = _Database.Query(sql)) 496 using (AutoClosingSqlCommand cmd = _Database.Query(sql))
496 { 497 {
497 // MySqlParameter param = new MySqlParameter(); 498 // MySqlParameter param = new MySqlParameter();
498 cmd.Parameters.AddWithValue("@RegionUUID", regionID.ToString()); 499 cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
499 500
500 using (SqlDataReader reader = cmd.ExecuteReader()) 501 using (SqlDataReader reader = cmd.ExecuteReader())
501 { 502 {
@@ -805,7 +806,7 @@ VALUES
805 //TODO change this is some more generic code so we doesnt have to change it every time a new field is added? 806 //TODO change this is some more generic code so we doesnt have to change it every time a new field is added?
806 RegionSettings newSettings = new RegionSettings(); 807 RegionSettings newSettings = new RegionSettings();
807 808
808 newSettings.RegionUUID = new UUID((string)row["regionUUID"]); 809 newSettings.RegionUUID = new UUID((Guid)row["regionUUID"]);
809 newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); 810 newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]);
810 newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); 811 newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]);
811 newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); 812 newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]);
@@ -819,10 +820,10 @@ VALUES
819 newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); 820 newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]);
820 newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); 821 newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]);
821 newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); 822 newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]);
822 newSettings.TerrainTexture1 = new UUID((String)row["terrain_texture_1"]); 823 newSettings.TerrainTexture1 = new UUID((Guid)row["terrain_texture_1"]);
823 newSettings.TerrainTexture2 = new UUID((String)row["terrain_texture_2"]); 824 newSettings.TerrainTexture2 = new UUID((Guid)row["terrain_texture_2"]);
824 newSettings.TerrainTexture3 = new UUID((String)row["terrain_texture_3"]); 825 newSettings.TerrainTexture3 = new UUID((Guid)row["terrain_texture_3"]);
825 newSettings.TerrainTexture4 = new UUID((String)row["terrain_texture_4"]); 826 newSettings.TerrainTexture4 = new UUID((Guid)row["terrain_texture_4"]);
826 newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); 827 newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]);
827 newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); 828 newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]);
828 newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); 829 newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]);
@@ -843,7 +844,7 @@ VALUES
843 Convert.ToSingle(row["sunvectory"]), 844 Convert.ToSingle(row["sunvectory"]),
844 Convert.ToSingle(row["sunvectorz"]) 845 Convert.ToSingle(row["sunvectorz"])
845 ); 846 );
846 newSettings.Covenant = new UUID((String)row["covenant"]); 847 newSettings.Covenant = new UUID((Guid)row["covenant"]);
847 848
848 return newSettings; 849 return newSettings;
849 } 850 }
@@ -857,15 +858,15 @@ VALUES
857 { 858 {
858 LandData newData = new LandData(); 859 LandData newData = new LandData();
859 860
860 newData.GlobalID = new UUID((String)row["UUID"]); 861 newData.GlobalID = new UUID((Guid)row["UUID"]);
861 newData.LocalID = Convert.ToInt32(row["LocalLandID"]); 862 newData.LocalID = Convert.ToInt32(row["LocalLandID"]);
862 863
863 // Bitmap is a byte[512] 864 // Bitmap is a byte[512]
864 newData.Bitmap = (Byte[])row["Bitmap"]; 865 newData.Bitmap = (Byte[])row["Bitmap"];
865 866
866 newData.Name = (String)row["Name"]; 867 newData.Name = (string)row["Name"];
867 newData.Description = (String)row["Description"]; 868 newData.Description = (string)row["Description"];
868 newData.OwnerID = (UUID)(String)row["OwnerUUID"]; 869 newData.OwnerID = new UUID((Guid)row["OwnerUUID"]);
869 newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); 870 newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]);
870 newData.Area = Convert.ToInt32(row["Area"]); 871 newData.Area = Convert.ToInt32(row["Area"]);
871 newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented 872 newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented
@@ -873,27 +874,29 @@ VALUES
873 //Enum libsecondlife.Parcel.ParcelCategory 874 //Enum libsecondlife.Parcel.ParcelCategory
874 newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); 875 newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]);
875 newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); 876 newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]);
876 newData.GroupID = new UUID((String)row["GroupUUID"]); 877 newData.GroupID = new UUID((Guid)row["GroupUUID"]);
877 newData.SalePrice = Convert.ToInt32(row["SalePrice"]); 878 newData.SalePrice = Convert.ToInt32(row["SalePrice"]);
878 newData.Status = (Parcel.ParcelStatus)Convert.ToInt32(row["LandStatus"]); 879 newData.Status = (Parcel.ParcelStatus)Convert.ToInt32(row["LandStatus"]);
879 //Enum. libsecondlife.Parcel.ParcelStatus 880 //Enum. libsecondlife.Parcel.ParcelStatus
880 newData.Flags = Convert.ToUInt32(row["LandFlags"]); 881 newData.Flags = Convert.ToUInt32(row["LandFlags"]);
881 newData.LandingType = Convert.ToByte(row["LandingType"]); 882 newData.LandingType = Convert.ToByte(row["LandingType"]);
882 newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); 883 newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]);
883 newData.MediaID = new UUID((String)row["MediaTextureUUID"]); 884 newData.MediaID = new UUID((Guid)row["MediaTextureUUID"]);
884 newData.MediaURL = (String)row["MediaURL"]; 885 newData.MediaURL = (string)row["MediaURL"];
885 newData.MusicURL = (String)row["MusicURL"]; 886 newData.MusicURL = (string)row["MusicURL"];
886 newData.PassHours = Convert.ToSingle(row["PassHours"]); 887 newData.PassHours = Convert.ToSingle(row["PassHours"]);
887 newData.PassPrice = Convert.ToInt32(row["PassPrice"]); 888 newData.PassPrice = Convert.ToInt32(row["PassPrice"]);
888 889
889 UUID authedbuyer; 890// UUID authedbuyer;
890 UUID snapshotID; 891// UUID snapshotID;
891 892//
892 if (UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer)) 893// if (UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer))
893 newData.AuthBuyerID = authedbuyer; 894// newData.AuthBuyerID = authedbuyer;
894 895//
895 if (UUID.TryParse((string)row["SnapshotUUID"], out snapshotID)) 896// if (UUID.TryParse((string)row["SnapshotUUID"], out snapshotID))
896 newData.SnapshotID = snapshotID; 897// newData.SnapshotID = snapshotID;
898 newData.AuthBuyerID = new UUID((Guid) row["AuthBuyerID"]);
899 newData.SnapshotID = new UUID((Guid)row["SnapshotUUID"]);
897 900
898 newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); 901 newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]);
899 newData.Dwell = Convert.ToInt32(row["Dwell"]); 902 newData.Dwell = Convert.ToInt32(row["Dwell"]);
@@ -927,7 +930,7 @@ VALUES
927 private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataRecord row) 930 private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataRecord row)
928 { 931 {
929 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 932 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
930 entry.AgentID = new UUID((string)row["AccessUUID"]); 933 entry.AgentID = new UUID((Guid)row["AccessUUID"]);
931 entry.Flags = (AccessList)Convert.ToInt32(row["Flags"]); 934 entry.Flags = (AccessList)Convert.ToInt32(row["Flags"]);
932 entry.Time = new DateTime(); 935 entry.Time = new DateTime();
933 return entry; 936 return entry;
@@ -942,26 +945,26 @@ VALUES
942 { 945 {
943 SceneObjectPart prim = new SceneObjectPart(); 946 SceneObjectPart prim = new SceneObjectPart();
944 947
945 prim.UUID = new UUID((String)primRow["UUID"]); 948 prim.UUID = new UUID((Guid)primRow["UUID"]);
946 // explicit conversion of integers is required, which sort 949 // explicit conversion of integers is required, which sort
947 // of sucks. No idea if there is a shortcut here or not. 950 // of sucks. No idea if there is a shortcut here or not.
948 prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]); 951 prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]);
949 prim.Name = (String)primRow["Name"]; 952 prim.Name = (string)primRow["Name"];
950 // various text fields 953 // various text fields
951 prim.Text = (String)primRow["Text"]; 954 prim.Text = (string)primRow["Text"];
952 prim.Color = Color.FromArgb(Convert.ToInt32(primRow["ColorA"]), 955 prim.Color = Color.FromArgb(Convert.ToInt32(primRow["ColorA"]),
953 Convert.ToInt32(primRow["ColorR"]), 956 Convert.ToInt32(primRow["ColorR"]),
954 Convert.ToInt32(primRow["ColorG"]), 957 Convert.ToInt32(primRow["ColorG"]),
955 Convert.ToInt32(primRow["ColorB"])); 958 Convert.ToInt32(primRow["ColorB"]));
956 prim.Description = (String)primRow["Description"]; 959 prim.Description = (string)primRow["Description"];
957 prim.SitName = (String)primRow["SitName"]; 960 prim.SitName = (string)primRow["SitName"];
958 prim.TouchName = (String)primRow["TouchName"]; 961 prim.TouchName = (string)primRow["TouchName"];
959 // permissions 962 // permissions
960 prim.ObjectFlags = Convert.ToUInt32(primRow["ObjectFlags"]); 963 prim.ObjectFlags = Convert.ToUInt32(primRow["ObjectFlags"]);
961 prim.CreatorID = new UUID((String)primRow["CreatorID"]); 964 prim.CreatorID = new UUID((Guid)primRow["CreatorID"]);
962 prim.OwnerID = new UUID((String)primRow["OwnerID"]); 965 prim.OwnerID = new UUID((Guid)primRow["OwnerID"]);
963 prim.GroupID = new UUID((String)primRow["GroupID"]); 966 prim.GroupID = new UUID((Guid)primRow["GroupID"]);
964 prim.LastOwnerID = new UUID((String)primRow["LastOwnerID"]); 967 prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]);
965 prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]); 968 prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]);
966 prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]); 969 prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]);
967 prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]); 970 prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]);
@@ -1017,7 +1020,7 @@ VALUES
1017 prim.PayPrice[3] = Convert.ToInt32(primRow["PayButton3"]); 1020 prim.PayPrice[3] = Convert.ToInt32(primRow["PayButton3"]);
1018 prim.PayPrice[4] = Convert.ToInt32(primRow["PayButton4"]); 1021 prim.PayPrice[4] = Convert.ToInt32(primRow["PayButton4"]);
1019 1022
1020 prim.Sound = new UUID(primRow["LoopedSound"].ToString()); 1023 prim.Sound = new UUID((Guid)primRow["LoopedSound"]);
1021 prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]); 1024 prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]);
1022 prim.SoundFlags = 1; // If it's persisted at all, it's looped 1025 prim.SoundFlags = 1; // If it's persisted at all, it's looped
1023 1026
@@ -1062,7 +1065,7 @@ VALUES
1062 if (!(primRow["ClickAction"] is DBNull)) 1065 if (!(primRow["ClickAction"] is DBNull))
1063 prim.ClickAction = Convert.ToByte(primRow["ClickAction"]); 1066 prim.ClickAction = Convert.ToByte(primRow["ClickAction"]);
1064 1067
1065 prim.CollisionSound = new UUID(primRow["CollisionSound"].ToString()); 1068 prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]);
1066 prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); 1069 prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]);
1067 1070
1068 prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]); 1071 prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]);
@@ -1131,21 +1134,21 @@ VALUES
1131 { 1134 {
1132 TaskInventoryItem taskItem = new TaskInventoryItem(); 1135 TaskInventoryItem taskItem = new TaskInventoryItem();
1133 1136
1134 taskItem.ItemID = new UUID((String)inventoryRow["itemID"]); 1137 taskItem.ItemID = new UUID((Guid)inventoryRow["itemID"]);
1135 taskItem.ParentPartID = new UUID((String)inventoryRow["primID"]); 1138 taskItem.ParentPartID = new UUID((Guid)inventoryRow["primID"]);
1136 taskItem.AssetID = new UUID((String)inventoryRow["assetID"]); 1139 taskItem.AssetID = new UUID((Guid)inventoryRow["assetID"]);
1137 taskItem.ParentID = new UUID((String)inventoryRow["parentFolderID"]); 1140 taskItem.ParentID = new UUID((Guid)inventoryRow["parentFolderID"]);
1138 1141
1139 taskItem.InvType = Convert.ToInt32(inventoryRow["invType"]); 1142 taskItem.InvType = Convert.ToInt32(inventoryRow["invType"]);
1140 taskItem.Type = Convert.ToInt32(inventoryRow["assetType"]); 1143 taskItem.Type = Convert.ToInt32(inventoryRow["assetType"]);
1141 1144
1142 taskItem.Name = (String)inventoryRow["name"]; 1145 taskItem.Name = (string)inventoryRow["name"];
1143 taskItem.Description = (String)inventoryRow["description"]; 1146 taskItem.Description = (string)inventoryRow["description"];
1144 taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]); 1147 taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]);
1145 taskItem.CreatorID = new UUID((String)inventoryRow["creatorID"]); 1148 taskItem.CreatorID = new UUID((Guid)inventoryRow["creatorID"]);
1146 taskItem.OwnerID = new UUID((String)inventoryRow["ownerID"]); 1149 taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]);
1147 taskItem.LastOwnerID = new UUID((String)inventoryRow["lastOwnerID"]); 1150 taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]);
1148 taskItem.GroupID = new UUID((String)inventoryRow["groupID"]); 1151 taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]);
1149 1152
1150 taskItem.NextPermissions = Convert.ToUInt32(inventoryRow["nextPermissions"]); 1153 taskItem.NextPermissions = Convert.ToUInt32(inventoryRow["nextPermissions"]);
1151 taskItem.CurrentPermissions = Convert.ToUInt32(inventoryRow["currentPermissions"]); 1154 taskItem.CurrentPermissions = Convert.ToUInt32(inventoryRow["currentPermissions"]);