diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Data/MySQL | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
35 files changed, 3437 insertions, 880 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs new file mode 100644 index 0000000..ed0ab98 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs | |||
@@ -0,0 +1,56 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using MySql.Data.MySqlClient; | ||
35 | |||
36 | namespace OpenSim.Data.MySQL | ||
37 | { | ||
38 | public class MySQLAgentPreferencesData : MySQLGenericTableHandler<AgentPreferencesData>, IAgentPreferencesData | ||
39 | { | ||
40 | public MySQLAgentPreferencesData(string connectionString, string realm) | ||
41 | : base(connectionString, realm, "AgentPrefs") | ||
42 | { | ||
43 | } | ||
44 | |||
45 | public AgentPreferencesData GetPrefs(UUID agentID) | ||
46 | { | ||
47 | AgentPreferencesData[] ret = Get("PrincipalID", agentID.ToString()); | ||
48 | |||
49 | if (ret.Length == 0) | ||
50 | return null; | ||
51 | |||
52 | return ret[0]; | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | |||
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 73de64b..5d8da17 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -45,7 +45,6 @@ namespace OpenSim.Data.MySQL | |||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private string m_connectionString; | 47 | private string m_connectionString; |
48 | private object m_dbLock = new object(); | ||
49 | 48 | ||
50 | protected virtual Assembly Assembly | 49 | protected virtual Assembly Assembly |
51 | { | 50 | { |
@@ -107,46 +106,46 @@ namespace OpenSim.Data.MySQL | |||
107 | override public AssetBase GetAsset(UUID assetID) | 106 | override public AssetBase GetAsset(UUID assetID) |
108 | { | 107 | { |
109 | AssetBase asset = null; | 108 | AssetBase asset = null; |
110 | lock (m_dbLock) | 109 | |
110 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
111 | { | 111 | { |
112 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 112 | dbcon.Open(); |
113 | |||
114 | using (MySqlCommand cmd = new MySqlCommand( | ||
115 | "SELECT name, description, assetType, local, temporary, asset_flags, CreatorID, data FROM assets WHERE id=?id", | ||
116 | dbcon)) | ||
113 | { | 117 | { |
114 | dbcon.Open(); | 118 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); |
115 | 119 | ||
116 | using (MySqlCommand cmd = new MySqlCommand( | 120 | try |
117 | "SELECT name, description, assetType, local, temporary, asset_flags, CreatorID, data FROM assets WHERE id=?id", | ||
118 | dbcon)) | ||
119 | { | 121 | { |
120 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); | 122 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
121 | |||
122 | try | ||
123 | { | 123 | { |
124 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 124 | if (dbReader.Read()) |
125 | { | 125 | { |
126 | if (dbReader.Read()) | 126 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], dbReader["CreatorID"].ToString()); |
127 | { | 127 | asset.Data = (byte[])dbReader["data"]; |
128 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], dbReader["CreatorID"].ToString()); | 128 | asset.Description = (string)dbReader["description"]; |
129 | asset.Data = (byte[])dbReader["data"]; | 129 | |
130 | asset.Description = (string)dbReader["description"]; | 130 | string local = dbReader["local"].ToString(); |
131 | 131 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | |
132 | string local = dbReader["local"].ToString(); | 132 | asset.Local = true; |
133 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | 133 | else |
134 | asset.Local = true; | 134 | asset.Local = false; |
135 | else | 135 | |
136 | asset.Local = false; | 136 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); |
137 | 137 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | |
138 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | ||
139 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | ||
140 | } | ||
141 | } | 138 | } |
142 | } | 139 | } |
143 | catch (Exception e) | 140 | } |
144 | { | 141 | catch (Exception e) |
145 | m_log.Error("[ASSETS DB]: MySql failure fetching asset " + assetID + ": " + e.Message); | 142 | { |
146 | } | 143 | m_log.Error( |
144 | string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); | ||
147 | } | 145 | } |
148 | } | 146 | } |
149 | } | 147 | } |
148 | |||
150 | return asset; | 149 | return asset; |
151 | } | 150 | } |
152 | 151 | ||
@@ -157,137 +156,134 @@ namespace OpenSim.Data.MySQL | |||
157 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> | 156 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> |
158 | override public void StoreAsset(AssetBase asset) | 157 | override public void StoreAsset(AssetBase asset) |
159 | { | 158 | { |
160 | lock (m_dbLock) | 159 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
161 | { | 160 | { |
162 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 161 | dbcon.Open(); |
162 | |||
163 | using (MySqlCommand cmd = | ||
164 | new MySqlCommand( | ||
165 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + | ||
166 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", | ||
167 | dbcon)) | ||
163 | { | 168 | { |
164 | dbcon.Open(); | 169 | string assetName = asset.Name; |
170 | if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) | ||
171 | { | ||
172 | assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); | ||
173 | m_log.WarnFormat( | ||
174 | "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", | ||
175 | asset.Name, asset.ID, asset.Name.Length, assetName.Length); | ||
176 | } | ||
165 | 177 | ||
166 | using (MySqlCommand cmd = | 178 | string assetDescription = asset.Description; |
167 | new MySqlCommand( | 179 | if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) |
168 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + | ||
169 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", | ||
170 | dbcon)) | ||
171 | { | 180 | { |
172 | string assetName = asset.Name; | 181 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); |
173 | if (asset.Name.Length > 64) | 182 | m_log.WarnFormat( |
174 | { | 183 | "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", |
175 | assetName = asset.Name.Substring(0, 64); | 184 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); |
176 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); | 185 | } |
177 | } | 186 | |
178 | 187 | try | |
179 | string assetDescription = asset.Description; | 188 | { |
180 | if (asset.Description.Length > 64) | 189 | using (cmd) |
181 | { | ||
182 | assetDescription = asset.Description.Substring(0, 64); | ||
183 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); | ||
184 | } | ||
185 | |||
186 | try | ||
187 | { | ||
188 | using (cmd) | ||
189 | { | ||
190 | // create unix epoch time | ||
191 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
192 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
193 | cmd.Parameters.AddWithValue("?name", assetName); | ||
194 | cmd.Parameters.AddWithValue("?description", assetDescription); | ||
195 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | ||
196 | cmd.Parameters.AddWithValue("?local", asset.Local); | ||
197 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | ||
198 | cmd.Parameters.AddWithValue("?create_time", now); | ||
199 | cmd.Parameters.AddWithValue("?access_time", now); | ||
200 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
201 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | ||
202 | cmd.Parameters.AddWithValue("?data", asset.Data); | ||
203 | cmd.ExecuteNonQuery(); | ||
204 | } | ||
205 | } | ||
206 | catch (Exception e) | ||
207 | { | 190 | { |
208 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", | 191 | // create unix epoch time |
209 | asset.FullID, asset.Name, e.Message); | 192 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
193 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
194 | cmd.Parameters.AddWithValue("?name", assetName); | ||
195 | cmd.Parameters.AddWithValue("?description", assetDescription); | ||
196 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | ||
197 | cmd.Parameters.AddWithValue("?local", asset.Local); | ||
198 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | ||
199 | cmd.Parameters.AddWithValue("?create_time", now); | ||
200 | cmd.Parameters.AddWithValue("?access_time", now); | ||
201 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
202 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | ||
203 | cmd.Parameters.AddWithValue("?data", asset.Data); | ||
204 | cmd.ExecuteNonQuery(); | ||
210 | } | 205 | } |
211 | } | 206 | } |
207 | catch (Exception e) | ||
208 | { | ||
209 | m_log.Error( | ||
210 | string.Format( | ||
211 | "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", | ||
212 | asset.FullID, asset.Name) | ||
213 | , e); | ||
214 | } | ||
212 | } | 215 | } |
213 | } | 216 | } |
214 | } | 217 | } |
215 | 218 | ||
216 | private void UpdateAccessTime(AssetBase asset) | 219 | private void UpdateAccessTime(AssetBase asset) |
217 | { | 220 | { |
218 | lock (m_dbLock) | 221 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
219 | { | 222 | { |
220 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 223 | dbcon.Open(); |
221 | { | ||
222 | dbcon.Open(); | ||
223 | 224 | ||
224 | using (MySqlCommand cmd | 225 | using (MySqlCommand cmd |
225 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) | 226 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) |
227 | { | ||
228 | try | ||
226 | { | 229 | { |
227 | try | 230 | using (cmd) |
228 | { | ||
229 | using (cmd) | ||
230 | { | ||
231 | // create unix epoch time | ||
232 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
233 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
234 | cmd.Parameters.AddWithValue("?access_time", now); | ||
235 | cmd.ExecuteNonQuery(); | ||
236 | } | ||
237 | } | ||
238 | catch (Exception e) | ||
239 | { | 231 | { |
240 | m_log.ErrorFormat( | 232 | // create unix epoch time |
241 | "[ASSETS DB]: " + | 233 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
242 | "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | 234 | cmd.Parameters.AddWithValue("?id", asset.ID); |
243 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | 235 | cmd.Parameters.AddWithValue("?access_time", now); |
236 | cmd.ExecuteNonQuery(); | ||
244 | } | 237 | } |
245 | } | 238 | } |
239 | catch (Exception e) | ||
240 | { | ||
241 | m_log.Error( | ||
242 | string.Format( | ||
243 | "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", | ||
244 | asset.FullID, asset.Name), | ||
245 | e); | ||
246 | } | ||
246 | } | 247 | } |
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
250 | /// <summary> | 251 | /// <summary> |
251 | /// Check if the asset exists in the database | 252 | /// Check if the assets exist in the database. |
252 | /// </summary> | 253 | /// </summary> |
253 | /// <param name="uuid">The asset UUID</param> | 254 | /// <param name="uuidss">The assets' IDs</param> |
254 | /// <returns>true if it exists, false otherwise.</returns> | 255 | /// <returns>For each asset: true if it exists, false otherwise</returns> |
255 | override public bool ExistsAsset(UUID uuid) | 256 | public override bool[] AssetsExist(UUID[] uuids) |
256 | { | 257 | { |
257 | // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); | 258 | if (uuids.Length == 0) |
259 | return new bool[0]; | ||
258 | 260 | ||
259 | bool assetExists = false; | 261 | HashSet<UUID> exist = new HashSet<UUID>(); |
260 | 262 | ||
261 | lock (m_dbLock) | 263 | string ids = "'" + string.Join("','", uuids) + "'"; |
264 | string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids); | ||
265 | |||
266 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
262 | { | 267 | { |
263 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 268 | dbcon.Open(); |
269 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
264 | { | 270 | { |
265 | dbcon.Open(); | 271 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
266 | using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon)) | ||
267 | { | 272 | { |
268 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); | 273 | while (dbReader.Read()) |
269 | |||
270 | try | ||
271 | { | ||
272 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
273 | { | ||
274 | if (dbReader.Read()) | ||
275 | { | ||
276 | // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); | ||
277 | assetExists = true; | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | catch (Exception e) | ||
282 | { | 274 | { |
283 | m_log.ErrorFormat( | 275 | UUID id = DBGuid.FromDB(dbReader["id"]); |
284 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); | 276 | exist.Add(id); |
285 | } | 277 | } |
286 | } | 278 | } |
287 | } | 279 | } |
288 | } | 280 | } |
289 | 281 | ||
290 | return assetExists; | 282 | bool[] results = new bool[uuids.Length]; |
283 | for (int i = 0; i < uuids.Length; i++) | ||
284 | results[i] = exist.Contains(uuids[i]); | ||
285 | |||
286 | return results; | ||
291 | } | 287 | } |
292 | 288 | ||
293 | /// <summary> | 289 | /// <summary> |
@@ -302,46 +298,47 @@ namespace OpenSim.Data.MySQL | |||
302 | { | 298 | { |
303 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 299 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
304 | 300 | ||
305 | lock (m_dbLock) | 301 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
306 | { | 302 | { |
307 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 303 | dbcon.Open(); |
304 | |||
305 | using (MySqlCommand cmd | ||
306 | = new MySqlCommand( | ||
307 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
308 | dbcon)) | ||
308 | { | 309 | { |
309 | dbcon.Open(); | 310 | cmd.Parameters.AddWithValue("?start", start); |
311 | cmd.Parameters.AddWithValue("?count", count); | ||
310 | 312 | ||
311 | using (MySqlCommand cmd | 313 | try |
312 | = new MySqlCommand( | ||
313 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
314 | dbcon)) | ||
315 | { | 314 | { |
316 | cmd.Parameters.AddWithValue("?start", start); | 315 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
317 | cmd.Parameters.AddWithValue("?count", count); | ||
318 | |||
319 | try | ||
320 | { | 316 | { |
321 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 317 | while (dbReader.Read()) |
322 | { | 318 | { |
323 | while (dbReader.Read()) | 319 | AssetMetadata metadata = new AssetMetadata(); |
324 | { | 320 | metadata.Name = (string)dbReader["name"]; |
325 | AssetMetadata metadata = new AssetMetadata(); | 321 | metadata.Description = (string)dbReader["description"]; |
326 | metadata.Name = (string)dbReader["name"]; | 322 | metadata.Type = (sbyte)dbReader["assetType"]; |
327 | metadata.Description = (string)dbReader["description"]; | 323 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. |
328 | metadata.Type = (sbyte)dbReader["assetType"]; | 324 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); |
329 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | 325 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); |
330 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 326 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
331 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 327 | |
332 | metadata.CreatorID = dbReader["CreatorID"].ToString(); | 328 | // Current SHA1s are not stored/computed. |
333 | 329 | metadata.SHA1 = new byte[] { }; | |
334 | // Current SHA1s are not stored/computed. | 330 | |
335 | metadata.SHA1 = new byte[] { }; | 331 | retList.Add(metadata); |
336 | |||
337 | retList.Add(metadata); | ||
338 | } | ||
339 | } | 332 | } |
340 | } | 333 | } |
341 | catch (Exception e) | 334 | } |
342 | { | 335 | catch (Exception e) |
343 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); | 336 | { |
344 | } | 337 | m_log.Error( |
338 | string.Format( | ||
339 | "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", | ||
340 | start, count), | ||
341 | e); | ||
345 | } | 342 | } |
346 | } | 343 | } |
347 | } | 344 | } |
@@ -351,17 +348,14 @@ namespace OpenSim.Data.MySQL | |||
351 | 348 | ||
352 | public override bool Delete(string id) | 349 | public override bool Delete(string id) |
353 | { | 350 | { |
354 | lock (m_dbLock) | 351 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
355 | { | 352 | { |
356 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 353 | dbcon.Open(); |
357 | { | ||
358 | dbcon.Open(); | ||
359 | 354 | ||
360 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) | 355 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) |
361 | { | 356 | { |
362 | cmd.Parameters.AddWithValue("?id", id); | 357 | cmd.Parameters.AddWithValue("?id", id); |
363 | cmd.ExecuteNonQuery(); | 358 | cmd.ExecuteNonQuery(); |
364 | } | ||
365 | } | 359 | } |
366 | } | 360 | } |
367 | 361 | ||
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 3dd46cb..fe1487b 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs | |||
@@ -43,12 +43,7 @@ namespace OpenSim.Data.MySQL | |||
43 | private static readonly ILog m_log = | 43 | private static readonly ILog m_log = |
44 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | private const string m_waitTimeoutSelect = "select @@wait_timeout"; | ||
47 | |||
48 | private string m_connectionString; | 46 | private string m_connectionString; |
49 | private long m_waitTimeout; | ||
50 | private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; | ||
51 | // private long m_lastConnectionUse; | ||
52 | 47 | ||
53 | private FieldInfo[] m_Fields; | 48 | private FieldInfo[] m_Fields; |
54 | private Dictionary<string, FieldInfo> m_FieldMap = | 49 | private Dictionary<string, FieldInfo> m_FieldMap = |
@@ -81,8 +76,6 @@ namespace OpenSim.Data.MySQL | |||
81 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); | 76 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); |
82 | } | 77 | } |
83 | 78 | ||
84 | GetWaitTimeout(); | ||
85 | |||
86 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 79 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
87 | { | 80 | { |
88 | dbcon.Open(); | 81 | dbcon.Open(); |
@@ -108,33 +101,6 @@ namespace OpenSim.Data.MySQL | |||
108 | get { return new List<string>(m_FieldMap.Keys).ToArray(); } | 101 | get { return new List<string>(m_FieldMap.Keys).ToArray(); } |
109 | } | 102 | } |
110 | 103 | ||
111 | protected void GetWaitTimeout() | ||
112 | { | ||
113 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
114 | { | ||
115 | dbcon.Open(); | ||
116 | |||
117 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) | ||
118 | { | ||
119 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
120 | { | ||
121 | if (dbReader.Read()) | ||
122 | { | ||
123 | m_waitTimeout | ||
124 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * | ||
125 | TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | |||
130 | // m_lastConnectionUse = DateTime.Now.Ticks; | ||
131 | |||
132 | m_log.DebugFormat( | ||
133 | "[REGION DB]: Connection wait timeout {0} seconds", | ||
134 | m_waitTimeout / TimeSpan.TicksPerSecond); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) | 104 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) |
139 | { | 105 | { |
140 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + | 106 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + |
@@ -145,7 +111,11 @@ namespace OpenSim.Data.MySQL | |||
145 | cmd.CommandText = sql; | 111 | cmd.CommandText = sql; |
146 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 112 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
147 | 113 | ||
148 | return DoLoad(cmd, regionID, create); | 114 | EstateSettings e = DoLoad(cmd, regionID, create); |
115 | if (!create && e.EstateID == 0) // Not found | ||
116 | return null; | ||
117 | |||
118 | return e; | ||
149 | } | 119 | } |
150 | } | 120 | } |
151 | 121 | ||
@@ -427,7 +397,10 @@ namespace OpenSim.Data.MySQL | |||
427 | cmd.CommandText = sql; | 397 | cmd.CommandText = sql; |
428 | cmd.Parameters.AddWithValue("?EstateID", estateID); | 398 | cmd.Parameters.AddWithValue("?EstateID", estateID); |
429 | 399 | ||
430 | return DoLoad(cmd, UUID.Zero, false); | 400 | EstateSettings e = DoLoad(cmd, UUID.Zero, false); |
401 | if (e.EstateID != estateID) | ||
402 | return null; | ||
403 | return e; | ||
431 | } | 404 | } |
432 | } | 405 | } |
433 | 406 | ||
diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs new file mode 100644 index 0000000..19e23b5 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs | |||
@@ -0,0 +1,414 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Console; | ||
34 | using log4net; | ||
35 | using MySql.Data.MySqlClient; | ||
36 | using OpenMetaverse; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | public class MySQLFSAssetData : IFSAssetDataPlugin | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | protected MySqlConnection m_Connection = null; | ||
45 | protected string m_ConnectionString; | ||
46 | protected string m_Table; | ||
47 | protected Object m_connLock = new Object(); | ||
48 | |||
49 | /// <summary> | ||
50 | /// Number of days that must pass before we update the access time on an asset when it has been fetched | ||
51 | /// Config option to change this is "DaysBetweenAccessTimeUpdates" | ||
52 | /// </summary> | ||
53 | private int DaysBetweenAccessTimeUpdates = 0; | ||
54 | |||
55 | protected virtual Assembly Assembly | ||
56 | { | ||
57 | get { return GetType().Assembly; } | ||
58 | } | ||
59 | |||
60 | public MySQLFSAssetData() | ||
61 | { | ||
62 | } | ||
63 | |||
64 | #region IPlugin Members | ||
65 | |||
66 | public string Version { get { return "1.0.0.0"; } } | ||
67 | |||
68 | // Loads and initialises the MySQL storage plugin and checks for migrations | ||
69 | public void Initialise(string connect, string realm, int UpdateAccessTime) | ||
70 | { | ||
71 | m_ConnectionString = connect; | ||
72 | m_Table = realm; | ||
73 | |||
74 | DaysBetweenAccessTimeUpdates = UpdateAccessTime; | ||
75 | |||
76 | try | ||
77 | { | ||
78 | OpenDatabase(); | ||
79 | |||
80 | Migration m = new Migration(m_Connection, Assembly, "FSAssetStore"); | ||
81 | m.Update(); | ||
82 | } | ||
83 | catch (MySqlException e) | ||
84 | { | ||
85 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", e.Message.ToString()); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | public void Initialise() | ||
90 | { | ||
91 | throw new NotImplementedException(); | ||
92 | } | ||
93 | |||
94 | public void Dispose() { } | ||
95 | |||
96 | public string Name | ||
97 | { | ||
98 | get { return "MySQL FSAsset storage engine"; } | ||
99 | } | ||
100 | |||
101 | #endregion | ||
102 | |||
103 | private bool OpenDatabase() | ||
104 | { | ||
105 | try | ||
106 | { | ||
107 | m_Connection = new MySqlConnection(m_ConnectionString); | ||
108 | |||
109 | m_Connection.Open(); | ||
110 | } | ||
111 | catch (MySqlException e) | ||
112 | { | ||
113 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", | ||
114 | e.Message.ToString()); | ||
115 | |||
116 | return false; | ||
117 | } | ||
118 | |||
119 | return true; | ||
120 | } | ||
121 | |||
122 | private IDataReader ExecuteReader(MySqlCommand c) | ||
123 | { | ||
124 | IDataReader r = null; | ||
125 | MySqlConnection connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); | ||
126 | connection.Open(); | ||
127 | c.Connection = connection; | ||
128 | |||
129 | r = c.ExecuteReader(); | ||
130 | |||
131 | return r; | ||
132 | } | ||
133 | |||
134 | private void ExecuteNonQuery(MySqlCommand c) | ||
135 | { | ||
136 | lock (m_connLock) | ||
137 | { | ||
138 | bool errorSeen = false; | ||
139 | |||
140 | while (true) | ||
141 | { | ||
142 | try | ||
143 | { | ||
144 | c.ExecuteNonQuery(); | ||
145 | } | ||
146 | catch (MySqlException) | ||
147 | { | ||
148 | System.Threading.Thread.Sleep(500); | ||
149 | |||
150 | m_Connection.Close(); | ||
151 | m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); | ||
152 | m_Connection.Open(); | ||
153 | c.Connection = m_Connection; | ||
154 | |||
155 | if (!errorSeen) | ||
156 | { | ||
157 | errorSeen = true; | ||
158 | continue; | ||
159 | } | ||
160 | m_log.ErrorFormat("[FSASSETS] MySQL command: {0}", c.CommandText); | ||
161 | throw; | ||
162 | } | ||
163 | |||
164 | break; | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | |||
169 | #region IFSAssetDataPlugin Members | ||
170 | |||
171 | public AssetMetadata Get(string id, out string hash) | ||
172 | { | ||
173 | hash = String.Empty; | ||
174 | |||
175 | MySqlCommand cmd = new MySqlCommand(); | ||
176 | |||
177 | cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, access_time, asset_flags from {0} where id = ?id", m_Table); | ||
178 | cmd.Parameters.AddWithValue("?id", id); | ||
179 | |||
180 | IDataReader reader = ExecuteReader(cmd); | ||
181 | |||
182 | if (!reader.Read()) | ||
183 | { | ||
184 | reader.Close(); | ||
185 | FreeCommand(cmd); | ||
186 | return null; | ||
187 | } | ||
188 | |||
189 | AssetMetadata meta = new AssetMetadata(); | ||
190 | |||
191 | hash = reader["hash"].ToString(); | ||
192 | |||
193 | meta.ID = id; | ||
194 | meta.FullID = new UUID(id); | ||
195 | |||
196 | meta.Name = reader["name"].ToString(); | ||
197 | meta.Description = reader["description"].ToString(); | ||
198 | meta.Type = (sbyte)Convert.ToInt32(reader["type"]); | ||
199 | meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); | ||
200 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); | ||
201 | meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]); | ||
202 | |||
203 | int AccessTime = Convert.ToInt32(reader["access_time"]); | ||
204 | |||
205 | reader.Close(); | ||
206 | |||
207 | UpdateAccessTime(AccessTime, cmd); | ||
208 | |||
209 | FreeCommand(cmd); | ||
210 | |||
211 | return meta; | ||
212 | } | ||
213 | |||
214 | private void UpdateAccessTime(int AccessTime, MySqlCommand cmd) | ||
215 | { | ||
216 | // Reduce DB work by only updating access time if asset hasn't recently been accessed | ||
217 | // 0 By Default, Config option is "DaysBetweenAccessTimeUpdates" | ||
218 | if (DaysBetweenAccessTimeUpdates > 0 && (DateTime.UtcNow - Utils.UnixTimeToDateTime(AccessTime)).TotalDays < DaysBetweenAccessTimeUpdates) | ||
219 | return; | ||
220 | |||
221 | cmd.CommandText = String.Format("UPDATE {0} SET `access_time` = UNIX_TIMESTAMP() WHERE `id` = ?id", m_Table); | ||
222 | |||
223 | cmd.ExecuteNonQuery(); | ||
224 | } | ||
225 | |||
226 | protected void FreeCommand(MySqlCommand cmd) | ||
227 | { | ||
228 | MySqlConnection c = cmd.Connection; | ||
229 | cmd.Dispose(); | ||
230 | c.Close(); | ||
231 | c.Dispose(); | ||
232 | } | ||
233 | |||
234 | public bool Store(AssetMetadata meta, string hash) | ||
235 | { | ||
236 | try | ||
237 | { | ||
238 | string oldhash; | ||
239 | AssetMetadata existingAsset = Get(meta.ID, out oldhash); | ||
240 | |||
241 | MySqlCommand cmd = m_Connection.CreateCommand(); | ||
242 | |||
243 | cmd.Parameters.AddWithValue("?id", meta.ID); | ||
244 | cmd.Parameters.AddWithValue("?name", meta.Name); | ||
245 | cmd.Parameters.AddWithValue("?description", meta.Description); | ||
246 | cmd.Parameters.AddWithValue("?type", meta.Type.ToString()); | ||
247 | cmd.Parameters.AddWithValue("?hash", hash); | ||
248 | cmd.Parameters.AddWithValue("?asset_flags", meta.Flags); | ||
249 | |||
250 | if (existingAsset == null) | ||
251 | { | ||
252 | cmd.CommandText = String.Format("insert into {0} (id, name, description, type, hash, asset_flags, create_time, access_time) values ( ?id, ?name, ?description, ?type, ?hash, ?asset_flags, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())", m_Table); | ||
253 | |||
254 | ExecuteNonQuery(cmd); | ||
255 | |||
256 | cmd.Dispose(); | ||
257 | |||
258 | return true; | ||
259 | } | ||
260 | |||
261 | //cmd.CommandText = String.Format("update {0} set hash = ?hash, access_time = UNIX_TIMESTAMP() where id = ?id", m_Table); | ||
262 | |||
263 | //ExecuteNonQuery(cmd); | ||
264 | |||
265 | cmd.Dispose(); | ||
266 | return false; | ||
267 | } | ||
268 | catch(Exception e) | ||
269 | { | ||
270 | m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID); | ||
271 | m_log.Error(e.ToString()); | ||
272 | return false; | ||
273 | } | ||
274 | } | ||
275 | |||
276 | /// <summary> | ||
277 | /// Check if the assets exist in the database. | ||
278 | /// </summary> | ||
279 | /// <param name="uuids">The asset UUID's</param> | ||
280 | /// <returns>For each asset: true if it exists, false otherwise</returns> | ||
281 | public bool[] AssetsExist(UUID[] uuids) | ||
282 | { | ||
283 | if (uuids.Length == 0) | ||
284 | return new bool[0]; | ||
285 | |||
286 | HashSet<UUID> exists = new HashSet<UUID>(); | ||
287 | |||
288 | string ids = "'" + string.Join("','", uuids) + "'"; | ||
289 | string sql = string.Format("select id from {1} where id in ({0})", ids, m_Table); | ||
290 | |||
291 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | ||
292 | { | ||
293 | cmd.CommandText = sql; | ||
294 | |||
295 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | ||
296 | { | ||
297 | while (dbReader.Read()) | ||
298 | { | ||
299 | UUID id = DBGuid.FromDB(dbReader["ID"]); | ||
300 | exists.Add(id); | ||
301 | } | ||
302 | } | ||
303 | } | ||
304 | |||
305 | bool[] results = new bool[uuids.Length]; | ||
306 | for (int i = 0; i < uuids.Length; i++) | ||
307 | results[i] = exists.Contains(uuids[i]); | ||
308 | return results; | ||
309 | } | ||
310 | |||
311 | public int Count() | ||
312 | { | ||
313 | MySqlCommand cmd = m_Connection.CreateCommand(); | ||
314 | |||
315 | cmd.CommandText = String.Format("select count(*) as count from {0}", m_Table); | ||
316 | |||
317 | IDataReader reader = ExecuteReader(cmd); | ||
318 | |||
319 | reader.Read(); | ||
320 | |||
321 | int count = Convert.ToInt32(reader["count"]); | ||
322 | |||
323 | reader.Close(); | ||
324 | FreeCommand(cmd); | ||
325 | |||
326 | return count; | ||
327 | } | ||
328 | |||
329 | public bool Delete(string id) | ||
330 | { | ||
331 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | ||
332 | { | ||
333 | cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table); | ||
334 | |||
335 | cmd.Parameters.AddWithValue("?id", id); | ||
336 | |||
337 | ExecuteNonQuery(cmd); | ||
338 | } | ||
339 | |||
340 | return true; | ||
341 | } | ||
342 | |||
343 | public void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store) | ||
344 | { | ||
345 | MySqlConnection importConn; | ||
346 | |||
347 | try | ||
348 | { | ||
349 | importConn = new MySqlConnection(conn); | ||
350 | |||
351 | importConn.Open(); | ||
352 | } | ||
353 | catch (MySqlException e) | ||
354 | { | ||
355 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", | ||
356 | e.Message.ToString()); | ||
357 | |||
358 | return; | ||
359 | } | ||
360 | |||
361 | int imported = 0; | ||
362 | |||
363 | MySqlCommand cmd = importConn.CreateCommand(); | ||
364 | |||
365 | string limit = String.Empty; | ||
366 | if (count != -1) | ||
367 | { | ||
368 | limit = String.Format(" limit {0},{1}", start, count); | ||
369 | } | ||
370 | |||
371 | cmd.CommandText = String.Format("select * from {0}{1}", table, limit); | ||
372 | |||
373 | MainConsole.Instance.Output("Querying database"); | ||
374 | IDataReader reader = cmd.ExecuteReader(); | ||
375 | |||
376 | MainConsole.Instance.Output("Reading data"); | ||
377 | |||
378 | while (reader.Read()) | ||
379 | { | ||
380 | if ((imported % 100) == 0) | ||
381 | { | ||
382 | MainConsole.Instance.Output(String.Format("{0} assets imported so far", imported)); | ||
383 | } | ||
384 | |||
385 | AssetBase asset = new AssetBase(); | ||
386 | AssetMetadata meta = new AssetMetadata(); | ||
387 | |||
388 | meta.ID = reader["id"].ToString(); | ||
389 | meta.FullID = new UUID(meta.ID); | ||
390 | |||
391 | meta.Name = reader["name"].ToString(); | ||
392 | meta.Description = reader["description"].ToString(); | ||
393 | meta.Type = (sbyte)Convert.ToInt32(reader["assetType"]); | ||
394 | meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); | ||
395 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); | ||
396 | |||
397 | asset.Metadata = meta; | ||
398 | asset.Data = (byte[])reader["data"]; | ||
399 | |||
400 | store(asset, force); | ||
401 | |||
402 | imported++; | ||
403 | } | ||
404 | |||
405 | reader.Close(); | ||
406 | cmd.Dispose(); | ||
407 | importConn.Close(); | ||
408 | |||
409 | MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); | ||
410 | } | ||
411 | |||
412 | #endregion | ||
413 | } | ||
414 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index 3fdcf1e..5820a90 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -45,38 +45,29 @@ namespace OpenSim.Data.MySQL | |||
45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | protected string m_connectionString; | 47 | protected string m_connectionString; |
48 | protected object m_dbLock = new object(); | ||
49 | 48 | ||
50 | protected MySqlFramework(string connectionString) | 49 | protected MySqlFramework(string connectionString) |
51 | { | 50 | { |
52 | m_connectionString = connectionString; | 51 | m_connectionString = connectionString; |
53 | } | 52 | } |
54 | 53 | ||
55 | ////////////////////////////////////////////////////////////// | ||
56 | // | ||
57 | // All non queries are funneled through one connection | ||
58 | // to increase performance a little | ||
59 | // | ||
60 | protected int ExecuteNonQuery(MySqlCommand cmd) | 54 | protected int ExecuteNonQuery(MySqlCommand cmd) |
61 | { | 55 | { |
62 | lock (m_dbLock) | 56 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
63 | { | 57 | { |
64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 58 | dbcon.Open(); |
65 | { | 59 | cmd.Connection = dbcon; |
66 | dbcon.Open(); | ||
67 | cmd.Connection = dbcon; | ||
68 | 60 | ||
69 | try | 61 | try |
70 | { | 62 | { |
71 | return cmd.ExecuteNonQuery(); | 63 | return cmd.ExecuteNonQuery(); |
72 | } | 64 | } |
73 | catch (Exception e) | 65 | catch (Exception e) |
74 | { | 66 | { |
75 | m_log.Error(e.Message, e); | 67 | m_log.Error(e.Message, e); |
76 | return 0; | 68 | return 0; |
77 | } | ||
78 | } | 69 | } |
79 | } | 70 | } |
80 | } | 71 | } |
81 | } | 72 | } |
82 | } | 73 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 3cd6b8f..6ba9fbd 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Data.MySQL | |||
47 | return Delete(principalID.ToString(), friend); | 47 | return Delete(principalID.ToString(), friend); |
48 | } | 48 | } |
49 | 49 | ||
50 | public bool Delete(string principalID, string friend) | 50 | public override bool Delete(string principalID, string friend) |
51 | { | 51 | { |
52 | using (MySqlCommand cmd = new MySqlCommand()) | 52 | using (MySqlCommand cmd = new MySqlCommand()) |
53 | { | 53 | { |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 995c6a5..35fa89f 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -301,5 +301,65 @@ namespace OpenSim.Data.MySQL | |||
301 | return ExecuteNonQuery(cmd) > 0; | 301 | return ExecuteNonQuery(cmd) > 0; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | |||
305 | public long GetCount(string field, string key) | ||
306 | { | ||
307 | return GetCount(new string[] { field }, new string[] { key }); | ||
308 | } | ||
309 | |||
310 | public long GetCount(string[] fields, string[] keys) | ||
311 | { | ||
312 | if (fields.Length != keys.Length) | ||
313 | return 0; | ||
314 | |||
315 | List<string> terms = new List<string>(); | ||
316 | |||
317 | using (MySqlCommand cmd = new MySqlCommand()) | ||
318 | { | ||
319 | for (int i = 0; i < fields.Length; i++) | ||
320 | { | ||
321 | cmd.Parameters.AddWithValue(fields[i], keys[i]); | ||
322 | terms.Add("`" + fields[i] + "` = ?" + fields[i]); | ||
323 | } | ||
324 | |||
325 | string where = String.Join(" and ", terms.ToArray()); | ||
326 | |||
327 | string query = String.Format("select count(*) from {0} where {1}", | ||
328 | m_Realm, where); | ||
329 | |||
330 | cmd.CommandText = query; | ||
331 | |||
332 | Object result = DoQueryScalar(cmd); | ||
333 | |||
334 | return Convert.ToInt64(result); | ||
335 | } | ||
336 | } | ||
337 | |||
338 | public long GetCount(string where) | ||
339 | { | ||
340 | using (MySqlCommand cmd = new MySqlCommand()) | ||
341 | { | ||
342 | string query = String.Format("select count(*) from {0} where {1}", | ||
343 | m_Realm, where); | ||
344 | |||
345 | cmd.CommandText = query; | ||
346 | |||
347 | object result = DoQueryScalar(cmd); | ||
348 | |||
349 | return Convert.ToInt64(result); | ||
350 | } | ||
351 | } | ||
352 | |||
353 | public object DoQueryScalar(MySqlCommand cmd) | ||
354 | { | ||
355 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
356 | { | ||
357 | dbcon.Open(); | ||
358 | cmd.Connection = dbcon; | ||
359 | |||
360 | return cmd.ExecuteScalar(); | ||
361 | } | ||
362 | } | ||
363 | |||
304 | } | 364 | } |
305 | } \ No newline at end of file | 365 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index a9ce94d..00560c1 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Data.MySQL | |||
46 | 46 | ||
47 | public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} | 47 | public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} |
48 | 48 | ||
49 | public GridUserData Get(string userID) | 49 | public new GridUserData Get(string userID) |
50 | { | 50 | { |
51 | GridUserData[] ret = Get("UserID", userID); | 51 | GridUserData[] ret = Get("UserID", userID); |
52 | 52 | ||
@@ -56,6 +56,9 @@ namespace OpenSim.Data.MySQL | |||
56 | return ret[0]; | 56 | return ret[0]; |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | public GridUserData[] GetAll(string userID) | |
60 | { | ||
61 | return base.Get(String.Format("UserID LIKE '{0}%'", userID)); | ||
62 | } | ||
60 | } | 63 | } |
61 | } \ No newline at end of file | 64 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs new file mode 100644 index 0000000..afa499e --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs | |||
@@ -0,0 +1,484 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Data.MySQL; | ||
35 | |||
36 | using OpenMetaverse; | ||
37 | using MySql.Data.MySqlClient; | ||
38 | |||
39 | namespace OpenSim.Data.MySQL | ||
40 | { | ||
41 | public class MySQLGroupsData : IGroupsData | ||
42 | { | ||
43 | private MySqlGroupsGroupsHandler m_Groups; | ||
44 | private MySqlGroupsMembershipHandler m_Membership; | ||
45 | private MySqlGroupsRolesHandler m_Roles; | ||
46 | private MySqlGroupsRoleMembershipHandler m_RoleMembership; | ||
47 | private MySqlGroupsInvitesHandler m_Invites; | ||
48 | private MySqlGroupsNoticesHandler m_Notices; | ||
49 | private MySqlGroupsPrincipalsHandler m_Principals; | ||
50 | |||
51 | public MySQLGroupsData(string connectionString, string realm) | ||
52 | { | ||
53 | m_Groups = new MySqlGroupsGroupsHandler(connectionString, realm + "_groups", realm + "_Store"); | ||
54 | m_Membership = new MySqlGroupsMembershipHandler(connectionString, realm + "_membership"); | ||
55 | m_Roles = new MySqlGroupsRolesHandler(connectionString, realm + "_roles"); | ||
56 | m_RoleMembership = new MySqlGroupsRoleMembershipHandler(connectionString, realm + "_rolemembership"); | ||
57 | m_Invites = new MySqlGroupsInvitesHandler(connectionString, realm + "_invites"); | ||
58 | m_Notices = new MySqlGroupsNoticesHandler(connectionString, realm + "_notices"); | ||
59 | m_Principals = new MySqlGroupsPrincipalsHandler(connectionString, realm + "_principals"); | ||
60 | } | ||
61 | |||
62 | #region groups table | ||
63 | public bool StoreGroup(GroupData data) | ||
64 | { | ||
65 | return m_Groups.Store(data); | ||
66 | } | ||
67 | |||
68 | public GroupData RetrieveGroup(UUID groupID) | ||
69 | { | ||
70 | GroupData[] groups = m_Groups.Get("GroupID", groupID.ToString()); | ||
71 | if (groups.Length > 0) | ||
72 | return groups[0]; | ||
73 | |||
74 | return null; | ||
75 | } | ||
76 | |||
77 | public GroupData RetrieveGroup(string name) | ||
78 | { | ||
79 | GroupData[] groups = m_Groups.Get("Name", name); | ||
80 | if (groups.Length > 0) | ||
81 | return groups[0]; | ||
82 | |||
83 | return null; | ||
84 | } | ||
85 | |||
86 | public GroupData[] RetrieveGroups(string pattern) | ||
87 | { | ||
88 | if (string.IsNullOrEmpty(pattern)) | ||
89 | pattern = "1"; | ||
90 | else | ||
91 | pattern = string.Format("Name LIKE '%{0}%'", MySqlHelper.EscapeString(pattern)); | ||
92 | |||
93 | return m_Groups.Get(string.Format("ShowInList=1 AND ({0}) ORDER BY Name LIMIT 100", pattern)); | ||
94 | } | ||
95 | |||
96 | public bool DeleteGroup(UUID groupID) | ||
97 | { | ||
98 | return m_Groups.Delete("GroupID", groupID.ToString()); | ||
99 | } | ||
100 | |||
101 | public int GroupsCount() | ||
102 | { | ||
103 | return (int)m_Groups.GetCount("Location=\"\""); | ||
104 | } | ||
105 | |||
106 | #endregion | ||
107 | |||
108 | #region membership table | ||
109 | public MembershipData[] RetrieveMembers(UUID groupID) | ||
110 | { | ||
111 | return m_Membership.Get("GroupID", groupID.ToString()); | ||
112 | } | ||
113 | |||
114 | public MembershipData RetrieveMember(UUID groupID, string pricipalID) | ||
115 | { | ||
116 | MembershipData[] m = m_Membership.Get(new string[] { "GroupID", "PrincipalID" }, | ||
117 | new string[] { groupID.ToString(), pricipalID }); | ||
118 | if (m != null && m.Length > 0) | ||
119 | return m[0]; | ||
120 | |||
121 | return null; | ||
122 | } | ||
123 | |||
124 | public MembershipData[] RetrieveMemberships(string pricipalID) | ||
125 | { | ||
126 | return m_Membership.Get("PrincipalID", pricipalID.ToString()); | ||
127 | } | ||
128 | |||
129 | public bool StoreMember(MembershipData data) | ||
130 | { | ||
131 | return m_Membership.Store(data); | ||
132 | } | ||
133 | |||
134 | public bool DeleteMember(UUID groupID, string pricipalID) | ||
135 | { | ||
136 | return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" }, | ||
137 | new string[] { groupID.ToString(), pricipalID }); | ||
138 | } | ||
139 | |||
140 | public int MemberCount(UUID groupID) | ||
141 | { | ||
142 | return (int)m_Membership.GetCount("GroupID", groupID.ToString()); | ||
143 | } | ||
144 | #endregion | ||
145 | |||
146 | #region roles table | ||
147 | public bool StoreRole(RoleData data) | ||
148 | { | ||
149 | return m_Roles.Store(data); | ||
150 | } | ||
151 | |||
152 | public RoleData RetrieveRole(UUID groupID, UUID roleID) | ||
153 | { | ||
154 | RoleData[] data = m_Roles.Get(new string[] { "GroupID", "RoleID" }, | ||
155 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
156 | |||
157 | if (data != null && data.Length > 0) | ||
158 | return data[0]; | ||
159 | |||
160 | return null; | ||
161 | } | ||
162 | |||
163 | public RoleData[] RetrieveRoles(UUID groupID) | ||
164 | { | ||
165 | //return m_Roles.RetrieveRoles(groupID); | ||
166 | return m_Roles.Get("GroupID", groupID.ToString()); | ||
167 | } | ||
168 | |||
169 | public bool DeleteRole(UUID groupID, UUID roleID) | ||
170 | { | ||
171 | return m_Roles.Delete(new string[] { "GroupID", "RoleID" }, | ||
172 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
173 | } | ||
174 | |||
175 | public int RoleCount(UUID groupID) | ||
176 | { | ||
177 | return (int)m_Roles.GetCount("GroupID", groupID.ToString()); | ||
178 | } | ||
179 | |||
180 | |||
181 | #endregion | ||
182 | |||
183 | #region rolememberhip table | ||
184 | public RoleMembershipData[] RetrieveRolesMembers(UUID groupID) | ||
185 | { | ||
186 | RoleMembershipData[] data = m_RoleMembership.Get("GroupID", groupID.ToString()); | ||
187 | |||
188 | return data; | ||
189 | } | ||
190 | |||
191 | public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID) | ||
192 | { | ||
193 | RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID" }, | ||
194 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
195 | |||
196 | return data; | ||
197 | } | ||
198 | |||
199 | public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID) | ||
200 | { | ||
201 | RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "PrincipalID" }, | ||
202 | new string[] { groupID.ToString(), principalID.ToString() }); | ||
203 | |||
204 | return data; | ||
205 | } | ||
206 | |||
207 | public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID) | ||
208 | { | ||
209 | RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID", "PrincipalID" }, | ||
210 | new string[] { groupID.ToString(), roleID.ToString(), principalID.ToString() }); | ||
211 | |||
212 | if (data != null && data.Length > 0) | ||
213 | return data[0]; | ||
214 | |||
215 | return null; | ||
216 | } | ||
217 | |||
218 | public int RoleMemberCount(UUID groupID, UUID roleID) | ||
219 | { | ||
220 | return (int)m_RoleMembership.GetCount(new string[] { "GroupID", "RoleID" }, | ||
221 | new string[] { groupID.ToString(), roleID.ToString() }); | ||
222 | } | ||
223 | |||
224 | public bool StoreRoleMember(RoleMembershipData data) | ||
225 | { | ||
226 | return m_RoleMembership.Store(data); | ||
227 | } | ||
228 | |||
229 | public bool DeleteRoleMember(RoleMembershipData data) | ||
230 | { | ||
231 | return m_RoleMembership.Delete(new string[] { "GroupID", "RoleID", "PrincipalID"}, | ||
232 | new string[] { data.GroupID.ToString(), data.RoleID.ToString(), data.PrincipalID }); | ||
233 | } | ||
234 | |||
235 | public bool DeleteMemberAllRoles(UUID groupID, string principalID) | ||
236 | { | ||
237 | return m_RoleMembership.Delete(new string[] { "GroupID", "PrincipalID" }, | ||
238 | new string[] { groupID.ToString(), principalID }); | ||
239 | } | ||
240 | |||
241 | #endregion | ||
242 | |||
243 | #region principals table | ||
244 | public bool StorePrincipal(PrincipalData data) | ||
245 | { | ||
246 | return m_Principals.Store(data); | ||
247 | } | ||
248 | |||
249 | public PrincipalData RetrievePrincipal(string principalID) | ||
250 | { | ||
251 | PrincipalData[] p = m_Principals.Get("PrincipalID", principalID); | ||
252 | if (p != null && p.Length > 0) | ||
253 | return p[0]; | ||
254 | |||
255 | return null; | ||
256 | } | ||
257 | |||
258 | public bool DeletePrincipal(string principalID) | ||
259 | { | ||
260 | return m_Principals.Delete("PrincipalID", principalID); | ||
261 | } | ||
262 | #endregion | ||
263 | |||
264 | #region invites table | ||
265 | |||
266 | public bool StoreInvitation(InvitationData data) | ||
267 | { | ||
268 | return m_Invites.Store(data); | ||
269 | } | ||
270 | |||
271 | public InvitationData RetrieveInvitation(UUID inviteID) | ||
272 | { | ||
273 | InvitationData[] invites = m_Invites.Get("InviteID", inviteID.ToString()); | ||
274 | |||
275 | if (invites != null && invites.Length > 0) | ||
276 | return invites[0]; | ||
277 | |||
278 | return null; | ||
279 | } | ||
280 | |||
281 | public InvitationData RetrieveInvitation(UUID groupID, string principalID) | ||
282 | { | ||
283 | InvitationData[] invites = m_Invites.Get(new string[] { "GroupID", "PrincipalID" }, | ||
284 | new string[] { groupID.ToString(), principalID }); | ||
285 | |||
286 | if (invites != null && invites.Length > 0) | ||
287 | return invites[0]; | ||
288 | |||
289 | return null; | ||
290 | } | ||
291 | |||
292 | public bool DeleteInvite(UUID inviteID) | ||
293 | { | ||
294 | return m_Invites.Delete("InviteID", inviteID.ToString()); | ||
295 | } | ||
296 | |||
297 | public void DeleteOldInvites() | ||
298 | { | ||
299 | m_Invites.DeleteOld(); | ||
300 | } | ||
301 | |||
302 | #endregion | ||
303 | |||
304 | #region notices table | ||
305 | |||
306 | public bool StoreNotice(NoticeData data) | ||
307 | { | ||
308 | return m_Notices.Store(data); | ||
309 | } | ||
310 | |||
311 | public NoticeData RetrieveNotice(UUID noticeID) | ||
312 | { | ||
313 | NoticeData[] notices = m_Notices.Get("NoticeID", noticeID.ToString()); | ||
314 | |||
315 | if (notices != null && notices.Length > 0) | ||
316 | return notices[0]; | ||
317 | |||
318 | return null; | ||
319 | } | ||
320 | |||
321 | public NoticeData[] RetrieveNotices(UUID groupID) | ||
322 | { | ||
323 | NoticeData[] notices = m_Notices.Get("GroupID", groupID.ToString()); | ||
324 | |||
325 | return notices; | ||
326 | } | ||
327 | |||
328 | public bool DeleteNotice(UUID noticeID) | ||
329 | { | ||
330 | return m_Notices.Delete("NoticeID", noticeID.ToString()); | ||
331 | } | ||
332 | |||
333 | public void DeleteOldNotices() | ||
334 | { | ||
335 | m_Notices.DeleteOld(); | ||
336 | } | ||
337 | |||
338 | #endregion | ||
339 | |||
340 | #region combinations | ||
341 | public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID) | ||
342 | { | ||
343 | // TODO | ||
344 | return null; | ||
345 | } | ||
346 | public MembershipData[] RetrievePrincipalGroupMemberships(string principalID) | ||
347 | { | ||
348 | // TODO | ||
349 | return null; | ||
350 | } | ||
351 | |||
352 | #endregion | ||
353 | } | ||
354 | |||
355 | public class MySqlGroupsGroupsHandler : MySQLGenericTableHandler<GroupData> | ||
356 | { | ||
357 | protected override Assembly Assembly | ||
358 | { | ||
359 | // WARNING! Moving migrations to this assembly!!! | ||
360 | get { return GetType().Assembly; } | ||
361 | } | ||
362 | |||
363 | public MySqlGroupsGroupsHandler(string connectionString, string realm, string store) | ||
364 | : base(connectionString, realm, store) | ||
365 | { | ||
366 | } | ||
367 | |||
368 | } | ||
369 | |||
370 | public class MySqlGroupsMembershipHandler : MySQLGenericTableHandler<MembershipData> | ||
371 | { | ||
372 | protected override Assembly Assembly | ||
373 | { | ||
374 | // WARNING! Moving migrations to this assembly!!! | ||
375 | get { return GetType().Assembly; } | ||
376 | } | ||
377 | |||
378 | public MySqlGroupsMembershipHandler(string connectionString, string realm) | ||
379 | : base(connectionString, realm, string.Empty) | ||
380 | { | ||
381 | } | ||
382 | |||
383 | } | ||
384 | |||
385 | public class MySqlGroupsRolesHandler : MySQLGenericTableHandler<RoleData> | ||
386 | { | ||
387 | protected override Assembly Assembly | ||
388 | { | ||
389 | // WARNING! Moving migrations to this assembly!!! | ||
390 | get { return GetType().Assembly; } | ||
391 | } | ||
392 | |||
393 | public MySqlGroupsRolesHandler(string connectionString, string realm) | ||
394 | : base(connectionString, realm, string.Empty) | ||
395 | { | ||
396 | } | ||
397 | |||
398 | } | ||
399 | |||
400 | public class MySqlGroupsRoleMembershipHandler : MySQLGenericTableHandler<RoleMembershipData> | ||
401 | { | ||
402 | protected override Assembly Assembly | ||
403 | { | ||
404 | // WARNING! Moving migrations to this assembly!!! | ||
405 | get { return GetType().Assembly; } | ||
406 | } | ||
407 | |||
408 | public MySqlGroupsRoleMembershipHandler(string connectionString, string realm) | ||
409 | : base(connectionString, realm, string.Empty) | ||
410 | { | ||
411 | } | ||
412 | |||
413 | } | ||
414 | |||
415 | public class MySqlGroupsInvitesHandler : MySQLGenericTableHandler<InvitationData> | ||
416 | { | ||
417 | protected override Assembly Assembly | ||
418 | { | ||
419 | // WARNING! Moving migrations to this assembly!!! | ||
420 | get { return GetType().Assembly; } | ||
421 | } | ||
422 | |||
423 | public MySqlGroupsInvitesHandler(string connectionString, string realm) | ||
424 | : base(connectionString, realm, string.Empty) | ||
425 | { | ||
426 | } | ||
427 | |||
428 | public void DeleteOld() | ||
429 | { | ||
430 | uint now = (uint)Util.UnixTimeSinceEpoch(); | ||
431 | |||
432 | using (MySqlCommand cmd = new MySqlCommand()) | ||
433 | { | ||
434 | cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); | ||
435 | cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old | ||
436 | |||
437 | ExecuteNonQuery(cmd); | ||
438 | } | ||
439 | |||
440 | } | ||
441 | } | ||
442 | |||
443 | public class MySqlGroupsNoticesHandler : MySQLGenericTableHandler<NoticeData> | ||
444 | { | ||
445 | protected override Assembly Assembly | ||
446 | { | ||
447 | // WARNING! Moving migrations to this assembly!!! | ||
448 | get { return GetType().Assembly; } | ||
449 | } | ||
450 | |||
451 | public MySqlGroupsNoticesHandler(string connectionString, string realm) | ||
452 | : base(connectionString, realm, string.Empty) | ||
453 | { | ||
454 | } | ||
455 | |||
456 | public void DeleteOld() | ||
457 | { | ||
458 | uint now = (uint)Util.UnixTimeSinceEpoch(); | ||
459 | |||
460 | using (MySqlCommand cmd = new MySqlCommand()) | ||
461 | { | ||
462 | cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm); | ||
463 | cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old | ||
464 | |||
465 | ExecuteNonQuery(cmd); | ||
466 | } | ||
467 | |||
468 | } | ||
469 | } | ||
470 | |||
471 | public class MySqlGroupsPrincipalsHandler : MySQLGenericTableHandler<PrincipalData> | ||
472 | { | ||
473 | protected override Assembly Assembly | ||
474 | { | ||
475 | // WARNING! Moving migrations to this assembly!!! | ||
476 | get { return GetType().Assembly; } | ||
477 | } | ||
478 | |||
479 | public MySqlGroupsPrincipalsHandler(string connectionString, string realm) | ||
480 | : base(connectionString, realm, string.Empty) | ||
481 | { | ||
482 | } | ||
483 | } | ||
484 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLHGTravelData.cs b/OpenSim/Data/MySQL/MySQLHGTravelData.cs new file mode 100644 index 0000000..e81b880 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLHGTravelData.cs | |||
@@ -0,0 +1,80 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using MySql.Data.MySqlClient; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// A MySQL Interface for user grid data | ||
42 | /// </summary> | ||
43 | public class MySQLHGTravelData : MySQLGenericTableHandler<HGTravelingData>, IHGTravelingData | ||
44 | { | ||
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | public MySQLHGTravelData(string connectionString, string realm) : base(connectionString, realm, "HGTravelStore") { } | ||
48 | |||
49 | public HGTravelingData Get(UUID sessionID) | ||
50 | { | ||
51 | HGTravelingData[] ret = Get("SessionID", sessionID.ToString()); | ||
52 | |||
53 | if (ret.Length == 0) | ||
54 | return null; | ||
55 | |||
56 | return ret[0]; | ||
57 | } | ||
58 | |||
59 | public HGTravelingData[] GetSessions(UUID userID) | ||
60 | { | ||
61 | return base.Get("UserID", userID.ToString()); | ||
62 | } | ||
63 | |||
64 | public bool Delete(UUID sessionID) | ||
65 | { | ||
66 | return Delete("SessionID", sessionID.ToString()); | ||
67 | } | ||
68 | |||
69 | public void DeleteOld() | ||
70 | { | ||
71 | using (MySqlCommand cmd = new MySqlCommand()) | ||
72 | { | ||
73 | cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 DAY", m_Realm); | ||
74 | |||
75 | ExecuteNonQuery(cmd); | ||
76 | } | ||
77 | |||
78 | } | ||
79 | } | ||
80 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/MySQL/MySQLOfflineIMData.cs b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs new file mode 100644 index 0000000..bafd204 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs | |||
@@ -0,0 +1,59 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Data.MySQL; | ||
35 | |||
36 | using OpenMetaverse; | ||
37 | using MySql.Data.MySqlClient; | ||
38 | |||
39 | namespace OpenSim.Data.MySQL | ||
40 | { | ||
41 | public class MySQLOfflineIMData : MySQLGenericTableHandler<OfflineIMData>, IOfflineIMData | ||
42 | { | ||
43 | public MySQLOfflineIMData(string connectionString, string realm) | ||
44 | : base(connectionString, realm, "IM_Store") | ||
45 | { | ||
46 | } | ||
47 | |||
48 | public void DeleteOld() | ||
49 | { | ||
50 | using (MySqlCommand cmd = new MySqlCommand()) | ||
51 | { | ||
52 | cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 WEEK", m_Realm); | ||
53 | |||
54 | ExecuteNonQuery(cmd); | ||
55 | } | ||
56 | |||
57 | } | ||
58 | } | ||
59 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index a2d4ae4..2ad7590 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -310,6 +310,11 @@ namespace OpenSim.Data.MySQL | |||
310 | return Get((int)RegionFlags.DefaultRegion, scopeID); | 310 | return Get((int)RegionFlags.DefaultRegion, scopeID); |
311 | } | 311 | } |
312 | 312 | ||
313 | public List<RegionData> GetDefaultHypergridRegions(UUID scopeID) | ||
314 | { | ||
315 | return Get((int)RegionFlags.DefaultHGRegion, scopeID); | ||
316 | } | ||
317 | |||
313 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) | 318 | public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) |
314 | { | 319 | { |
315 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); | 320 | List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID); |
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index d562783..bb0ab75 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -48,8 +48,18 @@ namespace OpenSim.Data.MySQL | |||
48 | public class MySQLSimulationData : ISimulationDataStore | 48 | public class MySQLSimulationData : ISimulationDataStore |
49 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | private static string LogHeader = "[REGION DB MYSQL]"; | ||
51 | 52 | ||
52 | private string m_connectionString; | 53 | private string m_connectionString; |
54 | |||
55 | /// <summary> | ||
56 | /// This lock was being used to serialize database operations when the connection was shared, but this has | ||
57 | /// been unnecessary for a long time after we switched to using MySQL's underlying connection pooling instead. | ||
58 | /// FIXME: However, the locks remain in many places since they are effectively providing a level of | ||
59 | /// transactionality. This should be replaced by more efficient database transactions which would not require | ||
60 | /// unrelated operations to block each other or unrelated operations on the same tables from blocking each | ||
61 | /// other. | ||
62 | /// </summary> | ||
53 | private object m_dbLock = new object(); | 63 | private object m_dbLock = new object(); |
54 | 64 | ||
55 | protected virtual Assembly Assembly | 65 | protected virtual Assembly Assembly |
@@ -91,7 +101,7 @@ namespace OpenSim.Data.MySQL | |||
91 | } | 101 | } |
92 | catch (Exception e) | 102 | catch (Exception e) |
93 | { | 103 | { |
94 | m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message); | 104 | m_log.ErrorFormat("{0} MySQL error in ExecuteReader: {1}", LogHeader, e); |
95 | throw; | 105 | throw; |
96 | } | 106 | } |
97 | 107 | ||
@@ -119,8 +129,10 @@ namespace OpenSim.Data.MySQL | |||
119 | 129 | ||
120 | // Eligibility check | 130 | // Eligibility check |
121 | // | 131 | // |
122 | if ((flags & (uint)PrimFlags.Temporary) != 0) | 132 | // PrimFlags.Temporary is not used in OpenSim code and cannot |
123 | return; | 133 | // be guaranteed to always be clear. Don't check it. |
134 | // if ((flags & (uint)PrimFlags.Temporary) != 0) | ||
135 | // return; | ||
124 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) | 136 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) |
125 | return; | 137 | return; |
126 | 138 | ||
@@ -135,7 +147,7 @@ namespace OpenSim.Data.MySQL | |||
135 | foreach (SceneObjectPart prim in obj.Parts) | 147 | foreach (SceneObjectPart prim in obj.Parts) |
136 | { | 148 | { |
137 | cmd.Parameters.Clear(); | 149 | cmd.Parameters.Clear(); |
138 | 150 | ||
139 | cmd.CommandText = "replace into prims (" + | 151 | cmd.CommandText = "replace into prims (" + |
140 | "UUID, CreationDate, " + | 152 | "UUID, CreationDate, " + |
141 | "Name, Text, Description, " + | 153 | "Name, Text, Description, " + |
@@ -171,7 +183,11 @@ namespace OpenSim.Data.MySQL | |||
171 | "ParticleSystem, ClickAction, Material, " + | 183 | "ParticleSystem, ClickAction, Material, " + |
172 | "CollisionSound, CollisionSoundVolume, " + | 184 | "CollisionSound, CollisionSoundVolume, " + |
173 | "PassTouches, " + | 185 | "PassTouches, " + |
174 | "LinkNumber, MediaURL) values (" + "?UUID, " + | 186 | "LinkNumber, MediaURL, AttachedPosX, " + |
187 | "AttachedPosY, AttachedPosZ, KeyframeMotion, " + | ||
188 | "PhysicsShapeType, Density, GravityModifier, " + | ||
189 | "Friction, Restitution, DynAttrs " + | ||
190 | ") values (" + "?UUID, " + | ||
175 | "?CreationDate, ?Name, ?Text, " + | 191 | "?CreationDate, ?Name, ?Text, " + |
176 | "?Description, ?SitName, ?TouchName, " + | 192 | "?Description, ?SitName, ?TouchName, " + |
177 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + | 193 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + |
@@ -202,14 +218,18 @@ namespace OpenSim.Data.MySQL | |||
202 | "?SaleType, ?ColorR, ?ColorG, " + | 218 | "?SaleType, ?ColorR, ?ColorG, " + |
203 | "?ColorB, ?ColorA, ?ParticleSystem, " + | 219 | "?ColorB, ?ColorA, ?ParticleSystem, " + |
204 | "?ClickAction, ?Material, ?CollisionSound, " + | 220 | "?ClickAction, ?Material, ?CollisionSound, " + |
205 | "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; | 221 | "?CollisionSoundVolume, ?PassTouches, " + |
206 | 222 | "?LinkNumber, ?MediaURL, ?AttachedPosX, " + | |
223 | "?AttachedPosY, ?AttachedPosZ, ?KeyframeMotion, " + | ||
224 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + | ||
225 | "?Friction, ?Restitution, ?DynAttrs)"; | ||
226 | |||
207 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | 227 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); |
208 | 228 | ||
209 | ExecuteNonQuery(cmd); | 229 | ExecuteNonQuery(cmd); |
210 | 230 | ||
211 | cmd.Parameters.Clear(); | 231 | cmd.Parameters.Clear(); |
212 | 232 | ||
213 | cmd.CommandText = "replace into primshapes (" + | 233 | cmd.CommandText = "replace into primshapes (" + |
214 | "UUID, Shape, ScaleX, ScaleY, " + | 234 | "UUID, Shape, ScaleX, ScaleY, " + |
215 | "ScaleZ, PCode, PathBegin, PathEnd, " + | 235 | "ScaleZ, PCode, PathBegin, PathEnd, " + |
@@ -219,7 +239,8 @@ namespace OpenSim.Data.MySQL | |||
219 | "PathTaperX, PathTaperY, PathTwist, " + | 239 | "PathTaperX, PathTaperY, PathTwist, " + |
220 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + | 240 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + |
221 | "ProfileCurve, ProfileHollow, Texture, " + | 241 | "ProfileCurve, ProfileHollow, Texture, " + |
222 | "ExtraParams, State, Media) values (?UUID, " + | 242 | "ExtraParams, State, LastAttachPoint, Media) " + |
243 | "values (?UUID, " + | ||
223 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + | 244 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + |
224 | "?PCode, ?PathBegin, ?PathEnd, " + | 245 | "?PCode, ?PathBegin, ?PathEnd, " + |
225 | "?PathScaleX, ?PathScaleY, " + | 246 | "?PathScaleX, ?PathScaleY, " + |
@@ -230,10 +251,10 @@ namespace OpenSim.Data.MySQL | |||
230 | "?PathTwistBegin, ?ProfileBegin, " + | 251 | "?PathTwistBegin, ?ProfileBegin, " + |
231 | "?ProfileEnd, ?ProfileCurve, " + | 252 | "?ProfileEnd, ?ProfileCurve, " + |
232 | "?ProfileHollow, ?Texture, ?ExtraParams, " + | 253 | "?ProfileHollow, ?Texture, ?ExtraParams, " + |
233 | "?State, ?Media)"; | 254 | "?State, ?LastAttachPoint, ?Media)"; |
234 | 255 | ||
235 | FillShapeCommand(cmd, prim); | 256 | FillShapeCommand(cmd, prim); |
236 | 257 | ||
237 | ExecuteNonQuery(cmd); | 258 | ExecuteNonQuery(cmd); |
238 | } | 259 | } |
239 | } | 260 | } |
@@ -446,7 +467,9 @@ namespace OpenSim.Data.MySQL | |||
446 | foreach (SceneObjectPart prim in prims.Values) | 467 | foreach (SceneObjectPart prim in prims.Values) |
447 | { | 468 | { |
448 | if (prim.ParentUUID == UUID.Zero) | 469 | if (prim.ParentUUID == UUID.Zero) |
470 | { | ||
449 | objects[prim.UUID] = new SceneObjectGroup(prim); | 471 | objects[prim.UUID] = new SceneObjectGroup(prim); |
472 | } | ||
450 | } | 473 | } |
451 | 474 | ||
452 | // Add all of the children objects to the SOGs | 475 | // Add all of the children objects to the SOGs |
@@ -559,10 +582,14 @@ namespace OpenSim.Data.MySQL | |||
559 | } | 582 | } |
560 | } | 583 | } |
561 | 584 | ||
585 | // Legacy entry point for when terrain was always a 256x256 hieghtmap | ||
562 | public void StoreTerrain(double[,] ter, UUID regionID) | 586 | public void StoreTerrain(double[,] ter, UUID regionID) |
563 | { | 587 | { |
564 | m_log.Info("[REGION DB]: Storing terrain"); | 588 | StoreTerrain(new HeightmapTerrainData(ter), regionID); |
589 | } | ||
565 | 590 | ||
591 | public void StoreTerrain(TerrainData terrData, UUID regionID) | ||
592 | { | ||
566 | lock (m_dbLock) | 593 | lock (m_dbLock) |
567 | { | 594 | { |
568 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 595 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
@@ -576,11 +603,18 @@ namespace OpenSim.Data.MySQL | |||
576 | 603 | ||
577 | ExecuteNonQuery(cmd); | 604 | ExecuteNonQuery(cmd); |
578 | 605 | ||
579 | cmd.CommandText = "insert into terrain (RegionUUID, " + | 606 | int terrainDBRevision; |
580 | "Revision, Heightfield) values (?RegionUUID, " + | 607 | Array terrainDBblob; |
581 | "1, ?Heightfield)"; | 608 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); |
609 | |||
610 | m_log.InfoFormat("{0} Storing terrain. X={1}, Y={2}, rev={3}", | ||
611 | LogHeader, terrData.SizeX, terrData.SizeY, terrainDBRevision); | ||
582 | 612 | ||
583 | cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); | 613 | cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)" |
614 | + "values (?RegionUUID, ?Revision, ?Heightfield)"; | ||
615 | |||
616 | cmd.Parameters.AddWithValue("Revision", terrainDBRevision); | ||
617 | cmd.Parameters.AddWithValue("Heightfield", terrainDBblob); | ||
584 | 618 | ||
585 | ExecuteNonQuery(cmd); | 619 | ExecuteNonQuery(cmd); |
586 | } | 620 | } |
@@ -588,9 +622,20 @@ namespace OpenSim.Data.MySQL | |||
588 | } | 622 | } |
589 | } | 623 | } |
590 | 624 | ||
625 | // Legacy region loading | ||
591 | public double[,] LoadTerrain(UUID regionID) | 626 | public double[,] LoadTerrain(UUID regionID) |
592 | { | 627 | { |
593 | double[,] terrain = null; | 628 | double[,] ret = null; |
629 | TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); | ||
630 | if (terrData != null) | ||
631 | ret = terrData.GetDoubles(); | ||
632 | return ret; | ||
633 | } | ||
634 | |||
635 | // Returns 'null' if region not found | ||
636 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
637 | { | ||
638 | TerrainData terrData = null; | ||
594 | 639 | ||
595 | lock (m_dbLock) | 640 | lock (m_dbLock) |
596 | { | 641 | { |
@@ -610,32 +655,15 @@ namespace OpenSim.Data.MySQL | |||
610 | while (reader.Read()) | 655 | while (reader.Read()) |
611 | { | 656 | { |
612 | int rev = Convert.ToInt32(reader["Revision"]); | 657 | int rev = Convert.ToInt32(reader["Revision"]); |
613 | 658 | byte[] blob = (byte[])reader["Heightfield"]; | |
614 | terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | 659 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); |
615 | terrain.Initialize(); | ||
616 | |||
617 | using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) | ||
618 | { | ||
619 | using (BinaryReader br = new BinaryReader(mstr)) | ||
620 | { | ||
621 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
622 | { | ||
623 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
624 | { | ||
625 | terrain[x, y] = br.ReadDouble(); | ||
626 | } | ||
627 | } | ||
628 | } | ||
629 | |||
630 | m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); | ||
631 | } | ||
632 | } | 660 | } |
633 | } | 661 | } |
634 | } | 662 | } |
635 | } | 663 | } |
636 | } | 664 | } |
637 | 665 | ||
638 | return terrain; | 666 | return terrData; |
639 | } | 667 | } |
640 | 668 | ||
641 | public void RemoveLandObject(UUID globalID) | 669 | public void RemoveLandObject(UUID globalID) |
@@ -676,7 +704,7 @@ namespace OpenSim.Data.MySQL | |||
676 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + | 704 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + |
677 | "UserLocationX, UserLocationY, UserLocationZ, " + | 705 | "UserLocationX, UserLocationY, UserLocationZ, " + |
678 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + | 706 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + |
679 | "AuthbuyerID, OtherCleanTime, MediaType, MediaDescription, " + | 707 | "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " + |
680 | "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + | 708 | "MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" + |
681 | "?UUID, ?RegionUUID, " + | 709 | "?UUID, ?RegionUUID, " + |
682 | "?LocalLandID, ?Bitmap, ?Name, ?Description, " + | 710 | "?LocalLandID, ?Bitmap, ?Name, ?Description, " + |
@@ -687,7 +715,7 @@ namespace OpenSim.Data.MySQL | |||
687 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + | 715 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + |
688 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + | 716 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + |
689 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + | 717 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + |
690 | "?AuthbuyerID, ?OtherCleanTime, ?MediaType, ?MediaDescription, "+ | 718 | "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+ |
691 | "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; | 719 | "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)"; |
692 | 720 | ||
693 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); | 721 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); |
@@ -719,95 +747,92 @@ namespace OpenSim.Data.MySQL | |||
719 | RegionLightShareData nWP = new RegionLightShareData(); | 747 | RegionLightShareData nWP = new RegionLightShareData(); |
720 | nWP.OnSave += StoreRegionWindlightSettings; | 748 | nWP.OnSave += StoreRegionWindlightSettings; |
721 | 749 | ||
722 | lock (m_dbLock) | 750 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
723 | { | 751 | { |
724 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 752 | dbcon.Open(); |
753 | |||
754 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | ||
755 | |||
756 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
725 | { | 757 | { |
726 | dbcon.Open(); | 758 | cmd.Connection = dbcon; |
727 | 759 | ||
728 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | 760 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); |
729 | 761 | ||
730 | using (MySqlCommand cmd = new MySqlCommand(command)) | 762 | IDataReader result = ExecuteReader(cmd); |
763 | if (!result.Read()) | ||
731 | { | 764 | { |
732 | cmd.Connection = dbcon; | 765 | //No result, so store our default windlight profile and return it |
733 | 766 | nWP.regionID = regionUUID; | |
734 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); | 767 | // StoreRegionWindlightSettings(nWP); |
735 | 768 | return nWP; | |
736 | IDataReader result = ExecuteReader(cmd); | 769 | } |
737 | if (!result.Read()) | 770 | else |
738 | { | 771 | { |
739 | //No result, so store our default windlight profile and return it | 772 | nWP.regionID = DBGuid.FromDB(result["region_id"]); |
740 | nWP.regionID = regionUUID; | 773 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); |
741 | StoreRegionWindlightSettings(nWP); | 774 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); |
742 | return nWP; | 775 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); |
743 | } | 776 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); |
744 | else | 777 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); |
745 | { | 778 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); |
746 | nWP.regionID = DBGuid.FromDB(result["region_id"]); | 779 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); |
747 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); | 780 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); |
748 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); | 781 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); |
749 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); | 782 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); |
750 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); | 783 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); |
751 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); | 784 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); |
752 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); | 785 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); |
753 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); | 786 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); |
754 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); | 787 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); |
755 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); | 788 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); |
756 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); | 789 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); |
757 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); | 790 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); |
758 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); | 791 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); |
759 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); | 792 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); |
760 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); | 793 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); |
761 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); | 794 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); |
762 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); | 795 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); |
763 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); | 796 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); |
764 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); | 797 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); |
765 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); | 798 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); |
766 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); | 799 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); |
767 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); | 800 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); |
768 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); | 801 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); |
769 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); | 802 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); |
770 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); | 803 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); |
771 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); | 804 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); |
772 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); | 805 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); |
773 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); | 806 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); |
774 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); | 807 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); |
775 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); | 808 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); |
776 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); | 809 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); |
777 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); | 810 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); |
778 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); | 811 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); |
779 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); | 812 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); |
780 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); | 813 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); |
781 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); | 814 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); |
782 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); | 815 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); |
783 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); | 816 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); |
784 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); | 817 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); |
785 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); | 818 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); |
786 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); | 819 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); |
787 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); | 820 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); |
788 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); | 821 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); |
789 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); | 822 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); |
790 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); | 823 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); |
791 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); | 824 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); |
792 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); | 825 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); |
793 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); | 826 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); |
794 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); | 827 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); |
795 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); | 828 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); |
796 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); | 829 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); |
797 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); | 830 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); |
798 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); | 831 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); |
799 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); | 832 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); |
800 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); | 833 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); |
801 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); | 834 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); |
802 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); | 835 | nWP.valid = true; |
803 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); | ||
804 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); | ||
805 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); | ||
806 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); | ||
807 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); | ||
808 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); | ||
809 | nWP.valid = true; | ||
810 | } | ||
811 | } | 836 | } |
812 | } | 837 | } |
813 | } | 838 | } |
@@ -857,124 +882,118 @@ namespace OpenSim.Data.MySQL | |||
857 | 882 | ||
858 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | 883 | public void StoreRegionWindlightSettings(RegionLightShareData wl) |
859 | { | 884 | { |
860 | lock (m_dbLock) | 885 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
861 | { | 886 | { |
862 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 887 | dbcon.Open(); |
888 | |||
889 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
863 | { | 890 | { |
864 | dbcon.Open(); | 891 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; |
865 | 892 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | |
866 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 893 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; |
867 | { | 894 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; |
868 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; | 895 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; |
869 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | 896 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; |
870 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; | 897 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; |
871 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; | 898 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; |
872 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; | 899 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; |
873 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; | 900 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; |
874 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; | 901 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; |
875 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; | 902 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; |
876 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; | 903 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; |
877 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; | 904 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; |
878 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; | 905 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; |
879 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; | 906 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; |
880 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; | 907 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; |
881 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; | 908 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; |
882 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; | 909 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; |
883 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; | 910 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; |
884 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; | 911 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; |
885 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; | 912 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; |
886 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; | 913 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; |
887 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; | 914 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; |
888 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; | 915 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; |
889 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; | 916 | |
890 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; | 917 | cmd.Parameters.AddWithValue("region_id", wl.regionID); |
891 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; | 918 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); |
892 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; | 919 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); |
893 | 920 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | |
894 | cmd.Parameters.AddWithValue("region_id", wl.regionID); | 921 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); |
895 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); | 922 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); |
896 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); | 923 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); |
897 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | 924 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); |
898 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); | 925 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); |
899 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); | 926 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); |
900 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); | 927 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); |
901 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); | 928 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); |
902 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); | 929 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); |
903 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); | 930 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); |
904 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); | 931 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); |
905 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); | 932 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); |
906 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); | 933 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); |
907 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); | 934 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); |
908 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); | 935 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); |
909 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); | 936 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); |
910 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); | 937 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); |
911 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); | 938 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); |
912 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); | 939 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); |
913 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); | 940 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); |
914 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); | 941 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); |
915 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); | 942 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); |
916 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); | 943 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); |
917 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); | 944 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); |
918 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); | 945 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); |
919 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); | 946 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); |
920 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); | 947 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); |
921 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); | 948 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); |
922 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); | 949 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); |
923 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); | 950 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); |
924 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); | 951 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); |
925 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); | 952 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); |
926 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); | 953 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); |
927 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); | 954 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); |
928 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); | 955 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); |
929 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); | 956 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); |
930 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); | 957 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); |
931 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); | 958 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); |
932 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); | 959 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); |
933 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); | 960 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); |
934 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); | 961 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); |
935 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); | 962 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); |
936 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); | 963 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); |
937 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); | 964 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); |
938 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); | 965 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); |
939 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); | 966 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); |
940 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); | 967 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); |
941 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); | 968 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); |
942 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); | 969 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); |
943 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); | 970 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); |
944 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); | 971 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); |
945 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); | 972 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); |
946 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); | 973 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); |
947 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); | 974 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); |
948 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); | 975 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); |
949 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); | 976 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); |
950 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); | 977 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); |
951 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); | 978 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); |
952 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); | 979 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); |
953 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); | 980 | |
954 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); | 981 | ExecuteNonQuery(cmd); |
955 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); | ||
956 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); | ||
957 | |||
958 | ExecuteNonQuery(cmd); | ||
959 | } | ||
960 | } | 982 | } |
961 | } | 983 | } |
962 | } | 984 | } |
963 | 985 | ||
964 | public void RemoveRegionWindlightSettings(UUID regionID) | 986 | public void RemoveRegionWindlightSettings(UUID regionID) |
965 | { | 987 | { |
966 | lock (m_dbLock) | 988 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
967 | { | 989 | { |
968 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 990 | dbcon.Open(); |
991 | |||
992 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
969 | { | 993 | { |
970 | dbcon.Open(); | 994 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; |
971 | 995 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | |
972 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 996 | ExecuteNonQuery(cmd); |
973 | { | ||
974 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; | ||
975 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | ||
976 | ExecuteNonQuery(cmd); | ||
977 | } | ||
978 | } | 997 | } |
979 | } | 998 | } |
980 | } | 999 | } |
@@ -982,29 +1001,26 @@ namespace OpenSim.Data.MySQL | |||
982 | #region RegionEnvironmentSettings | 1001 | #region RegionEnvironmentSettings |
983 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 1002 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
984 | { | 1003 | { |
985 | lock (m_dbLock) | 1004 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
986 | { | 1005 | { |
987 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1006 | dbcon.Open(); |
1007 | |||
1008 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | ||
1009 | |||
1010 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
988 | { | 1011 | { |
989 | dbcon.Open(); | 1012 | cmd.Connection = dbcon; |
990 | 1013 | ||
991 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | 1014 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); |
992 | 1015 | ||
993 | using (MySqlCommand cmd = new MySqlCommand(command)) | 1016 | IDataReader result = ExecuteReader(cmd); |
1017 | if (!result.Read()) | ||
994 | { | 1018 | { |
995 | cmd.Connection = dbcon; | 1019 | return String.Empty; |
996 | 1020 | } | |
997 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | 1021 | else |
998 | 1022 | { | |
999 | IDataReader result = ExecuteReader(cmd); | 1023 | return Convert.ToString(result["llsd_settings"]); |
1000 | if (!result.Read()) | ||
1001 | { | ||
1002 | return String.Empty; | ||
1003 | } | ||
1004 | else | ||
1005 | { | ||
1006 | return Convert.ToString(result["llsd_settings"]); | ||
1007 | } | ||
1008 | } | 1024 | } |
1009 | } | 1025 | } |
1010 | } | 1026 | } |
@@ -1012,39 +1028,33 @@ namespace OpenSim.Data.MySQL | |||
1012 | 1028 | ||
1013 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 1029 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
1014 | { | 1030 | { |
1015 | lock (m_dbLock) | 1031 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1016 | { | 1032 | { |
1017 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1033 | dbcon.Open(); |
1034 | |||
1035 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1018 | { | 1036 | { |
1019 | dbcon.Open(); | 1037 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; |
1020 | 1038 | ||
1021 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1039 | cmd.Parameters.AddWithValue("region_id", regionUUID); |
1022 | { | 1040 | cmd.Parameters.AddWithValue("llsd_settings", settings); |
1023 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; | 1041 | |
1024 | 1042 | ExecuteNonQuery(cmd); | |
1025 | cmd.Parameters.AddWithValue("region_id", regionUUID); | ||
1026 | cmd.Parameters.AddWithValue("llsd_settings", settings); | ||
1027 | |||
1028 | ExecuteNonQuery(cmd); | ||
1029 | } | ||
1030 | } | 1043 | } |
1031 | } | 1044 | } |
1032 | } | 1045 | } |
1033 | 1046 | ||
1034 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 1047 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
1035 | { | 1048 | { |
1036 | lock (m_dbLock) | 1049 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1037 | { | 1050 | { |
1038 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1051 | dbcon.Open(); |
1052 | |||
1053 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1039 | { | 1054 | { |
1040 | dbcon.Open(); | 1055 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; |
1041 | 1056 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | |
1042 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1057 | ExecuteNonQuery(cmd); |
1043 | { | ||
1044 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; | ||
1045 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | ||
1046 | ExecuteNonQuery(cmd); | ||
1047 | } | ||
1048 | } | 1058 | } |
1049 | } | 1059 | } |
1050 | } | 1060 | } |
@@ -1052,56 +1062,55 @@ namespace OpenSim.Data.MySQL | |||
1052 | 1062 | ||
1053 | public void StoreRegionSettings(RegionSettings rs) | 1063 | public void StoreRegionSettings(RegionSettings rs) |
1054 | { | 1064 | { |
1055 | lock (m_dbLock) | 1065 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1056 | { | 1066 | { |
1057 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1067 | dbcon.Open(); |
1058 | { | ||
1059 | dbcon.Open(); | ||
1060 | |||
1061 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1062 | { | ||
1063 | cmd.CommandText = "replace into regionsettings (regionUUID, " + | ||
1064 | "block_terraform, block_fly, allow_damage, " + | ||
1065 | "restrict_pushing, allow_land_resell, " + | ||
1066 | "allow_land_join_divide, block_show_in_search, " + | ||
1067 | "agent_limit, object_bonus, maturity, " + | ||
1068 | "disable_scripts, disable_collisions, " + | ||
1069 | "disable_physics, terrain_texture_1, " + | ||
1070 | "terrain_texture_2, terrain_texture_3, " + | ||
1071 | "terrain_texture_4, elevation_1_nw, " + | ||
1072 | "elevation_2_nw, elevation_1_ne, " + | ||
1073 | "elevation_2_ne, elevation_1_se, " + | ||
1074 | "elevation_2_se, elevation_1_sw, " + | ||
1075 | "elevation_2_sw, water_height, " + | ||
1076 | "terrain_raise_limit, terrain_lower_limit, " + | ||
1077 | "use_estate_sun, fixed_sun, sun_position, " + | ||
1078 | "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + | ||
1079 | "sunvectorz, loaded_creation_datetime, " + | ||
1080 | "loaded_creation_id, map_tile_ID, " + | ||
1081 | "TelehubObject, parcel_tile_ID) " + | ||
1082 | "values (?RegionUUID, ?BlockTerraform, " + | ||
1083 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | ||
1084 | "?AllowLandResell, ?AllowLandJoinDivide, " + | ||
1085 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | ||
1086 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + | ||
1087 | "?DisablePhysics, ?TerrainTexture1, " + | ||
1088 | "?TerrainTexture2, ?TerrainTexture3, " + | ||
1089 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + | ||
1090 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + | ||
1091 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + | ||
1092 | "?WaterHeight, ?TerrainRaiseLimit, " + | ||
1093 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | ||
1094 | "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + | ||
1095 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | ||
1096 | "?LoadedCreationDateTime, ?LoadedCreationID, " + | ||
1097 | "?TerrainImageID, ?TelehubObject, ?ParcelImageID) "; | ||
1098 | |||
1099 | FillRegionSettingsCommand(cmd, rs); | ||
1100 | 1068 | ||
1101 | ExecuteNonQuery(cmd); | 1069 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1102 | } | 1070 | { |
1071 | cmd.CommandText = "replace into regionsettings (regionUUID, " + | ||
1072 | "block_terraform, block_fly, allow_damage, " + | ||
1073 | "restrict_pushing, allow_land_resell, " + | ||
1074 | "allow_land_join_divide, block_show_in_search, " + | ||
1075 | "agent_limit, object_bonus, maturity, " + | ||
1076 | "disable_scripts, disable_collisions, " + | ||
1077 | "disable_physics, terrain_texture_1, " + | ||
1078 | "terrain_texture_2, terrain_texture_3, " + | ||
1079 | "terrain_texture_4, elevation_1_nw, " + | ||
1080 | "elevation_2_nw, elevation_1_ne, " + | ||
1081 | "elevation_2_ne, elevation_1_se, " + | ||
1082 | "elevation_2_se, elevation_1_sw, " + | ||
1083 | "elevation_2_sw, water_height, " + | ||
1084 | "terrain_raise_limit, terrain_lower_limit, " + | ||
1085 | "use_estate_sun, fixed_sun, sun_position, " + | ||
1086 | "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + | ||
1087 | "sunvectorz, loaded_creation_datetime, " + | ||
1088 | "loaded_creation_id, map_tile_ID, " + | ||
1089 | "TelehubObject, parcel_tile_ID) " + | ||
1090 | "values (?RegionUUID, ?BlockTerraform, " + | ||
1091 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | ||
1092 | "?AllowLandResell, ?AllowLandJoinDivide, " + | ||
1093 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | ||
1094 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + | ||
1095 | "?DisablePhysics, ?TerrainTexture1, " + | ||
1096 | "?TerrainTexture2, ?TerrainTexture3, " + | ||
1097 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + | ||
1098 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + | ||
1099 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + | ||
1100 | "?WaterHeight, ?TerrainRaiseLimit, " + | ||
1101 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | ||
1102 | "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + | ||
1103 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | ||
1104 | "?LoadedCreationDateTime, ?LoadedCreationID, " + | ||
1105 | "?TerrainImageID, " + | ||
1106 | "?TelehubObject, ?ParcelImageID)"; | ||
1107 | |||
1108 | FillRegionSettingsCommand(cmd, rs); | ||
1109 | |||
1110 | ExecuteNonQuery(cmd); | ||
1103 | } | 1111 | } |
1104 | } | 1112 | } |
1113 | |||
1105 | SaveSpawnPoints(rs); | 1114 | SaveSpawnPoints(rs); |
1106 | } | 1115 | } |
1107 | 1116 | ||
@@ -1292,6 +1301,39 @@ namespace OpenSim.Data.MySQL | |||
1292 | if (!(row["MediaURL"] is System.DBNull)) | 1301 | if (!(row["MediaURL"] is System.DBNull)) |
1293 | prim.MediaUrl = (string)row["MediaURL"]; | 1302 | prim.MediaUrl = (string)row["MediaURL"]; |
1294 | 1303 | ||
1304 | if (!(row["AttachedPosX"] is System.DBNull)) | ||
1305 | { | ||
1306 | prim.AttachedPos = new Vector3( | ||
1307 | (float)(double)row["AttachedPosX"], | ||
1308 | (float)(double)row["AttachedPosY"], | ||
1309 | (float)(double)row["AttachedPosZ"] | ||
1310 | ); | ||
1311 | } | ||
1312 | |||
1313 | if (!(row["DynAttrs"] is System.DBNull)) | ||
1314 | prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]); | ||
1315 | else | ||
1316 | prim.DynAttrs = new DAMap(); | ||
1317 | |||
1318 | if (!(row["KeyframeMotion"] is DBNull)) | ||
1319 | { | ||
1320 | Byte[] data = (byte[])row["KeyframeMotion"]; | ||
1321 | if (data.Length > 0) | ||
1322 | prim.KeyframeMotion = KeyframeMotion.FromData(null, data); | ||
1323 | else | ||
1324 | prim.KeyframeMotion = null; | ||
1325 | } | ||
1326 | else | ||
1327 | { | ||
1328 | prim.KeyframeMotion = null; | ||
1329 | } | ||
1330 | |||
1331 | prim.PhysicsShapeType = (byte)Convert.ToInt32(row["PhysicsShapeType"].ToString()); | ||
1332 | prim.Density = (float)(double)row["Density"]; | ||
1333 | prim.GravityModifier = (float)(double)row["GravityModifier"]; | ||
1334 | prim.Friction = (float)(double)row["Friction"]; | ||
1335 | prim.Restitution = (float)(double)row["Restitution"]; | ||
1336 | |||
1295 | return prim; | 1337 | return prim; |
1296 | } | 1338 | } |
1297 | 1339 | ||
@@ -1431,6 +1473,7 @@ namespace OpenSim.Data.MySQL | |||
1431 | UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); | 1473 | UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); |
1432 | UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); | 1474 | UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); |
1433 | newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); | 1475 | newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); |
1476 | newData.Dwell = Convert.ToSingle(row["Dwell"]); | ||
1434 | 1477 | ||
1435 | newData.AuthBuyerID = authedbuyer; | 1478 | newData.AuthBuyerID = authedbuyer; |
1436 | newData.SnapshotID = snapshotID; | 1479 | newData.SnapshotID = snapshotID; |
@@ -1478,30 +1521,6 @@ namespace OpenSim.Data.MySQL | |||
1478 | } | 1521 | } |
1479 | 1522 | ||
1480 | /// <summary> | 1523 | /// <summary> |
1481 | /// | ||
1482 | /// </summary> | ||
1483 | /// <param name="val"></param> | ||
1484 | /// <returns></returns> | ||
1485 | private static Array SerializeTerrain(double[,] val) | ||
1486 | { | ||
1487 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); | ||
1488 | BinaryWriter bw = new BinaryWriter(str); | ||
1489 | |||
1490 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
1491 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
1492 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
1493 | { | ||
1494 | double height = val[x, y]; | ||
1495 | if (height == 0.0) | ||
1496 | height = double.Epsilon; | ||
1497 | |||
1498 | bw.Write(height); | ||
1499 | } | ||
1500 | |||
1501 | return str.ToArray(); | ||
1502 | } | ||
1503 | |||
1504 | /// <summary> | ||
1505 | /// Fill the prim command with prim values | 1524 | /// Fill the prim command with prim values |
1506 | /// </summary> | 1525 | /// </summary> |
1507 | /// <param name="row"></param> | 1526 | /// <param name="row"></param> |
@@ -1637,6 +1656,28 @@ namespace OpenSim.Data.MySQL | |||
1637 | 1656 | ||
1638 | cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); | 1657 | cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); |
1639 | cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); | 1658 | cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); |
1659 | if (prim.AttachedPos != null) | ||
1660 | { | ||
1661 | cmd.Parameters.AddWithValue("AttachedPosX", (double)prim.AttachedPos.X); | ||
1662 | cmd.Parameters.AddWithValue("AttachedPosY", (double)prim.AttachedPos.Y); | ||
1663 | cmd.Parameters.AddWithValue("AttachedPosZ", (double)prim.AttachedPos.Z); | ||
1664 | } | ||
1665 | |||
1666 | if (prim.KeyframeMotion != null) | ||
1667 | cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize()); | ||
1668 | else | ||
1669 | cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); | ||
1670 | |||
1671 | if (prim.DynAttrs.CountNamespaces > 0) | ||
1672 | cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); | ||
1673 | else | ||
1674 | cmd.Parameters.AddWithValue("DynAttrs", null); | ||
1675 | |||
1676 | cmd.Parameters.AddWithValue("PhysicsShapeType", prim.PhysicsShapeType); | ||
1677 | cmd.Parameters.AddWithValue("Density", (double)prim.Density); | ||
1678 | cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); | ||
1679 | cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); | ||
1680 | cmd.Parameters.AddWithValue("Restitution", (double)prim.Restitution); | ||
1640 | } | 1681 | } |
1641 | 1682 | ||
1642 | /// <summary> | 1683 | /// <summary> |
@@ -1715,6 +1756,7 @@ namespace OpenSim.Data.MySQL | |||
1715 | cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); | 1756 | cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); |
1716 | cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); | 1757 | cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); |
1717 | cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); | 1758 | cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); |
1759 | |||
1718 | cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); | 1760 | cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); |
1719 | cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); | 1761 | cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); |
1720 | } | 1762 | } |
@@ -1763,6 +1805,7 @@ namespace OpenSim.Data.MySQL | |||
1763 | cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); | 1805 | cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); |
1764 | cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); | 1806 | cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); |
1765 | cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); | 1807 | cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); |
1808 | cmd.Parameters.AddWithValue("Dwell", land.Dwell); | ||
1766 | cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); | 1809 | cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); |
1767 | cmd.Parameters.AddWithValue("MediaType", land.MediaType); | 1810 | cmd.Parameters.AddWithValue("MediaType", land.MediaType); |
1768 | cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); | 1811 | cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); |
@@ -1770,7 +1813,6 @@ namespace OpenSim.Data.MySQL | |||
1770 | cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); | 1813 | cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop); |
1771 | cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); | 1814 | cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic); |
1772 | cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); | 1815 | cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia); |
1773 | |||
1774 | } | 1816 | } |
1775 | 1817 | ||
1776 | /// <summary> | 1818 | /// <summary> |
@@ -1826,6 +1868,7 @@ namespace OpenSim.Data.MySQL | |||
1826 | s.ExtraParams = (byte[])row["ExtraParams"]; | 1868 | s.ExtraParams = (byte[])row["ExtraParams"]; |
1827 | 1869 | ||
1828 | s.State = (byte)(int)row["State"]; | 1870 | s.State = (byte)(int)row["State"]; |
1871 | s.LastAttachPoint = (byte)(int)row["LastAttachPoint"]; | ||
1829 | 1872 | ||
1830 | if (!(row["Media"] is System.DBNull)) | 1873 | if (!(row["Media"] is System.DBNull)) |
1831 | s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); | 1874 | s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]); |
@@ -1872,6 +1915,7 @@ namespace OpenSim.Data.MySQL | |||
1872 | cmd.Parameters.AddWithValue("Texture", s.TextureEntry); | 1915 | cmd.Parameters.AddWithValue("Texture", s.TextureEntry); |
1873 | cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); | 1916 | cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams); |
1874 | cmd.Parameters.AddWithValue("State", s.State); | 1917 | cmd.Parameters.AddWithValue("State", s.State); |
1918 | cmd.Parameters.AddWithValue("LastAttachPoint", s.LastAttachPoint); | ||
1875 | cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); | 1919 | cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); |
1876 | } | 1920 | } |
1877 | 1921 | ||
@@ -1988,41 +2032,35 @@ namespace OpenSim.Data.MySQL | |||
1988 | 2032 | ||
1989 | public void SaveExtra(UUID regionID, string name, string val) | 2033 | public void SaveExtra(UUID regionID, string name, string val) |
1990 | { | 2034 | { |
1991 | lock (m_dbLock) | 2035 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1992 | { | 2036 | { |
1993 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2037 | dbcon.Open(); |
1994 | { | ||
1995 | dbcon.Open(); | ||
1996 | 2038 | ||
1997 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2039 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1998 | { | 2040 | { |
1999 | cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; | 2041 | cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; |
2000 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 2042 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
2001 | cmd.Parameters.AddWithValue("?Name", name); | 2043 | cmd.Parameters.AddWithValue("?Name", name); |
2002 | cmd.Parameters.AddWithValue("?value", val); | 2044 | cmd.Parameters.AddWithValue("?value", val); |
2003 | 2045 | ||
2004 | cmd.ExecuteNonQuery(); | 2046 | cmd.ExecuteNonQuery(); |
2005 | } | ||
2006 | } | 2047 | } |
2007 | } | 2048 | } |
2008 | } | 2049 | } |
2009 | 2050 | ||
2010 | public void RemoveExtra(UUID regionID, string name) | 2051 | public void RemoveExtra(UUID regionID, string name) |
2011 | { | 2052 | { |
2012 | lock (m_dbLock) | 2053 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2013 | { | 2054 | { |
2014 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2055 | dbcon.Open(); |
2015 | { | ||
2016 | dbcon.Open(); | ||
2017 | 2056 | ||
2018 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2057 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2019 | { | 2058 | { |
2020 | cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; | 2059 | cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; |
2021 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 2060 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
2022 | cmd.Parameters.AddWithValue("?Name", name); | 2061 | cmd.Parameters.AddWithValue("?Name", name); |
2023 | 2062 | ||
2024 | cmd.ExecuteNonQuery(); | 2063 | cmd.ExecuteNonQuery(); |
2025 | } | ||
2026 | } | 2064 | } |
2027 | } | 2065 | } |
2028 | } | 2066 | } |
@@ -2031,22 +2069,19 @@ namespace OpenSim.Data.MySQL | |||
2031 | { | 2069 | { |
2032 | Dictionary<string, string> ret = new Dictionary<string, string>(); | 2070 | Dictionary<string, string> ret = new Dictionary<string, string>(); |
2033 | 2071 | ||
2034 | lock (m_dbLock) | 2072 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2035 | { | 2073 | { |
2036 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2074 | dbcon.Open(); |
2037 | { | ||
2038 | dbcon.Open(); | ||
2039 | 2075 | ||
2040 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2076 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2077 | { | ||
2078 | cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; | ||
2079 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
2080 | using (IDataReader r = cmd.ExecuteReader()) | ||
2041 | { | 2081 | { |
2042 | cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; | 2082 | while (r.Read()) |
2043 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
2044 | using (IDataReader r = cmd.ExecuteReader()) | ||
2045 | { | 2083 | { |
2046 | while (r.Read()) | 2084 | ret[r["Name"].ToString()] = r["value"].ToString(); |
2047 | { | ||
2048 | ret[r["Name"].ToString()] = r["value"].ToString(); | ||
2049 | } | ||
2050 | } | 2085 | } |
2051 | } | 2086 | } |
2052 | } | 2087 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs new file mode 100644 index 0000000..b35595d --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -0,0 +1,1086 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Data; | ||
30 | using System.Reflection; | ||
31 | using OpenSim.Data; | ||
32 | using OpenSim.Framework; | ||
33 | using MySql.Data.MySqlClient; | ||
34 | using OpenMetaverse; | ||
35 | using OpenMetaverse.StructuredData; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | public class UserProfilesData: IProfilesData | ||
41 | { | ||
42 | static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | #region Properites | ||
45 | string ConnectionString | ||
46 | { | ||
47 | get; set; | ||
48 | } | ||
49 | |||
50 | protected virtual Assembly Assembly | ||
51 | { | ||
52 | get { return GetType().Assembly; } | ||
53 | } | ||
54 | |||
55 | #endregion Properties | ||
56 | |||
57 | #region class Member Functions | ||
58 | public UserProfilesData(string connectionString) | ||
59 | { | ||
60 | ConnectionString = connectionString; | ||
61 | Init(); | ||
62 | } | ||
63 | |||
64 | void Init() | ||
65 | { | ||
66 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
67 | { | ||
68 | dbcon.Open(); | ||
69 | |||
70 | Migration m = new Migration(dbcon, Assembly, "UserProfiles"); | ||
71 | m.Update(); | ||
72 | } | ||
73 | } | ||
74 | #endregion Member Functions | ||
75 | |||
76 | #region Classifieds Queries | ||
77 | /// <summary> | ||
78 | /// Gets the classified records. | ||
79 | /// </summary> | ||
80 | /// <returns> | ||
81 | /// Array of classified records | ||
82 | /// </returns> | ||
83 | /// <param name='creatorId'> | ||
84 | /// Creator identifier. | ||
85 | /// </param> | ||
86 | public OSDArray GetClassifiedRecords(UUID creatorId) | ||
87 | { | ||
88 | OSDArray data = new OSDArray(); | ||
89 | |||
90 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
91 | { | ||
92 | string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; | ||
93 | dbcon.Open(); | ||
94 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
95 | { | ||
96 | cmd.Parameters.AddWithValue("?Id", creatorId); | ||
97 | using( MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default)) | ||
98 | { | ||
99 | if(reader.HasRows) | ||
100 | { | ||
101 | while (reader.Read()) | ||
102 | { | ||
103 | OSDMap n = new OSDMap(); | ||
104 | UUID Id = UUID.Zero; | ||
105 | |||
106 | string Name = null; | ||
107 | try | ||
108 | { | ||
109 | UUID.TryParse(Convert.ToString( reader["classifieduuid"]), out Id); | ||
110 | Name = Convert.ToString(reader["name"]); | ||
111 | } | ||
112 | catch (Exception e) | ||
113 | { | ||
114 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
115 | ": UserAccount exception {0}", e.Message); | ||
116 | } | ||
117 | n.Add("classifieduuid", OSD.FromUUID(Id)); | ||
118 | n.Add("name", OSD.FromString(Name)); | ||
119 | data.Add(n); | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | return data; | ||
126 | } | ||
127 | |||
128 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) | ||
129 | { | ||
130 | string query = string.Empty; | ||
131 | |||
132 | |||
133 | query += "INSERT INTO classifieds ("; | ||
134 | query += "`classifieduuid`,"; | ||
135 | query += "`creatoruuid`,"; | ||
136 | query += "`creationdate`,"; | ||
137 | query += "`expirationdate`,"; | ||
138 | query += "`category`,"; | ||
139 | query += "`name`,"; | ||
140 | query += "`description`,"; | ||
141 | query += "`parceluuid`,"; | ||
142 | query += "`parentestate`,"; | ||
143 | query += "`snapshotuuid`,"; | ||
144 | query += "`simname`,"; | ||
145 | query += "`posglobal`,"; | ||
146 | query += "`parcelname`,"; | ||
147 | query += "`classifiedflags`,"; | ||
148 | query += "`priceforlisting`) "; | ||
149 | query += "VALUES ("; | ||
150 | query += "?ClassifiedId,"; | ||
151 | query += "?CreatorId,"; | ||
152 | query += "?CreatedDate,"; | ||
153 | query += "?ExpirationDate,"; | ||
154 | query += "?Category,"; | ||
155 | query += "?Name,"; | ||
156 | query += "?Description,"; | ||
157 | query += "?ParcelId,"; | ||
158 | query += "?ParentEstate,"; | ||
159 | query += "?SnapshotId,"; | ||
160 | query += "?SimName,"; | ||
161 | query += "?GlobalPos,"; | ||
162 | query += "?ParcelName,"; | ||
163 | query += "?Flags,"; | ||
164 | query += "?ListingPrice ) "; | ||
165 | query += "ON DUPLICATE KEY UPDATE "; | ||
166 | query += "category=?Category, "; | ||
167 | query += "expirationdate=?ExpirationDate, "; | ||
168 | query += "name=?Name, "; | ||
169 | query += "description=?Description, "; | ||
170 | query += "parentestate=?ParentEstate, "; | ||
171 | query += "posglobal=?GlobalPos, "; | ||
172 | query += "parcelname=?ParcelName, "; | ||
173 | query += "classifiedflags=?Flags, "; | ||
174 | query += "priceforlisting=?ListingPrice, "; | ||
175 | query += "snapshotuuid=?SnapshotId"; | ||
176 | |||
177 | if(string.IsNullOrEmpty(ad.ParcelName)) | ||
178 | ad.ParcelName = "Unknown"; | ||
179 | if(ad.ParcelId == null) | ||
180 | ad.ParcelId = UUID.Zero; | ||
181 | if(string.IsNullOrEmpty(ad.Description)) | ||
182 | ad.Description = "No Description"; | ||
183 | |||
184 | DateTime epoch = new DateTime(1970, 1, 1); | ||
185 | DateTime now = DateTime.Now; | ||
186 | TimeSpan epochnow = now - epoch; | ||
187 | TimeSpan duration; | ||
188 | DateTime expiration; | ||
189 | TimeSpan epochexp; | ||
190 | |||
191 | if(ad.Flags == 2) | ||
192 | { | ||
193 | duration = new TimeSpan(7,0,0,0); | ||
194 | expiration = now.Add(duration); | ||
195 | epochexp = expiration - epoch; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | duration = new TimeSpan(365,0,0,0); | ||
200 | expiration = now.Add(duration); | ||
201 | epochexp = expiration - epoch; | ||
202 | } | ||
203 | ad.CreationDate = (int)epochnow.TotalSeconds; | ||
204 | ad.ExpirationDate = (int)epochexp.TotalSeconds; | ||
205 | |||
206 | try | ||
207 | { | ||
208 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
209 | { | ||
210 | dbcon.Open(); | ||
211 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
212 | { | ||
213 | cmd.Parameters.AddWithValue("?ClassifiedId", ad.ClassifiedId.ToString()); | ||
214 | cmd.Parameters.AddWithValue("?CreatorId", ad.CreatorId.ToString()); | ||
215 | cmd.Parameters.AddWithValue("?CreatedDate", ad.CreationDate.ToString()); | ||
216 | cmd.Parameters.AddWithValue("?ExpirationDate", ad.ExpirationDate.ToString()); | ||
217 | cmd.Parameters.AddWithValue("?Category", ad.Category.ToString()); | ||
218 | cmd.Parameters.AddWithValue("?Name", ad.Name.ToString()); | ||
219 | cmd.Parameters.AddWithValue("?Description", ad.Description.ToString()); | ||
220 | cmd.Parameters.AddWithValue("?ParcelId", ad.ParcelId.ToString()); | ||
221 | cmd.Parameters.AddWithValue("?ParentEstate", ad.ParentEstate.ToString()); | ||
222 | cmd.Parameters.AddWithValue("?SnapshotId", ad.SnapshotId.ToString ()); | ||
223 | cmd.Parameters.AddWithValue("?SimName", ad.SimName.ToString()); | ||
224 | cmd.Parameters.AddWithValue("?GlobalPos", ad.GlobalPos.ToString()); | ||
225 | cmd.Parameters.AddWithValue("?ParcelName", ad.ParcelName.ToString()); | ||
226 | cmd.Parameters.AddWithValue("?Flags", ad.Flags.ToString()); | ||
227 | cmd.Parameters.AddWithValue("?ListingPrice", ad.Price.ToString ()); | ||
228 | |||
229 | cmd.ExecuteNonQuery(); | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | catch (Exception e) | ||
234 | { | ||
235 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
236 | ": ClassifiedesUpdate exception {0}", e.Message); | ||
237 | result = e.Message; | ||
238 | return false; | ||
239 | } | ||
240 | return true; | ||
241 | } | ||
242 | |||
243 | public bool DeleteClassifiedRecord(UUID recordId) | ||
244 | { | ||
245 | string query = string.Empty; | ||
246 | |||
247 | query += "DELETE FROM classifieds WHERE "; | ||
248 | query += "classifieduuid = ?recordId"; | ||
249 | |||
250 | try | ||
251 | { | ||
252 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
253 | { | ||
254 | dbcon.Open(); | ||
255 | |||
256 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
257 | { | ||
258 | cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); | ||
259 | cmd.ExecuteNonQuery(); | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | catch (Exception e) | ||
264 | { | ||
265 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
266 | ": DeleteClassifiedRecord exception {0}", e.Message); | ||
267 | return false; | ||
268 | } | ||
269 | return true; | ||
270 | } | ||
271 | |||
272 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) | ||
273 | { | ||
274 | string query = string.Empty; | ||
275 | |||
276 | query += "SELECT * FROM classifieds WHERE "; | ||
277 | query += "classifieduuid = ?AdId"; | ||
278 | |||
279 | try | ||
280 | { | ||
281 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
282 | { | ||
283 | dbcon.Open(); | ||
284 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
285 | { | ||
286 | cmd.Parameters.AddWithValue("?AdId", ad.ClassifiedId.ToString()); | ||
287 | |||
288 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
289 | { | ||
290 | if(reader.Read ()) | ||
291 | { | ||
292 | ad.CreatorId = new UUID(reader.GetGuid("creatoruuid")); | ||
293 | ad.ParcelId = new UUID(reader.GetGuid("parceluuid")); | ||
294 | ad.SnapshotId = new UUID(reader.GetGuid("snapshotuuid")); | ||
295 | ad.CreationDate = Convert.ToInt32(reader["creationdate"]); | ||
296 | ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]); | ||
297 | ad.ParentEstate = Convert.ToInt32(reader["parentestate"]); | ||
298 | ad.Flags = (byte)reader.GetUInt32("classifiedflags"); | ||
299 | ad.Category = reader.GetInt32("category"); | ||
300 | ad.Price = reader.GetInt16("priceforlisting"); | ||
301 | ad.Name = reader.GetString("name"); | ||
302 | ad.Description = reader.GetString("description"); | ||
303 | ad.SimName = reader.GetString("simname"); | ||
304 | ad.GlobalPos = reader.GetString("posglobal"); | ||
305 | ad.ParcelName = reader.GetString("parcelname"); | ||
306 | |||
307 | } | ||
308 | } | ||
309 | } | ||
310 | dbcon.Close(); | ||
311 | } | ||
312 | } | ||
313 | catch (Exception e) | ||
314 | { | ||
315 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
316 | ": GetPickInfo exception {0}", e.Message); | ||
317 | } | ||
318 | return true; | ||
319 | } | ||
320 | #endregion Classifieds Queries | ||
321 | |||
322 | #region Picks Queries | ||
323 | public OSDArray GetAvatarPicks(UUID avatarId) | ||
324 | { | ||
325 | string query = string.Empty; | ||
326 | |||
327 | query += "SELECT `pickuuid`,`name` FROM userpicks WHERE "; | ||
328 | query += "creatoruuid = ?Id"; | ||
329 | OSDArray data = new OSDArray(); | ||
330 | |||
331 | try | ||
332 | { | ||
333 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
334 | { | ||
335 | dbcon.Open(); | ||
336 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
337 | { | ||
338 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
339 | |||
340 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
341 | { | ||
342 | if(reader.HasRows) | ||
343 | { | ||
344 | while (reader.Read()) | ||
345 | { | ||
346 | OSDMap record = new OSDMap(); | ||
347 | |||
348 | record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"])); | ||
349 | record.Add("name",OSD.FromString((string)reader["name"])); | ||
350 | data.Add(record); | ||
351 | } | ||
352 | } | ||
353 | } | ||
354 | } | ||
355 | } | ||
356 | } | ||
357 | catch (Exception e) | ||
358 | { | ||
359 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
360 | ": GetAvatarPicks exception {0}", e.Message); | ||
361 | } | ||
362 | return data; | ||
363 | } | ||
364 | |||
365 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) | ||
366 | { | ||
367 | string query = string.Empty; | ||
368 | UserProfilePick pick = new UserProfilePick(); | ||
369 | |||
370 | query += "SELECT * FROM userpicks WHERE "; | ||
371 | query += "creatoruuid = ?CreatorId AND "; | ||
372 | query += "pickuuid = ?PickId"; | ||
373 | |||
374 | try | ||
375 | { | ||
376 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
377 | { | ||
378 | dbcon.Open(); | ||
379 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
380 | { | ||
381 | cmd.Parameters.AddWithValue("?CreatorId", avatarId.ToString()); | ||
382 | cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); | ||
383 | |||
384 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
385 | { | ||
386 | if(reader.HasRows) | ||
387 | { | ||
388 | reader.Read(); | ||
389 | |||
390 | string description = (string)reader["description"]; | ||
391 | |||
392 | if (string.IsNullOrEmpty(description)) | ||
393 | description = "No description given."; | ||
394 | |||
395 | UUID.TryParse((string)reader["pickuuid"], out pick.PickId); | ||
396 | UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId); | ||
397 | UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); | ||
398 | UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId); | ||
399 | pick.GlobalPos = (string)reader["posglobal"]; | ||
400 | pick.Gatekeeper = (string)reader["gatekeeper"]; | ||
401 | bool.TryParse((string)reader["toppick"], out pick.TopPick); | ||
402 | bool.TryParse((string)reader["enabled"], out pick.Enabled); | ||
403 | pick.Name = (string)reader["name"]; | ||
404 | pick.Desc = description; | ||
405 | pick.ParcelName = (string)reader["user"]; | ||
406 | pick.OriginalName = (string)reader["originalname"]; | ||
407 | pick.SimName = (string)reader["simname"]; | ||
408 | pick.SortOrder = (int)reader["sortorder"]; | ||
409 | } | ||
410 | } | ||
411 | } | ||
412 | dbcon.Close(); | ||
413 | } | ||
414 | } | ||
415 | catch (Exception e) | ||
416 | { | ||
417 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
418 | ": GetPickInfo exception {0}", e.Message); | ||
419 | } | ||
420 | return pick; | ||
421 | } | ||
422 | |||
423 | public bool UpdatePicksRecord(UserProfilePick pick) | ||
424 | { | ||
425 | string query = string.Empty; | ||
426 | |||
427 | query += "INSERT INTO userpicks VALUES ("; | ||
428 | query += "?PickId,"; | ||
429 | query += "?CreatorId,"; | ||
430 | query += "?TopPick,"; | ||
431 | query += "?ParcelId,"; | ||
432 | query += "?Name,"; | ||
433 | query += "?Desc,"; | ||
434 | query += "?SnapshotId,"; | ||
435 | query += "?User,"; | ||
436 | query += "?Original,"; | ||
437 | query += "?SimName,"; | ||
438 | query += "?GlobalPos,"; | ||
439 | query += "?SortOrder,"; | ||
440 | query += "?Enabled,"; | ||
441 | query += "?Gatekeeper)"; | ||
442 | query += "ON DUPLICATE KEY UPDATE "; | ||
443 | query += "parceluuid=?ParcelId,"; | ||
444 | query += "name=?Name,"; | ||
445 | query += "description=?Desc,"; | ||
446 | query += "user=?User,"; | ||
447 | query += "simname=?SimName,"; | ||
448 | query += "snapshotuuid=?SnapshotId,"; | ||
449 | query += "pickuuid=?PickId,"; | ||
450 | query += "posglobal=?GlobalPos,"; | ||
451 | query += "gatekeeper=?Gatekeeper"; | ||
452 | |||
453 | try | ||
454 | { | ||
455 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
456 | { | ||
457 | dbcon.Open(); | ||
458 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
459 | { | ||
460 | cmd.Parameters.AddWithValue("?PickId", pick.PickId.ToString()); | ||
461 | cmd.Parameters.AddWithValue("?CreatorId", pick.CreatorId.ToString()); | ||
462 | cmd.Parameters.AddWithValue("?TopPick", pick.TopPick.ToString()); | ||
463 | cmd.Parameters.AddWithValue("?ParcelId", pick.ParcelId.ToString()); | ||
464 | cmd.Parameters.AddWithValue("?Name", pick.Name.ToString()); | ||
465 | cmd.Parameters.AddWithValue("?Desc", pick.Desc.ToString()); | ||
466 | cmd.Parameters.AddWithValue("?SnapshotId", pick.SnapshotId.ToString()); | ||
467 | cmd.Parameters.AddWithValue("?User", pick.ParcelName.ToString()); | ||
468 | cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString()); | ||
469 | cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString()); | ||
470 | cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos); | ||
471 | cmd.Parameters.AddWithValue("?Gatekeeper",pick.Gatekeeper); | ||
472 | cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ()); | ||
473 | cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString()); | ||
474 | |||
475 | cmd.ExecuteNonQuery(); | ||
476 | } | ||
477 | } | ||
478 | } | ||
479 | catch (Exception e) | ||
480 | { | ||
481 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
482 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
483 | return false; | ||
484 | } | ||
485 | return true; | ||
486 | } | ||
487 | |||
488 | public bool DeletePicksRecord(UUID pickId) | ||
489 | { | ||
490 | string query = string.Empty; | ||
491 | |||
492 | query += "DELETE FROM userpicks WHERE "; | ||
493 | query += "pickuuid = ?PickId"; | ||
494 | |||
495 | try | ||
496 | { | ||
497 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
498 | { | ||
499 | dbcon.Open(); | ||
500 | |||
501 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
502 | { | ||
503 | cmd.Parameters.AddWithValue("?PickId", pickId.ToString()); | ||
504 | |||
505 | cmd.ExecuteNonQuery(); | ||
506 | } | ||
507 | } | ||
508 | } | ||
509 | catch (Exception e) | ||
510 | { | ||
511 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
512 | ": DeleteUserPickRecord exception {0}", e.Message); | ||
513 | return false; | ||
514 | } | ||
515 | return true; | ||
516 | } | ||
517 | #endregion Picks Queries | ||
518 | |||
519 | #region Avatar Notes Queries | ||
520 | public bool GetAvatarNotes(ref UserProfileNotes notes) | ||
521 | { // WIP | ||
522 | string query = string.Empty; | ||
523 | |||
524 | query += "SELECT `notes` FROM usernotes WHERE "; | ||
525 | query += "useruuid = ?Id AND "; | ||
526 | query += "targetuuid = ?TargetId"; | ||
527 | OSDArray data = new OSDArray(); | ||
528 | |||
529 | try | ||
530 | { | ||
531 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
532 | { | ||
533 | dbcon.Open(); | ||
534 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
535 | { | ||
536 | cmd.Parameters.AddWithValue("?Id", notes.UserId.ToString()); | ||
537 | cmd.Parameters.AddWithValue("?TargetId", notes.TargetId.ToString()); | ||
538 | |||
539 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
540 | { | ||
541 | if(reader.HasRows) | ||
542 | { | ||
543 | reader.Read(); | ||
544 | notes.Notes = OSD.FromString((string)reader["notes"]); | ||
545 | } | ||
546 | else | ||
547 | { | ||
548 | notes.Notes = OSD.FromString(""); | ||
549 | } | ||
550 | } | ||
551 | } | ||
552 | } | ||
553 | } | ||
554 | catch (Exception e) | ||
555 | { | ||
556 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
557 | ": GetAvatarNotes exception {0}", e.Message); | ||
558 | } | ||
559 | return true; | ||
560 | } | ||
561 | |||
562 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) | ||
563 | { | ||
564 | string query = string.Empty; | ||
565 | bool remove; | ||
566 | |||
567 | if(string.IsNullOrEmpty(note.Notes)) | ||
568 | { | ||
569 | remove = true; | ||
570 | query += "DELETE FROM usernotes WHERE "; | ||
571 | query += "useruuid=?UserId AND "; | ||
572 | query += "targetuuid=?TargetId"; | ||
573 | } | ||
574 | else | ||
575 | { | ||
576 | remove = false; | ||
577 | query += "INSERT INTO usernotes VALUES ( "; | ||
578 | query += "?UserId,"; | ||
579 | query += "?TargetId,"; | ||
580 | query += "?Notes )"; | ||
581 | query += "ON DUPLICATE KEY "; | ||
582 | query += "UPDATE "; | ||
583 | query += "notes=?Notes"; | ||
584 | } | ||
585 | |||
586 | try | ||
587 | { | ||
588 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
589 | { | ||
590 | dbcon.Open(); | ||
591 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
592 | { | ||
593 | if(!remove) | ||
594 | cmd.Parameters.AddWithValue("?Notes", note.Notes); | ||
595 | cmd.Parameters.AddWithValue("?TargetId", note.TargetId.ToString ()); | ||
596 | cmd.Parameters.AddWithValue("?UserId", note.UserId.ToString()); | ||
597 | |||
598 | cmd.ExecuteNonQuery(); | ||
599 | } | ||
600 | } | ||
601 | } | ||
602 | catch (Exception e) | ||
603 | { | ||
604 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
605 | ": UpdateAvatarNotes exception {0}", e.Message); | ||
606 | return false; | ||
607 | } | ||
608 | return true; | ||
609 | |||
610 | } | ||
611 | #endregion Avatar Notes Queries | ||
612 | |||
613 | #region Avatar Properties | ||
614 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) | ||
615 | { | ||
616 | string query = string.Empty; | ||
617 | |||
618 | query += "SELECT * FROM userprofile WHERE "; | ||
619 | query += "useruuid = ?Id"; | ||
620 | |||
621 | try | ||
622 | { | ||
623 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
624 | { | ||
625 | dbcon.Open(); | ||
626 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
627 | { | ||
628 | cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); | ||
629 | |||
630 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
631 | { | ||
632 | if(reader.HasRows) | ||
633 | { | ||
634 | reader.Read(); | ||
635 | props.WebUrl = (string)reader["profileURL"]; | ||
636 | UUID.TryParse((string)reader["profileImage"], out props.ImageId); | ||
637 | props.AboutText = (string)reader["profileAboutText"]; | ||
638 | UUID.TryParse((string)reader["profileFirstImage"], out props.FirstLifeImageId); | ||
639 | props.FirstLifeText = (string)reader["profileFirstText"]; | ||
640 | UUID.TryParse((string)reader["profilePartner"], out props.PartnerId); | ||
641 | props.WantToMask = (int)reader["profileWantToMask"]; | ||
642 | props.WantToText = (string)reader["profileWantToText"]; | ||
643 | props.SkillsMask = (int)reader["profileSkillsMask"]; | ||
644 | props.SkillsText = (string)reader["profileSkillsText"]; | ||
645 | props.Language = (string)reader["profileLanguages"]; | ||
646 | } | ||
647 | else | ||
648 | { | ||
649 | props.WebUrl = string.Empty; | ||
650 | props.ImageId = UUID.Zero; | ||
651 | props.AboutText = string.Empty; | ||
652 | props.FirstLifeImageId = UUID.Zero; | ||
653 | props.FirstLifeText = string.Empty; | ||
654 | props.PartnerId = UUID.Zero; | ||
655 | props.WantToMask = 0; | ||
656 | props.WantToText = string.Empty; | ||
657 | props.SkillsMask = 0; | ||
658 | props.SkillsText = string.Empty; | ||
659 | props.Language = string.Empty; | ||
660 | props.PublishProfile = false; | ||
661 | props.PublishMature = false; | ||
662 | |||
663 | query = "INSERT INTO userprofile ("; | ||
664 | query += "useruuid, "; | ||
665 | query += "profilePartner, "; | ||
666 | query += "profileAllowPublish, "; | ||
667 | query += "profileMaturePublish, "; | ||
668 | query += "profileURL, "; | ||
669 | query += "profileWantToMask, "; | ||
670 | query += "profileWantToText, "; | ||
671 | query += "profileSkillsMask, "; | ||
672 | query += "profileSkillsText, "; | ||
673 | query += "profileLanguages, "; | ||
674 | query += "profileImage, "; | ||
675 | query += "profileAboutText, "; | ||
676 | query += "profileFirstImage, "; | ||
677 | query += "profileFirstText) VALUES ("; | ||
678 | query += "?userId, "; | ||
679 | query += "?profilePartner, "; | ||
680 | query += "?profileAllowPublish, "; | ||
681 | query += "?profileMaturePublish, "; | ||
682 | query += "?profileURL, "; | ||
683 | query += "?profileWantToMask, "; | ||
684 | query += "?profileWantToText, "; | ||
685 | query += "?profileSkillsMask, "; | ||
686 | query += "?profileSkillsText, "; | ||
687 | query += "?profileLanguages, "; | ||
688 | query += "?profileImage, "; | ||
689 | query += "?profileAboutText, "; | ||
690 | query += "?profileFirstImage, "; | ||
691 | query += "?profileFirstText)"; | ||
692 | |||
693 | dbcon.Close(); | ||
694 | dbcon.Open(); | ||
695 | |||
696 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
697 | { | ||
698 | put.Parameters.AddWithValue("?userId", props.UserId.ToString()); | ||
699 | put.Parameters.AddWithValue("?profilePartner", props.PartnerId.ToString()); | ||
700 | put.Parameters.AddWithValue("?profileAllowPublish", props.PublishProfile); | ||
701 | put.Parameters.AddWithValue("?profileMaturePublish", props.PublishMature); | ||
702 | put.Parameters.AddWithValue("?profileURL", props.WebUrl); | ||
703 | put.Parameters.AddWithValue("?profileWantToMask", props.WantToMask); | ||
704 | put.Parameters.AddWithValue("?profileWantToText", props.WantToText); | ||
705 | put.Parameters.AddWithValue("?profileSkillsMask", props.SkillsMask); | ||
706 | put.Parameters.AddWithValue("?profileSkillsText", props.SkillsText); | ||
707 | put.Parameters.AddWithValue("?profileLanguages", props.Language); | ||
708 | put.Parameters.AddWithValue("?profileImage", props.ImageId.ToString()); | ||
709 | put.Parameters.AddWithValue("?profileAboutText", props.AboutText); | ||
710 | put.Parameters.AddWithValue("?profileFirstImage", props.FirstLifeImageId.ToString()); | ||
711 | put.Parameters.AddWithValue("?profileFirstText", props.FirstLifeText); | ||
712 | |||
713 | put.ExecuteNonQuery(); | ||
714 | } | ||
715 | } | ||
716 | } | ||
717 | } | ||
718 | } | ||
719 | } | ||
720 | catch (Exception e) | ||
721 | { | ||
722 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
723 | ": Requst properties exception {0}", e.Message); | ||
724 | result = e.Message; | ||
725 | return false; | ||
726 | } | ||
727 | return true; | ||
728 | } | ||
729 | |||
730 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) | ||
731 | { | ||
732 | string query = string.Empty; | ||
733 | |||
734 | query += "UPDATE userprofile SET "; | ||
735 | query += "profileURL=?profileURL, "; | ||
736 | query += "profileImage=?image, "; | ||
737 | query += "profileAboutText=?abouttext,"; | ||
738 | query += "profileFirstImage=?firstlifeimage,"; | ||
739 | query += "profileFirstText=?firstlifetext "; | ||
740 | query += "WHERE useruuid=?uuid"; | ||
741 | |||
742 | try | ||
743 | { | ||
744 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
745 | { | ||
746 | dbcon.Open(); | ||
747 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
748 | { | ||
749 | cmd.Parameters.AddWithValue("?profileURL", props.WebUrl); | ||
750 | cmd.Parameters.AddWithValue("?image", props.ImageId.ToString()); | ||
751 | cmd.Parameters.AddWithValue("?abouttext", props.AboutText); | ||
752 | cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString()); | ||
753 | cmd.Parameters.AddWithValue("?firstlifetext", props.FirstLifeText); | ||
754 | cmd.Parameters.AddWithValue("?uuid", props.UserId.ToString()); | ||
755 | |||
756 | cmd.ExecuteNonQuery(); | ||
757 | } | ||
758 | } | ||
759 | } | ||
760 | catch (Exception e) | ||
761 | { | ||
762 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
763 | ": AgentPropertiesUpdate exception {0}", e.Message); | ||
764 | |||
765 | return false; | ||
766 | } | ||
767 | return true; | ||
768 | } | ||
769 | #endregion Avatar Properties | ||
770 | |||
771 | #region Avatar Interests | ||
772 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) | ||
773 | { | ||
774 | string query = string.Empty; | ||
775 | |||
776 | query += "UPDATE userprofile SET "; | ||
777 | query += "profileWantToMask=?WantMask, "; | ||
778 | query += "profileWantToText=?WantText,"; | ||
779 | query += "profileSkillsMask=?SkillsMask,"; | ||
780 | query += "profileSkillsText=?SkillsText, "; | ||
781 | query += "profileLanguages=?Languages "; | ||
782 | query += "WHERE useruuid=?uuid"; | ||
783 | |||
784 | try | ||
785 | { | ||
786 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
787 | { | ||
788 | dbcon.Open(); | ||
789 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
790 | { | ||
791 | cmd.Parameters.AddWithValue("?WantMask", up.WantToMask); | ||
792 | cmd.Parameters.AddWithValue("?WantText", up.WantToText); | ||
793 | cmd.Parameters.AddWithValue("?SkillsMask", up.SkillsMask); | ||
794 | cmd.Parameters.AddWithValue("?SkillsText", up.SkillsText); | ||
795 | cmd.Parameters.AddWithValue("?Languages", up.Language); | ||
796 | cmd.Parameters.AddWithValue("?uuid", up.UserId.ToString()); | ||
797 | |||
798 | cmd.ExecuteNonQuery(); | ||
799 | } | ||
800 | } | ||
801 | } | ||
802 | catch (Exception e) | ||
803 | { | ||
804 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
805 | ": AgentInterestsUpdate exception {0}", e.Message); | ||
806 | result = e.Message; | ||
807 | return false; | ||
808 | } | ||
809 | return true; | ||
810 | } | ||
811 | #endregion Avatar Interests | ||
812 | |||
813 | public OSDArray GetUserImageAssets(UUID avatarId) | ||
814 | { | ||
815 | OSDArray data = new OSDArray(); | ||
816 | string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; | ||
817 | |||
818 | // Get classified image assets | ||
819 | |||
820 | |||
821 | try | ||
822 | { | ||
823 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
824 | { | ||
825 | dbcon.Open(); | ||
826 | |||
827 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon)) | ||
828 | { | ||
829 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
830 | |||
831 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
832 | { | ||
833 | if(reader.HasRows) | ||
834 | { | ||
835 | while (reader.Read()) | ||
836 | { | ||
837 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); | ||
838 | } | ||
839 | } | ||
840 | } | ||
841 | } | ||
842 | |||
843 | dbcon.Close(); | ||
844 | dbcon.Open(); | ||
845 | |||
846 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) | ||
847 | { | ||
848 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
849 | |||
850 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
851 | { | ||
852 | if(reader.HasRows) | ||
853 | { | ||
854 | while (reader.Read()) | ||
855 | { | ||
856 | data.Add(new OSDString((string)reader["snapshotuuid"].ToString ())); | ||
857 | } | ||
858 | } | ||
859 | } | ||
860 | } | ||
861 | |||
862 | dbcon.Close(); | ||
863 | dbcon.Open(); | ||
864 | |||
865 | query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; | ||
866 | |||
867 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) | ||
868 | { | ||
869 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | ||
870 | |||
871 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
872 | { | ||
873 | if(reader.HasRows) | ||
874 | { | ||
875 | while (reader.Read()) | ||
876 | { | ||
877 | data.Add(new OSDString((string)reader["profileImage"].ToString ())); | ||
878 | data.Add(new OSDString((string)reader["profileFirstImage"].ToString ())); | ||
879 | } | ||
880 | } | ||
881 | } | ||
882 | } | ||
883 | } | ||
884 | } | ||
885 | catch (Exception e) | ||
886 | { | ||
887 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
888 | ": GetAvatarNotes exception {0}", e.Message); | ||
889 | } | ||
890 | return data; | ||
891 | } | ||
892 | |||
893 | #region User Preferences | ||
894 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) | ||
895 | { | ||
896 | string query = string.Empty; | ||
897 | |||
898 | query += "SELECT imviaemail,visible,email FROM "; | ||
899 | query += "usersettings WHERE "; | ||
900 | query += "useruuid = ?Id"; | ||
901 | |||
902 | OSDArray data = new OSDArray(); | ||
903 | |||
904 | try | ||
905 | { | ||
906 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
907 | { | ||
908 | dbcon.Open(); | ||
909 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
910 | { | ||
911 | cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); | ||
912 | |||
913 | using (MySqlDataReader reader = cmd.ExecuteReader()) | ||
914 | { | ||
915 | if(reader.HasRows) | ||
916 | { | ||
917 | reader.Read(); | ||
918 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); | ||
919 | bool.TryParse((string)reader["visible"], out pref.Visible); | ||
920 | pref.EMail = (string)reader["email"]; | ||
921 | } | ||
922 | else | ||
923 | { | ||
924 | dbcon.Close(); | ||
925 | dbcon.Open(); | ||
926 | |||
927 | query = "INSERT INTO usersettings VALUES "; | ||
928 | query += "(?uuid,'false','false', ?Email)"; | ||
929 | |||
930 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
931 | { | ||
932 | |||
933 | put.Parameters.AddWithValue("?Email", pref.EMail); | ||
934 | put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); | ||
935 | |||
936 | put.ExecuteNonQuery(); | ||
937 | } | ||
938 | } | ||
939 | } | ||
940 | } | ||
941 | } | ||
942 | } | ||
943 | catch (Exception e) | ||
944 | { | ||
945 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
946 | ": Get preferences exception {0}", e.Message); | ||
947 | result = e.Message; | ||
948 | return false; | ||
949 | } | ||
950 | return true; | ||
951 | } | ||
952 | |||
953 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) | ||
954 | { | ||
955 | string query = string.Empty; | ||
956 | |||
957 | query += "UPDATE usersettings SET "; | ||
958 | query += "imviaemail=?ImViaEmail, "; | ||
959 | query += "visible=?Visible, "; | ||
960 | query += "email=?EMail "; | ||
961 | query += "WHERE useruuid=?uuid"; | ||
962 | |||
963 | try | ||
964 | { | ||
965 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
966 | { | ||
967 | dbcon.Open(); | ||
968 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
969 | { | ||
970 | cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail.ToString().ToLower()); | ||
971 | cmd.Parameters.AddWithValue("?Visible", pref.Visible.ToString().ToLower()); | ||
972 | cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); | ||
973 | cmd.Parameters.AddWithValue("?EMail", pref.EMail.ToString().ToLower()); | ||
974 | |||
975 | cmd.ExecuteNonQuery(); | ||
976 | } | ||
977 | } | ||
978 | } | ||
979 | catch (Exception e) | ||
980 | { | ||
981 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
982 | ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException); | ||
983 | result = e.Message; | ||
984 | return false; | ||
985 | } | ||
986 | return true; | ||
987 | } | ||
988 | #endregion User Preferences | ||
989 | |||
990 | #region Integration | ||
991 | public bool GetUserAppData(ref UserAppData props, ref string result) | ||
992 | { | ||
993 | string query = string.Empty; | ||
994 | |||
995 | query += "SELECT * FROM `userdata` WHERE "; | ||
996 | query += "UserId = ?Id AND "; | ||
997 | query += "TagId = ?TagId"; | ||
998 | |||
999 | try | ||
1000 | { | ||
1001 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
1002 | { | ||
1003 | dbcon.Open(); | ||
1004 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
1005 | { | ||
1006 | cmd.Parameters.AddWithValue("?Id", props.UserId.ToString()); | ||
1007 | cmd.Parameters.AddWithValue ("?TagId", props.TagId.ToString()); | ||
1008 | |||
1009 | using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
1010 | { | ||
1011 | if(reader.HasRows) | ||
1012 | { | ||
1013 | reader.Read(); | ||
1014 | props.DataKey = (string)reader["DataKey"]; | ||
1015 | props.DataVal = (string)reader["DataVal"]; | ||
1016 | } | ||
1017 | else | ||
1018 | { | ||
1019 | query += "INSERT INTO userdata VALUES ( "; | ||
1020 | query += "?UserId,"; | ||
1021 | query += "?TagId,"; | ||
1022 | query += "?DataKey,"; | ||
1023 | query += "?DataVal) "; | ||
1024 | |||
1025 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
1026 | { | ||
1027 | put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); | ||
1028 | put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); | ||
1029 | put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); | ||
1030 | put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); | ||
1031 | |||
1032 | put.ExecuteNonQuery(); | ||
1033 | } | ||
1034 | } | ||
1035 | } | ||
1036 | } | ||
1037 | } | ||
1038 | } | ||
1039 | catch (Exception e) | ||
1040 | { | ||
1041 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
1042 | ": Requst application data exception {0}", e.Message); | ||
1043 | result = e.Message; | ||
1044 | return false; | ||
1045 | } | ||
1046 | return true; | ||
1047 | } | ||
1048 | |||
1049 | public bool SetUserAppData(UserAppData props, ref string result) | ||
1050 | { | ||
1051 | string query = string.Empty; | ||
1052 | |||
1053 | query += "UPDATE userdata SET "; | ||
1054 | query += "TagId = ?TagId, "; | ||
1055 | query += "DataKey = ?DataKey, "; | ||
1056 | query += "DataVal = ?DataVal WHERE "; | ||
1057 | query += "UserId = ?UserId AND "; | ||
1058 | query += "TagId = ?TagId"; | ||
1059 | |||
1060 | try | ||
1061 | { | ||
1062 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | ||
1063 | { | ||
1064 | dbcon.Open(); | ||
1065 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | ||
1066 | { | ||
1067 | cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString()); | ||
1068 | cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString()); | ||
1069 | cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); | ||
1070 | cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString()); | ||
1071 | |||
1072 | cmd.ExecuteNonQuery(); | ||
1073 | } | ||
1074 | } | ||
1075 | } | ||
1076 | catch (Exception e) | ||
1077 | { | ||
1078 | m_log.ErrorFormat("[PROFILES_DATA]" + | ||
1079 | ": SetUserData exception {0}", e.Message); | ||
1080 | return false; | ||
1081 | } | ||
1082 | return true; | ||
1083 | } | ||
1084 | #endregion Integration | ||
1085 | } | ||
1086 | } \ No newline at end of file | ||
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index e6ac22e..af7e876 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs | |||
@@ -50,9 +50,13 @@ namespace OpenSim.Data.MySQL | |||
50 | get { return GetType().Assembly; } | 50 | get { return GetType().Assembly; } |
51 | } | 51 | } |
52 | 52 | ||
53 | /// <summary> | ||
54 | /// Number of days that must pass before we update the access time on an asset when it has been fetched. | ||
55 | /// </summary> | ||
56 | private const int DaysBetweenAccessTimeUpdates = 30; | ||
57 | |||
53 | private bool m_enableCompression = false; | 58 | private bool m_enableCompression = false; |
54 | private string m_connectionString; | 59 | private string m_connectionString; |
55 | private object m_dbLock = new object(); | ||
56 | 60 | ||
57 | /// <summary> | 61 | /// <summary> |
58 | /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock | 62 | /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock |
@@ -126,58 +130,58 @@ namespace OpenSim.Data.MySQL | |||
126 | // m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); | 130 | // m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); |
127 | 131 | ||
128 | AssetBase asset = null; | 132 | AssetBase asset = null; |
129 | lock (m_dbLock) | 133 | |
134 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
130 | { | 135 | { |
131 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 136 | dbcon.Open(); |
137 | |||
138 | using (MySqlCommand cmd = new MySqlCommand( | ||
139 | "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID", | ||
140 | dbcon)) | ||
132 | { | 141 | { |
133 | dbcon.Open(); | 142 | cmd.Parameters.AddWithValue("?ID", assetID.ToString()); |
134 | 143 | ||
135 | using (MySqlCommand cmd = new MySqlCommand( | 144 | try |
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 | { | 145 | { |
139 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); | 146 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
140 | |||
141 | try | ||
142 | { | 147 | { |
143 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 148 | if (dbReader.Read()) |
144 | { | 149 | { |
145 | if (dbReader.Read()) | 150 | asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString()); |
146 | { | 151 | asset.Data = (byte[])dbReader["Data"]; |
147 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString()); | 152 | asset.Description = (string)dbReader["Description"]; |
148 | asset.Data = (byte[])dbReader["data"]; | ||
149 | asset.Description = (string)dbReader["description"]; | ||
150 | 153 | ||
151 | string local = dbReader["local"].ToString(); | 154 | string local = dbReader["Local"].ToString(); |
152 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | 155 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) |
153 | asset.Local = true; | 156 | asset.Local = true; |
154 | else | 157 | else |
155 | asset.Local = false; | 158 | asset.Local = false; |
156 | 159 | ||
157 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | 160 | asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); |
158 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 161 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); |
159 | 162 | ||
160 | if (m_enableCompression) | 163 | if (m_enableCompression) |
164 | { | ||
165 | using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) | ||
161 | { | 166 | { |
162 | using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) | 167 | MemoryStream outputStream = new MemoryStream(); |
163 | { | 168 | WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); |
164 | MemoryStream outputStream = new MemoryStream(); | 169 | // int compressedLength = asset.Data.Length; |
165 | WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); | 170 | asset.Data = outputStream.ToArray(); |
166 | // int compressedLength = asset.Data.Length; | 171 | |
167 | asset.Data = outputStream.ToArray(); | 172 | // m_log.DebugFormat( |
168 | 173 | // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", | |
169 | // m_log.DebugFormat( | 174 | // asset.ID, asset.Name, asset.Data.Length, compressedLength); |
170 | // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", | ||
171 | // asset.ID, asset.Name, asset.Data.Length, compressedLength); | ||
172 | } | ||
173 | } | 175 | } |
174 | } | 176 | } |
177 | |||
178 | UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]); | ||
175 | } | 179 | } |
176 | } | 180 | } |
177 | catch (Exception e) | 181 | } |
178 | { | 182 | catch (Exception e) |
179 | m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message); | 183 | { |
180 | } | 184 | m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); |
181 | } | 185 | } |
182 | } | 186 | } |
183 | } | 187 | } |
@@ -192,148 +196,156 @@ namespace OpenSim.Data.MySQL | |||
192 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> | 196 | /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> |
193 | public void StoreAsset(AssetBase asset) | 197 | public void StoreAsset(AssetBase asset) |
194 | { | 198 | { |
195 | lock (m_dbLock) | 199 | // m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID); |
200 | |||
201 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
196 | { | 202 | { |
197 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 203 | dbcon.Open(); |
204 | |||
205 | using (MySqlTransaction transaction = dbcon.BeginTransaction()) | ||
198 | { | 206 | { |
199 | dbcon.Open(); | 207 | string assetName = asset.Name; |
208 | if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) | ||
209 | { | ||
210 | assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); | ||
211 | m_log.WarnFormat( | ||
212 | "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", | ||
213 | asset.Name, asset.ID, asset.Name.Length, assetName.Length); | ||
214 | } | ||
200 | 215 | ||
201 | using (MySqlTransaction transaction = dbcon.BeginTransaction()) | 216 | string assetDescription = asset.Description; |
217 | if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) | ||
202 | { | 218 | { |
203 | string assetName = asset.Name; | 219 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); |
204 | if (asset.Name.Length > 64) | 220 | m_log.WarnFormat( |
205 | { | 221 | "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", |
206 | assetName = asset.Name.Substring(0, 64); | 222 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); |
207 | m_log.Warn("[XASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); | 223 | } |
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 | 224 | ||
217 | if (m_enableCompression) | 225 | if (m_enableCompression) |
218 | { | 226 | { |
219 | MemoryStream outputStream = new MemoryStream(); | 227 | MemoryStream outputStream = new MemoryStream(); |
220 | 228 | ||
221 | using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) | 229 | using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) |
222 | { | 230 | { |
223 | // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); | 231 | // 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. | 232 | // 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(); | 233 | compressionStream.Close(); |
226 | byte[] compressedData = outputStream.ToArray(); | 234 | byte[] compressedData = outputStream.ToArray(); |
227 | asset.Data = compressedData; | 235 | asset.Data = compressedData; |
228 | } | ||
229 | } | 236 | } |
237 | } | ||
230 | 238 | ||
231 | byte[] hash = hasher.ComputeHash(asset.Data); | 239 | byte[] hash = hasher.ComputeHash(asset.Data); |
232 | 240 | ||
233 | // m_log.DebugFormat( | 241 | // m_log.DebugFormat( |
234 | // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", | 242 | // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", |
235 | // asset.ID, asset.Name, hash, compressedData.Length); | 243 | // asset.ID, asset.Name, hash, compressedData.Length); |
236 | 244 | ||
245 | try | ||
246 | { | ||
247 | using (MySqlCommand cmd = | ||
248 | new MySqlCommand( | ||
249 | "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" + | ||
250 | "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)", | ||
251 | dbcon)) | ||
252 | { | ||
253 | // create unix epoch time | ||
254 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
255 | cmd.Parameters.AddWithValue("?ID", asset.ID); | ||
256 | cmd.Parameters.AddWithValue("?Hash", hash); | ||
257 | cmd.Parameters.AddWithValue("?Name", assetName); | ||
258 | cmd.Parameters.AddWithValue("?Description", assetDescription); | ||
259 | cmd.Parameters.AddWithValue("?AssetType", asset.Type); | ||
260 | cmd.Parameters.AddWithValue("?Local", asset.Local); | ||
261 | cmd.Parameters.AddWithValue("?Temporary", asset.Temporary); | ||
262 | cmd.Parameters.AddWithValue("?CreateTime", now); | ||
263 | cmd.Parameters.AddWithValue("?AccessTime", now); | ||
264 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
265 | cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags); | ||
266 | cmd.ExecuteNonQuery(); | ||
267 | } | ||
268 | } | ||
269 | catch (Exception e) | ||
270 | { | ||
271 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", | ||
272 | asset.FullID, asset.Name, e.Message); | ||
273 | |||
274 | transaction.Rollback(); | ||
275 | |||
276 | return; | ||
277 | } | ||
278 | |||
279 | if (!ExistsData(dbcon, transaction, hash)) | ||
280 | { | ||
237 | try | 281 | try |
238 | { | 282 | { |
239 | using (MySqlCommand cmd = | 283 | using (MySqlCommand cmd = |
240 | new MySqlCommand( | 284 | new MySqlCommand( |
241 | "replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" + | 285 | "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)", |
242 | "VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)", | ||
243 | dbcon)) | 286 | dbcon)) |
244 | { | 287 | { |
245 | // create unix epoch time | 288 | cmd.Parameters.AddWithValue("?Hash", hash); |
246 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 289 | cmd.Parameters.AddWithValue("?Data", asset.Data); |
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(); | 290 | cmd.ExecuteNonQuery(); |
259 | } | 291 | } |
260 | } | 292 | } |
261 | catch (Exception e) | 293 | catch (Exception e) |
262 | { | 294 | { |
263 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", | 295 | m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", |
264 | asset.FullID, asset.Name, e.Message); | 296 | asset.FullID, asset.Name, e.Message); |
265 | 297 | ||
266 | transaction.Rollback(); | 298 | transaction.Rollback(); |
267 | 299 | ||
268 | return; | 300 | return; |
269 | } | 301 | } |
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 | } | 302 | } |
303 | |||
304 | transaction.Commit(); | ||
298 | } | 305 | } |
299 | } | 306 | } |
300 | } | 307 | } |
301 | 308 | ||
302 | // private void UpdateAccessTime(AssetBase asset) | 309 | /// <summary> |
303 | // { | 310 | /// Updates the access time of the asset if it was accessed above a given threshhold amount of time. |
304 | // lock (m_dbLock) | 311 | /// </summary> |
305 | // { | 312 | /// <remarks> |
306 | // using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 313 | /// This gives us some insight into assets which haven't ben accessed for a long period. This is only done |
307 | // { | 314 | /// over the threshold time to avoid excessive database writes as assets are fetched. |
308 | // dbcon.Open(); | 315 | /// </remarks> |
309 | // MySqlCommand cmd = | 316 | /// <param name='asset'></param> |
310 | // new MySqlCommand("update assets set access_time=?access_time where id=?id", | 317 | /// <param name='accessTime'></param> |
311 | // dbcon); | 318 | private void UpdateAccessTime(AssetMetadata assetMetadata, int accessTime) |
312 | // | 319 | { |
313 | // // need to ensure we dispose | 320 | DateTime now = DateTime.UtcNow; |
314 | // try | 321 | |
315 | // { | 322 | if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates) |
316 | // using (cmd) | 323 | return; |
317 | // { | 324 | |
318 | // // create unix epoch time | 325 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
319 | // int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 326 | { |
320 | // cmd.Parameters.AddWithValue("?id", asset.ID); | 327 | dbcon.Open(); |
321 | // cmd.Parameters.AddWithValue("?access_time", now); | 328 | MySqlCommand cmd = |
322 | // cmd.ExecuteNonQuery(); | 329 | new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon); |
323 | // cmd.Dispose(); | 330 | |
324 | // } | 331 | try |
325 | // } | 332 | { |
326 | // catch (Exception e) | 333 | using (cmd) |
327 | // { | 334 | { |
328 | // m_log.ErrorFormat( | 335 | // create unix epoch time |
329 | // "[ASSETS DB]: " + | 336 | cmd.Parameters.AddWithValue("?ID", assetMetadata.ID); |
330 | // "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | 337 | cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now)); |
331 | // + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | 338 | cmd.ExecuteNonQuery(); |
332 | // } | 339 | } |
333 | // } | 340 | } |
334 | // } | 341 | catch (Exception) |
335 | // | 342 | { |
336 | // } | 343 | m_log.ErrorFormat( |
344 | "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", | ||
345 | assetMetadata.ID, assetMetadata.Name); | ||
346 | } | ||
347 | } | ||
348 | } | ||
337 | 349 | ||
338 | /// <summary> | 350 | /// <summary> |
339 | /// We assume we already have the m_dbLock. | 351 | /// We assume we already have the m_dbLock. |
@@ -349,9 +361,9 @@ namespace OpenSim.Data.MySQL | |||
349 | 361 | ||
350 | bool exists = false; | 362 | bool exists = false; |
351 | 363 | ||
352 | using (MySqlCommand cmd = new MySqlCommand("SELECT hash FROM xassetsdata WHERE hash=?hash", dbcon)) | 364 | using (MySqlCommand cmd = new MySqlCommand("SELECT Hash FROM XAssetsData WHERE Hash=?Hash", dbcon)) |
353 | { | 365 | { |
354 | cmd.Parameters.AddWithValue("?hash", hash); | 366 | cmd.Parameters.AddWithValue("?Hash", hash); |
355 | 367 | ||
356 | try | 368 | try |
357 | { | 369 | { |
@@ -376,48 +388,43 @@ namespace OpenSim.Data.MySQL | |||
376 | } | 388 | } |
377 | 389 | ||
378 | /// <summary> | 390 | /// <summary> |
379 | /// Check if the asset exists in the database | 391 | /// Check if the assets exist in the database. |
380 | /// </summary> | 392 | /// </summary> |
381 | /// <param name="uuid">The asset UUID</param> | 393 | /// <param name="uuids">The asset UUID's</param> |
382 | /// <returns>true if it exists, false otherwise.</returns> | 394 | /// <returns>For each asset: true if it exists, false otherwise</returns> |
383 | public bool ExistsAsset(UUID uuid) | 395 | public bool[] AssetsExist(UUID[] uuids) |
384 | { | 396 | { |
385 | // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); | 397 | if (uuids.Length == 0) |
398 | return new bool[0]; | ||
399 | |||
400 | HashSet<UUID> exists = new HashSet<UUID>(); | ||
386 | 401 | ||
387 | bool assetExists = false; | 402 | string ids = "'" + string.Join("','", uuids) + "'"; |
403 | string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids); | ||
388 | 404 | ||
389 | lock (m_dbLock) | 405 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
390 | { | 406 | { |
391 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 407 | dbcon.Open(); |
408 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
392 | { | 409 | { |
393 | dbcon.Open(); | 410 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
394 | using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM xassetsmeta WHERE id=?id", dbcon)) | ||
395 | { | 411 | { |
396 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); | 412 | while (dbReader.Read()) |
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 | { | 413 | { |
411 | m_log.ErrorFormat( | 414 | UUID id = DBGuid.FromDB(dbReader["ID"]); |
412 | "[XASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); | 415 | exists.Add(id); |
413 | } | 416 | } |
414 | } | 417 | } |
415 | } | 418 | } |
416 | } | 419 | } |
417 | 420 | ||
418 | return assetExists; | 421 | bool[] results = new bool[uuids.Length]; |
422 | for (int i = 0; i < uuids.Length; i++) | ||
423 | results[i] = exists.Contains(uuids[i]); | ||
424 | return results; | ||
419 | } | 425 | } |
420 | 426 | ||
427 | |||
421 | /// <summary> | 428 | /// <summary> |
422 | /// Returns a list of AssetMetadata objects. The list is a subset of | 429 | /// Returns a list of AssetMetadata objects. The list is a subset of |
423 | /// the entire data set offset by <paramref name="start" /> containing | 430 | /// the entire data set offset by <paramref name="start" /> containing |
@@ -430,41 +437,40 @@ namespace OpenSim.Data.MySQL | |||
430 | { | 437 | { |
431 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 438 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
432 | 439 | ||
433 | lock (m_dbLock) | 440 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
434 | { | 441 | { |
435 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 442 | dbcon.Open(); |
436 | { | 443 | MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); |
437 | dbcon.Open(); | 444 | cmd.Parameters.AddWithValue("?start", start); |
438 | MySqlCommand cmd = new MySqlCommand("SELECT name,description,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon); | 445 | cmd.Parameters.AddWithValue("?count", count); |
439 | cmd.Parameters.AddWithValue("?start", start); | ||
440 | cmd.Parameters.AddWithValue("?count", count); | ||
441 | 446 | ||
442 | try | 447 | try |
448 | { | ||
449 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | ||
443 | { | 450 | { |
444 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 451 | while (dbReader.Read()) |
445 | { | 452 | { |
446 | while (dbReader.Read()) | 453 | AssetMetadata metadata = new AssetMetadata(); |
447 | { | 454 | metadata.Name = (string)dbReader["Name"]; |
448 | AssetMetadata metadata = new AssetMetadata(); | 455 | metadata.Description = (string)dbReader["Description"]; |
449 | metadata.Name = (string)dbReader["name"]; | 456 | metadata.Type = (sbyte)dbReader["AssetType"]; |
450 | metadata.Description = (string)dbReader["description"]; | 457 | metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. |
451 | metadata.Type = (sbyte)dbReader["asset_type"]; | 458 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); |
452 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | 459 | metadata.FullID = DBGuid.FromDB(dbReader["ID"]); |
453 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 460 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
454 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 461 | |
455 | metadata.CreatorID = dbReader["creator_id"].ToString(); | 462 | // We'll ignore this for now - it appears unused! |
456 | |||
457 | // We'll ignore this for now - it appears unused! | ||
458 | // metadata.SHA1 = dbReader["hash"]); | 463 | // metadata.SHA1 = dbReader["hash"]); |
459 | 464 | ||
460 | retList.Add(metadata); | 465 | UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); |
461 | } | 466 | |
467 | retList.Add(metadata); | ||
462 | } | 468 | } |
463 | } | 469 | } |
464 | catch (Exception e) | 470 | } |
465 | { | 471 | catch (Exception e) |
466 | m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); | 472 | { |
467 | } | 473 | m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); |
468 | } | 474 | } |
469 | } | 475 | } |
470 | 476 | ||
@@ -475,21 +481,18 @@ namespace OpenSim.Data.MySQL | |||
475 | { | 481 | { |
476 | // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); | 482 | // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); |
477 | 483 | ||
478 | lock (m_dbLock) | 484 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
479 | { | 485 | { |
480 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 486 | dbcon.Open(); |
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 | 487 | ||
490 | // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we | 488 | using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon)) |
491 | // keep a reference count (?) | 489 | { |
490 | cmd.Parameters.AddWithValue("?ID", id); | ||
491 | cmd.ExecuteNonQuery(); | ||
492 | } | 492 | } |
493 | |||
494 | // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we | ||
495 | // keep a reference count (?) | ||
493 | } | 496 | } |
494 | 497 | ||
495 | return true; | 498 | return true; |
diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index ab3fe36..b46d175 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | |||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices; | |||
61 | // You can specify all the values or you can default the Revision and Build Numbers | 61 | // You can specify all the values or you can default the Revision and Build Numbers |
62 | // by using the '*' as shown below: | 62 | // by using the '*' as shown below: |
63 | 63 | ||
64 | [assembly : AssemblyVersion("0.7.5.*")] | 64 | [assembly : AssemblyVersion("0.8.2.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | |
diff --git a/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations b/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations new file mode 100644 index 0000000..e496f72 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/AgentPrefs.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | :VERSION 1 # ------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE `AgentPrefs` ( | ||
6 | `PrincipalID` CHAR(36) NOT NULL, | ||
7 | `AccessPrefs` CHAR(2) NOT NULL DEFAULT 'M', | ||
8 | `HoverHeight` DOUBLE(30, 27) NOT NULL DEFAULT 0, | ||
9 | `Language` CHAR(5) NOT NULL DEFAULT 'en-us', | ||
10 | `LanguageIsPublic` BOOLEAN NOT NULL DEFAULT 1, | ||
11 | `PermEveryone` INT(6) NOT NULL DEFAULT 0, | ||
12 | `PermGroup` INT(6) NOT NULL DEFAULT 0, | ||
13 | `PermNextOwner` INT(6) NOT NULL DEFAULT 532480, | ||
14 | UNIQUE KEY `PrincipalID` (`PrincipalID`), | ||
15 | PRIMARY KEY(`PrincipalID`) | ||
16 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
17 | |||
18 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/AssetStore.migrations b/OpenSim/Data/MySQL/Resources/AssetStore.migrations index f7211c2..661d825 100644 --- a/OpenSim/Data/MySQL/Resources/AssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations | |||
@@ -13,7 +13,7 @@ CREATE TABLE `assets` ( | |||
13 | `temporary` tinyint(1) NOT NULL, | 13 | `temporary` tinyint(1) NOT NULL, |
14 | `data` longblob NOT NULL, | 14 | `data` longblob NOT NULL, |
15 | PRIMARY KEY (`id`) | 15 | PRIMARY KEY (`id`) |
16 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; | 16 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; |
17 | 17 | ||
18 | COMMIT; | 18 | COMMIT; |
19 | 19 | ||
@@ -75,3 +75,7 @@ ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; | |||
75 | 75 | ||
76 | ALTER TABLE assets ADD COLUMN CreatorID varchar(128) NOT NULL DEFAULT ''; | 76 | ALTER TABLE assets ADD COLUMN CreatorID varchar(128) NOT NULL DEFAULT ''; |
77 | 77 | ||
78 | :VERSION 9 | ||
79 | |||
80 | BEGIN; | ||
81 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/AuthStore.migrations b/OpenSim/Data/MySQL/Resources/AuthStore.migrations index 9450940..023c786 100644 --- a/OpenSim/Data/MySQL/Resources/AuthStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AuthStore.migrations | |||
@@ -8,7 +8,7 @@ CREATE TABLE `auth` ( | |||
8 | `passwordSalt` char(32) NOT NULL default '', | 8 | `passwordSalt` char(32) NOT NULL default '', |
9 | `webLoginKey` varchar(255) NOT NULL default '', | 9 | `webLoginKey` varchar(255) NOT NULL default '', |
10 | PRIMARY KEY (`UUID`) | 10 | PRIMARY KEY (`UUID`) |
11 | ) ENGINE=MyISAM; | 11 | ) ENGINE=InnoDB; |
12 | 12 | ||
13 | CREATE TABLE `tokens` ( | 13 | CREATE TABLE `tokens` ( |
14 | `UUID` char(36) NOT NULL, | 14 | `UUID` char(36) NOT NULL, |
@@ -18,7 +18,7 @@ CREATE TABLE `tokens` ( | |||
18 | KEY `UUID` (`UUID`), | 18 | KEY `UUID` (`UUID`), |
19 | KEY `token` (`token`), | 19 | KEY `token` (`token`), |
20 | KEY `validity` (`validity`) | 20 | KEY `validity` (`validity`) |
21 | ) ENGINE=MyISAM; | 21 | ) ENGINE=InnoDB; |
22 | 22 | ||
23 | commit; | 23 | commit; |
24 | 24 | ||
diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index 6ef92ee..2d1c2b5 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations | |||
@@ -10,19 +10,19 @@ CREATE TABLE IF NOT EXISTS `estate_managers` ( | |||
10 | `EstateID` int(10) unsigned NOT NULL, | 10 | `EstateID` int(10) unsigned NOT NULL, |
11 | `uuid` char(36) NOT NULL, | 11 | `uuid` char(36) NOT NULL, |
12 | KEY `EstateID` (`EstateID`) | 12 | KEY `EstateID` (`EstateID`) |
13 | ) ENGINE=MyISAM; | 13 | ) ENGINE=InnoDB; |
14 | 14 | ||
15 | CREATE TABLE IF NOT EXISTS `estate_groups` ( | 15 | CREATE TABLE IF NOT EXISTS `estate_groups` ( |
16 | `EstateID` int(10) unsigned NOT NULL, | 16 | `EstateID` int(10) unsigned NOT NULL, |
17 | `uuid` char(36) NOT NULL, | 17 | `uuid` char(36) NOT NULL, |
18 | KEY `EstateID` (`EstateID`) | 18 | KEY `EstateID` (`EstateID`) |
19 | ) ENGINE=MyISAM; | 19 | ) ENGINE=InnoDB; |
20 | 20 | ||
21 | CREATE TABLE IF NOT EXISTS `estate_users` ( | 21 | CREATE TABLE IF NOT EXISTS `estate_users` ( |
22 | `EstateID` int(10) unsigned NOT NULL, | 22 | `EstateID` int(10) unsigned NOT NULL, |
23 | `uuid` char(36) NOT NULL, | 23 | `uuid` char(36) NOT NULL, |
24 | KEY `EstateID` (`EstateID`) | 24 | KEY `EstateID` (`EstateID`) |
25 | ) ENGINE=MyISAM; | 25 | ) ENGINE=InnoDB; |
26 | 26 | ||
27 | CREATE TABLE IF NOT EXISTS `estateban` ( | 27 | CREATE TABLE IF NOT EXISTS `estateban` ( |
28 | `EstateID` int(10) unsigned NOT NULL, | 28 | `EstateID` int(10) unsigned NOT NULL, |
@@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS `estateban` ( | |||
31 | `bannedIpHostMask` varchar(16) NOT NULL, | 31 | `bannedIpHostMask` varchar(16) NOT NULL, |
32 | `bannedNameMask` varchar(64) default NULL, | 32 | `bannedNameMask` varchar(64) default NULL, |
33 | KEY `estateban_EstateID` (`EstateID`) | 33 | KEY `estateban_EstateID` (`EstateID`) |
34 | ) ENGINE=MyISAM; | 34 | ) ENGINE=InnoDB; |
35 | 35 | ||
36 | CREATE TABLE IF NOT EXISTS `estate_settings` ( | 36 | CREATE TABLE IF NOT EXISTS `estate_settings` ( |
37 | `EstateID` int(10) unsigned NOT NULL auto_increment, | 37 | `EstateID` int(10) unsigned NOT NULL auto_increment, |
@@ -60,14 +60,14 @@ CREATE TABLE IF NOT EXISTS `estate_settings` ( | |||
60 | `DenyMinors` tinyint not null, | 60 | `DenyMinors` tinyint not null, |
61 | 61 | ||
62 | PRIMARY KEY (`EstateID`) | 62 | PRIMARY KEY (`EstateID`) |
63 | ) ENGINE=MyISAM AUTO_INCREMENT=100; | 63 | ) ENGINE=InnoDB AUTO_INCREMENT=100; |
64 | 64 | ||
65 | CREATE TABLE IF NOT EXISTS `estate_map` ( | 65 | CREATE TABLE IF NOT EXISTS `estate_map` ( |
66 | `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', | 66 | `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', |
67 | `EstateID` int(11) NOT NULL, | 67 | `EstateID` int(11) NOT NULL, |
68 | PRIMARY KEY (`RegionID`), | 68 | PRIMARY KEY (`RegionID`), |
69 | KEY `EstateID` (`EstateID`) | 69 | KEY `EstateID` (`EstateID`) |
70 | ) ENGINE=MyISAM; | 70 | ) ENGINE=InnoDB; |
71 | 71 | ||
72 | COMMIT; | 72 | COMMIT; |
73 | 73 | ||
@@ -77,5 +77,11 @@ BEGIN; | |||
77 | ALTER TABLE estate_settings AUTO_INCREMENT = 100; | 77 | ALTER TABLE estate_settings AUTO_INCREMENT = 100; |
78 | COMMIT; | 78 | COMMIT; |
79 | 79 | ||
80 | :VERSION 33 #--------------------- | ||
80 | 81 | ||
82 | BEGIN; | ||
83 | ALTER TABLE estate_settings ADD COLUMN `AllowLandmark` tinyint(4) NOT NULL default '1'; | ||
84 | ALTER TABLE estate_settings ADD COLUMN `AllowParcelChanges` tinyint(4) NOT NULL default '1'; | ||
85 | ALTER TABLE estate_settings ADD COLUMN `AllowSetHome` tinyint(4) NOT NULL default '1'; | ||
86 | COMMIT; | ||
81 | 87 | ||
diff --git a/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations new file mode 100644 index 0000000..87d08c6 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/FSAssetStore.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | # ----------------- | ||
2 | :VERSION 1 | ||
3 | |||
4 | BEGIN; | ||
5 | |||
6 | CREATE TABLE `fsassets` ( | ||
7 | `id` char(36) NOT NULL, | ||
8 | `name` varchar(64) NOT NULL DEFAULT '', | ||
9 | `description` varchar(64) NOT NULL DEFAULT '', | ||
10 | `type` int(11) NOT NULL, | ||
11 | `hash` char(80) NOT NULL, | ||
12 | `create_time` int(11) NOT NULL DEFAULT '0', | ||
13 | `access_time` int(11) NOT NULL DEFAULT '0', | ||
14 | `asset_flags` int(11) NOT NULL DEFAULT '0', | ||
15 | PRIMARY KEY (`id`) | ||
16 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
17 | |||
18 | COMMIT; \ No newline at end of file | ||
diff --git a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations index 55d82ec..5faf956 100644 --- a/OpenSim/Data/MySQL/Resources/FriendsStore.migrations +++ b/OpenSim/Data/MySQL/Resources/FriendsStore.migrations | |||
@@ -9,7 +9,7 @@ CREATE TABLE `Friends` ( | |||
9 | `Offered` VARCHAR(32) NOT NULL DEFAULT 0, | 9 | `Offered` VARCHAR(32) NOT NULL DEFAULT 0, |
10 | PRIMARY KEY(`PrincipalID`, `Friend`), | 10 | PRIMARY KEY(`PrincipalID`, `Friend`), |
11 | KEY(`PrincipalID`) | 11 | KEY(`PrincipalID`) |
12 | ); | 12 | ) ENGINE=InnoDB; |
13 | 13 | ||
14 | COMMIT; | 14 | COMMIT; |
15 | 15 | ||
diff --git a/OpenSim/Data/MySQL/Resources/GridStore.migrations b/OpenSim/Data/MySQL/Resources/GridStore.migrations index b010c63..b8d287a 100644 --- a/OpenSim/Data/MySQL/Resources/GridStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridStore.migrations | |||
@@ -1,5 +1,7 @@ | |||
1 | :VERSION 1 | 1 | :VERSION 1 |
2 | 2 | ||
3 | BEGIN; | ||
4 | |||
3 | CREATE TABLE `regions` ( | 5 | CREATE TABLE `regions` ( |
4 | `uuid` varchar(36) NOT NULL, | 6 | `uuid` varchar(36) NOT NULL, |
5 | `regionHandle` bigint(20) unsigned NOT NULL, | 7 | `regionHandle` bigint(20) unsigned NOT NULL, |
@@ -31,7 +33,9 @@ CREATE TABLE `regions` ( | |||
31 | KEY `regionName` (`regionName`), | 33 | KEY `regionName` (`regionName`), |
32 | KEY `regionHandle` (`regionHandle`), | 34 | KEY `regionHandle` (`regionHandle`), |
33 | KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) | 35 | KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`) |
34 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 3'; | 36 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
37 | |||
38 | COMMIT; | ||
35 | 39 | ||
36 | :VERSION 2 | 40 | :VERSION 2 |
37 | 41 | ||
diff --git a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations index e2be27e..d08e096 100644 --- a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations | |||
@@ -14,7 +14,7 @@ CREATE TABLE `GridUser` ( | |||
14 | `Login` CHAR(16) NOT NULL DEFAULT '0', | 14 | `Login` CHAR(16) NOT NULL DEFAULT '0', |
15 | `Logout` CHAR(16) NOT NULL DEFAULT '0', | 15 | `Logout` CHAR(16) NOT NULL DEFAULT '0', |
16 | PRIMARY KEY (`UserID`) | 16 | PRIMARY KEY (`UserID`) |
17 | ) ENGINE=MyISAM; | 17 | ) ENGINE=InnoDB; |
18 | 18 | ||
19 | COMMIT; | 19 | COMMIT; |
20 | 20 | ||
diff --git a/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations new file mode 100644 index 0000000..b4e4422 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations | |||
@@ -0,0 +1,18 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE `hg_traveling_data` ( | ||
6 | `SessionID` VARCHAR(36) NOT NULL, | ||
7 | `UserID` VARCHAR(36) NOT NULL, | ||
8 | `GridExternalName` VARCHAR(255) NOT NULL DEFAULT '', | ||
9 | `ServiceToken` VARCHAR(255) NOT NULL DEFAULT '', | ||
10 | `ClientIPAddress` VARCHAR(16) NOT NULL DEFAULT '', | ||
11 | `MyIPAddress` VARCHAR(16) NOT NULL DEFAULT '', | ||
12 | `TMStamp` timestamp NOT NULL, | ||
13 | PRIMARY KEY (`SessionID`), | ||
14 | KEY (`UserID`) | ||
15 | ) ENGINE=InnoDB; | ||
16 | |||
17 | COMMIT; | ||
18 | |||
diff --git a/OpenSim/Data/MySQL/Resources/IM_Store.migrations b/OpenSim/Data/MySQL/Resources/IM_Store.migrations new file mode 100644 index 0000000..79ead98 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/IM_Store.migrations | |||
@@ -0,0 +1,42 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE `im_offline` ( | ||
6 | `ID` MEDIUMINT NOT NULL AUTO_INCREMENT, | ||
7 | `PrincipalID` char(36) NOT NULL default '', | ||
8 | `Message` text NOT NULL, | ||
9 | `TMStamp` timestamp NOT NULL, | ||
10 | PRIMARY KEY (`ID`), | ||
11 | KEY `PrincipalID` (`PrincipalID`) | ||
12 | ) ENGINE=MyISAM; | ||
13 | |||
14 | COMMIT; | ||
15 | |||
16 | :VERSION 2 # -------------------------- | ||
17 | |||
18 | BEGIN; | ||
19 | |||
20 | INSERT INTO `im_offline` SELECT * from `diva_im_offline`; | ||
21 | DROP TABLE `diva_im_offline`; | ||
22 | DELETE FROM `migrations` WHERE name='diva_im_Store'; | ||
23 | |||
24 | COMMIT; | ||
25 | |||
26 | :VERSION 3 # -------------------------- | ||
27 | |||
28 | BEGIN; | ||
29 | |||
30 | ALTER TABLE `im_offline` | ||
31 | ADD `FromID` char(36) NOT NULL default '' AFTER `PrincipalID`, | ||
32 | ADD KEY `FromID` (`FromID`); | ||
33 | |||
34 | COMMIT; | ||
35 | |||
36 | :VERSION 4 # -------------------------- | ||
37 | |||
38 | BEGIN; | ||
39 | |||
40 | ALTER TABLE im_offline CONVERT TO CHARACTER SET utf8; | ||
41 | |||
42 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations index ca2fe11..993a5a0 100644 --- a/OpenSim/Data/MySQL/Resources/InventoryStore.migrations +++ b/OpenSim/Data/MySQL/Resources/InventoryStore.migrations | |||
@@ -11,7 +11,7 @@ CREATE TABLE `inventoryfolders` ( | |||
11 | PRIMARY KEY (`folderID`), | 11 | PRIMARY KEY (`folderID`), |
12 | KEY `owner` (`agentID`), | 12 | KEY `owner` (`agentID`), |
13 | KEY `parent` (`parentFolderID`) | 13 | KEY `parent` (`parentFolderID`) |
14 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 14 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
15 | 15 | ||
16 | CREATE TABLE `inventoryitems` ( | 16 | CREATE TABLE `inventoryitems` ( |
17 | `inventoryID` varchar(36) NOT NULL default '', | 17 | `inventoryID` varchar(36) NOT NULL default '', |
@@ -36,7 +36,7 @@ CREATE TABLE `inventoryitems` ( | |||
36 | PRIMARY KEY (`inventoryID`), | 36 | PRIMARY KEY (`inventoryID`), |
37 | KEY `owner` (`avatarID`), | 37 | KEY `owner` (`avatarID`), |
38 | KEY `folder` (`parentFolderID`) | 38 | KEY `folder` (`parentFolderID`) |
39 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 39 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
40 | 40 | ||
41 | COMMIT; | 41 | COMMIT; |
42 | 42 | ||
diff --git a/OpenSim/Data/MySQL/Resources/LogStore.migrations b/OpenSim/Data/MySQL/Resources/LogStore.migrations index b572411..9ac26ac 100644 --- a/OpenSim/Data/MySQL/Resources/LogStore.migrations +++ b/OpenSim/Data/MySQL/Resources/LogStore.migrations | |||
@@ -10,4 +10,4 @@ CREATE TABLE `logs` ( | |||
10 | `priority` int(11) default NULL, | 10 | `priority` int(11) default NULL, |
11 | `message` text, | 11 | `message` text, |
12 | PRIMARY KEY (`logID`) | 12 | PRIMARY KEY (`logID`) |
13 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 13 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations index 5dc96d2..c4e40fa 100644 --- a/OpenSim/Data/MySQL/Resources/Presence.migrations +++ b/OpenSim/Data/MySQL/Resources/Presence.migrations | |||
@@ -1,4 +1,4 @@ | |||
1 | :VERSION 1 # -------------------------- | 1 | :VERSION 1 # -------------------------- |
2 | 2 | ||
3 | BEGIN; | 3 | BEGIN; |
4 | 4 | ||
@@ -7,7 +7,7 @@ CREATE TABLE `Presence` ( | |||
7 | `RegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | 7 | `RegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', |
8 | `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', | 8 | `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', |
9 | `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' | 9 | `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' |
10 | ) ENGINE=MyISAM; | 10 | ) ENGINE=InnoDB; |
11 | 11 | ||
12 | CREATE UNIQUE INDEX SessionID ON Presence(SessionID); | 12 | CREATE UNIQUE INDEX SessionID ON Presence(SessionID); |
13 | CREATE INDEX UserID ON Presence(UserID); | 13 | CREATE INDEX UserID ON Presence(UserID); |
@@ -21,3 +21,11 @@ BEGIN; | |||
21 | ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp; | 21 | ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp; |
22 | 22 | ||
23 | COMMIT; | 23 | COMMIT; |
24 | |||
25 | :VERSION 3 # -------------------------- | ||
26 | |||
27 | BEGIN; | ||
28 | |||
29 | CREATE INDEX RegionID ON Presence(RegionID); | ||
30 | |||
31 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 071f64e..ac31380 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations | |||
@@ -146,7 +146,7 @@ CREATE TABLE `land` ( | |||
146 | `UserLookAtZ` float default NULL, | 146 | `UserLookAtZ` float default NULL, |
147 | `AuthbuyerID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', | 147 | `AuthbuyerID` varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000', |
148 | PRIMARY KEY (`UUID`) | 148 | PRIMARY KEY (`UUID`) |
149 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 149 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
150 | 150 | ||
151 | CREATE TABLE `landaccesslist` ( | 151 | CREATE TABLE `landaccesslist` ( |
152 | `LandUUID` varchar(255) default NULL, | 152 | `LandUUID` varchar(255) default NULL, |
@@ -168,7 +168,7 @@ COMMIT; | |||
168 | :VERSION 3 #--------------------- | 168 | :VERSION 3 #--------------------- |
169 | 169 | ||
170 | BEGIN; | 170 | BEGIN; |
171 | CREATE TABLE regionban (regionUUID VARCHAR(36) NOT NULL, bannedUUID VARCHAR(36) NOT NULL, bannedIp VARCHAR(16) NOT NULL, bannedIpHostMask VARCHAR(16) NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; | 171 | CREATE TABLE regionban (regionUUID VARCHAR(36) NOT NULL, bannedUUID VARCHAR(36) NOT NULL, bannedIp VARCHAR(16) NOT NULL, bannedIpHostMask VARCHAR(16) NOT NULL) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; |
172 | COMMIT; | 172 | COMMIT; |
173 | 173 | ||
174 | :VERSION 4 #--------------------- | 174 | :VERSION 4 #--------------------- |
@@ -226,13 +226,13 @@ COMMIT; | |||
226 | 226 | ||
227 | BEGIN; | 227 | BEGIN; |
228 | 228 | ||
229 | alter table landaccesslist ENGINE = MyISAM; | 229 | alter table landaccesslist ENGINE = InnoDB; |
230 | alter table migrations ENGINE = MyISAM; | 230 | alter table migrations ENGINE = InnoDB; |
231 | alter table primitems ENGINE = MyISAM; | 231 | alter table primitems ENGINE = InnoDB; |
232 | alter table prims ENGINE = MyISAM; | 232 | alter table prims ENGINE = InnoDB; |
233 | alter table primshapes ENGINE = MyISAM; | 233 | alter table primshapes ENGINE = InnoDB; |
234 | alter table regionsettings ENGINE = MyISAM; | 234 | alter table regionsettings ENGINE = InnoDB; |
235 | alter table terrain ENGINE = MyISAM; | 235 | alter table terrain ENGINE = InnoDB; |
236 | 236 | ||
237 | COMMIT; | 237 | COMMIT; |
238 | 238 | ||
@@ -384,7 +384,7 @@ CREATE TABLE `regionsettings` ( | |||
384 | `covenant` char(36) default NULL, | 384 | `covenant` char(36) default NULL, |
385 | `Sandbox` tinyint(4) NOT NULL, | 385 | `Sandbox` tinyint(4) NOT NULL, |
386 | PRIMARY KEY (`regionUUID`) | 386 | PRIMARY KEY (`regionUUID`) |
387 | ) ENGINE=MyISAM; | 387 | ) ENGINE=InnoDB; |
388 | 388 | ||
389 | commit; | 389 | commit; |
390 | 390 | ||
@@ -852,7 +852,7 @@ CREATE TABLE IF NOT EXISTS `spawn_points` ( | |||
852 | `Pitch` float NOT NULL, | 852 | `Pitch` float NOT NULL, |
853 | `Distance` float NOT NULL, | 853 | `Distance` float NOT NULL, |
854 | KEY `RegionID` (`RegionID`) | 854 | KEY `RegionID` (`RegionID`) |
855 | ) ENGINE=MyISAM; | 855 | ) ENGINE=Innodb; |
856 | 856 | ||
857 | ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; | 857 | ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; |
858 | COMMIT; | 858 | COMMIT; |
@@ -891,7 +891,7 @@ CREATE TABLE `regionenvironment` ( | |||
891 | `region_id` varchar(36) NOT NULL, | 891 | `region_id` varchar(36) NOT NULL, |
892 | `llsd_settings` TEXT NOT NULL, | 892 | `llsd_settings` TEXT NOT NULL, |
893 | PRIMARY KEY (`region_id`) | 893 | PRIMARY KEY (`region_id`) |
894 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 894 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
895 | 895 | ||
896 | COMMIT; | 896 | COMMIT; |
897 | 897 | ||
@@ -902,3 +902,49 @@ BEGIN; | |||
902 | CREATE TABLE `regionextra` (`RegionID` char(36) not null, `Name` varchar(32) not null, `value` text, primary key(`RegionID`, `Name`)); | 902 | CREATE TABLE `regionextra` (`RegionID` char(36) not null, `Name` varchar(32) not null, `value` text, primary key(`RegionID`, `Name`)); |
903 | 903 | ||
904 | COMMIT; | 904 | COMMIT; |
905 | |||
906 | :VERSION 46 #---------------- Dynamic attributes | ||
907 | |||
908 | BEGIN; | ||
909 | |||
910 | ALTER TABLE prims ADD COLUMN DynAttrs TEXT; | ||
911 | |||
912 | COMMIT; | ||
913 | |||
914 | :VERSION 47 #---------------- Extra physics params | ||
915 | |||
916 | BEGIN; | ||
917 | |||
918 | ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0'; | ||
919 | ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000'; | ||
920 | ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1'; | ||
921 | ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6'; | ||
922 | ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5'; | ||
923 | |||
924 | COMMIT; | ||
925 | |||
926 | :VERSION 48 #---------------- Keyframes | ||
927 | |||
928 | BEGIN; | ||
929 | |||
930 | ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob; | ||
931 | |||
932 | COMMIT; | ||
933 | |||
934 | :VERSION 49 #--------------------- Save attachment info | ||
935 | |||
936 | BEGIN; | ||
937 | ALTER TABLE prims ADD COLUMN AttachedPosX double default 0; | ||
938 | ALTER TABLE prims ADD COLUMN AttachedPosY double default 0; | ||
939 | ALTER TABLE prims ADD COLUMN AttachedPosZ double default 0; | ||
940 | ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0'; | ||
941 | COMMIT; | ||
942 | |||
943 | :VERSION 50 #---- Change LandFlags to unsigned | ||
944 | |||
945 | BEGIN; | ||
946 | |||
947 | ALTER TABLE land CHANGE COLUMN LandFlags LandFlags int unsigned default null; | ||
948 | |||
949 | COMMIT; | ||
950 | |||
diff --git a/OpenSim/Data/MySQL/Resources/UserAccount.migrations b/OpenSim/Data/MySQL/Resources/UserAccount.migrations index 97e5e4f..84011e6 100644 --- a/OpenSim/Data/MySQL/Resources/UserAccount.migrations +++ b/OpenSim/Data/MySQL/Resources/UserAccount.migrations | |||
@@ -10,7 +10,7 @@ CREATE TABLE `UserAccounts` ( | |||
10 | `Email` VARCHAR(64), | 10 | `Email` VARCHAR(64), |
11 | `ServiceURLs` TEXT, | 11 | `ServiceURLs` TEXT, |
12 | `Created` INT(11) | 12 | `Created` INT(11) |
13 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 13 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
14 | 14 | ||
15 | COMMIT; | 15 | COMMIT; |
16 | 16 | ||
diff --git a/sql/osprofile.sql b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations index bcd5be0..87e99fa 100644 --- a/sql/osprofile.sql +++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations | |||
@@ -1,3 +1,7 @@ | |||
1 | :VERSION 1 # ------------------------------- | ||
2 | |||
3 | begin; | ||
4 | |||
1 | CREATE TABLE IF NOT EXISTS `classifieds` ( | 5 | CREATE TABLE IF NOT EXISTS `classifieds` ( |
2 | `classifieduuid` char(36) NOT NULL, | 6 | `classifieduuid` char(36) NOT NULL, |
3 | `creatoruuid` char(36) NOT NULL, | 7 | `creatoruuid` char(36) NOT NULL, |
@@ -15,7 +19,8 @@ CREATE TABLE IF NOT EXISTS `classifieds` ( | |||
15 | `classifiedflags` int(8) NOT NULL, | 19 | `classifiedflags` int(8) NOT NULL, |
16 | `priceforlisting` int(5) NOT NULL, | 20 | `priceforlisting` int(5) NOT NULL, |
17 | PRIMARY KEY (`classifieduuid`) | 21 | PRIMARY KEY (`classifieduuid`) |
18 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 22 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
23 | |||
19 | 24 | ||
20 | CREATE TABLE IF NOT EXISTS `usernotes` ( | 25 | CREATE TABLE IF NOT EXISTS `usernotes` ( |
21 | `useruuid` varchar(36) NOT NULL, | 26 | `useruuid` varchar(36) NOT NULL, |
@@ -24,6 +29,7 @@ CREATE TABLE IF NOT EXISTS `usernotes` ( | |||
24 | UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`) | 29 | UNIQUE KEY `useruuid` (`useruuid`,`targetuuid`) |
25 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 30 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
26 | 31 | ||
32 | |||
27 | CREATE TABLE IF NOT EXISTS `userpicks` ( | 33 | CREATE TABLE IF NOT EXISTS `userpicks` ( |
28 | `pickuuid` varchar(36) NOT NULL, | 34 | `pickuuid` varchar(36) NOT NULL, |
29 | `creatoruuid` varchar(36) NOT NULL, | 35 | `creatoruuid` varchar(36) NOT NULL, |
@@ -41,6 +47,7 @@ CREATE TABLE IF NOT EXISTS `userpicks` ( | |||
41 | PRIMARY KEY (`pickuuid`) | 47 | PRIMARY KEY (`pickuuid`) |
42 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 48 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
43 | 49 | ||
50 | |||
44 | CREATE TABLE IF NOT EXISTS `userprofile` ( | 51 | CREATE TABLE IF NOT EXISTS `userprofile` ( |
45 | `useruuid` varchar(36) NOT NULL, | 52 | `useruuid` varchar(36) NOT NULL, |
46 | `profilePartner` varchar(36) NOT NULL, | 53 | `profilePartner` varchar(36) NOT NULL, |
@@ -59,6 +66,23 @@ CREATE TABLE IF NOT EXISTS `userprofile` ( | |||
59 | PRIMARY KEY (`useruuid`) | 66 | PRIMARY KEY (`useruuid`) |
60 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 67 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
61 | 68 | ||
69 | commit; | ||
70 | |||
71 | :VERSION 2 # ------------------------------- | ||
72 | |||
73 | begin; | ||
74 | CREATE TABLE IF NOT EXISTS `userdata` ( | ||
75 | `UserId` char(36) NOT NULL, | ||
76 | `TagId` varchar(64) NOT NULL, | ||
77 | `DataKey` varchar(255), | ||
78 | `DataVal` varchar(255), | ||
79 | PRIMARY KEY (`UserId`,`TagId`) | ||
80 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | ||
81 | |||
82 | commit; | ||
83 | |||
84 | :VERSION 3 # ------------------------------- | ||
85 | begin; | ||
62 | CREATE TABLE IF NOT EXISTS `usersettings` ( | 86 | CREATE TABLE IF NOT EXISTS `usersettings` ( |
63 | `useruuid` varchar(36) NOT NULL, | 87 | `useruuid` varchar(36) NOT NULL, |
64 | `imviaemail` enum('true','false') NOT NULL, | 88 | `imviaemail` enum('true','false') NOT NULL, |
@@ -66,3 +90,9 @@ CREATE TABLE IF NOT EXISTS `usersettings` ( | |||
66 | `email` varchar(254) NOT NULL, | 90 | `email` varchar(254) NOT NULL, |
67 | PRIMARY KEY (`useruuid`) | 91 | PRIMARY KEY (`useruuid`) |
68 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | 92 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
93 | commit; | ||
94 | |||
95 | :VERSION 4 # ------------------------------- | ||
96 | begin; | ||
97 | ALTER TABLE userpicks ADD COLUMN gatekeeper varchar(255); | ||
98 | commit; | ||
diff --git a/OpenSim/Data/MySQL/Resources/UserStore.migrations b/OpenSim/Data/MySQL/Resources/UserStore.migrations index 9129075..f054611 100644 --- a/OpenSim/Data/MySQL/Resources/UserStore.migrations +++ b/OpenSim/Data/MySQL/Resources/UserStore.migrations | |||
@@ -21,7 +21,7 @@ CREATE TABLE `agents` ( | |||
21 | PRIMARY KEY (`UUID`), | 21 | PRIMARY KEY (`UUID`), |
22 | UNIQUE KEY `session` (`sessionID`), | 22 | UNIQUE KEY `session` (`sessionID`), |
23 | UNIQUE KEY `ssession` (`secureSessionID`) | 23 | UNIQUE KEY `ssession` (`secureSessionID`) |
24 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 24 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
25 | 25 | ||
26 | -- Create schema avatar_appearance | 26 | -- Create schema avatar_appearance |
27 | -- | 27 | -- |
@@ -59,7 +59,7 @@ CREATE TABLE `avatarappearance` ( | |||
59 | Skirt_Item char(36) NOT NULL, | 59 | Skirt_Item char(36) NOT NULL, |
60 | Skirt_Asset char(36) NOT NULL, | 60 | Skirt_Asset char(36) NOT NULL, |
61 | PRIMARY KEY (`Owner`) | 61 | PRIMARY KEY (`Owner`) |
62 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 62 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
63 | 63 | ||
64 | SET FOREIGN_KEY_CHECKS=0; | 64 | SET FOREIGN_KEY_CHECKS=0; |
65 | -- ---------------------------- | 65 | -- ---------------------------- |
@@ -71,7 +71,7 @@ CREATE TABLE `userfriends` ( | |||
71 | `friendPerms` INT NOT NULL, | 71 | `friendPerms` INT NOT NULL, |
72 | `datetimestamp` INT NOT NULL, | 72 | `datetimestamp` INT NOT NULL, |
73 | UNIQUE KEY (`ownerID`, `friendID`) | 73 | UNIQUE KEY (`ownerID`, `friendID`) |
74 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 74 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
75 | -- ---------------------------- | 75 | -- ---------------------------- |
76 | -- Table structure for users | 76 | -- Table structure for users |
77 | -- ---------------------------- | 77 | -- ---------------------------- |
@@ -101,7 +101,7 @@ CREATE TABLE `users` ( | |||
101 | `webLoginKey` varchar(36) default NULL, | 101 | `webLoginKey` varchar(36) default NULL, |
102 | PRIMARY KEY (`UUID`), | 102 | PRIMARY KEY (`UUID`), |
103 | UNIQUE KEY `usernames` (`username`,`lastname`) | 103 | UNIQUE KEY `usernames` (`username`,`lastname`) |
104 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | 104 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
105 | 105 | ||
106 | -- ---------------------------- | 106 | -- ---------------------------- |
107 | -- Records | 107 | -- Records |
@@ -138,7 +138,7 @@ COMMIT; | |||
138 | 138 | ||
139 | BEGIN; | 139 | BEGIN; |
140 | 140 | ||
141 | CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL, `attachpoint` int(11) NOT NULL, `item` char(36) NOT NULL, `asset` char(36) NOT NULL) ENGINE=MyISAM; | 141 | CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL, `attachpoint` int(11) NOT NULL, `item` char(36) NOT NULL, `asset` char(36) NOT NULL) ENGINE=InnoDB; |
142 | 142 | ||
143 | COMMIT; | 143 | COMMIT; |
144 | 144 | ||
diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations index bb58c39..9459e3e 100644 --- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations | |||
@@ -3,25 +3,30 @@ | |||
3 | 3 | ||
4 | BEGIN; | 4 | BEGIN; |
5 | 5 | ||
6 | CREATE TABLE `xassetsmeta` ( | 6 | CREATE TABLE `XAssetsMeta` ( |
7 | `id` char(36) NOT NULL, | 7 | `ID` char(36) NOT NULL, |
8 | `hash` binary(32) NOT NULL, | 8 | `Hash` binary(32) NOT NULL, |
9 | `name` varchar(64) NOT NULL, | 9 | `Name` varchar(64) NOT NULL, |
10 | `description` varchar(64) NOT NULL, | 10 | `Description` varchar(64) NOT NULL, |
11 | `asset_type` tinyint(4) NOT NULL, | 11 | `AssetType` tinyint(4) NOT NULL, |
12 | `local` tinyint(1) NOT NULL, | 12 | `Local` tinyint(1) NOT NULL, |
13 | `temporary` tinyint(1) NOT NULL, | 13 | `Temporary` tinyint(1) NOT NULL, |
14 | `create_time` int(11) NOT NULL, | 14 | `CreateTime` int(11) NOT NULL, |
15 | `access_time` int(11) NOT NULL, | 15 | `AccessTime` int(11) NOT NULL, |
16 | `asset_flags` int(11) NOT NULL, | 16 | `AssetFlags` int(11) NOT NULL, |
17 | `creator_id` varchar(128) NOT NULL, | 17 | `CreatorID` varchar(128) NOT NULL, |
18 | PRIMARY KEY (`id`) | 18 | PRIMARY KEY (`id`) |
19 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Version 1'; | 19 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; |
20 | 20 | ||
21 | CREATE TABLE `xassetsdata` ( | 21 | CREATE TABLE `XAssetsData` ( |
22 | `hash` binary(32) NOT NULL, | 22 | `Hash` binary(32) NOT NULL, |
23 | `data` longblob NOT NULL, | 23 | `Data` longblob NOT NULL, |
24 | PRIMARY KEY (`hash`) | 24 | PRIMARY KEY (`hash`) |
25 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Version 1'; | 25 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; |
26 | 26 | ||
27 | COMMIT; \ No newline at end of file | 27 | COMMIT; |
28 | |||
29 | :VERSION 2 | ||
30 | |||
31 | BEGIN; | ||
32 | COMMIT; | ||
diff --git a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations new file mode 100644 index 0000000..9e6f1c1 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations | |||
@@ -0,0 +1,115 @@ | |||
1 | :VERSION 1 # -------------------------- | ||
2 | |||
3 | BEGIN; | ||
4 | |||
5 | CREATE TABLE `os_groups_groups` ( | ||
6 | `GroupID` char(36) NOT NULL default '', | ||
7 | `Location` varchar(255) NOT NULL default '', | ||
8 | `Name` varchar(255) NOT NULL default '', | ||
9 | `Charter` text NOT NULL, | ||
10 | `InsigniaID` char(36) NOT NULL default '', | ||
11 | `FounderID` char(36) NOT NULL default '', | ||
12 | `MembershipFee` int(11) NOT NULL default '0', | ||
13 | `OpenEnrollment` varchar(255) NOT NULL default '', | ||
14 | `ShowInList` int(4) NOT NULL default '0', | ||
15 | `AllowPublish` int(4) NOT NULL default '0', | ||
16 | `MaturePublish` int(4) NOT NULL default '0', | ||
17 | `OwnerRoleID` char(36) NOT NULL default '', | ||
18 | PRIMARY KEY (`GroupID`), | ||
19 | UNIQUE KEY `Name` (`Name`), | ||
20 | FULLTEXT KEY `Name_2` (`Name`) | ||
21 | ) ENGINE=MyISAM; | ||
22 | |||
23 | |||
24 | CREATE TABLE `os_groups_membership` ( | ||
25 | `GroupID`char(36) NOT NULL default '', | ||
26 | `PrincipalID` VARCHAR(255) NOT NULL default '', | ||
27 | `SelectedRoleID` char(36) NOT NULL default '', | ||
28 | `Contribution` int(11) NOT NULL default '0', | ||
29 | `ListInProfile` int(4) NOT NULL default '1', | ||
30 | `AcceptNotices` int(4) NOT NULL default '1', | ||
31 | `AccessToken` char(36) NOT NULL default '', | ||
32 | PRIMARY KEY (`GroupID`,`PrincipalID`), | ||
33 | KEY `PrincipalID` (`PrincipalID`) | ||
34 | ) ENGINE=MyISAM; | ||
35 | |||
36 | |||
37 | CREATE TABLE `os_groups_roles` ( | ||
38 | `GroupID` char(36) NOT NULL default '', | ||
39 | `RoleID` char(36) NOT NULL default '', | ||
40 | `Name` varchar(255) NOT NULL default '', | ||
41 | `Description` varchar(255) NOT NULL default '', | ||
42 | `Title` varchar(255) NOT NULL default '', | ||
43 | `Powers` bigint(20) unsigned NOT NULL default '0', | ||
44 | PRIMARY KEY (`GroupID`,`RoleID`), | ||
45 | KEY `GroupID` (`GroupID`) | ||
46 | ) ENGINE=MyISAM; | ||
47 | |||
48 | |||
49 | CREATE TABLE `os_groups_rolemembership` ( | ||
50 | `GroupID` char(36) NOT NULL default '', | ||
51 | `RoleID` char(36) NOT NULL default '', | ||
52 | `PrincipalID` VARCHAR(255) NOT NULL default '', | ||
53 | PRIMARY KEY (`GroupID`,`RoleID`,`PrincipalID`), | ||
54 | KEY `PrincipalID` (`PrincipalID`) | ||
55 | ) ENGINE=MyISAM; | ||
56 | |||
57 | |||
58 | CREATE TABLE `os_groups_invites` ( | ||
59 | `InviteID` char(36) NOT NULL default '', | ||
60 | `GroupID` char(36) NOT NULL default '', | ||
61 | `RoleID` char(36) NOT NULL default '', | ||
62 | `PrincipalID` VARCHAR(255) NOT NULL default '', | ||
63 | `TMStamp` timestamp NOT NULL, | ||
64 | PRIMARY KEY (`InviteID`), | ||
65 | UNIQUE KEY `PrincipalGroup` (`GroupID`,`PrincipalID`) | ||
66 | ) ENGINE=MyISAM; | ||
67 | |||
68 | |||
69 | CREATE TABLE `os_groups_notices` ( | ||
70 | `GroupID` char(36) NOT NULL default '', | ||
71 | `NoticeID` char(36) NOT NULL default '', | ||
72 | `TMStamp` int(10) unsigned NOT NULL default '0', | ||
73 | `FromName` varchar(255) NOT NULL default '', | ||
74 | `Subject` varchar(255) NOT NULL default '', | ||
75 | `Message` text NOT NULL, | ||
76 | `HasAttachment` int(4) NOT NULL default '0', | ||
77 | `AttachmentType` int(4) NOT NULL default '0', | ||
78 | `AttachmentName` varchar(128) NOT NULL default '', | ||
79 | `AttachmentItemID` char(36) NOT NULL default '', | ||
80 | `AttachmentOwnerID` varchar(255) NOT NULL default '', | ||
81 | PRIMARY KEY (`NoticeID`), | ||
82 | KEY `GroupID` (`GroupID`), | ||
83 | KEY `TMStamp` (`TMStamp`) | ||
84 | ) ENGINE=MyISAM; | ||
85 | |||
86 | CREATE TABLE `os_groups_principals` ( | ||
87 | `PrincipalID` VARCHAR(255) NOT NULL default '', | ||
88 | `ActiveGroupID` char(36) NOT NULL default '', | ||
89 | PRIMARY KEY (`PrincipalID`) | ||
90 | ) ENGINE=MyISAM; | ||
91 | |||
92 | COMMIT; | ||
93 | |||
94 | :VERSION 2 # -------------------------- | ||
95 | |||
96 | BEGIN; | ||
97 | |||
98 | INSERT INTO `os_groups_groups` SELECT * from `diva_groups_groups`; | ||
99 | DROP TABLE `diva_groups_groups`; | ||
100 | INSERT INTO `os_groups_membership` SELECT * from `diva_groups_membership`; | ||
101 | DROP TABLE `diva_groups_membership`; | ||
102 | INSERT INTO `os_groups_roles` SELECT * from `diva_groups_roles`; | ||
103 | DROP TABLE `diva_groups_roles`; | ||
104 | INSERT INTO `os_groups_rolemembership` SELECT * from `diva_groups_rolemembership`; | ||
105 | DROP TABLE `diva_groups_rolemembership`; | ||
106 | INSERT INTO `os_groups_invites` SELECT * from `diva_groups_invites`; | ||
107 | DROP TABLE `diva_groups_invites`; | ||
108 | INSERT INTO `os_groups_notices` SELECT * from `diva_groups_notices`; | ||
109 | DROP TABLE `diva_groups_notices`; | ||
110 | INSERT INTO `os_groups_principals` SELECT * from `diva_groups_principals`; | ||
111 | DROP TABLE `diva_groups_principals`; | ||
112 | |||
113 | DELETE FROM `migrations` WHERE name='diva_im_Store'; | ||
114 | |||
115 | COMMIT; \ No newline at end of file | ||