diff options
author | KittoFlora | 2009-11-16 01:40:15 +0100 |
---|---|---|
committer | KittoFlora | 2009-11-16 01:40:15 +0100 |
commit | 873c9098d8627972e80a1688e85a4cda45e1e7fe (patch) | |
tree | a0edc24aef11d5ad6928493d8985386f48dd2607 /OpenSim/Data/MySQL/MySQLGridData.cs | |
parent | Merge branch 'vehicles' into tests (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC-873c9098d8627972e80a1688e85a4cda45e1e7fe.zip opensim-SC-873c9098d8627972e80a1688e85a4cda45e1e7fe.tar.gz opensim-SC-873c9098d8627972e80a1688e85a4cda45e1e7fe.tar.bz2 opensim-SC-873c9098d8627972e80a1688e85a4cda45e1e7fe.tar.xz |
Merge branch 'careminster' into tests
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLGridData.cs | 171 |
1 files changed, 87 insertions, 84 deletions
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 38cb3b7..1ec2609 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs | |||
@@ -197,27 +197,29 @@ namespace OpenSim.Data.MySQL | |||
197 | param["?xmax"] = xmax.ToString(); | 197 | param["?xmax"] = xmax.ToString(); |
198 | param["?ymax"] = ymax.ToString(); | 198 | param["?ymax"] = ymax.ToString(); |
199 | 199 | ||
200 | using (IDbCommand result = dbm.Manager.Query( | 200 | IDbCommand result = |
201 | dbm.Manager.Query( | ||
201 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", | 202 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", |
202 | param)) | 203 | param); |
203 | { | 204 | IDataReader reader = result.ExecuteReader(); |
204 | using (IDataReader reader = result.ExecuteReader()) | ||
205 | { | ||
206 | RegionProfileData row; | ||
207 | 205 | ||
208 | List<RegionProfileData> rows = new List<RegionProfileData>(); | 206 | RegionProfileData row; |
209 | 207 | ||
210 | while ((row = dbm.Manager.readSimRow(reader)) != null) | 208 | List<RegionProfileData> rows = new List<RegionProfileData>(); |
211 | rows.Add(row); | ||
212 | 209 | ||
213 | return rows.ToArray(); | 210 | while ((row = dbm.Manager.readSimRow(reader)) != null) |
214 | } | 211 | { |
212 | rows.Add(row); | ||
215 | } | 213 | } |
214 | reader.Close(); | ||
215 | result.Dispose(); | ||
216 | |||
217 | return rows.ToArray(); | ||
216 | } | 218 | } |
217 | catch (Exception e) | 219 | catch (Exception e) |
218 | { | 220 | { |
219 | dbm.Manager.Reconnect(); | 221 | dbm.Manager.Reconnect(); |
220 | m_log.Error(e.Message, e); | 222 | m_log.Error(e.ToString()); |
221 | return null; | 223 | return null; |
222 | } | 224 | } |
223 | finally | 225 | finally |
@@ -241,27 +243,29 @@ namespace OpenSim.Data.MySQL | |||
241 | Dictionary<string, object> param = new Dictionary<string, object>(); | 243 | Dictionary<string, object> param = new Dictionary<string, object>(); |
242 | param["?name"] = namePrefix + "%"; | 244 | param["?name"] = namePrefix + "%"; |
243 | 245 | ||
244 | using (IDbCommand result = dbm.Manager.Query( | 246 | IDbCommand result = |
245 | "SELECT * FROM regions WHERE regionName LIKE ?name", | 247 | dbm.Manager.Query( |
246 | param)) | 248 | "SELECT * FROM regions WHERE regionName LIKE ?name", |
247 | { | 249 | param); |
248 | using (IDataReader reader = result.ExecuteReader()) | 250 | IDataReader reader = result.ExecuteReader(); |
249 | { | ||
250 | RegionProfileData row; | ||
251 | 251 | ||
252 | List<RegionProfileData> rows = new List<RegionProfileData>(); | 252 | RegionProfileData row; |
253 | 253 | ||
254 | while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) | 254 | List<RegionProfileData> rows = new List<RegionProfileData>(); |
255 | rows.Add(row); | ||
256 | 255 | ||
257 | return rows; | 256 | while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) |
258 | } | 257 | { |
258 | rows.Add(row); | ||
259 | } | 259 | } |
260 | reader.Close(); | ||
261 | result.Dispose(); | ||
262 | |||
263 | return rows; | ||
260 | } | 264 | } |
261 | catch (Exception e) | 265 | catch (Exception e) |
262 | { | 266 | { |
263 | dbm.Manager.Reconnect(); | 267 | dbm.Manager.Reconnect(); |
264 | m_log.Error(e.Message, e); | 268 | m_log.Error(e.ToString()); |
265 | return null; | 269 | return null; |
266 | } | 270 | } |
267 | finally | 271 | finally |
@@ -282,21 +286,21 @@ namespace OpenSim.Data.MySQL | |||
282 | try | 286 | try |
283 | { | 287 | { |
284 | Dictionary<string, object> param = new Dictionary<string, object>(); | 288 | Dictionary<string, object> param = new Dictionary<string, object>(); |
285 | param["?handle"] = handle.ToString(); | 289 | param["?handle"] = handle.ToString(); |
286 | 290 | ||
287 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param)) | 291 | IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); |
288 | { | 292 | IDataReader reader = result.ExecuteReader(); |
289 | using (IDataReader reader = result.ExecuteReader()) | 293 | |
290 | { | 294 | RegionProfileData row = dbm.Manager.readSimRow(reader); |
291 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 295 | reader.Close(); |
292 | return row; | 296 | result.Dispose(); |
293 | } | 297 | |
298 | return row; | ||
294 | } | 299 | } |
295 | } | ||
296 | catch (Exception e) | 300 | catch (Exception e) |
297 | { | 301 | { |
298 | dbm.Manager.Reconnect(); | 302 | dbm.Manager.Reconnect(); |
299 | m_log.Error(e.Message, e); | 303 | m_log.Error(e.ToString()); |
300 | return null; | 304 | return null; |
301 | } | 305 | } |
302 | finally | 306 | finally |
@@ -317,24 +321,23 @@ namespace OpenSim.Data.MySQL | |||
317 | try | 321 | try |
318 | { | 322 | { |
319 | Dictionary<string, object> param = new Dictionary<string, object>(); | 323 | Dictionary<string, object> param = new Dictionary<string, object>(); |
320 | param["?uuid"] = uuid.ToString(); | 324 | param["?uuid"] = uuid.ToString(); |
321 | 325 | ||
322 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param)) | 326 | IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); |
323 | { | 327 | IDataReader reader = result.ExecuteReader(); |
324 | using (IDataReader reader = result.ExecuteReader()) | 328 | |
325 | { | 329 | RegionProfileData row = dbm.Manager.readSimRow(reader); |
326 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 330 | reader.Close(); |
327 | return row; | 331 | result.Dispose(); |
328 | } | 332 | |
333 | return row; | ||
329 | } | 334 | } |
330 | } | ||
331 | catch (Exception e) | 335 | catch (Exception e) |
332 | { | 336 | { |
333 | dbm.Manager.Reconnect(); | 337 | dbm.Manager.Reconnect(); |
334 | m_log.Error(e.Message, e); | 338 | m_log.Error(e.ToString()); |
335 | return null; | 339 | return null; |
336 | } | 340 | } finally |
337 | finally | ||
338 | { | 341 | { |
339 | dbm.Release(); | 342 | dbm.Release(); |
340 | } | 343 | } |
@@ -356,21 +359,22 @@ namespace OpenSim.Data.MySQL | |||
356 | // Add % because this is a like query. | 359 | // Add % because this is a like query. |
357 | param["?regionName"] = regionName + "%"; | 360 | param["?regionName"] = regionName + "%"; |
358 | // Order by statement will return shorter matches first. Only returns one record or no record. | 361 | // Order by statement will return shorter matches first. Only returns one record or no record. |
359 | using (IDbCommand result = dbm.Manager.Query( | 362 | IDbCommand result = |
360 | "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", | 363 | dbm.Manager.Query( |
361 | param)) | 364 | "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", |
362 | { | 365 | param); |
363 | using (IDataReader reader = result.ExecuteReader()) | 366 | IDataReader reader = result.ExecuteReader(); |
364 | { | 367 | |
365 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 368 | RegionProfileData row = dbm.Manager.readSimRow(reader); |
366 | return row; | 369 | reader.Close(); |
367 | } | 370 | result.Dispose(); |
368 | } | 371 | |
372 | return row; | ||
369 | } | 373 | } |
370 | catch (Exception e) | 374 | catch (Exception e) |
371 | { | 375 | { |
372 | dbm.Manager.Reconnect(); | 376 | dbm.Manager.Reconnect(); |
373 | m_log.Error(e.Message, e); | 377 | m_log.Error(e.ToString()); |
374 | return null; | 378 | return null; |
375 | } | 379 | } |
376 | finally | 380 | finally |
@@ -378,7 +382,6 @@ namespace OpenSim.Data.MySQL | |||
378 | dbm.Release(); | 382 | dbm.Release(); |
379 | } | 383 | } |
380 | } | 384 | } |
381 | |||
382 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); | 385 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); |
383 | return null; | 386 | return null; |
384 | } | 387 | } |
@@ -391,12 +394,12 @@ namespace OpenSim.Data.MySQL | |||
391 | override public DataResponse StoreProfile(RegionProfileData profile) | 394 | override public DataResponse StoreProfile(RegionProfileData profile) |
392 | { | 395 | { |
393 | MySQLSuperManager dbm = GetLockedConnection(); | 396 | MySQLSuperManager dbm = GetLockedConnection(); |
394 | try | 397 | try { |
395 | { | ||
396 | if (dbm.Manager.insertRegion(profile)) | 398 | if (dbm.Manager.insertRegion(profile)) |
399 | { | ||
397 | return DataResponse.RESPONSE_OK; | 400 | return DataResponse.RESPONSE_OK; |
398 | else | 401 | } |
399 | return DataResponse.RESPONSE_ERROR; | 402 | return DataResponse.RESPONSE_ERROR; |
400 | } | 403 | } |
401 | finally | 404 | finally |
402 | { | 405 | { |
@@ -414,14 +417,14 @@ namespace OpenSim.Data.MySQL | |||
414 | { | 417 | { |
415 | MySQLSuperManager dbm = GetLockedConnection(); | 418 | MySQLSuperManager dbm = GetLockedConnection(); |
416 | 419 | ||
417 | try | 420 | |
418 | { | 421 | try { |
419 | if (dbm.Manager.deleteRegion(uuid)) | 422 | if (dbm.Manager.deleteRegion(uuid)) |
423 | { | ||
420 | return DataResponse.RESPONSE_OK; | 424 | return DataResponse.RESPONSE_OK; |
421 | else | 425 | } |
422 | return DataResponse.RESPONSE_ERROR; | 426 | return DataResponse.RESPONSE_ERROR; |
423 | } | 427 | } finally |
424 | finally | ||
425 | { | 428 | { |
426 | dbm.Release(); | 429 | dbm.Release(); |
427 | } | 430 | } |
@@ -479,26 +482,26 @@ namespace OpenSim.Data.MySQL | |||
479 | try | 482 | try |
480 | { | 483 | { |
481 | Dictionary<string, object> param = new Dictionary<string, object>(); | 484 | Dictionary<string, object> param = new Dictionary<string, object>(); |
482 | param["?x"] = x.ToString(); | 485 | param["?x"] = x.ToString(); |
483 | param["?y"] = y.ToString(); | 486 | param["?y"] = y.ToString(); |
484 | using (IDbCommand result = dbm.Manager.Query( | 487 | IDbCommand result = |
485 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", | 488 | dbm.Manager.Query( |
486 | param)) | 489 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", |
487 | { | 490 | param); |
488 | using (IDataReader reader = result.ExecuteReader()) | 491 | IDataReader reader = result.ExecuteReader(); |
489 | { | 492 | |
490 | ReservationData row = dbm.Manager.readReservationRow(reader); | 493 | ReservationData row = dbm.Manager.readReservationRow(reader); |
491 | return row; | 494 | reader.Close(); |
492 | } | 495 | result.Dispose(); |
493 | } | 496 | |
497 | return row; | ||
494 | } | 498 | } |
495 | catch (Exception e) | 499 | catch (Exception e) |
496 | { | 500 | { |
497 | dbm.Manager.Reconnect(); | 501 | dbm.Manager.Reconnect(); |
498 | m_log.Error(e.Message, e); | 502 | m_log.Error(e.ToString()); |
499 | return null; | 503 | return null; |
500 | } | 504 | } finally |
501 | finally | ||
502 | { | 505 | { |
503 | dbm.Release(); | 506 | dbm.Release(); |
504 | } | 507 | } |