diff options
author | Master ScienceSim | 2010-02-04 13:19:30 -0800 |
---|---|---|
committer | John Hurliman | 2010-02-05 18:07:59 -0800 |
commit | e1b5c612472b9d1acf47383c0bf75b555daff2e6 (patch) | |
tree | 083896698038fbdad59c2bd3adeba9b290c5ce1b /OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | |
parent | Fixing an incorrect logging message in insertUserRow (diff) | |
download | opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.zip opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.gz opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.bz2 opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.xz |
Updated MySQL connection management to use the MySQL connection pooling. This should accommodate various timeout problems that exist with the current connection pool code in a more general and standard way.
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLLegacyRegionData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 924 |
1 files changed, 481 insertions, 443 deletions
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 9a4a4bb..a06eec3 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | |||
@@ -48,75 +48,54 @@ namespace OpenSim.Data.MySQL | |||
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | private string m_ConnectionString; | 51 | private string m_connectionString; |
52 | 52 | private object m_dbLock = new object(); | |
53 | private MySqlConnection m_Connection = null; | ||
54 | 53 | ||
55 | public void Initialise(string connectionString) | 54 | public void Initialise(string connectionString) |
56 | { | 55 | { |
57 | m_ConnectionString = connectionString; | 56 | m_connectionString = connectionString; |
58 | 57 | ||
59 | m_Connection = new MySqlConnection(m_ConnectionString); | 58 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
59 | { | ||
60 | dbcon.Open(); | ||
60 | 61 | ||
61 | m_Connection.Open(); | 62 | // Apply new Migrations |
63 | // | ||
64 | Assembly assem = GetType().Assembly; | ||
65 | Migration m = new Migration(dbcon, assem, "RegionStore"); | ||
66 | m.Update(); | ||
62 | 67 | ||
63 | // Apply new Migrations | 68 | // Clean dropped attachments |
64 | // | 69 | // |
65 | Assembly assem = GetType().Assembly; | 70 | try |
66 | Migration m = new Migration(m_Connection, assem, "RegionStore"); | 71 | { |
67 | m.Update(); | 72 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
68 | 73 | { | |
69 | // NOTE: This is a very slow query that times out on regions with a lot of prims. | 74 | cmd.CommandText = "delete from prims, primshapes using prims " + |
70 | // I'm told that it is no longer relevant so it's commented out now, but if it | 75 | "left join primshapes on prims.uuid = primshapes.uuid " + |
71 | // is relevant it should be added as a console command instead of part of the | 76 | "where PCode = 9 and State <> 0"; |
72 | // startup phase | 77 | ExecuteNonQuery(cmd); |
73 | // Clean dropped attachments | 78 | } |
74 | // | 79 | } |
75 | //try | 80 | catch (MySqlException ex) |
76 | //{ | 81 | { |
77 | // using (MySqlCommand cmd = m_Connection.CreateCommand()) | 82 | m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); |
78 | // { | 83 | } |
79 | // cmd.CommandText = "delete from prims, primshapes using prims " + | 84 | } |
80 | // "left join primshapes on prims.uuid = primshapes.uuid " + | ||
81 | // "where PCode = 9 and State <> 0"; | ||
82 | // ExecuteNonQuery(cmd); | ||
83 | // } | ||
84 | //} | ||
85 | //catch (MySqlException ex) | ||
86 | //{ | ||
87 | // m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); | ||
88 | //} | ||
89 | } | 85 | } |
90 | 86 | ||
91 | private IDataReader ExecuteReader(MySqlCommand c) | 87 | private IDataReader ExecuteReader(MySqlCommand c) |
92 | { | 88 | { |
93 | IDataReader r = null; | 89 | IDataReader r = null; |
94 | bool errorSeen = false; | ||
95 | 90 | ||
96 | while (true) | 91 | try |
97 | { | 92 | { |
98 | try | 93 | r = c.ExecuteReader(); |
99 | { | 94 | } |
100 | r = c.ExecuteReader(); | 95 | catch (Exception e) |
101 | } | 96 | { |
102 | catch (Exception) | 97 | m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message); |
103 | { | 98 | throw; |
104 | Thread.Sleep(500); | ||
105 | |||
106 | m_Connection.Close(); | ||
107 | m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); | ||
108 | m_Connection.Open(); | ||
109 | c.Connection = m_Connection; | ||
110 | |||
111 | if (!errorSeen) | ||
112 | { | ||
113 | errorSeen = true; | ||
114 | continue; | ||
115 | } | ||
116 | throw; | ||
117 | } | ||
118 | |||
119 | break; | ||
120 | } | 99 | } |
121 | 100 | ||
122 | return r; | 101 | return r; |
@@ -124,32 +103,14 @@ namespace OpenSim.Data.MySQL | |||
124 | 103 | ||
125 | private void ExecuteNonQuery(MySqlCommand c) | 104 | private void ExecuteNonQuery(MySqlCommand c) |
126 | { | 105 | { |
127 | bool errorSeen = false; | 106 | try |
128 | |||
129 | while (true) | ||
130 | { | 107 | { |
131 | try | 108 | c.ExecuteNonQuery(); |
132 | { | 109 | } |
133 | c.ExecuteNonQuery(); | 110 | catch (Exception e) |
134 | } | 111 | { |
135 | catch (Exception) | 112 | m_log.Error("[REGION DB]: MySQL error in ExecuteNonQuery: " + e.Message); |
136 | { | 113 | throw; |
137 | Thread.Sleep(500); | ||
138 | |||
139 | m_Connection.Close(); | ||
140 | m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); | ||
141 | m_Connection.Open(); | ||
142 | c.Connection = m_Connection; | ||
143 | |||
144 | if (!errorSeen) | ||
145 | { | ||
146 | errorSeen = true; | ||
147 | continue; | ||
148 | } | ||
149 | throw; | ||
150 | } | ||
151 | |||
152 | break; | ||
153 | } | 114 | } |
154 | } | 115 | } |
155 | 116 | ||
@@ -166,115 +127,119 @@ namespace OpenSim.Data.MySQL | |||
166 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) | 127 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) |
167 | return; | 128 | return; |
168 | 129 | ||
169 | lock (m_Connection) | 130 | lock (m_dbLock) |
170 | { | 131 | { |
171 | MySqlCommand cmd = m_Connection.CreateCommand(); | 132 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
172 | |||
173 | foreach (SceneObjectPart prim in obj.Children.Values) | ||
174 | { | 133 | { |
175 | cmd.Parameters.Clear(); | 134 | dbcon.Open(); |
176 | 135 | MySqlCommand cmd = dbcon.CreateCommand(); | |
177 | cmd.CommandText = "replace into prims ("+ | 136 | |
178 | "UUID, CreationDate, "+ | 137 | foreach (SceneObjectPart prim in obj.Children.Values) |
179 | "Name, Text, Description, "+ | 138 | { |
180 | "SitName, TouchName, ObjectFlags, "+ | 139 | cmd.Parameters.Clear(); |
181 | "OwnerMask, NextOwnerMask, GroupMask, "+ | 140 | |
182 | "EveryoneMask, BaseMask, PositionX, "+ | 141 | cmd.CommandText = "replace into prims (" + |
183 | "PositionY, PositionZ, GroupPositionX, "+ | 142 | "UUID, CreationDate, " + |
184 | "GroupPositionY, GroupPositionZ, VelocityX, "+ | 143 | "Name, Text, Description, " + |
185 | "VelocityY, VelocityZ, AngularVelocityX, "+ | 144 | "SitName, TouchName, ObjectFlags, " + |
186 | "AngularVelocityY, AngularVelocityZ, "+ | 145 | "OwnerMask, NextOwnerMask, GroupMask, " + |
187 | "AccelerationX, AccelerationY, "+ | 146 | "EveryoneMask, BaseMask, PositionX, " + |
188 | "AccelerationZ, RotationX, "+ | 147 | "PositionY, PositionZ, GroupPositionX, " + |
189 | "RotationY, RotationZ, "+ | 148 | "GroupPositionY, GroupPositionZ, VelocityX, " + |
190 | "RotationW, SitTargetOffsetX, "+ | 149 | "VelocityY, VelocityZ, AngularVelocityX, " + |
191 | "SitTargetOffsetY, SitTargetOffsetZ, "+ | 150 | "AngularVelocityY, AngularVelocityZ, " + |
192 | "SitTargetOrientW, SitTargetOrientX, "+ | 151 | "AccelerationX, AccelerationY, " + |
193 | "SitTargetOrientY, SitTargetOrientZ, "+ | 152 | "AccelerationZ, RotationX, " + |
194 | "RegionUUID, CreatorID, "+ | 153 | "RotationY, RotationZ, " + |
195 | "OwnerID, GroupID, "+ | 154 | "RotationW, SitTargetOffsetX, " + |
196 | "LastOwnerID, SceneGroupID, "+ | 155 | "SitTargetOffsetY, SitTargetOffsetZ, " + |
197 | "PayPrice, PayButton1, "+ | 156 | "SitTargetOrientW, SitTargetOrientX, " + |
198 | "PayButton2, PayButton3, "+ | 157 | "SitTargetOrientY, SitTargetOrientZ, " + |
199 | "PayButton4, LoopedSound, "+ | 158 | "RegionUUID, CreatorID, " + |
200 | "LoopedSoundGain, TextureAnimation, "+ | 159 | "OwnerID, GroupID, " + |
201 | "OmegaX, OmegaY, OmegaZ, "+ | 160 | "LastOwnerID, SceneGroupID, " + |
202 | "CameraEyeOffsetX, CameraEyeOffsetY, "+ | 161 | "PayPrice, PayButton1, " + |
203 | "CameraEyeOffsetZ, CameraAtOffsetX, "+ | 162 | "PayButton2, PayButton3, " + |
204 | "CameraAtOffsetY, CameraAtOffsetZ, "+ | 163 | "PayButton4, LoopedSound, " + |
205 | "ForceMouselook, ScriptAccessPin, "+ | 164 | "LoopedSoundGain, TextureAnimation, " + |
206 | "AllowedDrop, DieAtEdge, "+ | 165 | "OmegaX, OmegaY, OmegaZ, " + |
207 | "SalePrice, SaleType, "+ | 166 | "CameraEyeOffsetX, CameraEyeOffsetY, " + |
208 | "ColorR, ColorG, ColorB, ColorA, "+ | 167 | "CameraEyeOffsetZ, CameraAtOffsetX, " + |
209 | "ParticleSystem, ClickAction, Material, "+ | 168 | "CameraAtOffsetY, CameraAtOffsetZ, " + |
210 | "CollisionSound, CollisionSoundVolume, "+ | 169 | "ForceMouselook, ScriptAccessPin, " + |
211 | "PassTouches, "+ | 170 | "AllowedDrop, DieAtEdge, " + |
212 | "LinkNumber) values (" + "?UUID, "+ | 171 | "SalePrice, SaleType, " + |
213 | "?CreationDate, ?Name, ?Text, "+ | 172 | "ColorR, ColorG, ColorB, ColorA, " + |
214 | "?Description, ?SitName, ?TouchName, "+ | 173 | "ParticleSystem, ClickAction, Material, " + |
215 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+ | 174 | "CollisionSound, CollisionSoundVolume, " + |
216 | "?GroupMask, ?EveryoneMask, ?BaseMask, "+ | 175 | "PassTouches, " + |
217 | "?PositionX, ?PositionY, ?PositionZ, "+ | 176 | "LinkNumber) values (" + "?UUID, " + |
218 | "?GroupPositionX, ?GroupPositionY, "+ | 177 | "?CreationDate, ?Name, ?Text, " + |
219 | "?GroupPositionZ, ?VelocityX, "+ | 178 | "?Description, ?SitName, ?TouchName, " + |
220 | "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+ | 179 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + |
221 | "?AngularVelocityY, ?AngularVelocityZ, "+ | 180 | "?GroupMask, ?EveryoneMask, ?BaseMask, " + |
222 | "?AccelerationX, ?AccelerationY, "+ | 181 | "?PositionX, ?PositionY, ?PositionZ, " + |
223 | "?AccelerationZ, ?RotationX, "+ | 182 | "?GroupPositionX, ?GroupPositionY, " + |
224 | "?RotationY, ?RotationZ, "+ | 183 | "?GroupPositionZ, ?VelocityX, " + |
225 | "?RotationW, ?SitTargetOffsetX, "+ | 184 | "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + |
226 | "?SitTargetOffsetY, ?SitTargetOffsetZ, "+ | 185 | "?AngularVelocityY, ?AngularVelocityZ, " + |
227 | "?SitTargetOrientW, ?SitTargetOrientX, "+ | 186 | "?AccelerationX, ?AccelerationY, " + |
228 | "?SitTargetOrientY, ?SitTargetOrientZ, "+ | 187 | "?AccelerationZ, ?RotationX, " + |
229 | "?RegionUUID, ?CreatorID, ?OwnerID, "+ | 188 | "?RotationY, ?RotationZ, " + |
230 | "?GroupID, ?LastOwnerID, ?SceneGroupID, "+ | 189 | "?RotationW, ?SitTargetOffsetX, " + |
231 | "?PayPrice, ?PayButton1, ?PayButton2, "+ | 190 | "?SitTargetOffsetY, ?SitTargetOffsetZ, " + |
232 | "?PayButton3, ?PayButton4, ?LoopedSound, "+ | 191 | "?SitTargetOrientW, ?SitTargetOrientX, " + |
233 | "?LoopedSoundGain, ?TextureAnimation, "+ | 192 | "?SitTargetOrientY, ?SitTargetOrientZ, " + |
234 | "?OmegaX, ?OmegaY, ?OmegaZ, "+ | 193 | "?RegionUUID, ?CreatorID, ?OwnerID, " + |
235 | "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+ | 194 | "?GroupID, ?LastOwnerID, ?SceneGroupID, " + |
236 | "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+ | 195 | "?PayPrice, ?PayButton1, ?PayButton2, " + |
237 | "?CameraAtOffsetY, ?CameraAtOffsetZ, "+ | 196 | "?PayButton3, ?PayButton4, ?LoopedSound, " + |
238 | "?ForceMouselook, ?ScriptAccessPin, "+ | 197 | "?LoopedSoundGain, ?TextureAnimation, " + |
239 | "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+ | 198 | "?OmegaX, ?OmegaY, ?OmegaZ, " + |
240 | "?SaleType, ?ColorR, ?ColorG, "+ | 199 | "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + |
241 | "?ColorB, ?ColorA, ?ParticleSystem, "+ | 200 | "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + |
242 | "?ClickAction, ?Material, ?CollisionSound, "+ | 201 | "?CameraAtOffsetY, ?CameraAtOffsetZ, " + |
243 | "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; | 202 | "?ForceMouselook, ?ScriptAccessPin, " + |
244 | 203 | "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + | |
245 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | 204 | "?SaleType, ?ColorR, ?ColorG, " + |
246 | 205 | "?ColorB, ?ColorA, ?ParticleSystem, " + | |
247 | ExecuteNonQuery(cmd); | 206 | "?ClickAction, ?Material, ?CollisionSound, " + |
248 | 207 | "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)"; | |
249 | cmd.Parameters.Clear(); | 208 | |
250 | 209 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | |
251 | cmd.CommandText = "replace into primshapes ("+ | 210 | |
252 | "UUID, Shape, ScaleX, ScaleY, "+ | 211 | ExecuteNonQuery(cmd); |
253 | "ScaleZ, PCode, PathBegin, PathEnd, "+ | 212 | |
254 | "PathScaleX, PathScaleY, PathShearX, "+ | 213 | cmd.Parameters.Clear(); |
255 | "PathShearY, PathSkew, PathCurve, "+ | 214 | |
256 | "PathRadiusOffset, PathRevolutions, "+ | 215 | cmd.CommandText = "replace into primshapes (" + |
257 | "PathTaperX, PathTaperY, PathTwist, "+ | 216 | "UUID, Shape, ScaleX, ScaleY, " + |
258 | "PathTwistBegin, ProfileBegin, ProfileEnd, "+ | 217 | "ScaleZ, PCode, PathBegin, PathEnd, " + |
259 | "ProfileCurve, ProfileHollow, Texture, "+ | 218 | "PathScaleX, PathScaleY, PathShearX, " + |
260 | "ExtraParams, State) values (?UUID, "+ | 219 | "PathShearY, PathSkew, PathCurve, " + |
261 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+ | 220 | "PathRadiusOffset, PathRevolutions, " + |
262 | "?PCode, ?PathBegin, ?PathEnd, "+ | 221 | "PathTaperX, PathTaperY, PathTwist, " + |
263 | "?PathScaleX, ?PathScaleY, "+ | 222 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + |
264 | "?PathShearX, ?PathShearY, "+ | 223 | "ProfileCurve, ProfileHollow, Texture, " + |
265 | "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+ | 224 | "ExtraParams, State) values (?UUID, " + |
266 | "?PathRevolutions, ?PathTaperX, "+ | 225 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + |
267 | "?PathTaperY, ?PathTwist, "+ | 226 | "?PCode, ?PathBegin, ?PathEnd, " + |
268 | "?PathTwistBegin, ?ProfileBegin, "+ | 227 | "?PathScaleX, ?PathScaleY, " + |
269 | "?ProfileEnd, ?ProfileCurve, "+ | 228 | "?PathShearX, ?PathShearY, " + |
270 | "?ProfileHollow, ?Texture, ?ExtraParams, "+ | 229 | "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + |
271 | "?State)"; | 230 | "?PathRevolutions, ?PathTaperX, " + |
272 | 231 | "?PathTaperY, ?PathTwist, " + | |
273 | FillShapeCommand(cmd, prim); | 232 | "?PathTwistBegin, ?ProfileBegin, " + |
274 | 233 | "?ProfileEnd, ?ProfileCurve, " + | |
275 | ExecuteNonQuery(cmd); | 234 | "?ProfileHollow, ?Texture, ?ExtraParams, " + |
235 | "?State)"; | ||
236 | |||
237 | FillShapeCommand(cmd, prim); | ||
238 | |||
239 | ExecuteNonQuery(cmd); | ||
240 | } | ||
241 | cmd.Dispose(); | ||
276 | } | 242 | } |
277 | cmd.Dispose(); | ||
278 | } | 243 | } |
279 | } | 244 | } |
280 | 245 | ||
@@ -290,22 +255,27 @@ namespace OpenSim.Data.MySQL | |||
290 | // cause the loss of a prim, but is cleaner. | 255 | // cause the loss of a prim, but is cleaner. |
291 | // It's also faster because it uses the primary key. | 256 | // It's also faster because it uses the primary key. |
292 | // | 257 | // |
293 | lock (m_Connection) | 258 | lock (m_dbLock) |
294 | { | 259 | { |
295 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 260 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
296 | { | 261 | { |
297 | cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; | 262 | dbcon.Open(); |
298 | cmd.Parameters.AddWithValue("UUID", obj.ToString()); | ||
299 | 263 | ||
300 | using (IDataReader reader = ExecuteReader(cmd)) | 264 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
301 | { | 265 | { |
302 | while (reader.Read()) | 266 | cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID"; |
303 | uuids.Add(new UUID(reader["UUID"].ToString())); | 267 | cmd.Parameters.AddWithValue("UUID", obj.ToString()); |
304 | } | 268 | |
269 | using (IDataReader reader = ExecuteReader(cmd)) | ||
270 | { | ||
271 | while (reader.Read()) | ||
272 | uuids.Add(new UUID(reader["UUID"].ToString())); | ||
273 | } | ||
305 | 274 | ||
306 | // delete the main prims | 275 | // delete the main prims |
307 | cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; | 276 | cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; |
308 | ExecuteNonQuery(cmd); | 277 | ExecuteNonQuery(cmd); |
278 | } | ||
309 | } | 279 | } |
310 | } | 280 | } |
311 | 281 | ||
@@ -326,14 +296,19 @@ namespace OpenSim.Data.MySQL | |||
326 | /// <param name="uuid">the Item UUID</param> | 296 | /// <param name="uuid">the Item UUID</param> |
327 | private void RemoveItems(UUID uuid) | 297 | private void RemoveItems(UUID uuid) |
328 | { | 298 | { |
329 | lock (m_Connection) | 299 | lock (m_dbLock) |
330 | { | 300 | { |
331 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 301 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
332 | { | 302 | { |
333 | cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; | 303 | dbcon.Open(); |
334 | cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); | 304 | |
305 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
306 | { | ||
307 | cmd.CommandText = "delete from primitems where PrimID = ?PrimID"; | ||
308 | cmd.Parameters.AddWithValue("PrimID", uuid.ToString()); | ||
335 | 309 | ||
336 | ExecuteNonQuery(cmd); | 310 | ExecuteNonQuery(cmd); |
311 | } | ||
337 | } | 312 | } |
338 | } | 313 | } |
339 | } | 314 | } |
@@ -345,29 +320,33 @@ namespace OpenSim.Data.MySQL | |||
345 | /// <param name="uuids">the list of UUIDs</param> | 320 | /// <param name="uuids">the list of UUIDs</param> |
346 | private void RemoveShapes(List<UUID> uuids) | 321 | private void RemoveShapes(List<UUID> uuids) |
347 | { | 322 | { |
348 | lock (m_Connection) | 323 | lock (m_dbLock) |
349 | { | 324 | { |
350 | string sql = "delete from primshapes where "; | 325 | string sql = "delete from primshapes where "; |
351 | 326 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | |
352 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | ||
353 | { | 327 | { |
354 | for (int i = 0; i < uuids.Count; i++) | 328 | dbcon.Open(); |
329 | |||
330 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
355 | { | 331 | { |
356 | if ((i + 1) == uuids.Count) | 332 | for (int i = 0; i < uuids.Count; i++) |
357 | {// end of the list | ||
358 | sql += "(UUID = ?UUID" + i + ")"; | ||
359 | } | ||
360 | else | ||
361 | { | 333 | { |
362 | sql += "(UUID = ?UUID" + i + ") or "; | 334 | if ((i + 1) == uuids.Count) |
335 | {// end of the list | ||
336 | sql += "(UUID = ?UUID" + i + ")"; | ||
337 | } | ||
338 | else | ||
339 | { | ||
340 | sql += "(UUID = ?UUID" + i + ") or "; | ||
341 | } | ||
363 | } | 342 | } |
364 | } | 343 | cmd.CommandText = sql; |
365 | cmd.CommandText = sql; | ||
366 | 344 | ||
367 | for (int i = 0; i < uuids.Count; i++) | 345 | for (int i = 0; i < uuids.Count; i++) |
368 | cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); | 346 | cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString()); |
369 | 347 | ||
370 | ExecuteNonQuery(cmd); | 348 | ExecuteNonQuery(cmd); |
349 | } | ||
371 | } | 350 | } |
372 | } | 351 | } |
373 | } | 352 | } |
@@ -379,30 +358,34 @@ namespace OpenSim.Data.MySQL | |||
379 | /// <param name="uuids">the list of UUIDs</param> | 358 | /// <param name="uuids">the list of UUIDs</param> |
380 | private void RemoveItems(List<UUID> uuids) | 359 | private void RemoveItems(List<UUID> uuids) |
381 | { | 360 | { |
382 | lock (m_Connection) | 361 | lock (m_dbLock) |
383 | { | 362 | { |
384 | string sql = "delete from primitems where "; | 363 | string sql = "delete from primitems where "; |
385 | 364 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | |
386 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | ||
387 | { | 365 | { |
388 | for (int i = 0; i < uuids.Count; i++) | 366 | dbcon.Open(); |
367 | |||
368 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
389 | { | 369 | { |
390 | if ((i + 1) == uuids.Count) | 370 | for (int i = 0; i < uuids.Count; i++) |
391 | { | 371 | { |
392 | // end of the list | 372 | if ((i + 1) == uuids.Count) |
393 | sql += "(PrimID = ?PrimID" + i + ")"; | 373 | { |
394 | } | 374 | // end of the list |
395 | else | 375 | sql += "(PrimID = ?PrimID" + i + ")"; |
396 | { | 376 | } |
397 | sql += "(PrimID = ?PrimID" + i + ") or "; | 377 | else |
378 | { | ||
379 | sql += "(PrimID = ?PrimID" + i + ") or "; | ||
380 | } | ||
398 | } | 381 | } |
399 | } | 382 | cmd.CommandText = sql; |
400 | cmd.CommandText = sql; | ||
401 | 383 | ||
402 | for (int i = 0; i < uuids.Count; i++) | 384 | for (int i = 0; i < uuids.Count; i++) |
403 | cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); | 385 | cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString()); |
404 | 386 | ||
405 | ExecuteNonQuery(cmd); | 387 | ExecuteNonQuery(cmd); |
388 | } | ||
406 | } | 389 | } |
407 | } | 390 | } |
408 | } | 391 | } |
@@ -417,33 +400,38 @@ namespace OpenSim.Data.MySQL | |||
417 | 400 | ||
418 | #region Prim Loading | 401 | #region Prim Loading |
419 | 402 | ||
420 | lock (m_Connection) | 403 | lock (m_dbLock) |
421 | { | 404 | { |
422 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 405 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
423 | { | 406 | { |
424 | cmd.CommandText = | 407 | dbcon.Open(); |
425 | "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; | ||
426 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
427 | 408 | ||
428 | using (IDataReader reader = ExecuteReader(cmd)) | 409 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
429 | { | 410 | { |
430 | while (reader.Read()) | 411 | cmd.CommandText = |
412 | "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID"; | ||
413 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
414 | |||
415 | using (IDataReader reader = ExecuteReader(cmd)) | ||
431 | { | 416 | { |
432 | SceneObjectPart prim = BuildPrim(reader); | 417 | while (reader.Read()) |
433 | if (reader["Shape"] is DBNull) | 418 | { |
434 | prim.Shape = PrimitiveBaseShape.Default; | 419 | SceneObjectPart prim = BuildPrim(reader); |
435 | else | 420 | if (reader["Shape"] is DBNull) |
436 | prim.Shape = BuildShape(reader); | 421 | prim.Shape = PrimitiveBaseShape.Default; |
422 | else | ||
423 | prim.Shape = BuildShape(reader); | ||
437 | 424 | ||
438 | UUID parentID = new UUID(reader["SceneGroupID"].ToString()); | 425 | UUID parentID = new UUID(reader["SceneGroupID"].ToString()); |
439 | if (parentID != prim.UUID) | 426 | if (parentID != prim.UUID) |
440 | prim.ParentUUID = parentID; | 427 | prim.ParentUUID = parentID; |
441 | 428 | ||
442 | prims[prim.UUID] = prim; | 429 | prims[prim.UUID] = prim; |
443 | 430 | ||
444 | ++count; | 431 | ++count; |
445 | if (count % ROWS_PER_QUERY == 0) | 432 | if (count % ROWS_PER_QUERY == 0) |
446 | m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); | 433 | m_log.Debug("[REGION DB]: Loaded " + count + " prims..."); |
434 | } | ||
447 | } | 435 | } |
448 | } | 436 | } |
449 | } | 437 | } |
@@ -497,20 +485,25 @@ namespace OpenSim.Data.MySQL | |||
497 | // list from DB of all prims which have items and | 485 | // list from DB of all prims which have items and |
498 | // LoadItems only on those | 486 | // LoadItems only on those |
499 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); | 487 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); |
500 | lock (m_Connection) | 488 | lock (m_dbLock) |
501 | { | 489 | { |
502 | using (MySqlCommand itemCmd = m_Connection.CreateCommand()) | 490 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
503 | { | 491 | { |
504 | itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems"; | 492 | dbcon.Open(); |
505 | using (IDataReader itemReader = ExecuteReader(itemCmd)) | 493 | |
494 | using (MySqlCommand itemCmd = dbcon.CreateCommand()) | ||
506 | { | 495 | { |
507 | while (itemReader.Read()) | 496 | itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems"; |
497 | using (IDataReader itemReader = ExecuteReader(itemCmd)) | ||
508 | { | 498 | { |
509 | if (!(itemReader["primID"] is DBNull)) | 499 | while (itemReader.Read()) |
510 | { | 500 | { |
511 | UUID primID = new UUID(itemReader["primID"].ToString()); | 501 | if (!(itemReader["primID"] is DBNull)) |
512 | if (prims.ContainsKey(primID)) | 502 | { |
513 | primsWithInventory.Add(prims[primID]); | 503 | UUID primID = new UUID(itemReader["primID"].ToString()); |
504 | if (prims.ContainsKey(primID)) | ||
505 | primsWithInventory.Add(prims[primID]); | ||
506 | } | ||
514 | } | 507 | } |
515 | } | 508 | } |
516 | } | 509 | } |
@@ -535,23 +528,28 @@ namespace OpenSim.Data.MySQL | |||
535 | /// <param name="prim">The prim</param> | 528 | /// <param name="prim">The prim</param> |
536 | private void LoadItems(SceneObjectPart prim) | 529 | private void LoadItems(SceneObjectPart prim) |
537 | { | 530 | { |
538 | lock (m_Connection) | 531 | lock (m_dbLock) |
539 | { | 532 | { |
540 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); | 533 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); |
541 | 534 | ||
542 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 535 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
543 | { | 536 | { |
544 | cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; | 537 | dbcon.Open(); |
545 | cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); | ||
546 | 538 | ||
547 | using (IDataReader reader = ExecuteReader(cmd)) | 539 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
548 | { | 540 | { |
549 | while (reader.Read()) | 541 | cmd.CommandText = "select * from primitems where PrimID = ?PrimID"; |
542 | cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString()); | ||
543 | |||
544 | using (IDataReader reader = ExecuteReader(cmd)) | ||
550 | { | 545 | { |
551 | TaskInventoryItem item = BuildItem(reader); | 546 | while (reader.Read()) |
547 | { | ||
548 | TaskInventoryItem item = BuildItem(reader); | ||
552 | 549 | ||
553 | item.ParentID = prim.UUID; // Values in database are often wrong | 550 | item.ParentID = prim.UUID; // Values in database are often wrong |
554 | inventory.Add(item); | 551 | inventory.Add(item); |
552 | } | ||
555 | } | 553 | } |
556 | } | 554 | } |
557 | } | 555 | } |
@@ -564,22 +562,27 @@ namespace OpenSim.Data.MySQL | |||
564 | { | 562 | { |
565 | m_log.Info("[REGION DB]: Storing terrain"); | 563 | m_log.Info("[REGION DB]: Storing terrain"); |
566 | 564 | ||
567 | lock (m_Connection) | 565 | lock (m_dbLock) |
568 | { | 566 | { |
569 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 567 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
570 | { | 568 | { |
571 | cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; | 569 | dbcon.Open(); |
572 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
573 | 570 | ||
574 | ExecuteNonQuery(cmd); | 571 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
572 | { | ||
573 | cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; | ||
574 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
575 | 575 | ||
576 | cmd.CommandText = "insert into terrain (RegionUUID, " + | 576 | ExecuteNonQuery(cmd); |
577 | "Revision, Heightfield) values (?RegionUUID, " + | ||
578 | "1, ?Heightfield)"; | ||
579 | 577 | ||
580 | cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); | 578 | cmd.CommandText = "insert into terrain (RegionUUID, " + |
579 | "Revision, Heightfield) values (?RegionUUID, " + | ||
580 | "1, ?Heightfield)"; | ||
581 | 581 | ||
582 | ExecuteNonQuery(cmd); | 582 | cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); |
583 | |||
584 | ExecuteNonQuery(cmd); | ||
585 | } | ||
583 | } | 586 | } |
584 | } | 587 | } |
585 | } | 588 | } |
@@ -588,38 +591,43 @@ namespace OpenSim.Data.MySQL | |||
588 | { | 591 | { |
589 | double[,] terrain = null; | 592 | double[,] terrain = null; |
590 | 593 | ||
591 | lock (m_Connection) | 594 | lock (m_dbLock) |
592 | { | 595 | { |
593 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 596 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
594 | { | 597 | { |
595 | cmd.CommandText = "select RegionUUID, Revision, Heightfield " + | 598 | dbcon.Open(); |
596 | "from terrain where RegionUUID = ?RegionUUID " + | ||
597 | "order by Revision desc limit 1"; | ||
598 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
599 | 599 | ||
600 | using (IDataReader reader = ExecuteReader(cmd)) | 600 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
601 | { | 601 | { |
602 | while (reader.Read()) | 602 | cmd.CommandText = "select RegionUUID, Revision, Heightfield " + |
603 | "from terrain where RegionUUID = ?RegionUUID " + | ||
604 | "order by Revision desc limit 1"; | ||
605 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
606 | |||
607 | using (IDataReader reader = ExecuteReader(cmd)) | ||
603 | { | 608 | { |
604 | int rev = Convert.ToInt32(reader["Revision"]); | 609 | while (reader.Read()) |
610 | { | ||
611 | int rev = Convert.ToInt32(reader["Revision"]); | ||
605 | 612 | ||
606 | terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | 613 | terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; |
607 | terrain.Initialize(); | 614 | terrain.Initialize(); |
608 | 615 | ||
609 | using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) | 616 | using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"])) |
610 | { | ||
611 | using (BinaryReader br = new BinaryReader(mstr)) | ||
612 | { | 617 | { |
613 | for (int x = 0; x < (int)Constants.RegionSize; x++) | 618 | using (BinaryReader br = new BinaryReader(mstr)) |
614 | { | 619 | { |
615 | for (int y = 0; y < (int)Constants.RegionSize; y++) | 620 | for (int x = 0; x < (int)Constants.RegionSize; x++) |
616 | { | 621 | { |
617 | terrain[x, y] = br.ReadDouble(); | 622 | for (int y = 0; y < (int)Constants.RegionSize; y++) |
623 | { | ||
624 | terrain[x, y] = br.ReadDouble(); | ||
625 | } | ||
618 | } | 626 | } |
619 | } | 627 | } |
620 | } | ||
621 | 628 | ||
622 | m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); | 629 | m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev); |
630 | } | ||
623 | } | 631 | } |
624 | } | 632 | } |
625 | } | 633 | } |
@@ -631,63 +639,73 @@ namespace OpenSim.Data.MySQL | |||
631 | 639 | ||
632 | public void RemoveLandObject(UUID globalID) | 640 | public void RemoveLandObject(UUID globalID) |
633 | { | 641 | { |
634 | lock (m_Connection) | 642 | lock (m_dbLock) |
635 | { | 643 | { |
636 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 644 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
637 | { | 645 | { |
638 | cmd.CommandText = "delete from land where UUID = ?UUID"; | 646 | dbcon.Open(); |
639 | cmd.Parameters.AddWithValue("UUID", globalID.ToString()); | 647 | |
648 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
649 | { | ||
650 | cmd.CommandText = "delete from land where UUID = ?UUID"; | ||
651 | cmd.Parameters.AddWithValue("UUID", globalID.ToString()); | ||
640 | 652 | ||
641 | ExecuteNonQuery(cmd); | 653 | ExecuteNonQuery(cmd); |
654 | } | ||
642 | } | 655 | } |
643 | } | 656 | } |
644 | } | 657 | } |
645 | 658 | ||
646 | public void StoreLandObject(ILandObject parcel) | 659 | public void StoreLandObject(ILandObject parcel) |
647 | { | 660 | { |
648 | lock (m_Connection) | 661 | lock (m_dbLock) |
649 | { | 662 | { |
650 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 663 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
651 | { | 664 | { |
652 | cmd.CommandText = "replace into land (UUID, RegionUUID, " + | 665 | dbcon.Open(); |
653 | "LocalLandID, Bitmap, Name, Description, " + | 666 | |
654 | "OwnerUUID, IsGroupOwned, Area, AuctionID, " + | 667 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
655 | "Category, ClaimDate, ClaimPrice, GroupUUID, " + | ||
656 | "SalePrice, LandStatus, LandFlags, LandingType, " + | ||
657 | "MediaAutoScale, MediaTextureUUID, MediaURL, " + | ||
658 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + | ||
659 | "UserLocationX, UserLocationY, UserLocationZ, " + | ||
660 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + | ||
661 | "AuthbuyerID, OtherCleanTime, Dwell) values (" + | ||
662 | "?UUID, ?RegionUUID, " + | ||
663 | "?LocalLandID, ?Bitmap, ?Name, ?Description, " + | ||
664 | "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + | ||
665 | "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + | ||
666 | "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + | ||
667 | "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + | ||
668 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + | ||
669 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + | ||
670 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + | ||
671 | "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; | ||
672 | |||
673 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); | ||
674 | |||
675 | ExecuteNonQuery(cmd); | ||
676 | |||
677 | cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; | ||
678 | |||
679 | ExecuteNonQuery(cmd); | ||
680 | |||
681 | cmd.Parameters.Clear(); | ||
682 | cmd.CommandText = "insert into landaccesslist (LandUUID, " + | ||
683 | "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + | ||
684 | "?Flags)"; | ||
685 | |||
686 | foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) | ||
687 | { | 668 | { |
688 | FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); | 669 | cmd.CommandText = "replace into land (UUID, RegionUUID, " + |
670 | "LocalLandID, Bitmap, Name, Description, " + | ||
671 | "OwnerUUID, IsGroupOwned, Area, AuctionID, " + | ||
672 | "Category, ClaimDate, ClaimPrice, GroupUUID, " + | ||
673 | "SalePrice, LandStatus, LandFlags, LandingType, " + | ||
674 | "MediaAutoScale, MediaTextureUUID, MediaURL, " + | ||
675 | "MusicURL, PassHours, PassPrice, SnapshotUUID, " + | ||
676 | "UserLocationX, UserLocationY, UserLocationZ, " + | ||
677 | "UserLookAtX, UserLookAtY, UserLookAtZ, " + | ||
678 | "AuthbuyerID, OtherCleanTime, Dwell) values (" + | ||
679 | "?UUID, ?RegionUUID, " + | ||
680 | "?LocalLandID, ?Bitmap, ?Name, ?Description, " + | ||
681 | "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " + | ||
682 | "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " + | ||
683 | "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " + | ||
684 | "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " + | ||
685 | "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " + | ||
686 | "?UserLocationX, ?UserLocationY, ?UserLocationZ, " + | ||
687 | "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " + | ||
688 | "?AuthbuyerID, ?OtherCleanTime, ?Dwell)"; | ||
689 | |||
690 | FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID); | ||
691 | |||
689 | ExecuteNonQuery(cmd); | 692 | ExecuteNonQuery(cmd); |
693 | |||
694 | cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID"; | ||
695 | |||
696 | ExecuteNonQuery(cmd); | ||
697 | |||
690 | cmd.Parameters.Clear(); | 698 | cmd.Parameters.Clear(); |
699 | cmd.CommandText = "insert into landaccesslist (LandUUID, " + | ||
700 | "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + | ||
701 | "?Flags)"; | ||
702 | |||
703 | foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) | ||
704 | { | ||
705 | FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); | ||
706 | ExecuteNonQuery(cmd); | ||
707 | cmd.Parameters.Clear(); | ||
708 | } | ||
691 | } | 709 | } |
692 | } | 710 | } |
693 | } | 711 | } |
@@ -697,27 +715,32 @@ namespace OpenSim.Data.MySQL | |||
697 | { | 715 | { |
698 | RegionSettings rs = null; | 716 | RegionSettings rs = null; |
699 | 717 | ||
700 | lock (m_Connection) | 718 | lock (m_dbLock) |
701 | { | 719 | { |
702 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 720 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
703 | { | 721 | { |
704 | cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; | 722 | dbcon.Open(); |
705 | cmd.Parameters.AddWithValue("regionUUID", regionUUID); | ||
706 | 723 | ||
707 | using (IDataReader reader = ExecuteReader(cmd)) | 724 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
708 | { | 725 | { |
709 | if (reader.Read()) | 726 | cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID"; |
710 | { | 727 | cmd.Parameters.AddWithValue("regionUUID", regionUUID); |
711 | rs = BuildRegionSettings(reader); | 728 | |
712 | rs.OnSave += StoreRegionSettings; | 729 | using (IDataReader reader = ExecuteReader(cmd)) |
713 | } | ||
714 | else | ||
715 | { | 730 | { |
716 | rs = new RegionSettings(); | 731 | if (reader.Read()) |
717 | rs.RegionUUID = regionUUID; | 732 | { |
718 | rs.OnSave += StoreRegionSettings; | 733 | rs = BuildRegionSettings(reader); |
734 | rs.OnSave += StoreRegionSettings; | ||
735 | } | ||
736 | else | ||
737 | { | ||
738 | rs = new RegionSettings(); | ||
739 | rs.RegionUUID = regionUUID; | ||
740 | rs.OnSave += StoreRegionSettings; | ||
719 | 741 | ||
720 | StoreRegionSettings(rs); | 742 | StoreRegionSettings(rs); |
743 | } | ||
721 | } | 744 | } |
722 | } | 745 | } |
723 | } | 746 | } |
@@ -728,46 +751,51 @@ namespace OpenSim.Data.MySQL | |||
728 | 751 | ||
729 | public void StoreRegionSettings(RegionSettings rs) | 752 | public void StoreRegionSettings(RegionSettings rs) |
730 | { | 753 | { |
731 | lock (m_Connection) | 754 | lock (m_dbLock) |
732 | { | 755 | { |
733 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 756 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
734 | { | 757 | { |
735 | cmd.CommandText = "replace into regionsettings (regionUUID, " + | 758 | dbcon.Open(); |
736 | "block_terraform, block_fly, allow_damage, " + | 759 | |
737 | "restrict_pushing, allow_land_resell, " + | 760 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
738 | "allow_land_join_divide, block_show_in_search, " + | 761 | { |
739 | "agent_limit, object_bonus, maturity, " + | 762 | cmd.CommandText = "replace into regionsettings (regionUUID, " + |
740 | "disable_scripts, disable_collisions, " + | 763 | "block_terraform, block_fly, allow_damage, " + |
741 | "disable_physics, terrain_texture_1, " + | 764 | "restrict_pushing, allow_land_resell, " + |
742 | "terrain_texture_2, terrain_texture_3, " + | 765 | "allow_land_join_divide, block_show_in_search, " + |
743 | "terrain_texture_4, elevation_1_nw, " + | 766 | "agent_limit, object_bonus, maturity, " + |
744 | "elevation_2_nw, elevation_1_ne, " + | 767 | "disable_scripts, disable_collisions, " + |
745 | "elevation_2_ne, elevation_1_se, " + | 768 | "disable_physics, terrain_texture_1, " + |
746 | "elevation_2_se, elevation_1_sw, " + | 769 | "terrain_texture_2, terrain_texture_3, " + |
747 | "elevation_2_sw, water_height, " + | 770 | "terrain_texture_4, elevation_1_nw, " + |
748 | "terrain_raise_limit, terrain_lower_limit, " + | 771 | "elevation_2_nw, elevation_1_ne, " + |
749 | "use_estate_sun, fixed_sun, sun_position, " + | 772 | "elevation_2_ne, elevation_1_se, " + |
750 | "covenant, Sandbox, sunvectorx, sunvectory, " + | 773 | "elevation_2_se, elevation_1_sw, " + |
751 | "sunvectorz, loaded_creation_datetime, " + | 774 | "elevation_2_sw, water_height, " + |
752 | "loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " + | 775 | "terrain_raise_limit, terrain_lower_limit, " + |
753 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | 776 | "use_estate_sun, fixed_sun, sun_position, " + |
754 | "?AllowLandResell, ?AllowLandJoinDivide, " + | 777 | "covenant, Sandbox, sunvectorx, sunvectory, " + |
755 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | 778 | "sunvectorz, loaded_creation_datetime, " + |
756 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + | 779 | "loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " + |
757 | "?DisablePhysics, ?TerrainTexture1, " + | 780 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + |
758 | "?TerrainTexture2, ?TerrainTexture3, " + | 781 | "?AllowLandResell, ?AllowLandJoinDivide, " + |
759 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + | 782 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + |
760 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + | 783 | "?Maturity, ?DisableScripts, ?DisableCollisions, " + |
761 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + | 784 | "?DisablePhysics, ?TerrainTexture1, " + |
762 | "?WaterHeight, ?TerrainRaiseLimit, " + | 785 | "?TerrainTexture2, ?TerrainTexture3, " + |
763 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | 786 | "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " + |
764 | "?SunPosition, ?Covenant, ?Sandbox, " + | 787 | "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " + |
765 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | 788 | "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " + |
766 | "?LoadedCreationDateTime, ?LoadedCreationID)"; | 789 | "?WaterHeight, ?TerrainRaiseLimit, " + |
767 | 790 | "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + | |
768 | FillRegionSettingsCommand(cmd, rs); | 791 | "?SunPosition, ?Covenant, ?Sandbox, " + |
769 | 792 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | |
770 | ExecuteNonQuery(cmd); | 793 | "?LoadedCreationDateTime, ?LoadedCreationID)"; |
794 | |||
795 | FillRegionSettingsCommand(cmd, rs); | ||
796 | |||
797 | ExecuteNonQuery(cmd); | ||
798 | } | ||
771 | } | 799 | } |
772 | } | 800 | } |
773 | } | 801 | } |
@@ -776,36 +804,41 @@ namespace OpenSim.Data.MySQL | |||
776 | { | 804 | { |
777 | List<LandData> landData = new List<LandData>(); | 805 | List<LandData> landData = new List<LandData>(); |
778 | 806 | ||
779 | lock (m_Connection) | 807 | lock (m_dbLock) |
780 | { | 808 | { |
781 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 809 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
782 | { | 810 | { |
783 | cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; | 811 | dbcon.Open(); |
784 | cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); | ||
785 | 812 | ||
786 | using (IDataReader reader = ExecuteReader(cmd)) | 813 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
787 | { | 814 | { |
788 | while (reader.Read()) | 815 | cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID"; |
816 | cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString()); | ||
817 | |||
818 | using (IDataReader reader = ExecuteReader(cmd)) | ||
789 | { | 819 | { |
790 | LandData newLand = BuildLandData(reader); | 820 | while (reader.Read()) |
791 | landData.Add(newLand); | 821 | { |
822 | LandData newLand = BuildLandData(reader); | ||
823 | landData.Add(newLand); | ||
824 | } | ||
792 | } | 825 | } |
793 | } | 826 | } |
794 | } | ||
795 | 827 | ||
796 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 828 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
797 | { | ||
798 | foreach (LandData land in landData) | ||
799 | { | 829 | { |
800 | cmd.Parameters.Clear(); | 830 | foreach (LandData land in landData) |
801 | cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; | ||
802 | cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); | ||
803 | |||
804 | using (IDataReader reader = ExecuteReader(cmd)) | ||
805 | { | 831 | { |
806 | while (reader.Read()) | 832 | cmd.Parameters.Clear(); |
833 | cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID"; | ||
834 | cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString()); | ||
835 | |||
836 | using (IDataReader reader = ExecuteReader(cmd)) | ||
807 | { | 837 | { |
808 | land.ParcelAccessList.Add(BuildLandAccessData(reader)); | 838 | while (reader.Read()) |
839 | { | ||
840 | land.ParcelAccessList.Add(BuildLandAccessData(reader)); | ||
841 | } | ||
809 | } | 842 | } |
810 | } | 843 | } |
811 | } | 844 | } |
@@ -1513,41 +1546,46 @@ namespace OpenSim.Data.MySQL | |||
1513 | 1546 | ||
1514 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) | 1547 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) |
1515 | { | 1548 | { |
1516 | lock (m_Connection) | 1549 | lock (m_dbLock) |
1517 | { | 1550 | { |
1518 | RemoveItems(primID); | 1551 | RemoveItems(primID); |
1519 | 1552 | ||
1520 | MySqlCommand cmd = m_Connection.CreateCommand(); | 1553 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1521 | |||
1522 | if (items.Count == 0) | ||
1523 | return; | ||
1524 | |||
1525 | cmd.CommandText = "insert into primitems ("+ | ||
1526 | "invType, assetType, name, "+ | ||
1527 | "description, creationDate, nextPermissions, "+ | ||
1528 | "currentPermissions, basePermissions, "+ | ||
1529 | "everyonePermissions, groupPermissions, "+ | ||
1530 | "flags, itemID, primID, assetID, "+ | ||
1531 | "parentFolderID, creatorID, ownerID, "+ | ||
1532 | "groupID, lastOwnerID) values (?invType, "+ | ||
1533 | "?assetType, ?name, ?description, "+ | ||
1534 | "?creationDate, ?nextPermissions, "+ | ||
1535 | "?currentPermissions, ?basePermissions, "+ | ||
1536 | "?everyonePermissions, ?groupPermissions, "+ | ||
1537 | "?flags, ?itemID, ?primID, ?assetID, "+ | ||
1538 | "?parentFolderID, ?creatorID, ?ownerID, "+ | ||
1539 | "?groupID, ?lastOwnerID)"; | ||
1540 | |||
1541 | foreach (TaskInventoryItem item in items) | ||
1542 | { | 1554 | { |
1543 | cmd.Parameters.Clear(); | 1555 | dbcon.Open(); |
1556 | |||
1557 | MySqlCommand cmd = dbcon.CreateCommand(); | ||
1558 | |||
1559 | if (items.Count == 0) | ||
1560 | return; | ||
1561 | |||
1562 | cmd.CommandText = "insert into primitems (" + | ||
1563 | "invType, assetType, name, " + | ||
1564 | "description, creationDate, nextPermissions, " + | ||
1565 | "currentPermissions, basePermissions, " + | ||
1566 | "everyonePermissions, groupPermissions, " + | ||
1567 | "flags, itemID, primID, assetID, " + | ||
1568 | "parentFolderID, creatorID, ownerID, " + | ||
1569 | "groupID, lastOwnerID) values (?invType, " + | ||
1570 | "?assetType, ?name, ?description, " + | ||
1571 | "?creationDate, ?nextPermissions, " + | ||
1572 | "?currentPermissions, ?basePermissions, " + | ||
1573 | "?everyonePermissions, ?groupPermissions, " + | ||
1574 | "?flags, ?itemID, ?primID, ?assetID, " + | ||
1575 | "?parentFolderID, ?creatorID, ?ownerID, " + | ||
1576 | "?groupID, ?lastOwnerID)"; | ||
1577 | |||
1578 | foreach (TaskInventoryItem item in items) | ||
1579 | { | ||
1580 | cmd.Parameters.Clear(); | ||
1581 | |||
1582 | FillItemCommand(cmd, item); | ||
1544 | 1583 | ||
1545 | FillItemCommand(cmd, item); | 1584 | ExecuteNonQuery(cmd); |
1585 | } | ||
1546 | 1586 | ||
1547 | ExecuteNonQuery(cmd); | 1587 | cmd.Dispose(); |
1548 | } | 1588 | } |
1549 | |||
1550 | cmd.Dispose(); | ||
1551 | } | 1589 | } |
1552 | } | 1590 | } |
1553 | } | 1591 | } |