diff options
author | Justin Clark-Casey (justincc) | 2012-04-30 15:54:35 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-04-30 15:54:35 +0100 |
commit | 522eff61383e9a8acfdf34289cd64a8fdc27bb19 (patch) | |
tree | 3e9d6428bf6832caafd69d45c3a377a9f643dcae /OpenSim/Data/MySQL | |
parent | Comment out debug [ASYNC DELETER] messages for now. (diff) | |
download | opensim-SC_OLD-522eff61383e9a8acfdf34289cd64a8fdc27bb19.zip opensim-SC_OLD-522eff61383e9a8acfdf34289cd64a8fdc27bb19.tar.gz opensim-SC_OLD-522eff61383e9a8acfdf34289cd64a8fdc27bb19.tar.bz2 opensim-SC_OLD-522eff61383e9a8acfdf34289cd64a8fdc27bb19.tar.xz |
Consistently use using() to make sure we dispose of used MySqlCommands where this is not already being done.
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAssetData.cs | 180 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 165 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAvatarData.cs | 17 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLFriendsData.cs | 36 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLInventoryData.cs | 130 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLPresenceData.cs | 36 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLRegionData.cs | 13 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 267 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserAccountData.cs | 33 |
9 files changed, 446 insertions, 431 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index a743479..73de64b 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -163,52 +163,51 @@ namespace OpenSim.Data.MySQL | |||
163 | { | 163 | { |
164 | dbcon.Open(); | 164 | dbcon.Open(); |
165 | 165 | ||
166 | MySqlCommand cmd = | 166 | using (MySqlCommand cmd = |
167 | new MySqlCommand( | 167 | new MySqlCommand( |
168 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + | 168 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + |
169 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", | 169 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", |
170 | dbcon); | 170 | dbcon)) |
171 | |||
172 | string assetName = asset.Name; | ||
173 | if (asset.Name.Length > 64) | ||
174 | { | ||
175 | assetName = asset.Name.Substring(0, 64); | ||
176 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); | ||
177 | } | ||
178 | |||
179 | string assetDescription = asset.Description; | ||
180 | if (asset.Description.Length > 64) | ||
181 | { | ||
182 | assetDescription = asset.Description.Substring(0, 64); | ||
183 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); | ||
184 | } | ||
185 | |||
186 | // need to ensure we dispose | ||
187 | try | ||
188 | { | 171 | { |
189 | using (cmd) | 172 | string assetName = asset.Name; |
173 | if (asset.Name.Length > 64) | ||
190 | { | 174 | { |
191 | // create unix epoch time | 175 | assetName = asset.Name.Substring(0, 64); |
192 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 176 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); |
193 | cmd.Parameters.AddWithValue("?id", asset.ID); | 177 | } |
194 | cmd.Parameters.AddWithValue("?name", assetName); | 178 | |
195 | cmd.Parameters.AddWithValue("?description", assetDescription); | 179 | string assetDescription = asset.Description; |
196 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | 180 | if (asset.Description.Length > 64) |
197 | cmd.Parameters.AddWithValue("?local", asset.Local); | 181 | { |
198 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | 182 | assetDescription = asset.Description.Substring(0, 64); |
199 | cmd.Parameters.AddWithValue("?create_time", now); | 183 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); |
200 | cmd.Parameters.AddWithValue("?access_time", now); | 184 | } |
201 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | 185 | |
202 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | 186 | try |
203 | cmd.Parameters.AddWithValue("?data", asset.Data); | 187 | { |
204 | cmd.ExecuteNonQuery(); | 188 | using (cmd) |
205 | cmd.Dispose(); | 189 | { |
190 | // create unix epoch time | ||
191 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
192 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
193 | cmd.Parameters.AddWithValue("?name", assetName); | ||
194 | cmd.Parameters.AddWithValue("?description", assetDescription); | ||
195 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | ||
196 | cmd.Parameters.AddWithValue("?local", asset.Local); | ||
197 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | ||
198 | cmd.Parameters.AddWithValue("?create_time", now); | ||
199 | cmd.Parameters.AddWithValue("?access_time", now); | ||
200 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
201 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | ||
202 | cmd.Parameters.AddWithValue("?data", asset.Data); | ||
203 | cmd.ExecuteNonQuery(); | ||
204 | } | ||
205 | } | ||
206 | catch (Exception e) | ||
207 | { | ||
208 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", | ||
209 | asset.FullID, asset.Name, e.Message); | ||
206 | } | 210 | } |
207 | } | ||
208 | catch (Exception e) | ||
209 | { | ||
210 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", | ||
211 | asset.FullID, asset.Name, e.Message); | ||
212 | } | 211 | } |
213 | } | 212 | } |
214 | } | 213 | } |
@@ -221,33 +220,31 @@ namespace OpenSim.Data.MySQL | |||
221 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 220 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
222 | { | 221 | { |
223 | dbcon.Open(); | 222 | dbcon.Open(); |
224 | MySqlCommand cmd = | ||
225 | new MySqlCommand("update assets set access_time=?access_time where id=?id", | ||
226 | dbcon); | ||
227 | 223 | ||
228 | // need to ensure we dispose | 224 | using (MySqlCommand cmd |
229 | try | 225 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) |
230 | { | 226 | { |
231 | using (cmd) | 227 | try |
232 | { | 228 | { |
233 | // create unix epoch time | 229 | using (cmd) |
234 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 230 | { |
235 | cmd.Parameters.AddWithValue("?id", asset.ID); | 231 | // create unix epoch time |
236 | cmd.Parameters.AddWithValue("?access_time", now); | 232 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
237 | cmd.ExecuteNonQuery(); | 233 | cmd.Parameters.AddWithValue("?id", asset.ID); |
238 | cmd.Dispose(); | 234 | cmd.Parameters.AddWithValue("?access_time", now); |
235 | cmd.ExecuteNonQuery(); | ||
236 | } | ||
237 | } | ||
238 | catch (Exception e) | ||
239 | { | ||
240 | m_log.ErrorFormat( | ||
241 | "[ASSETS DB]: " + | ||
242 | "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | ||
243 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | ||
239 | } | 244 | } |
240 | } | ||
241 | catch (Exception e) | ||
242 | { | ||
243 | m_log.ErrorFormat( | ||
244 | "[ASSETS DB]: " + | ||
245 | "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | ||
246 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | ||
247 | } | 245 | } |
248 | } | 246 | } |
249 | } | 247 | } |
250 | |||
251 | } | 248 | } |
252 | 249 | ||
253 | /// <summary> | 250 | /// <summary> |
@@ -310,35 +307,41 @@ namespace OpenSim.Data.MySQL | |||
310 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 307 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
311 | { | 308 | { |
312 | dbcon.Open(); | 309 | dbcon.Open(); |
313 | MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", dbcon); | ||
314 | cmd.Parameters.AddWithValue("?start", start); | ||
315 | cmd.Parameters.AddWithValue("?count", count); | ||
316 | 310 | ||
317 | try | 311 | using (MySqlCommand cmd |
312 | = new MySqlCommand( | ||
313 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
314 | dbcon)) | ||
318 | { | 315 | { |
319 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 316 | cmd.Parameters.AddWithValue("?start", start); |
317 | cmd.Parameters.AddWithValue("?count", count); | ||
318 | |||
319 | try | ||
320 | { | 320 | { |
321 | while (dbReader.Read()) | 321 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
322 | { | 322 | { |
323 | AssetMetadata metadata = new AssetMetadata(); | 323 | while (dbReader.Read()) |
324 | metadata.Name = (string)dbReader["name"]; | 324 | { |
325 | metadata.Description = (string)dbReader["description"]; | 325 | AssetMetadata metadata = new AssetMetadata(); |
326 | metadata.Type = (sbyte)dbReader["assetType"]; | 326 | metadata.Name = (string)dbReader["name"]; |
327 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | 327 | metadata.Description = (string)dbReader["description"]; |
328 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 328 | metadata.Type = (sbyte)dbReader["assetType"]; |
329 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 329 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. |
330 | metadata.CreatorID = dbReader["CreatorID"].ToString(); | 330 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); |
331 | 331 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | |
332 | // Current SHA1s are not stored/computed. | 332 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
333 | metadata.SHA1 = new byte[] { }; | 333 | |
334 | 334 | // Current SHA1s are not stored/computed. | |
335 | retList.Add(metadata); | 335 | metadata.SHA1 = new byte[] { }; |
336 | |||
337 | retList.Add(metadata); | ||
338 | } | ||
336 | } | 339 | } |
337 | } | 340 | } |
338 | } | 341 | catch (Exception e) |
339 | catch (Exception e) | 342 | { |
340 | { | 343 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); |
341 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); | 344 | } |
342 | } | 345 | } |
343 | } | 346 | } |
344 | } | 347 | } |
@@ -353,11 +356,12 @@ namespace OpenSim.Data.MySQL | |||
353 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 356 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
354 | { | 357 | { |
355 | dbcon.Open(); | 358 | dbcon.Open(); |
356 | MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon); | ||
357 | cmd.Parameters.AddWithValue("?id", id); | ||
358 | cmd.ExecuteNonQuery(); | ||
359 | 359 | ||
360 | cmd.Dispose(); | 360 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) |
361 | { | ||
362 | cmd.Parameters.AddWithValue("?id", id); | ||
363 | cmd.ExecuteNonQuery(); | ||
364 | } | ||
361 | } | 365 | } |
362 | } | 366 | } |
363 | 367 | ||
@@ -366,4 +370,4 @@ namespace OpenSim.Data.MySQL | |||
366 | 370 | ||
367 | #endregion | 371 | #endregion |
368 | } | 372 | } |
369 | } | 373 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 664ce84..7627497 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |||
@@ -70,30 +70,34 @@ namespace OpenSim.Data.MySQL | |||
70 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 70 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
71 | { | 71 | { |
72 | dbcon.Open(); | 72 | dbcon.Open(); |
73 | MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon); | ||
74 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
75 | |||
76 | IDataReader result = cmd.ExecuteReader(); | ||
77 | 73 | ||
78 | if (result.Read()) | 74 | using (MySqlCommand cmd |
75 | = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon)) | ||
79 | { | 76 | { |
80 | ret.PrincipalID = principalID; | 77 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); |
81 | |||
82 | CheckColumnNames(result); | ||
83 | 78 | ||
84 | foreach (string s in m_ColumnNames) | 79 | IDataReader result = cmd.ExecuteReader(); |
80 | |||
81 | if (result.Read()) | ||
85 | { | 82 | { |
86 | if (s == "UUID") | 83 | ret.PrincipalID = principalID; |
87 | continue; | 84 | |
88 | 85 | CheckColumnNames(result); | |
89 | ret.Data[s] = result[s].ToString(); | 86 | |
87 | foreach (string s in m_ColumnNames) | ||
88 | { | ||
89 | if (s == "UUID") | ||
90 | continue; | ||
91 | |||
92 | ret.Data[s] = result[s].ToString(); | ||
93 | } | ||
94 | |||
95 | return ret; | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | return null; | ||
90 | } | 100 | } |
91 | |||
92 | return ret; | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | return null; | ||
97 | } | 101 | } |
98 | } | 102 | } |
99 | } | 103 | } |
@@ -119,57 +123,53 @@ namespace OpenSim.Data.MySQL | |||
119 | 123 | ||
120 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 124 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
121 | 125 | ||
122 | MySqlCommand cmd = new MySqlCommand(); | 126 | using (MySqlCommand cmd = new MySqlCommand()) |
123 | |||
124 | string update = "update `"+m_Realm+"` set "; | ||
125 | bool first = true; | ||
126 | foreach (string field in fields) | ||
127 | { | 127 | { |
128 | if (!first) | 128 | string update = "update `"+m_Realm+"` set "; |
129 | update += ", "; | 129 | bool first = true; |
130 | update += "`" + field + "` = ?"+field; | 130 | foreach (string field in fields) |
131 | 131 | { | |
132 | first = false; | 132 | if (!first) |
133 | 133 | update += ", "; | |
134 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); | 134 | update += "`" + field + "` = ?"+field; |
135 | } | 135 | |
136 | 136 | first = false; | |
137 | update += " where UUID = ?principalID"; | 137 | |
138 | 138 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); | |
139 | cmd.CommandText = update; | 139 | } |
140 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); | 140 | |
141 | 141 | update += " where UUID = ?principalID"; | |
142 | if (ExecuteNonQuery(cmd) < 1) | 142 | |
143 | { | 143 | cmd.CommandText = update; |
144 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + | 144 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); |
145 | String.Join("`, `", fields) + | 145 | |
146 | "`) values (?principalID, ?" + String.Join(", ?", fields) + ")"; | ||
147 | |||
148 | cmd.CommandText = insert; | ||
149 | |||
150 | if (ExecuteNonQuery(cmd) < 1) | 146 | if (ExecuteNonQuery(cmd) < 1) |
151 | { | 147 | { |
152 | cmd.Dispose(); | 148 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + |
153 | return false; | 149 | String.Join("`, `", fields) + |
150 | "`) values (?principalID, ?" + String.Join(", ?", fields) + ")"; | ||
151 | |||
152 | cmd.CommandText = insert; | ||
153 | |||
154 | if (ExecuteNonQuery(cmd) < 1) | ||
155 | return false; | ||
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
157 | cmd.Dispose(); | ||
158 | |||
159 | return true; | 159 | return true; |
160 | } | 160 | } |
161 | 161 | ||
162 | public bool SetDataItem(UUID principalID, string item, string value) | 162 | public bool SetDataItem(UUID principalID, string item, string value) |
163 | { | 163 | { |
164 | MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + | 164 | using (MySqlCommand cmd |
165 | "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); | 165 | = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where UUID = ?UUID")) |
166 | 166 | { | |
167 | 167 | cmd.Parameters.AddWithValue("?"+item, value); | |
168 | cmd.Parameters.AddWithValue("?"+item, value); | 168 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); |
169 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); | 169 | |
170 | 170 | if (ExecuteNonQuery(cmd) > 0) | |
171 | if (ExecuteNonQuery(cmd) > 0) | 171 | return true; |
172 | return true; | 172 | } |
173 | 173 | ||
174 | return false; | 174 | return false; |
175 | } | 175 | } |
@@ -179,18 +179,18 @@ namespace OpenSim.Data.MySQL | |||
179 | if (System.Environment.TickCount - m_LastExpire > 30000) | 179 | if (System.Environment.TickCount - m_LastExpire > 30000) |
180 | DoExpire(); | 180 | DoExpire(); |
181 | 181 | ||
182 | MySqlCommand cmd = new MySqlCommand("insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))"); | 182 | using (MySqlCommand cmd |
183 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | 183 | = new MySqlCommand( |
184 | cmd.Parameters.AddWithValue("?token", token); | 184 | "insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))")) |
185 | cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); | ||
186 | |||
187 | if (ExecuteNonQuery(cmd) > 0) | ||
188 | { | 185 | { |
189 | cmd.Dispose(); | 186 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); |
190 | return true; | 187 | cmd.Parameters.AddWithValue("?token", token); |
188 | cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); | ||
189 | |||
190 | if (ExecuteNonQuery(cmd) > 0) | ||
191 | return true; | ||
191 | } | 192 | } |
192 | 193 | ||
193 | cmd.Dispose(); | ||
194 | return false; | 194 | return false; |
195 | } | 195 | } |
196 | 196 | ||
@@ -199,30 +199,29 @@ namespace OpenSim.Data.MySQL | |||
199 | if (System.Environment.TickCount - m_LastExpire > 30000) | 199 | if (System.Environment.TickCount - m_LastExpire > 30000) |
200 | DoExpire(); | 200 | DoExpire(); |
201 | 201 | ||
202 | MySqlCommand cmd = new MySqlCommand("update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()"); | 202 | using (MySqlCommand cmd |
203 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | 203 | = new MySqlCommand( |
204 | cmd.Parameters.AddWithValue("?token", token); | 204 | "update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()")) |
205 | cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); | ||
206 | |||
207 | if (ExecuteNonQuery(cmd) > 0) | ||
208 | { | 205 | { |
209 | cmd.Dispose(); | 206 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); |
210 | return true; | 207 | cmd.Parameters.AddWithValue("?token", token); |
211 | } | 208 | cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); |
212 | 209 | ||
213 | cmd.Dispose(); | 210 | if (ExecuteNonQuery(cmd) > 0) |
211 | return true; | ||
212 | } | ||
214 | 213 | ||
215 | return false; | 214 | return false; |
216 | } | 215 | } |
217 | 216 | ||
218 | private void DoExpire() | 217 | private void DoExpire() |
219 | { | 218 | { |
220 | MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()"); | 219 | using (MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()")) |
221 | ExecuteNonQuery(cmd); | 220 | { |
222 | 221 | ExecuteNonQuery(cmd); | |
223 | cmd.Dispose(); | 222 | } |
224 | 223 | ||
225 | m_LastExpire = System.Environment.TickCount; | 224 | m_LastExpire = System.Environment.TickCount; |
226 | } | 225 | } |
227 | } | 226 | } |
228 | } | 227 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs index 8c841ab..6a2f5d8 100644 --- a/OpenSim/Data/MySQL/MySQLAvatarData.cs +++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs | |||
@@ -52,14 +52,15 @@ namespace OpenSim.Data.MySQL | |||
52 | 52 | ||
53 | public bool Delete(UUID principalID, string name) | 53 | public bool Delete(UUID principalID, string name) |
54 | { | 54 | { |
55 | MySqlCommand cmd = new MySqlCommand(); | 55 | using (MySqlCommand cmd = new MySqlCommand()) |
56 | 56 | { | |
57 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); | 57 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); |
58 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | 58 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); |
59 | cmd.Parameters.AddWithValue("?Name", name); | 59 | cmd.Parameters.AddWithValue("?Name", name); |
60 | 60 | ||
61 | if (ExecuteNonQuery(cmd) > 0) | 61 | if (ExecuteNonQuery(cmd) > 0) |
62 | return true; | 62 | return true; |
63 | } | ||
63 | 64 | ||
64 | return false; | 65 | return false; |
65 | } | 66 | } |
diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 130ba5e..3cd6b8f 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs | |||
@@ -49,34 +49,38 @@ namespace OpenSim.Data.MySQL | |||
49 | 49 | ||
50 | public bool Delete(string principalID, string friend) | 50 | public bool Delete(string principalID, string friend) |
51 | { | 51 | { |
52 | MySqlCommand cmd = new MySqlCommand(); | 52 | using (MySqlCommand cmd = new MySqlCommand()) |
53 | { | ||
54 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); | ||
55 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | ||
56 | cmd.Parameters.AddWithValue("?Friend", friend); | ||
53 | 57 | ||
54 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); | 58 | ExecuteNonQuery(cmd); |
55 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | 59 | } |
56 | cmd.Parameters.AddWithValue("?Friend", friend); | ||
57 | |||
58 | ExecuteNonQuery(cmd); | ||
59 | 60 | ||
60 | return true; | 61 | return true; |
61 | } | 62 | } |
62 | 63 | ||
63 | public FriendsData[] GetFriends(UUID principalID) | 64 | public FriendsData[] GetFriends(UUID principalID) |
64 | { | 65 | { |
65 | MySqlCommand cmd = new MySqlCommand(); | 66 | using (MySqlCommand cmd = new MySqlCommand()) |
66 | 67 | { | |
67 | 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); | 68 | 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); |
68 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | 69 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); |
69 | 70 | ||
70 | return DoQuery(cmd); | 71 | return DoQuery(cmd); |
72 | } | ||
71 | } | 73 | } |
72 | 74 | ||
73 | public FriendsData[] GetFriends(string principalID) | 75 | public FriendsData[] GetFriends(string principalID) |
74 | { | 76 | { |
75 | MySqlCommand cmd = new MySqlCommand(); | 77 | using (MySqlCommand cmd = new MySqlCommand()) |
78 | { | ||
79 | 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 LIKE ?PrincipalID", m_Realm); | ||
80 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); | ||
76 | 81 | ||
77 | 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 LIKE ?PrincipalID", m_Realm); | 82 | return DoQuery(cmd); |
78 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); | 83 | } |
79 | return DoQuery(cmd); | ||
80 | } | 84 | } |
81 | } | 85 | } |
82 | } | 86 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 1a634e5..e9b10f3 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs | |||
@@ -467,43 +467,43 @@ namespace OpenSim.Data.MySQL | |||
467 | { | 467 | { |
468 | dbcon.Open(); | 468 | dbcon.Open(); |
469 | 469 | ||
470 | MySqlCommand result = new MySqlCommand(sql, dbcon); | 470 | using (MySqlCommand result = new MySqlCommand(sql, dbcon)) |
471 | result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); | ||
472 | result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); | ||
473 | result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); | ||
474 | result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); | ||
475 | result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); | ||
476 | result.Parameters.AddWithValue("?inventoryName", itemName); | ||
477 | result.Parameters.AddWithValue("?inventoryDescription", itemDesc); | ||
478 | result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); | ||
479 | result.Parameters.AddWithValue("?inventoryCurrentPermissions", | ||
480 | item.CurrentPermissions.ToString()); | ||
481 | result.Parameters.AddWithValue("?invType", item.InvType); | ||
482 | result.Parameters.AddWithValue("?creatorID", item.CreatorId); | ||
483 | result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); | ||
484 | result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); | ||
485 | result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); | ||
486 | result.Parameters.AddWithValue("?salePrice", item.SalePrice); | ||
487 | result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); | ||
488 | result.Parameters.AddWithValue("?creationDate", item.CreationDate); | ||
489 | result.Parameters.AddWithValue("?groupID", item.GroupID); | ||
490 | result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); | ||
491 | result.Parameters.AddWithValue("?flags", item.Flags); | ||
492 | |||
493 | lock (m_dbLock) | ||
494 | { | 471 | { |
495 | result.ExecuteNonQuery(); | 472 | result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); |
473 | result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); | ||
474 | result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); | ||
475 | result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); | ||
476 | result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); | ||
477 | result.Parameters.AddWithValue("?inventoryName", itemName); | ||
478 | result.Parameters.AddWithValue("?inventoryDescription", itemDesc); | ||
479 | result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); | ||
480 | result.Parameters.AddWithValue("?inventoryCurrentPermissions", | ||
481 | item.CurrentPermissions.ToString()); | ||
482 | result.Parameters.AddWithValue("?invType", item.InvType); | ||
483 | result.Parameters.AddWithValue("?creatorID", item.CreatorId); | ||
484 | result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); | ||
485 | result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); | ||
486 | result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); | ||
487 | result.Parameters.AddWithValue("?salePrice", item.SalePrice); | ||
488 | result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); | ||
489 | result.Parameters.AddWithValue("?creationDate", item.CreationDate); | ||
490 | result.Parameters.AddWithValue("?groupID", item.GroupID); | ||
491 | result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); | ||
492 | result.Parameters.AddWithValue("?flags", item.Flags); | ||
493 | |||
494 | lock (m_dbLock) | ||
495 | result.ExecuteNonQuery(); | ||
496 | |||
497 | result.Dispose(); | ||
496 | } | 498 | } |
497 | 499 | ||
498 | result.Dispose(); | 500 | using (MySqlCommand result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon)) |
499 | |||
500 | result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon); | ||
501 | result.Parameters.AddWithValue("?folderID", item.Folder.ToString()); | ||
502 | lock (m_dbLock) | ||
503 | { | 501 | { |
504 | result.ExecuteNonQuery(); | 502 | result.Parameters.AddWithValue("?folderID", item.Folder.ToString()); |
503 | |||
504 | lock (m_dbLock) | ||
505 | result.ExecuteNonQuery(); | ||
505 | } | 506 | } |
506 | result.Dispose(); | ||
507 | } | 507 | } |
508 | } | 508 | } |
509 | catch (MySqlException e) | 509 | catch (MySqlException e) |
@@ -533,12 +533,12 @@ namespace OpenSim.Data.MySQL | |||
533 | { | 533 | { |
534 | dbcon.Open(); | 534 | dbcon.Open(); |
535 | 535 | ||
536 | MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon); | 536 | using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon)) |
537 | cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); | ||
538 | |||
539 | lock (m_dbLock) | ||
540 | { | 537 | { |
541 | cmd.ExecuteNonQuery(); | 538 | cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); |
539 | |||
540 | lock (m_dbLock) | ||
541 | cmd.ExecuteNonQuery(); | ||
542 | } | 542 | } |
543 | } | 543 | } |
544 | } | 544 | } |
@@ -579,24 +579,26 @@ namespace OpenSim.Data.MySQL | |||
579 | { | 579 | { |
580 | dbcon.Open(); | 580 | dbcon.Open(); |
581 | 581 | ||
582 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | 582 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) |
583 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); | ||
584 | cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); | ||
585 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | ||
586 | cmd.Parameters.AddWithValue("?folderName", folderName); | ||
587 | cmd.Parameters.AddWithValue("?type", folder.Type); | ||
588 | cmd.Parameters.AddWithValue("?version", folder.Version); | ||
589 | |||
590 | try | ||
591 | { | 583 | { |
592 | lock (m_dbLock) | 584 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); |
585 | cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); | ||
586 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | ||
587 | cmd.Parameters.AddWithValue("?folderName", folderName); | ||
588 | cmd.Parameters.AddWithValue("?type", folder.Type); | ||
589 | cmd.Parameters.AddWithValue("?version", folder.Version); | ||
590 | |||
591 | try | ||
593 | { | 592 | { |
594 | cmd.ExecuteNonQuery(); | 593 | lock (m_dbLock) |
594 | { | ||
595 | cmd.ExecuteNonQuery(); | ||
596 | } | ||
597 | } | ||
598 | catch (Exception e) | ||
599 | { | ||
600 | m_log.Error(e.ToString()); | ||
595 | } | 601 | } |
596 | } | ||
597 | catch (Exception e) | ||
598 | { | ||
599 | m_log.Error(e.ToString()); | ||
600 | } | 602 | } |
601 | } | 603 | } |
602 | } | 604 | } |
@@ -624,20 +626,22 @@ namespace OpenSim.Data.MySQL | |||
624 | { | 626 | { |
625 | dbcon.Open(); | 627 | dbcon.Open(); |
626 | 628 | ||
627 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | 629 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) |
628 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); | ||
629 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | ||
630 | |||
631 | try | ||
632 | { | 630 | { |
633 | lock (m_dbLock) | 631 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); |
632 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | ||
633 | |||
634 | try | ||
634 | { | 635 | { |
635 | cmd.ExecuteNonQuery(); | 636 | lock (m_dbLock) |
637 | { | ||
638 | cmd.ExecuteNonQuery(); | ||
639 | } | ||
640 | } | ||
641 | catch (Exception e) | ||
642 | { | ||
643 | m_log.Error(e.ToString()); | ||
636 | } | 644 | } |
637 | } | ||
638 | catch (Exception e) | ||
639 | { | ||
640 | m_log.Error(e.ToString()); | ||
641 | } | 645 | } |
642 | } | 646 | } |
643 | } | 647 | } |
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index fc625f0..7808060 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs | |||
@@ -63,13 +63,14 @@ namespace OpenSim.Data.MySQL | |||
63 | 63 | ||
64 | public void LogoutRegionAgents(UUID regionID) | 64 | public void LogoutRegionAgents(UUID regionID) |
65 | { | 65 | { |
66 | MySqlCommand cmd = new MySqlCommand(); | 66 | using (MySqlCommand cmd = new MySqlCommand()) |
67 | 67 | { | |
68 | cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); | 68 | cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); |
69 | 69 | ||
70 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 70 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
71 | 71 | ||
72 | ExecuteNonQuery(cmd); | 72 | ExecuteNonQuery(cmd); |
73 | } | ||
73 | } | 74 | } |
74 | 75 | ||
75 | public bool ReportAgent(UUID sessionID, UUID regionID) | 76 | public bool ReportAgent(UUID sessionID, UUID regionID) |
@@ -81,17 +82,18 @@ namespace OpenSim.Data.MySQL | |||
81 | if (regionID == UUID.Zero) | 82 | if (regionID == UUID.Zero) |
82 | return false; | 83 | return false; |
83 | 84 | ||
84 | MySqlCommand cmd = new MySqlCommand(); | 85 | using (MySqlCommand cmd = new MySqlCommand()) |
85 | 86 | { | |
86 | cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); | 87 | cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); |
87 | 88 | ||
88 | cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); | 89 | cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); |
89 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 90 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
90 | 91 | ||
91 | if (ExecuteNonQuery(cmd) == 0) | 92 | if (ExecuteNonQuery(cmd) == 0) |
92 | return false; | 93 | return false; |
94 | } | ||
93 | 95 | ||
94 | return true; | 96 | return true; |
95 | } | 97 | } |
96 | } | 98 | } |
97 | } | 99 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index d1f1932..0614879 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -329,11 +329,12 @@ namespace OpenSim.Data.MySQL | |||
329 | if (scopeID != UUID.Zero) | 329 | if (scopeID != UUID.Zero) |
330 | command += " and ScopeID = ?scopeID"; | 330 | command += " and ScopeID = ?scopeID"; |
331 | 331 | ||
332 | MySqlCommand cmd = new MySqlCommand(command); | 332 | using (MySqlCommand cmd = new MySqlCommand(command)) |
333 | 333 | { | |
334 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | 334 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
335 | 335 | ||
336 | return RunCommand(cmd); | 336 | return RunCommand(cmd); |
337 | } | ||
337 | } | 338 | } |
338 | } | 339 | } |
339 | } | 340 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 381a514..b36ff5a 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -129,114 +129,114 @@ namespace OpenSim.Data.MySQL | |||
129 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 129 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
130 | { | 130 | { |
131 | dbcon.Open(); | 131 | dbcon.Open(); |
132 | MySqlCommand cmd = dbcon.CreateCommand(); | ||
133 | 132 | ||
134 | foreach (SceneObjectPart prim in obj.Parts) | 133 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
135 | { | 134 | { |
136 | cmd.Parameters.Clear(); | 135 | foreach (SceneObjectPart prim in obj.Parts) |
137 | 136 | { | |
138 | cmd.CommandText = "replace into prims (" + | 137 | cmd.Parameters.Clear(); |
139 | "UUID, CreationDate, " + | 138 | |
140 | "Name, Text, Description, " + | 139 | cmd.CommandText = "replace into prims (" + |
141 | "SitName, TouchName, ObjectFlags, " + | 140 | "UUID, CreationDate, " + |
142 | "OwnerMask, NextOwnerMask, GroupMask, " + | 141 | "Name, Text, Description, " + |
143 | "EveryoneMask, BaseMask, PositionX, " + | 142 | "SitName, TouchName, ObjectFlags, " + |
144 | "PositionY, PositionZ, GroupPositionX, " + | 143 | "OwnerMask, NextOwnerMask, GroupMask, " + |
145 | "GroupPositionY, GroupPositionZ, VelocityX, " + | 144 | "EveryoneMask, BaseMask, PositionX, " + |
146 | "VelocityY, VelocityZ, AngularVelocityX, " + | 145 | "PositionY, PositionZ, GroupPositionX, " + |
147 | "AngularVelocityY, AngularVelocityZ, " + | 146 | "GroupPositionY, GroupPositionZ, VelocityX, " + |
148 | "AccelerationX, AccelerationY, " + | 147 | "VelocityY, VelocityZ, AngularVelocityX, " + |
149 | "AccelerationZ, RotationX, " + | 148 | "AngularVelocityY, AngularVelocityZ, " + |
150 | "RotationY, RotationZ, " + | 149 | "AccelerationX, AccelerationY, " + |
151 | "RotationW, SitTargetOffsetX, " + | 150 | "AccelerationZ, RotationX, " + |
152 | "SitTargetOffsetY, SitTargetOffsetZ, " + | 151 | "RotationY, RotationZ, " + |
153 | "SitTargetOrientW, SitTargetOrientX, " + | 152 | "RotationW, SitTargetOffsetX, " + |
154 | "SitTargetOrientY, SitTargetOrientZ, " + | 153 | "SitTargetOffsetY, SitTargetOffsetZ, " + |
155 | "RegionUUID, CreatorID, " + | 154 | "SitTargetOrientW, SitTargetOrientX, " + |
156 | "OwnerID, GroupID, " + | 155 | "SitTargetOrientY, SitTargetOrientZ, " + |
157 | "LastOwnerID, SceneGroupID, " + | 156 | "RegionUUID, CreatorID, " + |
158 | "PayPrice, PayButton1, " + | 157 | "OwnerID, GroupID, " + |
159 | "PayButton2, PayButton3, " + | 158 | "LastOwnerID, SceneGroupID, " + |
160 | "PayButton4, LoopedSound, " + | 159 | "PayPrice, PayButton1, " + |
161 | "LoopedSoundGain, TextureAnimation, " + | 160 | "PayButton2, PayButton3, " + |
162 | "OmegaX, OmegaY, OmegaZ, " + | 161 | "PayButton4, LoopedSound, " + |
163 | "CameraEyeOffsetX, CameraEyeOffsetY, " + | 162 | "LoopedSoundGain, TextureAnimation, " + |
164 | "CameraEyeOffsetZ, CameraAtOffsetX, " + | 163 | "OmegaX, OmegaY, OmegaZ, " + |
165 | "CameraAtOffsetY, CameraAtOffsetZ, " + | 164 | "CameraEyeOffsetX, CameraEyeOffsetY, " + |
166 | "ForceMouselook, ScriptAccessPin, " + | 165 | "CameraEyeOffsetZ, CameraAtOffsetX, " + |
167 | "AllowedDrop, DieAtEdge, " + | 166 | "CameraAtOffsetY, CameraAtOffsetZ, " + |
168 | "SalePrice, SaleType, " + | 167 | "ForceMouselook, ScriptAccessPin, " + |
169 | "ColorR, ColorG, ColorB, ColorA, " + | 168 | "AllowedDrop, DieAtEdge, " + |
170 | "ParticleSystem, ClickAction, Material, " + | 169 | "SalePrice, SaleType, " + |
171 | "CollisionSound, CollisionSoundVolume, " + | 170 | "ColorR, ColorG, ColorB, ColorA, " + |
172 | "PassTouches, " + | 171 | "ParticleSystem, ClickAction, Material, " + |
173 | "LinkNumber, MediaURL) values (" + "?UUID, " + | 172 | "CollisionSound, CollisionSoundVolume, " + |
174 | "?CreationDate, ?Name, ?Text, " + | 173 | "PassTouches, " + |
175 | "?Description, ?SitName, ?TouchName, " + | 174 | "LinkNumber, MediaURL) values (" + "?UUID, " + |
176 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + | 175 | "?CreationDate, ?Name, ?Text, " + |
177 | "?GroupMask, ?EveryoneMask, ?BaseMask, " + | 176 | "?Description, ?SitName, ?TouchName, " + |
178 | "?PositionX, ?PositionY, ?PositionZ, " + | 177 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + |
179 | "?GroupPositionX, ?GroupPositionY, " + | 178 | "?GroupMask, ?EveryoneMask, ?BaseMask, " + |
180 | "?GroupPositionZ, ?VelocityX, " + | 179 | "?PositionX, ?PositionY, ?PositionZ, " + |
181 | "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + | 180 | "?GroupPositionX, ?GroupPositionY, " + |
182 | "?AngularVelocityY, ?AngularVelocityZ, " + | 181 | "?GroupPositionZ, ?VelocityX, " + |
183 | "?AccelerationX, ?AccelerationY, " + | 182 | "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + |
184 | "?AccelerationZ, ?RotationX, " + | 183 | "?AngularVelocityY, ?AngularVelocityZ, " + |
185 | "?RotationY, ?RotationZ, " + | 184 | "?AccelerationX, ?AccelerationY, " + |
186 | "?RotationW, ?SitTargetOffsetX, " + | 185 | "?AccelerationZ, ?RotationX, " + |
187 | "?SitTargetOffsetY, ?SitTargetOffsetZ, " + | 186 | "?RotationY, ?RotationZ, " + |
188 | "?SitTargetOrientW, ?SitTargetOrientX, " + | 187 | "?RotationW, ?SitTargetOffsetX, " + |
189 | "?SitTargetOrientY, ?SitTargetOrientZ, " + | 188 | "?SitTargetOffsetY, ?SitTargetOffsetZ, " + |
190 | "?RegionUUID, ?CreatorID, ?OwnerID, " + | 189 | "?SitTargetOrientW, ?SitTargetOrientX, " + |
191 | "?GroupID, ?LastOwnerID, ?SceneGroupID, " + | 190 | "?SitTargetOrientY, ?SitTargetOrientZ, " + |
192 | "?PayPrice, ?PayButton1, ?PayButton2, " + | 191 | "?RegionUUID, ?CreatorID, ?OwnerID, " + |
193 | "?PayButton3, ?PayButton4, ?LoopedSound, " + | 192 | "?GroupID, ?LastOwnerID, ?SceneGroupID, " + |
194 | "?LoopedSoundGain, ?TextureAnimation, " + | 193 | "?PayPrice, ?PayButton1, ?PayButton2, " + |
195 | "?OmegaX, ?OmegaY, ?OmegaZ, " + | 194 | "?PayButton3, ?PayButton4, ?LoopedSound, " + |
196 | "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + | 195 | "?LoopedSoundGain, ?TextureAnimation, " + |
197 | "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + | 196 | "?OmegaX, ?OmegaY, ?OmegaZ, " + |
198 | "?CameraAtOffsetY, ?CameraAtOffsetZ, " + | 197 | "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + |
199 | "?ForceMouselook, ?ScriptAccessPin, " + | 198 | "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + |
200 | "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + | 199 | "?CameraAtOffsetY, ?CameraAtOffsetZ, " + |
201 | "?SaleType, ?ColorR, ?ColorG, " + | 200 | "?ForceMouselook, ?ScriptAccessPin, " + |
202 | "?ColorB, ?ColorA, ?ParticleSystem, " + | 201 | "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + |
203 | "?ClickAction, ?Material, ?CollisionSound, " + | 202 | "?SaleType, ?ColorR, ?ColorG, " + |
204 | "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; | 203 | "?ColorB, ?ColorA, ?ParticleSystem, " + |
205 | 204 | "?ClickAction, ?Material, ?CollisionSound, " + | |
206 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | 205 | "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; |
207 | 206 | ||
208 | ExecuteNonQuery(cmd); | 207 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); |
209 | 208 | ||
210 | cmd.Parameters.Clear(); | 209 | ExecuteNonQuery(cmd); |
211 | 210 | ||
212 | cmd.CommandText = "replace into primshapes (" + | 211 | cmd.Parameters.Clear(); |
213 | "UUID, Shape, ScaleX, ScaleY, " + | 212 | |
214 | "ScaleZ, PCode, PathBegin, PathEnd, " + | 213 | cmd.CommandText = "replace into primshapes (" + |
215 | "PathScaleX, PathScaleY, PathShearX, " + | 214 | "UUID, Shape, ScaleX, ScaleY, " + |
216 | "PathShearY, PathSkew, PathCurve, " + | 215 | "ScaleZ, PCode, PathBegin, PathEnd, " + |
217 | "PathRadiusOffset, PathRevolutions, " + | 216 | "PathScaleX, PathScaleY, PathShearX, " + |
218 | "PathTaperX, PathTaperY, PathTwist, " + | 217 | "PathShearY, PathSkew, PathCurve, " + |
219 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + | 218 | "PathRadiusOffset, PathRevolutions, " + |
220 | "ProfileCurve, ProfileHollow, Texture, " + | 219 | "PathTaperX, PathTaperY, PathTwist, " + |
221 | "ExtraParams, State, Media) values (?UUID, " + | 220 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + |
222 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + | 221 | "ProfileCurve, ProfileHollow, Texture, " + |
223 | "?PCode, ?PathBegin, ?PathEnd, " + | 222 | "ExtraParams, State, Media) values (?UUID, " + |
224 | "?PathScaleX, ?PathScaleY, " + | 223 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + |
225 | "?PathShearX, ?PathShearY, " + | 224 | "?PCode, ?PathBegin, ?PathEnd, " + |
226 | "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + | 225 | "?PathScaleX, ?PathScaleY, " + |
227 | "?PathRevolutions, ?PathTaperX, " + | 226 | "?PathShearX, ?PathShearY, " + |
228 | "?PathTaperY, ?PathTwist, " + | 227 | "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + |
229 | "?PathTwistBegin, ?ProfileBegin, " + | 228 | "?PathRevolutions, ?PathTaperX, " + |
230 | "?ProfileEnd, ?ProfileCurve, " + | 229 | "?PathTaperY, ?PathTwist, " + |
231 | "?ProfileHollow, ?Texture, ?ExtraParams, " + | 230 | "?PathTwistBegin, ?ProfileBegin, " + |
232 | "?State, ?Media)"; | 231 | "?ProfileEnd, ?ProfileCurve, " + |
233 | 232 | "?ProfileHollow, ?Texture, ?ExtraParams, " + | |
234 | FillShapeCommand(cmd, prim); | 233 | "?State, ?Media)"; |
235 | 234 | ||
236 | ExecuteNonQuery(cmd); | 235 | FillShapeCommand(cmd, prim); |
236 | |||
237 | ExecuteNonQuery(cmd); | ||
238 | } | ||
237 | } | 239 | } |
238 | |||
239 | cmd.Dispose(); | ||
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
@@ -1804,37 +1804,36 @@ namespace OpenSim.Data.MySQL | |||
1804 | { | 1804 | { |
1805 | dbcon.Open(); | 1805 | dbcon.Open(); |
1806 | 1806 | ||
1807 | MySqlCommand cmd = dbcon.CreateCommand(); | 1807 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1808 | |||
1809 | if (items.Count == 0) | ||
1810 | return; | ||
1811 | |||
1812 | cmd.CommandText = "insert into primitems (" + | ||
1813 | "invType, assetType, name, " + | ||
1814 | "description, creationDate, nextPermissions, " + | ||
1815 | "currentPermissions, basePermissions, " + | ||
1816 | "everyonePermissions, groupPermissions, " + | ||
1817 | "flags, itemID, primID, assetID, " + | ||
1818 | "parentFolderID, creatorID, ownerID, " + | ||
1819 | "groupID, lastOwnerID) values (?invType, " + | ||
1820 | "?assetType, ?name, ?description, " + | ||
1821 | "?creationDate, ?nextPermissions, " + | ||
1822 | "?currentPermissions, ?basePermissions, " + | ||
1823 | "?everyonePermissions, ?groupPermissions, " + | ||
1824 | "?flags, ?itemID, ?primID, ?assetID, " + | ||
1825 | "?parentFolderID, ?creatorID, ?ownerID, " + | ||
1826 | "?groupID, ?lastOwnerID)"; | ||
1827 | |||
1828 | foreach (TaskInventoryItem item in items) | ||
1829 | { | 1808 | { |
1830 | cmd.Parameters.Clear(); | 1809 | if (items.Count == 0) |
1831 | 1810 | return; | |
1832 | FillItemCommand(cmd, item); | 1811 | |
1833 | 1812 | cmd.CommandText = "insert into primitems (" + | |
1834 | ExecuteNonQuery(cmd); | 1813 | "invType, assetType, name, " + |
1814 | "description, creationDate, nextPermissions, " + | ||
1815 | "currentPermissions, basePermissions, " + | ||
1816 | "everyonePermissions, groupPermissions, " + | ||
1817 | "flags, itemID, primID, assetID, " + | ||
1818 | "parentFolderID, creatorID, ownerID, " + | ||
1819 | "groupID, lastOwnerID) values (?invType, " + | ||
1820 | "?assetType, ?name, ?description, " + | ||
1821 | "?creationDate, ?nextPermissions, " + | ||
1822 | "?currentPermissions, ?basePermissions, " + | ||
1823 | "?everyonePermissions, ?groupPermissions, " + | ||
1824 | "?flags, ?itemID, ?primID, ?assetID, " + | ||
1825 | "?parentFolderID, ?creatorID, ?ownerID, " + | ||
1826 | "?groupID, ?lastOwnerID)"; | ||
1827 | |||
1828 | foreach (TaskInventoryItem item in items) | ||
1829 | { | ||
1830 | cmd.Parameters.Clear(); | ||
1831 | |||
1832 | FillItemCommand(cmd, item); | ||
1833 | |||
1834 | ExecuteNonQuery(cmd); | ||
1835 | } | ||
1835 | } | 1836 | } |
1836 | |||
1837 | cmd.Dispose(); | ||
1838 | } | 1837 | } |
1839 | } | 1838 | } |
1840 | } | 1839 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index aa69d68..e964295 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs | |||
@@ -62,23 +62,24 @@ namespace OpenSim.Data.MySQL | |||
62 | if (words.Length > 2) | 62 | if (words.Length > 2) |
63 | return new UserAccountData[0]; | 63 | return new UserAccountData[0]; |
64 | 64 | ||
65 | MySqlCommand cmd = new MySqlCommand(); | 65 | using (MySqlCommand cmd = new MySqlCommand()) |
66 | |||
67 | if (words.Length == 1) | ||
68 | { | ||
69 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); | ||
70 | cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); | ||
71 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); | ||
72 | } | ||
73 | else | ||
74 | { | 66 | { |
75 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); | 67 | if (words.Length == 1) |
76 | cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); | 68 | { |
77 | cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); | 69 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); |
78 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); | 70 | cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); |
79 | } | 71 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); |
72 | } | ||
73 | else | ||
74 | { | ||
75 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); | ||
76 | cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); | ||
77 | cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); | ||
78 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); | ||
79 | } | ||
80 | 80 | ||
81 | return DoQuery(cmd); | 81 | return DoQuery(cmd); |
82 | } | ||
82 | } | 83 | } |
83 | } | 84 | } |
84 | } | 85 | } \ No newline at end of file |