Thank you, StrawberryFride, for a patch to port MSSQL fixes to stable

0.6.5-post-fixes
Melanie Thielker 2009-06-11 13:20:32 +00:00
parent 2587170445
commit f8666f3630
2 changed files with 48 additions and 62 deletions

View File

@ -108,7 +108,7 @@ namespace OpenSim.Data.MSSQL
{
cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID));
using (IDataReader reader = cmd.ExecuteReader())
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
@ -124,16 +124,11 @@ namespace OpenSim.Data.MSSQL
}
else if (_FieldMap[name].GetValue(es) is UUID)
{
// UUID uuid;
// UUID.TryParse(reader[name].ToString(), out uuid);
_FieldMap[name].SetValue(es, new UUID((Guid) reader[name])); // uuid);
}
else
{
es.EstateID = Convert.ToUInt32(reader["EstateID"].ToString());
//Problems converting a Int32 to a UInt32
//_FieldMap[name].SetValue(es, reader["EstateID"]);
}
}
}
@ -153,7 +148,6 @@ namespace OpenSim.Data.MSSQL
sql = string.Format("insert into estate_settings ({0}) values ( @{1})", String.Join(",", names.ToArray()), String.Join(", @", names.ToArray()));
//_Log.Debug("[DB ESTATE]: SQL: " + sql);
using (SqlConnection connection = _Database.DatabaseConnection())
{
using (SqlCommand insertCommand = connection.CreateCommand())
@ -163,28 +157,8 @@ namespace OpenSim.Data.MSSQL
foreach (string name in names)
{
insertCommand.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es)));
// if (_FieldMap[name].GetValue(es) is bool)
// {
// SqlParameter tempBool = new SqlParameter("@" + name, SqlDbType.Bit);
//
// if ((bool) _FieldMap[name].GetValue(es))
// tempBool.Value = 1;
// else
// tempBool.Value = 0;
//
// insertCommand.Parameters.Add(tempBool);
// }
// else
// {
// //cmd.Parameters.AddWithValue("@" + name, _FieldMap[name].GetValue(es));
// SqlParameter tempPar = new SqlParameter("@" + name,
// _Database.DbtypeFromType(_FieldMap[name].FieldType));
// tempPar.Value = _FieldMap[name].GetValue(es).ToString();
//
// insertCommand.Parameters.Add(tempPar);
// }
}
// insertCommand.Parameters.Add(_Database.CreateParameter("@ID", es.EstateID, true));
SqlParameter idParameter = new SqlParameter("@ID", SqlDbType.Int);
idParameter.Direction = ParameterDirection.Output;
insertCommand.Parameters.Add(idParameter);
@ -211,7 +185,6 @@ namespace OpenSim.Data.MSSQL
}
// Munge and transfer the ban list
//
sql = string.Format("insert into estateban select {0}, bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = @UUID", es.EstateID);
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
@ -253,7 +226,7 @@ namespace OpenSim.Data.MSSQL
names.Remove("EstateID");
string sql = string.Format("UPDATE estate_settings SET ") ; // ({0}) values ( @{1}) WHERE EstateID = @EstateID", String.Join(",", names.ToArray()), String.Join(", @", names.ToArray()));
string sql = string.Format("UPDATE estate_settings SET ") ;
foreach (string name in names)
{
sql += name + " = @" + name + ", ";
@ -266,33 +239,8 @@ namespace OpenSim.Data.MSSQL
foreach (string name in names)
{
cmd.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es)));
// if (_FieldMap[name].GetValue(es) is bool)
// {
// SqlParameter tempBool = new SqlParameter("@" + name, SqlDbType.Bit);
//
// if ((bool)_FieldMap[name].GetValue(es))
// tempBool.Value = 1;
// else
// tempBool.Value = 0;
//
// cmd.Parameters.Add(tempBool);
// }
// else
// {
// //cmd.Parameters.AddWithValue("@" + name, _FieldMap[name].GetValue(es));
// SqlParameter tempPar = new SqlParameter("@" + name,
// _Database.DbtypeFromType(_FieldMap[name].FieldType));
// tempPar.Value = _FieldMap[name].GetValue(es).ToString();
//
// cmd.Parameters.Add(tempPar);
// }
}
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID));
// SqlParameter idParameter = new SqlParameter("@EstateID", SqlDbType.Int);
// idParameter.Value = es.EstateID;
// cmd.Parameters.Add(idParameter);
cmd.ExecuteNonQuery();
}

