diff options
author | Robert Adams | 2014-08-26 06:47:50 -0700 |
---|---|---|
committer | Robert Adams | 2014-08-26 06:47:50 -0700 |
commit | b3e423303f9d2127706e07ad6482dddb16815aa3 (patch) | |
tree | 0b30b0601586118b751ce6993e9f9b55596e8382 /OpenSim | |
parent | Merge branch 'master' into bullet-2.82 (diff) | |
parent | Add back URL endings in examples (diff) | |
download | opensim-SC_OLD-b3e423303f9d2127706e07ad6482dddb16815aa3.zip opensim-SC_OLD-b3e423303f9d2127706e07ad6482dddb16815aa3.tar.gz opensim-SC_OLD-b3e423303f9d2127706e07ad6482dddb16815aa3.tar.bz2 opensim-SC_OLD-b3e423303f9d2127706e07ad6482dddb16815aa3.tar.xz |
Merge branch 'master' into bullet-2.82
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAssetData.cs | 305 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLFramework.cs | 33 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 616 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 28 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLXAssetData.cs | 354 |
5 files changed, 630 insertions, 706 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index f03e322..5d8da17 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -45,7 +45,6 @@ namespace OpenSim.Data.MySQL | |||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private string m_connectionString; | 47 | private string m_connectionString; |
48 | private object m_dbLock = new object(); | ||
49 | 48 | ||
50 | protected virtual Assembly Assembly | 49 | protected virtual Assembly Assembly |
51 | { | 50 | { |
@@ -107,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,100 +156,94 @@ 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 void StoreAsset(AssetBase asset) | 157 | override public void 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 > AssetBase.MAX_ASSET_NAME) | 182 | m_log.WarnFormat( |
175 | { | 183 | "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", |
176 | assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); | 184 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); |
177 | m_log.WarnFormat( | 185 | } |
178 | "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", | 186 | |
179 | asset.Name, asset.ID, asset.Name.Length, assetName.Length); | 187 | try |
180 | } | 188 | { |
181 | 189 | using (cmd) | |
182 | string assetDescription = asset.Description; | ||
183 | if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) | ||
184 | { | ||
185 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); | ||
186 | m_log.WarnFormat( | ||
187 | "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", | ||
188 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); | ||
189 | } | ||
190 | |||
191 | try | ||
192 | { | ||
193 | using (cmd) | ||
194 | { | ||
195 | // create unix epoch time | ||
196 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
197 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
198 | cmd.Parameters.AddWithValue("?name", assetName); | ||
199 | cmd.Parameters.AddWithValue("?description", assetDescription); | ||
200 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | ||
201 | cmd.Parameters.AddWithValue("?local", asset.Local); | ||
202 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | ||
203 | cmd.Parameters.AddWithValue("?create_time", now); | ||
204 | cmd.Parameters.AddWithValue("?access_time", now); | ||
205 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
206 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | ||
207 | cmd.Parameters.AddWithValue("?data", asset.Data); | ||
208 | cmd.ExecuteNonQuery(); | ||
209 | } | ||
210 | } | ||
211 | catch (Exception e) | ||
212 | { | 190 | { |
213 | m_log.Error( | 191 | // create unix epoch time |
214 | string.Format( | 192 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
215 | "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", | 193 | cmd.Parameters.AddWithValue("?id", asset.ID); |
216 | asset.FullID, asset.Name) | 194 | cmd.Parameters.AddWithValue("?name", assetName); |
217 | , e); | 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(); | ||
218 | } | 205 | } |
219 | } | 206 | } |
207 | catch (Exception e) | ||
208 | { | ||
209 | m_log.Error( | ||
210 | string.Format( | ||
211 | "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", | ||
212 | asset.FullID, asset.Name) | ||
213 | , e); | ||
214 | } | ||
220 | } | 215 | } |
221 | } | 216 | } |
222 | } | 217 | } |
223 | 218 | ||
224 | private void UpdateAccessTime(AssetBase asset) | 219 | private void UpdateAccessTime(AssetBase asset) |
225 | { | 220 | { |
226 | lock (m_dbLock) | 221 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
227 | { | 222 | { |
228 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 223 | dbcon.Open(); |
229 | { | ||
230 | dbcon.Open(); | ||
231 | 224 | ||
232 | using (MySqlCommand cmd | 225 | using (MySqlCommand cmd |
233 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) | 226 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) |
227 | { | ||
228 | try | ||
234 | { | 229 | { |
235 | try | 230 | using (cmd) |
236 | { | ||
237 | using (cmd) | ||
238 | { | ||
239 | // create unix epoch time | ||
240 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
241 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
242 | cmd.Parameters.AddWithValue("?access_time", now); | ||
243 | cmd.ExecuteNonQuery(); | ||
244 | } | ||
245 | } | ||
246 | catch (Exception e) | ||
247 | { | 231 | { |
248 | m_log.Error( | 232 | // create unix epoch time |
249 | string.Format( | 233 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
250 | "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", | 234 | cmd.Parameters.AddWithValue("?id", asset.ID); |
251 | asset.FullID, asset.Name), | 235 | cmd.Parameters.AddWithValue("?access_time", now); |
252 | e); | 236 | cmd.ExecuteNonQuery(); |
253 | } | 237 | } |
254 | } | 238 | } |
239 | catch (Exception e) | ||
240 | { | ||
241 | m_log.Error( | ||
242 | string.Format( | ||
243 | "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", | ||
244 | asset.FullID, asset.Name), | ||
245 | e); | ||
246 | } | ||
255 | } | 247 | } |
256 | } | 248 | } |
257 | } | 249 | } |
@@ -271,20 +263,17 @@ namespace OpenSim.Data.MySQL | |||
271 | string ids = "'" + string.Join("','", uuids) + "'"; | 263 | string ids = "'" + string.Join("','", uuids) + "'"; |
272 | string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids); | 264 | string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids); |
273 | 265 | ||
274 | lock (m_dbLock) | 266 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
275 | { | 267 | { |
276 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 268 | dbcon.Open(); |
269 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
277 | { | 270 | { |
278 | dbcon.Open(); | 271 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
279 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
280 | { | 272 | { |
281 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 273 | while (dbReader.Read()) |
282 | { | 274 | { |
283 | while (dbReader.Read()) | 275 | UUID id = DBGuid.FromDB(dbReader["id"]); |
284 | { | 276 | exist.Add(id); |
285 | UUID id = DBGuid.FromDB(dbReader["id"]); | ||
286 | exist.Add(id); | ||
287 | } | ||
288 | } | 277 | } |
289 | } | 278 | } |
290 | } | 279 | } |
@@ -309,50 +298,47 @@ namespace OpenSim.Data.MySQL | |||
309 | { | 298 | { |
310 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 299 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
311 | 300 | ||
312 | lock (m_dbLock) | 301 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
313 | { | 302 | { |
314 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 303 | dbcon.Open(); |
304 | |||
305 | using (MySqlCommand cmd | ||
306 | = new MySqlCommand( | ||
307 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
308 | dbcon)) | ||
315 | { | 309 | { |
316 | dbcon.Open(); | 310 | cmd.Parameters.AddWithValue("?start", start); |
311 | cmd.Parameters.AddWithValue("?count", count); | ||
317 | 312 | ||
318 | using (MySqlCommand cmd | 313 | try |
319 | = new MySqlCommand( | ||
320 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
321 | dbcon)) | ||
322 | { | 314 | { |
323 | cmd.Parameters.AddWithValue("?start", start); | 315 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
324 | cmd.Parameters.AddWithValue("?count", count); | ||
325 | |||
326 | try | ||
327 | { | 316 | { |
328 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 317 | while (dbReader.Read()) |
329 | { | 318 | { |
330 | while (dbReader.Read()) | 319 | AssetMetadata metadata = new AssetMetadata(); |
331 | { | 320 | metadata.Name = (string)dbReader["name"]; |
332 | AssetMetadata metadata = new AssetMetadata(); | 321 | metadata.Description = (string)dbReader["description"]; |
333 | metadata.Name = (string)dbReader["name"]; | 322 | metadata.Type = (sbyte)dbReader["assetType"]; |
334 | metadata.Description = (string)dbReader["description"]; | 323 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. |
335 | metadata.Type = (sbyte)dbReader["assetType"]; | 324 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); |
336 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | 325 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); |
337 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 326 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
338 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 327 | |
339 | metadata.CreatorID = dbReader["CreatorID"].ToString(); | 328 | // Current SHA1s are not stored/computed. |
340 | 329 | metadata.SHA1 = new byte[] { }; | |
341 | // Current SHA1s are not stored/computed. | 330 | |
342 | metadata.SHA1 = new byte[] { }; | 331 | retList.Add(metadata); |
343 | |||
344 | retList.Add(metadata); | ||
345 | } | ||
346 | } | 332 | } |
347 | } | 333 | } |
348 | catch (Exception e) | 334 | } |
349 | { | 335 | catch (Exception e) |
350 | m_log.Error( | 336 | { |
351 | string.Format( | 337 | m_log.Error( |
352 | "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", | 338 | string.Format( |
353 | start, count), | 339 | "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", |
354 | e); | 340 | start, count), |
355 | } | 341 | e); |
356 | } | 342 | } |
357 | } | 343 | } |
358 | } | 344 | } |
@@ -362,17 +348,14 @@ namespace OpenSim.Data.MySQL | |||
362 | 348 | ||
363 | public override bool Delete(string id) | 349 | public override bool Delete(string id) |
364 | { | 350 | { |
365 | lock (m_dbLock) | 351 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
366 | { | 352 | { |
367 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 353 | dbcon.Open(); |
368 | { | ||
369 | dbcon.Open(); | ||
370 | 354 | ||
371 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) | 355 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) |
372 | { | 356 | { |
373 | cmd.Parameters.AddWithValue("?id", id); | 357 | cmd.Parameters.AddWithValue("?id", id); |
374 | cmd.ExecuteNonQuery(); | 358 | cmd.ExecuteNonQuery(); |
375 | } | ||
376 | } | 359 | } |
377 | } | 360 | } |
378 | 361 | ||
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index 3fdcf1e..5820a90 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -45,38 +45,29 @@ namespace OpenSim.Data.MySQL | |||
45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | protected string m_connectionString; | 47 | protected string m_connectionString; |
48 | protected object m_dbLock = new object(); | ||
49 | 48 | ||
50 | protected MySqlFramework(string connectionString) | 49 | protected MySqlFramework(string connectionString) |
51 | { | 50 | { |
52 | m_connectionString = connectionString; | 51 | m_connectionString = connectionString; |
53 | } | 52 | } |
54 | 53 | ||
55 | ////////////////////////////////////////////////////////////// | ||
56 | // | ||
57 | // All non queries are funneled through one connection | ||
58 | // to increase performance a little | ||
59 | // | ||
60 | protected int ExecuteNonQuery(MySqlCommand cmd) | 54 | protected int ExecuteNonQuery(MySqlCommand cmd) |
61 | { | 55 | { |
62 | lock (m_dbLock) | 56 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
63 | { | 57 | { |
64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 58 | dbcon.Open(); |
65 | { | 59 | cmd.Connection = dbcon; |
66 | dbcon.Open(); | ||
67 | cmd.Connection = dbcon; | ||
68 | 60 | ||
69 | try | 61 | try |
70 | { | 62 | { |
71 | return cmd.ExecuteNonQuery(); | 63 | return cmd.ExecuteNonQuery(); |
72 | } | 64 | } |
73 | catch (Exception e) | 65 | catch (Exception e) |
74 | { | 66 | { |
75 | m_log.Error(e.Message, e); | 67 | m_log.Error(e.Message, e); |
76 | return 0; | 68 | return 0; |
77 | } | ||
78 | } | 69 | } |
79 | } | 70 | } |
80 | } | 71 | } |
81 | } | 72 | } |
82 | } | 73 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 8937b64..bb0ab75 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -51,6 +51,15 @@ namespace OpenSim.Data.MySQL | |||
51 | private static string LogHeader = "[REGION DB MYSQL]"; | 51 | private static string LogHeader = "[REGION DB MYSQL]"; |
52 | 52 | ||
53 | private string m_connectionString; | 53 | private string m_connectionString; |
54 | |||
55 | /// <summary> | ||
56 | /// This lock was being used to serialize database operations when the connection was shared, but this has | ||
57 | /// been unnecessary for a long time after we switched to using MySQL's underlying connection pooling instead. | ||
58 | /// FIXME: However, the locks remain in many places since they are effectively providing a level of | ||
59 | /// transactionality. This should be replaced by more efficient database transactions which would not require | ||
60 | /// unrelated operations to block each other or unrelated operations on the same tables from blocking each | ||
61 | /// other. | ||
62 | /// </summary> | ||
54 | private object m_dbLock = new object(); | 63 | private object m_dbLock = new object(); |
55 | 64 | ||
56 | protected virtual Assembly Assembly | 65 | protected virtual Assembly Assembly |
@@ -738,95 +747,92 @@ namespace OpenSim.Data.MySQL | |||
738 | RegionLightShareData nWP = new RegionLightShareData(); | 747 | RegionLightShareData nWP = new RegionLightShareData(); |
739 | nWP.OnSave += StoreRegionWindlightSettings; | 748 | nWP.OnSave += StoreRegionWindlightSettings; |
740 | 749 | ||
741 | lock (m_dbLock) | 750 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
742 | { | 751 | { |
743 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 752 | dbcon.Open(); |
753 | |||
754 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | ||
755 | |||
756 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
744 | { | 757 | { |
745 | dbcon.Open(); | 758 | cmd.Connection = dbcon; |
746 | 759 | ||
747 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | 760 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); |
748 | 761 | ||
749 | using (MySqlCommand cmd = new MySqlCommand(command)) | 762 | IDataReader result = ExecuteReader(cmd); |
763 | if (!result.Read()) | ||
750 | { | 764 | { |
751 | cmd.Connection = dbcon; | 765 | //No result, so store our default windlight profile and return it |
752 | 766 | nWP.regionID = regionUUID; | |
753 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); | ||
754 | |||
755 | IDataReader result = ExecuteReader(cmd); | ||
756 | if (!result.Read()) | ||
757 | { | ||
758 | //No result, so store our default windlight profile and return it | ||
759 | nWP.regionID = regionUUID; | ||
760 | // StoreRegionWindlightSettings(nWP); | 767 | // StoreRegionWindlightSettings(nWP); |
761 | return nWP; | 768 | return nWP; |
762 | } | 769 | } |
763 | else | 770 | else |
764 | { | 771 | { |
765 | nWP.regionID = DBGuid.FromDB(result["region_id"]); | 772 | nWP.regionID = DBGuid.FromDB(result["region_id"]); |
766 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); | 773 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); |
767 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); | 774 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); |
768 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); | 775 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); |
769 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); | 776 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); |
770 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); | 777 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); |
771 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); | 778 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); |
772 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); | 779 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); |
773 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); | 780 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); |
774 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); | 781 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); |
775 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); | 782 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); |
776 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); | 783 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); |
777 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); | 784 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); |
778 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); | 785 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); |
779 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); | 786 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); |
780 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); | 787 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); |
781 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); | 788 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); |
782 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); | 789 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); |
783 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); | 790 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); |
784 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); | 791 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); |
785 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); | 792 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); |
786 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); | 793 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); |
787 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); | 794 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); |
788 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); | 795 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); |
789 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); | 796 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); |
790 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); | 797 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); |
791 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); | 798 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); |
792 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); | 799 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); |
793 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); | 800 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); |
794 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); | 801 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); |
795 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); | 802 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); |
796 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); | 803 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); |
797 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); | 804 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); |
798 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); | 805 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); |
799 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); | 806 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); |
800 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); | 807 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); |
801 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); | 808 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); |
802 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); | 809 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); |
803 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); | 810 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); |
804 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); | 811 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); |
805 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); | 812 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); |
806 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); | 813 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); |
807 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); | 814 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); |
808 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); | 815 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); |
809 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); | 816 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); |
810 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); | 817 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); |
811 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); | 818 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); |
812 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); | 819 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); |
813 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); | 820 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); |
814 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); | 821 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); |
815 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); | 822 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); |
816 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); | 823 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); |
817 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); | 824 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); |
818 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); | 825 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); |
819 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); | 826 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); |
820 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); | 827 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); |
821 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); | 828 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); |
822 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); | 829 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); |
823 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); | 830 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); |
824 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); | 831 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); |
825 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); | 832 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); |
826 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); | 833 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); |
827 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); | 834 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); |
828 | nWP.valid = true; | 835 | nWP.valid = true; |
829 | } | ||
830 | } | 836 | } |
831 | } | 837 | } |
832 | } | 838 | } |
@@ -876,124 +882,118 @@ namespace OpenSim.Data.MySQL | |||
876 | 882 | ||
877 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | 883 | public void StoreRegionWindlightSettings(RegionLightShareData wl) |
878 | { | 884 | { |
879 | lock (m_dbLock) | 885 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
880 | { | 886 | { |
881 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 887 | dbcon.Open(); |
888 | |||
889 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
882 | { | 890 | { |
883 | dbcon.Open(); | 891 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; |
884 | 892 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | |
885 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 893 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; |
886 | { | 894 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; |
887 | cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; | 895 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; |
888 | cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; | 896 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; |
889 | cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; | 897 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; |
890 | cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; | 898 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; |
891 | cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; | 899 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; |
892 | cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; | 900 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; |
893 | cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; | 901 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; |
894 | cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; | 902 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; |
895 | cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; | 903 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; |
896 | cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; | 904 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; |
897 | cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; | 905 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; |
898 | cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; | 906 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; |
899 | cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; | 907 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; |
900 | cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; | 908 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; |
901 | cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; | 909 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; |
902 | cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; | 910 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; |
903 | cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; | 911 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; |
904 | cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; | 912 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; |
905 | cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; | 913 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; |
906 | cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; | 914 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; |
907 | cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; | 915 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; |
908 | cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; | 916 | |
909 | cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; | 917 | cmd.Parameters.AddWithValue("region_id", wl.regionID); |
910 | cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; | 918 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); |
911 | cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; | 919 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); |
912 | 920 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | |
913 | cmd.Parameters.AddWithValue("region_id", wl.regionID); | 921 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); |
914 | cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); | 922 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); |
915 | cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y); | 923 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); |
916 | cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z); | 924 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); |
917 | cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent); | 925 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); |
918 | cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier); | 926 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); |
919 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X); | 927 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); |
920 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y); | 928 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); |
921 | cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z); | 929 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); |
922 | cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale); | 930 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); |
923 | cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset); | 931 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); |
924 | cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove); | 932 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); |
925 | cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow); | 933 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); |
926 | cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier); | 934 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); |
927 | cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X); | 935 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); |
928 | cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y); | 936 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); |
929 | cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X); | 937 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); |
930 | cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y); | 938 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); |
931 | cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture); | 939 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); |
932 | cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X); | 940 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); |
933 | cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y); | 941 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); |
934 | cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z); | 942 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); |
935 | cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W); | 943 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); |
936 | cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon); | 944 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); |
937 | cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X); | 945 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); |
938 | cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y); | 946 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); |
939 | cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z); | 947 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); |
940 | cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W); | 948 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); |
941 | cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity); | 949 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); |
942 | cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier); | 950 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); |
943 | cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier); | 951 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); |
944 | cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude); | 952 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); |
945 | cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X); | 953 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); |
946 | cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y); | 954 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); |
947 | cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z); | 955 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); |
948 | cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W); | 956 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); |
949 | cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition); | 957 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); |
950 | cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X); | 958 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); |
951 | cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y); | 959 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); |
952 | cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z); | 960 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); |
953 | cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W); | 961 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); |
954 | cmd.Parameters.AddWithValue("east_angle", wl.eastAngle); | 962 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); |
955 | cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus); | 963 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); |
956 | cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize); | 964 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); |
957 | cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma); | 965 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); |
958 | cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness); | 966 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); |
959 | cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X); | 967 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); |
960 | cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y); | 968 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); |
961 | cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z); | 969 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); |
962 | cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W); | 970 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); |
963 | cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X); | 971 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); |
964 | cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y); | 972 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); |
965 | cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z); | 973 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); |
966 | cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage); | 974 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); |
967 | cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale); | 975 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); |
968 | cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X); | 976 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); |
969 | cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y); | 977 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); |
970 | cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z); | 978 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); |
971 | cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX); | 979 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); |
972 | cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock); | 980 | |
973 | cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY); | 981 | ExecuteNonQuery(cmd); |
974 | cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock); | ||
975 | cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds); | ||
976 | |||
977 | ExecuteNonQuery(cmd); | ||
978 | } | ||
979 | } | 982 | } |
980 | } | 983 | } |
981 | } | 984 | } |
982 | 985 | ||
983 | public void RemoveRegionWindlightSettings(UUID regionID) | 986 | public void RemoveRegionWindlightSettings(UUID regionID) |
984 | { | 987 | { |
985 | lock (m_dbLock) | 988 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
986 | { | 989 | { |
987 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 990 | dbcon.Open(); |
991 | |||
992 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
988 | { | 993 | { |
989 | dbcon.Open(); | 994 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; |
990 | 995 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | |
991 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 996 | ExecuteNonQuery(cmd); |
992 | { | ||
993 | cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID"; | ||
994 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | ||
995 | ExecuteNonQuery(cmd); | ||
996 | } | ||
997 | } | 997 | } |
998 | } | 998 | } |
999 | } | 999 | } |
@@ -1001,29 +1001,26 @@ namespace OpenSim.Data.MySQL | |||
1001 | #region RegionEnvironmentSettings | 1001 | #region RegionEnvironmentSettings |
1002 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 1002 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
1003 | { | 1003 | { |
1004 | lock (m_dbLock) | 1004 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1005 | { | 1005 | { |
1006 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1006 | dbcon.Open(); |
1007 | |||
1008 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | ||
1009 | |||
1010 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
1007 | { | 1011 | { |
1008 | dbcon.Open(); | 1012 | cmd.Connection = dbcon; |
1009 | 1013 | ||
1010 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | 1014 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); |
1011 | 1015 | ||
1012 | using (MySqlCommand cmd = new MySqlCommand(command)) | 1016 | IDataReader result = ExecuteReader(cmd); |
1017 | if (!result.Read()) | ||
1013 | { | 1018 | { |
1014 | cmd.Connection = dbcon; | 1019 | return String.Empty; |
1015 | 1020 | } | |
1016 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | 1021 | else |
1017 | 1022 | { | |
1018 | IDataReader result = ExecuteReader(cmd); | 1023 | return Convert.ToString(result["llsd_settings"]); |
1019 | if (!result.Read()) | ||
1020 | { | ||
1021 | return String.Empty; | ||
1022 | } | ||
1023 | else | ||
1024 | { | ||
1025 | return Convert.ToString(result["llsd_settings"]); | ||
1026 | } | ||
1027 | } | 1024 | } |
1028 | } | 1025 | } |
1029 | } | 1026 | } |
@@ -1031,39 +1028,33 @@ namespace OpenSim.Data.MySQL | |||
1031 | 1028 | ||
1032 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 1029 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
1033 | { | 1030 | { |
1034 | lock (m_dbLock) | 1031 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1035 | { | 1032 | { |
1036 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1033 | dbcon.Open(); |
1034 | |||
1035 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1037 | { | 1036 | { |
1038 | dbcon.Open(); | 1037 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; |
1039 | 1038 | ||
1040 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1039 | cmd.Parameters.AddWithValue("region_id", regionUUID); |
1041 | { | 1040 | cmd.Parameters.AddWithValue("llsd_settings", settings); |
1042 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; | 1041 | |
1043 | 1042 | ExecuteNonQuery(cmd); | |
1044 | cmd.Parameters.AddWithValue("region_id", regionUUID); | ||
1045 | cmd.Parameters.AddWithValue("llsd_settings", settings); | ||
1046 | |||
1047 | ExecuteNonQuery(cmd); | ||
1048 | } | ||
1049 | } | 1043 | } |
1050 | } | 1044 | } |
1051 | } | 1045 | } |
1052 | 1046 | ||
1053 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 1047 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
1054 | { | 1048 | { |
1055 | lock (m_dbLock) | 1049 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1056 | { | 1050 | { |
1057 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1051 | dbcon.Open(); |
1052 | |||
1053 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1058 | { | 1054 | { |
1059 | dbcon.Open(); | 1055 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; |
1060 | 1056 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | |
1061 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 1057 | ExecuteNonQuery(cmd); |
1062 | { | ||
1063 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; | ||
1064 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | ||
1065 | ExecuteNonQuery(cmd); | ||
1066 | } | ||
1067 | } | 1058 | } |
1068 | } | 1059 | } |
1069 | } | 1060 | } |
@@ -1071,57 +1062,55 @@ namespace OpenSim.Data.MySQL | |||
1071 | 1062 | ||
1072 | public void StoreRegionSettings(RegionSettings rs) | 1063 | public void StoreRegionSettings(RegionSettings rs) |
1073 | { | 1064 | { |
1074 | lock (m_dbLock) | 1065 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1075 | { | 1066 | { |
1076 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1067 | dbcon.Open(); |
1077 | { | ||
1078 | dbcon.Open(); | ||
1079 | |||
1080 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1081 | { | ||
1082 | cmd.CommandText = "replace into regionsettings (regionUUID, " + | ||
1083 | "block_terraform, block_fly, allow_damage, " + | ||
1084 | "restrict_pushing, allow_land_resell, " + | ||
1085 | "allow_land_join_divide, block_show_in_search, " + | ||
1086 | "agent_limit, object_bonus, maturity, " + | ||
1087 | "disable_scripts, disable_collisions, " + | ||
1088 | "disable_physics, terrain_texture_1, " + | ||
1089 | "terrain_texture_2, terrain_texture_3, " + | ||
1090 | "terrain_texture_4, elevation_1_nw, " + | ||
1091 | "elevation_2_nw, elevation_1_ne, " + | ||
1092 | "elevation_2_ne, elevation_1_se, " + | ||
1093 | "elevation_2_se, elevation_1_sw, " + | ||
1094 | "elevation_2_sw, water_height, " + | ||
1095 | "terrain_raise_limit, terrain_lower_limit, " + | ||
1096 | "use_estate_sun, fixed_sun, sun_position, " + | ||
1097 | "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + | ||
1098 | "sunvectorz, loaded_creation_datetime, " + | ||
1099 | "loaded_creation_id, map_tile_ID, " + | ||
1100 | "TelehubObject, parcel_tile_ID) " + | ||
1101 | "values (?RegionUUID, ?BlockTerraform, " + | ||
1102 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | ||
1103 | "?AllowLandResell, ?AllowLandJoinDivide, " + | ||
1104 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | ||
1105 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + | ||
1106 | "?DisablePhysics, ?TerrainTexture1, " + | ||
1107 | "?TerrainTexture2, ?TerrainTexture3, " + | ||
1108 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + | ||
1109 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + | ||
1110 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + | ||
1111 | "?WaterHeight, ?TerrainRaiseLimit, " + | ||
1112 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | ||
1113 | "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + | ||
1114 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | ||
1115 | "?LoadedCreationDateTime, ?LoadedCreationID, " + | ||
1116 | "?TerrainImageID, " + | ||
1117 | "?TelehubObject, ?ParcelImageID)"; | ||
1118 | |||
1119 | FillRegionSettingsCommand(cmd, rs); | ||
1120 | 1068 | ||
1121 | ExecuteNonQuery(cmd); | 1069 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1122 | } | 1070 | { |
1071 | cmd.CommandText = "replace into regionsettings (regionUUID, " + | ||
1072 | "block_terraform, block_fly, allow_damage, " + | ||
1073 | "restrict_pushing, allow_land_resell, " + | ||
1074 | "allow_land_join_divide, block_show_in_search, " + | ||
1075 | "agent_limit, object_bonus, maturity, " + | ||
1076 | "disable_scripts, disable_collisions, " + | ||
1077 | "disable_physics, terrain_texture_1, " + | ||
1078 | "terrain_texture_2, terrain_texture_3, " + | ||
1079 | "terrain_texture_4, elevation_1_nw, " + | ||
1080 | "elevation_2_nw, elevation_1_ne, " + | ||
1081 | "elevation_2_ne, elevation_1_se, " + | ||
1082 | "elevation_2_se, elevation_1_sw, " + | ||
1083 | "elevation_2_sw, water_height, " + | ||
1084 | "terrain_raise_limit, terrain_lower_limit, " + | ||
1085 | "use_estate_sun, fixed_sun, sun_position, " + | ||
1086 | "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + | ||
1087 | "sunvectorz, loaded_creation_datetime, " + | ||
1088 | "loaded_creation_id, map_tile_ID, " + | ||
1089 | "TelehubObject, parcel_tile_ID) " + | ||
1090 | "values (?RegionUUID, ?BlockTerraform, " + | ||
1091 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | ||
1092 | "?AllowLandResell, ?AllowLandJoinDivide, " + | ||
1093 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | ||
1094 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + | ||
1095 | "?DisablePhysics, ?TerrainTexture1, " + | ||
1096 | "?TerrainTexture2, ?TerrainTexture3, " + | ||
1097 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + | ||
1098 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + | ||
1099 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + | ||
1100 | "?WaterHeight, ?TerrainRaiseLimit, " + | ||
1101 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | ||
1102 | "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + | ||
1103 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | ||
1104 | "?LoadedCreationDateTime, ?LoadedCreationID, " + | ||
1105 | "?TerrainImageID, " + | ||
1106 | "?TelehubObject, ?ParcelImageID)"; | ||
1107 | |||
1108 | FillRegionSettingsCommand(cmd, rs); | ||
1109 | |||
1110 | ExecuteNonQuery(cmd); | ||
1123 | } | 1111 | } |
1124 | } | 1112 | } |
1113 | |||
1125 | SaveSpawnPoints(rs); | 1114 | SaveSpawnPoints(rs); |
1126 | } | 1115 | } |
1127 | 1116 | ||
@@ -2043,41 +2032,35 @@ namespace OpenSim.Data.MySQL | |||
2043 | 2032 | ||
2044 | public void SaveExtra(UUID regionID, string name, string val) | 2033 | public void SaveExtra(UUID regionID, string name, string val) |
2045 | { | 2034 | { |
2046 | lock (m_dbLock) | 2035 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2047 | { | 2036 | { |
2048 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2037 | dbcon.Open(); |
2049 | { | ||
2050 | dbcon.Open(); | ||
2051 | 2038 | ||
2052 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2039 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2053 | { | 2040 | { |
2054 | cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; | 2041 | cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; |
2055 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 2042 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
2056 | cmd.Parameters.AddWithValue("?Name", name); | 2043 | cmd.Parameters.AddWithValue("?Name", name); |
2057 | cmd.Parameters.AddWithValue("?value", val); | 2044 | cmd.Parameters.AddWithValue("?value", val); |
2058 | 2045 | ||
2059 | cmd.ExecuteNonQuery(); | 2046 | cmd.ExecuteNonQuery(); |
2060 | } | ||
2061 | } | 2047 | } |
2062 | } | 2048 | } |
2063 | } | 2049 | } |
2064 | 2050 | ||
2065 | public void RemoveExtra(UUID regionID, string name) | 2051 | public void RemoveExtra(UUID regionID, string name) |
2066 | { | 2052 | { |
2067 | lock (m_dbLock) | 2053 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2068 | { | 2054 | { |
2069 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2055 | dbcon.Open(); |
2070 | { | ||
2071 | dbcon.Open(); | ||
2072 | 2056 | ||
2073 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2057 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2074 | { | 2058 | { |
2075 | cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; | 2059 | cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; |
2076 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 2060 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
2077 | cmd.Parameters.AddWithValue("?Name", name); | 2061 | cmd.Parameters.AddWithValue("?Name", name); |
2078 | 2062 | ||
2079 | cmd.ExecuteNonQuery(); | 2063 | cmd.ExecuteNonQuery(); |
2080 | } | ||
2081 | } | 2064 | } |
2082 | } | 2065 | } |
2083 | } | 2066 | } |
@@ -2086,22 +2069,19 @@ namespace OpenSim.Data.MySQL | |||
2086 | { | 2069 | { |
2087 | Dictionary<string, string> ret = new Dictionary<string, string>(); | 2070 | Dictionary<string, string> ret = new Dictionary<string, string>(); |
2088 | 2071 | ||
2089 | lock (m_dbLock) | 2072 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
2090 | { | 2073 | { |
2091 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 2074 | dbcon.Open(); |
2092 | { | ||
2093 | dbcon.Open(); | ||
2094 | 2075 | ||
2095 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 2076 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
2077 | { | ||
2078 | cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; | ||
2079 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
2080 | using (IDataReader r = cmd.ExecuteReader()) | ||
2096 | { | 2081 | { |
2097 | cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; | 2082 | while (r.Read()) |
2098 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
2099 | using (IDataReader r = cmd.ExecuteReader()) | ||
2100 | { | 2083 | { |
2101 | while (r.Read()) | 2084 | ret[r["Name"].ToString()] = r["value"].ToString(); |
2102 | { | ||
2103 | ret[r["Name"].ToString()] = r["value"].ToString(); | ||
2104 | } | ||
2105 | } | 2085 | } |
2106 | } | 2086 | } |
2107 | } | 2087 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index adb75d6..7e846e3 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 | { |
@@ -1025,11 +1020,8 @@ namespace OpenSim.Data.MySQL | |||
1025 | put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); | 1020 | put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); |
1026 | put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); | 1021 | put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); |
1027 | put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); | 1022 | put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString()); |
1028 | 1023 | ||
1029 | lock(Lock) | 1024 | put.ExecuteNonQuery(); |
1030 | { | ||
1031 | put.ExecuteNonQuery(); | ||
1032 | } | ||
1033 | } | 1025 | } |
1034 | } | 1026 | } |
1035 | } | 1027 | } |
@@ -1065,14 +1057,11 @@ namespace OpenSim.Data.MySQL | |||
1065 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 1057 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
1066 | { | 1058 | { |
1067 | cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString()); | 1059 | cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString()); |
1068 | cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString ()); | 1060 | cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString()); |
1069 | cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString ()); | 1061 | cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString()); |
1070 | cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString ()); | 1062 | cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString()); |
1071 | 1063 | ||
1072 | lock(Lock) | 1064 | cmd.ExecuteNonQuery(); |
1073 | { | ||
1074 | cmd.ExecuteNonQuery(); | ||
1075 | } | ||
1076 | } | 1065 | } |
1077 | } | 1066 | } |
1078 | } | 1067 | } |
@@ -1086,5 +1075,4 @@ namespace OpenSim.Data.MySQL | |||
1086 | } | 1075 | } |
1087 | #endregion Integration | 1076 | #endregion Integration |
1088 | } | 1077 | } |
1089 | } | 1078 | } \ No newline at end of file |
1090 | |||
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 8361da2..af7e876 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 > AssetBase.MAX_ASSET_NAME) | 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, AssetBase.MAX_ASSET_NAME); | 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 > AssetBase.MAX_ASSET_DESC) | ||
223 | { | ||
224 | assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); | ||
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) | ||
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 | ||
@@ -411,20 +402,17 @@ namespace OpenSim.Data.MySQL | |||
411 | string ids = "'" + string.Join("','", uuids) + "'"; | 402 | string ids = "'" + string.Join("','", uuids) + "'"; |
412 | string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids); | 403 | string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids); |
413 | 404 | ||
414 | lock (m_dbLock) | 405 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
415 | { | 406 | { |
416 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 407 | dbcon.Open(); |
408 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
417 | { | 409 | { |
418 | dbcon.Open(); | 410 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
419 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) | ||
420 | { | 411 | { |
421 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 412 | while (dbReader.Read()) |
422 | { | 413 | { |
423 | while (dbReader.Read()) | 414 | UUID id = DBGuid.FromDB(dbReader["ID"]); |
424 | { | 415 | exists.Add(id); |
425 | UUID id = DBGuid.FromDB(dbReader["ID"]); | ||
426 | exists.Add(id); | ||
427 | } | ||
428 | } | 416 | } |
429 | } | 417 | } |
430 | } | 418 | } |
@@ -449,43 +437,40 @@ namespace OpenSim.Data.MySQL | |||
449 | { | 437 | { |
450 | List<AssetMetadata> retList = new List<AssetMetadata>(count); | 438 | List<AssetMetadata> retList = new List<AssetMetadata>(count); |
451 | 439 | ||
452 | lock (m_dbLock) | 440 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
453 | { | 441 | { |
454 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 442 | dbcon.Open(); |
455 | { | 443 | MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon); |
456 | dbcon.Open(); | 444 | cmd.Parameters.AddWithValue("?start", start); |
457 | 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); |
458 | cmd.Parameters.AddWithValue("?start", start); | ||
459 | cmd.Parameters.AddWithValue("?count", count); | ||
460 | 446 | ||
461 | try | 447 | try |
448 | { | ||
449 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | ||
462 | { | 450 | { |
463 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 451 | while (dbReader.Read()) |
464 | { | 452 | { |
465 | while (dbReader.Read()) | 453 | AssetMetadata metadata = new AssetMetadata(); |
466 | { | 454 | metadata.Name = (string)dbReader["Name"]; |
467 | AssetMetadata metadata = new AssetMetadata(); | 455 | metadata.Description = (string)dbReader["Description"]; |
468 | metadata.Name = (string)dbReader["Name"]; | 456 | metadata.Type = (sbyte)dbReader["AssetType"]; |
469 | metadata.Description = (string)dbReader["Description"]; | 457 | metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. |
470 | metadata.Type = (sbyte)dbReader["AssetType"]; | 458 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); |
471 | metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct. | 459 | metadata.FullID = DBGuid.FromDB(dbReader["ID"]); |
472 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); | 460 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
473 | metadata.FullID = DBGuid.FromDB(dbReader["ID"]); | 461 | |
474 | metadata.CreatorID = dbReader["CreatorID"].ToString(); | 462 | // We'll ignore this for now - it appears unused! |
475 | |||
476 | // We'll ignore this for now - it appears unused! | ||
477 | // metadata.SHA1 = dbReader["hash"]); | 463 | // metadata.SHA1 = dbReader["hash"]); |
478 | 464 | ||
479 | UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); | 465 | UpdateAccessTime(metadata, (int)dbReader["AccessTime"]); |
480 | 466 | ||
481 | retList.Add(metadata); | 467 | retList.Add(metadata); |
482 | } | ||
483 | } | 468 | } |
484 | } | 469 | } |
485 | catch (Exception e) | 470 | } |
486 | { | 471 | catch (Exception e) |
487 | m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); | 472 | { |
488 | } | 473 | m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); |
489 | } | 474 | } |
490 | } | 475 | } |
491 | 476 | ||
@@ -496,21 +481,18 @@ namespace OpenSim.Data.MySQL | |||
496 | { | 481 | { |
497 | // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); | 482 | // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); |
498 | 483 | ||
499 | lock (m_dbLock) | 484 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
500 | { | 485 | { |
501 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 486 | dbcon.Open(); |
502 | { | ||
503 | dbcon.Open(); | ||
504 | |||
505 | using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon)) | ||
506 | { | ||
507 | cmd.Parameters.AddWithValue("?ID", id); | ||
508 | cmd.ExecuteNonQuery(); | ||
509 | } | ||
510 | 487 | ||
511 | // 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)) |
512 | // keep a reference count (?) | 489 | { |
490 | cmd.Parameters.AddWithValue("?ID", id); | ||
491 | cmd.ExecuteNonQuery(); | ||
513 | } | 492 | } |
493 | |||
494 | // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we | ||
495 | // keep a reference count (?) | ||
514 | } | 496 | } |
515 | 497 | ||
516 | return true; | 498 | return true; |