aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorUbitUmarov2012-03-09 03:00:31 +0000
committerUbitUmarov2012-03-09 03:00:31 +0000
commitfc4dc7708dc07dc41791de64d7a6b2586d3170b5 (patch)
tree2b807fd97cdef06e671b52f3e735b849b05f9cfc /OpenSim/Data
parent more changes on undo/redo group scaling seems to work better (diff)
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC-fc4dc7708dc07dc41791de64d7a6b2586d3170b5.zip
opensim-SC-fc4dc7708dc07dc41791de64d7a6b2586d3170b5.tar.gz
opensim-SC-fc4dc7708dc07dc41791de64d7a6b2586d3170b5.tar.bz2
opensim-SC-fc4dc7708dc07dc41791de64d7a6b2586d3170b5.tar.xz
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster into ubitwork
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLFriendsData.cs6
-rw-r--r--OpenSim/Data/MSSQL/MSSQLInventoryData.cs2
-rw-r--r--OpenSim/Data/MSSQL/MSSQLSimulationData.cs87
-rw-r--r--OpenSim/Data/MSSQL/Resources/RegionStore.migrations85
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs500
-rw-r--r--OpenSim/Data/MySQL/Resources/XAssetStore.migrations27
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs2
8 files changed, 700 insertions, 11 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs b/OpenSim/Data/MSSQL/MSSQLFriendsData.cs
index 09dde5e..fef6978 100644
--- a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLFriendsData.cs
@@ -89,5 +89,11 @@ namespace OpenSim.Data.MSSQL
89 return DoQuery(cmd); 89 return DoQuery(cmd);
90 } 90 }
91 } 91 }
92
93 public FriendsData[] GetFriends(Guid principalID)
94 {
95 return GetFriends(principalID.ToString());
96 }
97
92 } 98 }
93} 99}
diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
index 4d06377..961593f 100644
--- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
@@ -813,7 +813,7 @@ namespace OpenSim.Data.MSSQL
813 { 813 {
814 try 814 try
815 { 815 {
816 using (SqlCommand command = new SqlCommand("DELETE FROM inventoryfolders WHERE folderID=@folderID", connection)) 816 using (SqlCommand command = new SqlCommand("DELETE FROM inventoryfolders WHERE folderID=@folderID and type=-1", connection))
817 { 817 {
818 command.Parameters.Add(database.CreateParameter("folderID", folderID)); 818 command.Parameters.Add(database.CreateParameter("folderID", folderID));
819 819
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
index e58620a..d9dfe86 100644
--- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
@@ -675,7 +675,7 @@ VALUES
675 cmd.ExecuteNonQuery(); 675 cmd.ExecuteNonQuery();
676 } 676 }
677 677
678 sql = "INSERT INTO [landaccesslist] ([LandUUID],[AccessUUID],[Flags]) VALUES (@LandUUID,@AccessUUID,@Flags)"; 678 sql = "INSERT INTO [landaccesslist] ([LandUUID],[AccessUUID],[Flags],[Expires]) VALUES (@LandUUID,@AccessUUID,@Flags,@Expires)";
679 679
680 using (SqlConnection conn = new SqlConnection(m_connectionString)) 680 using (SqlConnection conn = new SqlConnection(m_connectionString))
681 using (SqlCommand cmd = new SqlCommand(sql, conn)) 681 using (SqlCommand cmd = new SqlCommand(sql, conn))
@@ -1215,6 +1215,8 @@ VALUES
1215 //Store new values 1215 //Store new values
1216 StoreNewRegionSettings(regionSettings); 1216 StoreNewRegionSettings(regionSettings);
1217 1217
1218 LoadSpawnPoints(regionSettings);
1219
1218 return regionSettings; 1220 return regionSettings;
1219 } 1221 }
1220 1222
@@ -1252,7 +1254,7 @@ VALUES
1252,[elevation_1_ne] = @elevation_1_ne ,[elevation_2_ne] = @elevation_2_ne ,[elevation_1_se] = @elevation_1_se ,[elevation_2_se] = @elevation_2_se 1254,[elevation_1_ne] = @elevation_1_ne ,[elevation_2_ne] = @elevation_2_ne ,[elevation_1_se] = @elevation_1_se ,[elevation_2_se] = @elevation_2_se
1253,[elevation_1_sw] = @elevation_1_sw ,[elevation_2_sw] = @elevation_2_sw ,[water_height] = @water_height ,[terrain_raise_limit] = @terrain_raise_limit 1255,[elevation_1_sw] = @elevation_1_sw ,[elevation_2_sw] = @elevation_2_sw ,[water_height] = @water_height ,[terrain_raise_limit] = @terrain_raise_limit
1254,[terrain_lower_limit] = @terrain_lower_limit ,[use_estate_sun] = @use_estate_sun ,[fixed_sun] = @fixed_sun ,[sun_position] = @sun_position 1256,[terrain_lower_limit] = @terrain_lower_limit ,[use_estate_sun] = @use_estate_sun ,[fixed_sun] = @fixed_sun ,[sun_position] = @sun_position
1255,[covenant] = @covenant ,[covenant_datetime] = @covenant_datetime, [sunvectorx] = @sunvectorx, [sunvectory] = @sunvectory, [sunvectorz] = @sunvectorz, [Sandbox] = @Sandbox, [loaded_creation_datetime] = @loaded_creation_datetime, [loaded_creation_id] = @loaded_creation_id 1257,[covenant] = @covenant ,[covenant_datetime] = @covenant_datetime, [sunvectorx] = @sunvectorx, [sunvectory] = @sunvectory, [sunvectorz] = @sunvectorz, [Sandbox] = @Sandbox, [loaded_creation_datetime] = @loaded_creation_datetime, [loaded_creation_id] = @loaded_creation_id, [map_tile_id] = @TerrainImageID, [telehubobject] = @telehubobject, [parcel_tile_id] = @ParcelImageID
1256 WHERE [regionUUID] = @regionUUID"; 1258 WHERE [regionUUID] = @regionUUID";
1257 1259
1258 using (SqlConnection conn = new SqlConnection(m_connectionString)) 1260 using (SqlConnection conn = new SqlConnection(m_connectionString))
@@ -1263,6 +1265,7 @@ VALUES
1263 cmd.ExecuteNonQuery(); 1265 cmd.ExecuteNonQuery();
1264 } 1266 }
1265 } 1267 }
1268 SaveSpawnPoints(regionSettings);
1266 } 1269 }
1267 1270
1268 public void Shutdown() 1271 public void Shutdown()
@@ -1367,7 +1370,7 @@ VALUES
1367 newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); 1370 newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]);
1368 newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); 1371 newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]);
1369 newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); 1372 newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]);
1370 newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); 1373 newSettings.Sandbox = Convert.ToBoolean(row["Sandbox"]);
1371 newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); 1374 newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]);
1372 newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); 1375 newSettings.SunPosition = Convert.ToDouble(row["sun_position"]);
1373 newSettings.SunVector = new Vector3( 1376 newSettings.SunVector = new Vector3(
@@ -1383,6 +1386,11 @@ VALUES
1383 newSettings.LoadedCreationID = ""; 1386 newSettings.LoadedCreationID = "";
1384 else 1387 else
1385 newSettings.LoadedCreationID = (String)row["loaded_creation_id"]; 1388 newSettings.LoadedCreationID = (String)row["loaded_creation_id"];
1389
1390 newSettings.TerrainImageID = new UUID((string)row["map_tile_ID"]);
1391 newSettings.ParcelImageID = new UUID((Guid)row["parcel_tile_ID"]);
1392 newSettings.TelehubObject = new UUID((Guid)row["TelehubObject"]);
1393
1386 return newSettings; 1394 return newSettings;
1387 } 1395 }
1388 1396
@@ -1454,6 +1462,13 @@ VALUES
1454 } 1462 }
1455 1463
1456 newData.ParcelAccessList = new List<LandAccessEntry>(); 1464 newData.ParcelAccessList = new List<LandAccessEntry>();
1465 newData.MediaDescription = (string)row["MediaDescription"];
1466 newData.MediaType = (string)row["MediaType"];
1467 newData.MediaWidth = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[0]);
1468 newData.MediaHeight = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[1]);
1469 newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]);
1470 newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]);
1471 newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]);
1457 1472
1458 return newData; 1473 return newData;
1459 } 1474 }
@@ -1468,7 +1483,7 @@ VALUES
1468 LandAccessEntry entry = new LandAccessEntry(); 1483 LandAccessEntry entry = new LandAccessEntry();
1469 entry.AgentID = new UUID((Guid)row["AccessUUID"]); 1484 entry.AgentID = new UUID((Guid)row["AccessUUID"]);
1470 entry.Flags = (AccessList)Convert.ToInt32(row["Flags"]); 1485 entry.Flags = (AccessList)Convert.ToInt32(row["Flags"]);
1471 entry.Expires = 0; 1486 entry.Expires = Convert.ToInt32(row["Expires"]);
1472 return entry; 1487 return entry;
1473 } 1488 }
1474 1489
@@ -1497,7 +1512,8 @@ VALUES
1497 prim.TouchName = (string)primRow["TouchName"]; 1512 prim.TouchName = (string)primRow["TouchName"];
1498 // permissions 1513 // permissions
1499 prim.Flags = (PrimFlags)Convert.ToUInt32(primRow["ObjectFlags"]); 1514 prim.Flags = (PrimFlags)Convert.ToUInt32(primRow["ObjectFlags"]);
1500 prim.CreatorID = new UUID((Guid)primRow["CreatorID"]); 1515 //prim.CreatorID = new UUID((Guid)primRow["CreatorID"]);
1516 prim.CreatorIdentification = (string)primRow["CreatorID"];
1501 prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); 1517 prim.OwnerID = new UUID((Guid)primRow["OwnerID"]);
1502 prim.GroupID = new UUID((Guid)primRow["GroupID"]); 1518 prim.GroupID = new UUID((Guid)primRow["GroupID"]);
1503 prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]); 1519 prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]);
@@ -1691,7 +1707,8 @@ VALUES
1691 taskItem.Name = (string)inventoryRow["name"]; 1707 taskItem.Name = (string)inventoryRow["name"];
1692 taskItem.Description = (string)inventoryRow["description"]; 1708 taskItem.Description = (string)inventoryRow["description"];
1693 taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]); 1709 taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]);
1694 taskItem.CreatorID = new UUID((Guid)inventoryRow["creatorID"]); 1710 //taskItem.CreatorID = new UUID((Guid)inventoryRow["creatorID"]);
1711 taskItem.CreatorIdentification = (string)inventoryRow["creatorID"];
1695 taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]); 1712 taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]);
1696 taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]); 1713 taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]);
1697 taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]); 1714 taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]);
@@ -1782,7 +1799,7 @@ VALUES
1782 parameters.Add(_Database.CreateParameter("terrain_raise_limit", settings.TerrainRaiseLimit)); 1799 parameters.Add(_Database.CreateParameter("terrain_raise_limit", settings.TerrainRaiseLimit));
1783 parameters.Add(_Database.CreateParameter("terrain_lower_limit", settings.TerrainLowerLimit)); 1800 parameters.Add(_Database.CreateParameter("terrain_lower_limit", settings.TerrainLowerLimit));
1784 parameters.Add(_Database.CreateParameter("use_estate_sun", settings.UseEstateSun)); 1801 parameters.Add(_Database.CreateParameter("use_estate_sun", settings.UseEstateSun));
1785 parameters.Add(_Database.CreateParameter("sandbox", settings.Sandbox)); 1802 parameters.Add(_Database.CreateParameter("Sandbox", settings.Sandbox));
1786 parameters.Add(_Database.CreateParameter("fixed_sun", settings.FixedSun)); 1803 parameters.Add(_Database.CreateParameter("fixed_sun", settings.FixedSun));
1787 parameters.Add(_Database.CreateParameter("sun_position", settings.SunPosition)); 1804 parameters.Add(_Database.CreateParameter("sun_position", settings.SunPosition));
1788 parameters.Add(_Database.CreateParameter("sunvectorx", settings.SunVector.X)); 1805 parameters.Add(_Database.CreateParameter("sunvectorx", settings.SunVector.X));
@@ -1792,6 +1809,9 @@ VALUES
1792 parameters.Add(_Database.CreateParameter("covenant_datetime", settings.CovenantChangedDateTime)); 1809 parameters.Add(_Database.CreateParameter("covenant_datetime", settings.CovenantChangedDateTime));
1793 parameters.Add(_Database.CreateParameter("Loaded_Creation_DateTime", settings.LoadedCreationDateTime)); 1810 parameters.Add(_Database.CreateParameter("Loaded_Creation_DateTime", settings.LoadedCreationDateTime));
1794 parameters.Add(_Database.CreateParameter("Loaded_Creation_ID", settings.LoadedCreationID)); 1811 parameters.Add(_Database.CreateParameter("Loaded_Creation_ID", settings.LoadedCreationID));
1812 parameters.Add(_Database.CreateParameter("TerrainImageID", settings.TerrainImageID));
1813 parameters.Add(_Database.CreateParameter("ParcelImageID", settings.ParcelImageID));
1814 parameters.Add(_Database.CreateParameter("TelehubObject", settings.TelehubObject));
1795 1815
1796 return parameters.ToArray(); 1816 return parameters.ToArray();
1797 } 1817 }
@@ -1859,6 +1879,7 @@ VALUES
1859 parameters.Add(_Database.CreateParameter("LandUUID", parcelID)); 1879 parameters.Add(_Database.CreateParameter("LandUUID", parcelID));
1860 parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID)); 1880 parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID));
1861 parameters.Add(_Database.CreateParameter("Flags", parcelAccessEntry.Flags)); 1881 parameters.Add(_Database.CreateParameter("Flags", parcelAccessEntry.Flags));
1882 parameters.Add(_Database.CreateParameter("Expires", parcelAccessEntry.Expires));
1862 1883
1863 return parameters.ToArray(); 1884 return parameters.ToArray();
1864 } 1885 }
@@ -2063,5 +2084,57 @@ VALUES
2063 #endregion 2084 #endregion
2064 2085
2065 #endregion 2086 #endregion
2087
2088 private void LoadSpawnPoints(RegionSettings rs)
2089 {
2090 rs.ClearSpawnPoints();
2091
2092 string sql = "SELECT Yaw, Pitch, Distance FROM spawn_points WHERE RegionUUID = @RegionUUID";
2093 using (SqlConnection conn = new SqlConnection(m_connectionString))
2094 using (SqlCommand cmd = new SqlCommand(sql, conn))
2095 {
2096 cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", rs.RegionUUID.ToString()));
2097 conn.Open();
2098 using (SqlDataReader reader = cmd.ExecuteReader())
2099 {
2100 if (reader.Read())
2101 {
2102 SpawnPoint sp = new SpawnPoint();
2103
2104 sp.Yaw = (float)reader["Yaw"];
2105 sp.Pitch = (float)reader["Pitch"];
2106 sp.Distance = (float)reader["Distance"];
2107
2108 rs.AddSpawnPoint(sp);
2109 }
2110 }
2111 }
2112 }
2113
2114 private void SaveSpawnPoints(RegionSettings rs)
2115 {
2116 string sql = "DELETE FROM spawn_points WHERE RegionUUID = @RegionUUID";
2117 using (SqlConnection conn = new SqlConnection(m_connectionString))
2118 using (SqlCommand cmd = new SqlCommand(sql, conn))
2119 {
2120 cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", rs.RegionUUID));
2121 conn.Open();
2122 cmd.ExecuteNonQuery();
2123 }
2124 foreach (SpawnPoint p in rs.SpawnPoints())
2125 {
2126 sql = "INSERT INTO spawn_points (RegionUUID, Yaw, Pitch, Distance) VALUES (@RegionUUID, @Yaw, @Pitch, @Distance)";
2127 using (SqlConnection conn = new SqlConnection(m_connectionString))
2128 using (SqlCommand cmd = new SqlCommand(sql, conn))
2129 {
2130 cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", rs.RegionUUID));
2131 cmd.Parameters.Add(_Database.CreateParameter("@Yaw", p.Yaw));
2132 cmd.Parameters.Add(_Database.CreateParameter("@Pitch", p.Pitch));
2133 cmd.Parameters.Add(_Database.CreateParameter("@Distance", p.Distance));
2134 conn.Open();
2135 cmd.ExecuteNonQuery();
2136 }
2137 }
2138 }
2066 } 2139 }
2067} 2140}
diff --git a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
index a98690a..d6a3be9 100644
--- a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
@@ -1044,10 +1044,93 @@ ALTER TABLE primitems ALTER COLUMN CreatorID uniqueidentifier NOT NULL
1044 1044
1045COMMIT 1045COMMIT
1046 1046
1047:VERSION 29 #--------------------- 1047:VERSION 29 #----------------- Region Covenant changed time
1048 1048
1049BEGIN TRANSACTION 1049BEGIN TRANSACTION
1050 1050
1051ALTER TABLE regionsettings ADD covenant_datetime int NOT NULL default 0 1051ALTER TABLE regionsettings ADD covenant_datetime int NOT NULL default 0
1052 1052
1053COMMIT 1053COMMIT
1054
1055:VERSION 30 #------------------Migrate creatorID storage to varchars instead of UUIDs for HG support
1056
1057BEGIN TRANSACTION
1058
1059EXECUTE sp_rename N'dbo.prims.creatorid', N'creatoridold', 'COLUMN'
1060EXECUTE sp_rename N'dbo.primitems.creatorid', N'creatoridold', 'COLUMN'
1061
1062COMMIT
1063
1064:VERSION 31 #---------------------
1065
1066BEGIN TRANSACTION
1067
1068ALTER TABLE prims ADD CreatorID varchar(255)
1069ALTER TABLE primitems ADD CreatorID varchar(255)
1070
1071COMMIT
1072
1073:VERSION 32 #---------------------
1074
1075BEGIN TRANSACTION
1076
1077UPDATE prims SET prims.CreatorID = CONVERT(varchar(255), creatoridold)
1078UPDATE primitems SET primitems.CreatorID = CONVERT(varchar(255), creatoridold)
1079
1080COMMIT
1081
1082:VERSION 33 #---------------------
1083
1084BEGIN TRANSACTION
1085
1086ALTER TABLE prims
1087ADD CONSTRAINT DF_prims_CreatorIDNew
1088DEFAULT '00000000-0000-0000-0000-000000000000'
1089FOR CreatorID
1090
1091ALTER TABLE prims ALTER COLUMN CreatorID varchar(255) NOT NULL
1092
1093ALTER TABLE primitems
1094ADD CONSTRAINT DF_primitems_CreatorIDNew
1095DEFAULT '00000000-0000-0000-0000-000000000000'
1096FOR CreatorID
1097
1098ALTER TABLE primitems ALTER COLUMN CreatorID varchar(255) NOT NULL
1099
1100COMMIT
1101
1102:VERSION 34 #--------------- Telehub support
1103
1104BEGIN TRANSACTION
1105
1106CREATE TABLE [dbo].[Spawn_Points](
1107 [RegionUUID] [uniqueidentifier] NOT NULL,
1108 [Yaw] [float] NOT NULL,
1109 [Pitch] [float] NOT NULL,
1110 [Distance] [float] NOT NULL,
1111 PRIMARY KEY CLUSTERED
1112 (
1113 [RegionUUID] ASC
1114 )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
1115) ON [PRIMARY]
1116
1117ALTER TABLE regionsettings ADD TelehubObject uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
1118
1119COMMIT
1120
1121:VERSION 35 #---------------- Parcels for sale
1122
1123BEGIN TRANSACTION
1124
1125ALTER TABLE regionsettings ADD parcel_tile_ID uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
1126
1127COMMIT
1128
1129:VERSION 36 #---------------- Timed bans/access
1130
1131BEGIN TRANSACTION
1132
1133ALTER TABLE landaccesslist ADD Expires integer NOT NULL DEFAULT 0;
1134
1135COMMIT
1136
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 5dafc0b..1197548 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -1315,7 +1315,7 @@ namespace OpenSim.Data.MySQL
1315 newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); 1315 newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]);
1316 newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); 1316 newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]);
1317 newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); 1317 newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]);
1318 newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); 1318 newSettings.Sandbox = Convert.ToBoolean(row["Sandbox"]);
1319 newSettings.SunVector = new Vector3 ( 1319 newSettings.SunVector = new Vector3 (
1320 Convert.ToSingle(row["sunvectorx"]), 1320 Convert.ToSingle(row["sunvectorx"]),
1321 Convert.ToSingle(row["sunvectory"]), 1321 Convert.ToSingle(row["sunvectory"]),
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
new file mode 100644
index 0000000..95ef72a
--- /dev/null
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -0,0 +1,500 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.IO;
32using System.IO.Compression;
33using System.Reflection;
34using System.Security.Cryptography;
35using System.Text;
36using log4net;
37using MySql.Data.MySqlClient;
38using OpenMetaverse;
39using OpenSim.Framework;
40using OpenSim.Data;
41
42namespace OpenSim.Data.MySQL
43{
44 public class MySQLXAssetData : AssetDataBase
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 protected virtual Assembly Assembly
49 {
50 get { return GetType().Assembly; }
51 }
52
53 private bool m_enableCompression = false;
54 private string m_connectionString;
55 private object m_dbLock = new object();
56
57 /// <summary>
58 /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock
59 /// </summary>
60 private HashAlgorithm hasher = new SHA256CryptoServiceProvider();
61
62 #region IPlugin Members
63
64 public override string Version { get { return "1.0.0.0"; } }
65
66 /// <summary>
67 /// <para>Initialises Asset interface</para>
68 /// <para>
69 /// <list type="bullet">
70 /// <item>Loads and initialises the MySQL storage plugin.</item>
71 /// <item>Warns and uses the obsolete mysql_connection.ini if connect string is empty.</item>
72 /// <item>Check for migration</item>
73 /// </list>
74 /// </para>
75 /// </summary>
76 /// <param name="connect">connect string</param>
77 public override void Initialise(string connect)
78 {
79 m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************");
80 m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************");
81 m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************");
82 m_log.ErrorFormat("[MYSQL XASSETDATA]: THIS PLUGIN IS STRICTLY EXPERIMENTAL.");
83 m_log.ErrorFormat("[MYSQL XASSETDATA]: DO NOT USE FOR ANY DATA THAT YOU DO NOT MIND LOSING.");
84 m_log.ErrorFormat("[MYSQL XASSETDATA]: DATABASE TABLES CAN CHANGE AT ANY TIME, CAUSING EXISTING DATA TO BE LOST.");
85 m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************");
86 m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************");
87 m_log.ErrorFormat("[MYSQL XASSETDATA]: ***********************************************************");
88
89 m_connectionString = connect;
90
91 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
92 {
93 dbcon.Open();
94 Migration m = new Migration(dbcon, Assembly, "XAssetStore");
95 m.Update();
96 }
97 }
98
99 public override void Initialise()
100 {
101 throw new NotImplementedException();
102 }
103
104 public override void Dispose() { }
105
106 /// <summary>
107 /// The name of this DB provider
108 /// </summary>
109 override public string Name
110 {
111 get { return "MySQL XAsset storage engine"; }
112 }
113
114 #endregion
115
116 #region IAssetDataPlugin Members
117
118 /// <summary>
119 /// Fetch Asset <paramref name="assetID"/> from database
120 /// </summary>
121 /// <param name="assetID">Asset UUID to fetch</param>
122 /// <returns>Return the asset</returns>
123 /// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks>
124 override public AssetBase GetAsset(UUID assetID)
125 {
126// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
127
128 AssetBase asset = null;
129 lock (m_dbLock)
130 {
131 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
132 {
133 dbcon.Open();
134
135 using (MySqlCommand cmd = new MySqlCommand(
136 "SELECT name, description, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id",
137 dbcon))
138 {
139 cmd.Parameters.AddWithValue("?id", assetID.ToString());
140
141 try
142 {
143 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
144 {
145 if (dbReader.Read())
146 {
147 asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString());
148 asset.Data = (byte[])dbReader["data"];
149 asset.Description = (string)dbReader["description"];
150
151 string local = dbReader["local"].ToString();
152 if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
153 asset.Local = true;
154 else
155 asset.Local = false;
156
157 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
158 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
159
160 if (m_enableCompression)
161 {
162 using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
163 {
164 MemoryStream outputStream = new MemoryStream();
165 WebUtil.CopyTo(decompressionStream, outputStream, int.MaxValue);
166 // int compressedLength = asset.Data.Length;
167 asset.Data = outputStream.ToArray();
168
169 // m_log.DebugFormat(
170 // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
171 // asset.ID, asset.Name, asset.Data.Length, compressedLength);
172 }
173 }
174 }
175 }
176 }
177 catch (Exception e)
178 {
179 m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message);
180 }
181 }
182 }
183 }
184
185 return asset;
186 }
187
188 /// <summary>
189 /// Create an asset in database, or update it if existing.
190 /// </summary>
191 /// <param name="asset">Asset UUID to create</param>
192 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
193 override public void StoreAsset(AssetBase asset)
194 {
195 lock (m_dbLock)
196 {
197 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
198 {
199 dbcon.Open();
200
201 using (MySqlTransaction transaction = dbcon.BeginTransaction())
202 {
203 string assetName = asset.Name;
204 if (asset.Name.Length > 64)
205 {
206 assetName = asset.Name.Substring(0, 64);
207 m_log.Warn("[XASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add");
208 }
209
210 string assetDescription = asset.Description;
211 if (asset.Description.Length > 64)
212 {
213 assetDescription = asset.Description.Substring(0, 64);
214 m_log.Warn("[XASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add");
215 }
216
217 if (m_enableCompression)
218 {
219 MemoryStream outputStream = new MemoryStream();
220
221 using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false))
222 {
223 // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue));
224 // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream.
225 compressionStream.Close();
226 byte[] compressedData = outputStream.ToArray();
227 asset.Data = compressedData;
228 }
229 }
230
231 byte[] hash = hasher.ComputeHash(asset.Data);
232
233// m_log.DebugFormat(
234// "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}",
235// asset.ID, asset.Name, hash, compressedData.Length);
236
237 try
238 {
239 using (MySqlCommand cmd =
240 new MySqlCommand(
241 "replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" +
242 "VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)",
243 dbcon))
244 {
245 // create unix epoch time
246 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
247 cmd.Parameters.AddWithValue("?id", asset.ID);
248 cmd.Parameters.AddWithValue("?hash", hash);
249 cmd.Parameters.AddWithValue("?name", assetName);
250 cmd.Parameters.AddWithValue("?description", assetDescription);
251 cmd.Parameters.AddWithValue("?asset_type", asset.Type);
252 cmd.Parameters.AddWithValue("?local", asset.Local);
253 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
254 cmd.Parameters.AddWithValue("?create_time", now);
255 cmd.Parameters.AddWithValue("?access_time", now);
256 cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID);
257 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
258 cmd.ExecuteNonQuery();
259 }
260 }
261 catch (Exception e)
262 {
263 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}",
264 asset.FullID, asset.Name, e.Message);
265
266 transaction.Rollback();
267
268 return;
269 }
270
271 if (!ExistsData(dbcon, transaction, hash))
272 {
273 try
274 {
275 using (MySqlCommand cmd =
276 new MySqlCommand(
277 "INSERT INTO xassetsdata(hash, data) VALUES(?hash, ?data)",
278 dbcon))
279 {
280 cmd.Parameters.AddWithValue("?hash", hash);
281 cmd.Parameters.AddWithValue("?data", asset.Data);
282 cmd.ExecuteNonQuery();
283 }
284 }
285 catch (Exception e)
286 {
287 m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}",
288 asset.FullID, asset.Name, e.Message);
289
290 transaction.Rollback();
291
292 return;
293 }
294 }
295
296 transaction.Commit();
297 }
298 }
299 }
300 }
301
302// private void UpdateAccessTime(AssetBase asset)
303// {
304// lock (m_dbLock)
305// {
306// using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
307// {
308// dbcon.Open();
309// MySqlCommand cmd =
310// new MySqlCommand("update assets set access_time=?access_time where id=?id",
311// dbcon);
312//
313// // need to ensure we dispose
314// try
315// {
316// using (cmd)
317// {
318// // create unix epoch time
319// int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
320// cmd.Parameters.AddWithValue("?id", asset.ID);
321// cmd.Parameters.AddWithValue("?access_time", now);
322// cmd.ExecuteNonQuery();
323// cmd.Dispose();
324// }
325// }
326// catch (Exception e)
327// {
328// m_log.ErrorFormat(
329// "[ASSETS DB]: " +
330// "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString()
331// + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
332// }
333// }
334// }
335//
336// }
337
338 /// <summary>
339 /// We assume we already have the m_dbLock.
340 /// </summary>
341 /// TODO: need to actually use the transaction.
342 /// <param name="dbcon"></param>
343 /// <param name="transaction"></param>
344 /// <param name="hash"></param>
345 /// <returns></returns>
346 private bool ExistsData(MySqlConnection dbcon, MySqlTransaction transaction, byte[] hash)
347 {
348// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
349
350 bool exists = false;
351
352 using (MySqlCommand cmd = new MySqlCommand("SELECT hash FROM xassetsdata WHERE hash=?hash", dbcon))
353 {
354 cmd.Parameters.AddWithValue("?hash", hash);
355
356 try
357 {
358 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
359 {
360 if (dbReader.Read())
361 {
362// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
363 exists = true;
364 }
365 }
366 }
367 catch (Exception e)
368 {
369 m_log.ErrorFormat(
370 "[XASSETS DB]: MySql failure in ExistsData fetching hash {0}. Exception {1}{2}",
371 hash, e.Message, e.StackTrace);
372 }
373 }
374
375 return exists;
376 }
377
378 /// <summary>
379 /// Check if the asset exists in the database
380 /// </summary>
381 /// <param name="uuid">The asset UUID</param>
382 /// <returns>true if it exists, false otherwise.</returns>
383 override public bool ExistsAsset(UUID uuid)
384 {
385// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
386
387 bool assetExists = false;
388
389 lock (m_dbLock)
390 {
391 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
392 {
393 dbcon.Open();
394 using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM xassetsmeta WHERE id=?id", dbcon))
395 {
396 cmd.Parameters.AddWithValue("?id", uuid.ToString());
397
398 try
399 {
400 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
401 {
402 if (dbReader.Read())
403 {
404// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
405 assetExists = true;
406 }
407 }
408 }
409 catch (Exception e)
410 {
411 m_log.ErrorFormat(
412 "[XASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid);
413 }
414 }
415 }
416 }
417
418 return assetExists;
419 }
420
421 /// <summary>
422 /// Returns a list of AssetMetadata objects. The list is a subset of
423 /// the entire data set offset by <paramref name="start" /> containing
424 /// <paramref name="count" /> elements.
425 /// </summary>
426 /// <param name="start">The number of results to discard from the total data set.</param>
427 /// <param name="count">The number of rows the returned list should contain.</param>
428 /// <returns>A list of AssetMetadata objects.</returns>
429 public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
430 {
431 List<AssetMetadata> retList = new List<AssetMetadata>(count);
432
433 lock (m_dbLock)
434 {
435 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
436 {
437 dbcon.Open();
438 MySqlCommand cmd = new MySqlCommand("SELECT name,description,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon);
439 cmd.Parameters.AddWithValue("?start", start);
440 cmd.Parameters.AddWithValue("?count", count);
441
442 try
443 {
444 using (MySqlDataReader dbReader = cmd.ExecuteReader())
445 {
446 while (dbReader.Read())
447 {
448 AssetMetadata metadata = new AssetMetadata();
449 metadata.Name = (string)dbReader["name"];
450 metadata.Description = (string)dbReader["description"];
451 metadata.Type = (sbyte)dbReader["asset_type"];
452 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct.
453 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
454 metadata.FullID = DBGuid.FromDB(dbReader["id"]);
455 metadata.CreatorID = dbReader["creator_id"].ToString();
456
457 // We'll ignore this for now - it appears unused!
458// metadata.SHA1 = dbReader["hash"]);
459
460 retList.Add(metadata);
461 }
462 }
463 }
464 catch (Exception e)
465 {
466 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
467 }
468 }
469 }
470
471 return retList;
472 }
473
474 public override bool Delete(string id)
475 {
476// m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id);
477
478 lock (m_dbLock)
479 {
480 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
481 {
482 dbcon.Open();
483
484 using (MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon))
485 {
486 cmd.Parameters.AddWithValue("?id", id);
487 cmd.ExecuteNonQuery();
488 }
489
490 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
491 // keep a reference count (?)
492 }
493 }
494
495 return true;
496 }
497
498 #endregion
499 }
500} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations
new file mode 100644
index 0000000..d3cca5e
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations
@@ -0,0 +1,27 @@
1# -----------------
2:VERSION 1
3
4BEGIN;
5
6CREATE TABLE `xassetsmeta` (
7 `id` char(36) NOT NULL,
8 `hash` binary(32) NOT NULL,
9 `name` varchar(64) NOT NULL,
10 `description` varchar(64) NOT NULL,
11 `asset_type` tinyint(4) NOT NULL,
12 `local` tinyint(1) NOT NULL,
13 `temporary` tinyint(1) NOT NULL,
14 `create_time` int(11) NOT NULL,
15 `access_time` int(11) NOT NULL,
16 `asset_flags` int(11) NOT NULL,
17 `creator_id` varchar(128) NOT NULL,
18 PRIMARY KEY (`id`)
19) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';
20
21CREATE TABLE `xassetsdata` (
22 `hash` binary(32) NOT NULL,
23 `data` longblob NOT NULL,
24 PRIMARY KEY (`hash`)
25) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';
26
27COMMIT; \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index 186a586..7e7c08a 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -2157,7 +2157,7 @@ namespace OpenSim.Data.SQLite
2157 row["terrain_raise_limit"] = settings.TerrainRaiseLimit; 2157 row["terrain_raise_limit"] = settings.TerrainRaiseLimit;
2158 row["terrain_lower_limit"] = settings.TerrainLowerLimit; 2158 row["terrain_lower_limit"] = settings.TerrainLowerLimit;
2159 row["use_estate_sun"] = settings.UseEstateSun; 2159 row["use_estate_sun"] = settings.UseEstateSun;
2160 row["Sandbox"] = settings.Sandbox; // database uses upper case S for sandbox 2160 row["sandbox"] = settings.Sandbox; // unlike other database modules, sqlite uses a lower case s for sandbox!
2161 row["sunvectorx"] = settings.SunVector.X; 2161 row["sunvectorx"] = settings.SunVector.X;
2162 row["sunvectory"] = settings.SunVector.Y; 2162 row["sunvectory"] = settings.SunVector.Y;
2163 row["sunvectorz"] = settings.SunVector.Z; 2163 row["sunvectorz"] = settings.SunVector.Z;