View File

@ -576,8 +576,7 @@ namespace OpenSim.Data.MSSQL
/// <param name="user">the used UUID</param>
/// <param name="appearance">the appearence</param>
override public void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
{
m_log.Error("[USER DB] updating user appearance for user ID " + user.Guid);
{
string sql = String.Empty;
sql += "DELETE FROM avatarappearance WHERE owner=@owner ";
sql += "INSERT INTO avatarappearance ";
@ -1113,6 +1112,10 @@ ELSE
retval.ID = new UUID((Guid)reader["UUID"]);
retval.FirstName = (string)reader["username"];
retval.SurName = (string)reader["lastname"];
if (reader.IsDBNull(reader.GetOrdinal("email")))
retval.Email = "";
else
retval.Email = (string)reader["email"];
retval.PasswordHash = (string)reader["passwordHash"];
retval.PasswordSalt = (string)reader["passwordSalt"];
@ -1127,6 +1130,11 @@ ELSE
Convert.ToSingle(reader["homeLookAtY"].ToString()),
Convert.ToSingle(reader["homeLookAtZ"].ToString()));
if (reader.IsDBNull(reader.GetOrdinal("homeRegionID")))
retval.HomeRegionID = UUID.Zero;
else
retval.HomeRegionID = new UUID((Guid)reader["homeRegionID"]);
retval.Created = Convert.ToInt32(reader["created"].ToString());
retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
@ -1136,12 +1144,42 @@ ELSE
retval.CanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
retval.WantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
retval.AboutText = (string)reader["profileAboutText"];
retval.FirstLifeAboutText = (string)reader["profileFirstText"];
if (reader.IsDBNull(reader.GetOrdinal("profileAboutText")))
retval.AboutText = "";
else
retval.AboutText = (string)reader["profileAboutText"];
retval.Image = new UUID((Guid)reader["profileImage"]);
retval.FirstLifeImage = new UUID((Guid)reader["profileFirstImage"]);
retval.WebLoginKey = new UUID((Guid)reader["webLoginKey"]);
if (reader.IsDBNull(reader.GetOrdinal("profileFirstText")))
retval.FirstLifeAboutText = "";
else
retval.FirstLifeAboutText = (string)reader["profileFirstText"];
if (reader.IsDBNull(reader.GetOrdinal("profileImage")))
retval.Image = UUID.Zero;
else
retval.Image = new UUID((Guid)reader["profileImage"]);
if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage")))
retval.Image = UUID.Zero;
else
retval.FirstLifeImage = new UUID((Guid)reader["profileFirstImage"]);
if (reader.IsDBNull(reader.GetOrdinal("webLoginKey")))
retval.WebLoginKey = UUID.Zero;
else
retval.WebLoginKey = new UUID((Guid)reader["webLoginKey"]);
retval.UserFlags = Convert.ToInt32(reader["userFlags"].ToString());
retval.GodLevel = Convert.ToInt32(reader["godLevel"].ToString());
if (reader.IsDBNull(reader.GetOrdinal("customType")))
retval.CustomType = "";
else
retval.CustomType = reader["customType"].ToString();
if (reader.IsDBNull(reader.GetOrdinal("partner")))
retval.Partner = UUID.Zero;
else
retval.Partner = new UUID((Guid)reader["partner"]);
}
else
{