aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs46
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLManager.cs2
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLUserData.cs80
-rw-r--r--bin/OpenSim.ini.example4
-rw-r--r--bin/mssql_connection.ini.example10
-rw-r--r--bin/mysql_connection.ini.example10
6 files changed, 110 insertions, 42 deletions
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
index ed9929c..60e6df4 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
@@ -46,6 +46,10 @@ namespace OpenSim.Framework.Data.MSSQL
46 /// </summary> 46 /// </summary>
47 public MSSQLManager database; 47 public MSSQLManager 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>
@@ -53,12 +57,30 @@ namespace OpenSim.Framework.Data.MSSQL
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?
56 IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini"); 60 IniFile iniFile = new IniFile("mssql_connection.ini");
57 string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source"); 61 string settingDataSource = iniFile.ParseFileReadValue("data_source");
58 string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog"); 62 string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
59 string settingPersistSecurityInfo = GridDataMySqlFile.ParseFileReadValue("persist_security_info"); 63 string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
60 string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); 64 string settingUserId = iniFile.ParseFileReadValue("user_id");
61 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); 65 string settingPassword = iniFile.ParseFileReadValue("password");
66
67 m_usersTableName = iniFile.ParseFileReadValue("userstablename");
68 if (m_usersTableName == null)
69 {
70 m_usersTableName = "users";
71 }
72
73 m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename");
74 if (m_userFriendsTableName == null)
75 {
76 m_userFriendsTableName = "userfriends";
77 }
78
79 m_agentsTableName = iniFile.ParseFileReadValue("agentstablename");
80 if (m_agentsTableName == null)
81 {
82 m_agentsTableName = "agents";
83 }
62 84
63 database = 85 database =
64 new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, 86 new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
@@ -82,7 +104,7 @@ namespace OpenSim.Framework.Data.MSSQL
82 param["second"] = last; 104 param["second"] = last;
83 105
84 IDbCommand result = 106 IDbCommand result =
85 database.Query("SELECT * FROM users WHERE username = @first AND lastname = @second", param); 107 database.Query("SELECT * FROM "+m_usersTableName+" WHERE username = @first AND lastname = @second", param);
86 IDataReader reader = result.ExecuteReader(); 108 IDataReader reader = result.ExecuteReader();
87 109
88 UserProfileData row = database.readUserRow(reader); 110 UserProfileData row = database.readUserRow(reader);
@@ -150,7 +172,7 @@ namespace OpenSim.Framework.Data.MSSQL
150 172
151 IDbCommand result = 173 IDbCommand result =
152 database.Query( 174 database.Query(
153 "SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second", 175 "SELECT UUID,username,surname FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second",
154 param); 176 param);
155 IDataReader reader = result.ExecuteReader(); 177 IDataReader reader = result.ExecuteReader();
156 178
@@ -186,7 +208,7 @@ namespace OpenSim.Framework.Data.MSSQL
186 208
187 IDbCommand result = 209 IDbCommand result =
188 database.Query( 210 database.Query(
189 "SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second", 211 "SELECT UUID,username,surname FROM " + m_usersTableName + " WHERE username = @first OR lastname = @second",
190 param); 212 param);
191 IDataReader reader = result.ExecuteReader(); 213 IDataReader reader = result.ExecuteReader();
192 214
@@ -223,7 +245,7 @@ namespace OpenSim.Framework.Data.MSSQL
223 Dictionary<string, string> param = new Dictionary<string, string>(); 245 Dictionary<string, string> param = new Dictionary<string, string>();
224 param["uuid"] = uuid.ToString(); 246 param["uuid"] = uuid.ToString();
225 247
226 IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = @uuid", param); 248 IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = @uuid", param);
227 IDataReader reader = result.ExecuteReader(); 249 IDataReader reader = result.ExecuteReader();
228 250
229 UserProfileData row = database.readUserRow(reader); 251 UserProfileData row = database.readUserRow(reader);
@@ -278,7 +300,7 @@ namespace OpenSim.Framework.Data.MSSQL
278 Dictionary<string, string> param = new Dictionary<string, string>(); 300 Dictionary<string, string> param = new Dictionary<string, string>();
279 param["uuid"] = uuid.ToString(); 301 param["uuid"] = uuid.ToString();
280 302
281 IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = @uuid", param); 303 IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = @uuid", param);
282 IDataReader reader = result.ExecuteReader(); 304 IDataReader reader = result.ExecuteReader();
283 305
284 UserAgentData row = database.readAgentRow(reader); 306 UserAgentData row = database.readAgentRow(reader);
@@ -342,7 +364,7 @@ namespace OpenSim.Framework.Data.MSSQL
342 364
343 public bool UpdateUserProfile(UserProfileData user) 365 public bool UpdateUserProfile(UserProfileData user)
344 { 366 {
345 SqlCommand command = new SqlCommand("UPDATE users set UUID = @uuid, " + 367 SqlCommand command = new SqlCommand("UPDATE " + m_usersTableName + " set UUID = @uuid, " +
346 "username = @username, " + 368 "username = @username, " +
347 "lastname = @lastname," + 369 "lastname = @lastname," +
348 "passwordHash = @passwordHash," + 370 "passwordHash = @passwordHash," +
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);
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index ce2f02e..2297fc4 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -76,8 +76,12 @@ physical_prim = true
76accounts_authenticate = true 76accounts_authenticate = true
77welcome_message = "Welcome to OpenSim" 77welcome_message = "Welcome to OpenSim"
78inventory_plugin = "OpenSim.Framework.Data.SQLite.dll" 78inventory_plugin = "OpenSim.Framework.Data.SQLite.dll"
79
80; User Data Database provider
79; userDatabase_plugin = "OpenSim.Framework.Data.DB4o.dll" 81; userDatabase_plugin = "OpenSim.Framework.Data.DB4o.dll"
82; userDatabase_plugin = "OpenSim.Framework.Data.MySQL.dll"
80userDatabase_plugin = "OpenSim.Framework.Data.SQLite.dll" 83userDatabase_plugin = "OpenSim.Framework.Data.SQLite.dll"
84
81default_location_x = 1000 85default_location_x = 1000
82default_location_y = 1000 86default_location_y = 1000
83dump_assets_to_file = false 87dump_assets_to_file = false
diff --git a/bin/mssql_connection.ini.example b/bin/mssql_connection.ini.example
index c63d008..ceb277f 100644
--- a/bin/mssql_connection.ini.example
+++ b/bin/mssql_connection.ini.example
@@ -1,6 +1,16 @@
1; The IniConfig.cs that parses this file by just finding the first key={value} in the whole text so comments aren't really honoured.
2; Also, this algorithm can probably lead to 'amusing' results in unfortunate cases.
3
1[mssqlconnection] 4[mssqlconnection]
2data_source=\SQLEXPRESS 5data_source=\SQLEXPRESS
3initial_catalog=database 6initial_catalog=database
4persist_security_info=True 7persist_security_info=True
5user_id=username 8user_id=username
6password=password 9password=password
10
11; These entries are only for if you, for some reason, wish to customize your user server table names.
12; If ommitted, default values will be used.
13
14userstablename=users
15userfriendstablename=userfriends
16agentstablename=agents \ No newline at end of file
diff --git a/bin/mysql_connection.ini.example b/bin/mysql_connection.ini.example
index 7933bed..2fe469c 100644
--- a/bin/mysql_connection.ini.example
+++ b/bin/mysql_connection.ini.example
@@ -1,3 +1,6 @@
1; The IniConfig.cs that parses this file by just finding the first key={value} in the whole text so comments aren't really honoured.
2; Also, this algorithm can probably lead to 'amusing' results in unfortunate cases.
3
1[mysqlconnection] 4[mysqlconnection]
2hostname=localhost 5hostname=localhost
3database=database 6database=database
@@ -5,3 +8,10 @@ username=username
5password=password 8password=password
6pooling=false 9pooling=false
7port=3306 10port=3306
11
12; These entries are only for if you, for some reason, wish to customize your user server table names.
13; If ommitted, default values will be used.
14
15userstablename=users
16userfriendstablename=userfriends
17agentstablename=agents