aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorMelanie2009-10-06 17:44:59 +0100
committerMelanie2009-10-06 17:44:59 +0100
commit0374f1b144f3faf35da39e3925e8abd4b2a8bd04 (patch)
tree456d3d532c70d32564d35fc3cb9bbc81bdf08b2e /OpenSim/Data
parentMake sure that keys exist in arrays before trying to access them. (diff)
parentCorrected words in error message. (diff)
downloadopensim-SC-0374f1b144f3faf35da39e3925e8abd4b2a8bd04.zip
opensim-SC-0374f1b144f3faf35da39e3925e8abd4b2a8bd04.tar.gz
opensim-SC-0374f1b144f3faf35da39e3925e8abd4b2a8bd04.tar.bz2
opensim-SC-0374f1b144f3faf35da39e3925e8abd4b2a8bd04.tar.xz
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs52
-rw-r--r--OpenSim/Data/MySQL/MySQLFramework.cs22
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs70
4 files changed, 79 insertions, 67 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index e96a123..0780936 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -55,39 +55,41 @@ namespace OpenSim.Data.MySQL
55 AuthenticationData ret = new AuthenticationData(); 55 AuthenticationData ret = new AuthenticationData();
56 ret.Data = new Dictionary<string, object>(); 56 ret.Data = new Dictionary<string, object>();
57 57
58 using (MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID")) 58 MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID");
59 {
60 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
61 59
62 using (IDataReader result = ExecuteReader(cmd)) 60 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
63 {
64 if (result.Read())
65 {
66 ret.PrincipalID = principalID;
67 61
68 if (m_ColumnNames == null) 62 IDataReader result = ExecuteReader(cmd);
69 {
70 m_ColumnNames = new List<string>();
71 63
72 DataTable schemaTable = result.GetSchemaTable(); 64 if (result.Read())
73 foreach (DataRow row in schemaTable.Rows) 65 {
74 m_ColumnNames.Add(row["ColumnName"].ToString()); 66 ret.PrincipalID = principalID;
75 } 67
68 if (m_ColumnNames == null)
69 {
70 m_ColumnNames = new List<string>();
76 71
77 foreach (string s in m_ColumnNames) 72 DataTable schemaTable = result.GetSchemaTable();
78 { 73 foreach (DataRow row in schemaTable.Rows)
79 if (s == "UUID") 74 m_ColumnNames.Add(row["ColumnName"].ToString());
80 continue; 75 }
81 76
82 ret.Data[s] = result[s].ToString(); 77 foreach (string s in m_ColumnNames)
83 } 78 {
79 if (s == "UUID")
80 continue;
84 81
85 return ret; 82 ret.Data[s] = result[s].ToString();
86 }
87 } 83 }
88 }
89 84
90 return null; 85 CloseDBConnection(result, cmd);
86 return ret;
87 }
88 else
89 {
90 CloseDBConnection(result, cmd);
91 return null;
92 }
91 } 93 }
92 94
93 public bool Store(AuthenticationData data) 95 public bool Store(AuthenticationData data)
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs
index c756c9c..ccd1ab0 100644
--- a/OpenSim/Data/MySQL/MySQLFramework.cs
+++ b/OpenSim/Data/MySQL/MySQLFramework.cs
@@ -40,14 +40,15 @@ namespace OpenSim.Data.MySQL
40 /// </summary> 40 /// </summary>
41 public class MySqlFramework 41 public class MySqlFramework
42 { 42 {
43 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly log4net.ILog m_log =
44 log4net.LogManager.GetLogger(
45 System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
44 46
45 protected MySqlConnection m_Connection; 47 protected MySqlConnection m_Connection;
46 48
47 protected MySqlFramework(string connectionString) 49 protected MySqlFramework(string connectionString)
48 { 50 {
49 m_Connection = new MySqlConnection(connectionString); 51 m_Connection = new MySqlConnection(connectionString);
50
51 m_Connection.Open(); 52 m_Connection.Open();
52 } 53 }
53 54
@@ -82,8 +83,8 @@ namespace OpenSim.Data.MySQL
82 errorSeen = true; 83 errorSeen = true;
83 84
84 m_Connection.Close(); 85 m_Connection.Close();
85 MySqlConnection newConnection = (MySqlConnection) 86 MySqlConnection newConnection =
86 ((ICloneable)m_Connection).Clone(); 87 (MySqlConnection)((ICloneable)m_Connection).Clone();
87 m_Connection.Dispose(); 88 m_Connection.Dispose();
88 m_Connection = newConnection; 89 m_Connection = newConnection;
89 m_Connection.Open(); 90 m_Connection.Open();
@@ -104,14 +105,19 @@ namespace OpenSim.Data.MySQL
104 105
105 protected IDataReader ExecuteReader(MySqlCommand cmd) 106 protected IDataReader ExecuteReader(MySqlCommand cmd)
106 { 107 {
107 MySqlConnection newConnection = (MySqlConnection) 108 MySqlConnection newConnection =
108 ((ICloneable)m_Connection).Clone(); 109 (MySqlConnection)((ICloneable)m_Connection).Clone();
109
110 newConnection.Open(); 110 newConnection.Open();
111 111
112 cmd.Connection = newConnection; 112 cmd.Connection = newConnection;
113
114 return cmd.ExecuteReader(); 113 return cmd.ExecuteReader();
115 } 114 }
115
116 protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd)
117 {
118 reader.Close();
119 cmd.Connection.Close();
120 cmd.Connection.Dispose();
121 }
116 } 122 }
117} 123}
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 04b24b6..3b561d1 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -172,6 +172,8 @@ namespace OpenSim.Data.MySQL
172 172
173 retList.Add(ret); 173 retList.Add(ret);
174 } 174 }
175
176 CloseDBConnection(result, cmd);
175 } 177 }
176 178
177 return retList; 179 return retList;
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index c713a11..0bbc3f5 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -64,45 +64,47 @@ namespace OpenSim.Data.MySQL
64 if (scopeID != UUID.Zero) 64 if (scopeID != UUID.Zero)
65 command += " and ScopeID = ?scopeID"; 65 command += " and ScopeID = ?scopeID";
66 66
67 using (MySqlCommand cmd = new MySqlCommand(command)) 67 MySqlCommand cmd = new MySqlCommand(command);
68
69 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
70 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
71
72 IDataReader result = ExecuteReader(cmd);
73
74 if (result.Read())
68 { 75 {
69 cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); 76 ret.PrincipalID = principalID;
70 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 77 UUID scope;
78 UUID.TryParse(result["ScopeID"].ToString(), out scope);
79 ret.ScopeID = scope;
71 80
72 using (IDataReader result = ExecuteReader(cmd)) 81 if (m_ColumnNames == null)
73 { 82 {
74 if (result.Read()) 83 m_ColumnNames = new List<string>();
75 { 84
76 ret.PrincipalID = principalID; 85 DataTable schemaTable = result.GetSchemaTable();
77 UUID scope; 86 foreach (DataRow row in schemaTable.Rows)
78 UUID.TryParse(result["ScopeID"].ToString(), out scope); 87 m_ColumnNames.Add(row["ColumnName"].ToString());
79 ret.ScopeID = scope;
80
81 if (m_ColumnNames == null)
82 {
83 m_ColumnNames = new List<string>();
84
85 DataTable schemaTable = result.GetSchemaTable();
86 foreach (DataRow row in schemaTable.Rows)
87 m_ColumnNames.Add(row["ColumnName"].ToString());
88 }
89
90 foreach (string s in m_ColumnNames)
91 {
92 if (s == "UUID")
93 continue;
94 if (s == "ScopeID")
95 continue;
96
97 ret.Data[s] = result[s].ToString();
98 }
99
100 return ret;
101 }
102 } 88 }
103 }
104 89
105 return null; 90 foreach (string s in m_ColumnNames)
91 {
92 if (s == "UUID")
93 continue;
94 if (s == "ScopeID")
95 continue;
96
97 ret.Data[s] = result[s].ToString();
98 }
99
100 CloseDBConnection(result, cmd);
101 return ret;
102 }
103 else
104 {
105 CloseDBConnection(result, cmd);
106 return null;
107 }
106 } 108 }
107 109
108 public bool Store(UserAccountData data) 110 public bool Store(UserAccountData data)