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