diff options
Diffstat (limited to 'OpenSim/Data/SQLite')
-rw-r--r-- | OpenSim/Data/SQLite/Properties/AssemblyInfo.cs | 2 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteAssetData.cs | 14 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteAuthenticationData.cs | 145 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteAvatarData.cs | 22 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteEstateData.cs | 206 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteFramework.cs | 9 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteFriendsData.cs | 25 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | 116 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteSimulationData.cs | 25 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserAccountData.cs | 25 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteXInventoryData.cs | 182 |
11 files changed, 465 insertions, 306 deletions
diff --git a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs index d45ab50..c9a8553 100644 --- a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs | |||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices; | |||
61 | // You can specify all the values or you can default the Revision and Build Numbers | 61 | // You can specify all the values or you can default the Revision and Build Numbers |
62 | // by using the '*' as shown below: | 62 | // by using the '*' as shown below: |
63 | 63 | ||
64 | [assembly : AssemblyVersion("0.6.5.*")] | 64 | [assembly : AssemblyVersion("0.7.5.*")] |
65 | [assembly : AssemblyFileVersion("0.6.5.0")] | 65 | [assembly : AssemblyFileVersion("0.6.5.0")] |
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 7f7059b..b94a58c 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -204,7 +204,8 @@ namespace OpenSim.Data.SQLite | |||
204 | /// <returns>True if exist, or false.</returns> | 204 | /// <returns>True if exist, or false.</returns> |
205 | override public bool ExistsAsset(UUID uuid) | 205 | override public bool ExistsAsset(UUID uuid) |
206 | { | 206 | { |
207 | lock (this) { | 207 | lock (this) |
208 | { | ||
208 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) | 209 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) |
209 | { | 210 | { |
210 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); | 211 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); |
@@ -355,12 +356,13 @@ namespace OpenSim.Data.SQLite | |||
355 | { | 356 | { |
356 | lock (this) | 357 | lock (this) |
357 | { | 358 | { |
358 | using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) | 359 | using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) |
359 | { | 360 | { |
360 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); | 361 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); |
361 | cmd.ExecuteNonQuery(); | 362 | cmd.ExecuteNonQuery(); |
362 | } | 363 | } |
363 | } | 364 | } |
365 | |||
364 | return true; | 366 | return true; |
365 | } | 367 | } |
366 | 368 | ||
diff --git a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs index 5120453..0428c11 100644 --- a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs +++ b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs | |||
@@ -82,11 +82,14 @@ namespace OpenSim.Data.SQLite | |||
82 | { | 82 | { |
83 | AuthenticationData ret = new AuthenticationData(); | 83 | AuthenticationData ret = new AuthenticationData(); |
84 | ret.Data = new Dictionary<string, object>(); | 84 | ret.Data = new Dictionary<string, object>(); |
85 | IDataReader result; | ||
85 | 86 | ||
86 | SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID"); | 87 | using (SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID")) |
87 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | 88 | { |
89 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | ||
88 | 90 | ||
89 | IDataReader result = ExecuteReader(cmd, m_Connection); | 91 | result = ExecuteReader(cmd, m_Connection); |
92 | } | ||
90 | 93 | ||
91 | try | 94 | try |
92 | { | 95 | { |
@@ -121,10 +124,6 @@ namespace OpenSim.Data.SQLite | |||
121 | catch | 124 | catch |
122 | { | 125 | { |
123 | } | 126 | } |
124 | finally | ||
125 | { | ||
126 | //CloseCommand(cmd); | ||
127 | } | ||
128 | 127 | ||
129 | return null; | 128 | return null; |
130 | } | 129 | } |
@@ -140,84 +139,81 @@ namespace OpenSim.Data.SQLite | |||
140 | foreach (object o in data.Data.Values) | 139 | foreach (object o in data.Data.Values) |
141 | values[i++] = o.ToString(); | 140 | values[i++] = o.ToString(); |
142 | 141 | ||
143 | SqliteCommand cmd = new SqliteCommand(); | 142 | using (SqliteCommand cmd = new SqliteCommand()) |
144 | |||
145 | if (Get(data.PrincipalID) != null) | ||
146 | { | 143 | { |
144 | if (Get(data.PrincipalID) != null) | ||
145 | { | ||
147 | 146 | ||
148 | 147 | ||
149 | string update = "update `" + m_Realm + "` set "; | 148 | string update = "update `" + m_Realm + "` set "; |
150 | bool first = true; | 149 | bool first = true; |
151 | foreach (string field in fields) | 150 | foreach (string field in fields) |
152 | { | 151 | { |
153 | if (!first) | 152 | if (!first) |
154 | update += ", "; | 153 | update += ", "; |
155 | update += "`" + field + "` = :" + field; | 154 | update += "`" + field + "` = :" + field; |
156 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); | 155 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); |
157 | 156 | ||
158 | first = false; | 157 | first = false; |
159 | } | 158 | } |
160 | 159 | ||
161 | update += " where UUID = :UUID"; | 160 | update += " where UUID = :UUID"; |
162 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); | 161 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); |
163 | 162 | ||
164 | cmd.CommandText = update; | 163 | cmd.CommandText = update; |
165 | try | 164 | try |
166 | { | 165 | { |
167 | if (ExecuteNonQuery(cmd, m_Connection) < 1) | 166 | if (ExecuteNonQuery(cmd, m_Connection) < 1) |
167 | { | ||
168 | //CloseCommand(cmd); | ||
169 | return false; | ||
170 | } | ||
171 | } | ||
172 | catch (Exception e) | ||
168 | { | 173 | { |
174 | m_log.Error("[SQLITE]: Exception storing authentication data", e); | ||
169 | //CloseCommand(cmd); | 175 | //CloseCommand(cmd); |
170 | return false; | 176 | return false; |
171 | } | 177 | } |
172 | } | 178 | } |
173 | catch (Exception e) | 179 | else |
174 | { | 180 | { |
175 | m_log.Error("[SQLITE]: Exception storing authentication data", e); | 181 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + |
176 | //CloseCommand(cmd); | 182 | String.Join("`, `", fields) + |
177 | return false; | 183 | "`) values (:UUID, :" + String.Join(", :", fields) + ")"; |
178 | } | ||
179 | } | ||
180 | 184 | ||
181 | else | 185 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); |
182 | { | 186 | foreach (string field in fields) |
183 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + | 187 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); |
184 | String.Join("`, `", fields) + | ||
185 | "`) values (:UUID, :" + String.Join(", :", fields) + ")"; | ||
186 | |||
187 | cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); | ||
188 | foreach (string field in fields) | ||
189 | cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); | ||
190 | 188 | ||
191 | cmd.CommandText = insert; | 189 | cmd.CommandText = insert; |
192 | 190 | ||
193 | try | 191 | try |
194 | { | ||
195 | if (ExecuteNonQuery(cmd, m_Connection) < 1) | ||
196 | { | 192 | { |
197 | //CloseCommand(cmd); | 193 | if (ExecuteNonQuery(cmd, m_Connection) < 1) |
194 | { | ||
195 | return false; | ||
196 | } | ||
197 | } | ||
198 | catch (Exception e) | ||
199 | { | ||
200 | Console.WriteLine(e.ToString()); | ||
198 | return false; | 201 | return false; |
199 | } | 202 | } |
200 | } | 203 | } |
201 | catch (Exception e) | ||
202 | { | ||
203 | Console.WriteLine(e.ToString()); | ||
204 | //CloseCommand(cmd); | ||
205 | return false; | ||
206 | } | ||
207 | } | 204 | } |
208 | 205 | ||
209 | //CloseCommand(cmd); | ||
210 | |||
211 | return true; | 206 | return true; |
212 | } | 207 | } |
213 | 208 | ||
214 | public bool SetDataItem(UUID principalID, string item, string value) | 209 | public bool SetDataItem(UUID principalID, string item, string value) |
215 | { | 210 | { |
216 | SqliteCommand cmd = new SqliteCommand("update `" + m_Realm + | 211 | using (SqliteCommand cmd = new SqliteCommand("update `" + m_Realm + |
217 | "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'"); | 212 | "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'")) |
218 | 213 | { | |
219 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | 214 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
220 | return true; | 215 | return true; |
216 | } | ||
221 | 217 | ||
222 | return false; | 218 | return false; |
223 | } | 219 | } |
@@ -227,16 +223,13 @@ namespace OpenSim.Data.SQLite | |||
227 | if (System.Environment.TickCount - m_LastExpire > 30000) | 223 | if (System.Environment.TickCount - m_LastExpire > 30000) |
228 | DoExpire(); | 224 | DoExpire(); |
229 | 225 | ||
230 | SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + | 226 | using (SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + |
231 | "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))"); | 227 | "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))")) |
232 | |||
233 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | ||
234 | { | 228 | { |
235 | cmd.Dispose(); | 229 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
236 | return true; | 230 | return true; |
237 | } | 231 | } |
238 | 232 | ||
239 | cmd.Dispose(); | ||
240 | return false; | 233 | return false; |
241 | } | 234 | } |
242 | 235 | ||
@@ -245,28 +238,22 @@ namespace OpenSim.Data.SQLite | |||
245 | if (System.Environment.TickCount - m_LastExpire > 30000) | 238 | if (System.Environment.TickCount - m_LastExpire > 30000) |
246 | DoExpire(); | 239 | DoExpire(); |
247 | 240 | ||
248 | SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() + | 241 | using (SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() + |
249 | " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')"); | 242 | " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')")) |
250 | |||
251 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | ||
252 | { | 243 | { |
253 | cmd.Dispose(); | 244 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
254 | return true; | 245 | return true; |
255 | } | 246 | } |
256 | 247 | ||
257 | cmd.Dispose(); | ||
258 | |||
259 | return false; | 248 | return false; |
260 | } | 249 | } |
261 | 250 | ||
262 | private void DoExpire() | 251 | private void DoExpire() |
263 | { | 252 | { |
264 | SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')"); | 253 | using (SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')")) |
265 | ExecuteNonQuery(cmd, m_Connection); | 254 | ExecuteNonQuery(cmd, m_Connection); |
266 | |||
267 | cmd.Dispose(); | ||
268 | 255 | ||
269 | m_LastExpire = System.Environment.TickCount; | 256 | m_LastExpire = System.Environment.TickCount; |
270 | } | 257 | } |
271 | } | 258 | } |
272 | } | 259 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteAvatarData.cs b/OpenSim/Data/SQLite/SQLiteAvatarData.cs index faf34da..c6d615b 100644 --- a/OpenSim/Data/SQLite/SQLiteAvatarData.cs +++ b/OpenSim/Data/SQLite/SQLiteAvatarData.cs | |||
@@ -56,23 +56,17 @@ namespace OpenSim.Data.SQLite | |||
56 | 56 | ||
57 | public bool Delete(UUID principalID, string name) | 57 | public bool Delete(UUID principalID, string name) |
58 | { | 58 | { |
59 | SqliteCommand cmd = new SqliteCommand(); | 59 | using (SqliteCommand cmd = new SqliteCommand()) |
60 | |||
61 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); | ||
62 | cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); | ||
63 | cmd.Parameters.AddWithValue(":Name", name); | ||
64 | |||
65 | try | ||
66 | { | 60 | { |
61 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); | ||
62 | cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); | ||
63 | cmd.Parameters.AddWithValue(":Name", name); | ||
64 | |||
67 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | 65 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
68 | return true; | 66 | return true; |
69 | |||
70 | return false; | ||
71 | } | ||
72 | finally | ||
73 | { | ||
74 | //CloseCommand(cmd); | ||
75 | } | 67 | } |
68 | |||
69 | return false; | ||
76 | } | 70 | } |
77 | } | 71 | } |
78 | } | 72 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index c042ba2..d51f2d4 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs | |||
@@ -104,12 +104,13 @@ namespace OpenSim.Data.SQLite | |||
104 | { | 104 | { |
105 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID"; | 105 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID"; |
106 | 106 | ||
107 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 107 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
108 | 108 | { | |
109 | cmd.CommandText = sql; | 109 | cmd.CommandText = sql; |
110 | cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); | 110 | cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); |
111 | 111 | ||
112 | return DoLoad(cmd, regionID, create); | 112 | return DoLoad(cmd, regionID, create); |
113 | } | ||
113 | } | 114 | } |
114 | 115 | ||
115 | private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) | 116 | private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) |
@@ -186,37 +187,39 @@ namespace OpenSim.Data.SQLite | |||
186 | { | 187 | { |
187 | List<string> names = new List<string>(FieldList); | 188 | List<string> names = new List<string>(FieldList); |
188 | 189 | ||
189 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | ||
190 | IDataReader r = null; | 190 | IDataReader r = null; |
191 | 191 | ||
192 | names.Remove("EstateID"); | 192 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
193 | { | ||
194 | names.Remove("EstateID"); | ||
193 | 195 | ||
194 | string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; | 196 | string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; |
195 | 197 | ||
196 | cmd.CommandText = sql; | 198 | cmd.CommandText = sql; |
197 | cmd.Parameters.Clear(); | 199 | cmd.Parameters.Clear(); |
198 | 200 | ||
199 | foreach (string name in FieldList) | 201 | foreach (string name in FieldList) |
200 | { | ||
201 | if (m_FieldMap[name].GetValue(es) is bool) | ||
202 | { | 202 | { |
203 | if ((bool)m_FieldMap[name].GetValue(es)) | 203 | if (m_FieldMap[name].GetValue(es) is bool) |
204 | cmd.Parameters.AddWithValue(":"+name, "1"); | 204 | { |
205 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
206 | cmd.Parameters.AddWithValue(":"+name, "1"); | ||
207 | else | ||
208 | cmd.Parameters.AddWithValue(":"+name, "0"); | ||
209 | } | ||
205 | else | 210 | else |
206 | cmd.Parameters.AddWithValue(":"+name, "0"); | 211 | { |
207 | } | 212 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); |
208 | else | 213 | } |
209 | { | ||
210 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); | ||
211 | } | 214 | } |
212 | } | ||
213 | 215 | ||
214 | cmd.ExecuteNonQuery(); | 216 | cmd.ExecuteNonQuery(); |
215 | 217 | ||
216 | cmd.CommandText = "select LAST_INSERT_ROWID() as id"; | 218 | cmd.CommandText = "select LAST_INSERT_ROWID() as id"; |
217 | cmd.Parameters.Clear(); | 219 | cmd.Parameters.Clear(); |
218 | 220 | ||
219 | r = cmd.ExecuteReader(); | 221 | r = cmd.ExecuteReader(); |
222 | } | ||
220 | 223 | ||
221 | r.Read(); | 224 | r.Read(); |
222 | 225 | ||
@@ -239,26 +242,27 @@ namespace OpenSim.Data.SQLite | |||
239 | 242 | ||
240 | string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID"; | 243 | string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID"; |
241 | 244 | ||
242 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 245 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
243 | |||
244 | cmd.CommandText = sql; | ||
245 | |||
246 | foreach (string name in FieldList) | ||
247 | { | 246 | { |
248 | if (m_FieldMap[name].GetValue(es) is bool) | 247 | cmd.CommandText = sql; |
248 | |||
249 | foreach (string name in FieldList) | ||
249 | { | 250 | { |
250 | if ((bool)m_FieldMap[name].GetValue(es)) | 251 | if (m_FieldMap[name].GetValue(es) is bool) |
251 | cmd.Parameters.AddWithValue(":"+name, "1"); | 252 | { |
253 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
254 | cmd.Parameters.AddWithValue(":"+name, "1"); | ||
255 | else | ||
256 | cmd.Parameters.AddWithValue(":"+name, "0"); | ||
257 | } | ||
252 | else | 258 | else |
253 | cmd.Parameters.AddWithValue(":"+name, "0"); | 259 | { |
254 | } | 260 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); |
255 | else | 261 | } |
256 | { | ||
257 | cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); | ||
258 | } | 262 | } |
259 | } | ||
260 | 263 | ||
261 | cmd.ExecuteNonQuery(); | 264 | cmd.ExecuteNonQuery(); |
265 | } | ||
262 | 266 | ||
263 | SaveBanList(es); | 267 | SaveBanList(es); |
264 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); | 268 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); |
@@ -270,12 +274,15 @@ namespace OpenSim.Data.SQLite | |||
270 | { | 274 | { |
271 | es.ClearBans(); | 275 | es.ClearBans(); |
272 | 276 | ||
273 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 277 | IDataReader r; |
274 | 278 | ||
275 | cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; | 279 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
276 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID); | 280 | { |
281 | cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; | ||
282 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID); | ||
277 | 283 | ||
278 | IDataReader r = cmd.ExecuteReader(); | 284 | r = cmd.ExecuteReader(); |
285 | } | ||
279 | 286 | ||
280 | while (r.Read()) | 287 | while (r.Read()) |
281 | { | 288 | { |
@@ -294,60 +301,64 @@ namespace OpenSim.Data.SQLite | |||
294 | 301 | ||
295 | private void SaveBanList(EstateSettings es) | 302 | private void SaveBanList(EstateSettings es) |
296 | { | 303 | { |
297 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 304 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
298 | |||
299 | cmd.CommandText = "delete from estateban where EstateID = :EstateID"; | ||
300 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); | ||
301 | |||
302 | cmd.ExecuteNonQuery(); | ||
303 | |||
304 | cmd.Parameters.Clear(); | ||
305 | |||
306 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )"; | ||
307 | |||
308 | foreach (EstateBan b in es.EstateBans) | ||
309 | { | 305 | { |
306 | cmd.CommandText = "delete from estateban where EstateID = :EstateID"; | ||
310 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); | 307 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); |
311 | cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString()); | ||
312 | 308 | ||
313 | cmd.ExecuteNonQuery(); | 309 | cmd.ExecuteNonQuery(); |
310 | |||
314 | cmd.Parameters.Clear(); | 311 | cmd.Parameters.Clear(); |
312 | |||
313 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )"; | ||
314 | |||
315 | foreach (EstateBan b in es.EstateBans) | ||
316 | { | ||
317 | cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); | ||
318 | cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString()); | ||
319 | |||
320 | cmd.ExecuteNonQuery(); | ||
321 | cmd.Parameters.Clear(); | ||
322 | } | ||
315 | } | 323 | } |
316 | } | 324 | } |
317 | 325 | ||
318 | void SaveUUIDList(uint EstateID, string table, UUID[] data) | 326 | void SaveUUIDList(uint EstateID, string table, UUID[] data) |
319 | { | 327 | { |
320 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 328 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
321 | |||
322 | cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; | ||
323 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); | ||
324 | |||
325 | cmd.ExecuteNonQuery(); | ||
326 | |||
327 | cmd.Parameters.Clear(); | ||
328 | |||
329 | cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )"; | ||
330 | |||
331 | foreach (UUID uuid in data) | ||
332 | { | 329 | { |
330 | cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; | ||
333 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); | 331 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); |
334 | cmd.Parameters.AddWithValue(":uuid", uuid.ToString()); | ||
335 | 332 | ||
336 | cmd.ExecuteNonQuery(); | 333 | cmd.ExecuteNonQuery(); |
334 | |||
337 | cmd.Parameters.Clear(); | 335 | cmd.Parameters.Clear(); |
336 | |||
337 | cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )"; | ||
338 | |||
339 | foreach (UUID uuid in data) | ||
340 | { | ||
341 | cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); | ||
342 | cmd.Parameters.AddWithValue(":uuid", uuid.ToString()); | ||
343 | |||
344 | cmd.ExecuteNonQuery(); | ||
345 | cmd.Parameters.Clear(); | ||
346 | } | ||
338 | } | 347 | } |
339 | } | 348 | } |
340 | 349 | ||
341 | UUID[] LoadUUIDList(uint EstateID, string table) | 350 | UUID[] LoadUUIDList(uint EstateID, string table) |
342 | { | 351 | { |
343 | List<UUID> uuids = new List<UUID>(); | 352 | List<UUID> uuids = new List<UUID>(); |
353 | IDataReader r; | ||
344 | 354 | ||
345 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 355 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
346 | 356 | { | |
347 | cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; | 357 | cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; |
348 | cmd.Parameters.AddWithValue(":EstateID", EstateID); | 358 | cmd.Parameters.AddWithValue(":EstateID", EstateID); |
349 | 359 | ||
350 | IDataReader r = cmd.ExecuteReader(); | 360 | r = cmd.ExecuteReader(); |
361 | } | ||
351 | 362 | ||
352 | while (r.Read()) | 363 | while (r.Read()) |
353 | { | 364 | { |
@@ -367,12 +378,13 @@ namespace OpenSim.Data.SQLite | |||
367 | { | 378 | { |
368 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID"; | 379 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID"; |
369 | 380 | ||
370 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 381 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
371 | 382 | { | |
372 | cmd.CommandText = sql; | 383 | cmd.CommandText = sql; |
373 | cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); | 384 | cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); |
374 | 385 | ||
375 | return DoLoad(cmd, UUID.Zero, false); | 386 | return DoLoad(cmd, UUID.Zero, false); |
387 | } | ||
376 | } | 388 | } |
377 | 389 | ||
378 | public List<EstateSettings> LoadEstateSettingsAll() | 390 | public List<EstateSettings> LoadEstateSettingsAll() |
@@ -391,13 +403,15 @@ namespace OpenSim.Data.SQLite | |||
391 | List<int> result = new List<int>(); | 403 | List<int> result = new List<int>(); |
392 | 404 | ||
393 | string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName"; | 405 | string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName"; |
406 | IDataReader r; | ||
394 | 407 | ||
395 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 408 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
396 | 409 | { | |
397 | cmd.CommandText = sql; | 410 | cmd.CommandText = sql; |
398 | cmd.Parameters.AddWithValue(":EstateName", search); | 411 | cmd.Parameters.AddWithValue(":EstateName", search); |
399 | 412 | ||
400 | IDataReader r = cmd.ExecuteReader(); | 413 | r = cmd.ExecuteReader(); |
414 | } | ||
401 | 415 | ||
402 | while (r.Read()) | 416 | while (r.Read()) |
403 | { | 417 | { |
@@ -413,12 +427,14 @@ namespace OpenSim.Data.SQLite | |||
413 | List<int> result = new List<int>(); | 427 | List<int> result = new List<int>(); |
414 | 428 | ||
415 | string sql = "select EstateID from estate_settings"; | 429 | string sql = "select EstateID from estate_settings"; |
430 | IDataReader r; | ||
416 | 431 | ||
417 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 432 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
418 | 433 | { | |
419 | cmd.CommandText = sql; | 434 | cmd.CommandText = sql; |
420 | 435 | ||
421 | IDataReader r = cmd.ExecuteReader(); | 436 | r = cmd.ExecuteReader(); |
437 | } | ||
422 | 438 | ||
423 | while (r.Read()) | 439 | while (r.Read()) |
424 | { | 440 | { |
@@ -434,13 +450,15 @@ namespace OpenSim.Data.SQLite | |||
434 | List<int> result = new List<int>(); | 450 | List<int> result = new List<int>(); |
435 | 451 | ||
436 | string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner"; | 452 | string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner"; |
453 | IDataReader r; | ||
437 | 454 | ||
438 | SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); | 455 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) |
439 | 456 | { | |
440 | cmd.CommandText = sql; | 457 | cmd.CommandText = sql; |
441 | cmd.Parameters.AddWithValue(":EstateOwner", ownerID); | 458 | cmd.Parameters.AddWithValue(":EstateOwner", ownerID); |
442 | 459 | ||
443 | IDataReader r = cmd.ExecuteReader(); | 460 | r = cmd.ExecuteReader(); |
461 | } | ||
444 | 462 | ||
445 | while (r.Read()) | 463 | while (r.Read()) |
446 | { | 464 | { |
diff --git a/OpenSim/Data/SQLite/SQLiteFramework.cs b/OpenSim/Data/SQLite/SQLiteFramework.cs index 1594717..35b9a2f 100644 --- a/OpenSim/Data/SQLite/SQLiteFramework.cs +++ b/OpenSim/Data/SQLite/SQLiteFramework.cs | |||
@@ -90,12 +90,5 @@ namespace OpenSim.Data.SQLite | |||
90 | return cmd.ExecuteReader(); | 90 | return cmd.ExecuteReader(); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | |||
94 | protected void CloseCommand(SqliteCommand cmd) | ||
95 | { | ||
96 | cmd.Connection.Close(); | ||
97 | cmd.Connection.Dispose(); | ||
98 | cmd.Dispose(); | ||
99 | } | ||
100 | } | 93 | } |
101 | } | 94 | } \ No newline at end of file |
diff --git a/OpenSim/Data/SQLite/SQLiteFriendsData.cs b/OpenSim/Data/SQLite/SQLiteFriendsData.cs index 5f68977..cab85eb 100644 --- a/OpenSim/Data/SQLite/SQLiteFriendsData.cs +++ b/OpenSim/Data/SQLite/SQLiteFriendsData.cs | |||
@@ -53,13 +53,13 @@ namespace OpenSim.Data.SQLite | |||
53 | 53 | ||
54 | public FriendsData[] GetFriends(string userID) | 54 | public FriendsData[] GetFriends(string userID) |
55 | { | 55 | { |
56 | SqliteCommand cmd = new SqliteCommand(); | 56 | using (SqliteCommand cmd = new SqliteCommand()) |
57 | 57 | { | |
58 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); | 58 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); |
59 | cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); | 59 | cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); |
60 | |||
61 | return DoQuery(cmd); | ||
62 | 60 | ||
61 | return DoQuery(cmd); | ||
62 | } | ||
63 | } | 63 | } |
64 | 64 | ||
65 | public bool Delete(UUID principalID, string friend) | 65 | public bool Delete(UUID principalID, string friend) |
@@ -69,13 +69,14 @@ namespace OpenSim.Data.SQLite | |||
69 | 69 | ||
70 | public bool Delete(string principalID, string friend) | 70 | public bool Delete(string principalID, string friend) |
71 | { | 71 | { |
72 | SqliteCommand cmd = new SqliteCommand(); | 72 | using (SqliteCommand cmd = new SqliteCommand()) |
73 | 73 | { | |
74 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); | 74 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); |
75 | cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); | 75 | cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); |
76 | cmd.Parameters.AddWithValue(":Friend", friend); | 76 | cmd.Parameters.AddWithValue(":Friend", friend); |
77 | 77 | ||
78 | ExecuteNonQuery(cmd, m_Connection); | 78 | ExecuteNonQuery(cmd, m_Connection); |
79 | } | ||
79 | 80 | ||
80 | return true; | 81 | return true; |
81 | } | 82 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 4f977a8..9fbeb10 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | |||
@@ -120,34 +120,35 @@ namespace OpenSim.Data.SQLite | |||
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | public T[] Get(string field, string key) | 123 | public virtual T[] Get(string field, string key) |
124 | { | 124 | { |
125 | return Get(new string[] { field }, new string[] { key }); | 125 | return Get(new string[] { field }, new string[] { key }); |
126 | } | 126 | } |
127 | 127 | ||
128 | public T[] Get(string[] fields, string[] keys) | 128 | public virtual T[] Get(string[] fields, string[] keys) |
129 | { | 129 | { |
130 | if (fields.Length != keys.Length) | 130 | if (fields.Length != keys.Length) |
131 | return new T[0]; | 131 | return new T[0]; |
132 | 132 | ||
133 | List<string> terms = new List<string>(); | 133 | List<string> terms = new List<string>(); |
134 | 134 | ||
135 | SqliteCommand cmd = new SqliteCommand(); | 135 | using (SqliteCommand cmd = new SqliteCommand()) |
136 | |||
137 | for (int i = 0 ; i < fields.Length ; i++) | ||
138 | { | 136 | { |
139 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); | 137 | for (int i = 0 ; i < fields.Length ; i++) |
140 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | 138 | { |
141 | } | 139 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); |
140 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | ||
141 | } | ||
142 | 142 | ||
143 | string where = String.Join(" and ", terms.ToArray()); | 143 | string where = String.Join(" and ", terms.ToArray()); |
144 | 144 | ||
145 | string query = String.Format("select * from {0} where {1}", | 145 | string query = String.Format("select * from {0} where {1}", |
146 | m_Realm, where); | 146 | m_Realm, where); |
147 | 147 | ||
148 | cmd.CommandText = query; | 148 | cmd.CommandText = query; |
149 | 149 | ||
150 | return DoQuery(cmd); | 150 | return DoQuery(cmd); |
151 | } | ||
151 | } | 152 | } |
152 | 153 | ||
153 | protected T[] DoQuery(SqliteCommand cmd) | 154 | protected T[] DoQuery(SqliteCommand cmd) |
@@ -212,52 +213,54 @@ namespace OpenSim.Data.SQLite | |||
212 | return result.ToArray(); | 213 | return result.ToArray(); |
213 | } | 214 | } |
214 | 215 | ||
215 | public T[] Get(string where) | 216 | public virtual T[] Get(string where) |
216 | { | 217 | { |
217 | SqliteCommand cmd = new SqliteCommand(); | 218 | using (SqliteCommand cmd = new SqliteCommand()) |
218 | 219 | { | |
219 | string query = String.Format("select * from {0} where {1}", | 220 | string query = String.Format("select * from {0} where {1}", |
220 | m_Realm, where); | 221 | m_Realm, where); |
221 | 222 | ||
222 | cmd.CommandText = query; | 223 | cmd.CommandText = query; |
223 | 224 | ||
224 | return DoQuery(cmd); | 225 | return DoQuery(cmd); |
226 | } | ||
225 | } | 227 | } |
226 | 228 | ||
227 | public bool Store(T row) | 229 | public virtual bool Store(T row) |
228 | { | 230 | { |
229 | SqliteCommand cmd = new SqliteCommand(); | 231 | using (SqliteCommand cmd = new SqliteCommand()) |
230 | |||
231 | string query = ""; | ||
232 | List<String> names = new List<String>(); | ||
233 | List<String> values = new List<String>(); | ||
234 | |||
235 | foreach (FieldInfo fi in m_Fields.Values) | ||
236 | { | 232 | { |
237 | names.Add(fi.Name); | 233 | string query = ""; |
238 | values.Add(":" + fi.Name); | 234 | List<String> names = new List<String>(); |
239 | cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString())); | 235 | List<String> values = new List<String>(); |
240 | } | ||
241 | 236 | ||
242 | if (m_DataField != null) | 237 | foreach (FieldInfo fi in m_Fields.Values) |
243 | { | 238 | { |
244 | Dictionary<string, string> data = | 239 | names.Add(fi.Name); |
245 | (Dictionary<string, string>)m_DataField.GetValue(row); | 240 | values.Add(":" + fi.Name); |
241 | cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString())); | ||
242 | } | ||
246 | 243 | ||
247 | foreach (KeyValuePair<string, string> kvp in data) | 244 | if (m_DataField != null) |
248 | { | 245 | { |
249 | names.Add(kvp.Key); | 246 | Dictionary<string, string> data = |
250 | values.Add(":" + kvp.Key); | 247 | (Dictionary<string, string>)m_DataField.GetValue(row); |
251 | cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value)); | 248 | |
249 | foreach (KeyValuePair<string, string> kvp in data) | ||
250 | { | ||
251 | names.Add(kvp.Key); | ||
252 | values.Add(":" + kvp.Key); | ||
253 | cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value)); | ||
254 | } | ||
252 | } | 255 | } |
253 | } | ||
254 | 256 | ||
255 | query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; | 257 | query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; |
256 | 258 | ||
257 | cmd.CommandText = query; | 259 | cmd.CommandText = query; |
258 | 260 | ||
259 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | 261 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
260 | return true; | 262 | return true; |
263 | } | ||
261 | 264 | ||
262 | return false; | 265 | return false; |
263 | } | 266 | } |
@@ -267,28 +270,29 @@ namespace OpenSim.Data.SQLite | |||
267 | return Delete(new string[] { field }, new string[] { key }); | 270 | return Delete(new string[] { field }, new string[] { key }); |
268 | } | 271 | } |
269 | 272 | ||
270 | public bool Delete(string[] fields, string[] keys) | 273 | public virtual bool Delete(string[] fields, string[] keys) |
271 | { | 274 | { |
272 | if (fields.Length != keys.Length) | 275 | if (fields.Length != keys.Length) |
273 | return false; | 276 | return false; |
274 | 277 | ||
275 | List<string> terms = new List<string>(); | 278 | List<string> terms = new List<string>(); |
276 | 279 | ||
277 | SqliteCommand cmd = new SqliteCommand(); | 280 | using (SqliteCommand cmd = new SqliteCommand()) |
278 | |||
279 | for (int i = 0 ; i < fields.Length ; i++) | ||
280 | { | 281 | { |
281 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); | 282 | for (int i = 0 ; i < fields.Length ; i++) |
282 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | 283 | { |
283 | } | 284 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); |
285 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | ||
286 | } | ||
284 | 287 | ||
285 | string where = String.Join(" and ", terms.ToArray()); | 288 | string where = String.Join(" and ", terms.ToArray()); |
286 | 289 | ||
287 | string query = String.Format("delete from {0} where {1}", m_Realm, where); | 290 | string query = String.Format("delete from {0} where {1}", m_Realm, where); |
288 | 291 | ||
289 | cmd.CommandText = query; | 292 | cmd.CommandText = query; |
290 | 293 | ||
291 | return ExecuteNonQuery(cmd, m_Connection) > 0; | 294 | return ExecuteNonQuery(cmd, m_Connection) > 0; |
295 | } | ||
292 | } | 296 | } |
293 | } | 297 | } |
294 | } | 298 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 431709f..42cd59d 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs | |||
@@ -1366,6 +1366,13 @@ namespace OpenSim.Data.SQLite | |||
1366 | createCol(land, "UserLookAtZ", typeof(Double)); | 1366 | createCol(land, "UserLookAtZ", typeof(Double)); |
1367 | createCol(land, "AuthbuyerID", typeof(String)); | 1367 | createCol(land, "AuthbuyerID", typeof(String)); |
1368 | createCol(land, "OtherCleanTime", typeof(Int32)); | 1368 | createCol(land, "OtherCleanTime", typeof(Int32)); |
1369 | createCol(land, "Dwell", typeof(Int32)); | ||
1370 | createCol(land, "MediaType", typeof(String)); | ||
1371 | createCol(land, "MediaDescription", typeof(String)); | ||
1372 | createCol(land, "MediaSize", typeof(String)); | ||
1373 | createCol(land, "MediaLoop", typeof(Boolean)); | ||
1374 | createCol(land, "ObscureMedia", typeof(Boolean)); | ||
1375 | createCol(land, "ObscureMusic", typeof(Boolean)); | ||
1369 | 1376 | ||
1370 | land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; | 1377 | land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; |
1371 | 1378 | ||
@@ -1781,9 +1788,16 @@ namespace OpenSim.Data.SQLite | |||
1781 | newData.PassHours = Convert.ToSingle(row["PassHours"]); | 1788 | newData.PassHours = Convert.ToSingle(row["PassHours"]); |
1782 | newData.PassPrice = Convert.ToInt32(row["PassPrice"]); | 1789 | newData.PassPrice = Convert.ToInt32(row["PassPrice"]); |
1783 | newData.SnapshotID = (UUID)(String)row["SnapshotUUID"]; | 1790 | newData.SnapshotID = (UUID)(String)row["SnapshotUUID"]; |
1791 | newData.Dwell = Convert.ToInt32(row["Dwell"]); | ||
1792 | newData.MediaType = (String)row["MediaType"]; | ||
1793 | newData.MediaDescription = (String)row["MediaDescription"]; | ||
1794 | newData.MediaWidth = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[0]); | ||
1795 | newData.MediaHeight = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[1]); | ||
1796 | newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); | ||
1797 | newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); | ||
1798 | newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); | ||
1784 | try | 1799 | try |
1785 | { | 1800 | { |
1786 | |||
1787 | newData.UserLocation = | 1801 | newData.UserLocation = |
1788 | new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), | 1802 | new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), |
1789 | Convert.ToSingle(row["UserLocationZ"])); | 1803 | Convert.ToSingle(row["UserLocationZ"])); |
@@ -2195,12 +2209,13 @@ namespace OpenSim.Data.SQLite | |||
2195 | row["UserLookAtZ"] = land.UserLookAt.Z; | 2209 | row["UserLookAtZ"] = land.UserLookAt.Z; |
2196 | row["AuthbuyerID"] = land.AuthBuyerID.ToString(); | 2210 | row["AuthbuyerID"] = land.AuthBuyerID.ToString(); |
2197 | row["OtherCleanTime"] = land.OtherCleanTime; | 2211 | row["OtherCleanTime"] = land.OtherCleanTime; |
2212 | row["Dwell"] = land.Dwell; | ||
2198 | row["MediaType"] = land.MediaType; | 2213 | row["MediaType"] = land.MediaType; |
2199 | row["MediaDescription"] = land.MediaDescription; | 2214 | row["MediaDescription"] = land.MediaDescription; |
2200 | row["MediaSize"] = land.MediaWidth.ToString() + "," + land.MediaHeight.ToString(); | 2215 | row["MediaSize"] = String.Format("{0},{1}", land.MediaWidth, land.MediaHeight); |
2201 | row["MediaLoop"] = land.MediaLoop.ToString(); | 2216 | row["MediaLoop"] = land.MediaLoop; |
2202 | row["ObscureMusic"] = land.ObscureMusic.ToString(); | 2217 | row["ObscureMusic"] = land.ObscureMusic; |
2203 | row["ObscureMedia"] = land.ObscureMedia.ToString(); | 2218 | row["ObscureMedia"] = land.ObscureMedia; |
2204 | } | 2219 | } |
2205 | 2220 | ||
2206 | /// <summary> | 2221 | /// <summary> |
diff --git a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs index 4d580c0..91d62ce 100644 --- a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs | |||
@@ -66,20 +66,21 @@ namespace OpenSim.Data.SQLite | |||
66 | if (words.Length > 2) | 66 | if (words.Length > 2) |
67 | return new UserAccountData[0]; | 67 | return new UserAccountData[0]; |
68 | 68 | ||
69 | SqliteCommand cmd = new SqliteCommand(); | 69 | using (SqliteCommand cmd = new SqliteCommand()) |
70 | |||
71 | if (words.Length == 1) | ||
72 | { | ||
73 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", | ||
74 | m_Realm, scopeID.ToString(), words[0]); | ||
75 | } | ||
76 | else | ||
77 | { | 70 | { |
78 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", | 71 | if (words.Length == 1) |
79 | m_Realm, scopeID.ToString(), words[0], words[1]); | 72 | { |
80 | } | 73 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", |
74 | m_Realm, scopeID.ToString(), words[0]); | ||
75 | } | ||
76 | else | ||
77 | { | ||
78 | cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", | ||
79 | m_Realm, scopeID.ToString(), words[0], words[1]); | ||
80 | } | ||
81 | 81 | ||
82 | return DoQuery(cmd); | 82 | return DoQuery(cmd); |
83 | } | ||
83 | } | 84 | } |
84 | 85 | ||
85 | public UserAccountData[] GetUsersWhere(UUID scopeID, string where) | 86 | public UserAccountData[] GetUsersWhere(UUID scopeID, string where) |
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index 1f36986..2a0a8f6 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Data.SQLite | |||
47 | { | 47 | { |
48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | private SQLiteGenericTableHandler<XInventoryFolder> m_Folders; | 50 | private SqliteFolderHandler m_Folders; |
51 | private SqliteItemHandler m_Items; | 51 | private SqliteItemHandler m_Items; |
52 | 52 | ||
53 | public SQLiteXInventoryData(string conn, string realm) | 53 | public SQLiteXInventoryData(string conn, string realm) |
@@ -55,7 +55,7 @@ namespace OpenSim.Data.SQLite | |||
55 | if (Util.IsWindows()) | 55 | if (Util.IsWindows()) |
56 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | 56 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); |
57 | 57 | ||
58 | m_Folders = new SQLiteGenericTableHandler<XInventoryFolder>( | 58 | m_Folders = new SqliteFolderHandler( |
59 | conn, "inventoryfolders", "XInventoryStore"); | 59 | conn, "inventoryfolders", "XInventoryStore"); |
60 | m_Items = new SqliteItemHandler( | 60 | m_Items = new SqliteItemHandler( |
61 | conn, "inventoryitems", String.Empty); | 61 | conn, "inventoryitems", String.Empty); |
@@ -114,6 +114,11 @@ namespace OpenSim.Data.SQLite | |||
114 | return m_Items.MoveItem(id, newParent); | 114 | return m_Items.MoveItem(id, newParent); |
115 | } | 115 | } |
116 | 116 | ||
117 | public bool MoveFolder(string id, string newParent) | ||
118 | { | ||
119 | return m_Folders.MoveFolder(id, newParent); | ||
120 | } | ||
121 | |||
117 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 122 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
118 | { | 123 | { |
119 | return m_Items.GetActiveGestures(principalID); | 124 | return m_Items.GetActiveGestures(principalID); |
@@ -125,44 +130,106 @@ namespace OpenSim.Data.SQLite | |||
125 | } | 130 | } |
126 | } | 131 | } |
127 | 132 | ||
128 | public class SqliteItemHandler : SQLiteGenericTableHandler<XInventoryItem> | 133 | public class SqliteItemHandler : SqliteInventoryHandler<XInventoryItem> |
129 | { | 134 | { |
130 | public SqliteItemHandler(string c, string t, string m) : | 135 | public SqliteItemHandler(string c, string t, string m) : |
131 | base(c, t, m) | 136 | base(c, t, m) |
132 | { | 137 | { |
133 | } | 138 | } |
134 | 139 | ||
140 | public override bool Store(XInventoryItem item) | ||
141 | { | ||
142 | if (!base.Store(item)) | ||
143 | return false; | ||
144 | |||
145 | IncrementFolderVersion(item.parentFolderID); | ||
146 | |||
147 | return true; | ||
148 | } | ||
149 | |||
150 | public override bool Delete(string field, string val) | ||
151 | { | ||
152 | XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val }); | ||
153 | if (retrievedItems.Length == 0) | ||
154 | return false; | ||
155 | |||
156 | if (!base.Delete(field, val)) | ||
157 | return false; | ||
158 | |||
159 | // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[]) | ||
160 | // IncrementFolderVersion(retrievedItems[0].parentFolderID); | ||
161 | |||
162 | return true; | ||
163 | } | ||
164 | |||
165 | public override bool Delete(string[] fields, string[] vals) | ||
166 | { | ||
167 | XInventoryItem[] retrievedItems = Get(fields, vals); | ||
168 | if (retrievedItems.Length == 0) | ||
169 | return false; | ||
170 | |||
171 | if (!base.Delete(fields, vals)) | ||
172 | return false; | ||
173 | |||
174 | HashSet<UUID> deletedItemFolderUUIDs = new HashSet<UUID>(); | ||
175 | |||
176 | Array.ForEach<XInventoryItem>(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID)); | ||
177 | |||
178 | foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs) | ||
179 | IncrementFolderVersion(deletedItemFolderUUID); | ||
180 | |||
181 | return true; | ||
182 | } | ||
183 | |||
135 | public bool MoveItem(string id, string newParent) | 184 | public bool MoveItem(string id, string newParent) |
136 | { | 185 | { |
137 | SqliteCommand cmd = new SqliteCommand(); | 186 | XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id }); |
187 | if (retrievedItems.Length == 0) | ||
188 | return false; | ||
189 | |||
190 | UUID oldParent = retrievedItems[0].parentFolderID; | ||
191 | |||
192 | using (SqliteCommand cmd = new SqliteCommand()) | ||
193 | { | ||
194 | cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm); | ||
195 | cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); | ||
196 | cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); | ||
138 | 197 | ||
139 | cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm); | 198 | if (ExecuteNonQuery(cmd, m_Connection) == 0) |
140 | cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); | 199 | return false; |
141 | cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); | 200 | } |
201 | |||
202 | IncrementFolderVersion(oldParent); | ||
203 | IncrementFolderVersion(newParent); | ||
142 | 204 | ||
143 | return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true; | 205 | return true; |
144 | } | 206 | } |
145 | 207 | ||
146 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 208 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
147 | { | 209 | { |
148 | SqliteCommand cmd = new SqliteCommand(); | 210 | using (SqliteCommand cmd = new SqliteCommand()) |
149 | cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm); | 211 | { |
212 | cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm); | ||
150 | 213 | ||
151 | cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString())); | 214 | cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString())); |
152 | cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture)); | 215 | cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture)); |
153 | 216 | ||
154 | return DoQuery(cmd); | 217 | return DoQuery(cmd); |
218 | } | ||
155 | } | 219 | } |
156 | 220 | ||
157 | public int GetAssetPermissions(UUID principalID, UUID assetID) | 221 | public int GetAssetPermissions(UUID principalID, UUID assetID) |
158 | { | 222 | { |
159 | SqliteCommand cmd = new SqliteCommand(); | 223 | IDataReader reader; |
160 | 224 | ||
161 | cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm); | 225 | using (SqliteCommand cmd = new SqliteCommand()) |
162 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | 226 | { |
163 | cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); | 227 | cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm); |
228 | cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); | ||
229 | cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); | ||
164 | 230 | ||
165 | IDataReader reader = ExecuteReader(cmd, m_Connection); | 231 | reader = ExecuteReader(cmd, m_Connection); |
232 | } | ||
166 | 233 | ||
167 | int perms = 0; | 234 | int perms = 0; |
168 | 235 | ||
@@ -177,4 +244,81 @@ namespace OpenSim.Data.SQLite | |||
177 | return perms; | 244 | return perms; |
178 | } | 245 | } |
179 | } | 246 | } |
180 | } | 247 | |
248 | public class SqliteFolderHandler : SqliteInventoryHandler<XInventoryFolder> | ||
249 | { | ||
250 | public SqliteFolderHandler(string c, string t, string m) : | ||
251 | base(c, t, m) | ||
252 | { | ||
253 | } | ||
254 | |||
255 | public override bool Store(XInventoryFolder folder) | ||
256 | { | ||
257 | if (!base.Store(folder)) | ||
258 | return false; | ||
259 | |||
260 | IncrementFolderVersion(folder.parentFolderID); | ||
261 | |||
262 | return true; | ||
263 | } | ||
264 | |||
265 | public bool MoveFolder(string id, string newParentFolderID) | ||
266 | { | ||
267 | XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); | ||
268 | |||
269 | if (folders.Length == 0) | ||
270 | return false; | ||
271 | |||
272 | UUID oldParentFolderUUID = folders[0].parentFolderID; | ||
273 | |||
274 | using (SqliteCommand cmd = new SqliteCommand()) | ||
275 | { | ||
276 | cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm); | ||
277 | cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParentFolderID)); | ||
278 | cmd.Parameters.Add(new SqliteParameter(":FolderID", id)); | ||
279 | |||
280 | if (ExecuteNonQuery(cmd, m_Connection) == 0) | ||
281 | return false; | ||
282 | } | ||
283 | |||
284 | IncrementFolderVersion(oldParentFolderUUID); | ||
285 | IncrementFolderVersion(newParentFolderID); | ||
286 | |||
287 | return true; | ||
288 | } | ||
289 | |||
290 | } | ||
291 | |||
292 | public class SqliteInventoryHandler<T> : SQLiteGenericTableHandler<T> where T: class, new() | ||
293 | { | ||
294 | public SqliteInventoryHandler(string c, string t, string m) : base(c, t, m) {} | ||
295 | |||
296 | protected bool IncrementFolderVersion(UUID folderID) | ||
297 | { | ||
298 | return IncrementFolderVersion(folderID.ToString()); | ||
299 | } | ||
300 | |||
301 | protected bool IncrementFolderVersion(string folderID) | ||
302 | { | ||
303 | // m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); | ||
304 | // Util.PrintCallStack(); | ||
305 | |||
306 | using (SqliteCommand cmd = new SqliteCommand()) | ||
307 | { | ||
308 | cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID"; | ||
309 | cmd.Parameters.Add(new SqliteParameter(":folderID", folderID)); | ||
310 | |||
311 | try | ||
312 | { | ||
313 | cmd.ExecuteNonQuery(); | ||
314 | } | ||
315 | catch (Exception) | ||
316 | { | ||
317 | return false; | ||
318 | } | ||
319 | } | ||
320 | |||
321 | return true; | ||
322 | } | ||
323 | } | ||
324 | } \ No newline at end of file | ||