diff options
author | Justin Clark-Casey (justincc) | 2011-05-17 21:49:38 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-05-27 01:36:33 +0100 |
commit | 3738aff608cfd7ea0cce9e89c496d9be5fbd39f0 (patch) | |
tree | 5f72dbd5158a4051df3d9a6f26092696254b2ec9 /OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs | |
parent | don't throw a null reference if an inventory link target doesn't exist when w... (diff) | |
download | opensim-SC_OLD-3738aff608cfd7ea0cce9e89c496d9be5fbd39f0.zip opensim-SC_OLD-3738aff608cfd7ea0cce9e89c496d9be5fbd39f0.tar.gz opensim-SC_OLD-3738aff608cfd7ea0cce9e89c496d9be5fbd39f0.tar.bz2 opensim-SC_OLD-3738aff608cfd7ea0cce9e89c496d9be5fbd39f0.tar.xz |
Allow item links to be deleted even when other deletes and purges are disabled.
If these links are not deleted, then they will build up in the player's inventory until they can no longer log in.
Accidental deletion of links due to bugs or other causes is potentially inconvenient but on a par with items being
accidentally moved. When a link is deleted, the target of the link is never touched.
This is a general solution that accounts for the use of links anywhere in the user's inventory.
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs index f5492b3..317afac 100644 --- a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs +++ b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs | |||
@@ -335,24 +335,35 @@ namespace OpenSim.Data.MSSQL | |||
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
338 | public virtual bool Delete(string field, string val) | 338 | public virtual bool Delete(string field, string key) |
339 | { | 339 | { |
340 | return Delete(new string[] { field }, new string[] { key }); | ||
341 | } | ||
342 | |||
343 | public virtual bool Delete(string[] fields, string[] keys) | ||
344 | { | ||
345 | if (fields.Length != keys.Length) | ||
346 | return false; | ||
347 | |||
348 | List<string> terms = new List<string>(); | ||
349 | |||
340 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 350 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
341 | using (SqlCommand cmd = new SqlCommand()) | 351 | using (SqlCommand cmd = new SqlCommand()) |
342 | { | 352 | { |
343 | string deleteCommand = String.Format("DELETE FROM {0} WHERE [{1}] = @{1}", m_Realm, field); | 353 | for (int i = 0; i < fields.Length; i++) |
344 | cmd.CommandText = deleteCommand; | ||
345 | |||
346 | cmd.Parameters.Add(m_database.CreateParameter(field, val)); | ||
347 | cmd.Connection = conn; | ||
348 | conn.Open(); | ||
349 | |||
350 | if (cmd.ExecuteNonQuery() > 0) | ||
351 | { | 354 | { |
352 | //m_log.Warn("[MSSQLGenericTable]: " + deleteCommand); | 355 | cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i])); |
353 | return true; | 356 | terms.Add("[" + fields[i] + "] = @" + fields[i]); |
354 | } | 357 | } |
355 | return false; | 358 | |
359 | string where = String.Join(" AND ", terms.ToArray()); | ||
360 | |||
361 | string query = String.Format("DELETE * FROM {0} WHERE {1}", m_Realm, where); | ||
362 | |||
363 | cmd.Connection = conn; | ||
364 | cmd.CommandText = query; | ||
365 | conn.Open(); | ||
366 | return cmd.ExecuteNonQuery() > 0; | ||
356 | } | 367 | } |
357 | } | 368 | } |
358 | } | 369 | } |