aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs35
-rw-r--r--OpenSim/Data/MySQL/MySQLFramework.cs8
2 files changed, 31 insertions, 12 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index 625d3b1..19575ec 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Data.MySQL
38 public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData 38 public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData
39 { 39 {
40 private string m_Realm; 40 private string m_Realm;
41 private DataTable m_SchemaTable = null; 41 private List<string> m_ColumnNames = null;
42 42
43 public MySqlAuthenticationData(string connectionString, string realm) 43 public MySqlAuthenticationData(string connectionString, string realm)
44 : base(connectionString) 44 : base(connectionString)
@@ -63,15 +63,21 @@ namespace OpenSim.Data.MySQL
63 { 63 {
64 ret.PrincipalID = principalID; 64 ret.PrincipalID = principalID;
65 65
66 if (m_SchemaTable == null) 66 if (m_ColumnNames == null)
67 m_SchemaTable = result.GetSchemaTable(); 67 {
68 m_ColumnNames = new List<string>();
69
70 DataTable schemaTable = result.GetSchemaTable();
71 foreach (DataRow row in schemaTable.Rows)
72 m_ColumnNames.Add(row["ColumnName"].ToString());
73 }
68 74
69 foreach (DataColumn c in m_SchemaTable.Columns) 75 foreach (string s in m_ColumnNames)
70 { 76 {
71 if (c.ColumnName == "UUID") 77 if (s == "UUID")
72 continue; 78 continue;
73 79
74 ret.Data[c.ColumnName] = result[c.ColumnName].ToString(); 80 ret.Data[s] = result[s].ToString();
75 } 81 }
76 82
77 result.Close(); 83 result.Close();
@@ -105,21 +111,23 @@ namespace OpenSim.Data.MySQL
105 111
106 first = false; 112 first = false;
107 113
108 cmd.Parameters.AddWithValue(field, data.Data[field]); 114 cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
109 } 115 }
110 116
111 update += " where UUID = ?principalID"; 117 update += " where UUID = ?principalID";
112 118
113 cmd.CommandText = update; 119 cmd.CommandText = update;
114 cmd.Parameters.AddWithValue("UUID", data.PrincipalID.ToString()); 120 cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
115 121
116 if (ExecuteNonQuery(cmd) < 1) 122 if (ExecuteNonQuery(cmd) < 1)
117 { 123 {
118 string insert = "insert into `" + m_Realm + "` (`UUID`, `" + 124 string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
119 String.Join("`, `", fields) + 125 String.Join("`, `", fields) +
120 "`) values ( ?UUID, ?" + String.Join(", ?", fields) + ")"; 126 "`) values ( ?principalID, ?" + String.Join(", ?", fields) + ")";
121 127
122 if (ExecuteNonQuery(cmd) < 0) 128 cmd.CommandText = insert;
129
130 if (ExecuteNonQuery(cmd) < 1)
123 { 131 {
124 cmd.Dispose(); 132 cmd.Dispose();
125 return false; 133 return false;
@@ -137,8 +145,11 @@ namespace OpenSim.Data.MySQL
137 "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); 145 "` set `" + item + "` = ?" + item + " where UUID = ?UUID");
138 146
139 147
140 cmd.Parameters.AddWithValue(item, value); 148 cmd.Parameters.AddWithValue("?"+item, value);
141 cmd.Parameters.AddWithValue("UUID", principalID.ToString()); 149 cmd.Parameters.AddWithValue("?UUID", principalID.ToString());
150
151 if (ExecuteNonQuery(cmd) > 0)
152 return true;
142 153
143 return false; 154 return false;
144 } 155 }
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs
index f2b31c4..6c73249 100644
--- a/OpenSim/Data/MySQL/MySQLFramework.cs
+++ b/OpenSim/Data/MySQL/MySQLFramework.cs
@@ -70,6 +70,7 @@ namespace OpenSim.Data.MySQL
70 } 70 }
71 catch (MySqlException e) 71 catch (MySqlException e)
72 { 72 {
73Console.WriteLine(e.ToString());
73 if (errorSeen) 74 if (errorSeen)
74 throw; 75 throw;
75 76
@@ -88,6 +89,13 @@ namespace OpenSim.Data.MySQL
88 89
89 cmd.Connection = m_Connection; 90 cmd.Connection = m_Connection;
90 } 91 }
92 else
93 throw;
94 }
95 catch (Exception e)
96 {
97Console.WriteLine(e.ToString());
98 return 0;
91 } 99 }
92 } 100 }
93 } 101 }