diff options
author | Diva Canto | 2011-05-21 14:07:30 -0700 |
---|---|---|
committer | Diva Canto | 2011-05-21 14:07:30 -0700 |
commit | 80457111e0779f296080f4e26c6e56ac1263cba4 (patch) | |
tree | 4a2df3859ad5f71be49a55add550c98a6af04f68 /OpenSim/Data | |
parent | HG Friends working to some extent: friendships offered and accepted correctly... (diff) | |
parent | Get rid of OpenSim.Tests.Common.Setup subpackage in favour of just OpenSim.Te... (diff) | |
download | opensim-SC-80457111e0779f296080f4e26c6e56ac1263cba4.zip opensim-SC-80457111e0779f296080f4e26c6e56ac1263cba4.tar.gz opensim-SC-80457111e0779f296080f4e26c6e56ac1263cba4.tar.bz2 opensim-SC-80457111e0779f296080f4e26c6e56ac1263cba4.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/IXInventoryData.cs | 29 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs | 35 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLXInventoryData.cs | 10 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 27 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLXInventoryData.cs | 10 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | 28 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteXInventoryData.cs | 10 |
7 files changed, 125 insertions, 24 deletions
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs index d85a7ef..85a5c08 100644 --- a/OpenSim/Data/IXInventoryData.cs +++ b/OpenSim/Data/IXInventoryData.cs | |||
@@ -74,9 +74,38 @@ namespace OpenSim.Data | |||
74 | bool StoreFolder(XInventoryFolder folder); | 74 | bool StoreFolder(XInventoryFolder folder); |
75 | bool StoreItem(XInventoryItem item); | 75 | bool StoreItem(XInventoryItem item); |
76 | 76 | ||
77 | /// <summary> | ||
78 | /// Delete folders where field == val | ||
79 | /// </summary> | ||
80 | /// <param name="field"></param> | ||
81 | /// <param name="val"></param> | ||
82 | /// <returns>true if the delete was successful, false if it was not</returns> | ||
77 | bool DeleteFolders(string field, string val); | 83 | bool DeleteFolders(string field, string val); |
84 | |||
85 | /// <summary> | ||
86 | /// Delete folders where field1 == val1, field2 == val2... | ||
87 | /// </summary> | ||
88 | /// <param name="fields"></param> | ||
89 | /// <param name="vals"></param> | ||
90 | /// <returns>true if the delete was successful, false if it was not</returns> | ||
91 | bool DeleteFolders(string[] fields, string[] vals); | ||
92 | |||
93 | /// <summary> | ||
94 | /// Delete items where field == val | ||
95 | /// </summary> | ||
96 | /// <param name="field"></param> | ||
97 | /// <param name="val"></param> | ||
98 | /// <returns>true if the delete was successful, false if it was not</returns> | ||
78 | bool DeleteItems(string field, string val); | 99 | bool DeleteItems(string field, string val); |
79 | 100 | ||
101 | /// <summary> | ||
102 | /// Delete items where field1 == val1, field2 == val2... | ||
103 | /// </summary> | ||
104 | /// <param name="fields"></param> | ||
105 | /// <param name="vals"></param> | ||
106 | /// <returns>true if the delete was successful, false if it was not</returns> | ||
107 | bool DeleteItems(string[] fields, string[] vals); | ||
108 | |||
80 | bool MoveItem(string id, string newParent); | 109 | bool MoveItem(string id, string newParent); |
81 | XInventoryItem[] GetActiveGestures(UUID principalID); | 110 | XInventoryItem[] GetActiveGestures(UUID principalID); |
82 | int GetAssetPermissions(UUID principalID, UUID assetID); | 111 | int GetAssetPermissions(UUID principalID, UUID assetID); |
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 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs index 5bc4fe4..01689a4 100644 --- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs | |||
@@ -79,11 +79,21 @@ namespace OpenSim.Data.MSSQL | |||
79 | return m_Folders.Delete(field, val); | 79 | return m_Folders.Delete(field, val); |
80 | } | 80 | } |
81 | 81 | ||
82 | public bool DeleteFolders(string[] fields, string[] vals) | ||
83 | { | ||
84 | return m_Folders.Delete(fields, vals); | ||
85 | } | ||
86 | |||
82 | public bool DeleteItems(string field, string val) | 87 | public bool DeleteItems(string field, string val) |
83 | { | 88 | { |
84 | return m_Items.Delete(field, val); | 89 | return m_Items.Delete(field, val); |
85 | } | 90 | } |
86 | 91 | ||
92 | public bool DeleteItems(string[] fields, string[] vals) | ||
93 | { | ||
94 | return m_Items.Delete(fields, vals); | ||
95 | } | ||
96 | |||
87 | public bool MoveItem(string id, string newParent) | 97 | public bool MoveItem(string id, string newParent) |
88 | { | 98 | { |
89 | return m_Items.MoveItem(id, newParent); | 99 | return m_Items.MoveItem(id, newParent); |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index cfffbd8..754cf72 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -264,18 +264,33 @@ namespace OpenSim.Data.MySQL | |||
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | public virtual bool Delete(string field, string val) | 267 | public virtual bool Delete(string field, string key) |
268 | { | 268 | { |
269 | return Delete(new string[] { field }, new string[] { key }); | ||
270 | } | ||
271 | |||
272 | public virtual bool Delete(string[] fields, string[] keys) | ||
273 | { | ||
274 | if (fields.Length != keys.Length) | ||
275 | return false; | ||
276 | |||
277 | List<string> terms = new List<string>(); | ||
278 | |||
269 | using (MySqlCommand cmd = new MySqlCommand()) | 279 | using (MySqlCommand cmd = new MySqlCommand()) |
270 | { | 280 | { |
281 | for (int i = 0 ; i < fields.Length ; i++) | ||
282 | { | ||
283 | cmd.Parameters.AddWithValue(fields[i], keys[i]); | ||
284 | terms.Add("`" + fields[i] + "` = ?" + fields[i]); | ||
285 | } | ||
271 | 286 | ||
272 | cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field); | 287 | string where = String.Join(" and ", terms.ToArray()); |
273 | cmd.Parameters.AddWithValue(field, val); | ||
274 | 288 | ||
275 | if (ExecuteNonQuery(cmd) > 0) | 289 | string query = String.Format("delete from {0} where {1}", m_Realm, where); |
276 | return true; | ||
277 | 290 | ||
278 | return false; | 291 | cmd.CommandText = query; |
292 | |||
293 | return ExecuteNonQuery(cmd) > 0; | ||
279 | } | 294 | } |
280 | } | 295 | } |
281 | } | 296 | } |
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 481da49..caf18a4 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs | |||
@@ -85,11 +85,21 @@ namespace OpenSim.Data.MySQL | |||
85 | return m_Folders.Delete(field, val); | 85 | return m_Folders.Delete(field, val); |
86 | } | 86 | } |
87 | 87 | ||
88 | public bool DeleteFolders(string[] fields, string[] vals) | ||
89 | { | ||
90 | return m_Folders.Delete(fields, vals); | ||
91 | } | ||
92 | |||
88 | public bool DeleteItems(string field, string val) | 93 | public bool DeleteItems(string field, string val) |
89 | { | 94 | { |
90 | return m_Items.Delete(field, val); | 95 | return m_Items.Delete(field, val); |
91 | } | 96 | } |
92 | 97 | ||
98 | public bool DeleteItems(string[] fields, string[] vals) | ||
99 | { | ||
100 | return m_Items.Delete(fields, vals); | ||
101 | } | ||
102 | |||
93 | public bool MoveItem(string id, string newParent) | 103 | public bool MoveItem(string id, string newParent) |
94 | { | 104 | { |
95 | return m_Items.MoveItem(id, newParent); | 105 | return m_Items.MoveItem(id, newParent); |
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 0d7b001..3fb2d3f 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | |||
@@ -258,17 +258,33 @@ namespace OpenSim.Data.SQLite | |||
258 | return false; | 258 | return false; |
259 | } | 259 | } |
260 | 260 | ||
261 | public bool Delete(string field, string val) | 261 | public virtual bool Delete(string field, string key) |
262 | { | 262 | { |
263 | return Delete(new string[] { field }, new string[] { key }); | ||
264 | } | ||
265 | |||
266 | public bool Delete(string[] fields, string[] keys) | ||
267 | { | ||
268 | if (fields.Length != keys.Length) | ||
269 | return false; | ||
270 | |||
271 | List<string> terms = new List<string>(); | ||
272 | |||
263 | SqliteCommand cmd = new SqliteCommand(); | 273 | SqliteCommand cmd = new SqliteCommand(); |
264 | 274 | ||
265 | cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field); | 275 | for (int i = 0 ; i < fields.Length ; i++) |
266 | cmd.Parameters.Add(new SqliteParameter(field, val)); | 276 | { |
277 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); | ||
278 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | ||
279 | } | ||
280 | |||
281 | string where = String.Join(" and ", terms.ToArray()); | ||
267 | 282 | ||
268 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | 283 | string query = String.Format("delete * from {0} where {1}", m_Realm, where); |
269 | return true; | ||
270 | 284 | ||
271 | return false; | 285 | cmd.CommandText = query; |
286 | |||
287 | return ExecuteNonQuery(cmd, m_Connection) > 0; | ||
272 | } | 288 | } |
273 | } | 289 | } |
274 | } | 290 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index ccbd86e..02edc30 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs | |||
@@ -91,11 +91,21 @@ namespace OpenSim.Data.SQLite | |||
91 | return m_Folders.Delete(field, val); | 91 | return m_Folders.Delete(field, val); |
92 | } | 92 | } |
93 | 93 | ||
94 | public bool DeleteFolders(string[] fields, string[] vals) | ||
95 | { | ||
96 | return m_Folders.Delete(fields, vals); | ||
97 | } | ||
98 | |||
94 | public bool DeleteItems(string field, string val) | 99 | public bool DeleteItems(string field, string val) |
95 | { | 100 | { |
96 | return m_Items.Delete(field, val); | 101 | return m_Items.Delete(field, val); |
97 | } | 102 | } |
98 | 103 | ||
104 | public bool DeleteItems(string[] fields, string[] vals) | ||
105 | { | ||
106 | return m_Items.Delete(fields, vals); | ||
107 | } | ||
108 | |||
99 | public bool MoveItem(string id, string newParent) | 109 | public bool MoveItem(string id, string newParent) |
100 | { | 110 | { |
101 | return m_Items.MoveItem(id, newParent); | 111 | return m_Items.MoveItem(id, newParent); |