diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLManager.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLManager.cs | 60 |
1 files changed, 32 insertions, 28 deletions
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 | ||