* This fixes adding and updating user profiles in MySQL on platforms that have a commas as a decimal separator
* Thanks Tommil!
0.6.2-post-fixes
Justin Clarke Casey 2009-01-07 18:46:27 +00:00
parent a9df572c25
commit 8d035b196d
3 changed files with 55 additions and 55 deletions

View File

@ -245,7 +245,7 @@ namespace OpenSim.Data.MySQL
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?xmin"] = xmin.ToString(); param["?xmin"] = xmin.ToString();
param["?ymin"] = ymin.ToString(); param["?ymin"] = ymin.ToString();
param["?xmax"] = xmax.ToString(); param["?xmax"] = xmax.ToString();
@ -294,7 +294,7 @@ namespace OpenSim.Data.MySQL
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?name"] = namePrefix + "%"; param["?name"] = namePrefix + "%";
IDbCommand result = IDbCommand result =
@ -339,7 +339,7 @@ namespace OpenSim.Data.MySQL
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?handle"] = handle.ToString(); param["?handle"] = handle.ToString();
IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param);
@ -374,7 +374,7 @@ namespace OpenSim.Data.MySQL
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?uuid"] = uuid.ToString(); param["?uuid"] = uuid.ToString();
IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param);
@ -409,7 +409,7 @@ namespace OpenSim.Data.MySQL
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
// Add % because this is a like query. // Add % because this is a like query.
param["?regionName"] = regionName + "%"; param["?regionName"] = regionName + "%";
// Order by statement will return shorter matches first. Only returns one record or no record. // Order by statement will return shorter matches first. Only returns one record or no record.
@ -546,7 +546,7 @@ namespace OpenSim.Data.MySQL
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?x"] = x.ToString(); param["?x"] = x.ToString();
param["?y"] = y.ToString(); param["?y"] = y.ToString();
IDbCommand result = IDbCommand result =

View File

