diff options
author | lbsa71 | 2008-02-13 12:06:09 +0000 |
---|---|---|
committer | lbsa71 | 2008-02-13 12:06:09 +0000 |
commit | bcd3a5b28bc63426e5ac1f4642afca4a391ece28 (patch) | |
tree | d38441c04425259fe450d062e7be25c90ae7cb09 /OpenSim/Framework/Data.MySQL | |
parent | * Removed a debug line that got called every frame. (diff) | |
download | opensim-SC_OLD-bcd3a5b28bc63426e5ac1f4642afca4a391ece28.zip opensim-SC_OLD-bcd3a5b28bc63426e5ac1f4642afca4a391ece28.tar.gz opensim-SC_OLD-bcd3a5b28bc63426e5ac1f4642afca4a391ece28.tar.bz2 opensim-SC_OLD-bcd3a5b28bc63426e5ac1f4642afca4a391ece28.tar.xz |
* Introduced customizable table names on MySQL and MSSQL UserData plug-ins.
[Provided by openlifegrid.com]
Diffstat (limited to 'OpenSim/Framework/Data.MySQL')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLManager.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 80 |
2 files changed, 52 insertions, 30 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index e763bfa..0ec976c 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs | |||
@@ -200,7 +200,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
200 | string tableName = (string) tables["TABLE_NAME"]; | 200 | string tableName = (string) tables["TABLE_NAME"]; |
201 | string comment = (string) tables["TABLE_COMMENT"]; | 201 | string comment = (string) tables["TABLE_COMMENT"]; |
202 | if (tableList.ContainsKey(tableName)) | 202 | if (tableList.ContainsKey(tableName)) |
203 | { | ||
203 | tableList[tableName] = comment; | 204 | tableList[tableName] = comment; |
205 | } | ||
204 | } | 206 | } |
205 | catch (Exception e) | 207 | catch (Exception e) |
206 | { | 208 | { |
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 0db727c..bc18376 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs | |||
@@ -46,20 +46,43 @@ namespace OpenSim.Framework.Data.MySQL | |||
46 | /// </summary> | 46 | /// </summary> |
47 | public MySQLManager database; | 47 | public MySQLManager database; |
48 | 48 | ||
49 | private string m_agentsTableName; | ||
50 | private string m_usersTableName; | ||
51 | private string m_userFriendsTableName; | ||
52 | |||
49 | /// <summary> | 53 | /// <summary> |
50 | /// Loads and initialises the MySQL storage plugin | 54 | /// Loads and initialises the MySQL storage plugin |
51 | /// </summary> | 55 | /// </summary> |
52 | public void Initialise() | 56 | public void Initialise() |
53 | { | 57 | { |
54 | // Load from an INI file connection details | 58 | // Load from an INI file connection details |
55 | // TODO: move this to XML? | 59 | // TODO: move this to XML? Yes, PLEASE! |
56 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | 60 | |
57 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | 61 | IniFile iniFile = new IniFile("mysql_connection.ini"); |
58 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | 62 | string settingHostname = iniFile.ParseFileReadValue("hostname"); |
59 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | 63 | string settingDatabase = iniFile.ParseFileReadValue("database"); |
60 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | 64 | string settingUsername = iniFile.ParseFileReadValue("username"); |
61 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 65 | string settingPassword = iniFile.ParseFileReadValue("password"); |
62 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 66 | string settingPooling = iniFile.ParseFileReadValue("pooling"); |
67 | string settingPort = iniFile.ParseFileReadValue("port"); | ||
68 | |||
69 | m_usersTableName = iniFile.ParseFileReadValue("userstablename"); | ||
70 | if( m_usersTableName == null ) | ||
71 | { | ||
72 | m_usersTableName = "users"; | ||
73 | } | ||
74 | |||
75 | m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename"); | ||
76 | if (m_userFriendsTableName == null) | ||
77 | { | ||
78 | m_userFriendsTableName = "userfriends"; | ||
79 | } | ||
80 | |||
81 | m_agentsTableName = iniFile.ParseFileReadValue("agentstablename"); | ||
82 | if (m_agentsTableName == null) | ||
83 | { | ||
84 | m_agentsTableName = "agents"; | ||
85 | } | ||
63 | 86 | ||
64 | database = | 87 | database = |
65 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, | 88 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, |
@@ -77,14 +100,14 @@ namespace OpenSim.Framework.Data.MySQL | |||
77 | { | 100 | { |
78 | Dictionary<string, string> tableList = new Dictionary<string, string>(); | 101 | Dictionary<string, string> tableList = new Dictionary<string, string>(); |
79 | 102 | ||
80 | tableList["agents"] = null; | 103 | tableList[m_agentsTableName] = null; |
81 | tableList["users"] = null; | 104 | tableList[m_usersTableName] = null; |
82 | tableList["userfriends"] = null; | 105 | tableList[m_userFriendsTableName] = null; |
83 | database.GetTableVersion(tableList); | 106 | database.GetTableVersion(tableList); |
84 | 107 | ||
85 | UpgradeAgentsTable(tableList["agents"]); | 108 | UpgradeAgentsTable(tableList[m_agentsTableName]); |
86 | UpgradeUsersTable(tableList["users"]); | 109 | UpgradeUsersTable(tableList[m_usersTableName]); |
87 | UpgradeFriendsTable(tableList["userfriends"]); | 110 | UpgradeFriendsTable(tableList[m_userFriendsTableName]); |
88 | 111 | ||
89 | } | 112 | } |
90 | 113 | ||
@@ -153,7 +176,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
153 | param["?second"] = last; | 176 | param["?second"] = last; |
154 | 177 | ||
155 | IDbCommand result = | 178 | IDbCommand result = |
156 | database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param); | 179 | database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); |
157 | IDataReader reader = result.ExecuteReader(); | 180 | IDataReader reader = result.ExecuteReader(); |
158 | 181 | ||
159 | UserProfileData row = database.readUserRow(reader); | 182 | UserProfileData row = database.readUserRow(reader); |
@@ -189,7 +212,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
189 | { | 212 | { |
190 | IDbCommand adder = | 213 | IDbCommand adder = |
191 | database.Query( | 214 | database.Query( |
192 | "INSERT INTO `userfriends` " + | 215 | "INSERT INTO `" + m_userFriendsTableName + "` " + |
193 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | 216 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + |
194 | "VALUES " + | 217 | "VALUES " + |
195 | "(?ownerID,?friendID,?friendPerms,?datetimestamp)", | 218 | "(?ownerID,?friendID,?friendPerms,?datetimestamp)", |
@@ -198,7 +221,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
198 | 221 | ||
199 | adder = | 222 | adder = |
200 | database.Query( | 223 | database.Query( |
201 | "INSERT INTO `userfriends` " + | 224 | "INSERT INTO `" + m_userFriendsTableName + "` " + |
202 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + | 225 | "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + |
203 | "VALUES " + | 226 | "VALUES " + |
204 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", | 227 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", |
@@ -228,15 +251,13 @@ namespace OpenSim.Framework.Data.MySQL | |||
228 | { | 251 | { |
229 | IDbCommand updater = | 252 | IDbCommand updater = |
230 | database.Query( | 253 | database.Query( |
231 | "delete from userfriends " + | 254 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", |
232 | "where ownerID = ?ownerID and friendID = ?friendID", | ||
233 | param); | 255 | param); |
234 | updater.ExecuteNonQuery(); | 256 | updater.ExecuteNonQuery(); |
235 | 257 | ||
236 | updater = | 258 | updater = |
237 | database.Query( | 259 | database.Query( |
238 | "delete from userfriends " + | 260 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", |
239 | "where ownerID = ?friendID and friendID = ?ownerID", | ||
240 | param); | 261 | param); |
241 | updater.ExecuteNonQuery(); | 262 | updater.ExecuteNonQuery(); |
242 | 263 | ||
@@ -263,8 +284,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
263 | { | 284 | { |
264 | IDbCommand updater = | 285 | IDbCommand updater = |
265 | database.Query( | 286 | database.Query( |
266 | "update userfriends " + | 287 | "update " + m_userFriendsTableName + |
267 | "SET friendPerms = ?friendPerms " + | 288 | " SET friendPerms = ?friendPerms " + |
268 | "where ownerID = ?ownerID and friendID = ?friendID", | 289 | "where ownerID = ?ownerID and friendID = ?friendID", |
269 | param); | 290 | param); |
270 | updater.ExecuteNonQuery(); | 291 | updater.ExecuteNonQuery(); |
@@ -294,7 +315,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
294 | //Left Join userfriends to itself | 315 | //Left Join userfriends to itself |
295 | IDbCommand result = | 316 | IDbCommand result = |
296 | database.Query( | 317 | database.Query( |
297 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from userfriends as a, userfriends as b" + | 318 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + |
298 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", | 319 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", |
299 | param); | 320 | param); |
300 | IDataReader reader = result.ExecuteReader(); | 321 | IDataReader reader = result.ExecuteReader(); |
@@ -353,7 +374,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
353 | { | 374 | { |
354 | IDbCommand result = | 375 | IDbCommand result = |
355 | database.Query( | 376 | database.Query( |
356 | "SELECT UUID,username,lastname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", | 377 | "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first AND lastname like ?second LIMIT 100", |
357 | param); | 378 | param); |
358 | IDataReader reader = result.ExecuteReader(); | 379 | IDataReader reader = result.ExecuteReader(); |
359 | 380 | ||
@@ -388,7 +409,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
388 | 409 | ||
389 | IDbCommand result = | 410 | IDbCommand result = |
390 | database.Query( | 411 | database.Query( |
391 | "SELECT UUID,username,lastname FROM users WHERE username like ?first OR lastname like ?first LIMIT 100", | 412 | "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first OR lastname like ?first LIMIT 100", |
392 | param); | 413 | param); |
393 | IDataReader reader = result.ExecuteReader(); | 414 | IDataReader reader = result.ExecuteReader(); |
394 | 415 | ||
@@ -425,7 +446,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
425 | Dictionary<string, string> param = new Dictionary<string, string>(); | 446 | Dictionary<string, string> param = new Dictionary<string, string>(); |
426 | param["?uuid"] = uuid.ToString(); | 447 | param["?uuid"] = uuid.ToString(); |
427 | 448 | ||
428 | IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param); | 449 | IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); |
429 | IDataReader reader = result.ExecuteReader(); | 450 | IDataReader reader = result.ExecuteReader(); |
430 | 451 | ||
431 | UserProfileData row = database.readUserRow(reader); | 452 | UserProfileData row = database.readUserRow(reader); |
@@ -479,8 +500,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
479 | { | 500 | { |
480 | IDbCommand updater = | 501 | IDbCommand updater = |
481 | database.Query( | 502 | database.Query( |
482 | "update users " + | 503 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + |
483 | "SET webLoginKey = ?webLoginKey " + | ||
484 | "where UUID = ?UUID", | 504 | "where UUID = ?UUID", |
485 | param); | 505 | param); |
486 | updater.ExecuteNonQuery(); | 506 | updater.ExecuteNonQuery(); |
@@ -513,7 +533,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
513 | Dictionary<string, string> param = new Dictionary<string, string>(); | 533 | Dictionary<string, string> param = new Dictionary<string, string>(); |
514 | param["?uuid"] = uuid.ToString(); | 534 | param["?uuid"] = uuid.ToString(); |
515 | 535 | ||
516 | IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param); | 536 | IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param); |
517 | IDataReader reader = result.ExecuteReader(); | 537 | IDataReader reader = result.ExecuteReader(); |
518 | 538 | ||
519 | UserAgentData row = database.readAgentRow(reader); | 539 | UserAgentData row = database.readAgentRow(reader); |