diff options
Diffstat (limited to 'OpenSim/Data/MySQL')
19 files changed, 1269 insertions, 728 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs b/OpenSim/Data/MySQL/MySQLAgentPreferencesData.cs new file mode 100644 index 0000000..17f1374 --- /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 59cc22a..cb5a38e 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,47 +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( | 142 | { |
146 | string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); | 143 | m_log.Error( |
147 | } | 144 | string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); |
148 | } | 145 | } |
149 | } | 146 | } |
150 | } | 147 | } |
148 | |||
151 | return asset; | 149 | return asset; |
152 | } | 150 | } |
153 | 151 | ||
@@ -158,25 +156,52 @@ namespace OpenSim.Data.MySQL | |||
158 | /// <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> |
159 | override public bool StoreAsset(AssetBase asset) | 157 | override public bool StoreAsset(AssetBase asset) |
160 | { | 158 | { |
161 | lock (m_dbLock) | 159 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
162 | { | 160 | { |
163 | 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)) | ||
164 | { | 168 | { |
165 | 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 | } | ||
166 | 177 | ||
167 | using (MySqlCommand cmd = | 178 | string assetDescription = asset.Description; |
168 | new MySqlCommand( | 179 | if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) |
169 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + | ||
170 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", | ||
171 | dbcon)) | ||
172 | { | 180 | { |
173 | string assetName = asset.Name; | 181 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); |
174 | if (asset.Name.Length > 64) | 182 | m_log.WarnFormat( |
183 | "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", | ||
184 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); | ||
185 | } | ||
186 | |||
187 | try | ||
188 | { | ||
189 | using (cmd) | ||
175 | { | 190 | { |
176 | assetName = asset.Name.Substring(0, 64); | 191 | // create unix epoch time |
177 | m_log.WarnFormat( | 192 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
178 | "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", | 193 | cmd.Parameters.AddWithValue("?id", asset.ID); |
179 | asset.Name, asset.ID, asset.Name.Length, assetName.Length); | 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(); | ||
180 | } | 205 | } |
181 | 206 | ||
182 | string assetDescription = asset.Description; | 207 | string assetDescription = asset.Description; |
@@ -216,86 +241,86 @@ namespace OpenSim.Data.MySQL | |||
216 | return false; | 241 | return false; |
217 | } | 242 | } |
218 | } | 243 | } |
244 | catch (Exception e) | ||
245 | { | ||
246 | m_log.Error( | ||
247 | string.Format( | ||
248 | "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", | ||
249 | asset.FullID, asset.Name) | ||
250 | , e); | ||
251 | } | ||
219 | } | 252 | } |
220 | } | 253 | } |
221 | } | 254 | } |
222 | 255 | ||
223 | private void UpdateAccessTime(AssetBase asset) | 256 | private void UpdateAccessTime(AssetBase asset) |
224 | { | 257 | { |
225 | lock (m_dbLock) | 258 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
226 | { | 259 | { |
227 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 260 | dbcon.Open(); |
228 | { | ||
229 | dbcon.Open(); | ||
230 | 261 | ||
231 | using (MySqlCommand cmd | 262 | using (MySqlCommand cmd |
232 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) | 263 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) |
264 | { | ||
265 | try | ||
233 | { | 266 | { |
234 | try | 267 | using (cmd) |
235 | { | 268 | { |
236 | using (cmd) | 269 | // create unix epoch time |
237 | { | 270 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
238 | // create unix epoch time | 271 | cmd.Parameters.AddWithValue("?id", asset.ID); |
239 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 272 | cmd.Parameters.AddWithValue("?access_time", now); |
240 | cmd.Parameters.AddWithValue("?id", asset.ID); | 273 | cmd.ExecuteNonQuery(); |
241 | cmd.Parameters.AddWithValue("?access_time", now); | ||
242 | cmd.ExecuteNonQuery(); | ||
243 | } | ||
244 | } | ||
245 | catch (Exception e) | ||
246 | { | ||
247 | m_log.Error( | ||
248 | string.Format( | ||
249 | "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", | ||
250 | asset.FullID, asset.Name), | ||
251 | e); | ||
252 | } | 274 | } |
253 | } | 275 | } |
276 | catch (Exception e) | ||
277 | { | ||
278 | m_log.Error( | ||
279 | string.Format( | ||
280 | "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", | ||
281 | asset.FullID, asset.Name), | ||
282 | e); | ||
283 | } | ||
254 | } | 284 | } |
255 | } | 285 | } |
256 | } | 286 | } |
257 | 287 | ||
258 | /// <summary> | 288 | /// <summary> |
259 | /// Check if the asset exists in the database | 289 | /// Check if the assets exist in the database. |
260 | /// </summary> | 290 | /// </summary> |
261 | /// <param name="uuid">The asset UUID</param> | 291 | /// <param name="uuidss">The assets' IDs</param> |
262 | /// <returns>true if it exists, false otherwise.</returns> | 292 | /// <returns>For each asset: true if it exists, false otherwise</returns> |
263 | override public bool ExistsAsset(UUID uuid) | 293 | public override bool[] AssetsExist(UUID[] uuids) |
264 | { | 294 | { |
265 | // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); | 295 | if (uuids.Length == 0) |
296 | return new bool[0]; | ||
297 | |||
298 | HashSet<UUID> exist = new HashSet<UUID>(); | ||
266 | 299 | ||
267 | bool assetExists = false; | 300 | string ids = "'" + string.Join("','", uuids) + "'"; |
301 | string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids); | ||
268 | 302 | ||
269 | lock (m_dbLock) | 303 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
270 | { | 304 | { |
271 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 305 | dbcon.Open(); |
306 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
272 | { | 307 | { |
273 | dbcon.Open(); | 308 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
274 | using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon)) | ||
275 | { | 309 | { |
276 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); | 310 | while (dbReader.Read()) |
277 | |||
278 | try | ||
279 | { | 311 | { |
280 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 312 | UUID id = DBGuid.FromDB(dbReader["id"]); |
281 | { | 313 | exist.Add(id); |
282 | if (dbReader.Read()) | ||
283 | { | ||
284 | // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); | ||
285 | assetExists = true; | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | catch (Exception e) | ||
290 | { | ||
291 | m_log.Error( | ||
292 | string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", uuid), e); | ||
293 | } | 314 | } |
294 | } | 315 | } |
295 | } | 316 | } |
296 | } | 317 | } |
297 | 318 | ||
298 | return assetExists; | 319 | bool[] results = new bool[uuids.Length]; |
320 | for (int i = 0; i < uuids.Length; i++) | ||
321 | results[i] = exist.Contains(uuids[i]); | ||
322 | |||
323 | return results; | ||
299 | } | 324 | } |
300 | 325 | ||
301 | /// <summary> | 326 | /// <summary> |
@@ -310,50 +335,47 @@ namespace OpenSim.Data.MySQL | |||
310 | { | 335 | { |
311 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 336 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
312 | 337 | ||
313 | lock (m_dbLock) | 338 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
314 | { | 339 | { |
315 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 340 | dbcon.Open(); |
341 | |||
342 | using (MySqlCommand cmd | ||
343 | = new MySqlCommand( | ||
344 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
345 | dbcon)) | ||
316 | { | 346 | { |
317 | dbcon.Open(); | 347 | cmd.Parameters.AddWithValue("?start", start); |
348 | cmd.Parameters.AddWithValue("?count", count); | ||
318 | 349 | ||
319 | using (MySqlCommand cmd | 350 | try |
320 | = new MySqlCommand( | ||
321 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
322 | dbcon)) | ||
323 | { | 351 | { |
324 | cmd.Parameters.AddWithValue("?start", start); | 352 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
325 | cmd.Parameters.AddWithValue("?count", count); | ||
326 | |||
327 | try | ||
328 | { | 353 | { |
329 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 354 | while (dbReader.Read()) |
330 | { | 355 | { |
331 | while (dbReader.Read()) | 356 | AssetMetadata metadata = new AssetMetadata(); |
332 | { | 357 | metadata.Name = (string)dbReader["name"]; |
333 | AssetMetadata metadata = new AssetMetadata(); | 358 | metadata.Description = (string)dbReader["description"]; |
334 | metadata.Name = (string)dbReader["name"]; | 359 | metadata.Type = (sbyte)dbReader["assetType"]; |
335 | metadata.Description = (string)dbReader["description"]; | 360 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. |
336 | metadata.Type = (sbyte)dbReader["assetType"]; | 361 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); |
337 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | 362 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); |
338 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 363 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
339 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 364 | |
340 | metadata.CreatorID = dbReader["CreatorID"].ToString(); | 365 | // Current SHA1s are not stored/computed. |
341 | 366 | metadata.SHA1 = new byte[] { }; | |
342 | // Current SHA1s are not stored/computed. | 367 | |
343 | metadata.SHA1 = new byte[] { }; | 368 | retList.Add(metadata); |
344 | |||
345 | retList.Add(metadata); | ||
346 | } | ||
347 | } | 369 | } |
348 | } | 370 | } |
349 | catch (Exception e) | 371 | } |
350 | { | 372 | catch (Exception e) |
351 | m_log.Error( | 373 | { |
352 | string.Format( | 374 | m_log.Error( |
353 | "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", | 375 | string.Format( |
354 | start, count), | 376 | "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", |
355 | e); | 377 | start, count), |
356 | } | 378 | e); |
357 | } | 379 | } |
358 | } | 380 | } |
359 | } | 381 | } |
@@ -363,17 +385,14 @@ namespace OpenSim.Data.MySQL | |||
363 | 385 | ||
364 | public override bool Delete(string id) | 386 | public override bool Delete(string id) |
365 | { | 387 | { |
366 | lock (m_dbLock) | 388 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
367 | { | 389 | { |
368 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 390 | dbcon.Open(); |
369 | { | ||
370 | dbcon.Open(); | ||
371 | 391 | ||
372 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) | 392 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) |
373 | { | 393 | { |
374 | cmd.Parameters.AddWithValue("?id", id); | 394 | cmd.Parameters.AddWithValue("?id", id); |
375 | cmd.ExecuteNonQuery(); | 395 | cmd.ExecuteNonQuery(); |
376 | } | ||
377 | } | 396 | } |
378 | } | 397 | } |
379 | 398 | ||
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 04f3316..a522912 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -60,8 +60,12 @@ namespace OpenSim.Data.MySQL | |||
60 | protected int ExecuteNonQuery(MySqlCommand cmd) | 60 | protected int ExecuteNonQuery(MySqlCommand cmd) |
61 | { | 61 | { |
62 | lock (m_dbLock) | 62 | lock (m_dbLock) |
63 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
63 | { | 64 | { |
64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 65 | dbcon.Open(); |
66 | cmd.Connection = dbcon; | ||
67 | |||
68 | try | ||
65 | { | 69 | { |
66 | dbcon.Open(); | 70 | dbcon.Open(); |
67 | cmd.Connection = dbcon; | 71 | cmd.Connection = dbcon; |
@@ -77,7 +81,12 @@ namespace OpenSim.Data.MySQL | |||
77 | return 0; | 81 | return 0; |
78 | } | 82 | } |
79 | } | 83 | } |
84 | catch (Exception e) | ||
85 | { | ||
86 | m_log.Error(e.Message, e); | ||
87 | return 0; | ||
88 | } | ||
80 | } | 89 | } |
81 | } | 90 | } |
82 | } | 91 | } |
83 | } | 92 | } \ 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/MySQLGroupsData.cs b/OpenSim/Data/MySQL/MySQLGroupsData.cs index 0318284..afa499e 100644 --- a/OpenSim/Data/MySQL/MySQLGroupsData.cs +++ b/OpenSim/Data/MySQL/MySQLGroupsData.cs | |||
@@ -86,11 +86,11 @@ namespace OpenSim.Data.MySQL | |||
86 | public GroupData[] RetrieveGroups(string pattern) | 86 | public GroupData[] RetrieveGroups(string pattern) |
87 | { | 87 | { |
88 | if (string.IsNullOrEmpty(pattern)) | 88 | if (string.IsNullOrEmpty(pattern)) |
89 | pattern = "1 ORDER BY Name LIMIT 100"; | 89 | pattern = "1"; |
90 | else | 90 | else |
91 | pattern = string.Format("Name LIKE '%{0}%' ORDER BY Name LIMIT 100", pattern); | 91 | pattern = string.Format("Name LIKE '%{0}%'", MySqlHelper.EscapeString(pattern)); |
92 | 92 | ||
93 | return m_Groups.Get(pattern); | 93 | return m_Groups.Get(string.Format("ShowInList=1 AND ({0}) ORDER BY Name LIMIT 100", pattern)); |
94 | } | 94 | } |
95 | 95 | ||
96 | public bool DeleteGroup(UUID groupID) | 96 | public bool DeleteGroup(UUID groupID) |
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 851fbc2..81b5ec4 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -722,7 +722,7 @@ namespace OpenSim.Data.MySQL | |||
722 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + | 722 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + |
723 | "UserLocationX, UserLocationY, UserLocationZ, " + | 723 | "UserLocationX, UserLocationY, UserLocationZ, " + |
724 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + | 724 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + |
725 | "AuthbuyerID, OtherCleanTime, MediaType, MediaDescription, " + | 725 | "AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " + |
726 | "MediaSize, MediaLoop, ObscureMusic, ObscureMedia, " + | 726 | "MediaSize, MediaLoop, ObscureMusic, ObscureMedia, " + |
727 | "SeeAVs, AnyAVSounds, GroupAVSounds) values (" + | 727 | "SeeAVs, AnyAVSounds, GroupAVSounds) values (" + |
728 | "?UUID, ?RegionUUID, " + | 728 | "?UUID, ?RegionUUID, " + |
@@ -734,7 +734,7 @@ namespace OpenSim.Data.MySQL | |||
734 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + | 734 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + |
735 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + | 735 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + |
736 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + | 736 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + |
737 | "?AuthbuyerID, ?OtherCleanTime, ?MediaType, ?MediaDescription, "+ | 737 | "?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+ |
738 | "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia, " + | 738 | "CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia, " + |
739 | "?SeeAVs, ?AnyAVSounds, ?GroupAVSounds)"; | 739 | "?SeeAVs, ?AnyAVSounds, ?GroupAVSounds)"; |
740 | 740 | ||
@@ -767,95 +767,92 @@ namespace OpenSim.Data.MySQL | |||
767 | RegionLightShareData nWP = new RegionLightShareData(); | 767 | RegionLightShareData nWP = new RegionLightShareData(); |
768 | nWP.OnSave += StoreRegionWindlightSettings; | 768 | nWP.OnSave += StoreRegionWindlightSettings; |
769 | 769 | ||
770 | lock (m_dbLock) | 770 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
771 | { | 771 | { |
772 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 772 | dbcon.Open(); |
773 | |||
774 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | ||
775 | |||
776 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
773 | { | 777 | { |
774 | dbcon.Open(); | 778 | cmd.Connection = dbcon; |
775 | 779 | ||
776 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | 780 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); |
777 | 781 | ||
778 | using (MySqlCommand cmd = new MySqlCommand(command)) | 782 | IDataReader result = ExecuteReader(cmd); |
783 | if (!result.Read()) | ||
779 | { | 784 | { |
780 | cmd.Connection = dbcon; | 785 | //No result, so store our default windlight profile and return it |
781 | 786 | nWP.regionID = regionUUID; | |
782 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); | ||
783 | |||
784 | IDataReader result = ExecuteReader(cmd); | ||
785 | if (!result.Read()) | ||
786 | { | ||
787 | //No result, so store our default windlight profile and return it | ||
788 | nWP.regionID = regionUUID; | ||
789 | // StoreRegionWindlightSettings(nWP); | 787 | // StoreRegionWindlightSettings(nWP); |
790 | return nWP; | 788 | return nWP; |
791 | } | 789 | } |
792 | else | 790 | else |
793 | { | 791 | { |
794 | nWP.regionID = DBGuid.FromDB(result["region_id"]); | 792 | nWP.regionID = DBGuid.FromDB(result["region_id"]); |
795 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); | 793 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); |
796 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); | 794 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); |
797 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); | 795 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); |
798 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); | 796 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); |
799 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); | 797 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); |
800 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); | 798 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); |
801 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); | 799 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); |
802 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); | 800 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); |
803 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); | 801 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); |
804 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); | 802 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); |
805 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); | 803 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); |
806 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); | 804 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); |
807 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); | 805 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); |
808 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); | 806 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); |
809 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); | 807 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); |
810 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); | 808 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); |
811 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); | 809 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); |
812 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); | 810 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); |
813 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); | 811 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); |
814 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); | 812 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); |
815 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); | 813 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); |
816 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); | 814 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); |
817 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); | 815 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); |
818 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); | 816 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); |
819 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); | 817 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); |
820 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); | 818 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); |
821 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); | 819 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); |
822 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); | 820 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); |
823 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); | 821 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); |
824 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); | 822 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); |
825 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); | 823 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); |
826 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); | 824 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); |
827 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); | 825 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); |
828 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); | 826 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); |
829 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); | 827 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); |
830 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); | 828 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); |
831 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); | 829 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); |
832 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); | 830 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); |
833 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); | 831 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); |
834 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); | 832 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); |
835 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); | 833 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); |
836 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); | 834 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); |
837 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); | 835 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); |
838 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); | 836 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); |
839 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); | 837 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); |
840 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); | 838 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); |
841 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); | 839 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); |
842 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); | 840 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); |
843 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); | 841 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); |
844 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); | 842 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); |
845 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); | 843 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); |
846 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); | 844 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); |
847 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); | 845 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); |
848 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); | 846 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); |
849 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); | 847 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); |
850 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); | 848 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); |
851 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); | 849 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); |
852 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); | 850 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); |
853 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); | 851 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); |
854 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); | 852 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); |
855 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); | 853 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); |
856 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); | 854 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); |
857 | nWP.valid = true; | 855 | nWP.valid = true; |
858 | } | ||
859 | } | 856 | } |
860 | } | 857 | } |
861 | } | 858 | } |
@@ -905,124 +902,118 @@ namespace OpenSim.Data.MySQL | |||
905 | 902 | ||
906 | public virtual void StoreRegionWindlightSettings(RegionLightShareData wl) | 903 | public virtual void StoreRegionWindlightSettings(RegionLightShareData wl) |
907 | { | 904 | { |
908 | lock (m_dbLock) | 905 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
909 | { | 906 | { |
910 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 907 | dbcon.Open(); |
908 | |||
909 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
911 | { | 910 | { |
912 | dbcon.Open(); | 911 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; |
913 | 912 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | |
914 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 913 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; |
915 | { | 914 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; |
916 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; | 915 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; |
917 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | 916 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; |
918 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; | 917 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; |
919 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; | 918 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; |
920 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; | 919 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; |
921 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; | 920 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; |
922 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; | 921 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; |
923 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; | 922 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; |
924 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; | 923 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; |
925 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; | 924 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; |
926 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; | 925 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; |
927 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; | 926 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; |
928 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; | 927 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; |
929 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; | 928 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; |
930 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; | 929 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; |
931 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; | 930 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; |
932 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; | 931 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; |
933 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; | 932 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; |
934 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; | 933 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; |
935 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; | 934 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; |
936 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; | 935 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; |
937 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; | 936 | |
938 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; | 937 | cmd.Parameters.AddWithValue("region_id", wl.regionID); |
939 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; | 938 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); |
940 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; | 939 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); |
941 | 940 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | |
942 | cmd.Parameters.AddWithValue("region_id", wl.regionID); | 941 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); |
943 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); | 942 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); |
944 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); | 943 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); |
945 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | 944 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); |
946 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); | 945 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); |
947 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); | 946 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); |
948 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); | 947 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); |
949 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); | 948 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); |
950 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); | 949 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); |
951 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); | 950 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); |
952 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); | 951 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); |
953 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); | 952 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); |
954 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); | 953 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); |
955 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); | 954 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); |
956 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); | 955 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); |
957 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); | 956 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); |
958 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); | 957 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); |
959 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); | 958 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); |
960 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); | 959 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); |
961 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); | 960 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); |
962 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); | 961 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); |
963 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); | 962 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); |
964 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); | 963 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); |
965 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); | 964 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); |
966 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); | 965 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); |
967 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); | 966 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); |
968 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); | 967 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); |
969 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); | 968 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); |
970 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); | 969 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); |
971 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); | 970 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); |
972 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); | 971 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); |
973 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); | 972 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); |
974 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); | 973 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); |
975 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); | 974 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); |
976 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); | 975 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); |
977 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); | 976 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); |
978 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); | 977 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); |
979 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); | 978 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); |
980 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); | 979 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); |
981 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); | 980 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); |
982 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); | 981 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); |
983 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); | 982 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); |
984 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); | 983 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); |
985 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); | 984 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); |
986 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); | 985 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); |
987 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); | 986 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); |
988 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); | 987 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); |
989 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); | 988 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); |
990 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); | 989 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); |
991 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); | 990 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); |
992 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); | 991 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); |
993 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); | 992 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); |
994 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); | 993 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); |
995 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); | 994 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); |
996 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); | 995 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); |
997 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); | 996 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); |
998 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); | 997 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); |
999 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); | 998 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); |
1000 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); | 999 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); |
1001 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); | 1000 | |
1002 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); | 1001 | ExecuteNonQuery(cmd); |
1003 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); | ||
1004 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); | ||
1005 | |||
1006 | ExecuteNonQuery(cmd); | ||
1007 | } | ||
1008 | } | 1002 | } |
1009 | } | 1003 | } |
1010 | } | 1004 | } |
1011 | 1005 | ||
1012 | public virtual void RemoveRegionWindlightSettings(UUID regionID) | 1006 | public virtual void RemoveRegionWindlightSettings(UUID regionID) |
1013 | { | 1007 | { |
1014 | lock (m_dbLock) | 1008 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1015 | { | 1009 | { |
1016 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1010 | dbcon.Open(); |
1011 | |||
1012 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1017 | { | 1013 | { |
1018 | dbcon.Open(); | 1014 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; |
1019 | 1015 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | |
1020 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1016 | ExecuteNonQuery(cmd); |
1021 | { | ||
1022 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; | ||
1023 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | ||
1024 | ExecuteNonQuery(cmd); | ||
1025 | } | ||
1026 | } | 1017 | } |
1027 | } | 1018 | } |
1028 | } | 1019 | } |
@@ -1030,29 +1021,26 @@ namespace OpenSim.Data.MySQL | |||
1030 | #region RegionEnvironmentSettings | 1021 | #region RegionEnvironmentSettings |
1031 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 1022 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
1032 | { | 1023 | { |
1033 | lock (m_dbLock) | 1024 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1034 | { | 1025 | { |
1035 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1026 | dbcon.Open(); |
1027 | |||
1028 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | ||
1029 | |||
1030 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
1036 | { | 1031 | { |
1037 | dbcon.Open(); | 1032 | cmd.Connection = dbcon; |
1038 | 1033 | ||
1039 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | 1034 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); |
1040 | 1035 | ||
1041 | using (MySqlCommand cmd = new MySqlCommand(command)) | 1036 | IDataReader result = ExecuteReader(cmd); |
1037 | if (!result.Read()) | ||
1042 | { | 1038 | { |
1043 | cmd.Connection = dbcon; | 1039 | return String.Empty; |
1044 | 1040 | } | |
1045 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | 1041 | else |
1046 | 1042 | { | |
1047 | IDataReader result = ExecuteReader(cmd); | 1043 | return Convert.ToString(result["llsd_settings"]); |
1048 | if (!result.Read()) | ||
1049 | { | ||
1050 | return String.Empty; | ||
1051 | } | ||
1052 | else | ||
1053 | { | ||
1054 | return Convert.ToString(result["llsd_settings"]); | ||
1055 | } | ||
1056 | } | 1044 | } |
1057 | } | 1045 | } |
1058 | } | 1046 | } |
@@ -1060,39 +1048,33 @@ namespace OpenSim.Data.MySQL | |||
1060 | 1048 | ||
1061 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 1049 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
1062 | { | 1050 | { |
1063 | lock (m_dbLock) | 1051 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1064 | { | 1052 | { |
1065 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1053 | dbcon.Open(); |
1054 | |||
1055 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1066 | { | 1056 | { |
1067 | dbcon.Open(); | 1057 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; |
1068 | 1058 | ||
1069 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1059 | cmd.Parameters.AddWithValue("region_id", regionUUID); |
1070 | { | 1060 | cmd.Parameters.AddWithValue("llsd_settings", settings); |
1071 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; | 1061 | |
1072 | 1062 | ExecuteNonQuery(cmd); | |
1073 | cmd.Parameters.AddWithValue("region_id", regionUUID); | ||
1074 | cmd.Parameters.AddWithValue("llsd_settings", settings); | ||
1075 | |||
1076 | ExecuteNonQuery(cmd); | ||
1077 | } | ||
1078 | } | 1063 | } |
1079 | } | 1064 | } |
1080 | } | 1065 | } |
1081 | 1066 | ||
1082 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 1067 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
1083 | { | 1068 | { |
1084 | lock (m_dbLock) | 1069 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1085 | { | 1070 | { |
1086 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1071 | dbcon.Open(); |
1072 | |||
1073 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1087 | { | 1074 | { |
1088 | dbcon.Open(); | 1075 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; |
1089 | 1076 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | |
1090 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1077 | ExecuteNonQuery(cmd); |
1091 | { | ||
1092 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; | ||
1093 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | ||
1094 | ExecuteNonQuery(cmd); | ||
1095 | } | ||
1096 | } | 1078 | } |
1097 | } | 1079 | } |
1098 | } | 1080 | } |
@@ -1100,11 +1082,48 @@ namespace OpenSim.Data.MySQL | |||
1100 | 1082 | ||
1101 | public virtual void StoreRegionSettings(RegionSettings rs) | 1083 | public virtual void StoreRegionSettings(RegionSettings rs) |
1102 | { | 1084 | { |
1103 | lock (m_dbLock) | 1085 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1104 | { | 1086 | { |
1105 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1087 | dbcon.Open(); |
1088 | |||
1089 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1106 | { | 1090 | { |
1107 | dbcon.Open(); | 1091 | cmd.CommandText = "replace into regionsettings (regionUUID, " + |
1092 | "block_terraform, block_fly, allow_damage, " + | ||
1093 | "restrict_pushing, allow_land_resell, " + | ||
1094 | "allow_land_join_divide, block_show_in_search, " + | ||
1095 | "agent_limit, object_bonus, maturity, " + | ||
1096 | "disable_scripts, disable_collisions, " + | ||
1097 | "disable_physics, terrain_texture_1, " + | ||
1098 | "terrain_texture_2, terrain_texture_3, " + | ||
1099 | "terrain_texture_4, elevation_1_nw, " + | ||
1100 | "elevation_2_nw, elevation_1_ne, " + | ||
1101 | "elevation_2_ne, elevation_1_se, " + | ||
1102 | "elevation_2_se, elevation_1_sw, " + | ||
1103 | "elevation_2_sw, water_height, " + | ||
1104 | "terrain_raise_limit, terrain_lower_limit, " + | ||
1105 | "use_estate_sun, fixed_sun, sun_position, " + | ||
1106 | "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + | ||
1107 | "sunvectorz, loaded_creation_datetime, " + | ||
1108 | "loaded_creation_id, map_tile_ID, " + | ||
1109 | "TelehubObject, parcel_tile_ID) " + | ||
1110 | "values (?RegionUUID, ?BlockTerraform, " + | ||
1111 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | ||
1112 | "?AllowLandResell, ?AllowLandJoinDivide, " + | ||
1113 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | ||
1114 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + | ||
1115 | "?DisablePhysics, ?TerrainTexture1, " + | ||
1116 | "?TerrainTexture2, ?TerrainTexture3, " + | ||
1117 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + | ||
1118 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + | ||
1119 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + | ||
1120 | "?WaterHeight, ?TerrainRaiseLimit, " + | ||
1121 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | ||
1122 | "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + | ||
1123 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | ||
1124 | "?LoadedCreationDateTime, ?LoadedCreationID, " + | ||
1125 | "?TerrainImageID, " + | ||
1126 | "?TelehubObject, ?ParcelImageID)"; | ||
1108 | 1127 | ||
1109 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1128 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1110 | { | 1129 | { |
@@ -1145,12 +1164,10 @@ namespace OpenSim.Data.MySQL | |||
1145 | "?TerrainImageID, ?block_search, ?casino, " + | 1164 | "?TerrainImageID, ?block_search, ?casino, " + |
1146 | "?TelehubObject, ?ParcelImageID)"; | 1165 | "?TelehubObject, ?ParcelImageID)"; |
1147 | 1166 | ||
1148 | FillRegionSettingsCommand(cmd, rs); | 1167 | ExecuteNonQuery(cmd); |
1149 | |||
1150 | ExecuteNonQuery(cmd); | ||
1151 | } | ||
1152 | } | 1168 | } |
1153 | } | 1169 | } |
1170 | |||
1154 | SaveSpawnPoints(rs); | 1171 | SaveSpawnPoints(rs); |
1155 | } | 1172 | } |
1156 | 1173 | ||
@@ -1534,6 +1551,7 @@ namespace OpenSim.Data.MySQL | |||
1534 | UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); | 1551 | UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer); |
1535 | UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); | 1552 | UUID.TryParse((string)row["SnapshotUUID"], out snapshotID); |
1536 | newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); | 1553 | newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); |
1554 | newData.Dwell = Convert.ToSingle(row["Dwell"]); | ||
1537 | 1555 | ||
1538 | newData.AuthBuyerID = authedbuyer; | 1556 | newData.AuthBuyerID = authedbuyer; |
1539 | newData.SnapshotID = snapshotID; | 1557 | newData.SnapshotID = snapshotID; |
@@ -1912,6 +1930,7 @@ namespace OpenSim.Data.MySQL | |||
1912 | cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); | 1930 | cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z); |
1913 | cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); | 1931 | cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID); |
1914 | cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); | 1932 | cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime); |
1933 | cmd.Parameters.AddWithValue("Dwell", land.Dwell); | ||
1915 | cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); | 1934 | cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription); |
1916 | cmd.Parameters.AddWithValue("MediaType", land.MediaType); | 1935 | cmd.Parameters.AddWithValue("MediaType", land.MediaType); |
1917 | cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); | 1936 | cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth); |
@@ -2173,41 +2192,35 @@ namespace OpenSim.Data.MySQL | |||
2173 | 2192 | ||
2174 | public void SaveExtra(UUID regionID, string name, string val) | 2193 | public void SaveExtra(UUID regionID, string name, string val) |
2175 | { | 2194 | { |
2176 | lock (m_dbLock) | 2195 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2177 | { | 2196 | { |
2178 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2197 | dbcon.Open(); |
2179 | { | ||
2180 | dbcon.Open(); | ||
2181 | 2198 | ||
2182 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2199 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2183 | { | 2200 | { |
2184 | cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; | 2201 | cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; |
2185 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 2202 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
2186 | cmd.Parameters.AddWithValue("?Name", name); | 2203 | cmd.Parameters.AddWithValue("?Name", name); |
2187 | cmd.Parameters.AddWithValue("?value", val); | 2204 | cmd.Parameters.AddWithValue("?value", val); |
2188 | 2205 | ||
2189 | cmd.ExecuteNonQuery(); | 2206 | cmd.ExecuteNonQuery(); |
2190 | } | ||
2191 | } | 2207 | } |
2192 | } | 2208 | } |
2193 | } | 2209 | } |
2194 | 2210 | ||
2195 | public void RemoveExtra(UUID regionID, string name) | 2211 | public void RemoveExtra(UUID regionID, string name) |
2196 | { | 2212 | { |
2197 | lock (m_dbLock) | 2213 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2198 | { | 2214 | { |
2199 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2215 | dbcon.Open(); |
2200 | { | ||
2201 | dbcon.Open(); | ||
2202 | 2216 | ||
2203 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2217 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2204 | { | 2218 | { |
2205 | cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; | 2219 | cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; |
2206 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 2220 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
2207 | cmd.Parameters.AddWithValue("?Name", name); | 2221 | cmd.Parameters.AddWithValue("?Name", name); |
2208 | 2222 | ||
2209 | cmd.ExecuteNonQuery(); | 2223 | cmd.ExecuteNonQuery(); |
2210 | } | ||
2211 | } | 2224 | } |
2212 | } | 2225 | } |
2213 | } | 2226 | } |
@@ -2216,22 +2229,19 @@ namespace OpenSim.Data.MySQL | |||
2216 | { | 2229 | { |
2217 | Dictionary<string, string> ret = new Dictionary<string, string>(); | 2230 | Dictionary<string, string> ret = new Dictionary<string, string>(); |
2218 | 2231 | ||
2219 | lock (m_dbLock) | 2232 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2220 | { | 2233 | { |
2221 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2234 | dbcon.Open(); |
2222 | { | ||
2223 | dbcon.Open(); | ||
2224 | 2235 | ||
2225 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2236 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2237 | { | ||
2238 | cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; | ||
2239 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
2240 | using (IDataReader r = cmd.ExecuteReader()) | ||
2226 | { | 2241 | { |
2227 | cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; | 2242 | while (r.Read()) |
2228 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
2229 | using (IDataReader r = cmd.ExecuteReader()) | ||
2230 | { | 2243 | { |
2231 | while (r.Read()) | 2244 | ret[r["Name"].ToString()] = r["value"].ToString(); |
2232 | { | ||
2233 | ret[r["Name"].ToString()] = r["value"].ToString(); | ||
2234 | } | ||
2235 | } | 2245 | } |
2236 | } | 2246 | } |
2237 | } | 2247 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 8b50c54..c213dd1 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -46,11 +46,6 @@ namespace OpenSim.Data.MySQL | |||
46 | { | 46 | { |
47 | get; set; | 47 | get; set; |
48 | } | 48 | } |
49 | |||
50 | protected object Lock | ||
51 | { | ||
52 | get; set; | ||
53 | } | ||
54 | 49 | ||
55 | protected virtual Assembly Assembly | 50 | protected virtual Assembly Assembly |
56 | { | 51 | { |
@@ -116,7 +111,7 @@ namespace OpenSim.Data.MySQL | |||
116 | } | 111 | } |
117 | catch (Exception e) | 112 | catch (Exception e) |
118 | { | 113 | { |
119 | m_log.DebugFormat("[PROFILES_DATA]" + | 114 | m_log.ErrorFormat("[PROFILES_DATA]" + |
120 | ": UserAccount exception {0}", e.Message); | 115 | ": UserAccount exception {0}", e.Message); |
121 | } | 116 | } |
122 | n.Add("classifieduuid", OSD.FromUUID(Id)); | 117 | n.Add("classifieduuid", OSD.FromUUID(Id)); |
@@ -237,7 +232,7 @@ namespace OpenSim.Data.MySQL | |||
237 | } | 232 | } |
238 | catch (Exception e) | 233 | catch (Exception e) |
239 | { | 234 | { |
240 | m_log.DebugFormat("[PROFILES_DATA]" + | 235 | m_log.ErrorFormat("[PROFILES_DATA]" + |
241 | ": ClassifiedesUpdate exception {0}", e.Message); | 236 | ": ClassifiedesUpdate exception {0}", e.Message); |
242 | result = e.Message; | 237 | result = e.Message; |
243 | return false; | 238 | return false; |
@@ -250,7 +245,7 @@ namespace OpenSim.Data.MySQL | |||
250 | string query = string.Empty; | 245 | string query = string.Empty; |
251 | 246 | ||
252 | query += "DELETE FROM classifieds WHERE "; | 247 | query += "DELETE FROM classifieds WHERE "; |
253 | query += "classifieduuid = ?ClasifiedId"; | 248 | query += "classifieduuid = ?recordId"; |
254 | 249 | ||
255 | try | 250 | try |
256 | { | 251 | { |
@@ -260,18 +255,14 @@ namespace OpenSim.Data.MySQL | |||
260 | 255 | ||
261 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 256 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
262 | { | 257 | { |
263 | cmd.Parameters.AddWithValue("?ClassifiedId", recordId.ToString()); | 258 | cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); |
264 | 259 | cmd.ExecuteNonQuery(); | |
265 | lock(Lock) | ||
266 | { | ||
267 | cmd.ExecuteNonQuery(); | ||
268 | } | ||
269 | } | 260 | } |
270 | } | 261 | } |
271 | } | 262 | } |
272 | catch (Exception e) | 263 | catch (Exception e) |
273 | { | 264 | { |
274 | m_log.DebugFormat("[PROFILES_DATA]" + | 265 | m_log.ErrorFormat("[PROFILES_DATA]" + |
275 | ": DeleteClassifiedRecord exception {0}", e.Message); | 266 | ": DeleteClassifiedRecord exception {0}", e.Message); |
276 | return false; | 267 | return false; |
277 | } | 268 | } |
@@ -321,7 +312,7 @@ namespace OpenSim.Data.MySQL | |||
321 | } | 312 | } |
322 | catch (Exception e) | 313 | catch (Exception e) |
323 | { | 314 | { |
324 | m_log.DebugFormat("[PROFILES_DATA]" + | 315 | m_log.ErrorFormat("[PROFILES_DATA]" + |
325 | ": GetPickInfo exception {0}", e.Message); | 316 | ": GetPickInfo exception {0}", e.Message); |
326 | } | 317 | } |
327 | return true; | 318 | return true; |
@@ -365,7 +356,7 @@ namespace OpenSim.Data.MySQL | |||
365 | } | 356 | } |
366 | catch (Exception e) | 357 | catch (Exception e) |
367 | { | 358 | { |
368 | m_log.DebugFormat("[PROFILES_DATA]" + | 359 | m_log.ErrorFormat("[PROFILES_DATA]" + |
369 | ": GetAvatarPicks exception {0}", e.Message); | 360 | ": GetAvatarPicks exception {0}", e.Message); |
370 | } | 361 | } |
371 | return data; | 362 | return data; |
@@ -406,11 +397,12 @@ namespace OpenSim.Data.MySQL | |||
406 | UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); | 397 | UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId); |
407 | UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId); | 398 | UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId); |
408 | pick.GlobalPos = (string)reader["posglobal"]; | 399 | pick.GlobalPos = (string)reader["posglobal"]; |
400 | pick.Gatekeeper = (string)reader["gatekeeper"]; | ||
409 | bool.TryParse((string)reader["toppick"], out pick.TopPick); | 401 | bool.TryParse((string)reader["toppick"], out pick.TopPick); |
410 | bool.TryParse((string)reader["enabled"], out pick.Enabled); | 402 | bool.TryParse((string)reader["enabled"], out pick.Enabled); |
411 | pick.Name = (string)reader["name"]; | 403 | pick.Name = (string)reader["name"]; |
412 | pick.Desc = description; | 404 | pick.Desc = description; |
413 | pick.User = (string)reader["user"]; | 405 | pick.ParcelName = (string)reader["user"]; |
414 | pick.OriginalName = (string)reader["originalname"]; | 406 | pick.OriginalName = (string)reader["originalname"]; |
415 | pick.SimName = (string)reader["simname"]; | 407 | pick.SimName = (string)reader["simname"]; |
416 | pick.SortOrder = (int)reader["sortorder"]; | 408 | pick.SortOrder = (int)reader["sortorder"]; |
@@ -422,7 +414,7 @@ namespace OpenSim.Data.MySQL | |||
422 | } | 414 | } |
423 | catch (Exception e) | 415 | catch (Exception e) |
424 | { | 416 | { |
425 | m_log.DebugFormat("[PROFILES_DATA]" + | 417 | m_log.ErrorFormat("[PROFILES_DATA]" + |
426 | ": GetPickInfo exception {0}", e.Message); | 418 | ": GetPickInfo exception {0}", e.Message); |
427 | } | 419 | } |
428 | return pick; | 420 | return pick; |
@@ -445,14 +437,18 @@ namespace OpenSim.Data.MySQL | |||
445 | query += "?SimName,"; | 437 | query += "?SimName,"; |
446 | query += "?GlobalPos,"; | 438 | query += "?GlobalPos,"; |
447 | query += "?SortOrder,"; | 439 | query += "?SortOrder,"; |
448 | query += "?Enabled) "; | 440 | query += "?Enabled,"; |
441 | query += "?Gatekeeper)"; | ||
449 | query += "ON DUPLICATE KEY UPDATE "; | 442 | query += "ON DUPLICATE KEY UPDATE "; |
450 | query += "parceluuid=?ParcelId,"; | 443 | query += "parceluuid=?ParcelId,"; |
451 | query += "name=?Name,"; | 444 | query += "name=?Name,"; |
452 | query += "description=?Desc,"; | 445 | query += "description=?Desc,"; |
446 | query += "user=?User,"; | ||
447 | query += "simname=?SimName,"; | ||
453 | query += "snapshotuuid=?SnapshotId,"; | 448 | query += "snapshotuuid=?SnapshotId,"; |
454 | query += "pickuuid=?PickId,"; | 449 | query += "pickuuid=?PickId,"; |
455 | query += "posglobal=?GlobalPos"; | 450 | query += "posglobal=?GlobalPos,"; |
451 | query += "gatekeeper=?Gatekeeper"; | ||
456 | 452 | ||
457 | try | 453 | try |
458 | { | 454 | { |
@@ -468,10 +464,11 @@ namespace OpenSim.Data.MySQL | |||
468 | cmd.Parameters.AddWithValue("?Name", pick.Name.ToString()); | 464 | cmd.Parameters.AddWithValue("?Name", pick.Name.ToString()); |
469 | cmd.Parameters.AddWithValue("?Desc", pick.Desc.ToString()); | 465 | cmd.Parameters.AddWithValue("?Desc", pick.Desc.ToString()); |
470 | cmd.Parameters.AddWithValue("?SnapshotId", pick.SnapshotId.ToString()); | 466 | cmd.Parameters.AddWithValue("?SnapshotId", pick.SnapshotId.ToString()); |
471 | cmd.Parameters.AddWithValue("?User", pick.User.ToString()); | 467 | cmd.Parameters.AddWithValue("?User", pick.ParcelName.ToString()); |
472 | cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString()); | 468 | cmd.Parameters.AddWithValue("?Original", pick.OriginalName.ToString()); |
473 | cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString()); | 469 | cmd.Parameters.AddWithValue("?SimName",pick.SimName.ToString()); |
474 | cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos); | 470 | cmd.Parameters.AddWithValue("?GlobalPos", pick.GlobalPos); |
471 | cmd.Parameters.AddWithValue("?Gatekeeper",pick.Gatekeeper); | ||
475 | cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ()); | 472 | cmd.Parameters.AddWithValue("?SortOrder", pick.SortOrder.ToString ()); |
476 | cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString()); | 473 | cmd.Parameters.AddWithValue("?Enabled", pick.Enabled.ToString()); |
477 | 474 | ||
@@ -481,7 +478,7 @@ namespace OpenSim.Data.MySQL | |||
481 | } | 478 | } |
482 | catch (Exception e) | 479 | catch (Exception e) |
483 | { | 480 | { |
484 | m_log.DebugFormat("[PROFILES_DATA]" + | 481 | m_log.ErrorFormat("[PROFILES_DATA]" + |
485 | ": UpdateAvatarNotes exception {0}", e.Message); | 482 | ": UpdateAvatarNotes exception {0}", e.Message); |
486 | return false; | 483 | return false; |
487 | } | 484 | } |
@@ -511,7 +508,7 @@ namespace OpenSim.Data.MySQL | |||
511 | } | 508 | } |
512 | catch (Exception e) | 509 | catch (Exception e) |
513 | { | 510 | { |
514 | m_log.DebugFormat("[PROFILES_DATA]" + | 511 | m_log.ErrorFormat("[PROFILES_DATA]" + |
515 | ": DeleteUserPickRecord exception {0}", e.Message); | 512 | ": DeleteUserPickRecord exception {0}", e.Message); |
516 | return false; | 513 | return false; |
517 | } | 514 | } |
@@ -556,7 +553,7 @@ namespace OpenSim.Data.MySQL | |||
556 | } | 553 | } |
557 | catch (Exception e) | 554 | catch (Exception e) |
558 | { | 555 | { |
559 | m_log.DebugFormat("[PROFILES_DATA]" + | 556 | m_log.ErrorFormat("[PROFILES_DATA]" + |
560 | ": GetAvatarNotes exception {0}", e.Message); | 557 | ": GetAvatarNotes exception {0}", e.Message); |
561 | } | 558 | } |
562 | return true; | 559 | return true; |
@@ -604,7 +601,7 @@ namespace OpenSim.Data.MySQL | |||
604 | } | 601 | } |
605 | catch (Exception e) | 602 | catch (Exception e) |
606 | { | 603 | { |
607 | m_log.DebugFormat("[PROFILES_DATA]" + | 604 | m_log.ErrorFormat("[PROFILES_DATA]" + |
608 | ": UpdateAvatarNotes exception {0}", e.Message); | 605 | ": UpdateAvatarNotes exception {0}", e.Message); |
609 | return false; | 606 | return false; |
610 | } | 607 | } |
@@ -727,7 +724,7 @@ namespace OpenSim.Data.MySQL | |||
727 | } | 724 | } |
728 | catch (Exception e) | 725 | catch (Exception e) |
729 | { | 726 | { |
730 | m_log.DebugFormat("[PROFILES_DATA]" + | 727 | m_log.ErrorFormat("[PROFILES_DATA]" + |
731 | ": Requst properties exception {0}", e.Message); | 728 | ": Requst properties exception {0}", e.Message); |
732 | result = e.Message; | 729 | result = e.Message; |
733 | return false; | 730 | return false; |
@@ -767,7 +764,7 @@ namespace OpenSim.Data.MySQL | |||
767 | } | 764 | } |
768 | catch (Exception e) | 765 | catch (Exception e) |
769 | { | 766 | { |
770 | m_log.DebugFormat("[PROFILES_DATA]" + | 767 | m_log.ErrorFormat("[PROFILES_DATA]" + |
771 | ": AgentPropertiesUpdate exception {0}", e.Message); | 768 | ": AgentPropertiesUpdate exception {0}", e.Message); |
772 | 769 | ||
773 | return false; | 770 | return false; |
@@ -809,7 +806,7 @@ namespace OpenSim.Data.MySQL | |||
809 | } | 806 | } |
810 | catch (Exception e) | 807 | catch (Exception e) |
811 | { | 808 | { |
812 | m_log.DebugFormat("[PROFILES_DATA]" + | 809 | m_log.ErrorFormat("[PROFILES_DATA]" + |
813 | ": AgentInterestsUpdate exception {0}", e.Message); | 810 | ": AgentInterestsUpdate exception {0}", e.Message); |
814 | result = e.Message; | 811 | result = e.Message; |
815 | return false; | 812 | return false; |
@@ -892,7 +889,7 @@ namespace OpenSim.Data.MySQL | |||
892 | } | 889 | } |
893 | catch (Exception e) | 890 | catch (Exception e) |
894 | { | 891 | { |
895 | m_log.DebugFormat("[PROFILES_DATA]" + | 892 | m_log.ErrorFormat("[PROFILES_DATA]" + |
896 | ": GetAvatarNotes exception {0}", e.Message); | 893 | ": GetAvatarNotes exception {0}", e.Message); |
897 | } | 894 | } |
898 | return data; | 895 | return data; |
@@ -953,7 +950,7 @@ namespace OpenSim.Data.MySQL | |||
953 | } | 950 | } |
954 | catch (Exception e) | 951 | catch (Exception e) |
955 | { | 952 | { |
956 | m_log.DebugFormat("[PROFILES_DATA]" + | 953 | m_log.ErrorFormat("[PROFILES_DATA]" + |
957 | ": Get preferences exception {0}", e.Message); | 954 | ": Get preferences exception {0}", e.Message); |
958 | } | 955 | } |
959 | return data; | 956 | return data; |
@@ -965,7 +962,8 @@ namespace OpenSim.Data.MySQL | |||
965 | 962 | ||
966 | query += "UPDATE userpsettings SET "; | 963 | query += "UPDATE userpsettings SET "; |
967 | query += "imviaemail=?ImViaEmail, "; | 964 | query += "imviaemail=?ImViaEmail, "; |
968 | query += "visible=?Visible,"; | 965 | query += "visible=?Visible, "; |
966 | query += "email=?EMail "; | ||
969 | query += "WHERE useruuid=?uuid"; | 967 | query += "WHERE useruuid=?uuid"; |
970 | 968 | ||
971 | try | 969 | try |
@@ -975,21 +973,19 @@ namespace OpenSim.Data.MySQL | |||
975 | dbcon.Open(); | 973 | dbcon.Open(); |
976 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 974 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
977 | { | 975 | { |
978 | cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ()); | 976 | cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail.ToString().ToLower()); |
979 | cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ()); | 977 | cmd.Parameters.AddWithValue("?Visible", pref.Visible.ToString().ToLower()); |
980 | cmd.Parameters.AddWithValue("?uuid", avatarId.ToString()); | 978 | cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); |
981 | 979 | cmd.Parameters.AddWithValue("?EMail", pref.EMail.ToString().ToLower()); | |
982 | lock(Lock) | 980 | |
983 | { | 981 | cmd.ExecuteNonQuery(); |
984 | cmd.ExecuteNonQuery(); | ||
985 | } | ||
986 | } | 982 | } |
987 | } | 983 | } |
988 | } | 984 | } |
989 | catch (Exception e) | 985 | catch (Exception e) |
990 | { | 986 | { |
991 | m_log.DebugFormat("[PROFILES_DATA]" + | 987 | m_log.ErrorFormat("[PROFILES_DATA]" + |
992 | ": AgentInterestsUpdate exception {0}", e.Message); | 988 | ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException); |
993 | return false; | 989 | return false; |
994 | } | 990 | } |
995 | return true; | 991 | return true; |
@@ -1033,15 +1029,12 @@ namespace OpenSim.Data.MySQL | |||
1033 | 1029 | ||
1034 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | 1030 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) |
1035 | { | 1031 | { |
1036 | put.Parameters.AddWithValue("?Id", props.UserId.ToString()); | 1032 | put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); |
1037 | put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); | 1033 | put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); |
1038 | put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); | 1034 | put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); |
1039 | put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); | 1035 | put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); |
1040 | 1036 | ||
1041 | lock(Lock) | 1037 | put.ExecuteNonQuery(); |
1042 | { | ||
1043 | put.ExecuteNonQuery(); | ||
1044 | } | ||
1045 | } | 1038 | } |
1046 | } | 1039 | } |
1047 | } | 1040 | } |
@@ -1050,7 +1043,7 @@ namespace OpenSim.Data.MySQL | |||
1050 | } | 1043 | } |
1051 | catch (Exception e) | 1044 | catch (Exception e) |
1052 | { | 1045 | { |
1053 | m_log.DebugFormat("[PROFILES_DATA]" + | 1046 | m_log.ErrorFormat("[PROFILES_DATA]" + |
1054 | ": Requst application data exception {0}", e.Message); | 1047 | ": Requst application data exception {0}", e.Message); |
1055 | result = e.Message; | 1048 | result = e.Message; |
1056 | return false; | 1049 | return false; |
@@ -1077,20 +1070,17 @@ namespace OpenSim.Data.MySQL | |||
1077 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 1070 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
1078 | { | 1071 | { |
1079 | cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString()); | 1072 | cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString()); |
1080 | cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString ()); | 1073 | cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString()); |
1081 | cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString ()); | 1074 | cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); |
1082 | cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString ()); | 1075 | cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString()); |
1083 | 1076 | ||
1084 | lock(Lock) | 1077 | cmd.ExecuteNonQuery(); |
1085 | { | ||
1086 | cmd.ExecuteNonQuery(); | ||
1087 | } | ||
1088 | } | 1078 | } |
1089 | } | 1079 | } |
1090 | } | 1080 | } |
1091 | catch (Exception e) | 1081 | catch (Exception e) |
1092 | { | 1082 | { |
1093 | m_log.DebugFormat("[PROFILES_DATA]" + | 1083 | m_log.ErrorFormat("[PROFILES_DATA]" + |
1094 | ": SetUserData exception {0}", e.Message); | 1084 | ": SetUserData exception {0}", e.Message); |
1095 | return false; | 1085 | return false; |
1096 | } | 1086 | } |
@@ -1098,5 +1088,4 @@ namespace OpenSim.Data.MySQL | |||
1098 | } | 1088 | } |
1099 | #endregion Integration | 1089 | #endregion Integration |
1100 | } | 1090 | } |
1101 | } | 1091 | } \ No newline at end of file |
1102 | |||
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 5f1d2ee..68e1a5a 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs | |||
@@ -57,7 +57,6 @@ namespace OpenSim.Data.MySQL | |||
57 | 57 | ||
58 | private bool m_enableCompression = false; | 58 | private bool m_enableCompression = false; |
59 | private string m_connectionString; | 59 | private string m_connectionString; |
60 | private object m_dbLock = new object(); | ||
61 | 60 | ||
62 | /// <summary> | 61 | /// <summary> |
63 | /// 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 |
@@ -131,60 +130,58 @@ namespace OpenSim.Data.MySQL | |||
131 | // m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); | 130 | // m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); |
132 | 131 | ||
133 | AssetBase asset = null; | 132 | AssetBase asset = null; |
134 | lock (m_dbLock) | 133 | |
134 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
135 | { | 135 | { |
136 | 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)) | ||
137 | { | 141 | { |
138 | dbcon.Open(); | 142 | cmd.Parameters.AddWithValue("?ID", assetID.ToString()); |
139 | 143 | ||
140 | using (MySqlCommand cmd = new MySqlCommand( | 144 | try |
141 | "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID", | ||
142 | dbcon)) | ||
143 | { | 145 | { |
144 | cmd.Parameters.AddWithValue("?ID", assetID.ToString()); | 146 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
145 | |||
146 | try | ||
147 | { | 147 | { |
148 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 148 | if (dbReader.Read()) |
149 | { | 149 | { |
150 | if (dbReader.Read()) | 150 | asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString()); |
151 | { | 151 | asset.Data = (byte[])dbReader["Data"]; |
152 | asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString()); | 152 | asset.Description = (string)dbReader["Description"]; |
153 | asset.Data = (byte[])dbReader["Data"]; | ||
154 | asset.Description = (string)dbReader["Description"]; | ||
155 | 153 | ||
156 | string local = dbReader["Local"].ToString(); | 154 | string local = dbReader["Local"].ToString(); |
157 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | 155 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) |
158 | asset.Local = true; | 156 | asset.Local = true; |
159 | else | 157 | else |
160 | asset.Local = false; | 158 | asset.Local = false; |
161 | 159 | ||
162 | asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); | 160 | asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); |
163 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); | 161 | asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); |
164 | 162 | ||
165 | if (m_enableCompression) | 163 | if (m_enableCompression) |
164 | { | ||
165 | using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) | ||
166 | { | 166 | { |
167 | using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) | 167 | MemoryStream outputStream = new MemoryStream(); |
168 | { | 168 | WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); |
169 | MemoryStream outputStream = new MemoryStream(); | 169 | // int compressedLength = asset.Data.Length; |
170 | WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); | 170 | asset.Data = outputStream.ToArray(); |
171 | // int compressedLength = asset.Data.Length; | 171 | |
172 | asset.Data = outputStream.ToArray(); | 172 | // m_log.DebugFormat( |
173 | 173 | // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", | |
174 | // m_log.DebugFormat( | 174 | // asset.ID, asset.Name, asset.Data.Length, compressedLength); |
175 | // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", | ||
176 | // asset.ID, asset.Name, asset.Data.Length, compressedLength); | ||
177 | } | ||
178 | } | 175 | } |
179 | |||
180 | UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]); | ||
181 | } | 176 | } |
177 | |||
178 | UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]); | ||
182 | } | 179 | } |
183 | } | 180 | } |
184 | catch (Exception e) | 181 | } |
185 | { | 182 | catch (Exception e) |
186 | m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); | 183 | { |
187 | } | 184 | m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); |
188 | } | 185 | } |
189 | } | 186 | } |
190 | } | 187 | } |
@@ -201,113 +198,110 @@ namespace OpenSim.Data.MySQL | |||
201 | { | 198 | { |
202 | // m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID); | 199 | // m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID); |
203 | 200 | ||
204 | lock (m_dbLock) | 201 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
205 | { | 202 | { |
206 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 203 | dbcon.Open(); |
204 | |||
205 | using (MySqlTransaction transaction = dbcon.BeginTransaction()) | ||
207 | { | 206 | { |
208 | 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 | } | ||
209 | 215 | ||
210 | using (MySqlTransaction transaction = dbcon.BeginTransaction()) | 216 | string assetDescription = asset.Description; |
217 | if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) | ||
211 | { | 218 | { |
212 | string assetName = asset.Name; | 219 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); |
213 | if (asset.Name.Length > 64) | 220 | m_log.WarnFormat( |
214 | { | 221 | "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", |
215 | assetName = asset.Name.Substring(0, 64); | 222 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); |
216 | m_log.WarnFormat( | 223 | } |
217 | "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", | ||
218 | asset.Name, asset.ID, asset.Name.Length, assetName.Length); | ||
219 | } | ||
220 | |||
221 | string assetDescription = asset.Description; | ||
222 | if (asset.Description.Length > 64) | ||
223 | { | ||
224 | assetDescription = asset.Description.Substring(0, 64); | ||
225 | m_log.WarnFormat( | ||
226 | "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", | ||
227 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); | ||
228 | } | ||
229 | 224 | ||
230 | if (m_enableCompression) | 225 | if (m_enableCompression) |
231 | { | 226 | { |
232 | MemoryStream outputStream = new MemoryStream(); | 227 | MemoryStream outputStream = new MemoryStream(); |
233 | 228 | ||
234 | using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) | 229 | using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) |
235 | { | 230 | { |
236 | // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); | 231 | // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); |
237 | // 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. |
238 | compressionStream.Close(); | 233 | compressionStream.Close(); |
239 | byte[] compressedData = outputStream.ToArray(); | 234 | byte[] compressedData = outputStream.ToArray(); |
240 | asset.Data = compressedData; | 235 | asset.Data = compressedData; |
241 | } | ||
242 | } | 236 | } |
237 | } | ||
243 | 238 | ||
244 | byte[] hash = hasher.ComputeHash(asset.Data); | 239 | byte[] hash = hasher.ComputeHash(asset.Data); |
245 | 240 | ||
246 | // m_log.DebugFormat( | 241 | // m_log.DebugFormat( |
247 | // "[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}", |
248 | // asset.ID, asset.Name, hash, compressedData.Length); | 243 | // asset.ID, asset.Name, hash, compressedData.Length); |
249 | 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 | { | ||
250 | try | 281 | try |
251 | { | 282 | { |
252 | using (MySqlCommand cmd = | 283 | using (MySqlCommand cmd = |
253 | new MySqlCommand( | 284 | new MySqlCommand( |
254 | "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" + | 285 | "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)", |
255 | "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)", | ||
256 | dbcon)) | 286 | dbcon)) |
257 | { | 287 | { |
258 | // create unix epoch time | ||
259 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
260 | cmd.Parameters.AddWithValue("?ID", asset.ID); | ||
261 | cmd.Parameters.AddWithValue("?Hash", hash); | 288 | cmd.Parameters.AddWithValue("?Hash", hash); |
262 | cmd.Parameters.AddWithValue("?Name", assetName); | 289 | cmd.Parameters.AddWithValue("?Data", asset.Data); |
263 | cmd.Parameters.AddWithValue("?Description", assetDescription); | ||
264 | cmd.Parameters.AddWithValue("?AssetType", asset.Type); | ||
265 | cmd.Parameters.AddWithValue("?Local", asset.Local); | ||
266 | cmd.Parameters.AddWithValue("?Temporary", asset.Temporary); | ||
267 | cmd.Parameters.AddWithValue("?CreateTime", now); | ||
268 | cmd.Parameters.AddWithValue("?AccessTime", now); | ||
269 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
270 | cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags); | ||
271 | cmd.ExecuteNonQuery(); | 290 | cmd.ExecuteNonQuery(); |
272 | } | 291 | } |
273 | } | 292 | } |
274 | catch (Exception e) | 293 | catch (Exception e) |
275 | { | 294 | { |
276 | 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}", |
277 | asset.FullID, asset.Name, e.Message); | 296 | asset.FullID, asset.Name, e.Message); |
278 | 297 | ||
279 | transaction.Rollback(); | 298 | transaction.Rollback(); |
280 | 299 | ||
281 | return; | 300 | return; |
282 | } | 301 | } |
283 | |||
284 | if (!ExistsData(dbcon, transaction, hash)) | ||
285 | { | ||
286 | try | ||
287 | { | ||
288 | using (MySqlCommand cmd = | ||
289 | new MySqlCommand( | ||
290 | "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)", | ||
291 | dbcon)) | ||
292 | { | ||
293 | cmd.Parameters.AddWithValue("?Hash", hash); | ||
294 | cmd.Parameters.AddWithValue("?Data", asset.Data); | ||
295 | cmd.ExecuteNonQuery(); | ||
296 | } | ||
297 | } | ||
298 | catch (Exception e) | ||
299 | { | ||
300 | m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}", | ||
301 | asset.FullID, asset.Name, e.Message); | ||
302 | |||
303 | transaction.Rollback(); | ||
304 | |||
305 | return; | ||
306 | } | ||
307 | } | ||
308 | |||
309 | transaction.Commit(); | ||
310 | } | 302 | } |
303 | |||
304 | transaction.Commit(); | ||
311 | } | 305 | } |
312 | } | 306 | } |
313 | } | 307 | } |
@@ -328,31 +322,28 @@ namespace OpenSim.Data.MySQL | |||
328 | if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates) | 322 | if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates) |
329 | return; | 323 | return; |
330 | 324 | ||
331 | lock (m_dbLock) | 325 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
332 | { | 326 | { |
333 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 327 | dbcon.Open(); |
334 | { | 328 | MySqlCommand cmd = |
335 | dbcon.Open(); | 329 | new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon); |
336 | MySqlCommand cmd = | ||
337 | new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon); | ||
338 | 330 | ||
339 | try | 331 | try |
340 | { | 332 | { |
341 | using (cmd) | 333 | using (cmd) |
342 | { | ||
343 | // create unix epoch time | ||
344 | cmd.Parameters.AddWithValue("?ID", assetMetadata.ID); | ||
345 | cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now)); | ||
346 | cmd.ExecuteNonQuery(); | ||
347 | } | ||
348 | } | ||
349 | catch (Exception e) | ||
350 | { | 334 | { |
351 | m_log.ErrorFormat( | 335 | // create unix epoch time |
352 | "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", | 336 | cmd.Parameters.AddWithValue("?ID", assetMetadata.ID); |
353 | assetMetadata.ID, assetMetadata.Name); | 337 | cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now)); |
338 | cmd.ExecuteNonQuery(); | ||
354 | } | 339 | } |
355 | } | 340 | } |
341 | catch (Exception) | ||
342 | { | ||
343 | m_log.ErrorFormat( | ||
344 | "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", | ||
345 | assetMetadata.ID, assetMetadata.Name); | ||
346 | } | ||
356 | } | 347 | } |
357 | } | 348 | } |
358 | 349 | ||
@@ -397,45 +388,40 @@ namespace OpenSim.Data.MySQL | |||
397 | } | 388 | } |
398 | 389 | ||
399 | /// <summary> | 390 | /// <summary> |
400 | /// Check if the asset exists in the database | 391 | /// Check if the assets exist in the database. |
401 | /// </summary> | 392 | /// </summary> |
402 | /// <param name="uuid">The asset UUID</param> | 393 | /// <param name="uuids">The asset UUID's</param> |
403 | /// <returns>true if it exists, false otherwise.</returns> | 394 | /// <returns>For each asset: true if it exists, false otherwise</returns> |
404 | public bool ExistsAsset(UUID uuid) | 395 | public bool[] AssetsExist(UUID[] uuids) |
405 | { | 396 | { |
406 | // 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>(); | ||
407 | 401 | ||
408 | bool assetExists = false; | 402 | string ids = "'" + string.Join("','", uuids) + "'"; |
403 | string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids); | ||
409 | 404 | ||
410 | lock (m_dbLock) | 405 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
411 | { | 406 | { |
412 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 407 | dbcon.Open(); |
408 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
413 | { | 409 | { |
414 | dbcon.Open(); | 410 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
415 | using (MySqlCommand cmd = new MySqlCommand("SELECT ID FROM XAssetsMeta WHERE ID=?ID", dbcon)) | ||
416 | { | 411 | { |
417 | cmd.Parameters.AddWithValue("?ID", uuid.ToString()); | 412 | while (dbReader.Read()) |
418 | |||
419 | try | ||
420 | { | 413 | { |
421 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 414 | UUID id = DBGuid.FromDB(dbReader["ID"]); |
422 | { | 415 | exists.Add(id); |
423 | if (dbReader.Read()) | ||
424 | { | ||
425 | // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); | ||
426 | assetExists = true; | ||
427 | } | ||
428 | } | ||
429 | } | ||
430 | catch (Exception e) | ||
431 | { | ||
432 | m_log.Error(string.Format("[XASSETS DB]: MySql failure fetching asset {0}", uuid), e); | ||
433 | } | 416 | } |
434 | } | 417 | } |
435 | } | 418 | } |
436 | } | 419 | } |
437 | 420 | ||
438 | 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; | ||
439 | } | 425 | } |
440 | 426 | ||
441 | 427 | ||
@@ -451,43 +437,40 @@ namespace OpenSim.Data.MySQL | |||
451 | { | 437 | { |
452 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 438 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
453 | 439 | ||
454 | lock (m_dbLock) | 440 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
455 | { | 441 | { |
456 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 442 | dbcon.Open(); |
457 | { | 443 | MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); |
458 | dbcon.Open(); | 444 | cmd.Parameters.AddWithValue("?start", start); |
459 | MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); | 445 | cmd.Parameters.AddWithValue("?count", count); |
460 | cmd.Parameters.AddWithValue("?start", start); | ||
461 | cmd.Parameters.AddWithValue("?count", count); | ||
462 | 446 | ||
463 | try | 447 | try |
448 | { | ||
449 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | ||
464 | { | 450 | { |
465 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 451 | while (dbReader.Read()) |
466 | { | 452 | { |
467 | while (dbReader.Read()) | 453 | AssetMetadata metadata = new AssetMetadata(); |
468 | { | 454 | metadata.Name = (string)dbReader["Name"]; |
469 | AssetMetadata metadata = new AssetMetadata(); | 455 | metadata.Description = (string)dbReader["Description"]; |
470 | metadata.Name = (string)dbReader["Name"]; | 456 | metadata.Type = (sbyte)dbReader["AssetType"]; |
471 | metadata.Description = (string)dbReader["Description"]; | 457 | metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. |
472 | metadata.Type = (sbyte)dbReader["AssetType"]; | 458 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); |
473 | metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. | 459 | metadata.FullID = DBGuid.FromDB(dbReader["ID"]); |
474 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); | 460 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
475 | metadata.FullID = DBGuid.FromDB(dbReader["ID"]); | 461 | |
476 | metadata.CreatorID = dbReader["CreatorID"].ToString(); | 462 | // We'll ignore this for now - it appears unused! |
477 | |||
478 | // We'll ignore this for now - it appears unused! | ||
479 | // metadata.SHA1 = dbReader["hash"]); | 463 | // metadata.SHA1 = dbReader["hash"]); |
480 | 464 | ||
481 | UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); | 465 | UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); |
482 | 466 | ||
483 | retList.Add(metadata); | 467 | retList.Add(metadata); |
484 | } | ||
485 | } | 468 | } |
486 | } | 469 | } |
487 | catch (Exception e) | 470 | } |
488 | { | 471 | catch (Exception e) |
489 | m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); | 472 | { |
490 | } | 473 | m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); |
491 | } | 474 | } |
492 | } | 475 | } |
493 | 476 | ||
@@ -498,21 +481,18 @@ namespace OpenSim.Data.MySQL | |||
498 | { | 481 | { |
499 | // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); | 482 | // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); |
500 | 483 | ||
501 | lock (m_dbLock) | 484 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
502 | { | 485 | { |
503 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 486 | dbcon.Open(); |
504 | { | ||
505 | dbcon.Open(); | ||
506 | |||
507 | using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon)) | ||
508 | { | ||
509 | cmd.Parameters.AddWithValue("?ID", id); | ||
510 | cmd.ExecuteNonQuery(); | ||
511 | } | ||
512 | 487 | ||
513 | // 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)) |
514 | // keep a reference count (?) | 489 | { |
490 | cmd.Parameters.AddWithValue("?ID", id); | ||
491 | cmd.ExecuteNonQuery(); | ||
515 | } | 492 | } |
493 | |||
494 | // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we | ||
495 | // keep a reference count (?) | ||
516 | } | 496 | } |
517 | 497 | ||
518 | return true; | 498 | return true; |
diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index f562300..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.8.0.*")] | 64 | [assembly : AssemblyVersion("0.8.2.*")] |
65 | 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 e0526fe..661d825 100644 --- a/OpenSim/Data/MySQL/Resources/AssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/AssetStore.migrations | |||
@@ -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/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/IM_Store.migrations b/OpenSim/Data/MySQL/Resources/IM_Store.migrations index f73475e..79ead98 100644 --- a/OpenSim/Data/MySQL/Resources/IM_Store.migrations +++ b/OpenSim/Data/MySQL/Resources/IM_Store.migrations | |||
@@ -1,4 +1,4 @@ | |||
1 | :VERSION 1 # -------------------------- | 1 | :VERSION 1 # -------------------------- |
2 | 2 | ||
3 | BEGIN; | 3 | BEGIN; |
4 | 4 | ||
@@ -32,3 +32,11 @@ ALTER TABLE `im_offline` | |||
32 | ADD KEY `FromID` (`FromID`); | 32 | ADD KEY `FromID` (`FromID`); |
33 | 33 | ||
34 | COMMIT; | 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/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations index be4030e..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 | ||
@@ -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 c2e3afe..738f5c2 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations | |||
@@ -939,3 +939,15 @@ ALTER TABLE prims ADD COLUMN AttachedPosY double default 0; | |||
939 | ALTER TABLE prims ADD COLUMN AttachedPosZ 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'; | 940 | ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0'; |
941 | COMMIT; | 941 | COMMIT; |
942 | <<<<<<< HEAD | ||
943 | |||
944 | :VERSION 50 #---- Change LandFlags to unsigned | ||
945 | |||
946 | BEGIN; | ||
947 | |||
948 | ALTER TABLE land CHANGE COLUMN LandFlags LandFlags int unsigned default null; | ||
949 | |||
950 | COMMIT; | ||
951 | |||
952 | ======= | ||
953 | >>>>>>> avn/ubitvar | ||
diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations index c29f1ab..3df9b9b 100644 --- a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations +++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations | |||
@@ -81,3 +81,21 @@ CREATE TABLE IF NOT EXISTS `userdata` ( | |||
81 | 81 | ||
82 | commit; | 82 | commit; |
83 | 83 | ||
84 | <<<<<<< HEAD | ||
85 | :VERSION 3 # ------------------------------- | ||
86 | begin; | ||
87 | CREATE TABLE IF NOT EXISTS `usersettings` ( | ||
88 | `useruuid` varchar(36) NOT NULL, | ||
89 | `imviaemail` enum('true','false') NOT NULL, | ||
90 | `visible` enum('true','false') NOT NULL, | ||
91 | `email` varchar(254) NOT NULL, | ||
92 | PRIMARY KEY (`useruuid`) | ||
93 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | ||
94 | commit; | ||
95 | |||
96 | :VERSION 4 # ------------------------------- | ||
97 | begin; | ||
98 | ALTER TABLE userpicks ADD COLUMN gatekeeper varchar(255); | ||
99 | commit; | ||
100 | ======= | ||
101 | >>>>>>> avn/ubitvar | ||
diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations index 0c49d0d..9459e3e 100644 --- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations +++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations | |||
@@ -24,4 +24,9 @@ CREATE TABLE `XAssetsData` ( | |||
24 | PRIMARY KEY (`hash`) | 24 | PRIMARY KEY (`hash`) |
25 | ) ENGINE=InnoDB 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; | ||