@ -340,7 +340,7 @@ namespace OpenSim.Data.MySQL
/// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param> /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
/// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param> /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param>
/// <returns>A MySQL DB Command</returns> /// <returns>A MySQL DB Command</returns>
public IDbCommand Query(string sql, Dictionary<string, string> parameters) public IDbCommand Query(string sql, Dictionary<string, object> parameters)
{ {
try try
{ {
@ -348,7 +348,7 @@ namespace OpenSim.Data.MySQL
MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand();
dbcommand.CommandText = sql; dbcommand.CommandText = sql;
foreach (KeyValuePair<string, string> param in parameters) foreach (KeyValuePair<string, object> param in parameters)
{ {
dbcommand.Parameters.AddWithValue(param.Key, param.Value); dbcommand.Parameters.AddWithValue(param.Key, param.Value);
} }
@ -714,7 +714,7 @@ namespace OpenSim.Data.MySQL
string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES ";
sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)";
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters["?server"] = serverDaemon; parameters["?server"] = serverDaemon;
parameters["?target"] = target; parameters["?target"] = target;
parameters["?method"] = methodCall; parameters["?method"] = methodCall;
@ -793,34 +793,34 @@ namespace OpenSim.Data.MySQL
"?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, ";
sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel, ?customType, ?partner)"; sql += "?profileFirstText, ?profileImage, ?profileFirstImage, ?webLoginKey, ?userFlags, ?godLevel, ?customType, ?partner)";
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters["?UUID"] = uuid.ToString(); parameters["?UUID"] = uuid.ToString();
parameters["?username"] = username; parameters["?username"] = username;
parameters["?lastname"] = lastname; parameters["?lastname"] = lastname;
parameters["?email"] = email; parameters["?email"] = email;
parameters["?passwordHash"] = passwordHash; parameters["?passwordHash"] = passwordHash;
parameters["?passwordSalt"] = passwordSalt; parameters["?passwordSalt"] = passwordSalt;
parameters["?homeRegion"] = homeRegion.ToString(); parameters["?homeRegion"] = homeRegion;
parameters["?homeRegionID"] = homeRegionID.ToString(); parameters["?homeRegionID"] = homeRegionID.ToString();
parameters["?homeLocationX"] = homeLocX.ToString(); parameters["?homeLocationX"] = homeLocX;
parameters["?homeLocationY"] = homeLocY.ToString(); parameters["?homeLocationY"] = homeLocY;
parameters["?homeLocationZ"] = homeLocZ.ToString(); parameters["?homeLocationZ"] = homeLocZ;
parameters["?homeLookAtX"] = homeLookAtX.ToString(); parameters["?homeLookAtX"] = homeLookAtX;
parameters["?homeLookAtY"] = homeLookAtY.ToString(); parameters["?homeLookAtY"] = homeLookAtY;
parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); parameters["?homeLookAtZ"] = homeLookAtZ;
parameters["?created"] = created.ToString(); parameters["?created"] = created;
parameters["?lastLogin"] = lastlogin.ToString(); parameters["?lastLogin"] = lastlogin;
parameters["?userInventoryURI"] = inventoryURI; parameters["?userInventoryURI"] = inventoryURI;
parameters["?userAssetURI"] = assetURI; parameters["?userAssetURI"] = assetURI;
parameters["?profileCanDoMask"] = canDoMask.ToString(); parameters["?profileCanDoMask"] = canDoMask;
parameters["?profileWantDoMask"] = wantDoMask.ToString(); parameters["?profileWantDoMask"] = wantDoMask;
parameters["?profileAboutText"] = aboutText; parameters["?profileAboutText"] = aboutText;
parameters["?profileFirstText"] = firstText; parameters["?profileFirstText"] = firstText;
parameters["?profileImage"] = profileImage.ToString(); parameters["?profileImage"] = profileImage.ToString();
parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString();
parameters["?webLoginKey"] = webLoginKey.ToString(); parameters["?webLoginKey"] = webLoginKey.ToString();
parameters["?userFlags"] = userFlags.ToString(); parameters["?userFlags"] = userFlags;
parameters["?godLevel"] = godLevel.ToString(); parameters["?godLevel"] = godLevel;
parameters["?customType"] = customType == null ? "" : customType; parameters["?customType"] = customType == null ? "" : customType;
parameters["?partner"] = partner.ToString(); parameters["?partner"] = partner.ToString();
bool returnval = false; bool returnval = false;
@ -892,35 +892,35 @@ namespace OpenSim.Data.MySQL
sql += "`customType` = ?customType , `partner` = ?partner , "; sql += "`customType` = ?customType , `partner` = ?partner , ";
sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID";
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters["?UUID"] = uuid.ToString(); parameters["?UUID"] = uuid.ToString();
parameters["?username"] = username; parameters["?username"] = username;
parameters["?lastname"] = lastname; parameters["?lastname"] = lastname;
parameters["?email"] = email; parameters["?email"] = email;
parameters["?passwordHash"] = passwordHash; parameters["?passwordHash"] = passwordHash;
parameters["?passwordSalt"] = passwordSalt; parameters["?passwordSalt"] = passwordSalt;
parameters["?homeRegion"] = homeRegion.ToString(); parameters["?homeRegion"] = homeRegion;
parameters["?homeRegionID"] = homeRegionID.ToString(); parameters["?homeRegionID"] = homeRegionID.ToString();
parameters["?homeLocationX"] = homeLocX.ToString(); parameters["?homeLocationX"] = homeLocX;
parameters["?homeLocationY"] = homeLocY.ToString(); parameters["?homeLocationY"] = homeLocY;
parameters["?homeLocationZ"] = homeLocZ.ToString(); parameters["?homeLocationZ"] = homeLocZ;
parameters["?homeLookAtX"] = homeLookAtX.ToString(); parameters["?homeLookAtX"] = homeLookAtX;
parameters["?homeLookAtY"] = homeLookAtY.ToString(); parameters["?homeLookAtY"] = homeLookAtY;
parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); parameters["?homeLookAtZ"] = homeLookAtZ;
parameters["?created"] = created.ToString(); parameters["?created"] = created;
parameters["?lastLogin"] = lastlogin.ToString(); parameters["?lastLogin"] = lastlogin;
parameters["?userInventoryURI"] = inventoryURI; parameters["?userInventoryURI"] = inventoryURI;
parameters["?userAssetURI"] = assetURI; parameters["?userAssetURI"] = assetURI;
parameters["?profileCanDoMask"] = canDoMask.ToString(); parameters["?profileCanDoMask"] = canDoMask;
parameters["?profileWantDoMask"] = wantDoMask.ToString(); parameters["?profileWantDoMask"] = wantDoMask;
parameters["?profileAboutText"] = aboutText; parameters["?profileAboutText"] = aboutText;
parameters["?profileFirstText"] = firstText; parameters["?profileFirstText"] = firstText;
parameters["?profileImage"] = profileImage.ToString(); parameters["?profileImage"] = profileImage.ToString();
parameters["?profileFirstImage"] = firstImage.ToString(); parameters["?profileFirstImage"] = firstImage.ToString();
parameters["?webLoginKey"] = webLoginKey.ToString(); parameters["?webLoginKey"] = webLoginKey.ToString();
parameters["?userFlags"] = userFlags.ToString(); parameters["?userFlags"] = userFlags;
parameters["?godLevel"] = godLevel.ToString(); parameters["?godLevel"] = godLevel;
parameters["?customType"] = customType == null ? "" : customType.ToString(); parameters["?customType"] = customType == null ? "" : customType;
parameters["?partner"] = partner.ToString(); parameters["?partner"] = partner.ToString();
bool returnval = false; bool returnval = false;
@ -993,7 +993,7 @@ namespace OpenSim.Data.MySQL
sql += ";"; sql += ";";
} }
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters["?regionHandle"] = regiondata.regionHandle.ToString(); parameters["?regionHandle"] = regiondata.regionHandle.ToString();
parameters["?regionName"] = regiondata.regionName.ToString(); parameters["?regionName"] = regiondata.regionName.ToString();
@ -1063,7 +1063,7 @@ namespace OpenSim.Data.MySQL
string sql = "DELETE FROM regions WHERE uuid = ?uuid;"; string sql = "DELETE FROM regions WHERE uuid = ?uuid;";
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, object> parameters = new Dictionary<string, object>();
try try
{ {
@ -1102,7 +1102,7 @@ namespace OpenSim.Data.MySQL
sql += "REPLACE INTO "; sql += "REPLACE INTO ";
sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos, currentLookAt) VALUES "; sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos, currentLookAt) VALUES ";
sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos, ?currentLookAt);"; sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos, ?currentLookAt);";
Dictionary<string, string> parameters = new Dictionary<string, string>(); Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters["?UUID"] = agentdata.ProfileID.ToString(); parameters["?UUID"] = agentdata.ProfileID.ToString();
parameters["?sessionID"] = agentdata.SessionID.ToString(); parameters["?sessionID"] = agentdata.SessionID.ToString();
@ -1114,8 +1114,8 @@ namespace OpenSim.Data.MySQL
parameters["?logoutTime"] = agentdata.LogoutTime.ToString(); parameters["?logoutTime"] = agentdata.LogoutTime.ToString();
parameters["?currentRegion"] = agentdata.Region.ToString(); parameters["?currentRegion"] = agentdata.Region.ToString();
parameters["?currentHandle"] = agentdata.Handle.ToString(); parameters["?currentHandle"] = agentdata.Handle.ToString();
parameters["?currentPos"] = "<" + (agentdata.Position.X).ToString() + "," + (agentdata.Position.Y).ToString() + "," + (agentdata.Position.Z).ToString() + ">"; parameters["?currentPos"] = "<" + (agentdata.Position.X).ToString().Replace(",", ".") + "," + (agentdata.Position.Y).ToString().Replace(",", ".") + "," + (agentdata.Position.Z).ToString().Replace(",", ".") + ">";
parameters["?currentLookAt"] = "<" + (agentdata.LookAt.X).ToString() + "," + (agentdata.LookAt.Y).ToString() + "," + (agentdata.LookAt.Z).ToString() + ">"; parameters["?currentLookAt"] = "<" + (agentdata.LookAt.X).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Y).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Z).ToString().Replace(",", ".") + ">";
bool returnval = false; bool returnval = false;

