Thank you, cmickeyb, for a patch that corrects the database connection
handling in the multithreaded user server.
0.6.0-stable
Melanie Thielker 2008-09-03 02:51:34 +00:00
parent 36dcedce31
commit e98780fea5
2 changed files with 38 additions and 16 deletions

View File

@ -280,6 +280,19 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
public void ExecuteParameterizedSql(string sql, Dictionary<string, string> parameters)
{
CheckConnection();
MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand();
cmd.CommandText = sql;
foreach (KeyValuePair<string, string> param in parameters)
{
cmd.Parameters.AddWithValue(param.Key, param.Value);
}
cmd.ExecuteNonQuery();
}
/// <summary> /// <summary>
/// Given a list of tables, return the version of the tables, as seen in the database /// Given a list of tables, return the version of the tables, as seen in the database
/// </summary> /// </summary>

View File

@ -62,6 +62,7 @@ namespace OpenSim.Data.MySQL
private string m_usersTableName; private string m_usersTableName;
private string m_userFriendsTableName; private string m_userFriendsTableName;
private string m_appearanceTableName = "avatarappearance"; private string m_appearanceTableName = "avatarappearance";
private string m_attachmentsTableName = "avatarattachments";
private string m_connectString; private string m_connectString;
public override void Initialise() public override void Initialise()
@ -542,12 +543,10 @@ namespace OpenSim.Data.MySQL
try try
{ {
IDbCommand updater = dbm.Manager.ExecuteParameterizedSql(
dbm.Manager.Query(
"update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
"where UUID = ?UUID", "where UUID = ?UUID",
param); param);
updater.ExecuteNonQuery();
} }
catch (Exception e) catch (Exception e)
{ {
@ -788,19 +787,27 @@ namespace OpenSim.Data.MySQL
{ {
MySQLSuperManager dbm = GetLockedConnection(); MySQLSuperManager dbm = GetLockedConnection();
Dictionary<string, string> param = new Dictionary<string, string>();
param["?uuid"] = agentID.ToString();
try try
{ {
MySqlCommand cmd = dbm.Manager.Connection.CreateCommand(); IDbCommand result = dbm.Manager.Query(
cmd.CommandText = "select attachpoint, item, asset from avatarattachments where UUID = ?uuid"; "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param);
cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); IDataReader reader = result.ExecuteReader();
IDataReader r = cmd.ExecuteReader(); Hashtable ret = dbm.Manager.readAttachments(reader);
Hashtable ret = dbm.Manager.readAttachments(r); reader.Dispose();
result.Dispose();
r.Close();
return ret; return ret;
} }
catch (Exception e)
{
dbm.Manager.Reconnect();
m_log.Error(e.ToString());
return null;
}
finally finally
{ {
dbm.Release(); dbm.Release();
@ -823,14 +830,16 @@ namespace OpenSim.Data.MySQL
public override void ResetAttachments(LLUUID userID) public override void ResetAttachments(LLUUID userID)
{ {
MySQLSuperManager dbm = GetLockedConnection(); MySQLSuperManager dbm = GetLockedConnection();
Dictionary<string, string> param = new Dictionary<string, string>();
param["?uuid"] = userID.ToString();
try try
{ {
MySqlCommand cmd = dbm.Manager.Connection.CreateCommand(); dbm.Manager.ExecuteParameterizedSql(
cmd.CommandText = "UPDATE " + m_attachmentsTableName +
"update avatarattachments set asset = '00000000-0000-0000-0000-000000000000' where UUID = ?uuid"; " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid",
cmd.Parameters.AddWithValue("?uuid", userID.ToString()); param);
cmd.ExecuteNonQuery();
} }
finally finally
{ {