diff options
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 62 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLFramework.cs | 14 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLRegionData.cs | 2 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserAccountData.cs | 74 |
4 files changed, 77 insertions, 75 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index a41f9f8..0780936 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |||
@@ -55,42 +55,40 @@ 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 | |||
62 | IDataReader result = ExecuteReader(cmd); | ||
63 | |||
64 | if (result.Read()) | ||
59 | { | 65 | { |
60 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | 66 | ret.PrincipalID = principalID; |
67 | |||
68 | if (m_ColumnNames == null) | ||
69 | { | ||
70 | m_ColumnNames = new List<string>(); | ||
61 | 71 | ||
62 | using (IDataReader result = ExecuteReader(cmd)) | 72 | DataTable schemaTable = result.GetSchemaTable(); |
73 | foreach (DataRow row in schemaTable.Rows) | ||
74 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
75 | } | ||
76 | |||
77 | foreach (string s in m_ColumnNames) | ||
63 | { | 78 | { |
64 | if (result.Read()) | 79 | if (s == "UUID") |
65 | { | 80 | continue; |
66 | ret.PrincipalID = principalID; | 81 | |
67 | 82 | ret.Data[s] = result[s].ToString(); | |
68 | if (m_ColumnNames == null) | ||
69 | { | ||
70 | m_ColumnNames = new List<string>(); | ||
71 | |||
72 | DataTable schemaTable = result.GetSchemaTable(); | ||
73 | foreach (DataRow row in schemaTable.Rows) | ||
74 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
75 | } | ||
76 | |||
77 | foreach (string s in m_ColumnNames) | ||
78 | { | ||
79 | if (s == "UUID") | ||
80 | continue; | ||
81 | |||
82 | ret.Data[s] = result[s].ToString(); | ||
83 | } | ||
84 | |||
85 | CloseDBConnection(cmd); | ||
86 | return ret; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | CloseDBConnection(cmd); | ||
91 | return null; | ||
92 | } | ||
93 | } | 83 | } |
84 | |||
85 | CloseDBConnection(result, cmd); | ||
86 | return ret; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | CloseDBConnection(result, cmd); | ||
91 | return null; | ||
94 | } | 92 | } |
95 | } | 93 | } |
96 | 94 | ||
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index f37e9bc..ccd1ab0 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -40,7 +40,9 @@ 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 | ||
@@ -81,7 +83,8 @@ namespace OpenSim.Data.MySQL | |||
81 | errorSeen = true; | 83 | errorSeen = true; |
82 | 84 | ||
83 | m_Connection.Close(); | 85 | m_Connection.Close(); |
84 | MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); | 86 | MySqlConnection newConnection = |
87 | (MySqlConnection)((ICloneable)m_Connection).Clone(); | ||
85 | m_Connection.Dispose(); | 88 | m_Connection.Dispose(); |
86 | m_Connection = newConnection; | 89 | m_Connection = newConnection; |
87 | m_Connection.Open(); | 90 | m_Connection.Open(); |
@@ -102,15 +105,18 @@ namespace OpenSim.Data.MySQL | |||
102 | 105 | ||
103 | protected IDataReader ExecuteReader(MySqlCommand cmd) | 106 | protected IDataReader ExecuteReader(MySqlCommand cmd) |
104 | { | 107 | { |
105 | MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); | 108 | MySqlConnection newConnection = |
109 | (MySqlConnection)((ICloneable)m_Connection).Clone(); | ||
106 | newConnection.Open(); | 110 | newConnection.Open(); |
107 | 111 | ||
108 | cmd.Connection = newConnection; | 112 | cmd.Connection = newConnection; |
109 | return cmd.ExecuteReader(); | 113 | return cmd.ExecuteReader(); |
110 | } | 114 | } |
111 | 115 | ||
112 | protected void CloseDBConnection(MySqlCommand cmd) | 116 | protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd) |
113 | { | 117 | { |
118 | reader.Close(); | ||
119 | cmd.Connection.Close(); | ||
114 | cmd.Connection.Dispose(); | 120 | cmd.Connection.Dispose(); |
115 | } | 121 | } |
116 | } | 122 | } |
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 3fe27d5..3b561d1 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -173,7 +173,7 @@ namespace OpenSim.Data.MySQL | |||
173 | retList.Add(ret); | 173 | retList.Add(ret); |
174 | } | 174 | } |
175 | 175 | ||
176 | CloseDBConnection(cmd); | 176 | CloseDBConnection(result, cmd); |
177 | } | 177 | } |
178 | 178 | ||
179 | return retList; | 179 | return retList; |
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 38a6f55..0bbc3f5 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs | |||
@@ -64,48 +64,46 @@ 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 | CloseDBConnection(cmd); | ||
101 | return ret; | ||
102 | } | ||
103 | else | ||
104 | { | ||
105 | CloseDBConnection(cmd); | ||
106 | return null; | ||
107 | } | ||
108 | } | 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 | CloseDBConnection(result, cmd); | ||
101 | return ret; | ||
102 | } | ||
103 | else | ||
104 | { | ||
105 | CloseDBConnection(result, cmd); | ||
106 | return null; | ||
109 | } | 107 | } |
110 | } | 108 | } |
111 | 109 | ||