View File

@ -176,7 +176,7 @@ namespace OpenSim.Data.MySQL
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?first"] = user; param["?first"] = user;
param["?second"] = last; param["?second"] = last;
@ -209,7 +209,7 @@ namespace OpenSim.Data.MySQL
{ {
int dtvalue = Util.UnixTimeSinceEpoch(); int dtvalue = Util.UnixTimeSinceEpoch();
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?ownerID"] = friendlistowner.ToString(); param["?ownerID"] = friendlistowner.ToString();
param["?friendID"] = friend.ToString(); param["?friendID"] = friend.ToString();
param["?friendPerms"] = perms.ToString(); param["?friendPerms"] = perms.ToString();
@ -251,7 +251,7 @@ namespace OpenSim.Data.MySQL
public override void RemoveUserFriend(UUID friendlistowner, UUID friend) public override void RemoveUserFriend(UUID friendlistowner, UUID friend)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?ownerID"] = friendlistowner.ToString(); param["?ownerID"] = friendlistowner.ToString();
param["?friendID"] = friend.ToString(); param["?friendID"] = friend.ToString();
@ -285,7 +285,7 @@ namespace OpenSim.Data.MySQL
public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?ownerID"] = friendlistowner.ToString(); param["?ownerID"] = friendlistowner.ToString();
param["?friendID"] = friend.ToString(); param["?friendID"] = friend.ToString();
param["?friendPerms"] = perms.ToString(); param["?friendPerms"] = perms.ToString();
@ -318,7 +318,7 @@ namespace OpenSim.Data.MySQL
{ {
List<FriendListItem> Lfli = new List<FriendListItem>(); List<FriendListItem> Lfli = new List<FriendListItem>();
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?ownerID"] = friendlistowner.ToString(); param["?ownerID"] = friendlistowner.ToString();
MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList"); MySQLSuperManager dbm = GetLockedConnection("GetUserFriendList");
@ -373,7 +373,7 @@ namespace OpenSim.Data.MySQL
{ {
foreach (UUID uuid in uuids) foreach (UUID uuid in uuids)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?uuid"] = uuid.ToString(); param["?uuid"] = uuid.ToString();
IDbCommand result = IDbCommand result =
dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName +
@ -419,7 +419,7 @@ namespace OpenSim.Data.MySQL
querysplit = query.Split(' '); querysplit = query.Split(' ');
if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty) if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%"; param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%";
MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults"); MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults");
@ -461,7 +461,7 @@ namespace OpenSim.Data.MySQL
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
IDbCommand result = IDbCommand result =
@ -506,7 +506,7 @@ namespace OpenSim.Data.MySQL
MySQLSuperManager dbm = GetLockedConnection("GetUserByUUID"); MySQLSuperManager dbm = GetLockedConnection("GetUserByUUID");
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?uuid"] = uuid.ToString(); param["?uuid"] = uuid.ToString();
IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param);
@ -596,7 +596,7 @@ namespace OpenSim.Data.MySQL
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?uuid"] = uuid.ToString(); param["?uuid"] = uuid.ToString();
IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid",
@ -744,7 +744,7 @@ namespace OpenSim.Data.MySQL
MySQLSuperManager dbm = GetLockedConnection("GetUserAppearance"); MySQLSuperManager dbm = GetLockedConnection("GetUserAppearance");
try try
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?owner"] = user.ToString(); param["?owner"] = user.ToString();
IDbCommand result = dbm.Manager.Query( IDbCommand result = dbm.Manager.Query(
@ -825,7 +825,7 @@ namespace OpenSim.Data.MySQL
public Hashtable GetUserAttachments(UUID agentID) public Hashtable GetUserAttachments(UUID agentID)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, object> param = new Dictionary<string, object>();
param["?uuid"] = agentID.ToString(); param["?uuid"] = agentID.ToString();
MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments"); MySQLSuperManager dbm = GetLockedConnection("GetUserAttachments");