diff options
author | Justin Clark-Casey (justincc) | 2010-04-30 17:45:00 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-04-30 19:28:28 +0100 |
commit | 56fe4c24b8c67ec3b6a5a897c35ab19507bd1077 (patch) | |
tree | 8feccd68058c70da1b96d8b6e804aa4afa6dc723 /OpenSim/Data/SQLite/SQLiteEstateData.cs | |
parent | add Mono.Data.Sqlite.dll (diff) | |
download | opensim-SC-56fe4c24b8c67ec3b6a5a897c35ab19507bd1077.zip opensim-SC-56fe4c24b8c67ec3b6a5a897c35ab19507bd1077.tar.gz opensim-SC-56fe4c24b8c67ec3b6a5a897c35ab19507bd1077.tar.bz2 opensim-SC-56fe4c24b8c67ec3b6a5a897c35ab19507bd1077.tar.xz |
rename SQLiteNG to SQLite and SQLite to SQLiteLegacy this seems the least evil way forward since mono 2.6 and later will see increasing usage, and this only works with what was
SQLiteNG MAC USERS WILL NEED TO CHANGE REFERENCES TO "OpenSim.Data.SQLite.dll" to "OpenSim.Data.SQLiteLegacy.dll" in OpenSim.ini and config-include/StandaloneCommon.ini (if
using standalone) See the OpenSim.ini.example and StandaloneCommon.ini.example files for more details This commit also temporarily changes unsigned ParentEstateID values in the
OpenSim.Data.Tests to signed temporarily, since the new plugin enforces creation of signed fields in the database (which is what the SQL actually specifies). And change data
columns in sqlite is a pita.
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteEstateData.cs')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteEstateData.cs | 101 |
1 files changed, 81 insertions, 20 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index 1be99ee..ad4e2a2 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs | |||
@@ -30,7 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using Mono.Data.SqliteClient; | 33 | using Mono.Data.Sqlite; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
@@ -62,8 +62,8 @@ namespace OpenSim.Data.SQLite | |||
62 | Migration m = new Migration(m_connection, assem, "EstateStore"); | 62 | Migration m = new Migration(m_connection, assem, "EstateStore"); |
63 | m.Update(); | 63 | m.Update(); |
64 | 64 | ||
65 | m_connection.Close(); | 65 | //m_connection.Close(); |
66 | m_connection.Open(); | 66 | // m_connection.Open(); |
67 | 67 | ||
68 | Type t = typeof(EstateSettings); | 68 | Type t = typeof(EstateSettings); |
69 | m_Fields = t.GetFields(BindingFlags.NonPublic | | 69 | m_Fields = t.GetFields(BindingFlags.NonPublic | |
@@ -90,7 +90,7 @@ namespace OpenSim.Data.SQLite | |||
90 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 90 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); |
91 | 91 | ||
92 | cmd.CommandText = sql; | 92 | cmd.CommandText = sql; |
93 | cmd.Parameters.Add(":RegionID", regionID.ToString()); | 93 | cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); |
94 | 94 | ||
95 | IDataReader r = cmd.ExecuteReader(); | 95 | IDataReader r = cmd.ExecuteReader(); |
96 | 96 | ||
@@ -140,13 +140,13 @@ namespace OpenSim.Data.SQLite | |||
140 | if (m_FieldMap[name].GetValue(es) is bool) | 140 | if (m_FieldMap[name].GetValue(es) is bool) |
141 | { | 141 | { |
142 | if ((bool)m_FieldMap[name].GetValue(es)) | 142 | if ((bool)m_FieldMap[name].GetValue(es)) |
143 | cmd.Parameters.Add(":"+name, "1"); | 143 | cmd.Parameters.AddWithValue(":"+name, "1"); |
144 | else | 144 | else |
145 | cmd.Parameters.Add(":"+name, "0"); | 145 | cmd.Parameters.AddWithValue(":"+name, "0"); |
146 | } | 146 | } |
147 | else | 147 | else |
148 | { | 148 | { |
149 | cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString()); | 149 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
@@ -164,8 +164,8 @@ namespace OpenSim.Data.SQLite | |||
164 | r.Close(); | 164 | r.Close(); |
165 | 165 | ||
166 | cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)"; | 166 | cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)"; |
167 | cmd.Parameters.Add(":RegionID", regionID.ToString()); | 167 | cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); |
168 | cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); | 168 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); |
169 | 169 | ||
170 | // This will throw on dupe key | 170 | // This will throw on dupe key |
171 | try | 171 | try |
@@ -222,13 +222,13 @@ namespace OpenSim.Data.SQLite | |||
222 | if (m_FieldMap[name].GetValue(es) is bool) | 222 | if (m_FieldMap[name].GetValue(es) is bool) |
223 | { | 223 | { |
224 | if ((bool)m_FieldMap[name].GetValue(es)) | 224 | if ((bool)m_FieldMap[name].GetValue(es)) |
225 | cmd.Parameters.Add(":"+name, "1"); | 225 | cmd.Parameters.AddWithValue(":"+name, "1"); |
226 | else | 226 | else |
227 | cmd.Parameters.Add(":"+name, "0"); | 227 | cmd.Parameters.AddWithValue(":"+name, "0"); |
228 | } | 228 | } |
229 | else | 229 | else |
230 | { | 230 | { |
231 | cmd.Parameters.Add(":"+name, m_FieldMap[name].GetValue(es).ToString()); | 231 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
@@ -247,7 +247,7 @@ namespace OpenSim.Data.SQLite | |||
247 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 247 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); |
248 | 248 | ||
249 | cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; | 249 | cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; |
250 | cmd.Parameters.Add(":EstateID", es.EstateID); | 250 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID); |
251 | 251 | ||
252 | IDataReader r = cmd.ExecuteReader(); | 252 | IDataReader r = cmd.ExecuteReader(); |
253 | 253 | ||
@@ -271,7 +271,7 @@ namespace OpenSim.Data.SQLite | |||
271 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 271 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); |
272 | 272 | ||
273 | cmd.CommandText = "delete from estateban where EstateID = :EstateID"; | 273 | cmd.CommandText = "delete from estateban where EstateID = :EstateID"; |
274 | cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); | 274 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); |
275 | 275 | ||
276 | cmd.ExecuteNonQuery(); | 276 | cmd.ExecuteNonQuery(); |
277 | 277 | ||
@@ -281,8 +281,8 @@ namespace OpenSim.Data.SQLite | |||
281 | 281 | ||
282 | foreach (EstateBan b in es.EstateBans) | 282 | foreach (EstateBan b in es.EstateBans) |
283 | { | 283 | { |
284 | cmd.Parameters.Add(":EstateID", es.EstateID.ToString()); | 284 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); |
285 | cmd.Parameters.Add(":bannedUUID", b.BannedUserID.ToString()); | 285 | cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString()); |
286 | 286 | ||
287 | cmd.ExecuteNonQuery(); | 287 | cmd.ExecuteNonQuery(); |
288 | cmd.Parameters.Clear(); | 288 | cmd.Parameters.Clear(); |
@@ -294,7 +294,7 @@ namespace OpenSim.Data.SQLite | |||
294 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 294 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); |
295 | 295 | ||
296 | cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; | 296 | cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; |
297 | cmd.Parameters.Add(":EstateID", EstateID.ToString()); | 297 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); |
298 | 298 | ||
299 | cmd.ExecuteNonQuery(); | 299 | cmd.ExecuteNonQuery(); |
300 | 300 | ||
@@ -304,8 +304,8 @@ namespace OpenSim.Data.SQLite | |||
304 | 304 | ||
305 | foreach (UUID uuid in data) | 305 | foreach (UUID uuid in data) |
306 | { | 306 | { |
307 | cmd.Parameters.Add(":EstateID", EstateID.ToString()); | 307 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); |
308 | cmd.Parameters.Add(":uuid", uuid.ToString()); | 308 | cmd.Parameters.AddWithValue(":uuid", uuid.ToString()); |
309 | 309 | ||
310 | cmd.ExecuteNonQuery(); | 310 | cmd.ExecuteNonQuery(); |
311 | cmd.Parameters.Clear(); | 311 | cmd.Parameters.Clear(); |
@@ -319,7 +319,7 @@ namespace OpenSim.Data.SQLite | |||
319 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 319 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); |
320 | 320 | ||
321 | cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; | 321 | cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; |
322 | cmd.Parameters.Add(":EstateID", EstateID); | 322 | cmd.Parameters.AddWithValue(":EstateID", EstateID); |
323 | 323 | ||
324 | IDataReader r = cmd.ExecuteReader(); | 324 | IDataReader r = cmd.ExecuteReader(); |
325 | 325 | ||
@@ -336,5 +336,66 @@ namespace OpenSim.Data.SQLite | |||
336 | 336 | ||
337 | return uuids.ToArray(); | 337 | return uuids.ToArray(); |
338 | } | 338 | } |
339 | <<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteEstateData.cs | ||
340 | ======= | ||
341 | |||
342 | public EstateSettings LoadEstateSettings(int estateID) | ||
343 | { | ||
344 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID :EstateID"; | ||
345 | |||
346 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | ||
347 | |||
348 | cmd.CommandText = sql; | ||
349 | cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); | ||
350 | |||
351 | return DoLoad(cmd, UUID.Zero, false); | ||
352 | } | ||
353 | |||
354 | public List<int> GetEstates(string search) | ||
355 | { | ||
356 | List<int> result = new List<int>(); | ||
357 | |||
358 | string sql = "select EstateID from estate_settings where estate_settings.EstateName :EstateName"; | ||
359 | |||
360 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | ||
361 | |||
362 | cmd.CommandText = sql; | ||
363 | cmd.Parameters.AddWithValue(":EstateName", search); | ||
364 | |||
365 | IDataReader r = cmd.ExecuteReader(); | ||
366 | |||
367 | while (r.Read()) | ||
368 | { | ||
369 | result.Add(Convert.ToInt32(r["EstateID"])); | ||
370 | } | ||
371 | r.Close(); | ||
372 | |||
373 | return result; | ||
374 | } | ||
375 | |||
376 | public bool LinkRegion(UUID regionID, int estateID) | ||
377 | { | ||
378 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | ||
379 | |||
380 | cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)"; | ||
381 | cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); | ||
382 | cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); | ||
383 | |||
384 | if (cmd.ExecuteNonQuery() == 0) | ||
385 | return false; | ||
386 | |||
387 | return true; | ||
388 | } | ||
389 | |||
390 | public List<UUID> GetRegions(int estateID) | ||
391 | { | ||
392 | return new List<UUID>(); | ||
393 | } | ||
394 | |||
395 | public bool DeleteEstate(int estateID) | ||
396 | { | ||
397 | return false; | ||
398 | } | ||
399 | >>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteEstateData.cs | ||
339 | } | 400 | } |
340 | } | 401 | } |