aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/IXInventoryData.cs29
-rw-r--r--OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs35
-rw-r--r--OpenSim/Data/MSSQL/MSSQLXInventoryData.cs10
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs27
-rw-r--r--OpenSim/Data/MySQL/MySQLXInventoryData.cs10
-rw-r--r--OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs28
-rw-r--r--OpenSim/Data/SQLite/SQLiteXInventoryData.cs10
7 files changed, 24 insertions, 125 deletions
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs
index 85a5c08..d85a7ef 100644
--- a/OpenSim/Data/IXInventoryData.cs
+++ b/OpenSim/Data/IXInventoryData.cs
@@ -74,38 +74,9 @@ 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>
83 bool DeleteFolders(string field, string val); 77 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>
99 bool DeleteItems(string field, string val); 78 bool DeleteItems(string field, string val);
100 79
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
109 bool MoveItem(string id, string newParent); 80 bool MoveItem(string id, string newParent);
110 XInventoryItem[] GetActiveGestures(UUID principalID); 81 XInventoryItem[] GetActiveGestures(UUID principalID);
111 int GetAssetPermissions(UUID principalID, UUID assetID); 82 int GetAssetPermissions(UUID principalID, UUID assetID);
diff --git a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
index 317afac..f5492b3 100644
--- a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
+++ b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
@@ -335,35 +335,24 @@ namespace OpenSim.Data.MSSQL
335 } 335 }
336 } 336 }
337 337
338 public virtual bool Delete(string field, string key) 338 public virtual bool Delete(string field, string val)
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
350 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 340 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
351 using (SqlCommand cmd = new SqlCommand()) 341 using (SqlCommand cmd = new SqlCommand())
352 { 342 {
353 for (int i = 0; i < fields.Length; i++) 343 string deleteCommand = String.Format("DELETE FROM {0} WHERE [{1}] = @{1}", m_Realm, field);
354 { 344 cmd.CommandText = deleteCommand;
355 cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i])); 345
356 terms.Add("[" + fields[i] + "] = @" + fields[i]); 346 cmd.Parameters.Add(m_database.CreateParameter(field, val));
357 }
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; 347 cmd.Connection = conn;
364 cmd.CommandText = query;
365 conn.Open(); 348 conn.Open();
366 return cmd.ExecuteNonQuery() > 0; 349
350 if (cmd.ExecuteNonQuery() > 0)
351 {
352 //m_log.Warn("[MSSQLGenericTable]: " + deleteCommand);
353 return true;
354 }
355 return false;
367 } 356 }
368 } 357 }
369 } 358 }
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
index 01689a4..5bc4fe4 100644
--- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
@@ -79,21 +79,11 @@ 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
87 public bool DeleteItems(string field, string val) 82 public bool DeleteItems(string field, string val)
88 { 83 {
89 return m_Items.Delete(field, val); 84 return m_Items.Delete(field, val);
90 } 85 }
91 86
92 public bool DeleteItems(string[] fields, string[] vals)
93 {
94 return m_Items.Delete(fields, vals);
95 }
96
97 public bool MoveItem(string id, string newParent) 87 public bool MoveItem(string id, string newParent)
98 { 88 {
99 return m_Items.MoveItem(id, newParent); 89 return m_Items.MoveItem(id, newParent);
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 754cf72..cfffbd8 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -264,33 +264,18 @@ namespace OpenSim.Data.MySQL
264 } 264 }
265 } 265 }
266 266
267 public virtual bool Delete(string field, string key) 267 public virtual bool Delete(string field, string val)
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
279 using (MySqlCommand cmd = new MySqlCommand()) 269 using (MySqlCommand cmd = new MySqlCommand())
280 { 270 {
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 }
286
287 string where = String.Join(" and ", terms.ToArray());
288 271
289 string query = String.Format("delete from {0} where {1}", m_Realm, where); 272 cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field);
273 cmd.Parameters.AddWithValue(field, val);
290 274
291 cmd.CommandText = query; 275 if (ExecuteNonQuery(cmd) > 0)
276 return true;
292 277
293 return ExecuteNonQuery(cmd) > 0; 278 return false;
294 } 279 }
295 } 280 }
296 } 281 }
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index caf18a4..481da49 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -85,21 +85,11 @@ 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
93 public bool DeleteItems(string field, string val) 88 public bool DeleteItems(string field, string val)
94 { 89 {
95 return m_Items.Delete(field, val); 90 return m_Items.Delete(field, val);
96 } 91 }
97 92
98 public bool DeleteItems(string[] fields, string[] vals)
99 {
100 return m_Items.Delete(fields, vals);
101 }
102
103 public bool MoveItem(string id, string newParent) 93 public bool MoveItem(string id, string newParent)
104 { 94 {
105 return m_Items.MoveItem(id, newParent); 95 return m_Items.MoveItem(id, newParent);
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
index 3fb2d3f..0d7b001 100644
--- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
+++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
@@ -258,33 +258,17 @@ namespace OpenSim.Data.SQLite
258 return false; 258 return false;
259 } 259 }
260 260
261 public virtual bool Delete(string field, string key) 261 public bool Delete(string field, string val)
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
273 SqliteCommand cmd = new SqliteCommand(); 263 SqliteCommand cmd = new SqliteCommand();
274 264
275 for (int i = 0 ; i < fields.Length ; i++) 265 cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field);
276 { 266 cmd.Parameters.Add(new SqliteParameter(field, val));
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());
282
283 string query = String.Format("delete * from {0} where {1}", m_Realm, where);
284 267
285 cmd.CommandText = query; 268 if (ExecuteNonQuery(cmd, m_Connection) > 0)
269 return true;
286 270
287 return ExecuteNonQuery(cmd, m_Connection) > 0; 271 return false;
288 } 272 }
289 } 273 }
290} 274}
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
index 02edc30..ccbd86e 100644
--- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
+++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
@@ -91,21 +91,11 @@ 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
99 public bool DeleteItems(string field, string val) 94 public bool DeleteItems(string field, string val)
100 { 95 {
101 return m_Items.Delete(field, val); 96 return m_Items.Delete(field, val);
102 } 97 }
103 98
104 public bool DeleteItems(string[] fields, string[] vals)
105 {
106 return m_Items.Delete(fields, vals);
107 }
108
109 public bool MoveItem(string id, string newParent) 99 public bool MoveItem(string id, string newParent)
110 { 100 {
111 return m_Items.MoveItem(id, newParent); 101 return m_Items.MoveItem(id, newParent);