aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-03 02:51:34 +0000
committerMelanie Thielker2008-09-03 02:51:34 +0000
commite98780fea5c9235da50062f09cac4d415c7f2125 (patch)
treedbd051d601a02f74d1b45ff82d8243b1d7b4ab4b /OpenSim/Data/MySQL
parenta piece of LSL_API changes got checked in incorectly with 6091. This (diff)
downloadopensim-SC-e98780fea5c9235da50062f09cac4d415c7f2125.zip
opensim-SC-e98780fea5c9235da50062f09cac4d415c7f2125.tar.gz
opensim-SC-e98780fea5c9235da50062f09cac4d415c7f2125.tar.bz2
opensim-SC-e98780fea5c9235da50062f09cac4d415c7f2125.tar.xz
Mantis #2099
Thank you, cmickeyb, for a patch that corrects the database connection handling in the multithreaded user server.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLManager.cs13
-rw-r--r--OpenSim/Data/MySQL/MySQLUserData.cs41
2 files changed, 38 insertions, 16 deletions
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs
index 15bdf44..e863216 100644
--- a/OpenSim/Data/MySQL/MySQLManager.cs
+++ b/OpenSim/Data/MySQL/MySQLManager.cs
@@ -280,6 +280,19 @@ namespace OpenSim.Data.MySQL
280 cmd.ExecuteNonQuery(); 280 cmd.ExecuteNonQuery();
281 } 281 }
282 282
283 public void ExecuteParameterizedSql(string sql, Dictionary<string, string> parameters)
284 {
285 CheckConnection();
286
287 MySqlCommand cmd = (MySqlCommand)dbcon.CreateCommand();
288 cmd.CommandText = sql;
289 foreach (KeyValuePair<string, string> param in parameters)
290 {
291 cmd.Parameters.AddWithValue(param.Key, param.Value);
292 }
293 cmd.ExecuteNonQuery();
294 }
295
283 /// <summary> 296 /// <summary>
284 /// Given a list of tables, return the version of the tables, as seen in the database 297 /// Given a list of tables, return the version of the tables, as seen in the database
285 /// </summary> 298 /// </summary>
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs
index 7a44d3c..8d0b177 100644
--- a/OpenSim/Data/MySQL/MySQLUserData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserData.cs
@@ -62,6 +62,7 @@ namespace OpenSim.Data.MySQL
62 private string m_usersTableName; 62 private string m_usersTableName;
63 private string m_userFriendsTableName; 63 private string m_userFriendsTableName;
64 private string m_appearanceTableName = "avatarappearance"; 64 private string m_appearanceTableName = "avatarappearance";
65 private string m_attachmentsTableName = "avatarattachments";
65 private string m_connectString; 66 private string m_connectString;
66 67
67 public override void Initialise() 68 public override void Initialise()
@@ -542,12 +543,10 @@ namespace OpenSim.Data.MySQL
542 543
543 try 544 try
544 { 545 {
545 IDbCommand updater = 546 dbm.Manager.ExecuteParameterizedSql(
546 dbm.Manager.Query(
547 "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + 547 "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
548 "where UUID = ?UUID", 548 "where UUID = ?UUID",
549 param); 549 param);
550 updater.ExecuteNonQuery();
551 } 550 }
552 catch (Exception e) 551 catch (Exception e)
553 { 552 {
@@ -788,19 +787,27 @@ namespace OpenSim.Data.MySQL
788 { 787 {
789 MySQLSuperManager dbm = GetLockedConnection(); 788 MySQLSuperManager dbm = GetLockedConnection();
790 789
790 Dictionary<string, string> param = new Dictionary<string, string>();
791 param["?uuid"] = agentID.ToString();
792
791 try 793 try
792 { 794 {
793 MySqlCommand cmd = dbm.Manager.Connection.CreateCommand(); 795 IDbCommand result = dbm.Manager.Query(
794 cmd.CommandText = "select attachpoint, item, asset from avatarattachments where UUID = ?uuid"; 796 "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param);
795 cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); 797 IDataReader reader = result.ExecuteReader();
796
797 IDataReader r = cmd.ExecuteReader();
798 798
799 Hashtable ret = dbm.Manager.readAttachments(r); 799 Hashtable ret = dbm.Manager.readAttachments(reader);
800 800
801 r.Close(); 801 reader.Dispose();
802 result.Dispose();
802 return ret; 803 return ret;
803 } 804 }
805 catch (Exception e)
806 {
807 dbm.Manager.Reconnect();
808 m_log.Error(e.ToString());
809 return null;
810 }
804 finally 811 finally
805 { 812 {
806 dbm.Release(); 813 dbm.Release();
@@ -823,14 +830,16 @@ namespace OpenSim.Data.MySQL
823 public override void ResetAttachments(LLUUID userID) 830 public override void ResetAttachments(LLUUID userID)
824 { 831 {
825 MySQLSuperManager dbm = GetLockedConnection(); 832 MySQLSuperManager dbm = GetLockedConnection();
833
834 Dictionary<string, string> param = new Dictionary<string, string>();
835 param["?uuid"] = userID.ToString();
836
826 try 837 try
827 { 838 {
828 MySqlCommand cmd = dbm.Manager.Connection.CreateCommand(); 839 dbm.Manager.ExecuteParameterizedSql(
829 cmd.CommandText = 840 "UPDATE " + m_attachmentsTableName +
830 "update avatarattachments set asset = '00000000-0000-0000-0000-000000000000' where UUID = ?uuid"; 841 " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid",
831 cmd.Parameters.AddWithValue("?uuid", userID.ToString()); 842 param);
832
833 cmd.ExecuteNonQuery();
834 } 843 }
835 finally 844 finally
836 { 845 {