* Introduced customizable table names on MySQL and MSSQL UserData plug-ins.
[Provided by openlifegrid.com]ThreadPoolClientBranch
parent
c1044039d4
commit
bcd3a5b28b
|
@ -46,6 +46,10 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MSSQLManager database;
|
public MSSQLManager database;
|
||||||
|
|
||||||
|
private string m_agentsTableName;
|
||||||
|
private string m_usersTableName;
|
||||||
|
private string m_userFriendsTableName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads and initialises the MySQL storage plugin
|
/// Loads and initialises the MySQL storage plugin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -53,12 +57,30 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
{
|
{
|
||||||
// Load from an INI file connection details
|
// Load from an INI file connection details
|
||||||
// TODO: move this to XML?
|
// TODO: move this to XML?
|
||||||
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
|
IniFile iniFile = new IniFile("mssql_connection.ini");
|
||||||
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
|
string settingDataSource = iniFile.ParseFileReadValue("data_source");
|
||||||
string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");
|
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
|
||||||
string settingPersistSecurityInfo = GridDataMySqlFile.ParseFileReadValue("persist_security_info");
|
string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
|
||||||
string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id");
|
string settingUserId = iniFile.ParseFileReadValue("user_id");
|
||||||
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
|
string settingPassword = iniFile.ParseFileReadValue("password");
|
||||||
|
|
||||||
|
m_usersTableName = iniFile.ParseFileReadValue("userstablename");
|
||||||
|
if (m_usersTableName == null)
|
||||||
|
{
|
||||||
|
m_usersTableName = "users";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename");
|
||||||
|
if (m_userFriendsTableName == null)
|
||||||
|
{
|
||||||
|
m_userFriendsTableName = "userfriends";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_agentsTableName = iniFile.ParseFileReadValue("agentstablename");
|
||||||
|
if (m_agentsTableName == null)
|
||||||
|
{
|
||||||
|
m_agentsTableName = "agents";
|
||||||
|
}
|
||||||
|
|
||||||
database =
|
database =
|
||||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||||
|
@ -82,7 +104,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
param["second"] = last;
|
param["second"] = last;
|
||||||
|
|
||||||
IDbCommand result =
|
IDbCommand result =
|
||||||
database.Query("SELECT * FROM users WHERE username = @first AND lastname = @second", param);
|
database.Query("SELECT * FROM "+m_usersTableName+" WHERE username = @first AND lastname = @second", param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
UserProfileData row = database.readUserRow(reader);
|
UserProfileData row = database.readUserRow(reader);
|
||||||
|
@ -150,7 +172,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
|
|
||||||
IDbCommand result =
|
IDbCommand result =
|
||||||
database.Query(
|
database.Query(
|
||||||
"SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second",
|
"SELECT UUID,username,surname FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second",
|
||||||
param);
|
param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
@ -186,7 +208,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
|
|
||||||
IDbCommand result =
|
IDbCommand result =
|
||||||
database.Query(
|
database.Query(
|
||||||
"SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second",
|
"SELECT UUID,username,surname FROM " + m_usersTableName + " WHERE username = @first OR lastname = @second",
|
||||||
param);
|
param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
@ -223,7 +245,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
param["uuid"] = uuid.ToString();
|
param["uuid"] = uuid.ToString();
|
||||||
|
|
||||||
IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = @uuid", param);
|
IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = @uuid", param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
UserProfileData row = database.readUserRow(reader);
|
UserProfileData row = database.readUserRow(reader);
|
||||||
|
@ -278,7 +300,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
param["uuid"] = uuid.ToString();
|
param["uuid"] = uuid.ToString();
|
||||||
|
|
||||||
IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = @uuid", param);
|
IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = @uuid", param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
UserAgentData row = database.readAgentRow(reader);
|
UserAgentData row = database.readAgentRow(reader);
|
||||||
|
@ -342,7 +364,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
|
|
||||||
public bool UpdateUserProfile(UserProfileData user)
|
public bool UpdateUserProfile(UserProfileData user)
|
||||||
{
|
{
|
||||||
SqlCommand command = new SqlCommand("UPDATE users set UUID = @uuid, " +
|
SqlCommand command = new SqlCommand("UPDATE " + m_usersTableName + " set UUID = @uuid, " +
|
||||||
"username = @username, " +
|
"username = @username, " +
|
||||||
"lastname = @lastname," +
|
"lastname = @lastname," +
|
||||||
"passwordHash = @passwordHash," +
|
"passwordHash = @passwordHash," +
|
||||||
|
|
|
@ -200,8 +200,10 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
string tableName = (string) tables["TABLE_NAME"];
|
string tableName = (string) tables["TABLE_NAME"];
|
||||||
string comment = (string) tables["TABLE_COMMENT"];
|
string comment = (string) tables["TABLE_COMMENT"];
|
||||||
if (tableList.ContainsKey(tableName))
|
if (tableList.ContainsKey(tableName))
|
||||||
|
{
|
||||||
tableList[tableName] = comment;
|
tableList[tableName] = comment;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.Error(e.ToString());
|
m_log.Error(e.ToString());
|
||||||
|
|
|
@ -46,20 +46,43 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MySQLManager database;
|
public MySQLManager database;
|
||||||
|
|
||||||
|
private string m_agentsTableName;
|
||||||
|
private string m_usersTableName;
|
||||||
|
private string m_userFriendsTableName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads and initialises the MySQL storage plugin
|
/// Loads and initialises the MySQL storage plugin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialise()
|
public void Initialise()
|
||||||
{
|
{
|
||||||
// Load from an INI file connection details
|
// Load from an INI file connection details
|
||||||
// TODO: move this to XML?
|
// TODO: move this to XML? Yes, PLEASE!
|
||||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
|
||||||
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
IniFile iniFile = new IniFile("mysql_connection.ini");
|
||||||
string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
|
string settingHostname = iniFile.ParseFileReadValue("hostname");
|
||||||
string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
|
string settingDatabase = iniFile.ParseFileReadValue("database");
|
||||||
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
|
string settingUsername = iniFile.ParseFileReadValue("username");
|
||||||
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
|
string settingPassword = iniFile.ParseFileReadValue("password");
|
||||||
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
|
string settingPooling = iniFile.ParseFileReadValue("pooling");
|
||||||
|
string settingPort = iniFile.ParseFileReadValue("port");
|
||||||
|
|
||||||
|
m_usersTableName = iniFile.ParseFileReadValue("userstablename");
|
||||||
|
if( m_usersTableName == null )
|
||||||
|
{
|
||||||
|
m_usersTableName = "users";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_userFriendsTableName = iniFile.ParseFileReadValue("userfriendstablename");
|
||||||
|
if (m_userFriendsTableName == null)
|
||||||
|
{
|
||||||
|
m_userFriendsTableName = "userfriends";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_agentsTableName = iniFile.ParseFileReadValue("agentstablename");
|
||||||
|
if (m_agentsTableName == null)
|
||||||
|
{
|
||||||
|
m_agentsTableName = "agents";
|
||||||
|
}
|
||||||
|
|
||||||
database =
|
database =
|
||||||
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
|
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
|
||||||
|
@ -77,14 +100,14 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
||||||
|
|
||||||
tableList["agents"] = null;
|
tableList[m_agentsTableName] = null;
|
||||||
tableList["users"] = null;
|
tableList[m_usersTableName] = null;
|
||||||
tableList["userfriends"] = null;
|
tableList[m_userFriendsTableName] = null;
|
||||||
database.GetTableVersion(tableList);
|
database.GetTableVersion(tableList);
|
||||||
|
|
||||||
UpgradeAgentsTable(tableList["agents"]);
|
UpgradeAgentsTable(tableList[m_agentsTableName]);
|
||||||
UpgradeUsersTable(tableList["users"]);
|
UpgradeUsersTable(tableList[m_usersTableName]);
|
||||||
UpgradeFriendsTable(tableList["userfriends"]);
|
UpgradeFriendsTable(tableList[m_userFriendsTableName]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +176,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
param["?second"] = last;
|
param["?second"] = last;
|
||||||
|
|
||||||
IDbCommand result =
|
IDbCommand result =
|
||||||
database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param);
|
database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
UserProfileData row = database.readUserRow(reader);
|
UserProfileData row = database.readUserRow(reader);
|
||||||
|
@ -189,7 +212,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
IDbCommand adder =
|
IDbCommand adder =
|
||||||
database.Query(
|
database.Query(
|
||||||
"INSERT INTO `userfriends` " +
|
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
||||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
||||||
"VALUES " +
|
"VALUES " +
|
||||||
"(?ownerID,?friendID,?friendPerms,?datetimestamp)",
|
"(?ownerID,?friendID,?friendPerms,?datetimestamp)",
|
||||||
|
@ -198,7 +221,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
|
|
||||||
adder =
|
adder =
|
||||||
database.Query(
|
database.Query(
|
||||||
"INSERT INTO `userfriends` " +
|
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
||||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
||||||
"VALUES " +
|
"VALUES " +
|
||||||
"(?friendID,?ownerID,?friendPerms,?datetimestamp)",
|
"(?friendID,?ownerID,?friendPerms,?datetimestamp)",
|
||||||
|
@ -228,15 +251,13 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
IDbCommand updater =
|
IDbCommand updater =
|
||||||
database.Query(
|
database.Query(
|
||||||
"delete from userfriends " +
|
"delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID",
|
||||||
"where ownerID = ?ownerID and friendID = ?friendID",
|
|
||||||
param);
|
param);
|
||||||
updater.ExecuteNonQuery();
|
updater.ExecuteNonQuery();
|
||||||
|
|
||||||
updater =
|
updater =
|
||||||
database.Query(
|
database.Query(
|
||||||
"delete from userfriends " +
|
"delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID",
|
||||||
"where ownerID = ?friendID and friendID = ?ownerID",
|
|
||||||
param);
|
param);
|
||||||
updater.ExecuteNonQuery();
|
updater.ExecuteNonQuery();
|
||||||
|
|
||||||
|
@ -263,8 +284,8 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
IDbCommand updater =
|
IDbCommand updater =
|
||||||
database.Query(
|
database.Query(
|
||||||
"update userfriends " +
|
"update " + m_userFriendsTableName +
|
||||||
"SET friendPerms = ?friendPerms " +
|
" SET friendPerms = ?friendPerms " +
|
||||||
"where ownerID = ?ownerID and friendID = ?friendID",
|
"where ownerID = ?ownerID and friendID = ?friendID",
|
||||||
param);
|
param);
|
||||||
updater.ExecuteNonQuery();
|
updater.ExecuteNonQuery();
|
||||||
|
@ -294,7 +315,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
//Left Join userfriends to itself
|
//Left Join userfriends to itself
|
||||||
IDbCommand result =
|
IDbCommand result =
|
||||||
database.Query(
|
database.Query(
|
||||||
"select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from userfriends as a, userfriends as b" +
|
"select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
|
||||||
" where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
|
" where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
|
||||||
param);
|
param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
@ -353,7 +374,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
IDbCommand result =
|
IDbCommand result =
|
||||||
database.Query(
|
database.Query(
|
||||||
"SELECT UUID,username,lastname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100",
|
"SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first AND lastname like ?second LIMIT 100",
|
||||||
param);
|
param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
@ -388,7 +409,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
|
|
||||||
IDbCommand result =
|
IDbCommand result =
|
||||||
database.Query(
|
database.Query(
|
||||||
"SELECT UUID,username,lastname FROM users WHERE username like ?first OR lastname like ?first LIMIT 100",
|
"SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username like ?first OR lastname like ?first LIMIT 100",
|
||||||
param);
|
param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
|
@ -425,7 +446,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
param["?uuid"] = uuid.ToString();
|
param["?uuid"] = uuid.ToString();
|
||||||
|
|
||||||
IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param);
|
IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
UserProfileData row = database.readUserRow(reader);
|
UserProfileData row = database.readUserRow(reader);
|
||||||
|
@ -479,8 +500,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
{
|
{
|
||||||
IDbCommand updater =
|
IDbCommand updater =
|
||||||
database.Query(
|
database.Query(
|
||||||
"update users " +
|
"update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
|
||||||
"SET webLoginKey = ?webLoginKey " +
|
|
||||||
"where UUID = ?UUID",
|
"where UUID = ?UUID",
|
||||||
param);
|
param);
|
||||||
updater.ExecuteNonQuery();
|
updater.ExecuteNonQuery();
|
||||||
|
@ -513,7 +533,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||||
param["?uuid"] = uuid.ToString();
|
param["?uuid"] = uuid.ToString();
|
||||||
|
|
||||||
IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param);
|
IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param);
|
||||||
IDataReader reader = result.ExecuteReader();
|
IDataReader reader = result.ExecuteReader();
|
||||||
|
|
||||||
UserAgentData row = database.readAgentRow(reader);
|
UserAgentData row = database.readAgentRow(reader);
|
||||||
|
|
|
@ -76,8 +76,12 @@ physical_prim = true
|
||||||
accounts_authenticate = true
|
accounts_authenticate = true
|
||||||
welcome_message = "Welcome to OpenSim"
|
welcome_message = "Welcome to OpenSim"
|
||||||
inventory_plugin = "OpenSim.Framework.Data.SQLite.dll"
|
inventory_plugin = "OpenSim.Framework.Data.SQLite.dll"
|
||||||
|
|
||||||
|
; User Data Database provider
|
||||||
; userDatabase_plugin = "OpenSim.Framework.Data.DB4o.dll"
|
; userDatabase_plugin = "OpenSim.Framework.Data.DB4o.dll"
|
||||||
|
; userDatabase_plugin = "OpenSim.Framework.Data.MySQL.dll"
|
||||||
userDatabase_plugin = "OpenSim.Framework.Data.SQLite.dll"
|
userDatabase_plugin = "OpenSim.Framework.Data.SQLite.dll"
|
||||||
|
|
||||||
default_location_x = 1000
|
default_location_x = 1000
|
||||||
default_location_y = 1000
|
default_location_y = 1000
|
||||||
dump_assets_to_file = false
|
dump_assets_to_file = false
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
|
; The IniConfig.cs that parses this file by just finding the first key={value} in the whole text so comments aren't really honoured.
|
||||||
|
; Also, this algorithm can probably lead to 'amusing' results in unfortunate cases.
|
||||||
|
|
||||||
[mssqlconnection]
|
[mssqlconnection]
|
||||||
data_source=\SQLEXPRESS
|
data_source=\SQLEXPRESS
|
||||||
initial_catalog=database
|
initial_catalog=database
|
||||||
persist_security_info=True
|
persist_security_info=True
|
||||||
user_id=username
|
user_id=username
|
||||||
password=password
|
password=password
|
||||||
|
|
||||||
|
; These entries are only for if you, for some reason, wish to customize your user server table names.
|
||||||
|
; If ommitted, default values will be used.
|
||||||
|
|
||||||
|
userstablename=users
|
||||||
|
userfriendstablename=userfriends
|
||||||
|
agentstablename=agents
|
|
@ -1,3 +1,6 @@
|
||||||
|
; The IniConfig.cs that parses this file by just finding the first key={value} in the whole text so comments aren't really honoured.
|
||||||
|
; Also, this algorithm can probably lead to 'amusing' results in unfortunate cases.
|
||||||
|
|
||||||
[mysqlconnection]
|
[mysqlconnection]
|
||||||
hostname=localhost
|
hostname=localhost
|
||||||
database=database
|
database=database
|
||||||
|
@ -5,3 +8,10 @@ username=username
|
||||||
password=password
|
password=password
|
||||||
pooling=false
|
pooling=false
|
||||||
port=3306
|
port=3306
|
||||||
|
|
||||||
|
; These entries are only for if you, for some reason, wish to customize your user server table names.
|
||||||
|
; If ommitted, default values will be used.
|
||||||
|
|
||||||
|
userstablename=users
|
||||||
|
userfriendstablename=userfriends
|
||||||
|
agentstablename=agents
|
||||||
|
|
Loading…
Reference in New Issue