diff options
Diffstat (limited to 'OpenSim/Data/SQLite')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteAssetData.cs | 4 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteEstateData.cs | 44 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteFramework.cs | 20 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | 23 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteInventoryStore.cs | 15 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteManager.cs | 8 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteRegionData.cs | 311 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserData.cs | 33 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUtils.cs | 2 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteXInventoryData.cs | 6 |
10 files changed, 286 insertions, 180 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index c52f60b..373c903 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -30,7 +30,7 @@ using System.Data; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
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 | 36 | ||
@@ -339,4 +339,4 @@ namespace OpenSim.Data.SQLite | |||
339 | 339 | ||
340 | #endregion | 340 | #endregion |
341 | } | 341 | } |
342 | } \ No newline at end of file | 342 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index 1be99ee..643e55d 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 |
@@ -180,7 +180,7 @@ namespace OpenSim.Data.SQLite | |||
180 | // | 180 | // |
181 | cmd.Parameters.Clear(); | 181 | cmd.Parameters.Clear(); |
182 | cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID"; | 182 | cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID"; |
183 | cmd.Parameters.Add(":UUID", regionID.ToString()); | 183 | cmd.Parameters.AddWithValue(":UUID", regionID.ToString()); |
184 | 184 | ||
185 | try | 185 | try |
186 | { | 186 | { |
@@ -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 | ||
@@ -337,4 +337,4 @@ namespace OpenSim.Data.SQLite | |||
337 | return uuids.ToArray(); | 337 | return uuids.ToArray(); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | } | 340 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteFramework.cs b/OpenSim/Data/SQLite/SQLiteFramework.cs index 12b2750..9567727 100644 --- a/OpenSim/Data/SQLite/SQLiteFramework.cs +++ b/OpenSim/Data/SQLite/SQLiteFramework.cs | |||
@@ -31,7 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Data; | 31 | using System.Data; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using Mono.Data.SqliteClient; | 34 | using Mono.Data.Sqlite; |
35 | 35 | ||
36 | namespace OpenSim.Data.SQLite | 36 | namespace OpenSim.Data.SQLite |
37 | { | 37 | { |
@@ -65,12 +65,18 @@ namespace OpenSim.Data.SQLite | |||
65 | 65 | ||
66 | protected IDataReader ExecuteReader(SqliteCommand cmd) | 66 | protected IDataReader ExecuteReader(SqliteCommand cmd) |
67 | { | 67 | { |
68 | SqliteConnection newConnection = | 68 | lock (m_Connection) |
69 | (SqliteConnection)((ICloneable)m_Connection).Clone(); | 69 | { |
70 | newConnection.Open(); | 70 | //SqliteConnection newConnection = |
71 | // (SqliteConnection)((ICloneable)connection).Clone(); | ||
72 | //newConnection.Open(); | ||
71 | 73 | ||
72 | cmd.Connection = newConnection; | 74 | //cmd.Connection = newConnection; |
73 | return cmd.ExecuteReader(); | 75 | cmd.Connection = m_Connection; |
76 | //Console.WriteLine("XXX " + cmd.CommandText); | ||
77 | |||
78 | return cmd.ExecuteReader(); | ||
79 | } | ||
74 | } | 80 | } |
75 | 81 | ||
76 | protected void CloseReaderCommand(SqliteCommand cmd) | 82 | protected void CloseReaderCommand(SqliteCommand cmd) |
@@ -80,4 +86,4 @@ namespace OpenSim.Data.SQLite | |||
80 | cmd.Dispose(); | 86 | cmd.Dispose(); |
81 | } | 87 | } |
82 | } | 88 | } |
83 | } | 89 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 8e91693..86eaca1 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.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; |
@@ -54,10 +54,23 @@ namespace OpenSim.Data.SQLite | |||
54 | m_Realm = realm; | 54 | m_Realm = realm; |
55 | if (storeName != String.Empty) | 55 | if (storeName != String.Empty) |
56 | { | 56 | { |
57 | Assembly assem = GetType().Assembly; | 57 | m_Connection = new SqliteConnection(connectionString); |
58 | //Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString)); | ||
59 | m_Connection.Open(); | ||
58 | 60 | ||
59 | Migration m = new Migration(m_Connection, assem, storeName); | 61 | if (storeName != String.Empty) |
60 | m.Update(); | 62 | { |
63 | Assembly assem = GetType().Assembly; | ||
64 | //SqliteConnection newConnection = | ||
65 | // (SqliteConnection)((ICloneable)m_Connection).Clone(); | ||
66 | //newConnection.Open(); | ||
67 | |||
68 | //Migration m = new Migration(newConnection, assem, storeName); | ||
69 | Migration m = new Migration(m_Connection, assem, storeName); | ||
70 | m.Update(); | ||
71 | //newConnection.Close(); | ||
72 | //newConnection.Dispose(); | ||
73 | } | ||
61 | } | 74 | } |
62 | 75 | ||
63 | Type t = typeof(T); | 76 | Type t = typeof(T); |
@@ -180,7 +193,7 @@ namespace OpenSim.Data.SQLite | |||
180 | result.Add(row); | 193 | result.Add(row); |
181 | } | 194 | } |
182 | 195 | ||
183 | CloseReaderCommand(cmd); | 196 | //CloseCommand(cmd); |
184 | 197 | ||
185 | return result.ToArray(); | 198 | return result.ToArray(); |
186 | } | 199 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs index 64591fd..9ce21b1 100644 --- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.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 | 36 | ||
@@ -88,15 +88,17 @@ namespace OpenSim.Data.SQLite | |||
88 | invFoldersDa = new SqliteDataAdapter(foldersSelectCmd); | 88 | invFoldersDa = new SqliteDataAdapter(foldersSelectCmd); |
89 | 89 | ||
90 | ds = new DataSet(); | 90 | ds = new DataSet(); |
91 | 91 | ||
92 | ds.Tables.Add(createInventoryFoldersTable()); | 92 | ds.Tables.Add(createInventoryFoldersTable()); |
93 | invFoldersDa.Fill(ds.Tables["inventoryfolders"]); | 93 | invFoldersDa.Fill(ds.Tables["inventoryfolders"]); |
94 | setupFoldersCommands(invFoldersDa, conn); | 94 | setupFoldersCommands(invFoldersDa, conn); |
95 | CreateDataSetMapping(invFoldersDa, "inventoryfolders"); | ||
95 | m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions"); | 96 | m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions"); |
96 | 97 | ||
97 | ds.Tables.Add(createInventoryItemsTable()); | 98 | ds.Tables.Add(createInventoryItemsTable()); |
98 | invItemsDa.Fill(ds.Tables["inventoryitems"]); | 99 | invItemsDa.Fill(ds.Tables["inventoryitems"]); |
99 | setupItemsCommands(invItemsDa, conn); | 100 | setupItemsCommands(invItemsDa, conn); |
101 | CreateDataSetMapping(invItemsDa, "inventoryitems"); | ||
100 | m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions"); | 102 | m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions"); |
101 | 103 | ||
102 | ds.AcceptChanges(); | 104 | ds.AcceptChanges(); |
@@ -721,6 +723,15 @@ namespace OpenSim.Data.SQLite | |||
721 | * | 723 | * |
722 | **********************************************************************/ | 724 | **********************************************************************/ |
723 | 725 | ||
726 | protected void CreateDataSetMapping(IDataAdapter da, string tableName) | ||
727 | { | ||
728 | ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName); | ||
729 | foreach (DataColumn col in ds.Tables[tableName].Columns) | ||
730 | { | ||
731 | dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName); | ||
732 | } | ||
733 | } | ||
734 | |||
724 | /// <summary> | 735 | /// <summary> |
725 | /// Create the "inventoryitems" table | 736 | /// Create the "inventoryitems" table |
726 | /// </summary> | 737 | /// </summary> |
diff --git a/OpenSim/Data/SQLite/SQLiteManager.cs b/OpenSim/Data/SQLite/SQLiteManager.cs index b6d4a1c..7dcd323 100644 --- a/OpenSim/Data/SQLite/SQLiteManager.cs +++ b/OpenSim/Data/SQLite/SQLiteManager.cs | |||
@@ -28,9 +28,9 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Data.SQLite; | ||
32 | using System.Reflection; | 31 | using System.Reflection; |
33 | using log4net; | 32 | using log4net; |
33 | using Mono.Data.Sqlite; | ||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | 35 | ||
36 | namespace OpenSim.Data.SQLite | 36 | namespace OpenSim.Data.SQLite |
@@ -66,7 +66,7 @@ namespace OpenSim.Data.SQLite | |||
66 | connectionString = "URI=file:GridServerSqlite.db;"; | 66 | connectionString = "URI=file:GridServerSqlite.db;"; |
67 | } | 67 | } |
68 | 68 | ||
69 | dbcon = new SQLiteConnection(connectionString); | 69 | dbcon = new SqliteConnection(connectionString); |
70 | 70 | ||
71 | dbcon.Open(); | 71 | dbcon.Open(); |
72 | } | 72 | } |
@@ -93,11 +93,11 @@ namespace OpenSim.Data.SQLite | |||
93 | /// <returns>A SQLite DB Command</returns> | 93 | /// <returns>A SQLite DB Command</returns> |
94 | public IDbCommand Query(string sql, Dictionary<string, string> parameters) | 94 | public IDbCommand Query(string sql, Dictionary<string, string> parameters) |
95 | { | 95 | { |
96 | SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand(); | 96 | SqliteCommand dbcommand = (SqliteCommand) dbcon.CreateCommand(); |
97 | dbcommand.CommandText = sql; | 97 | dbcommand.CommandText = sql; |
98 | foreach (KeyValuePair<string, string> param in parameters) | 98 | foreach (KeyValuePair<string, string> param in parameters) |
99 | { | 99 | { |
100 | SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value); | 100 | SqliteParameter paramx = new SqliteParameter(param.Key, param.Value); |
101 | dbcommand.Parameters.Add(paramx); | 101 | dbcommand.Parameters.Add(paramx); |
102 | } | 102 | } |
103 | 103 | ||
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 81c0703..8ea6bfb 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs | |||
@@ -32,7 +32,7 @@ using System.Drawing; | |||
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using log4net; | 34 | using log4net; |
35 | using Mono.Data.SqliteClient; | 35 | using Mono.Data.Sqlite; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
@@ -87,119 +87,151 @@ namespace OpenSim.Data.SQLite | |||
87 | /// <param name="connectionString">the connection string</param> | 87 | /// <param name="connectionString">the connection string</param> |
88 | public void Initialise(string connectionString) | 88 | public void Initialise(string connectionString) |
89 | { | 89 | { |
90 | m_connectionString = connectionString; | 90 | try |
91 | { | ||
92 | m_connectionString = connectionString; | ||
91 | 93 | ||
92 | ds = new DataSet(); | 94 | ds = new DataSet("Region"); |
93 | 95 | ||
94 | m_log.Info("[REGION DB]: Sqlite - connecting: " + connectionString); | 96 | m_log.Info("[SQLITE REGION DB]: Sqlite - connecting: " + connectionString); |
95 | m_conn = new SqliteConnection(m_connectionString); | 97 | m_conn = new SqliteConnection(m_connectionString); |
96 | m_conn.Open(); | 98 | m_conn.Open(); |
97 | 99 | ||
100 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); | ||
101 | primDa = new SqliteDataAdapter(primSelectCmd); | ||
98 | 102 | ||
103 | SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); | ||
104 | shapeDa = new SqliteDataAdapter(shapeSelectCmd); | ||
105 | // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); | ||
99 | 106 | ||
100 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); | 107 | SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); |
101 | primDa = new SqliteDataAdapter(primSelectCmd); | 108 | itemsDa = new SqliteDataAdapter(itemsSelectCmd); |
102 | // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); | ||
103 | 109 | ||
104 | SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); | 110 | SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); |
105 | shapeDa = new SqliteDataAdapter(shapeSelectCmd); | 111 | terrainDa = new SqliteDataAdapter(terrainSelectCmd); |
106 | // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); | ||
107 | 112 | ||
108 | SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); | 113 | SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn); |
109 | itemsDa = new SqliteDataAdapter(itemsSelectCmd); | 114 | landDa = new SqliteDataAdapter(landSelectCmd); |
110 | 115 | ||
111 | SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); | 116 | SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); |
112 | terrainDa = new SqliteDataAdapter(terrainSelectCmd); | 117 | landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); |
113 | 118 | ||
114 | SqliteCommand landSelectCmd = new SqliteCommand(landSelect, m_conn); | 119 | SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn); |
115 | landDa = new SqliteDataAdapter(landSelectCmd); | 120 | regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd); |
121 | // This actually does the roll forward assembly stuff | ||
122 | Assembly assem = GetType().Assembly; | ||
123 | Migration m = new Migration(m_conn, assem, "RegionStore"); | ||
124 | m.Update(); | ||
116 | 125 | ||
117 | SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); | 126 | lock (ds) |
118 | landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); | 127 | { |
128 | ds.Tables.Add(createPrimTable()); | ||
129 | setupPrimCommands(primDa, m_conn); | ||
119 | 130 | ||
120 | SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn); | 131 | ds.Tables.Add(createShapeTable()); |
121 | regionSettingsDa = new SqliteDataAdapter(regionSettingsSelectCmd); | 132 | setupShapeCommands(shapeDa, m_conn); |
122 | // This actually does the roll forward assembly stuff | ||
123 | Assembly assem = GetType().Assembly; | ||
124 | Migration m = new Migration(m_conn, assem, "RegionStore"); | ||
125 | m.Update(); | ||
126 | 133 | ||
127 | lock (ds) | 134 | ds.Tables.Add(createItemsTable()); |
128 | { | 135 | setupItemsCommands(itemsDa, m_conn); |
129 | ds.Tables.Add(createPrimTable()); | ||
130 | setupPrimCommands(primDa, m_conn); | ||
131 | primDa.Fill(ds.Tables["prims"]); | ||
132 | 136 | ||
133 | ds.Tables.Add(createShapeTable()); | 137 | ds.Tables.Add(createTerrainTable()); |
134 | setupShapeCommands(shapeDa, m_conn); | 138 | setupTerrainCommands(terrainDa, m_conn); |
135 | 139 | ||
136 | ds.Tables.Add(createItemsTable()); | 140 | ds.Tables.Add(createLandTable()); |
137 | setupItemsCommands(itemsDa, m_conn); | 141 | setupLandCommands(landDa, m_conn); |
138 | itemsDa.Fill(ds.Tables["primitems"]); | ||
139 | 142 | ||
140 | ds.Tables.Add(createTerrainTable()); | 143 | ds.Tables.Add(createLandAccessListTable()); |
141 | setupTerrainCommands(terrainDa, m_conn); | 144 | setupLandAccessCommands(landAccessListDa, m_conn); |
142 | 145 | ||
143 | ds.Tables.Add(createLandTable()); | 146 | ds.Tables.Add(createRegionSettingsTable()); |
144 | setupLandCommands(landDa, m_conn); | 147 | setupRegionSettingsCommands(regionSettingsDa, m_conn); |
145 | 148 | ||
146 | ds.Tables.Add(createLandAccessListTable()); | 149 | // WORKAROUND: This is a work around for sqlite on |
147 | setupLandAccessCommands(landAccessListDa, m_conn); | 150 | // windows, which gets really unhappy with blob columns |
151 | // that have no sample data in them. At some point we | ||
152 | // need to actually find a proper way to handle this. | ||
153 | try | ||
154 | { | ||
155 | primDa.Fill(ds.Tables["prims"]); | ||
156 | } | ||
157 | catch (Exception) | ||
158 | { | ||
159 | m_log.Info("[SQLITE REGION DB]: Caught fill error on prims table"); | ||
160 | } | ||
148 | 161 | ||
149 | ds.Tables.Add(createRegionSettingsTable()); | 162 | try |
150 | 163 | { | |
151 | setupRegionSettingsCommands(regionSettingsDa, m_conn); | 164 | shapeDa.Fill(ds.Tables["primshapes"]); |
165 | } | ||
166 | catch (Exception) | ||
167 | { | ||
168 | m_log.Info("[SQLITE REGION DB]: Caught fill error on primshapes table"); | ||
169 | } | ||
152 | 170 | ||
153 | // WORKAROUND: This is a work around for sqlite on | 171 | try |
154 | // windows, which gets really unhappy with blob columns | 172 | { |
155 | // that have no sample data in them. At some point we | 173 | itemsDa.Fill(ds.Tables["primitems"]); |
156 | // need to actually find a proper way to handle this. | 174 | } |
157 | try | 175 | catch (Exception) |
158 | { | 176 | { |
159 | shapeDa.Fill(ds.Tables["primshapes"]); | 177 | m_log.Info("[SQLITE REGION DB]: Caught fill error on primitems table"); |
160 | } | 178 | } |
161 | catch (Exception) | 179 | |
162 | { | 180 | try |
163 | m_log.Info("[REGION DB]: Caught fill error on primshapes table"); | 181 | { |
164 | } | 182 | terrainDa.Fill(ds.Tables["terrain"]); |
183 | } | ||
184 | catch (Exception) | ||
185 | { | ||
186 | m_log.Info("[SQLITE REGION DB]: Caught fill error on terrain table"); | ||
187 | } | ||
165 | 188 | ||
166 | try | 189 | try |
167 | { | 190 | { |
168 | terrainDa.Fill(ds.Tables["terrain"]); | 191 | landDa.Fill(ds.Tables["land"]); |
169 | } | 192 | } |
170 | catch (Exception) | 193 | catch (Exception) |
171 | { | 194 | { |
172 | m_log.Info("[REGION DB]: Caught fill error on terrain table"); | 195 | m_log.Info("[SQLITE REGION DB]: Caught fill error on land table"); |
173 | } | 196 | } |
174 | 197 | ||
175 | try | 198 | try |
176 | { | 199 | { |
177 | landDa.Fill(ds.Tables["land"]); | 200 | landAccessListDa.Fill(ds.Tables["landaccesslist"]); |
178 | } | 201 | } |
179 | catch (Exception) | 202 | catch (Exception) |
180 | { | 203 | { |
181 | m_log.Info("[REGION DB]: Caught fill error on land table"); | 204 | m_log.Info("[SQLITE REGION DB]: Caught fill error on landaccesslist table"); |
182 | } | 205 | } |
183 | 206 | ||
184 | try | 207 | try |
185 | { | 208 | { |
186 | landAccessListDa.Fill(ds.Tables["landaccesslist"]); | 209 | regionSettingsDa.Fill(ds.Tables["regionsettings"]); |
187 | } | 210 | } |
188 | catch (Exception) | 211 | catch (Exception) |
189 | { | 212 | { |
190 | m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); | 213 | m_log.Info("[SQLITE REGION DB]: Caught fill error on regionsettings table"); |
191 | } | 214 | } |
192 | 215 | ||
193 | try | 216 | // We have to create a data set mapping for every table, otherwise the IDataAdaptor.Update() will not populate rows with values! |
194 | { | 217 | // Not sure exactly why this is - this kind of thing was not necessary before - justincc 20100409 |
195 | regionSettingsDa.Fill(ds.Tables["regionsettings"]); | 218 | // Possibly because we manually set up our own DataTables before connecting to the database |
196 | } | 219 | CreateDataSetMapping(primDa, "prims"); |
197 | catch (Exception) | 220 | CreateDataSetMapping(shapeDa, "primshapes"); |
198 | { | 221 | CreateDataSetMapping(itemsDa, "primitems"); |
199 | m_log.Info("[REGION DB]: Caught fill error on regionsettings table"); | 222 | CreateDataSetMapping(terrainDa, "terrain"); |
223 | CreateDataSetMapping(landDa, "land"); | ||
224 | CreateDataSetMapping(landAccessListDa, "landaccesslist"); | ||
225 | CreateDataSetMapping(regionSettingsDa, "regionsettings"); | ||
200 | } | 226 | } |
201 | return; | ||
202 | } | 227 | } |
228 | catch (Exception e) | ||
229 | { | ||
230 | m_log.Error(e); | ||
231 | Environment.Exit(23); | ||
232 | } | ||
233 | |||
234 | return; | ||
203 | } | 235 | } |
204 | 236 | ||
205 | public void Dispose() | 237 | public void Dispose() |
@@ -411,7 +443,7 @@ namespace OpenSim.Data.SQLite | |||
411 | lock (ds) | 443 | lock (ds) |
412 | { | 444 | { |
413 | DataRow[] primsForRegion = prims.Select(byRegion); | 445 | DataRow[] primsForRegion = prims.Select(byRegion); |
414 | m_log.Info("[REGION DB]: Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); | 446 | // m_log.Info("[SQLITE REGION DB]: Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); |
415 | 447 | ||
416 | // First, create all groups | 448 | // First, create all groups |
417 | foreach (DataRow primRow in primsForRegion) | 449 | foreach (DataRow primRow in primsForRegion) |
@@ -433,8 +465,8 @@ namespace OpenSim.Data.SQLite | |||
433 | } | 465 | } |
434 | else | 466 | else |
435 | { | 467 | { |
436 | m_log.Info( | 468 | m_log.Warn( |
437 | "[REGION DB]: No shape found for prim in storage, so setting default box shape"); | 469 | "[SQLITE REGION DB]: No shape found for prim in storage, so setting default box shape"); |
438 | prim.Shape = PrimitiveBaseShape.Default; | 470 | prim.Shape = PrimitiveBaseShape.Default; |
439 | } | 471 | } |
440 | 472 | ||
@@ -446,11 +478,11 @@ namespace OpenSim.Data.SQLite | |||
446 | } | 478 | } |
447 | catch (Exception e) | 479 | catch (Exception e) |
448 | { | 480 | { |
449 | m_log.Error("[REGION DB]: Failed create prim object in new group, exception and data follows"); | 481 | m_log.Error("[SQLITE REGION DB]: Failed create prim object in new group, exception and data follows"); |
450 | m_log.Info("[REGION DB]: " + e.ToString()); | 482 | m_log.Error("[SQLITE REGION DB]: ", e); |
451 | foreach (DataColumn col in prims.Columns) | 483 | foreach (DataColumn col in prims.Columns) |
452 | { | 484 | { |
453 | m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); | 485 | m_log.Error("[SQLITE REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); |
454 | } | 486 | } |
455 | } | 487 | } |
456 | } | 488 | } |
@@ -475,7 +507,7 @@ namespace OpenSim.Data.SQLite | |||
475 | else | 507 | else |
476 | { | 508 | { |
477 | m_log.Warn( | 509 | m_log.Warn( |
478 | "[REGION DB]: No shape found for prim in storage, so setting default box shape"); | 510 | "[SQLITE REGION DB]: No shape found for prim in storage, so setting default box shape"); |
479 | prim.Shape = PrimitiveBaseShape.Default; | 511 | prim.Shape = PrimitiveBaseShape.Default; |
480 | } | 512 | } |
481 | 513 | ||
@@ -485,11 +517,11 @@ namespace OpenSim.Data.SQLite | |||
485 | } | 517 | } |
486 | catch (Exception e) | 518 | catch (Exception e) |
487 | { | 519 | { |
488 | m_log.Error("[REGION DB]: Failed create prim object in group, exception and data follows"); | 520 | m_log.Error("[SQLITE REGION DB]: Failed create prim object in group, exception and data follows"); |
489 | m_log.Info("[REGION DB]: " + e.ToString()); | 521 | m_log.Error("[SQLITE REGION DB]: ", e); |
490 | foreach (DataColumn col in prims.Columns) | 522 | foreach (DataColumn col in prims.Columns) |
491 | { | 523 | { |
492 | m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); | 524 | m_log.Error("[SQLITE REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]); |
493 | } | 525 | } |
494 | } | 526 | } |
495 | } | 527 | } |
@@ -502,20 +534,23 @@ namespace OpenSim.Data.SQLite | |||
502 | /// </summary> | 534 | /// </summary> |
503 | /// <param name="prim">the prim</param> | 535 | /// <param name="prim">the prim</param> |
504 | private void LoadItems(SceneObjectPart prim) | 536 | private void LoadItems(SceneObjectPart prim) |
505 | { | 537 | { |
506 | //m_log.DebugFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); | 538 | // m_log.DebugFormat("[SQLITE REGION DB]: Loading inventory for {0} {1}", prim.Name, prim.UUID); |
507 | 539 | ||
508 | DataTable dbItems = ds.Tables["primitems"]; | 540 | DataTable dbItems = ds.Tables["primitems"]; |
509 | String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); | 541 | String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); |
510 | DataRow[] dbItemRows = dbItems.Select(sql); | 542 | DataRow[] dbItemRows = dbItems.Select(sql); |
511 | IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); | 543 | IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); |
512 | 544 | ||
545 | // m_log.DebugFormat( | ||
546 | // "[SQLITE REGION DB]: Found {0} items for {1} {2}", dbItemRows.Length, prim.Name, prim.UUID); | ||
547 | |||
513 | foreach (DataRow row in dbItemRows) | 548 | foreach (DataRow row in dbItemRows) |
514 | { | 549 | { |
515 | TaskInventoryItem item = buildItem(row); | 550 | TaskInventoryItem item = buildItem(row); |
516 | inventory.Add(item); | 551 | inventory.Add(item); |
517 | 552 | ||
518 | //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); | 553 | // m_log.DebugFormat("[SQLITE REGION DB]: Restored item {0} {1}", item.Name, item.ItemID); |
519 | } | 554 | } |
520 | 555 | ||
521 | prim.Inventory.RestoreInventoryItems(inventory); | 556 | prim.Inventory.RestoreInventoryItems(inventory); |
@@ -551,7 +586,7 @@ namespace OpenSim.Data.SQLite | |||
551 | 586 | ||
552 | // the following is an work around for .NET. The perf | 587 | // the following is an work around for .NET. The perf |
553 | // issues associated with it aren't as bad as you think. | 588 | // issues associated with it aren't as bad as you think. |
554 | m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); | 589 | m_log.Debug("[SQLITE REGION DB]: Storing terrain revision r" + revision.ToString()); |
555 | String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + | 590 | String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + |
556 | " values(:RegionUUID, :Revision, :Heightfield)"; | 591 | " values(:RegionUUID, :Revision, :Heightfield)"; |
557 | 592 | ||
@@ -603,15 +638,15 @@ namespace OpenSim.Data.SQLite | |||
603 | } | 638 | } |
604 | } | 639 | } |
605 | } | 640 | } |
606 | rev = (int) row["Revision"]; | 641 | rev = Convert.ToInt32(row["Revision"]); |
607 | } | 642 | } |
608 | else | 643 | else |
609 | { | 644 | { |
610 | m_log.Info("[REGION DB]: No terrain found for region"); | 645 | m_log.Warn("[SQLITE REGION DB]: No terrain found for region"); |
611 | return null; | 646 | return null; |
612 | } | 647 | } |
613 | 648 | ||
614 | m_log.Info("[REGION DB]: Loaded terrain revision r" + rev.ToString()); | 649 | m_log.Debug("[SQLITE REGION DB]: Loaded terrain revision r" + rev.ToString()); |
615 | } | 650 | } |
616 | } | 651 | } |
617 | return terret; | 652 | return terret; |
@@ -755,6 +790,7 @@ namespace OpenSim.Data.SQLite | |||
755 | /// </summary> | 790 | /// </summary> |
756 | public void Commit() | 791 | public void Commit() |
757 | { | 792 | { |
793 | //m_log.Debug("[SQLITE]: Starting commit"); | ||
758 | lock (ds) | 794 | lock (ds) |
759 | { | 795 | { |
760 | primDa.Update(ds, "prims"); | 796 | primDa.Update(ds, "prims"); |
@@ -769,18 +805,11 @@ namespace OpenSim.Data.SQLite | |||
769 | { | 805 | { |
770 | regionSettingsDa.Update(ds, "regionsettings"); | 806 | regionSettingsDa.Update(ds, "regionsettings"); |
771 | } | 807 | } |
772 | catch (SqliteExecutionException SqlEx) | 808 | catch (SqliteException SqlEx) |
773 | { | 809 | { |
774 | if (SqlEx.Message.Contains("logic error")) | 810 | throw new Exception( |
775 | { | 811 | "There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!", |
776 | throw new Exception( | 812 | SqlEx); |
777 | "There was a SQL error or connection string configuration error when saving the region settings. This could be a bug, it could also happen if ConnectionString is defined in the [DatabaseService] section of StandaloneCommon.ini in the config_include folder. This could also happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. If this is your first time running OpenSimulator, please restart the simulator and bug a developer to fix this!", | ||
778 | SqlEx); | ||
779 | } | ||
780 | else | ||
781 | { | ||
782 | throw SqlEx; | ||
783 | } | ||
784 | } | 813 | } |
785 | ds.AcceptChanges(); | 814 | ds.AcceptChanges(); |
786 | } | 815 | } |
@@ -802,6 +831,15 @@ namespace OpenSim.Data.SQLite | |||
802 | * | 831 | * |
803 | **********************************************************************/ | 832 | **********************************************************************/ |
804 | 833 | ||
834 | protected void CreateDataSetMapping(IDataAdapter da, string tableName) | ||
835 | { | ||
836 | ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName); | ||
837 | foreach (DataColumn col in ds.Tables[tableName].Columns) | ||
838 | { | ||
839 | dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName); | ||
840 | } | ||
841 | } | ||
842 | |||
805 | /// <summary> | 843 | /// <summary> |
806 | /// | 844 | /// |
807 | /// </summary> | 845 | /// </summary> |
@@ -1390,7 +1428,7 @@ namespace OpenSim.Data.SQLite | |||
1390 | } | 1428 | } |
1391 | catch (InvalidCastException) | 1429 | catch (InvalidCastException) |
1392 | { | 1430 | { |
1393 | m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); | 1431 | m_log.ErrorFormat("[SQLITE REGION DB]: unable to get parcel telehub settings for {1}", newData.Name); |
1394 | newData.UserLocation = Vector3.Zero; | 1432 | newData.UserLocation = Vector3.Zero; |
1395 | newData.UserLookAt = Vector3.Zero; | 1433 | newData.UserLookAt = Vector3.Zero; |
1396 | } | 1434 | } |
@@ -1897,7 +1935,7 @@ namespace OpenSim.Data.SQLite | |||
1897 | /// <param name="items"></param> | 1935 | /// <param name="items"></param> |
1898 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) | 1936 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) |
1899 | { | 1937 | { |
1900 | m_log.InfoFormat("[REGION DB]: Entered StorePrimInventory with prim ID {0}", primID); | 1938 | // m_log.DebugFormat("[SQLITE REGION DB]: Entered StorePrimInventory with prim ID {0}", primID); |
1901 | 1939 | ||
1902 | DataTable dbItems = ds.Tables["primitems"]; | 1940 | DataTable dbItems = ds.Tables["primitems"]; |
1903 | 1941 | ||
@@ -1964,6 +2002,7 @@ namespace OpenSim.Data.SQLite | |||
1964 | sql += ") values (:"; | 2002 | sql += ") values (:"; |
1965 | sql += String.Join(", :", cols); | 2003 | sql += String.Join(", :", cols); |
1966 | sql += ")"; | 2004 | sql += ")"; |
2005 | //m_log.DebugFormat("[SQLITE]: Created insert command {0}", sql); | ||
1967 | SqliteCommand cmd = new SqliteCommand(sql); | 2006 | SqliteCommand cmd = new SqliteCommand(sql); |
1968 | 2007 | ||
1969 | // this provides the binding for all our parameters, so | 2008 | // this provides the binding for all our parameters, so |
@@ -2259,6 +2298,36 @@ namespace OpenSim.Data.SQLite | |||
2259 | return DbType.String; | 2298 | return DbType.String; |
2260 | } | 2299 | } |
2261 | } | 2300 | } |
2301 | |||
2302 | static void PrintDataSet(DataSet ds) | ||
2303 | { | ||
2304 | // Print out any name and extended properties. | ||
2305 | Console.WriteLine("DataSet is named: {0}", ds.DataSetName); | ||
2306 | foreach (System.Collections.DictionaryEntry de in ds.ExtendedProperties) | ||
2307 | { | ||
2308 | Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value); | ||
2309 | } | ||
2310 | Console.WriteLine(); | ||
2311 | foreach (DataTable dt in ds.Tables) | ||
2312 | { | ||
2313 | Console.WriteLine("=> {0} Table:", dt.TableName); | ||
2314 | // Print out the column names. | ||
2315 | for (int curCol = 0; curCol < dt.Columns.Count; curCol++) | ||
2316 | { | ||
2317 | Console.Write(dt.Columns[curCol].ColumnName + "\t"); | ||
2318 | } | ||
2319 | Console.WriteLine("\n----------------------------------"); | ||
2320 | // Print the DataTable. | ||
2321 | for (int curRow = 0; curRow < dt.Rows.Count; curRow++) | ||
2322 | { | ||
2323 | for (int curCol = 0; curCol < dt.Columns.Count; curCol++) | ||
2324 | { | ||
2325 | Console.Write(dt.Rows[curRow][curCol].ToString() + "\t"); | ||
2326 | } | ||
2327 | Console.WriteLine(); | ||
2328 | } | ||
2329 | } | ||
2330 | } | ||
2262 | 2331 | ||
2263 | } | 2332 | } |
2264 | } | 2333 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index caddcf8..ea755b0 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.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 | 36 | ||
@@ -115,15 +115,19 @@ namespace OpenSim.Data.SQLite | |||
115 | 115 | ||
116 | setupUserCommands(da, conn); | 116 | setupUserCommands(da, conn); |
117 | da.Fill(ds.Tables["users"]); | 117 | da.Fill(ds.Tables["users"]); |
118 | CreateDataSetMapping(da, "users"); | ||
118 | 119 | ||
119 | setupAgentCommands(dua, conn); | 120 | setupAgentCommands(dua, conn); |
120 | dua.Fill(ds.Tables["useragents"]); | 121 | dua.Fill(ds.Tables["useragents"]); |
122 | CreateDataSetMapping(dua, "useragents"); | ||
121 | 123 | ||
122 | setupUserFriendsCommands(daf, conn); | 124 | setupUserFriendsCommands(daf, conn); |
123 | daf.Fill(ds.Tables["userfriends"]); | 125 | daf.Fill(ds.Tables["userfriends"]); |
126 | CreateDataSetMapping(daf, "userfriends"); | ||
124 | 127 | ||
125 | setupAvatarAppearanceCommands(daa, conn); | 128 | setupAvatarAppearanceCommands(daa, conn); |
126 | daa.Fill(ds.Tables["avatarappearance"]); | 129 | daa.Fill(ds.Tables["avatarappearance"]); |
130 | CreateDataSetMapping(daa, "avatarappearance"); | ||
127 | } | 131 | } |
128 | 132 | ||
129 | return; | 133 | return; |
@@ -706,15 +710,10 @@ namespace OpenSim.Data.SQLite | |||
706 | aa.SkirtItem = new UUID((String)row["SkirtItem"]); | 710 | aa.SkirtItem = new UUID((String)row["SkirtItem"]); |
707 | aa.SkirtAsset = new UUID((String)row["SkirtAsset"]); | 711 | aa.SkirtAsset = new UUID((String)row["SkirtAsset"]); |
708 | 712 | ||
709 | // Ewe Loon | 713 | byte[] texture = (byte[])row["Texture"]; |
710 | // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) | ||
711 | |||
712 | String str = (String)row["Texture"]; | ||
713 | byte[] texture = Convert.FromBase64String(str); | ||
714 | aa.Texture = new Primitive.TextureEntry(texture, 0, texture.Length); | 714 | aa.Texture = new Primitive.TextureEntry(texture, 0, texture.Length); |
715 | 715 | ||
716 | str = (String)row["VisualParams"]; | 716 | byte[] VisualParams = (byte[])row["VisualParams"]; |
717 | byte[] VisualParams = Convert.FromBase64String(str); | ||
718 | aa.VisualParams = VisualParams; | 717 | aa.VisualParams = VisualParams; |
719 | 718 | ||
720 | aa.Serial = Convert.ToInt32(row["Serial"]); | 719 | aa.Serial = Convert.ToInt32(row["Serial"]); |
@@ -793,6 +792,15 @@ namespace OpenSim.Data.SQLite | |||
793 | * | 792 | * |
794 | **********************************************************************/ | 793 | **********************************************************************/ |
795 | 794 | ||
795 | protected void CreateDataSetMapping(IDataAdapter da, string tableName) | ||
796 | { | ||
797 | ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName); | ||
798 | foreach (DataColumn col in ds.Tables[tableName].Columns) | ||
799 | { | ||
800 | dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName); | ||
801 | } | ||
802 | } | ||
803 | |||
796 | /// <summary> | 804 | /// <summary> |
797 | /// Create the "users" table | 805 | /// Create the "users" table |
798 | /// </summary> | 806 | /// </summary> |
@@ -924,9 +932,8 @@ namespace OpenSim.Data.SQLite | |||
924 | SQLiteUtil.createCol(aa, "SkirtItem", typeof(String)); | 932 | SQLiteUtil.createCol(aa, "SkirtItem", typeof(String)); |
925 | SQLiteUtil.createCol(aa, "SkirtAsset", typeof(String)); | 933 | SQLiteUtil.createCol(aa, "SkirtAsset", typeof(String)); |
926 | 934 | ||
927 | // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) | 935 | SQLiteUtil.createCol(aa, "Texture", typeof (Byte[])); |
928 | SQLiteUtil.createCol(aa, "Texture", typeof (String)); | 936 | SQLiteUtil.createCol(aa, "VisualParams", typeof (Byte[])); |
929 | SQLiteUtil.createCol(aa, "VisualParams", typeof (String)); | ||
930 | 937 | ||
931 | SQLiteUtil.createCol(aa, "Serial", typeof(Int32)); | 938 | SQLiteUtil.createCol(aa, "Serial", typeof(Int32)); |
932 | SQLiteUtil.createCol(aa, "AvatarHeight", typeof(Double)); | 939 | SQLiteUtil.createCol(aa, "AvatarHeight", typeof(Double)); |
@@ -1090,8 +1097,8 @@ namespace OpenSim.Data.SQLite | |||
1090 | row["SkirtAsset"] = appearance.SkirtAsset.ToString(); | 1097 | row["SkirtAsset"] = appearance.SkirtAsset.ToString(); |
1091 | 1098 | ||
1092 | // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) | 1099 | // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date) |
1093 | row["Texture"] = Convert.ToBase64String(appearance.Texture.GetBytes()); | 1100 | row["Texture"] = appearance.Texture.GetBytes(); |
1094 | row["VisualParams"] = Convert.ToBase64String(appearance.VisualParams); | 1101 | row["VisualParams"] = appearance.VisualParams; |
1095 | 1102 | ||
1096 | row["Serial"] = appearance.Serial; | 1103 | row["Serial"] = appearance.Serial; |
1097 | row["AvatarHeight"] = appearance.AvatarHeight; | 1104 | row["AvatarHeight"] = appearance.AvatarHeight; |
diff --git a/OpenSim/Data/SQLite/SQLiteUtils.cs b/OpenSim/Data/SQLite/SQLiteUtils.cs index 4a835ce..07c6b69 100644 --- a/OpenSim/Data/SQLite/SQLiteUtils.cs +++ b/OpenSim/Data/SQLite/SQLiteUtils.cs | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Data; | 29 | using System.Data; |
30 | using Mono.Data.SqliteClient; | 30 | using Mono.Data.Sqlite; |
31 | 31 | ||
32 | namespace OpenSim.Data.SQLite | 32 | namespace OpenSim.Data.SQLite |
33 | { | 33 | { |
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index 5c93f88..0d211b6 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs | |||
@@ -29,7 +29,7 @@ using System; | |||
29 | using System.Data; | 29 | using System.Data; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using Mono.Data.SqliteClient; | 32 | using Mono.Data.Sqlite; |
33 | using log4net; | 33 | using log4net; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -147,8 +147,8 @@ namespace OpenSim.Data.SQLite | |||
147 | } | 147 | } |
148 | 148 | ||
149 | reader.Close(); | 149 | reader.Close(); |
150 | CloseReaderCommand(cmd); | 150 | |
151 | 151 | //CloseCommand(cmd); | |
152 | return perms; | 152 | return perms; |
153 | } | 153 | } |
154 | } | 154 | } |