diff options
author | KittoFlora | 2009-11-16 01:40:15 +0100 |
---|---|---|
committer | KittoFlora | 2009-11-16 01:40:15 +0100 |
commit | 873c9098d8627972e80a1688e85a4cda45e1e7fe (patch) | |
tree | a0edc24aef11d5ad6928493d8985386f48dd2607 /OpenSim/Data | |
parent | Merge branch 'vehicles' into tests (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC-873c9098d8627972e80a1688e85a4cda45e1e7fe.zip opensim-SC-873c9098d8627972e80a1688e85a4cda45e1e7fe.tar.gz opensim-SC-873c9098d8627972e80a1688e85a4cda45e1e7fe.tar.bz2 opensim-SC-873c9098d8627972e80a1688e85a4cda45e1e7fe.tar.xz |
Merge branch 'careminster' into tests
Diffstat (limited to '')
25 files changed, 1162 insertions, 927 deletions
diff --git a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs b/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs index 0e21880..93e48cd 100644 --- a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs +++ b/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs | |||
@@ -197,11 +197,20 @@ namespace OpenSim.Data.MSSQL | |||
197 | public void Dispose() | 197 | public void Dispose() |
198 | { | 198 | { |
199 | SqlConnection conn = realCommand.Connection; | 199 | SqlConnection conn = realCommand.Connection; |
200 | try { realCommand.Dispose(); } | 200 | try |
201 | { | ||
202 | realCommand.Dispose(); | ||
203 | } | ||
201 | finally | 204 | finally |
202 | { | 205 | { |
203 | try { conn.Dispose(); } | 206 | try |
204 | finally { } | 207 | { |
208 | conn.Close(); | ||
209 | } | ||
210 | finally | ||
211 | { | ||
212 | conn.Dispose(); | ||
213 | } | ||
205 | } | 214 | } |
206 | } | 215 | } |
207 | 216 | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 25f7cf0..1ce4abf 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs | |||
@@ -132,12 +132,13 @@ namespace OpenSim.Data.MSSQL | |||
132 | { | 132 | { |
133 | if (reader.Read()) | 133 | if (reader.Read()) |
134 | { | 134 | { |
135 | AssetBase asset = new AssetBase(); | 135 | AssetBase asset = new AssetBase( |
136 | new UUID((Guid)reader["id"]), | ||
137 | (string)reader["name"], | ||
138 | Convert.ToSByte(reader["assetType"]) | ||
139 | ); | ||
136 | // Region Main | 140 | // Region Main |
137 | asset.FullID = new UUID((Guid)reader["id"]); | ||
138 | asset.Name = (string)reader["name"]; | ||
139 | asset.Description = (string)reader["description"]; | 141 | asset.Description = (string)reader["description"]; |
140 | asset.Type = Convert.ToSByte(reader["assetType"]); | ||
141 | asset.Local = Convert.ToBoolean(reader["local"]); | 142 | asset.Local = Convert.ToBoolean(reader["local"]); |
142 | asset.Temporary = Convert.ToBoolean(reader["temporary"]); | 143 | asset.Temporary = Convert.ToBoolean(reader["temporary"]); |
143 | asset.Data = (byte[])reader["data"]; | 144 | asset.Data = (byte[])reader["data"]; |
diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs index d49c2b3..1482184 100644 --- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs | |||
@@ -348,6 +348,8 @@ namespace OpenSim.Data.MSSQL | |||
348 | //Delete the actual row | 348 | //Delete the actual row |
349 | DeleteOneFolder(folderID, connection); | 349 | DeleteOneFolder(folderID, connection); |
350 | DeleteItemsInFolder(folderID, connection); | 350 | DeleteItemsInFolder(folderID, connection); |
351 | |||
352 | connection.Close(); | ||
351 | } | 353 | } |
352 | } | 354 | } |
353 | 355 | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs index cff6b00..6371307 100644 --- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | |||
@@ -1049,7 +1049,7 @@ VALUES | |||
1049 | if (!(primRow["ParticleSystem"] is DBNull)) | 1049 | if (!(primRow["ParticleSystem"] is DBNull)) |
1050 | prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; | 1050 | prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; |
1051 | 1051 | ||
1052 | prim.RotationalVelocity = new Vector3( | 1052 | prim.AngularVelocity = new Vector3( |
1053 | Convert.ToSingle(primRow["OmegaX"]), | 1053 | Convert.ToSingle(primRow["OmegaX"]), |
1054 | Convert.ToSingle(primRow["OmegaY"]), | 1054 | Convert.ToSingle(primRow["OmegaY"]), |
1055 | Convert.ToSingle(primRow["OmegaZ"])); | 1055 | Convert.ToSingle(primRow["OmegaZ"])); |
@@ -1429,9 +1429,9 @@ VALUES | |||
1429 | parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation)); | 1429 | parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation)); |
1430 | parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem)); | 1430 | parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem)); |
1431 | 1431 | ||
1432 | parameters.Add(_Database.CreateParameter("OmegaX", prim.RotationalVelocity.X)); | 1432 | parameters.Add(_Database.CreateParameter("OmegaX", prim.AngularVelocity.X)); |
1433 | parameters.Add(_Database.CreateParameter("OmegaY", prim.RotationalVelocity.Y)); | 1433 | parameters.Add(_Database.CreateParameter("OmegaY", prim.AngularVelocity.Y)); |
1434 | parameters.Add(_Database.CreateParameter("OmegaZ", prim.RotationalVelocity.Z)); | 1434 | parameters.Add(_Database.CreateParameter("OmegaZ", prim.AngularVelocity.Z)); |
1435 | 1435 | ||
1436 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X)); | 1436 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X)); |
1437 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y)); | 1437 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y)); |
diff --git a/OpenSim/Data/MSSQL/MSSQLManager.cs b/OpenSim/Data/MSSQL/MSSQLManager.cs index 992ce02..3d7a768 100644 --- a/OpenSim/Data/MSSQL/MSSQLManager.cs +++ b/OpenSim/Data/MSSQL/MSSQLManager.cs | |||
@@ -340,6 +340,8 @@ namespace OpenSim.Data.MSSQL | |||
340 | MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore); | 340 | MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore); |
341 | 341 | ||
342 | migration.Update(); | 342 | migration.Update(); |
343 | |||
344 | connection.Close(); | ||
343 | } | 345 | } |
344 | } | 346 | } |
345 | 347 | ||
@@ -383,7 +385,9 @@ namespace OpenSim.Data.MSSQL | |||
383 | m_log.Error(e.ToString()); | 385 | m_log.Error(e.ToString()); |
384 | } | 386 | } |
385 | } | 387 | } |
388 | tables.Close(); | ||
386 | } | 389 | } |
390 | |||
387 | } | 391 | } |
388 | 392 | ||
389 | /// <summary> | 393 | /// <summary> |
diff --git a/OpenSim/Data/MSSQL/MSSQLMigration.cs b/OpenSim/Data/MSSQL/MSSQLMigration.cs index 549bcb3..aea31c9 100644 --- a/OpenSim/Data/MSSQL/MSSQLMigration.cs +++ b/OpenSim/Data/MSSQL/MSSQLMigration.cs | |||
@@ -56,6 +56,7 @@ namespace OpenSim.Data.MSSQL | |||
56 | { | 56 | { |
57 | version = Convert.ToInt32(reader["version"]); | 57 | version = Convert.ToInt32(reader["version"]); |
58 | } | 58 | } |
59 | reader.Close(); | ||
59 | } | 60 | } |
60 | } | 61 | } |
61 | catch | 62 | catch |
diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index 7a99d4a..e51dc22 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs | |||
@@ -131,26 +131,25 @@ namespace OpenSim.Data | |||
131 | m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type); | 131 | m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type); |
132 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); | 132 | m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); |
133 | 133 | ||
134 | using (DbCommand cmd = _conn.CreateCommand()) | 134 | DbCommand cmd = _conn.CreateCommand(); |
135 | foreach (KeyValuePair<int, string> kvp in migrations) | ||
135 | { | 136 | { |
136 | foreach (KeyValuePair<int, string> kvp in migrations) | 137 | int newversion = kvp.Key; |
137 | { | 138 | cmd.CommandText = kvp.Value; |
138 | int newversion = kvp.Key; | 139 | // we need to up the command timeout to infinite as we might be doing long migrations. |
139 | cmd.CommandText = kvp.Value; | 140 | cmd.CommandTimeout = 0; |
140 | // we need to up the command timeout to infinite as we might be doing long migrations. | 141 | cmd.ExecuteNonQuery(); |
141 | cmd.CommandTimeout = 0; | ||
142 | cmd.ExecuteNonQuery(); | ||
143 | 142 | ||
144 | if (version == 0) | 143 | if (version == 0) |
145 | { | 144 | { |
146 | InsertVersion(_type, newversion); | 145 | InsertVersion(_type, newversion); |
147 | } | ||
148 | else | ||
149 | { | ||
150 | UpdateVersion(_type, newversion); | ||
151 | } | ||
152 | version = newversion; | ||
153 | } | 146 | } |
147 | else | ||
148 | { | ||
149 | UpdateVersion(_type, newversion); | ||
150 | } | ||
151 | version = newversion; | ||
152 | cmd.Dispose(); | ||
154 | } | 153 | } |
155 | } | 154 | } |
156 | 155 | ||
@@ -190,45 +189,43 @@ namespace OpenSim.Data | |||
190 | protected virtual int FindVersion(DbConnection conn, string type) | 189 | protected virtual int FindVersion(DbConnection conn, string type) |
191 | { | 190 | { |
192 | int version = 0; | 191 | int version = 0; |
193 | 192 | DbCommand cmd = conn.CreateCommand(); | |
194 | using (DbCommand cmd = conn.CreateCommand()) | 193 | try |
195 | { | 194 | { |
196 | try | 195 | cmd.CommandText = "select version from migrations where name='" + type +"' order by version desc"; |
196 | using (IDataReader reader = cmd.ExecuteReader()) | ||
197 | { | 197 | { |
198 | cmd.CommandText = "select version from migrations where name='" + type + "' order by version desc"; | 198 | if (reader.Read()) |
199 | using (IDataReader reader = cmd.ExecuteReader()) | ||
200 | { | 199 | { |
201 | if (reader.Read()) | 200 | version = Convert.ToInt32(reader["version"]); |
202 | version = Convert.ToInt32(reader["version"]); | ||
203 | } | 201 | } |
204 | } | 202 | reader.Close(); |
205 | catch | ||
206 | { | ||
207 | // Something went wrong, so we're version 0 | ||
208 | } | 203 | } |
209 | } | 204 | } |
210 | 205 | catch | |
206 | { | ||
207 | // Something went wrong, so we're version 0 | ||
208 | } | ||
209 | cmd.Dispose(); | ||
211 | return version; | 210 | return version; |
212 | } | 211 | } |
213 | 212 | ||
214 | private void InsertVersion(string type, int version) | 213 | private void InsertVersion(string type, int version) |
215 | { | 214 | { |
216 | using (DbCommand cmd = _conn.CreateCommand()) | 215 | DbCommand cmd = _conn.CreateCommand(); |
217 | { | 216 | cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; |
218 | cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; | 217 | m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); |
219 | m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); | 218 | cmd.ExecuteNonQuery(); |
220 | cmd.ExecuteNonQuery(); | 219 | cmd.Dispose(); |
221 | } | ||
222 | } | 220 | } |
223 | 221 | ||
224 | private void UpdateVersion(string type, int version) | 222 | private void UpdateVersion(string type, int version) |
225 | { | 223 | { |
226 | using (DbCommand cmd = _conn.CreateCommand()) | 224 | DbCommand cmd = _conn.CreateCommand(); |
227 | { | 225 | cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; |
228 | cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; | 226 | m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); |
229 | m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); | 227 | cmd.ExecuteNonQuery(); |
230 | cmd.ExecuteNonQuery(); | 228 | cmd.Dispose(); |
231 | } | ||
232 | } | 229 | } |
233 | 230 | ||
234 | // private SortedList<int, string> GetAllMigrations() | 231 | // private SortedList<int, string> GetAllMigrations() |
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 4d49733..6a4ccd7 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -139,42 +139,42 @@ namespace OpenSim.Data.MySQL | |||
139 | { | 139 | { |
140 | _dbConnection.CheckConnection(); | 140 | _dbConnection.CheckConnection(); |
141 | 141 | ||
142 | using (MySqlCommand cmd = new MySqlCommand( | 142 | MySqlCommand cmd = |
143 | "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", | 143 | new MySqlCommand( |
144 | _dbConnection.Connection)) | 144 | "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", |
145 | { | 145 | _dbConnection.Connection); |
146 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); | 146 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); |
147 | 147 | ||
148 | try | 148 | try |
149 | { | ||
150 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
149 | { | 151 | { |
150 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 152 | if (dbReader.Read()) |
151 | { | 153 | { |
152 | if (dbReader.Read()) | 154 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); |
153 | { | 155 | asset.Data = (byte[]) dbReader["data"]; |
154 | asset = new AssetBase(); | 156 | asset.Description = (string) dbReader["description"]; |
155 | asset.Data = (byte[])dbReader["data"]; | 157 | |
156 | asset.Description = (string)dbReader["description"]; | 158 | string local = dbReader["local"].ToString(); |
157 | asset.FullID = assetID; | 159 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) |
158 | 160 | asset.Local = true; | |
159 | string local = dbReader["local"].ToString(); | 161 | else |
160 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | 162 | asset.Local = false; |
161 | asset.Local = true; | 163 | |
162 | else | 164 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); |
163 | asset.Local = false; | ||
164 | |||
165 | asset.Name = (string)dbReader["name"]; | ||
166 | asset.Type = (sbyte)dbReader["assetType"]; | ||
167 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | ||
168 | } | ||
169 | } | 165 | } |
166 | dbReader.Close(); | ||
167 | cmd.Dispose(); | ||
170 | } | 168 | } |
171 | catch (Exception e) | 169 | if (asset != null) |
172 | { | 170 | UpdateAccessTime(asset); |
173 | m_log.ErrorFormat( | 171 | } |
174 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() | 172 | catch (Exception e) |
175 | + Environment.NewLine + "Reconnecting", assetID); | 173 | { |
176 | _dbConnection.Reconnect(); | 174 | m_log.ErrorFormat( |
177 | } | 175 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() |
176 | + Environment.NewLine + "Reconnecting", assetID); | ||
177 | _dbConnection.Reconnect(); | ||
178 | } | 178 | } |
179 | } | 179 | } |
180 | return asset; | 180 | return asset; |
@@ -291,27 +291,32 @@ namespace OpenSim.Data.MySQL | |||
291 | { | 291 | { |
292 | _dbConnection.CheckConnection(); | 292 | _dbConnection.CheckConnection(); |
293 | 293 | ||
294 | using (MySqlCommand cmd = new MySqlCommand( | 294 | MySqlCommand cmd = |
295 | "SELECT id FROM assets WHERE id=?id", | 295 | new MySqlCommand( |
296 | _dbConnection.Connection)) | 296 | "SELECT id FROM assets WHERE id=?id", |
297 | { | 297 | _dbConnection.Connection); |
298 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); | ||
299 | 298 | ||
300 | try | 299 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); |
300 | |||
301 | try | ||
302 | { | ||
303 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
301 | { | 304 | { |
302 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 305 | if (dbReader.Read()) |
303 | { | 306 | { |
304 | if (dbReader.Read()) | 307 | assetExists = true; |
305 | assetExists = true; | ||
306 | } | 308 | } |
309 | |||
310 | dbReader.Close(); | ||
311 | cmd.Dispose(); | ||
307 | } | 312 | } |
308 | catch (Exception e) | 313 | } |
309 | { | 314 | catch (Exception e) |
310 | m_log.ErrorFormat( | 315 | { |
311 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() | 316 | m_log.ErrorFormat( |
312 | + Environment.NewLine + "Attempting reconnection", uuid); | 317 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() |
313 | _dbConnection.Reconnect(); | 318 | + Environment.NewLine + "Attempting reconnection", uuid); |
314 | } | 319 | _dbConnection.Reconnect(); |
315 | } | 320 | } |
316 | } | 321 | } |
317 | 322 | ||
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 0780936..e508b52 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |||
@@ -55,7 +55,9 @@ namespace OpenSim.Data.MySQL | |||
55 | AuthenticationData ret = new AuthenticationData(); | 55 | AuthenticationData ret = new AuthenticationData(); |
56 | ret.Data = new Dictionary<string, object>(); | 56 | ret.Data = new Dictionary<string, object>(); |
57 | 57 | ||
58 | MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"); | 58 | MySqlCommand cmd = new MySqlCommand( |
59 | "select * from `"+m_Realm+"` where UUID = ?principalID" | ||
60 | ); | ||
59 | 61 | ||
60 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | 62 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); |
61 | 63 | ||
@@ -82,14 +84,16 @@ namespace OpenSim.Data.MySQL | |||
82 | ret.Data[s] = result[s].ToString(); | 84 | ret.Data[s] = result[s].ToString(); |
83 | } | 85 | } |
84 | 86 | ||
85 | CloseDBConnection(result, cmd); | 87 | result.Close(); |
88 | CloseReaderCommand(cmd); | ||
89 | |||
86 | return ret; | 90 | return ret; |
87 | } | 91 | } |
88 | else | 92 | |
89 | { | 93 | result.Close(); |
90 | CloseDBConnection(result, cmd); | 94 | CloseReaderCommand(cmd); |
91 | return null; | 95 | |
92 | } | 96 | return null; |
93 | } | 97 | } |
94 | 98 | ||
95 | public bool Store(AuthenticationData data) | 99 | public bool Store(AuthenticationData data) |
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 7166b29..e8694fc 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs | |||
@@ -95,17 +95,21 @@ namespace OpenSim.Data.MySQL | |||
95 | 95 | ||
96 | protected void GetWaitTimeout() | 96 | protected void GetWaitTimeout() |
97 | { | 97 | { |
98 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection)) | 98 | MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, |
99 | m_connection); | ||
100 | |||
101 | using (MySqlDataReader dbReader = | ||
102 | cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
99 | { | 103 | { |
100 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 104 | if (dbReader.Read()) |
101 | { | 105 | { |
102 | if (dbReader.Read()) | 106 | m_waitTimeout |
103 | { | 107 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * |
104 | m_waitTimeout | 108 | TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; |
105 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * | ||
106 | TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
107 | } | ||
108 | } | 109 | } |
110 | |||
111 | dbReader.Close(); | ||
112 | cmd.Dispose(); | ||
109 | } | 113 | } |
110 | 114 | ||
111 | m_lastConnectionUse = DateTime.Now.Ticks; | 115 | m_lastConnectionUse = DateTime.Now.Ticks; |
@@ -143,103 +147,110 @@ namespace OpenSim.Data.MySQL | |||
143 | 147 | ||
144 | CheckConnection(); | 148 | CheckConnection(); |
145 | 149 | ||
146 | bool migration = true; | 150 | MySqlCommand cmd = m_connection.CreateCommand(); |
147 | 151 | ||
148 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 152 | cmd.CommandText = sql; |
149 | { | 153 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
150 | cmd.CommandText = sql; | 154 | |
151 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 155 | IDataReader r = cmd.ExecuteReader(); |
152 | 156 | ||
153 | using (IDataReader r = cmd.ExecuteReader()) | 157 | if (r.Read()) |
158 | { | ||
159 | foreach (string name in FieldList) | ||
154 | { | 160 | { |
155 | if (r.Read()) | 161 | if (m_FieldMap[name].GetValue(es) is bool) |
156 | { | 162 | { |
157 | migration = false; | 163 | int v = Convert.ToInt32(r[name]); |
158 | 164 | if (v != 0) | |
159 | foreach (string name in FieldList) | 165 | m_FieldMap[name].SetValue(es, true); |
160 | { | 166 | else |
161 | if (m_FieldMap[name].GetValue(es) is bool) | 167 | m_FieldMap[name].SetValue(es, false); |
162 | { | 168 | } |
163 | int v = Convert.ToInt32(r[name]); | 169 | else if (m_FieldMap[name].GetValue(es) is UUID) |
164 | if (v != 0) | 170 | { |
165 | m_FieldMap[name].SetValue(es, true); | 171 | UUID uuid = UUID.Zero; |
166 | else | 172 | |
167 | m_FieldMap[name].SetValue(es, false); | 173 | UUID.TryParse(r[name].ToString(), out uuid); |
168 | } | 174 | m_FieldMap[name].SetValue(es, uuid); |
169 | else if (m_FieldMap[name].GetValue(es) is UUID) | 175 | } |
170 | { | 176 | else |
171 | UUID uuid = UUID.Zero; | 177 | { |
172 | 178 | m_FieldMap[name].SetValue(es, r[name]); | |
173 | UUID.TryParse(r[name].ToString(), out uuid); | ||
174 | m_FieldMap[name].SetValue(es, uuid); | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | m_FieldMap[name].SetValue(es, r[name]); | ||
179 | } | ||
180 | } | ||
181 | } | 179 | } |
182 | } | 180 | } |
181 | r.Close(); | ||
183 | } | 182 | } |
184 | 183 | else | |
185 | if (migration) | ||
186 | { | 184 | { |
187 | // Migration case | 185 | // Migration case |
186 | // | ||
187 | r.Close(); | ||
188 | |||
188 | List<string> names = new List<string>(FieldList); | 189 | List<string> names = new List<string>(FieldList); |
189 | 190 | ||
190 | names.Remove("EstateID"); | 191 | names.Remove("EstateID"); |
191 | 192 | ||
192 | sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; | 193 | sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; |
193 | 194 | ||
194 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 195 | cmd.CommandText = sql; |
195 | { | 196 | cmd.Parameters.Clear(); |
196 | cmd.CommandText = sql; | ||
197 | cmd.Parameters.Clear(); | ||
198 | 197 | ||
199 | foreach (string name in FieldList) | 198 | foreach (string name in FieldList) |
199 | { | ||
200 | if (m_FieldMap[name].GetValue(es) is bool) | ||
200 | { | 201 | { |
201 | if (m_FieldMap[name].GetValue(es) is bool) | 202 | if ((bool)m_FieldMap[name].GetValue(es)) |
202 | { | 203 | cmd.Parameters.AddWithValue("?" + name, "1"); |
203 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
204 | cmd.Parameters.AddWithValue("?" + name, "1"); | ||
205 | else | ||
206 | cmd.Parameters.AddWithValue("?" + name, "0"); | ||
207 | } | ||
208 | else | 204 | else |
209 | { | 205 | cmd.Parameters.AddWithValue("?" + name, "0"); |
210 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | ||
211 | } | ||
212 | } | 206 | } |
207 | else | ||
208 | { | ||
209 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | ||
210 | } | ||
211 | } | ||
213 | 212 | ||
214 | cmd.ExecuteNonQuery(); | 213 | cmd.ExecuteNonQuery(); |
215 | 214 | ||
216 | cmd.CommandText = "select LAST_INSERT_ID() as id"; | 215 | cmd.CommandText = "select LAST_INSERT_ID() as id"; |
217 | cmd.Parameters.Clear(); | 216 | cmd.Parameters.Clear(); |
218 | 217 | ||
219 | using (IDataReader r = cmd.ExecuteReader()) | 218 | r = cmd.ExecuteReader(); |
220 | { | 219 | |
221 | r.Read(); | 220 | r.Read(); |
222 | es.EstateID = Convert.ToUInt32(r["id"]); | ||
223 | } | ||
224 | 221 | ||
225 | cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; | 222 | es.EstateID = Convert.ToUInt32(r["id"]); |
226 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
227 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
228 | 223 | ||
229 | // This will throw on dupe key | 224 | r.Close(); |
230 | try { cmd.ExecuteNonQuery(); } | 225 | |
231 | catch (Exception) { } | 226 | cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; |
227 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
228 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
232 | 229 | ||
233 | // Munge and transfer the ban list | 230 | // This will throw on dupe key |
234 | cmd.Parameters.Clear(); | 231 | try |
235 | cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; | 232 | { |
236 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | 233 | cmd.ExecuteNonQuery(); |
234 | } | ||
235 | catch (Exception) | ||
236 | { | ||
237 | } | ||
237 | 238 | ||
238 | try { cmd.ExecuteNonQuery(); } | 239 | // Munge and transfer the ban list |
239 | catch (Exception) { } | 240 | // |
241 | cmd.Parameters.Clear(); | ||
242 | cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; | ||
243 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
240 | 244 | ||
241 | es.Save(); | 245 | try |
246 | { | ||
247 | cmd.ExecuteNonQuery(); | ||
248 | } | ||
249 | catch (Exception) | ||
250 | { | ||
242 | } | 251 | } |
252 | |||
253 | es.Save(); | ||
243 | } | 254 | } |
244 | 255 | ||
245 | LoadBanList(es); | 256 | LoadBanList(es); |
@@ -256,28 +267,27 @@ namespace OpenSim.Data.MySQL | |||
256 | 267 | ||
257 | CheckConnection(); | 268 | CheckConnection(); |
258 | 269 | ||
259 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 270 | MySqlCommand cmd = m_connection.CreateCommand(); |
260 | { | ||
261 | cmd.CommandText = sql; | ||
262 | 271 | ||
263 | foreach (string name in FieldList) | 272 | cmd.CommandText = sql; |
273 | |||
274 | foreach (string name in FieldList) | ||
275 | { | ||
276 | if (m_FieldMap[name].GetValue(es) is bool) | ||
264 | { | 277 | { |
265 | if (m_FieldMap[name].GetValue(es) is bool) | 278 | if ((bool)m_FieldMap[name].GetValue(es)) |
266 | { | 279 | cmd.Parameters.AddWithValue("?" + name, "1"); |
267 | if ((bool)m_FieldMap[name].GetValue(es)) | ||
268 | cmd.Parameters.AddWithValue("?" + name, "1"); | ||
269 | else | ||
270 | cmd.Parameters.AddWithValue("?" + name, "0"); | ||
271 | } | ||
272 | else | 280 | else |
273 | { | 281 | cmd.Parameters.AddWithValue("?" + name, "0"); |
274 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | 282 | } |
275 | } | 283 | else |
284 | { | ||
285 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | ||
276 | } | 286 | } |
277 | |||
278 | cmd.ExecuteNonQuery(); | ||
279 | } | 287 | } |
280 | 288 | ||
289 | cmd.ExecuteNonQuery(); | ||
290 | |||
281 | SaveBanList(es); | 291 | SaveBanList(es); |
282 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); | 292 | SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); |
283 | SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); | 293 | SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); |
@@ -290,52 +300,50 @@ namespace OpenSim.Data.MySQL | |||
290 | 300 | ||
291 | CheckConnection(); | 301 | CheckConnection(); |
292 | 302 | ||
293 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 303 | MySqlCommand cmd = m_connection.CreateCommand(); |
294 | { | ||
295 | cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; | ||
296 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID); | ||
297 | 304 | ||
298 | using (IDataReader r = cmd.ExecuteReader()) | 305 | cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; |
299 | { | 306 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID); |
300 | while (r.Read()) | ||
301 | { | ||
302 | EstateBan eb = new EstateBan(); | ||
303 | 307 | ||
304 | UUID uuid = new UUID(); | 308 | IDataReader r = cmd.ExecuteReader(); |
305 | UUID.TryParse(r["bannedUUID"].ToString(), out uuid); | ||
306 | 309 | ||
307 | eb.BannedUserID = uuid; | 310 | while (r.Read()) |
308 | eb.BannedHostAddress = "0.0.0.0"; | 311 | { |
309 | eb.BannedHostIPMask = "0.0.0.0"; | 312 | EstateBan eb = new EstateBan(); |
310 | es.AddBan(eb); | 313 | |
311 | } | 314 | UUID uuid = new UUID(); |
312 | } | 315 | UUID.TryParse(r["bannedUUID"].ToString(), out uuid); |
316 | |||
317 | eb.BannedUserID = uuid; | ||
318 | eb.BannedHostAddress = "0.0.0.0"; | ||
319 | eb.BannedHostIPMask = "0.0.0.0"; | ||
320 | es.AddBan(eb); | ||
313 | } | 321 | } |
322 | r.Close(); | ||
314 | } | 323 | } |
315 | 324 | ||
316 | private void SaveBanList(EstateSettings es) | 325 | private void SaveBanList(EstateSettings es) |
317 | { | 326 | { |
318 | CheckConnection(); | 327 | CheckConnection(); |
319 | 328 | ||
320 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 329 | MySqlCommand cmd = m_connection.CreateCommand(); |
321 | { | ||
322 | cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; | ||
323 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
324 | 330 | ||
325 | cmd.ExecuteNonQuery(); | 331 | cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; |
332 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
326 | 333 | ||
327 | cmd.Parameters.Clear(); | 334 | cmd.ExecuteNonQuery(); |
328 | 335 | ||
329 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; | 336 | cmd.Parameters.Clear(); |
330 | 337 | ||
331 | foreach (EstateBan b in es.EstateBans) | 338 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; |
332 | { | ||
333 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | ||
334 | cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); | ||
335 | 339 | ||
336 | cmd.ExecuteNonQuery(); | 340 | foreach (EstateBan b in es.EstateBans) |
337 | cmd.Parameters.Clear(); | 341 | { |
338 | } | 342 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); |
343 | cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); | ||
344 | |||
345 | cmd.ExecuteNonQuery(); | ||
346 | cmd.Parameters.Clear(); | ||
339 | } | 347 | } |
340 | } | 348 | } |
341 | 349 | ||
@@ -343,25 +351,24 @@ namespace OpenSim.Data.MySQL | |||
343 | { | 351 | { |
344 | CheckConnection(); | 352 | CheckConnection(); |
345 | 353 | ||
346 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 354 | MySqlCommand cmd = m_connection.CreateCommand(); |
347 | { | ||
348 | cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; | ||
349 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | ||
350 | 355 | ||
351 | cmd.ExecuteNonQuery(); | 356 | cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; |
357 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | ||
352 | 358 | ||
353 | cmd.Parameters.Clear(); | 359 | cmd.ExecuteNonQuery(); |
354 | 360 | ||
355 | cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; | 361 | cmd.Parameters.Clear(); |
356 | 362 | ||
357 | foreach (UUID uuid in data) | 363 | cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; |
358 | { | ||
359 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | ||
360 | cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); | ||
361 | 364 | ||
362 | cmd.ExecuteNonQuery(); | 365 | foreach (UUID uuid in data) |
363 | cmd.Parameters.Clear(); | 366 | { |
364 | } | 367 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); |
368 | cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); | ||
369 | |||
370 | cmd.ExecuteNonQuery(); | ||
371 | cmd.Parameters.Clear(); | ||
365 | } | 372 | } |
366 | } | 373 | } |
367 | 374 | ||
@@ -371,24 +378,23 @@ namespace OpenSim.Data.MySQL | |||
371 | 378 | ||
372 | CheckConnection(); | 379 | CheckConnection(); |
373 | 380 | ||
374 | using (MySqlCommand cmd = m_connection.CreateCommand()) | 381 | MySqlCommand cmd = m_connection.CreateCommand(); |
375 | { | ||
376 | cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; | ||
377 | cmd.Parameters.AddWithValue("?EstateID", EstateID); | ||
378 | 382 | ||
379 | using (IDataReader r = cmd.ExecuteReader()) | 383 | cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; |
380 | { | 384 | cmd.Parameters.AddWithValue("?EstateID", EstateID); |
381 | while (r.Read()) | ||
382 | { | ||
383 | // EstateBan eb = new EstateBan(); | ||
384 | 385 | ||
385 | UUID uuid = new UUID(); | 386 | IDataReader r = cmd.ExecuteReader(); |
386 | UUID.TryParse(r["uuid"].ToString(), out uuid); | ||
387 | 387 | ||
388 | uuids.Add(uuid); | 388 | while (r.Read()) |
389 | } | 389 | { |
390 | } | 390 | // EstateBan eb = new EstateBan(); |
391 | |||
392 | UUID uuid = new UUID(); | ||
393 | UUID.TryParse(r["uuid"].ToString(), out uuid); | ||
394 | |||
395 | uuids.Add(uuid); | ||
391 | } | 396 | } |
397 | r.Close(); | ||
392 | 398 | ||
393 | return uuids.ToArray(); | 399 | return uuids.ToArray(); |
394 | } | 400 | } |
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index ccd1ab0..fca0ca5 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -40,10 +40,6 @@ namespace OpenSim.Data.MySQL | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class MySqlFramework | 41 | public class MySqlFramework |
42 | { | 42 | { |
43 | private static readonly log4net.ILog m_log = | ||
44 | log4net.LogManager.GetLogger( | ||
45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | protected MySqlConnection m_Connection; | 43 | protected MySqlConnection m_Connection; |
48 | 44 | ||
49 | protected MySqlFramework(string connectionString) | 45 | protected MySqlFramework(string connectionString) |
@@ -73,11 +69,11 @@ namespace OpenSim.Data.MySQL | |||
73 | } | 69 | } |
74 | catch (MySqlException e) | 70 | catch (MySqlException e) |
75 | { | 71 | { |
76 | m_log.Error(e.Message, e); | ||
77 | if (errorSeen) | 72 | if (errorSeen) |
78 | throw; | 73 | throw; |
79 | 74 | ||
80 | // This is "Server has gone away" and "Server lost" | 75 | // This is "Server has gone away" and "Server lost" |
76 | // | ||
81 | if (e.Number == 2006 || e.Number == 2013) | 77 | if (e.Number == 2006 || e.Number == 2013) |
82 | { | 78 | { |
83 | errorSeen = true; | 79 | errorSeen = true; |
@@ -96,7 +92,6 @@ namespace OpenSim.Data.MySQL | |||
96 | } | 92 | } |
97 | catch (Exception e) | 93 | catch (Exception e) |
98 | { | 94 | { |
99 | m_log.Error(e.Message, e); | ||
100 | return 0; | 95 | return 0; |
101 | } | 96 | } |
102 | } | 97 | } |
@@ -113,11 +108,11 @@ namespace OpenSim.Data.MySQL | |||
113 | return cmd.ExecuteReader(); | 108 | return cmd.ExecuteReader(); |
114 | } | 109 | } |
115 | 110 | ||
116 | protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd) | 111 | protected void CloseReaderCommand(MySqlCommand cmd) |
117 | { | 112 | { |
118 | reader.Close(); | ||
119 | cmd.Connection.Close(); | 113 | cmd.Connection.Close(); |
120 | cmd.Connection.Dispose(); | 114 | cmd.Connection.Dispose(); |
115 | cmd.Dispose(); | ||
121 | } | 116 | } |
122 | } | 117 | } |
123 | } | 118 | } |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs new file mode 100644 index 0000000..4eb4a24 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -0,0 +1,200 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using MySql.Data.MySqlClient; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | |||
38 | namespace OpenSim.Data.MySQL | ||
39 | { | ||
40 | public class MySQLGenericTableHandler<T> : MySqlFramework where T: struct | ||
41 | { | ||
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | |||
46 | protected Dictionary<string, FieldInfo> m_Fields = | ||
47 | new Dictionary<string, FieldInfo>(); | ||
48 | |||
49 | protected List<string> m_ColumnNames = null; | ||
50 | protected string m_Realm; | ||
51 | protected FieldInfo m_DataField = null; | ||
52 | |||
53 | public MySQLGenericTableHandler(string connectionString, | ||
54 | string realm, string storeName) : base(connectionString) | ||
55 | { | ||
56 | m_Realm = realm; | ||
57 | if (storeName != String.Empty) | ||
58 | { | ||
59 | Assembly assem = GetType().Assembly; | ||
60 | |||
61 | Migration m = new Migration(m_Connection, assem, storeName); | ||
62 | m.Update(); | ||
63 | } | ||
64 | |||
65 | Type t = typeof(T); | ||
66 | FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic | | ||
67 | BindingFlags.Instance | | ||
68 | BindingFlags.DeclaredOnly); | ||
69 | |||
70 | if (fields.Length == 0) | ||
71 | return; | ||
72 | |||
73 | foreach (FieldInfo f in fields) | ||
74 | { | ||
75 | if (f.Name != "Data") | ||
76 | m_Fields[f.Name] = f; | ||
77 | else | ||
78 | m_DataField = f; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | private void CheckColumnNames(IDataReader reader) | ||
83 | { | ||
84 | if (m_ColumnNames != null) | ||
85 | return; | ||
86 | |||
87 | m_ColumnNames = new List<string>(); | ||
88 | |||
89 | DataTable schemaTable = reader.GetSchemaTable(); | ||
90 | foreach (DataRow row in schemaTable.Rows) | ||
91 | { | ||
92 | if (row["ColumnName"] != null && | ||
93 | (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) | ||
94 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public T[] Get(string field, string key) | ||
99 | { | ||
100 | return Get(new string[] { field }, new string[] { key }); | ||
101 | } | ||
102 | |||
103 | public T[] Get(string[] fields, string[] keys) | ||
104 | { | ||
105 | if (fields.Length != keys.Length) | ||
106 | return new T[0]; | ||
107 | |||
108 | List<string> terms = new List<string>(); | ||
109 | |||
110 | MySqlCommand cmd = new MySqlCommand(); | ||
111 | |||
112 | for (int i = 0 ; i < fields.Length ; i++) | ||
113 | { | ||
114 | cmd.Parameters.AddWithValue(fields[i], keys[i]); | ||
115 | terms.Add(fields[i] + " = ?" + fields[i]); | ||
116 | } | ||
117 | |||
118 | string where = String.Join(" and ", terms.ToArray()); | ||
119 | |||
120 | string query = String.Format("select * from {0} where {1}", | ||
121 | m_Realm, where); | ||
122 | |||
123 | cmd.CommandText = query; | ||
124 | |||
125 | return DoQuery(cmd); | ||
126 | } | ||
127 | |||
128 | protected T[] DoQuery(MySqlCommand cmd) | ||
129 | { | ||
130 | IDataReader reader = ExecuteReader(cmd); | ||
131 | if (reader == null) | ||
132 | return new T[0]; | ||
133 | |||
134 | CheckColumnNames(reader); | ||
135 | |||
136 | List<T> result = new List<T>(); | ||
137 | |||
138 | while(reader.Read()) | ||
139 | { | ||
140 | T row = new T(); | ||
141 | |||
142 | foreach (string name in m_Fields.Keys) | ||
143 | { | ||
144 | if (m_Fields[name].GetValue(row) is bool) | ||
145 | { | ||
146 | int v = Convert.ToInt32(reader[name]); | ||
147 | m_Fields[name].SetValue(row, v != 0 ? true : false); | ||
148 | } | ||
149 | else if(m_Fields[name].GetValue(row) is UUID) | ||
150 | { | ||
151 | UUID uuid = UUID.Zero; | ||
152 | |||
153 | UUID.TryParse(reader[name].ToString(), out uuid); | ||
154 | m_Fields[name].SetValue(row, uuid); | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | m_Fields[name].SetValue(row, reader[name]); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | if (m_DataField != null) | ||
163 | { | ||
164 | Dictionary<string, string> data = | ||
165 | new Dictionary<string, string>(); | ||
166 | |||
167 | foreach (string col in m_ColumnNames) | ||
168 | data[col] = reader[col].ToString(); | ||
169 | |||
170 | m_DataField.SetValue(row, data); | ||
171 | } | ||
172 | |||
173 | result.Add(row); | ||
174 | } | ||
175 | |||
176 | CloseReaderCommand(cmd); | ||
177 | |||
178 | return result.ToArray(); | ||
179 | } | ||
180 | |||
181 | public T[] Get(string where) | ||
182 | { | ||
183 | MySqlCommand cmd = new MySqlCommand(); | ||
184 | |||
185 | string query = String.Format("select * from {0} where {1}", | ||
186 | m_Realm, where); | ||
187 | |||
188 | cmd.CommandText = query; | ||
189 | |||
190 | return DoQuery(cmd); | ||
191 | } | ||
192 | |||
193 | public void Store(T row) | ||
194 | { | ||
195 | MySqlCommand cmd = new MySqlCommand(); | ||
196 | |||
197 | string query = ""; | ||
198 | } | ||
199 | } | ||
200 | } | ||
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 38cb3b7..1ec2609 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs | |||
@@ -197,27 +197,29 @@ namespace OpenSim.Data.MySQL | |||
197 | param["?xmax"] = xmax.ToString(); | 197 | param["?xmax"] = xmax.ToString(); |
198 | param["?ymax"] = ymax.ToString(); | 198 | param["?ymax"] = ymax.ToString(); |
199 | 199 | ||
200 | using (IDbCommand result = dbm.Manager.Query( | 200 | IDbCommand result = |
201 | dbm.Manager.Query( | ||
201 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", | 202 | "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", |
202 | param)) | 203 | param); |
203 | { | 204 | IDataReader reader = result.ExecuteReader(); |
204 | using (IDataReader reader = result.ExecuteReader()) | ||
205 | { | ||
206 | RegionProfileData row; | ||
207 | 205 | ||
208 | List<RegionProfileData> rows = new List<RegionProfileData>(); | 206 | RegionProfileData row; |
209 | 207 | ||
210 | while ((row = dbm.Manager.readSimRow(reader)) != null) | 208 | List<RegionProfileData> rows = new List<RegionProfileData>(); |
211 | rows.Add(row); | ||
212 | 209 | ||
213 | return rows.ToArray(); | 210 | while ((row = dbm.Manager.readSimRow(reader)) != null) |
214 | } | 211 | { |
212 | rows.Add(row); | ||
215 | } | 213 | } |
214 | reader.Close(); | ||
215 | result.Dispose(); | ||
216 | |||
217 | return rows.ToArray(); | ||
216 | } | 218 | } |
217 | catch (Exception e) | 219 | catch (Exception e) |
218 | { | 220 | { |
219 | dbm.Manager.Reconnect(); | 221 | dbm.Manager.Reconnect(); |
220 | m_log.Error(e.Message, e); | 222 | m_log.Error(e.ToString()); |
221 | return null; | 223 | return null; |
222 | } | 224 | } |
223 | finally | 225 | finally |
@@ -241,27 +243,29 @@ namespace OpenSim.Data.MySQL | |||
241 | Dictionary<string, object> param = new Dictionary<string, object>(); | 243 | Dictionary<string, object> param = new Dictionary<string, object>(); |
242 | param["?name"] = namePrefix + "%"; | 244 | param["?name"] = namePrefix + "%"; |
243 | 245 | ||
244 | using (IDbCommand result = dbm.Manager.Query( | 246 | IDbCommand result = |
245 | "SELECT * FROM regions WHERE regionName LIKE ?name", | 247 | dbm.Manager.Query( |
246 | param)) | 248 | "SELECT * FROM regions WHERE regionName LIKE ?name", |
247 | { | 249 | param); |
248 | using (IDataReader reader = result.ExecuteReader()) | 250 | IDataReader reader = result.ExecuteReader(); |
249 | { | ||
250 | RegionProfileData row; | ||
251 | 251 | ||
252 | List<RegionProfileData> rows = new List<RegionProfileData>(); | 252 | RegionProfileData row; |
253 | 253 | ||
254 | while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) | 254 | List<RegionProfileData> rows = new List<RegionProfileData>(); |
255 | rows.Add(row); | ||
256 | 255 | ||
257 | return rows; | 256 | while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) |
258 | } | 257 | { |
258 | rows.Add(row); | ||
259 | } | 259 | } |
260 | reader.Close(); | ||
261 | result.Dispose(); | ||
262 | |||
263 | return rows; | ||
260 | } | 264 | } |
261 | catch (Exception e) | 265 | catch (Exception e) |
262 | { | 266 | { |
263 | dbm.Manager.Reconnect(); | 267 | dbm.Manager.Reconnect(); |
264 | m_log.Error(e.Message, e); | 268 | m_log.Error(e.ToString()); |
265 | return null; | 269 | return null; |
266 | } | 270 | } |
267 | finally | 271 | finally |
@@ -282,21 +286,21 @@ namespace OpenSim.Data.MySQL | |||
282 | try | 286 | try |
283 | { | 287 | { |
284 | Dictionary<string, object> param = new Dictionary<string, object>(); | 288 | Dictionary<string, object> param = new Dictionary<string, object>(); |
285 | param["?handle"] = handle.ToString(); | 289 | param["?handle"] = handle.ToString(); |
286 | 290 | ||
287 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param)) | 291 | IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); |
288 | { | 292 | IDataReader reader = result.ExecuteReader(); |
289 | using (IDataReader reader = result.ExecuteReader()) | 293 | |
290 | { | 294 | RegionProfileData row = dbm.Manager.readSimRow(reader); |
291 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 295 | reader.Close(); |
292 | return row; | 296 | result.Dispose(); |
293 | } | 297 | |
298 | return row; | ||
294 | } | 299 | } |
295 | } | ||
296 | catch (Exception e) | 300 | catch (Exception e) |
297 | { | 301 | { |
298 | dbm.Manager.Reconnect(); | 302 | dbm.Manager.Reconnect(); |
299 | m_log.Error(e.Message, e); | 303 | m_log.Error(e.ToString()); |
300 | return null; | 304 | return null; |
301 | } | 305 | } |
302 | finally | 306 | finally |
@@ -317,24 +321,23 @@ namespace OpenSim.Data.MySQL | |||
317 | try | 321 | try |
318 | { | 322 | { |
319 | Dictionary<string, object> param = new Dictionary<string, object>(); | 323 | Dictionary<string, object> param = new Dictionary<string, object>(); |
320 | param["?uuid"] = uuid.ToString(); | 324 | param["?uuid"] = uuid.ToString(); |
321 | 325 | ||
322 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param)) | 326 | IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); |
323 | { | 327 | IDataReader reader = result.ExecuteReader(); |
324 | using (IDataReader reader = result.ExecuteReader()) | 328 | |
325 | { | 329 | RegionProfileData row = dbm.Manager.readSimRow(reader); |
326 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 330 | reader.Close(); |
327 | return row; | 331 | result.Dispose(); |
328 | } | 332 | |
333 | return row; | ||
329 | } | 334 | } |
330 | } | ||
331 | catch (Exception e) | 335 | catch (Exception e) |
332 | { | 336 | { |
333 | dbm.Manager.Reconnect(); | 337 | dbm.Manager.Reconnect(); |
334 | m_log.Error(e.Message, e); | 338 | m_log.Error(e.ToString()); |
335 | return null; | 339 | return null; |
336 | } | 340 | } finally |
337 | finally | ||
338 | { | 341 | { |
339 | dbm.Release(); | 342 | dbm.Release(); |
340 | } | 343 | } |
@@ -356,21 +359,22 @@ namespace OpenSim.Data.MySQL | |||
356 | // Add % because this is a like query. | 359 | // Add % because this is a like query. |
357 | param["?regionName"] = regionName + "%"; | 360 | param["?regionName"] = regionName + "%"; |
358 | // Order by statement will return shorter matches first. Only returns one record or no record. | 361 | // Order by statement will return shorter matches first. Only returns one record or no record. |
359 | using (IDbCommand result = dbm.Manager.Query( | 362 | IDbCommand result = |
360 | "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", | 363 | dbm.Manager.Query( |
361 | param)) | 364 | "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", |
362 | { | 365 | param); |
363 | using (IDataReader reader = result.ExecuteReader()) | 366 | IDataReader reader = result.ExecuteReader(); |
364 | { | 367 | |
365 | RegionProfileData row = dbm.Manager.readSimRow(reader); | 368 | RegionProfileData row = dbm.Manager.readSimRow(reader); |
366 | return row; | 369 | reader.Close(); |
367 | } | 370 | result.Dispose(); |
368 | } | 371 | |
372 | return row; | ||
369 | } | 373 | } |
370 | catch (Exception e) | 374 | catch (Exception e) |
371 | { | 375 | { |
372 | dbm.Manager.Reconnect(); | 376 | dbm.Manager.Reconnect(); |
373 | m_log.Error(e.Message, e); | 377 | m_log.Error(e.ToString()); |
374 | return null; | 378 | return null; |
375 | } | 379 | } |
376 | finally | 380 | finally |
@@ -378,7 +382,6 @@ namespace OpenSim.Data.MySQL | |||
378 | dbm.Release(); | 382 | dbm.Release(); |
379 | } | 383 | } |
380 | } | 384 | } |
381 | |||
382 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); | 385 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); |
383 | return null; | 386 | return null; |
384 | } | 387 | } |
@@ -391,12 +394,12 @@ namespace OpenSim.Data.MySQL | |||
391 | override public DataResponse StoreProfile(RegionProfileData profile) | 394 | override public DataResponse StoreProfile(RegionProfileData profile) |
392 | { | 395 | { |
393 | MySQLSuperManager dbm = GetLockedConnection(); | 396 | MySQLSuperManager dbm = GetLockedConnection(); |
394 | try | 397 | try { |
395 | { | ||
396 | if (dbm.Manager.insertRegion(profile)) | 398 | if (dbm.Manager.insertRegion(profile)) |
399 | { | ||
397 | return DataResponse.RESPONSE_OK; | 400 | return DataResponse.RESPONSE_OK; |
398 | else | 401 | } |
399 | return DataResponse.RESPONSE_ERROR; | 402 | return DataResponse.RESPONSE_ERROR; |
400 | } | 403 | } |
401 | finally | 404 | finally |
402 | { | 405 | { |
@@ -414,14 +417,14 @@ namespace OpenSim.Data.MySQL | |||
414 | { | 417 | { |
415 | MySQLSuperManager dbm = GetLockedConnection(); | 418 | MySQLSuperManager dbm = GetLockedConnection(); |
416 | 419 | ||
417 | try | 420 | |
418 | { | 421 | try { |
419 | if (dbm.Manager.deleteRegion(uuid)) | 422 | if (dbm.Manager.deleteRegion(uuid)) |
423 | { | ||
420 | return DataResponse.RESPONSE_OK; | 424 | return DataResponse.RESPONSE_OK; |
421 | else | 425 | } |
422 | return DataResponse.RESPONSE_ERROR; | 426 | return DataResponse.RESPONSE_ERROR; |
423 | } | 427 | } finally |
424 | finally | ||
425 | { | 428 | { |
426 | dbm.Release(); | 429 | dbm.Release(); |
427 | } | 430 | } |
@@ -479,26 +482,26 @@ namespace OpenSim.Data.MySQL | |||
479 | try | 482 | try |
480 | { | 483 | { |
481 | Dictionary<string, object> param = new Dictionary<string, object>(); | 484 | Dictionary<string, object> param = new Dictionary<string, object>(); |
482 | param["?x"] = x.ToString(); | 485 | param["?x"] = x.ToString(); |
483 | param["?y"] = y.ToString(); | 486 | param["?y"] = y.ToString(); |
484 | using (IDbCommand result = dbm.Manager.Query( | 487 | IDbCommand result = |
485 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", | 488 | dbm.Manager.Query( |
486 | param)) | 489 | "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", |
487 | { | 490 | param); |
488 | using (IDataReader reader = result.ExecuteReader()) | 491 | IDataReader reader = result.ExecuteReader(); |
489 | { | 492 | |
490 | ReservationData row = dbm.Manager.readReservationRow(reader); | 493 | ReservationData row = dbm.Manager.readReservationRow(reader); |
491 | return row; | 494 | reader.Close(); |
492 | } | 495 | result.Dispose(); |
493 | } | 496 | |
497 | return row; | ||
494 | } | 498 | } |
495 | catch (Exception e) | 499 | catch (Exception e) |
496 | { | 500 | { |
497 | dbm.Manager.Reconnect(); | 501 | dbm.Manager.Reconnect(); |
498 | m_log.Error(e.Message, e); | 502 | m_log.Error(e.ToString()); |
499 | return null; | 503 | return null; |
500 | } | 504 | } finally |
501 | finally | ||
502 | { | 505 | { |
503 | dbm.Release(); | 506 | dbm.Release(); |
504 | } | 507 | } |
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 598971d..0eecf06 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs | |||
@@ -135,30 +135,30 @@ namespace OpenSim.Data.MySQL | |||
135 | 135 | ||
136 | database.CheckConnection(); | 136 | database.CheckConnection(); |
137 | 137 | ||
138 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", | 138 | MySqlCommand result = |
139 | database.Connection)) | 139 | new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", |
140 | database.Connection); | ||
141 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); | ||
142 | MySqlDataReader reader = result.ExecuteReader(); | ||
143 | |||
144 | while (reader.Read()) | ||
140 | { | 145 | { |
141 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); | 146 | // A null item (because something went wrong) breaks everything in the folder |
147 | InventoryItemBase item = readInventoryItem(reader); | ||
148 | if (item != null) | ||
149 | items.Add(item); | ||
150 | } | ||
142 | 151 | ||
143 | using (MySqlDataReader reader = result.ExecuteReader()) | 152 | reader.Close(); |
144 | { | 153 | result.Dispose(); |
145 | while (reader.Read()) | ||
146 | { | ||
147 | // A null item (because something went wrong) breaks everything in the folder | ||
148 | InventoryItemBase item = readInventoryItem(reader); | ||
149 | if (item != null) | ||
150 | items.Add(item); | ||
151 | } | ||
152 | 154 | ||
153 | return items; | 155 | return items; |
154 | } | ||
155 | } | ||
156 | } | 156 | } |
157 | } | 157 | } |
158 | catch (Exception e) | 158 | catch (Exception e) |
159 | { | 159 | { |
160 | database.Reconnect(); | 160 | database.Reconnect(); |
161 | m_log.Error(e.Message, e); | 161 | m_log.Error(e.ToString()); |
162 | return null; | 162 | return null; |
163 | } | 163 | } |
164 | } | 164 | } |
@@ -176,28 +176,29 @@ namespace OpenSim.Data.MySQL | |||
176 | { | 176 | { |
177 | database.CheckConnection(); | 177 | database.CheckConnection(); |
178 | 178 | ||
179 | using (MySqlCommand result = new MySqlCommand( | 179 | MySqlCommand result = |
180 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", | 180 | new MySqlCommand( |
181 | database.Connection)) | 181 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", |
182 | { | 182 | database.Connection); |
183 | result.Parameters.AddWithValue("?uuid", user.ToString()); | 183 | result.Parameters.AddWithValue("?uuid", user.ToString()); |
184 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); | 184 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); |
185 | MySqlDataReader reader = result.ExecuteReader(); | ||
185 | 186 | ||
186 | using (MySqlDataReader reader = result.ExecuteReader()) | 187 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
187 | { | 188 | while (reader.Read()) |
188 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | 189 | items.Add(readInventoryFolder(reader)); |
189 | while (reader.Read()) | ||
190 | items.Add(readInventoryFolder(reader)); | ||
191 | 190 | ||
192 | return items; | 191 | |
193 | } | 192 | reader.Close(); |
194 | } | 193 | result.Dispose(); |
194 | |||
195 | return items; | ||
195 | } | 196 | } |
196 | } | 197 | } |
197 | catch (Exception e) | 198 | catch (Exception e) |
198 | { | 199 | { |
199 | database.Reconnect(); | 200 | database.Reconnect(); |
200 | m_log.Error(e.Message, e); | 201 | m_log.Error(e.ToString()); |
201 | return null; | 202 | return null; |
202 | } | 203 | } |
203 | } | 204 | } |
@@ -216,38 +217,41 @@ namespace OpenSim.Data.MySQL | |||
216 | { | 217 | { |
217 | database.CheckConnection(); | 218 | database.CheckConnection(); |
218 | 219 | ||
219 | using (MySqlCommand result = new MySqlCommand( | 220 | MySqlCommand result = |
220 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", | 221 | new MySqlCommand( |
221 | database.Connection)) | 222 | "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", |
222 | { | 223 | database.Connection); |
223 | result.Parameters.AddWithValue("?uuid", user.ToString()); | 224 | result.Parameters.AddWithValue("?uuid", user.ToString()); |
224 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); | 225 | result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); |
225 | 226 | ||
226 | using (MySqlDataReader reader = result.ExecuteReader()) | 227 | MySqlDataReader reader = result.ExecuteReader(); |
227 | { | ||
228 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | ||
229 | while (reader.Read()) | ||
230 | items.Add(readInventoryFolder(reader)); | ||
231 | 228 | ||
232 | InventoryFolderBase rootFolder = null; | 229 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
230 | while (reader.Read()) | ||
231 | items.Add(readInventoryFolder(reader)); | ||
233 | 232 | ||
234 | // There should only ever be one root folder for a user. However, if there's more | 233 | InventoryFolderBase rootFolder = null; |
235 | // than one we'll simply use the first one rather than failing. It would be even | ||
236 | // nicer to print some message to this effect, but this feels like it's too low a | ||
237 | // to put such a message out, and it's too minor right now to spare the time to | ||
238 | // suitably refactor. | ||
239 | if (items.Count > 0) | ||
240 | rootFolder = items[0]; | ||
241 | 234 | ||
242 | return rootFolder; | 235 | // There should only ever be one root folder for a user. However, if there's more |
243 | } | 236 | // than one we'll simply use the first one rather than failing. It would be even |
237 | // nicer to print some message to this effect, but this feels like it's too low a | ||
238 | // to put such a message out, and it's too minor right now to spare the time to | ||
239 | // suitably refactor. | ||
240 | if (items.Count > 0) | ||
241 | { | ||
242 | rootFolder = items[0]; | ||
244 | } | 243 | } |
244 | |||
245 | reader.Close(); | ||
246 | result.Dispose(); | ||
247 | |||
248 | return rootFolder; | ||
245 | } | 249 | } |
246 | } | 250 | } |
247 | catch (Exception e) | 251 | catch (Exception e) |
248 | { | 252 | { |
249 | database.Reconnect(); | 253 | database.Reconnect(); |
250 | m_log.Error(e.Message, e); | 254 | m_log.Error(e.ToString()); |
251 | return null; | 255 | return null; |
252 | } | 256 | } |
253 | } | 257 | } |
@@ -267,26 +271,27 @@ namespace OpenSim.Data.MySQL | |||
267 | { | 271 | { |
268 | database.CheckConnection(); | 272 | database.CheckConnection(); |
269 | 273 | ||
270 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", | 274 | MySqlCommand result = |
271 | database.Connection)) | 275 | new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", |
272 | { | 276 | database.Connection); |
273 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); | 277 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); |
274 | using (MySqlDataReader reader = result.ExecuteReader()) | 278 | MySqlDataReader reader = result.ExecuteReader(); |
275 | { | ||
276 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); | ||
277 | 279 | ||
278 | while (reader.Read()) | 280 | List<InventoryFolderBase> items = new List<InventoryFolderBase>(); |
279 | items.Add(readInventoryFolder(reader)); | ||
280 | 281 | ||
281 | return items; | 282 | while (reader.Read()) |
282 | } | 283 | items.Add(readInventoryFolder(reader)); |
283 | } | 284 | |
285 | reader.Close(); | ||
286 | result.Dispose(); | ||
287 | |||
288 | return items; | ||
284 | } | 289 | } |
285 | } | 290 | } |
286 | catch (Exception e) | 291 | catch (Exception e) |
287 | { | 292 | { |
288 | database.Reconnect(); | 293 | database.Reconnect(); |
289 | m_log.Error(e.Message, e); | 294 | m_log.Error(e.ToString()); |
290 | return null; | 295 | return null; |
291 | } | 296 | } |
292 | } | 297 | } |
@@ -365,25 +370,25 @@ namespace OpenSim.Data.MySQL | |||
365 | { | 370 | { |
366 | database.CheckConnection(); | 371 | database.CheckConnection(); |
367 | 372 | ||
368 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection)) | 373 | MySqlCommand result = |
369 | { | 374 | new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); |
370 | result.Parameters.AddWithValue("?uuid", itemID.ToString()); | 375 | result.Parameters.AddWithValue("?uuid", itemID.ToString()); |
376 | MySqlDataReader reader = result.ExecuteReader(); | ||
371 | 377 | ||
372 | using (MySqlDataReader reader = result.ExecuteReader()) | 378 | InventoryItemBase item = null; |
373 | { | 379 | if (reader.Read()) |
374 | InventoryItemBase item = null; | 380 | item = readInventoryItem(reader); |
375 | if (reader.Read()) | ||
376 | item = readInventoryItem(reader); | ||
377 | 381 | ||
378 | return item; | 382 | reader.Close(); |
379 | } | 383 | result.Dispose(); |
380 | } | 384 | |
385 | return item; | ||
381 | } | 386 | } |
382 | } | 387 | } |
383 | catch (Exception e) | 388 | catch (Exception e) |
384 | { | 389 | { |
385 | database.Reconnect(); | 390 | database.Reconnect(); |
386 | m_log.Error(e.Message, e); | 391 | m_log.Error(e.ToString()); |
387 | } | 392 | } |
388 | return null; | 393 | return null; |
389 | } | 394 | } |
@@ -408,7 +413,7 @@ namespace OpenSim.Data.MySQL | |||
408 | } | 413 | } |
409 | catch (Exception e) | 414 | catch (Exception e) |
410 | { | 415 | { |
411 | m_log.Error(e.Message, e); | 416 | m_log.Error(e.ToString()); |
412 | } | 417 | } |
413 | 418 | ||
414 | return null; | 419 | return null; |
@@ -428,25 +433,24 @@ namespace OpenSim.Data.MySQL | |||
428 | { | 433 | { |
429 | database.CheckConnection(); | 434 | database.CheckConnection(); |
430 | 435 | ||
431 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) | 436 | MySqlCommand result = |
432 | { | 437 | new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); |
433 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); | 438 | result.Parameters.AddWithValue("?uuid", folderID.ToString()); |
439 | MySqlDataReader reader = result.ExecuteReader(); | ||
434 | 440 | ||
435 | using (MySqlDataReader reader = result.ExecuteReader()) | 441 | InventoryFolderBase folder = null; |
436 | { | 442 | if (reader.Read()) |
437 | InventoryFolderBase folder = null; | 443 | folder = readInventoryFolder(reader); |
438 | if (reader.Read()) | 444 | reader.Close(); |
439 | folder = readInventoryFolder(reader); | 445 | result.Dispose(); |
440 | 446 | ||
441 | return folder; | 447 | return folder; |
442 | } | ||
443 | } | ||
444 | } | 448 | } |
445 | } | 449 | } |
446 | catch (Exception e) | 450 | catch (Exception e) |
447 | { | 451 | { |
448 | database.Reconnect(); | 452 | database.Reconnect(); |
449 | m_log.Error(e.Message, e); | 453 | m_log.Error(e.ToString()); |
450 | return null; | 454 | return null; |
451 | } | 455 | } |
452 | } | 456 | } |
@@ -694,73 +698,69 @@ namespace OpenSim.Data.MySQL | |||
694 | try | 698 | try |
695 | { | 699 | { |
696 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 700 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); |
697 | Dictionary<UUID, List<InventoryFolderBase>> hashtable = new Dictionary<UUID, List<InventoryFolderBase>>(); ; | 701 | Dictionary<UUID, List<InventoryFolderBase>> hashtable |
702 | = new Dictionary<UUID, List<InventoryFolderBase>>(); ; | ||
698 | List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>(); | 703 | List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>(); |
699 | bool buildResultsFromHashTable = false; | ||
700 | |||
701 | lock (database) | 704 | lock (database) |
702 | { | 705 | { |
706 | MySqlCommand result; | ||
707 | MySqlDataReader reader; | ||
708 | bool buildResultsFromHashTable = false; | ||
709 | |||
703 | database.CheckConnection(); | 710 | database.CheckConnection(); |
704 | 711 | ||
705 | /* Fetch the parent folder from the database to determine the agent ID, and if | 712 | /* Fetch the parent folder from the database to determine the agent ID, and if |
706 | * we're querying the root of the inventory folder tree */ | 713 | * we're querying the root of the inventory folder tree */ |
707 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) | 714 | result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", |
708 | { | 715 | database.Connection); |
709 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); | 716 | result.Parameters.AddWithValue("?uuid", parentID.ToString()); |
710 | 717 | reader = result.ExecuteReader(); | |
711 | using (MySqlDataReader reader = result.ExecuteReader()) | 718 | while (reader.Read()) // Should be at most 1 result |
712 | { | 719 | parentFolder.Add(readInventoryFolder(reader)); |
713 | // Should be at most 1 result | 720 | reader.Close(); |
714 | while (reader.Read()) | 721 | result.Dispose(); |
715 | parentFolder.Add(readInventoryFolder(reader)); | ||
716 | } | ||
717 | } | ||
718 | 722 | ||
719 | if (parentFolder.Count >= 1) // No result means parent folder does not exist | 723 | if (parentFolder.Count >= 1) // No result means parent folder does not exist |
720 | { | 724 | { |
721 | if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder | 725 | if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder |
722 | { | 726 | { |
723 | /* Get all of the agent's folders from the database, put them in a list and return it */ | 727 | /* Get all of the agent's folders from the database, put them in a list and return it */ |
724 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) | 728 | result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", |
729 | database.Connection); | ||
730 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | ||
731 | reader = result.ExecuteReader(); | ||
732 | while (reader.Read()) | ||
725 | { | 733 | { |
726 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | 734 | InventoryFolderBase curFolder = readInventoryFolder(reader); |
727 | 735 | if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list | |
728 | using (MySqlDataReader reader = result.ExecuteReader()) | 736 | folders.Add(curFolder); |
729 | { | ||
730 | while (reader.Read()) | ||
731 | { | ||
732 | InventoryFolderBase curFolder = readInventoryFolder(reader); | ||
733 | if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list | ||
734 | folders.Add(curFolder); | ||
735 | } | ||
736 | } | ||
737 | } | 737 | } |
738 | reader.Close(); | ||
739 | result.Dispose(); | ||
738 | } // if we are querying the root folder | 740 | } // if we are querying the root folder |
739 | else // else we are querying a subtree of the inventory folder tree | 741 | else // else we are querying a subtree of the inventory folder tree |
740 | { | 742 | { |
741 | /* Get all of the agent's folders from the database, put them all in a hash table | 743 | /* Get all of the agent's folders from the database, put them all in a hash table |
742 | * indexed by their parent ID */ | 744 | * indexed by their parent ID */ |
743 | using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) | 745 | result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", |
746 | database.Connection); | ||
747 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | ||
748 | reader = result.ExecuteReader(); | ||
749 | while (reader.Read()) | ||
744 | { | 750 | { |
745 | result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); | 751 | InventoryFolderBase curFolder = readInventoryFolder(reader); |
746 | 752 | if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling | |
747 | using (MySqlDataReader reader = result.ExecuteReader()) | 753 | hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list |
754 | else // else current folder has no known (yet) siblings | ||
748 | { | 755 | { |
749 | while (reader.Read()) | 756 | List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>(); |
750 | { | 757 | siblingList.Add(curFolder); |
751 | InventoryFolderBase curFolder = readInventoryFolder(reader); | 758 | // Current folder has no known (yet) siblings |
752 | if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling | 759 | hashtable.Add(curFolder.ParentID, siblingList); |
753 | hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list | ||
754 | else // else current folder has no known (yet) siblings | ||
755 | { | ||
756 | List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>(); | ||
757 | siblingList.Add(curFolder); | ||
758 | // Current folder has no known (yet) siblings | ||
759 | hashtable.Add(curFolder.ParentID, siblingList); | ||
760 | } | ||
761 | } // while more items to read from the database | ||
762 | } | 760 | } |
763 | } | 761 | } // while more items to read from the database |
762 | reader.Close(); | ||
763 | result.Dispose(); | ||
764 | 764 | ||
765 | // Set flag so we know we need to build the results from the hash table after | 765 | // Set flag so we know we need to build the results from the hash table after |
766 | // we unlock the database | 766 | // we unlock the database |
@@ -781,13 +781,12 @@ namespace OpenSim.Data.MySQL | |||
781 | folders.AddRange(hashtable[folders[i].ID]); | 781 | folders.AddRange(hashtable[folders[i].ID]); |
782 | } | 782 | } |
783 | } // lock (database) | 783 | } // lock (database) |
784 | |||
785 | return folders; | 784 | return folders; |
786 | } | 785 | } |
787 | catch (Exception e) | 786 | catch (Exception e) |
788 | { | 787 | { |
789 | database.Reconnect(); | 788 | database.Reconnect(); |
790 | m_log.Error(e.Message, e); | 789 | m_log.Error(e.ToString()); |
791 | return null; | 790 | return null; |
792 | } | 791 | } |
793 | } | 792 | } |
@@ -802,18 +801,19 @@ namespace OpenSim.Data.MySQL | |||
802 | { | 801 | { |
803 | database.CheckConnection(); | 802 | database.CheckConnection(); |
804 | 803 | ||
805 | using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection)) | 804 | MySqlCommand cmd = |
806 | { | 805 | new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); |
807 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); | 806 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); |
808 | 807 | ||
809 | lock (database) | 808 | lock (database) |
810 | cmd.ExecuteNonQuery(); | 809 | { |
810 | cmd.ExecuteNonQuery(); | ||
811 | } | 811 | } |
812 | } | 812 | } |
813 | catch (MySqlException e) | 813 | catch (MySqlException e) |
814 | { | 814 | { |
815 | database.Reconnect(); | 815 | database.Reconnect(); |
816 | m_log.Error(e.Message, e); | 816 | m_log.Error(e.ToString()); |
817 | } | 817 | } |
818 | } | 818 | } |
819 | 819 | ||
@@ -827,12 +827,13 @@ namespace OpenSim.Data.MySQL | |||
827 | { | 827 | { |
828 | database.CheckConnection(); | 828 | database.CheckConnection(); |
829 | 829 | ||
830 | using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection)) | 830 | MySqlCommand cmd = |
831 | { | 831 | new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); |
832 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); | 832 | cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); |
833 | 833 | ||
834 | lock (database) | 834 | lock (database) |
835 | cmd.ExecuteNonQuery(); | 835 | { |
836 | cmd.ExecuteNonQuery(); | ||
836 | } | 837 | } |
837 | } | 838 | } |
838 | catch (MySqlException e) | 839 | catch (MySqlException e) |
@@ -864,38 +865,40 @@ namespace OpenSim.Data.MySQL | |||
864 | 865 | ||
865 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) | 866 | public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) |
866 | { | 867 | { |
868 | MySqlDataReader result = null; | ||
869 | MySqlCommand sqlCmd = null; | ||
867 | lock (database) | 870 | lock (database) |
868 | { | 871 | { |
869 | try | 872 | try |
870 | { | 873 | { |
871 | database.CheckConnection(); | 874 | database.CheckConnection(); |
872 | 875 | sqlCmd = new MySqlCommand( | |
873 | using (MySqlCommand sqlCmd = new MySqlCommand( | ||
874 | "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", | 876 | "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", |
875 | database.Connection)) | 877 | database.Connection); |
876 | { | 878 | sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); |
877 | sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); | 879 | sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); |
878 | sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); | 880 | result = sqlCmd.ExecuteReader(); |
879 | 881 | ||
880 | using (MySqlDataReader result = sqlCmd.ExecuteReader()) | 882 | List<InventoryItemBase> list = new List<InventoryItemBase>(); |
881 | { | 883 | while (result.Read()) |
882 | List<InventoryItemBase> list = new List<InventoryItemBase>(); | 884 | { |
883 | while (result.Read()) | 885 | InventoryItemBase item = readInventoryItem(result); |
884 | { | 886 | if (item != null) |
885 | InventoryItemBase item = readInventoryItem(result); | 887 | list.Add(item); |
886 | if (item != null) | ||
887 | list.Add(item); | ||
888 | } | ||
889 | return list; | ||
890 | } | ||
891 | } | 888 | } |
889 | return list; | ||
892 | } | 890 | } |
893 | catch (Exception e) | 891 | catch (Exception e) |
894 | { | 892 | { |
895 | database.Reconnect(); | 893 | database.Reconnect(); |
896 | m_log.Error(e.Message, e); | 894 | m_log.Error(e.ToString()); |
897 | return null; | 895 | return null; |
898 | } | 896 | } |
897 | finally | ||
898 | { | ||
899 | if (result != null) result.Close(); | ||
900 | if (sqlCmd != null) sqlCmd.Dispose(); | ||
901 | } | ||
899 | } | 902 | } |
900 | } | 903 | } |
901 | } | 904 | } |
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index a807948..c49153f 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | |||
@@ -908,7 +908,7 @@ namespace OpenSim.Data.MySQL | |||
908 | if (!(row["ParticleSystem"] is DBNull)) | 908 | if (!(row["ParticleSystem"] is DBNull)) |
909 | prim.ParticleSystem = (byte[])row["ParticleSystem"]; | 909 | prim.ParticleSystem = (byte[])row["ParticleSystem"]; |
910 | 910 | ||
911 | prim.RotationalVelocity = new Vector3( | 911 | prim.AngularVelocity = new Vector3( |
912 | (float)(double)row["OmegaX"], | 912 | (float)(double)row["OmegaX"], |
913 | (float)(double)row["OmegaY"], | 913 | (float)(double)row["OmegaY"], |
914 | (float)(double)row["OmegaZ"] | 914 | (float)(double)row["OmegaZ"] |
@@ -1240,9 +1240,9 @@ namespace OpenSim.Data.MySQL | |||
1240 | cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); | 1240 | cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); |
1241 | cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); | 1241 | cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); |
1242 | 1242 | ||
1243 | cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X); | 1243 | cmd.Parameters.AddWithValue("OmegaX", (double)prim.AngularVelocity.X); |
1244 | cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y); | 1244 | cmd.Parameters.AddWithValue("OmegaY", (double)prim.AngularVelocity.Y); |
1245 | cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z); | 1245 | cmd.Parameters.AddWithValue("OmegaZ", (double)prim.AngularVelocity.Z); |
1246 | 1246 | ||
1247 | cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); | 1247 | cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); |
1248 | cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); | 1248 | cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); |
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a724a50..a6cce57 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs | |||
@@ -134,16 +134,18 @@ namespace OpenSim.Data.MySQL | |||
134 | /// </summary> | 134 | /// </summary> |
135 | protected void GetWaitTimeout() | 135 | protected void GetWaitTimeout() |
136 | { | 136 | { |
137 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) | 137 | MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon); |
138 | |||
139 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
138 | { | 140 | { |
139 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 141 | if (dbReader.Read()) |
140 | { | 142 | { |
141 | if (dbReader.Read()) | 143 | m_waitTimeout |
142 | { | 144 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; |
143 | m_waitTimeout | ||
144 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
145 | } | ||
146 | } | 145 | } |
146 | |||
147 | dbReader.Close(); | ||
148 | cmd.Dispose(); | ||
147 | } | 149 | } |
148 | 150 | ||
149 | m_lastConnectionUse = DateTime.Now.Ticks; | 151 | m_lastConnectionUse = DateTime.Now.Ticks; |
@@ -301,31 +303,31 @@ namespace OpenSim.Data.MySQL | |||
301 | { | 303 | { |
302 | CheckConnection(); | 304 | CheckConnection(); |
303 | 305 | ||
304 | using (MySqlCommand tablesCmd = new MySqlCommand( | 306 | MySqlCommand tablesCmd = |
305 | "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", | 307 | new MySqlCommand( |
306 | dbcon)) | 308 | "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", |
307 | { | 309 | dbcon); |
308 | tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); | 310 | tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); |
309 | 311 | ||
310 | using (MySqlDataReader tables = tablesCmd.ExecuteReader()) | 312 | using (MySqlDataReader tables = tablesCmd.ExecuteReader()) |
313 | { | ||
314 | while (tables.Read()) | ||
311 | { | 315 | { |
312 | while (tables.Read()) | 316 | try |
313 | { | 317 | { |
314 | try | 318 | string tableName = (string) tables["TABLE_NAME"]; |
315 | { | 319 | string comment = (string) tables["TABLE_COMMENT"]; |
316 | string tableName = (string)tables["TABLE_NAME"]; | 320 | if (tableList.ContainsKey(tableName)) |
317 | string comment = (string)tables["TABLE_COMMENT"]; | ||
318 | if (tableList.ContainsKey(tableName)) | ||
319 | { | ||
320 | tableList[tableName] = comment; | ||
321 | } | ||
322 | } | ||
323 | catch (Exception e) | ||
324 | { | 321 | { |
325 | m_log.Error(e.Message, e); | 322 | tableList[tableName] = comment; |
326 | } | 323 | } |
327 | } | 324 | } |
325 | catch (Exception e) | ||
326 | { | ||
327 | m_log.Error(e.ToString()); | ||
328 | } | ||
328 | } | 329 | } |
330 | tables.Close(); | ||
329 | } | 331 | } |
330 | } | 332 | } |
331 | } | 333 | } |
@@ -344,19 +346,19 @@ namespace OpenSim.Data.MySQL | |||
344 | { | 346 | { |
345 | CheckConnection(); // Not sure if this one is necessary | 347 | CheckConnection(); // Not sure if this one is necessary |
346 | 348 | ||
347 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | 349 | MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); |
348 | dbcommand.CommandText = sql; | 350 | dbcommand.CommandText = sql; |
349 | foreach (KeyValuePair<string, object> param in parameters) | 351 | foreach (KeyValuePair<string, object> param in parameters) |
350 | { | 352 | { |
351 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); | 353 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); |
352 | } | 354 | } |
353 | 355 | ||
354 | return (IDbCommand)dbcommand; | 356 | return (IDbCommand) dbcommand; |
355 | } | 357 | } |
356 | catch (Exception e) | 358 | catch (Exception e) |
357 | { | 359 | { |
358 | // Return null if it fails. | 360 | // Return null if it fails. |
359 | m_log.Error("Failed during Query generation: " + e.Message, e); | 361 | m_log.Error("Failed during Query generation: " + e.ToString()); |
360 | return null; | 362 | return null; |
361 | } | 363 | } |
362 | } | 364 | } |
@@ -692,6 +694,8 @@ namespace OpenSim.Data.MySQL | |||
692 | ret.Add(attachpoint, item); | 694 | ret.Add(attachpoint, item); |
693 | } | 695 | } |
694 | 696 | ||
697 | r.Close(); | ||
698 | |||
695 | return ret; | 699 | return ret; |
696 | } | 700 | } |
697 | 701 | ||
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index f514076..b0075e8 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -56,13 +56,12 @@ namespace OpenSim.Data.MySQL | |||
56 | if (scopeID != UUID.Zero) | 56 | if (scopeID != UUID.Zero) |
57 | command += " and ScopeID = ?scopeID"; | 57 | command += " and ScopeID = ?scopeID"; |
58 | 58 | ||
59 | using (MySqlCommand cmd = new MySqlCommand(command)) | 59 | MySqlCommand cmd = new MySqlCommand(command); |
60 | { | ||
61 | cmd.Parameters.AddWithValue("?regionName", regionName); | ||
62 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
63 | 60 | ||
64 | return RunCommand(cmd); | 61 | cmd.Parameters.AddWithValue("?regionName", regionName); |
65 | } | 62 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
63 | |||
64 | return RunCommand(cmd); | ||
66 | } | 65 | } |
67 | 66 | ||
68 | public RegionData Get(int posX, int posY, UUID scopeID) | 67 | public RegionData Get(int posX, int posY, UUID scopeID) |
@@ -71,18 +70,17 @@ namespace OpenSim.Data.MySQL | |||
71 | if (scopeID != UUID.Zero) | 70 | if (scopeID != UUID.Zero) |
72 | command += " and ScopeID = ?scopeID"; | 71 | command += " and ScopeID = ?scopeID"; |
73 | 72 | ||
74 | using (MySqlCommand cmd = new MySqlCommand(command)) | 73 | MySqlCommand cmd = new MySqlCommand(command); |
75 | { | ||
76 | cmd.Parameters.AddWithValue("?posX", posX.ToString()); | ||
77 | cmd.Parameters.AddWithValue("?posY", posY.ToString()); | ||
78 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
79 | 74 | ||
80 | List<RegionData> ret = RunCommand(cmd); | 75 | cmd.Parameters.AddWithValue("?posX", posX.ToString()); |
81 | if (ret.Count == 0) | 76 | cmd.Parameters.AddWithValue("?posY", posY.ToString()); |
82 | return null; | 77 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
83 | 78 | ||
84 | return ret[0]; | 79 | List<RegionData> ret = RunCommand(cmd); |
85 | } | 80 | if (ret.Count == 0) |
81 | return null; | ||
82 | |||
83 | return ret[0]; | ||
86 | } | 84 | } |
87 | 85 | ||
88 | public RegionData Get(UUID regionID, UUID scopeID) | 86 | public RegionData Get(UUID regionID, UUID scopeID) |
@@ -91,17 +89,16 @@ namespace OpenSim.Data.MySQL | |||
91 | if (scopeID != UUID.Zero) | 89 | if (scopeID != UUID.Zero) |
92 | command += " and ScopeID = ?scopeID"; | 90 | command += " and ScopeID = ?scopeID"; |
93 | 91 | ||
94 | using (MySqlCommand cmd = new MySqlCommand(command)) | 92 | MySqlCommand cmd = new MySqlCommand(command); |
95 | { | ||
96 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); | ||
97 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
98 | 93 | ||
99 | List<RegionData> ret = RunCommand(cmd); | 94 | cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); |
100 | if (ret.Count == 0) | 95 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
101 | return null; | ||
102 | 96 | ||
103 | return ret[0]; | 97 | List<RegionData> ret = RunCommand(cmd); |
104 | } | 98 | if (ret.Count == 0) |
99 | return null; | ||
100 | |||
101 | return ret[0]; | ||
105 | } | 102 | } |
106 | 103 | ||
107 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) | 104 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) |
@@ -110,44 +107,43 @@ namespace OpenSim.Data.MySQL | |||
110 | if (scopeID != UUID.Zero) | 107 | if (scopeID != UUID.Zero) |
111 | command += " and ScopeID = ?scopeID"; | 108 | command += " and ScopeID = ?scopeID"; |
112 | 109 | ||
113 | using (MySqlCommand cmd = new MySqlCommand(command)) | 110 | MySqlCommand cmd = new MySqlCommand(command); |
114 | { | ||
115 | cmd.Parameters.AddWithValue("?startX", startX.ToString()); | ||
116 | cmd.Parameters.AddWithValue("?startY", startY.ToString()); | ||
117 | cmd.Parameters.AddWithValue("?endX", endX.ToString()); | ||
118 | cmd.Parameters.AddWithValue("?endY", endY.ToString()); | ||
119 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
120 | 111 | ||
121 | return RunCommand(cmd); | 112 | cmd.Parameters.AddWithValue("?startX", startX.ToString()); |
122 | } | 113 | cmd.Parameters.AddWithValue("?startY", startY.ToString()); |
114 | cmd.Parameters.AddWithValue("?endX", endX.ToString()); | ||
115 | cmd.Parameters.AddWithValue("?endY", endY.ToString()); | ||
116 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | ||
117 | |||
118 | return RunCommand(cmd); | ||
123 | } | 119 | } |
124 | 120 | ||
125 | public List<RegionData> RunCommand(MySqlCommand cmd) | 121 | public List<RegionData> RunCommand(MySqlCommand cmd) |
126 | { | 122 | { |
127 | List<RegionData> retList = new List<RegionData>(); | 123 | List<RegionData> retList = new List<RegionData>(); |
128 | 124 | ||
129 | using (IDataReader result = ExecuteReader(cmd)) | 125 | IDataReader result = ExecuteReader(cmd); |
126 | |||
127 | while (result.Read()) | ||
130 | { | 128 | { |
131 | while (result.Read()) | 129 | RegionData ret = new RegionData(); |
130 | ret.Data = new Dictionary<string, object>(); | ||
131 | |||
132 | UUID regionID; | ||
133 | UUID.TryParse(result["uuid"].ToString(), out regionID); | ||
134 | ret.RegionID = regionID; | ||
135 | UUID scope; | ||
136 | UUID.TryParse(result["ScopeID"].ToString(), out scope); | ||
137 | ret.ScopeID = scope; | ||
138 | ret.RegionName = result["regionName"].ToString(); | ||
139 | ret.posX = Convert.ToInt32(result["locX"]); | ||
140 | ret.posY = Convert.ToInt32(result["locY"]); | ||
141 | ret.sizeX = Convert.ToInt32(result["sizeX"]); | ||
142 | ret.sizeY = Convert.ToInt32(result["sizeY"]); | ||
143 | |||
144 | if (m_ColumnNames == null) | ||
132 | { | 145 | { |
133 | RegionData ret = new RegionData(); | 146 | m_ColumnNames = new List<string>(); |
134 | ret.Data = new Dictionary<string, object>(); | ||
135 | |||
136 | UUID regionID; | ||
137 | UUID.TryParse(result["uuid"].ToString(), out regionID); | ||
138 | ret.RegionID = regionID; | ||
139 | UUID scope; | ||
140 | UUID.TryParse(result["ScopeID"].ToString(), out scope); | ||
141 | ret.ScopeID = scope; | ||
142 | ret.RegionName = result["regionName"].ToString(); | ||
143 | ret.posX = Convert.ToInt32(result["locX"]); | ||
144 | ret.posY = Convert.ToInt32(result["locY"]); | ||
145 | ret.sizeX = Convert.ToInt32(result["sizeX"]); | ||
146 | ret.sizeY = Convert.ToInt32(result["sizeY"]); | ||
147 | |||
148 | if (m_ColumnNames == null) | ||
149 | { | ||
150 | m_ColumnNames = new List<string>(); | ||
151 | 147 | ||
152 | DataTable schemaTable = result.GetSchemaTable(); | 148 | DataTable schemaTable = result.GetSchemaTable(); |
153 | foreach (DataRow row in schemaTable.Rows) | 149 | foreach (DataRow row in schemaTable.Rows) |
@@ -157,28 +153,28 @@ namespace OpenSim.Data.MySQL | |||
157 | } | 153 | } |
158 | } | 154 | } |
159 | 155 | ||
160 | foreach (string s in m_ColumnNames) | 156 | foreach (string s in m_ColumnNames) |
161 | { | 157 | { |
162 | if (s == "uuid") | 158 | if (s == "uuid") |
163 | continue; | 159 | continue; |
164 | if (s == "ScopeID") | 160 | if (s == "ScopeID") |
165 | continue; | 161 | continue; |
166 | if (s == "regionName") | 162 | if (s == "regionName") |
167 | continue; | 163 | continue; |
168 | if (s == "locX") | 164 | if (s == "locX") |
169 | continue; | 165 | continue; |
170 | if (s == "locY") | 166 | if (s == "locY") |
171 | continue; | 167 | continue; |
172 | 168 | ||
173 | ret.Data[s] = result[s].ToString(); | 169 | ret.Data[s] = result[s].ToString(); |
174 | } | ||
175 | |||
176 | retList.Add(ret); | ||
177 | } | 170 | } |
178 | 171 | ||
179 | CloseDBConnection(result, cmd); | 172 | retList.Add(ret); |
180 | } | 173 | } |
181 | 174 | ||
175 | result.Close(); | ||
176 | CloseReaderCommand(cmd); | ||
177 | |||
182 | return retList; | 178 | return retList; |
183 | } | 179 | } |
184 | 180 | ||
@@ -205,72 +201,76 @@ namespace OpenSim.Data.MySQL | |||
205 | 201 | ||
206 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 202 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
207 | 203 | ||
208 | using (MySqlCommand cmd = new MySqlCommand()) | 204 | MySqlCommand cmd = new MySqlCommand(); |
205 | |||
206 | string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; | ||
207 | foreach (string field in fields) | ||
209 | { | 208 | { |
210 | string update = "update `" + m_Realm + "` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; | 209 | update += ", "; |
211 | foreach (string field in fields) | 210 | update += "`" + field + "` = ?"+field; |
212 | { | ||
213 | update += ", "; | ||
214 | update += "`" + field + "` = ?" + field; | ||
215 | 211 | ||
216 | cmd.Parameters.AddWithValue("?" + field, data.Data[field]); | 212 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); |
217 | } | 213 | } |
218 | 214 | ||
219 | update += " where uuid = ?regionID"; | 215 | update += " where uuid = ?regionID"; |
220 | 216 | ||
221 | if (data.ScopeID != UUID.Zero) | 217 | if (data.ScopeID != UUID.Zero) |
222 | update += " and ScopeID = ?scopeID"; | 218 | update += " and ScopeID = ?scopeID"; |
223 | 219 | ||
224 | cmd.CommandText = update; | 220 | cmd.CommandText = update; |
225 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); | 221 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); |
226 | cmd.Parameters.AddWithValue("?regionName", data.RegionName); | 222 | cmd.Parameters.AddWithValue("?regionName", data.RegionName); |
227 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | 223 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); |
228 | cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); | 224 | cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); |
229 | cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); | 225 | cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); |
230 | cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); | 226 | cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); |
231 | cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); | 227 | cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); |
232 | 228 | ||
233 | if (ExecuteNonQuery(cmd) < 1) | 229 | if (ExecuteNonQuery(cmd) < 1) |
234 | { | 230 | { |
235 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + | 231 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + |
236 | String.Join("`, `", fields) + | 232 | String.Join("`, `", fields) + |
237 | "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; | 233 | "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; |
238 | 234 | ||
239 | cmd.CommandText = insert; | 235 | cmd.CommandText = insert; |
240 | 236 | ||
241 | if (ExecuteNonQuery(cmd) < 1) | 237 | if (ExecuteNonQuery(cmd) < 1) |
242 | { | 238 | { |
243 | return false; | 239 | cmd.Dispose(); |
244 | } | 240 | return false; |
245 | } | 241 | } |
246 | } | 242 | } |
247 | 243 | ||
244 | cmd.Dispose(); | ||
245 | |||
248 | return true; | 246 | return true; |
249 | } | 247 | } |
250 | 248 | ||
251 | public bool SetDataItem(UUID regionID, string item, string value) | 249 | public bool SetDataItem(UUID regionID, string item, string value) |
252 | { | 250 | { |
253 | using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where uuid = ?UUID")) | 251 | MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + |
254 | { | 252 | "` set `" + item + "` = ?" + item + " where uuid = ?UUID"); |
255 | cmd.Parameters.AddWithValue("?" + item, value); | ||
256 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
257 | 253 | ||
258 | if (ExecuteNonQuery(cmd) > 0) | 254 | |
259 | return true; | 255 | cmd.Parameters.AddWithValue("?"+item, value); |
260 | } | 256 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); |
257 | |||
258 | if (ExecuteNonQuery(cmd) > 0) | ||
259 | return true; | ||
261 | 260 | ||
262 | return false; | 261 | return false; |
263 | } | 262 | } |
264 | 263 | ||
265 | public bool Delete(UUID regionID) | 264 | public bool Delete(UUID regionID) |
266 | { | 265 | { |
267 | using (MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + "` where uuid = ?UUID")) | 266 | MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + |
268 | { | 267 | "` where uuid = ?UUID"); |
269 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | ||
270 | 268 | ||
271 | if (ExecuteNonQuery(cmd) > 0) | 269 | |
272 | return true; | 270 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); |
273 | } | 271 | |
272 | if (ExecuteNonQuery(cmd) > 0) | ||
273 | return true; | ||
274 | 274 | ||
275 | return false; | 275 | return false; |
276 | } | 276 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 0bbc3f5..d48144d 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs | |||
@@ -97,14 +97,16 @@ namespace OpenSim.Data.MySQL | |||
97 | ret.Data[s] = result[s].ToString(); | 97 | ret.Data[s] = result[s].ToString(); |
98 | } | 98 | } |
99 | 99 | ||
100 | CloseDBConnection(result, cmd); | 100 | result.Close(); |
101 | CloseReaderCommand(cmd); | ||
102 | |||
101 | return ret; | 103 | return ret; |
102 | } | 104 | } |
103 | else | 105 | |
104 | { | 106 | result.Close(); |
105 | CloseDBConnection(result, cmd); | 107 | CloseReaderCommand(cmd); |
106 | return null; | 108 | |
107 | } | 109 | return null; |
108 | } | 110 | } |
109 | 111 | ||
110 | public bool Store(UserAccountData data) | 112 | public bool Store(UserAccountData data) |
@@ -116,60 +118,61 @@ namespace OpenSim.Data.MySQL | |||
116 | 118 | ||
117 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 119 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
118 | 120 | ||
119 | using (MySqlCommand cmd = new MySqlCommand()) | 121 | MySqlCommand cmd = new MySqlCommand(); |
122 | |||
123 | string update = "update `"+m_Realm+"` set "; | ||
124 | bool first = true; | ||
125 | foreach (string field in fields) | ||
120 | { | 126 | { |
121 | string update = "update `" + m_Realm + "` set "; | 127 | if (!first) |
122 | bool first = true; | 128 | update += ", "; |
123 | foreach (string field in fields) | 129 | update += "`" + field + "` = ?"+field; |
124 | { | ||
125 | if (!first) | ||
126 | update += ", "; | ||
127 | update += "`" + field + "` = ?" + field; | ||
128 | 130 | ||
129 | first = false; | 131 | first = false; |
130 | 132 | ||
131 | cmd.Parameters.AddWithValue("?" + field, data.Data[field]); | 133 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); |
132 | } | 134 | } |
133 | 135 | ||
134 | update += " where UUID = ?principalID"; | 136 | update += " where UUID = ?principalID"; |
135 | 137 | ||
136 | if (data.ScopeID != UUID.Zero) | 138 | if (data.ScopeID != UUID.Zero) |
137 | update += " and ScopeID = ?scopeID"; | 139 | update += " and ScopeID = ?scopeID"; |
138 | 140 | ||
139 | cmd.CommandText = update; | 141 | cmd.CommandText = update; |
140 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); | 142 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); |
141 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | 143 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); |
142 | 144 | ||
143 | if (ExecuteNonQuery(cmd) < 1) | 145 | if (ExecuteNonQuery(cmd) < 1) |
144 | { | 146 | { |
145 | string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + | 147 | string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + |
146 | String.Join("`, `", fields) + | 148 | String.Join("`, `", fields) + |
147 | "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; | 149 | "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; |
148 | 150 | ||
149 | cmd.CommandText = insert; | 151 | cmd.CommandText = insert; |
150 | 152 | ||
151 | if (ExecuteNonQuery(cmd) < 1) | 153 | if (ExecuteNonQuery(cmd) < 1) |
152 | { | 154 | { |
153 | cmd.Dispose(); | 155 | cmd.Dispose(); |
154 | return false; | 156 | return false; |
155 | } | ||
156 | } | 157 | } |
157 | } | 158 | } |
158 | 159 | ||
160 | cmd.Dispose(); | ||
161 | |||
159 | return true; | 162 | return true; |
160 | } | 163 | } |
161 | 164 | ||
162 | public bool SetDataItem(UUID principalID, string item, string value) | 165 | public bool SetDataItem(UUID principalID, string item, string value) |
163 | { | 166 | { |
164 | using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + | 167 | MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + |
165 | item + "` = ?" + item + " where UUID = ?UUID")) | 168 | "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); |
166 | { | ||
167 | cmd.Parameters.AddWithValue("?" + item, value); | ||
168 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); | ||
169 | 169 | ||
170 | if (ExecuteNonQuery(cmd) > 0) | 170 | |
171 | return true; | 171 | cmd.Parameters.AddWithValue("?"+item, value); |
172 | } | 172 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); |
173 | |||
174 | if (ExecuteNonQuery(cmd) > 0) | ||
175 | return true; | ||
173 | 176 | ||
174 | return false; | 177 | return false; |
175 | } | 178 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index bd46dfc..04f872f 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs | |||
@@ -181,20 +181,21 @@ namespace OpenSim.Data.MySQL | |||
181 | param["?first"] = user; | 181 | param["?first"] = user; |
182 | param["?second"] = last; | 182 | param["?second"] = last; |
183 | 183 | ||
184 | using (IDbCommand result = dbm.Manager.Query( | 184 | IDbCommand result = |
185 | "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param)) | 185 | dbm.Manager.Query( |
186 | { | 186 | "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); |
187 | using (IDataReader reader = result.ExecuteReader()) | 187 | IDataReader reader = result.ExecuteReader(); |
188 | { | 188 | |
189 | UserProfileData row = dbm.Manager.readUserRow(reader); | 189 | UserProfileData row = dbm.Manager.readUserRow(reader); |
190 | return row; | 190 | |
191 | } | 191 | reader.Dispose(); |
192 | } | 192 | result.Dispose(); |
193 | return row; | ||
193 | } | 194 | } |
194 | catch (Exception e) | 195 | catch (Exception e) |
195 | { | 196 | { |
196 | dbm.Manager.Reconnect(); | 197 | dbm.Manager.Reconnect(); |
197 | m_log.Error(e.Message, e); | 198 | m_log.Error(e.ToString()); |
198 | return null; | 199 | return null; |
199 | } | 200 | } |
200 | finally | 201 | finally |
@@ -219,30 +220,28 @@ namespace OpenSim.Data.MySQL | |||
219 | 220 | ||
220 | try | 221 | try |
221 | { | 222 | { |
222 | using (IDbCommand adder = dbm.Manager.Query( | 223 | IDbCommand adder = |
223 | "INSERT INTO `" + m_userFriendsTableName + "` " + | 224 | dbm.Manager.Query( |
224 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | 225 | "INSERT INTO `" + m_userFriendsTableName + "` " + |
225 | "VALUES " + | 226 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + |
226 | "(?ownerID,?friendID,?friendPerms,?datetimestamp)", | 227 | "VALUES " + |
227 | param)) | 228 | "(?ownerID,?friendID,?friendPerms,?datetimestamp)", |
228 | { | 229 | param); |
229 | adder.ExecuteNonQuery(); | 230 | adder.ExecuteNonQuery(); |
230 | } | 231 | |
231 | 232 | adder = | |
232 | using (IDbCommand adder = dbm.Manager.Query( | 233 | dbm.Manager.Query( |
233 | "INSERT INTO `" + m_userFriendsTableName + "` " + | 234 | "INSERT INTO `" + m_userFriendsTableName + "` " + |
234 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | 235 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + |
235 | "VALUES " + | 236 | "VALUES " + |
236 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", | 237 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", |
237 | param)) | 238 | param); |
238 | { | 239 | adder.ExecuteNonQuery(); |
239 | adder.ExecuteNonQuery(); | ||
240 | } | ||
241 | } | 240 | } |
242 | catch (Exception e) | 241 | catch (Exception e) |
243 | { | 242 | { |
244 | dbm.Manager.Reconnect(); | 243 | dbm.Manager.Reconnect(); |
245 | m_log.Error(e.Message, e); | 244 | m_log.Error(e.ToString()); |
246 | return; | 245 | return; |
247 | } | 246 | } |
248 | finally | 247 | finally |
@@ -261,24 +260,22 @@ namespace OpenSim.Data.MySQL | |||
261 | 260 | ||
262 | try | 261 | try |
263 | { | 262 | { |
264 | using (IDbCommand updater = dbm.Manager.Query( | 263 | IDbCommand updater = |
264 | dbm.Manager.Query( | ||
265 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", | 265 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", |
266 | param)) | 266 | param); |
267 | { | 267 | updater.ExecuteNonQuery(); |
268 | updater.ExecuteNonQuery(); | ||
269 | } | ||
270 | 268 | ||
271 | using (IDbCommand updater = dbm.Manager.Query( | 269 | updater = |
270 | dbm.Manager.Query( | ||
272 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", | 271 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", |
273 | param)) | 272 | param); |
274 | { | 273 | updater.ExecuteNonQuery(); |
275 | updater.ExecuteNonQuery(); | ||
276 | } | ||
277 | } | 274 | } |
278 | catch (Exception e) | 275 | catch (Exception e) |
279 | { | 276 | { |
280 | dbm.Manager.Reconnect(); | 277 | dbm.Manager.Reconnect(); |
281 | m_log.Error(e.Message, e); | 278 | m_log.Error(e.ToString()); |
282 | return; | 279 | return; |
283 | } | 280 | } |
284 | finally | 281 | finally |
@@ -298,19 +295,18 @@ namespace OpenSim.Data.MySQL | |||
298 | 295 | ||
299 | try | 296 | try |
300 | { | 297 | { |
301 | using (IDbCommand updater = dbm.Manager.Query( | 298 | IDbCommand updater = |
299 | dbm.Manager.Query( | ||
302 | "update " + m_userFriendsTableName + | 300 | "update " + m_userFriendsTableName + |
303 | " SET friendPerms = ?friendPerms " + | 301 | " SET friendPerms = ?friendPerms " + |
304 | "where ownerID = ?ownerID and friendID = ?friendID", | 302 | "where ownerID = ?ownerID and friendID = ?friendID", |
305 | param)) | 303 | param); |
306 | { | 304 | updater.ExecuteNonQuery(); |
307 | updater.ExecuteNonQuery(); | ||
308 | } | ||
309 | } | 305 | } |
310 | catch (Exception e) | 306 | catch (Exception e) |
311 | { | 307 | { |
312 | dbm.Manager.Reconnect(); | 308 | dbm.Manager.Reconnect(); |
313 | m_log.Error(e.Message, e); | 309 | m_log.Error(e.ToString()); |
314 | return; | 310 | return; |
315 | } | 311 | } |
316 | finally | 312 | finally |
@@ -331,33 +327,34 @@ namespace OpenSim.Data.MySQL | |||
331 | try | 327 | try |
332 | { | 328 | { |
333 | //Left Join userfriends to itself | 329 | //Left Join userfriends to itself |
334 | using (IDbCommand result = dbm.Manager.Query( | 330 | IDbCommand result = |
335 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + | 331 | dbm.Manager.Query( |
336 | m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + | 332 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + |
337 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", | 333 | m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + |
338 | param)) | 334 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", |
335 | param); | ||
336 | IDataReader reader = result.ExecuteReader(); | ||
337 | |||
338 | while (reader.Read()) | ||
339 | { | 339 | { |
340 | using (IDataReader reader = result.ExecuteReader()) | 340 | FriendListItem fli = new FriendListItem(); |
341 | { | 341 | fli.FriendListOwner = new UUID((string) reader["ownerID"]); |
342 | while (reader.Read()) | 342 | fli.Friend = new UUID((string) reader["friendID"]); |
343 | { | 343 | fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]); |
344 | FriendListItem fli = new FriendListItem(); | 344 | |
345 | fli.FriendListOwner = new UUID((string)reader["ownerID"]); | 345 | // This is not a real column in the database table, it's a joined column from the opposite record |
346 | fli.Friend = new UUID((string)reader["friendID"]); | 346 | fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]); |
347 | fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); | 347 | |
348 | 348 | Lfli.Add(fli); | |
349 | // This is not a real column in the database table, it's a joined column from the opposite record | ||
350 | fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); | ||
351 | |||
352 | Lfli.Add(fli); | ||
353 | } | ||
354 | } | ||
355 | } | 349 | } |
350 | |||
351 | reader.Dispose(); | ||
352 | result.Dispose(); | ||
356 | } | 353 | } |
357 | catch (Exception e) | 354 | catch (Exception e) |
358 | { | 355 | { |
359 | dbm.Manager.Reconnect(); | 356 | dbm.Manager.Reconnect(); |
360 | m_log.Error(e.Message, e); | 357 | m_log.Error(e.ToString()); |
361 | return Lfli; | 358 | return Lfli; |
362 | } | 359 | } |
363 | finally | 360 | finally |
@@ -379,29 +376,29 @@ namespace OpenSim.Data.MySQL | |||
379 | { | 376 | { |
380 | Dictionary<string, object> param = new Dictionary<string, object>(); | 377 | Dictionary<string, object> param = new Dictionary<string, object>(); |
381 | param["?uuid"] = uuid.ToString(); | 378 | param["?uuid"] = uuid.ToString(); |
379 | IDbCommand result = | ||
380 | dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + | ||
381 | " where UUID = ?uuid", param); | ||
382 | 382 | ||
383 | using (IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + | 383 | IDataReader reader = result.ExecuteReader(); |
384 | " where UUID = ?uuid", param)) | 384 | while (reader.Read()) |
385 | { | 385 | { |
386 | using (IDataReader reader = result.ExecuteReader()) | 386 | FriendRegionInfo fri = new FriendRegionInfo(); |
387 | { | 387 | fri.isOnline = (sbyte)reader["agentOnline"] != 0; |
388 | while (reader.Read()) | 388 | fri.regionHandle = (ulong)reader["currentHandle"]; |
389 | { | 389 | |
390 | FriendRegionInfo fri = new FriendRegionInfo(); | 390 | infos[uuid] = fri; |
391 | fri.isOnline = (sbyte)reader["agentOnline"] != 0; | ||
392 | fri.regionHandle = (ulong)reader["currentHandle"]; | ||
393 | |||
394 | infos[uuid] = fri; | ||
395 | } | ||
396 | } | ||
397 | } | 391 | } |
392 | |||
393 | reader.Dispose(); | ||
394 | result.Dispose(); | ||
398 | } | 395 | } |
399 | } | 396 | } |
400 | catch (Exception e) | 397 | catch (Exception e) |
401 | { | 398 | { |
402 | m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); | 399 | m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); |
403 | dbm.Manager.Reconnect(); | 400 | dbm.Manager.Reconnect(); |
404 | m_log.Error(e.Message, e); | 401 | m_log.Error(e.ToString()); |
405 | } | 402 | } |
406 | finally | 403 | finally |
407 | { | 404 | { |
@@ -430,28 +427,28 @@ namespace OpenSim.Data.MySQL | |||
430 | 427 | ||
431 | try | 428 | try |
432 | { | 429 | { |
433 | using (IDbCommand result = dbm.Manager.Query( | 430 | IDbCommand result = |
434 | "SELECT UUID,username,lastname FROM " + m_usersTableName + | 431 | dbm.Manager.Query( |
435 | " WHERE username like ?first AND lastname like ?second LIMIT 100", | 432 | "SELECT UUID,username,lastname FROM " + m_usersTableName + |
436 | param)) | 433 | " WHERE username like ?first AND lastname like ?second LIMIT 100", |
434 | param); | ||
435 | IDataReader reader = result.ExecuteReader(); | ||
436 | |||
437 | while (reader.Read()) | ||
437 | { | 438 | { |
438 | using (IDataReader reader = result.ExecuteReader()) | 439 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
439 | { | 440 | user.AvatarID = new UUID((string) reader["UUID"]); |
440 | while (reader.Read()) | 441 | user.firstName = (string) reader["username"]; |
441 | { | 442 | user.lastName = (string) reader["lastname"]; |
442 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 443 | returnlist.Add(user); |
443 | user.AvatarID = new UUID((string)reader["UUID"]); | ||
444 | user.firstName = (string)reader["username"]; | ||
445 | user.lastName = (string)reader["lastname"]; | ||
446 | returnlist.Add(user); | ||
447 | } | ||
448 | } | ||
449 | } | 444 | } |
445 | reader.Dispose(); | ||
446 | result.Dispose(); | ||
450 | } | 447 | } |
451 | catch (Exception e) | 448 | catch (Exception e) |
452 | { | 449 | { |
453 | dbm.Manager.Reconnect(); | 450 | dbm.Manager.Reconnect(); |
454 | m_log.Error(e.Message, e); | 451 | m_log.Error(e.ToString()); |
455 | return returnlist; | 452 | return returnlist; |
456 | } | 453 | } |
457 | finally | 454 | finally |
@@ -468,28 +465,28 @@ namespace OpenSim.Data.MySQL | |||
468 | Dictionary<string, object> param = new Dictionary<string, object>(); | 465 | Dictionary<string, object> param = new Dictionary<string, object>(); |
469 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; | 466 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; |
470 | 467 | ||
471 | using (IDbCommand result = dbm.Manager.Query( | 468 | IDbCommand result = |
472 | "SELECT UUID,username,lastname FROM " + m_usersTableName + | 469 | dbm.Manager.Query( |
473 | " WHERE username like ?first OR lastname like ?first LIMIT 100", | 470 | "SELECT UUID,username,lastname FROM " + m_usersTableName + |
474 | param)) | 471 | " WHERE username like ?first OR lastname like ?first LIMIT 100", |
472 | param); | ||
473 | IDataReader reader = result.ExecuteReader(); | ||
474 | |||
475 | while (reader.Read()) | ||
475 | { | 476 | { |
476 | using (IDataReader reader = result.ExecuteReader()) | 477 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
477 | { | 478 | user.AvatarID = new UUID((string) reader["UUID"]); |
478 | while (reader.Read()) | 479 | user.firstName = (string) reader["username"]; |
479 | { | 480 | user.lastName = (string) reader["lastname"]; |
480 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 481 | returnlist.Add(user); |
481 | user.AvatarID = new UUID((string)reader["UUID"]); | ||
482 | user.firstName = (string)reader["username"]; | ||
483 | user.lastName = (string)reader["lastname"]; | ||
484 | returnlist.Add(user); | ||
485 | } | ||
486 | } | ||
487 | } | 482 | } |
483 | reader.Dispose(); | ||
484 | result.Dispose(); | ||
488 | } | 485 | } |
489 | catch (Exception e) | 486 | catch (Exception e) |
490 | { | 487 | { |
491 | dbm.Manager.Reconnect(); | 488 | dbm.Manager.Reconnect(); |
492 | m_log.Error(e.Message, e); | 489 | m_log.Error(e.ToString()); |
493 | return returnlist; | 490 | return returnlist; |
494 | } | 491 | } |
495 | finally | 492 | finally |
@@ -513,19 +510,20 @@ namespace OpenSim.Data.MySQL | |||
513 | Dictionary<string, object> param = new Dictionary<string, object>(); | 510 | Dictionary<string, object> param = new Dictionary<string, object>(); |
514 | param["?uuid"] = uuid.ToString(); | 511 | param["?uuid"] = uuid.ToString(); |
515 | 512 | ||
516 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param)) | 513 | IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); |
517 | { | 514 | IDataReader reader = result.ExecuteReader(); |
518 | using (IDataReader reader = result.ExecuteReader()) | 515 | |
519 | { | 516 | UserProfileData row = dbm.Manager.readUserRow(reader); |
520 | UserProfileData row = dbm.Manager.readUserRow(reader); | 517 | |
521 | return row; | 518 | reader.Dispose(); |
522 | } | 519 | result.Dispose(); |
523 | } | 520 | |
521 | return row; | ||
524 | } | 522 | } |
525 | catch (Exception e) | 523 | catch (Exception e) |
526 | { | 524 | { |
527 | dbm.Manager.Reconnect(); | 525 | dbm.Manager.Reconnect(); |
528 | m_log.Error(e.Message, e); | 526 | m_log.Error(e.ToString()); |
529 | return null; | 527 | return null; |
530 | } | 528 | } |
531 | finally | 529 | finally |
@@ -571,15 +569,15 @@ namespace OpenSim.Data.MySQL | |||
571 | 569 | ||
572 | try | 570 | try |
573 | { | 571 | { |
574 | dbm.Manager.ExecuteParameterizedSql( | 572 | dbm.Manager.ExecuteParameterizedSql( |
575 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + | 573 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + |
576 | "where UUID = ?UUID", | 574 | "where UUID = ?UUID", |
577 | param); | 575 | param); |
578 | } | 576 | } |
579 | catch (Exception e) | 577 | catch (Exception e) |
580 | { | 578 | { |
581 | dbm.Manager.Reconnect(); | 579 | dbm.Manager.Reconnect(); |
582 | m_log.Error(e.Message, e); | 580 | m_log.Error(e.ToString()); |
583 | return; | 581 | return; |
584 | } | 582 | } |
585 | finally | 583 | finally |
@@ -602,19 +600,21 @@ namespace OpenSim.Data.MySQL | |||
602 | Dictionary<string, object> param = new Dictionary<string, object>(); | 600 | Dictionary<string, object> param = new Dictionary<string, object>(); |
603 | param["?uuid"] = uuid.ToString(); | 601 | param["?uuid"] = uuid.ToString(); |
604 | 602 | ||
605 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param)) | 603 | IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", |
606 | { | 604 | param); |
607 | using (IDataReader reader = result.ExecuteReader()) | 605 | IDataReader reader = result.ExecuteReader(); |
608 | { | 606 | |
609 | UserAgentData row = dbm.Manager.readAgentRow(reader); | 607 | UserAgentData row = dbm.Manager.readAgentRow(reader); |
610 | return row; | 608 | |
611 | } | 609 | reader.Dispose(); |
612 | } | 610 | result.Dispose(); |
611 | |||
612 | return row; | ||
613 | } | 613 | } |
614 | catch (Exception e) | 614 | catch (Exception e) |
615 | { | 615 | { |
616 | dbm.Manager.Reconnect(); | 616 | dbm.Manager.Reconnect(); |
617 | m_log.Error(e.Message, e); | 617 | m_log.Error(e.ToString()); |
618 | return null; | 618 | return null; |
619 | } | 619 | } |
620 | finally | 620 | finally |
@@ -638,20 +638,19 @@ namespace OpenSim.Data.MySQL | |||
638 | 638 | ||
639 | try | 639 | try |
640 | { | 640 | { |
641 | dbm.Manager.insertUserRow( | 641 | dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, |
642 | user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, | 642 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, |
643 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, | 643 | user.HomeLocation.Z, |
644 | user.HomeLocation.Z, | 644 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, |
645 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, | 645 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, |
646 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, | 646 | user.CanDoMask, user.WantDoMask, |
647 | user.CanDoMask, user.WantDoMask, | 647 | user.AboutText, user.FirstLifeAboutText, user.Image, |
648 | user.AboutText, user.FirstLifeAboutText, user.Image, | 648 | user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); |
649 | user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | ||
650 | } | 649 | } |
651 | catch (Exception e) | 650 | catch (Exception e) |
652 | { | 651 | { |
653 | dbm.Manager.Reconnect(); | 652 | dbm.Manager.Reconnect(); |
654 | m_log.Error(e.Message, e); | 653 | m_log.Error(e.ToString()); |
655 | } | 654 | } |
656 | finally | 655 | finally |
657 | { | 656 | { |
@@ -677,7 +676,7 @@ namespace OpenSim.Data.MySQL | |||
677 | catch (Exception e) | 676 | catch (Exception e) |
678 | { | 677 | { |
679 | dbm.Manager.Reconnect(); | 678 | dbm.Manager.Reconnect(); |
680 | m_log.Error(e.Message, e); | 679 | m_log.Error(e.ToString()); |
681 | } | 680 | } |
682 | finally | 681 | finally |
683 | { | 682 | { |
@@ -694,15 +693,14 @@ namespace OpenSim.Data.MySQL | |||
694 | MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); | 693 | MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); |
695 | try | 694 | try |
696 | { | 695 | { |
697 | dbm.Manager.updateUserRow( | 696 | dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, |
698 | user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, | 697 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, |
699 | user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, | 698 | user.HomeLocation.Z, user.HomeLookAt.X, |
700 | user.HomeLocation.Z, user.HomeLookAt.X, | 699 | user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, |
701 | user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, | 700 | user.UserInventoryURI, |
702 | user.UserInventoryURI, | 701 | user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, |
703 | user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, | 702 | user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, |
704 | user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, | 703 | user.UserFlags, user.GodLevel, user.CustomType, user.Partner); |
705 | user.UserFlags, user.GodLevel, user.CustomType, user.Partner); | ||
706 | } | 704 | } |
707 | finally | 705 | finally |
708 | { | 706 | { |
@@ -750,29 +748,29 @@ namespace OpenSim.Data.MySQL | |||
750 | Dictionary<string, object> param = new Dictionary<string, object>(); | 748 | Dictionary<string, object> param = new Dictionary<string, object>(); |
751 | param["?owner"] = user.ToString(); | 749 | param["?owner"] = user.ToString(); |
752 | 750 | ||
753 | using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param)) | 751 | IDbCommand result = dbm.Manager.Query( |
752 | "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); | ||
753 | IDataReader reader = result.ExecuteReader(); | ||
754 | |||
755 | AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); | ||
756 | |||
757 | reader.Dispose(); | ||
758 | result.Dispose(); | ||
759 | |||
760 | if (null == appearance) | ||
754 | { | 761 | { |
755 | using (IDataReader reader = result.ExecuteReader()) | 762 | m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); |
756 | { | 763 | return null; |
757 | AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); | ||
758 | |||
759 | if (appearance == null) | ||
760 | { | ||
761 | m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); | ||
762 | return null; | ||
763 | } | ||
764 | else | ||
765 | { | ||
766 | appearance.SetAttachments(GetUserAttachments(user)); | ||
767 | return appearance; | ||
768 | } | ||
769 | } | ||
770 | } | 764 | } |
765 | |||
766 | appearance.SetAttachments(GetUserAttachments(user)); | ||
767 | |||
768 | return appearance; | ||
771 | } | 769 | } |
772 | catch (Exception e) | 770 | catch (Exception e) |
773 | { | 771 | { |
774 | dbm.Manager.Reconnect(); | 772 | dbm.Manager.Reconnect(); |
775 | m_log.Error(e.Message, e); | 773 | m_log.Error(e.ToString()); |
776 | return null; | 774 | return null; |
777 | } | 775 | } |
778 | finally | 776 | finally |
@@ -800,7 +798,7 @@ namespace OpenSim.Data.MySQL | |||
800 | catch (Exception e) | 798 | catch (Exception e) |
801 | { | 799 | { |
802 | dbm.Manager.Reconnect(); | 800 | dbm.Manager.Reconnect(); |
803 | m_log.Error(e.Message, e); | 801 | m_log.Error(e.ToString()); |
804 | } | 802 | } |
805 | finally | 803 | finally |
806 | { | 804 | { |
@@ -835,20 +833,20 @@ namespace OpenSim.Data.MySQL | |||
835 | 833 | ||
836 | try | 834 | try |
837 | { | 835 | { |
838 | using (IDbCommand result = dbm.Manager.Query( | 836 | IDbCommand result = dbm.Manager.Query( |
839 | "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param)) | 837 | "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param); |
840 | { | 838 | IDataReader reader = result.ExecuteReader(); |
841 | using (IDataReader reader = result.ExecuteReader()) | 839 | |
842 | { | 840 | Hashtable ret = dbm.Manager.readAttachments(reader); |
843 | Hashtable ret = dbm.Manager.readAttachments(reader); | 841 | |
844 | return ret; | 842 | reader.Dispose(); |
845 | } | 843 | result.Dispose(); |
846 | } | 844 | return ret; |
847 | } | 845 | } |
848 | catch (Exception e) | 846 | catch (Exception e) |
849 | { | 847 | { |
850 | dbm.Manager.Reconnect(); | 848 | dbm.Manager.Reconnect(); |
851 | m_log.Error(e.Message, e); | 849 | m_log.Error(e.ToString()); |
852 | return null; | 850 | return null; |
853 | } | 851 | } |
854 | finally | 852 | finally |
@@ -907,7 +905,7 @@ namespace OpenSim.Data.MySQL | |||
907 | catch (Exception e) | 905 | catch (Exception e) |
908 | { | 906 | { |
909 | dbm.Manager.Reconnect(); | 907 | dbm.Manager.Reconnect(); |
910 | m_log.Error(e.Message, e); | 908 | m_log.Error(e.ToString()); |
911 | return; | 909 | return; |
912 | } | 910 | } |
913 | finally | 911 | finally |
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 49275cb..23642b3 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -162,22 +162,22 @@ namespace OpenSim.Data.SQLite | |||
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | /// <summary> | 165 | // /// <summary> |
166 | /// Some... logging functionnality | 166 | // /// Some... logging functionnality |
167 | /// </summary> | 167 | // /// </summary> |
168 | /// <param name="asset"></param> | 168 | // /// <param name="asset"></param> |
169 | private static void LogAssetLoad(AssetBase asset) | 169 | // private static void LogAssetLoad(AssetBase asset) |
170 | { | 170 | // { |
171 | string temporary = asset.Temporary ? "Temporary" : "Stored"; | 171 | // string temporary = asset.Temporary ? "Temporary" : "Stored"; |
172 | string local = asset.Local ? "Local" : "Remote"; | 172 | // string local = asset.Local ? "Local" : "Remote"; |
173 | 173 | // | |
174 | int assetLength = (asset.Data != null) ? asset.Data.Length : 0; | 174 | // int assetLength = (asset.Data != null) ? asset.Data.Length : 0; |
175 | 175 | // | |
176 | m_log.Debug("[ASSET DB]: " + | 176 | // m_log.Debug("[ASSET DB]: " + |
177 | string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)", | 177 | // string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)", |
178 | asset.FullID, asset.Name, asset.Description, asset.Type, | 178 | // asset.FullID, asset.Name, asset.Description, asset.Type, |
179 | temporary, local, assetLength)); | 179 | // temporary, local, assetLength)); |
180 | } | 180 | // } |
181 | 181 | ||
182 | /// <summary> | 182 | /// <summary> |
183 | /// Check if an asset exist in database | 183 | /// Check if an asset exist in database |
@@ -231,12 +231,13 @@ namespace OpenSim.Data.SQLite | |||
231 | // TODO: this doesn't work yet because something more | 231 | // TODO: this doesn't work yet because something more |
232 | // interesting has to be done to actually get these values | 232 | // interesting has to be done to actually get these values |
233 | // back out. Not enough time to figure it out yet. | 233 | // back out. Not enough time to figure it out yet. |
234 | AssetBase asset = new AssetBase(); | 234 | AssetBase asset = new AssetBase( |
235 | new UUID((String)row["UUID"]), | ||
236 | (String)row["Name"], | ||
237 | Convert.ToSByte(row["Type"]) | ||
238 | ); | ||
235 | 239 | ||
236 | asset.FullID = new UUID((String) row["UUID"]); | ||
237 | asset.Name = (String) row["Name"]; | ||
238 | asset.Description = (String) row["Description"]; | 240 | asset.Description = (String) row["Description"]; |
239 | asset.Type = Convert.ToSByte(row["Type"]); | ||
240 | asset.Local = Convert.ToBoolean(row["Local"]); | 241 | asset.Local = Convert.ToBoolean(row["Local"]); |
241 | asset.Temporary = Convert.ToBoolean(row["Temporary"]); | 242 | asset.Temporary = Convert.ToBoolean(row["Temporary"]); |
242 | asset.Data = (byte[]) row["Data"]; | 243 | asset.Data = (byte[]) row["Data"]; |
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 08af7c3..b68de1a 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs | |||
@@ -1213,7 +1213,7 @@ namespace OpenSim.Data.SQLite | |||
1213 | if (!row.IsNull("ParticleSystem")) | 1213 | if (!row.IsNull("ParticleSystem")) |
1214 | prim.ParticleSystem = Convert.FromBase64String(row["ParticleSystem"].ToString()); | 1214 | prim.ParticleSystem = Convert.FromBase64String(row["ParticleSystem"].ToString()); |
1215 | 1215 | ||
1216 | prim.RotationalVelocity = new Vector3( | 1216 | prim.AngularVelocity = new Vector3( |
1217 | Convert.ToSingle(row["OmegaX"]), | 1217 | Convert.ToSingle(row["OmegaX"]), |
1218 | Convert.ToSingle(row["OmegaY"]), | 1218 | Convert.ToSingle(row["OmegaY"]), |
1219 | Convert.ToSingle(row["OmegaZ"]) | 1219 | Convert.ToSingle(row["OmegaZ"]) |
@@ -1530,9 +1530,9 @@ namespace OpenSim.Data.SQLite | |||
1530 | row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation); | 1530 | row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation); |
1531 | row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem); | 1531 | row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem); |
1532 | 1532 | ||
1533 | row["OmegaX"] = prim.RotationalVelocity.X; | 1533 | row["OmegaX"] = prim.AngularVelocity.X; |
1534 | row["OmegaY"] = prim.RotationalVelocity.Y; | 1534 | row["OmegaY"] = prim.AngularVelocity.Y; |
1535 | row["OmegaZ"] = prim.RotationalVelocity.Z; | 1535 | row["OmegaZ"] = prim.AngularVelocity.Z; |
1536 | 1536 | ||
1537 | row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; | 1537 | row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; |
1538 | row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y; | 1538 | row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y; |
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index 1969d76..25aed61 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs | |||
@@ -66,9 +66,9 @@ namespace OpenSim.Data.Tests | |||
66 | [Test] | 66 | [Test] |
67 | public void T010_StoreSimpleAsset() | 67 | public void T010_StoreSimpleAsset() |
68 | { | 68 | { |
69 | AssetBase a1 = new AssetBase(uuid1, "asset one"); | 69 | AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
70 | AssetBase a2 = new AssetBase(uuid2, "asset two"); | 70 | AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture); |
71 | AssetBase a3 = new AssetBase(uuid3, "asset three"); | 71 | AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture); |
72 | a1.Data = asset1; | 72 | a1.Data = asset1; |
73 | a2.Data = asset1; | 73 | a2.Data = asset1; |
74 | a3.Data = asset1; | 74 | a3.Data = asset1; |
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs index 60a8874..f76962c 100644 --- a/OpenSim/Data/Tests/BasicRegionTest.cs +++ b/OpenSim/Data/Tests/BasicRegionTest.cs | |||
@@ -252,7 +252,7 @@ namespace OpenSim.Data.Tests | |||
252 | regionInfo.RegionLocX = 0; | 252 | regionInfo.RegionLocX = 0; |
253 | regionInfo.RegionLocY = 0; | 253 | regionInfo.RegionLocY = 0; |
254 | 254 | ||
255 | Scene scene = new Scene(regionInfo); | 255 | // Scene scene = new Scene(regionInfo); |
256 | 256 | ||
257 | SceneObjectPart sop = new SceneObjectPart(); | 257 | SceneObjectPart sop = new SceneObjectPart(); |
258 | sop.RegionHandle = regionh; | 258 | sop.RegionHandle = regionh; |
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs index 06ca53e..5b1f935 100644 --- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs +++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs | |||
@@ -297,8 +297,8 @@ namespace OpenSim.Data.Tests | |||
297 | public void AssetShouldMatch() | 297 | public void AssetShouldMatch() |
298 | { | 298 | { |
299 | UUID uuid1 = UUID.Random(); | 299 | UUID uuid1 = UUID.Random(); |
300 | AssetBase actual = new AssetBase(uuid1, "asset one"); | 300 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
301 | AssetBase expected = new AssetBase(uuid1, "asset one"); | 301 | AssetBase expected = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
302 | 302 | ||
303 | var constraint = Constraints.PropertyCompareConstraint(expected); | 303 | var constraint = Constraints.PropertyCompareConstraint(expected); |
304 | 304 | ||
@@ -309,8 +309,8 @@ namespace OpenSim.Data.Tests | |||
309 | public void AssetShouldNotMatch() | 309 | public void AssetShouldNotMatch() |
310 | { | 310 | { |
311 | UUID uuid1 = UUID.Random(); | 311 | UUID uuid1 = UUID.Random(); |
312 | AssetBase actual = new AssetBase(uuid1, "asset one"); | 312 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
313 | AssetBase expected = new AssetBase(UUID.Random(), "asset one"); | 313 | AssetBase expected = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); |
314 | 314 | ||
315 | var constraint = Constraints.PropertyCompareConstraint(expected); | 315 | var constraint = Constraints.PropertyCompareConstraint(expected); |
316 | 316 | ||
@@ -321,8 +321,8 @@ namespace OpenSim.Data.Tests | |||
321 | public void AssetShouldNotMatch2() | 321 | public void AssetShouldNotMatch2() |
322 | { | 322 | { |
323 | UUID uuid1 = UUID.Random(); | 323 | UUID uuid1 = UUID.Random(); |
324 | AssetBase actual = new AssetBase(uuid1, "asset one"); | 324 | AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); |
325 | AssetBase expected = new AssetBase(uuid1, "asset two"); | 325 | AssetBase expected = new AssetBase(uuid1, "asset two", (sbyte)AssetType.Texture); |
326 | 326 | ||
327 | var constraint = Constraints.PropertyCompareConstraint(expected); | 327 | var constraint = Constraints.PropertyCompareConstraint(expected); |
328 | 328 | ||
diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs index 72aaff1..c968364 100644 --- a/OpenSim/Data/Tests/PropertyScrambler.cs +++ b/OpenSim/Data/Tests/PropertyScrambler.cs | |||
@@ -165,7 +165,7 @@ namespace OpenSim.Data.Tests | |||
165 | [Test] | 165 | [Test] |
166 | public void TestScramble() | 166 | public void TestScramble() |
167 | { | 167 | { |
168 | AssetBase actual = new AssetBase(UUID.Random(), "asset one"); | 168 | AssetBase actual = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); |
169 | new PropertyScrambler<AssetBase>().Scramble(actual); | 169 | new PropertyScrambler<AssetBase>().Scramble(actual); |
170 | } | 170 | } |
171 | 171 | ||
@@ -173,8 +173,7 @@ namespace OpenSim.Data.Tests | |||
173 | public void DontScramble() | 173 | public void DontScramble() |
174 | { | 174 | { |
175 | UUID uuid = UUID.Random(); | 175 | UUID uuid = UUID.Random(); |
176 | AssetBase asset = new AssetBase(); | 176 | AssetBase asset = new AssetBase(uuid, "asset", (sbyte)AssetType.Texture); |
177 | asset.FullID = uuid; | ||
178 | new PropertyScrambler<AssetBase>() | 177 | new PropertyScrambler<AssetBase>() |
179 | .DontScramble(x => x.Metadata) | 178 | .DontScramble(x => x.Metadata) |
180 | .DontScramble(x => x.FullID) | 179 | .DontScramble(x => x.FullID) |