mirror of
https://github.com/opensim/opensim.git
synced 2026-05-13 18:21:49 +08:00
Remove the using() constructs from the new style database modules; they caused
the underlying connection of a reader or command to be closed before the reader or command itself. Added the proper logic to Close and dispose items in CloseDBConnection. Readers and Connections need Close(), Commands need Dispose(), in the order Reader, Command, Connection. Also reinstated 80-column-friendly formatting
This commit is contained in:
@@ -64,48 +64,46 @@ namespace OpenSim.Data.MySQL
|
||||
if (scopeID != UUID.Zero)
|
||||
command += " and ScopeID = ?scopeID";
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||
MySqlCommand cmd = new MySqlCommand(command);
|
||||
|
||||
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
|
||||
IDataReader result = ExecuteReader(cmd);
|
||||
|
||||
if (result.Read())
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
ret.PrincipalID = principalID;
|
||||
UUID scope;
|
||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
||||
ret.ScopeID = scope;
|
||||
|
||||
using (IDataReader result = ExecuteReader(cmd))
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
if (result.Read())
|
||||
{
|
||||
ret.PrincipalID = principalID;
|
||||
UUID scope;
|
||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
||||
ret.ScopeID = scope;
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = result.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
}
|
||||
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
if (s == "UUID")
|
||||
continue;
|
||||
if (s == "ScopeID")
|
||||
continue;
|
||||
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
|
||||
CloseDBConnection(cmd);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseDBConnection(cmd);
|
||||
return null;
|
||||
}
|
||||
DataTable schemaTable = result.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
}
|
||||
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
if (s == "UUID")
|
||||
continue;
|
||||
if (s == "ScopeID")
|
||||
continue;
|
||||
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
|
||||
CloseDBConnection(result, cmd);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseDBConnection(result, cmd);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user