aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-04 13:57:51 -0700
committerJohn Hurliman2009-10-04 13:57:51 -0700
commit29a4614529bbda02b9c690d2d1812be1d1e7bbae (patch)
tree89725829b37d502158a114c862a56a075b005b1b /OpenSim/Data/MySQL/MySQLAuthenticationData.cs
parentGuarding a line that is sometimes throwing a null pointer exception. (diff)
downloadopensim-SC-29a4614529bbda02b9c690d2d1812be1d1e7bbae.zip
opensim-SC-29a4614529bbda02b9c690d2d1812be1d1e7bbae.tar.gz
opensim-SC-29a4614529bbda02b9c690d2d1812be1d1e7bbae.tar.bz2
opensim-SC-29a4614529bbda02b9c690d2d1812be1d1e7bbae.tar.xz
* MySQL data tests now pass by fixing a bad fix for a bad cast on the asset Local member in MySQLAssetData
* First pass at applying the using(){} pattern to IDisposable objects. Always use the using pattern on IDisposable objects whenever possible, do not manually call .Close() or .Dispose() unless there is no other way to write the code. This pass mostly covers OpenSim.Data.MySQL, and should have no functional change (tests still pass)
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs50
1 files changed, 22 insertions, 28 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index e508b52..e96a123 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -55,44 +55,38 @@ 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 MySqlCommand cmd = new MySqlCommand( 58 using (MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"))
59 "select * from `"+m_Realm+"` where UUID = ?principalID"
60 );
61
62 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
63
64 IDataReader result = ExecuteReader(cmd);
65
66 if (result.Read())
67 { 59 {
68 ret.PrincipalID = principalID; 60 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
69 61
70 if (m_ColumnNames == null) 62 using (IDataReader result = ExecuteReader(cmd))
71 { 63 {
72 m_ColumnNames = new List<string>(); 64 if (result.Read())
65 {
66 ret.PrincipalID = principalID;
73 67
74 DataTable schemaTable = result.GetSchemaTable(); 68 if (m_ColumnNames == null)
75 foreach (DataRow row in schemaTable.Rows) 69 {
76 m_ColumnNames.Add(row["ColumnName"].ToString()); 70 m_ColumnNames = new List<string>();
77 }
78 71
79 foreach (string s in m_ColumnNames) 72 DataTable schemaTable = result.GetSchemaTable();
80 { 73 foreach (DataRow row in schemaTable.Rows)
81 if (s == "UUID") 74 m_ColumnNames.Add(row["ColumnName"].ToString());
82 continue; 75 }
83 76
84 ret.Data[s] = result[s].ToString(); 77 foreach (string s in m_ColumnNames)
85 } 78 {
79 if (s == "UUID")
80 continue;
86 81
87 result.Close(); 82 ret.Data[s] = result[s].ToString();
88 CloseReaderCommand(cmd); 83 }
89 84
90 return ret; 85 return ret;
86 }
87 }
91 } 88 }
92 89
93 result.Close();
94 CloseReaderCommand(cmd);
95
96 return null; 90 return null;
97 } 91 }
98 92