Mantis #2124
Thank you, RuudL, for a patch that brings MSSQL up to the same implementation level as MySQL.0.6.0-stable
parent
3476dd56ea
commit
2819559499
|
@ -39,6 +39,7 @@ namespace OpenSim.Data
|
|||
public abstract DataResponse AddProfile(RegionProfileData profile);
|
||||
public abstract ReservationData GetReservationAtPoint(uint x, uint y);
|
||||
public abstract DataResponse UpdateProfile(RegionProfileData profile);
|
||||
public abstract DataResponse DeleteProfile(string uuid);
|
||||
|
||||
public abstract void Initialise();
|
||||
public abstract void Initialise(string connect);
|
||||
|
|
|
@ -96,8 +96,26 @@ namespace OpenSim.Data
|
|||
/// <returns>RESPONSE_OK if successful, error if not.</returns>
|
||||
DataResponse AddProfile(RegionProfileData profile);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a profile in the database
|
||||
/// </summary>
|
||||
/// <param name="profile"></param>
|
||||
/// <returns></returns>
|
||||
DataResponse UpdateProfile(RegionProfileData profile);
|
||||
|
||||
/// <summary>
|
||||
/// Remove a profile from the database
|
||||
/// </summary>
|
||||
/// <param name="UUID">ID of profile to remove</param>
|
||||
/// <returns></returns>
|
||||
DataResponse DeleteProfile(string UUID);
|
||||
|
||||
/// <summary>
|
||||
/// Function not used????
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns></returns>
|
||||
ReservationData GetReservationAtPoint(uint x, uint y);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
|
||||
|
@ -163,16 +160,22 @@ namespace OpenSim.Data.MSSQL
|
|||
realCommand.Prepare();
|
||||
}
|
||||
|
||||
IDbTransaction IDbCommand.Transaction
|
||||
// IDbTransaction IDbCommand.Transaction
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return realCommand.Transaction;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// realCommand.Transaction = (SqlTransaction) value;
|
||||
// }
|
||||
// }
|
||||
|
||||
public IDbTransaction Transaction
|
||||
{
|
||||
get
|
||||
{
|
||||
return realCommand.Transaction;
|
||||
}
|
||||
set
|
||||
{
|
||||
realCommand.Transaction = (SqlTransaction) value;
|
||||
}
|
||||
get { return realCommand.Transaction; }
|
||||
set { realCommand.Transaction = (SqlTransaction)value; }
|
||||
}
|
||||
|
||||
UpdateRowSource IDbCommand.UpdatedRowSource
|
||||
|
|
|
@ -41,44 +41,83 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
internal class MSSQLAssetData : AssetDataBase
|
||||
{
|
||||
private const string _migrationStore = "AssetStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Database manager
|
||||
/// </summary>
|
||||
private MSSQLManager database;
|
||||
|
||||
#region IAssetProviderPlugin Members
|
||||
#region IPlugin Members
|
||||
|
||||
override public void Dispose() { }
|
||||
|
||||
/// <summary>
|
||||
/// Migration method
|
||||
/// <list type="bullet">
|
||||
/// <item>Execute "CreateAssetsTable.sql" if tableName == null</item>
|
||||
/// </list>
|
||||
/// <para>Initialises asset interface</para>
|
||||
/// </summary>
|
||||
/// <param name="tableName">Name of table</param>
|
||||
private void UpgradeAssetsTable(string tableName)
|
||||
override public void Initialise()
|
||||
{
|
||||
// null as the version, indicates that the table didn't exist
|
||||
if (tableName == null)
|
||||
m_log.Info("[MSSQLUserData]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises asset interface
|
||||
/// </summary>
|
||||
/// <para>
|
||||
/// a string instead of file, if someone writes the support
|
||||
/// </para>
|
||||
/// <param name="connectionString">connect string</param>
|
||||
override public void Initialise(string connectionString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
m_log.Info("[ASSET DB]: Creating new database tables");
|
||||
database.ExecuteResourceSql("CreateAssetsTable.sql");
|
||||
return;
|
||||
database = new MSSQLManager(connectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
|
||||
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
}
|
||||
|
||||
//TODO can be removed at some time!!
|
||||
TestTables();
|
||||
|
||||
//New migration to check for DB changes
|
||||
database.CheckMigration(_migrationStore);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure that the assets related tables exists and are at the latest version
|
||||
/// Database provider version.
|
||||
/// </summary>
|
||||
private void TestTables()
|
||||
override public string Version
|
||||
{
|
||||
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
||||
|
||||
tableList["assets"] = null;
|
||||
database.GetTableVersion(tableList);
|
||||
|
||||
UpgradeAssetsTable(tableList["assets"]);
|
||||
get { return database.getVersion(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of this DB provider.
|
||||
/// </summary>
|
||||
override public string Name
|
||||
{
|
||||
get { return "MSSQL Asset storage engine"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAssetProviderPlugin Members
|
||||
|
||||
/// <summary>
|
||||
/// Fetch Asset from database
|
||||
/// </summary>
|
||||
|
@ -86,13 +125,26 @@ namespace OpenSim.Data.MSSQL
|
|||
/// <returns></returns>
|
||||
override public AssetBase FetchAsset(UUID assetID)
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["id"] = assetID.ToString();
|
||||
|
||||
using (IDbCommand result = database.Query("SELECT * FROM assets WHERE id = @id", param))
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM assets WHERE id = @id"))
|
||||
{
|
||||
return database.getAssetRow(reader);
|
||||
command.Parameters.Add(database.CreateParameter("id", assetID));
|
||||
using (IDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
AssetBase asset = new AssetBase();
|
||||
// Region Main
|
||||
asset.FullID = new UUID((string)reader["id"]);
|
||||
asset.Name = (string)reader["name"];
|
||||
asset.Description = (string)reader["description"];
|
||||
asset.Type = Convert.ToSByte(reader["assetType"]);
|
||||
asset.Local = Convert.ToBoolean(reader["local"]);
|
||||
asset.Temporary = Convert.ToBoolean(reader["temporary"]);
|
||||
asset.Data = (byte[])reader["data"];
|
||||
return asset;
|
||||
}
|
||||
return null; // throw new Exception("No rows to return");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,34 +154,27 @@ namespace OpenSim.Data.MSSQL
|
|||
/// <param name="asset">the asset</param>
|
||||
override public void CreateAsset(AssetBase asset)
|
||||
{
|
||||
if (ExistsAsset((UUID) asset.FullID))
|
||||
if (ExistsAsset(asset.FullID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
using (AutoClosingSqlCommand cmd =
|
||||
database.Query(
|
||||
using (AutoClosingSqlCommand command = database.Query(
|
||||
"INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [data])" +
|
||||
" VALUES " +
|
||||
"(@id, @name, @description, @assetType, @local, @temporary, @data)"))
|
||||
{
|
||||
|
||||
//SqlParameter p = cmd.Parameters.Add("id", SqlDbType.NVarChar);
|
||||
//p.Value = asset.FullID.ToString();
|
||||
cmd.Parameters.AddWithValue("id", asset.FullID.ToString());
|
||||
cmd.Parameters.AddWithValue("name", asset.Name);
|
||||
cmd.Parameters.AddWithValue("description", asset.Description);
|
||||
SqlParameter e = cmd.Parameters.Add("assetType", SqlDbType.TinyInt);
|
||||
e.Value = asset.Type;
|
||||
SqlParameter g = cmd.Parameters.Add("local", SqlDbType.TinyInt);
|
||||
g.Value = asset.Local;
|
||||
SqlParameter h = cmd.Parameters.Add("temporary", SqlDbType.TinyInt);
|
||||
h.Value = asset.Temporary;
|
||||
SqlParameter i = cmd.Parameters.Add("data", SqlDbType.Image);
|
||||
i.Value = asset.Data;
|
||||
command.Parameters.Add(database.CreateParameter("id", asset.FullID));
|
||||
command.Parameters.Add(database.CreateParameter("name", asset.Name));
|
||||
command.Parameters.Add(database.CreateParameter("description", asset.Description));
|
||||
command.Parameters.Add(database.CreateParameter("assetType", asset.Type));
|
||||
command.Parameters.Add(database.CreateParameter("local", asset.Local));
|
||||
command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary));
|
||||
command.Parameters.Add(database.CreateParameter("data", asset.Data));
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +184,7 @@ namespace OpenSim.Data.MSSQL
|
|||
/// <param name="asset">the asset</param>
|
||||
override public void UpdateAsset(AssetBase asset)
|
||||
{
|
||||
using (IDbCommand command = database.Query("UPDATE assets set id = @id, " +
|
||||
using (AutoClosingSqlCommand command = database.Query("UPDATE assets set id = @id, " +
|
||||
"name = @name, " +
|
||||
"description = @description," +
|
||||
"assetType = @assetType," +
|
||||
|
@ -148,22 +193,14 @@ namespace OpenSim.Data.MSSQL
|
|||
"data = @data where " +
|
||||
"id = @keyId;"))
|
||||
{
|
||||
SqlParameter param1 = new SqlParameter("@id", asset.FullID.ToString());
|
||||
SqlParameter param2 = new SqlParameter("@name", asset.Name);
|
||||
SqlParameter param3 = new SqlParameter("@description", asset.Description);
|
||||
SqlParameter param4 = new SqlParameter("@assetType", asset.Type);
|
||||
SqlParameter param6 = new SqlParameter("@local", asset.Local);
|
||||
SqlParameter param7 = new SqlParameter("@temporary", asset.Temporary);
|
||||
SqlParameter param8 = new SqlParameter("@data", asset.Data);
|
||||
SqlParameter param9 = new SqlParameter("@keyId", asset.FullID.ToString());
|
||||
command.Parameters.Add(param1);
|
||||
command.Parameters.Add(param2);
|
||||
command.Parameters.Add(param3);
|
||||
command.Parameters.Add(param4);
|
||||
command.Parameters.Add(param6);
|
||||
command.Parameters.Add(param7);
|
||||
command.Parameters.Add(param8);
|
||||
command.Parameters.Add(param9);
|
||||
command.Parameters.Add(database.CreateParameter("id", asset.FullID));
|
||||
command.Parameters.Add(database.CreateParameter("name", asset.Name));
|
||||
command.Parameters.Add(database.CreateParameter("description", asset.Description));
|
||||
command.Parameters.Add(database.CreateParameter("assetType", asset.Type));
|
||||
command.Parameters.Add(database.CreateParameter("local", asset.Local));
|
||||
command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary));
|
||||
command.Parameters.Add(database.CreateParameter("data", asset.Data));
|
||||
command.Parameters.Add(database.CreateParameter("@keyId", asset.FullID));
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -192,57 +229,69 @@ namespace OpenSim.Data.MSSQL
|
|||
|
||||
#endregion
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
override public void Dispose() { }
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// <para>Initialises asset interface</para>
|
||||
/// <para>
|
||||
/// TODO: this would allow you to pass in connnect info as
|
||||
/// a string instead of file, if someone writes the support
|
||||
/// </para>
|
||||
/// Migration method
|
||||
/// <list type="bullet">
|
||||
/// <item>Execute "CreateAssetsTable.sql" if tableName == null</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
/// <param name="connect">connect string</param>
|
||||
override public void Initialise(string connect)
|
||||
/// <param name="tableName">Name of table</param>
|
||||
private void UpgradeAssetsTable(string tableName)
|
||||
{
|
||||
Initialise();
|
||||
// null as the version, indicates that the table didn't exist
|
||||
if (tableName == null)
|
||||
{
|
||||
m_log.Info("[ASSET DB]: Creating new database tables");
|
||||
database.ExecuteResourceSql("CreateAssetsTable.sql");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises asset interface
|
||||
/// Ensure that the assets related tables exists and are at the latest version
|
||||
/// </summary>
|
||||
/// <remarks>it use mssql_connection.ini</remarks>
|
||||
override public void Initialise()
|
||||
private void TestTables()
|
||||
{
|
||||
IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
|
||||
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
||||
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
tableList["assets"] = null;
|
||||
database.GetTableVersion(tableList);
|
||||
|
||||
TestTables();
|
||||
}
|
||||
UpgradeAssetsTable(tableList["assets"]);
|
||||
|
||||
/// <summary>
|
||||
/// Database provider version.
|
||||
/// </summary>
|
||||
override public string Version
|
||||
{
|
||||
get { return database.getVersion(); }
|
||||
}
|
||||
//Special for Migrations
|
||||
using (AutoClosingSqlCommand cmd = database.Query("select * from migrations where name = '" + _migrationStore + "'"))
|
||||
{
|
||||
try
|
||||
{
|
||||
bool insert = true;
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read()) insert = false;
|
||||
}
|
||||
if (insert)
|
||||
{
|
||||
cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)";
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
//No migrations table
|
||||
//HACK create one and add data
|
||||
cmd.CommandText = "create table migrations(name varchar(100), version int)";
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "insert into migrations(name, version) values('migrations', 1)";
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)";
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of this DB provider.
|
||||
/// </summary>
|
||||
override public string Name
|
||||
{
|
||||
get { return "MSSQL Asset storage engine"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -39,6 +39,8 @@ namespace OpenSim.Data.MSSQL
|
|||
{
|
||||
public class MSSQLEstateData : IEstateDataStore
|
||||
{
|
||||
private const string _migrationStore = "EstateStore";
|
||||
|
||||
private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private MSSQLManager _Database;
|
||||
|
@ -74,15 +76,7 @@ namespace OpenSim.Data.MSSQL
|
|||
}
|
||||
|
||||
//Migration settings
|
||||
using (SqlConnection connection = _Database.DatabaseConnection())
|
||||
{
|
||||
Assembly assem = GetType().Assembly;
|
||||
MSSQLMigration migration = new MSSQLMigration(connection, assem, "EstateStore");
|
||||
|
||||
migration.Update();
|
||||
|
||||
connection.Close();
|
||||
}
|
||||
_Database.CheckMigration(_migrationStore);
|
||||
|
||||
//Interesting way to get parameters! Maybe implement that also with other types
|
||||
Type t = typeof(EstateSettings);
|
||||
|
|
|
@ -28,9 +28,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
|
@ -42,6 +41,8 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
public class MSSQLGridData : GridDataBase
|
||||
{
|
||||
private const string _migrationStore = "GridStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
|
@ -49,49 +50,62 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
private MSSQLManager database;
|
||||
|
||||
private string m_regionsTableName;
|
||||
private string m_regionsTableName = "regions";
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
override public void Initialise()
|
||||
{
|
||||
m_log.Info("[MSSQLGridData]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException (Name);
|
||||
m_log.Info("[GRID DB]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the Grid Interface
|
||||
/// </summary>
|
||||
/// <param name="connect">connect string</param>
|
||||
/// <param name="connectionString">connect string</param>
|
||||
/// <remarks>use mssql_connection.ini</remarks>
|
||||
override public void Initialise(string connect)
|
||||
override public void Initialise(string connectionString)
|
||||
{
|
||||
// TODO: make the connect string actually do something
|
||||
IniFile iniFile = new IniFile("mssql_connection.ini");
|
||||
|
||||
string settingDataSource = iniFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = iniFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = iniFile.ParseFileReadValue("password");
|
||||
|
||||
m_regionsTableName = iniFile.ParseFileReadValue("regionstablename");
|
||||
if (m_regionsTableName == null)
|
||||
if (string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
m_regionsTableName = "regions";
|
||||
database = new MSSQLManager(connectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: make the connect string actually do something
|
||||
IniFile iniFile = new IniFile("mssql_connection.ini");
|
||||
|
||||
string settingDataSource = iniFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = iniFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = iniFile.ParseFileReadValue("password");
|
||||
|
||||
m_regionsTableName = iniFile.ParseFileReadValue("regionstablename");
|
||||
if (m_regionsTableName == null)
|
||||
{
|
||||
m_regionsTableName = "regions";
|
||||
}
|
||||
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
}
|
||||
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
|
||||
//TODO this can be removed at a certain time
|
||||
TestTables();
|
||||
|
||||
//New migrations check of store
|
||||
database.CheckMigration(_migrationStore);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Test is region
|
||||
/// </summary>
|
||||
private void TestTables()
|
||||
{
|
||||
using (IDbCommand cmd = database.Query("SELECT TOP 1 * FROM " + m_regionsTableName, new Dictionary<string, string>()))
|
||||
using (AutoClosingSqlCommand cmd = database.Query("SELECT TOP 1 * FROM " + m_regionsTableName, new Dictionary<string, string>()))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -103,6 +117,36 @@ namespace OpenSim.Data.MSSQL
|
|||
database.ExecuteResourceSql("Mssql-regions.sql");
|
||||
}
|
||||
}
|
||||
using (AutoClosingSqlCommand cmd = database.Query("select * from migrations where name = '" + _migrationStore + "'"))
|
||||
{
|
||||
//Special for Migrations to create backword compatible
|
||||
try
|
||||
{
|
||||
bool insert = true;
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read()) insert = false;
|
||||
}
|
||||
if (insert)
|
||||
{
|
||||
cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)";
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
//No migrations table
|
||||
//HACK create one and add data
|
||||
cmd.CommandText = "create table migrations(name varchar(100), version int)";
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "insert into migrations(name, version) values('migrations', 1)";
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)";
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -110,7 +154,7 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
override public void Dispose()
|
||||
{
|
||||
// nothing to close
|
||||
database = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -131,18 +175,44 @@ namespace OpenSim.Data.MSSQL
|
|||
get { return "0.1"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public override GridDataBase methods
|
||||
|
||||
/// <summary>
|
||||
/// NOT IMPLEMENTED,
|
||||
/// Returns a list of regions within the specified ranges
|
||||
/// </summary>
|
||||
/// <param name="a">minimum X coordinate</param>
|
||||
/// <param name="b">minimum Y coordinate</param>
|
||||
/// <param name="c">maximum X coordinate</param>
|
||||
/// <param name="d">maximum Y coordinate</param>
|
||||
/// <param name="xmin">minimum X coordinate</param>
|
||||
/// <param name="ymin">minimum Y coordinate</param>
|
||||
/// <param name="xmax">maximum X coordinate</param>
|
||||
/// <param name="ymax">maximum Y coordinate</param>
|
||||
/// <returns>null</returns>
|
||||
/// <remarks>always return null</remarks>
|
||||
override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
|
||||
override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax)
|
||||
{
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE locX >= @xmin AND locX <= @xmax AND locY >= @ymin AND locY <= @ymax"))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("xmin", xmin));
|
||||
command.Parameters.Add(database.CreateParameter("ymin", ymin));
|
||||
command.Parameters.Add(database.CreateParameter("xmax", xmax));
|
||||
command.Parameters.Add(database.CreateParameter("ymax", ymax));
|
||||
|
||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
rows.Add(ReadSimRow(reader));
|
||||
}
|
||||
}
|
||||
|
||||
if (rows.Count > 0)
|
||||
{
|
||||
return rows.ToArray();
|
||||
}
|
||||
}
|
||||
m_log.Info("[GRID DB] : Found no regions within range.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -153,22 +223,20 @@ namespace OpenSim.Data.MSSQL
|
|||
/// <returns>Sim profile</returns>
|
||||
override public RegionProfileData GetProfileByHandle(ulong handle)
|
||||
{
|
||||
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["handle"] = handle.ToString();
|
||||
|
||||
try
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle"))
|
||||
{
|
||||
using (IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle", param))
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
command.Parameters.Add(database.CreateParameter("handle", handle));
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
return database.getRegionRow(reader);
|
||||
if (reader.Read())
|
||||
{
|
||||
return ReadSimRow(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
m_log.InfoFormat("[GRID DB] : No region found with handle : {0}", handle);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -178,50 +246,49 @@ namespace OpenSim.Data.MSSQL
|
|||
/// <returns>The sim profile</returns>
|
||||
override public RegionProfileData GetProfileByUUID(UUID uuid)
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["uuid"] = uuid.ToString();
|
||||
|
||||
using (IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid", param))
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid"))
|
||||
{
|
||||
return database.getRegionRow(reader);
|
||||
}
|
||||
command.Parameters.Add(database.CreateParameter("uuid", uuid));
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return ReadSimRow(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_log.InfoFormat("[GRID DB] : No region found with UUID : {0}", uuid);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from it's Region name string
|
||||
/// </summary>
|
||||
/// <param name="uuid">The region name search query</param>
|
||||
/// <param name="regionName">The region name search query</param>
|
||||
/// <returns>The sim profile</returns>
|
||||
override public RegionProfileData GetProfileByString(string regionName)
|
||||
{
|
||||
if (regionName.Length > 2)
|
||||
{
|
||||
try
|
||||
using (AutoClosingSqlCommand command = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like @regionName order by regionName"))
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
// Add % because this is a like query.
|
||||
param["?regionName"] = regionName + "%";
|
||||
// Order by statement will return shorter matches first. Only returns one record or no record.
|
||||
using (IDbCommand result = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like ?regionName order by regionName", param))
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
return database.getRegionRow(reader);
|
||||
}
|
||||
command.Parameters.Add(database.CreateParameter("regionName", regionName + "%"));
|
||||
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return ReadSimRow(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters");
|
||||
m_log.InfoFormat("[GRID DB] : No region found with regionName : {0}", regionName);
|
||||
return null;
|
||||
}
|
||||
|
||||
m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -231,14 +298,11 @@ namespace OpenSim.Data.MSSQL
|
|||
/// <returns>A dataresponse enum indicating success</returns>
|
||||
override public DataResponse AddProfile(RegionProfileData profile)
|
||||
{
|
||||
if (insertRegionRow(profile))
|
||||
if (InsertRegionRow(profile))
|
||||
{
|
||||
return DataResponse.RESPONSE_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -246,156 +310,43 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
/// <param name="profile">The profile to update</param>
|
||||
/// <returns>A dataresponse enum indicating success</returns>
|
||||
public override DataResponse UpdateProfile(RegionProfileData profile)
|
||||
override public DataResponse UpdateProfile(RegionProfileData profile)
|
||||
{
|
||||
if (updateRegionRow(profile))
|
||||
if (UpdateRegionRow(profile))
|
||||
{
|
||||
return DataResponse.RESPONSE_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the specified region in the database
|
||||
/// Deletes a sim profile from the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The profile to update</param>
|
||||
/// <returns>success ?</returns>
|
||||
public bool updateRegionRow(RegionProfileData profile)
|
||||
{
|
||||
//Insert new region
|
||||
string sql =
|
||||
"UPDATE " + m_regionsTableName + @" SET
|
||||
[regionHandle]=@regionHandle, [regionName]=@regionName,
|
||||
[regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey,
|
||||
[regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI,
|
||||
[locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle,
|
||||
[westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle,
|
||||
[northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI,
|
||||
[regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey,
|
||||
[regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey,
|
||||
[regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort,
|
||||
[serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid
|
||||
where [uuid]=@uuid";
|
||||
|
||||
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||
|
||||
parameters["regionHandle"] = profile.regionHandle.ToString();
|
||||
parameters["regionName"] = profile.regionName;
|
||||
parameters["uuid"] = profile.ToString();
|
||||
parameters["regionRecvKey"] = profile.regionRecvKey;
|
||||
parameters["regionSecret"] = profile.regionSecret;
|
||||
parameters["regionSendKey"] = profile.regionSendKey;
|
||||
parameters["regionDataURI"] = profile.regionDataURI;
|
||||
parameters["serverIP"] = profile.serverIP;
|
||||
parameters["serverPort"] = profile.serverPort.ToString();
|
||||
parameters["serverURI"] = profile.serverURI;
|
||||
parameters["locX"] = profile.regionLocX.ToString();
|
||||
parameters["locY"] = profile.regionLocY.ToString();
|
||||
parameters["locZ"] = profile.regionLocZ.ToString();
|
||||
parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
|
||||
parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
|
||||
parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
|
||||
parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
|
||||
parameters["regionAssetURI"] = profile.regionAssetURI;
|
||||
parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
|
||||
parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
|
||||
parameters["regionUserURI"] = profile.regionUserURI;
|
||||
parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
|
||||
parameters["regionUserSendKey"] = profile.regionUserSendKey;
|
||||
parameters["regionMapTexture"] = profile.regionMapTextureID.ToString();
|
||||
parameters["serverHttpPort"] = profile.httpPort.ToString();
|
||||
parameters["serverRemotingPort"] = profile.remotingPort.ToString();
|
||||
parameters["owner_uuid"] = profile.owner_uuid.ToString();
|
||||
|
||||
bool returnval = false;
|
||||
|
||||
try
|
||||
{
|
||||
using (IDbCommand result = database.Query(sql, parameters))
|
||||
{
|
||||
|
||||
if (result.ExecuteNonQuery() == 1)
|
||||
returnval = true;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("MSSQLManager : " + e.ToString());
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new region in the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The region profile to insert</param>
|
||||
/// <param name="uuid">the sim UUID</param>
|
||||
/// <returns>Successful?</returns>
|
||||
public bool insertRegionRow(RegionProfileData profile)
|
||||
//public DataResponse DeleteProfile(RegionProfileData profile)
|
||||
override public DataResponse DeleteProfile(string uuid)
|
||||
{
|
||||
//Insert new region
|
||||
string sql =
|
||||
"INSERT INTO " + m_regionsTableName + @" ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI],
|
||||
[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle],
|
||||
[southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey],
|
||||
[regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort],
|
||||
[serverRemotingPort], [owner_uuid])
|
||||
VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI,
|
||||
@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle,
|
||||
@southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey,
|
||||
@regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid);";
|
||||
|
||||
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||
|
||||
parameters["regionHandle"] = profile.regionHandle.ToString();
|
||||
parameters["regionName"] = profile.regionName;
|
||||
parameters["uuid"] = profile.ToString();
|
||||
parameters["regionRecvKey"] = profile.regionRecvKey;
|
||||
parameters["regionSecret"] = profile.regionSecret;
|
||||
parameters["regionSendKey"] = profile.regionSendKey;
|
||||
parameters["regionDataURI"] = profile.regionDataURI;
|
||||
parameters["serverIP"] = profile.serverIP;
|
||||
parameters["serverPort"] = profile.serverPort.ToString();
|
||||
parameters["serverURI"] = profile.serverURI;
|
||||
parameters["locX"] = profile.regionLocX.ToString();
|
||||
parameters["locY"] = profile.regionLocY.ToString();
|
||||
parameters["locZ"] = profile.regionLocZ.ToString();
|
||||
parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
|
||||
parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
|
||||
parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
|
||||
parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
|
||||
parameters["regionAssetURI"] = profile.regionAssetURI;
|
||||
parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
|
||||
parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
|
||||
parameters["regionUserURI"] = profile.regionUserURI;
|
||||
parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
|
||||
parameters["regionUserSendKey"] = profile.regionUserSendKey;
|
||||
parameters["regionMapTexture"] = profile.regionMapTextureID.ToString();
|
||||
parameters["serverHttpPort"] = profile.httpPort.ToString();
|
||||
parameters["serverRemotingPort"] = profile.remotingPort.ToString();
|
||||
parameters["owner_uuid"] = profile.owner_uuid.ToString();
|
||||
|
||||
bool returnval = false;
|
||||
|
||||
try
|
||||
using (AutoClosingSqlCommand command = database.Query("DELETE FROM regions WHERE uuid = @uuid;"))
|
||||
{
|
||||
using (IDbCommand result = database.Query(sql, parameters))
|
||||
command.Parameters.Add(database.CreateParameter("uuid", uuid));
|
||||
try
|
||||
{
|
||||
if (result.ExecuteNonQuery() == 1)
|
||||
returnval = true;
|
||||
command.ExecuteNonQuery();
|
||||
return DataResponse.RESPONSE_OK;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[GRID DB] : Error deleting region info, error is : {0}", e.Message);
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[GRID DB]: " + e.ToString());
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods that are not used or deprecated (still needed because of base class)
|
||||
|
||||
/// <summary>
|
||||
/// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
|
||||
/// </summary>
|
||||
|
@ -436,6 +387,7 @@ namespace OpenSim.Data.MSSQL
|
|||
|
||||
/// <summary>
|
||||
/// NOT IMPLEMENTED
|
||||
/// WHEN IS THIS GONNA BE IMPLEMENTED.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
|
@ -444,5 +396,218 @@ namespace OpenSim.Data.MSSQL
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private methods
|
||||
|
||||
/// <summary>
|
||||
/// Reads a region row from a database reader
|
||||
/// </summary>
|
||||
/// <param name="reader">An active database reader</param>
|
||||
/// <returns>A region profile</returns>
|
||||
private static RegionProfileData ReadSimRow(IDataRecord reader)
|
||||
{
|
||||
RegionProfileData retval = new RegionProfileData();
|
||||
|
||||
// Region Main gotta-have-or-we-return-null parts
|
||||
UInt64 tmp64;
|
||||
if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
retval.regionHandle = tmp64;
|
||||
|
||||
UUID tmp_uuid;
|
||||
if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
retval.UUID = tmp_uuid;
|
||||
|
||||
// non-critical parts
|
||||
retval.regionName = reader["regionName"].ToString();
|
||||
retval.originUUID = new UUID((string)reader["originUUID"]);
|
||||
|
||||
// Secrets
|
||||
retval.regionRecvKey = reader["regionRecvKey"].ToString();
|
||||
retval.regionSecret = reader["regionSecret"].ToString();
|
||||
retval.regionSendKey = reader["regionSendKey"].ToString();
|
||||
|
||||
// Region Server
|
||||
retval.regionDataURI = reader["regionDataURI"].ToString();
|
||||
retval.regionOnline = false; // Needs to be pinged before this can be set.
|
||||
retval.serverIP = reader["serverIP"].ToString();
|
||||
retval.serverPort = Convert.ToUInt32(reader["serverPort"]);
|
||||
retval.serverURI = reader["serverURI"].ToString();
|
||||
retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString());
|
||||
retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString());
|
||||
|
||||
// Location
|
||||
retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString());
|
||||
retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString());
|
||||
retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString());
|
||||
|
||||
// Neighbours - 0 = No Override
|
||||
retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString());
|
||||
retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString());
|
||||
retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString());
|
||||
retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
|
||||
|
||||
// Assets
|
||||
retval.regionAssetURI = reader["regionAssetURI"].ToString();
|
||||
retval.regionAssetRecvKey = reader["regionAssetRecvKey"].ToString();
|
||||
retval.regionAssetSendKey = reader["regionAssetSendKey"].ToString();
|
||||
|
||||
// Userserver
|
||||
retval.regionUserURI = reader["regionUserURI"].ToString();
|
||||
retval.regionUserRecvKey = reader["regionUserRecvKey"].ToString();
|
||||
retval.regionUserSendKey = reader["regionUserSendKey"].ToString();
|
||||
|
||||
// World Map Addition
|
||||
UUID.TryParse((string)reader["regionMapTexture"], out retval.regionMapTextureID);
|
||||
UUID.TryParse((string)reader["owner_uuid"], out retval.owner_uuid);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the specified region in the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The profile to update</param>
|
||||
/// <returns>success ?</returns>
|
||||
private bool UpdateRegionRow(RegionProfileData profile)
|
||||
{
|
||||
bool returnval = false;
|
||||
|
||||
//Insert new region
|
||||
string sql =
|
||||
"UPDATE " + m_regionsTableName + @" SET
|
||||
[regionHandle]=@regionHandle, [regionName]=@regionName,
|
||||
[regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey,
|
||||
[regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI,
|
||||
[locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle,
|
||||
[westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle,
|
||||
[northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI,
|
||||
[regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey,
|
||||
[regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey,
|
||||
[regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort,
|
||||
[serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid , [originUUID]=@originUUID
|
||||
where [uuid]=@uuid";
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle));
|
||||
command.Parameters.Add(database.CreateParameter("regionName", profile.regionName));
|
||||
command.Parameters.Add(database.CreateParameter("uuid", profile.UUID));
|
||||
command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret));
|
||||
command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI));
|
||||
command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP));
|
||||
command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort));
|
||||
command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI));
|
||||
command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX));
|
||||
command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY));
|
||||
command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ));
|
||||
command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID));
|
||||
command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort));
|
||||
command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort));
|
||||
command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid));
|
||||
command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
returnval = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[GRID DB] : Error updating region, error: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new region in the database
|
||||
/// </summary>
|
||||
/// <param name="profile">The region profile to insert</param>
|
||||
/// <returns>Successful?</returns>
|
||||
private bool InsertRegionRow(RegionProfileData profile)
|
||||
{
|
||||
bool returnval = false;
|
||||
|
||||
//Insert new region
|
||||
string sql =
|
||||
"INSERT INTO " + m_regionsTableName + @" ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI],
|
||||
[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle],
|
||||
[southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey],
|
||||
[regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort],
|
||||
[serverRemotingPort], [owner_uuid], [originUUID])
|
||||
VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI,
|
||||
@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle,
|
||||
@southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey,
|
||||
@regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid, @originUUID);";
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle));
|
||||
command.Parameters.Add(database.CreateParameter("regionName", profile.regionName));
|
||||
command.Parameters.Add(database.CreateParameter("uuid", profile.UUID));
|
||||
command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret));
|
||||
command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI));
|
||||
command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP));
|
||||
command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort));
|
||||
command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI));
|
||||
command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX));
|
||||
command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY));
|
||||
command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ));
|
||||
command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey));
|
||||
command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID));
|
||||
command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort));
|
||||
command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort));
|
||||
command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid));
|
||||
command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
returnval = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[GRID DB] : Error inserting region, error: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
@ -39,6 +40,8 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
internal class MSSQLLogData : ILogDataPlugin
|
||||
{
|
||||
private const string _migrationStore = "LogStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
|
@ -48,7 +51,7 @@ namespace OpenSim.Data.MSSQL
|
|||
|
||||
public void Initialise()
|
||||
{
|
||||
m_log.Info("[MSSQLLogData]: " + Name + " cannot be default-initialized!");
|
||||
m_log.Info("[LOG DB]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException (Name);
|
||||
}
|
||||
|
||||
|
@ -57,18 +60,37 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
public void Initialise(string connect)
|
||||
{
|
||||
// TODO: do something with the connect string
|
||||
IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
|
||||
if (string.IsNullOrEmpty(connect))
|
||||
{
|
||||
database = new MSSQLManager(connect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: do something with the connect string
|
||||
IniFile gridDataMSSqlFile = new IniFile("mssql_connection.ini");
|
||||
string settingDataSource = gridDataMSSqlFile.ParseFileReadValue("data_source");
|
||||
string settingInitialCatalog = gridDataMSSqlFile.ParseFileReadValue("initial_catalog");
|
||||
string settingPersistSecurityInfo = gridDataMSSqlFile.ParseFileReadValue("persist_security_info");
|
||||
string settingUserId = gridDataMSSqlFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = gridDataMSSqlFile.ParseFileReadValue("password");
|
||||
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
}
|
||||
|
||||
//TODO when can this be removed
|
||||
TestTable();
|
||||
|
||||
//Updating mechanisme
|
||||
database.CheckMigration(_migrationStore);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can be removed someday!!!
|
||||
/// </summary>
|
||||
private void TestTable()
|
||||
{
|
||||
using (IDbCommand cmd = database.Query("select top 1 * from logs", new Dictionary<string, string>()))
|
||||
{
|
||||
try
|
||||
|
@ -80,7 +102,36 @@ namespace OpenSim.Data.MSSQL
|
|||
database.ExecuteResourceSql("Mssql-logs.sql");
|
||||
}
|
||||
}
|
||||
using (AutoClosingSqlCommand cmd = database.Query("select * from migrations where name = '" + _migrationStore + "'"))
|
||||
{
|
||||
//Special for Migrations to create backword compatible
|
||||
try
|
||||
{
|
||||
bool insert = true;
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read()) insert = false;
|
||||
}
|
||||
if (insert)
|
||||
{
|
||||
cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)";
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
//No migrations table
|
||||
//HACK create one and add data
|
||||
cmd.CommandText = "create table migrations(name varchar(100), version int)";
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "insert into migrations(name, version) values('migrations', 1)";
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)";
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -95,13 +146,28 @@ namespace OpenSim.Data.MSSQL
|
|||
public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,
|
||||
string logMessage)
|
||||
{
|
||||
try
|
||||
string sql = "INSERT INTO logs ([target], [server], [method], [arguments], [priority], [message]) VALUES ";
|
||||
sql += "(@target, @server, @method, @arguments, @priority, @message);";
|
||||
|
||||
using (AutoClosingSqlCommand command = database.Query(sql))
|
||||
{
|
||||
database.insertLogRow(serverDaemon, target, methodCall, arguments, priority, logMessage);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// it didn't log, don't worry about it
|
||||
command.Parameters.Add(database.CreateParameter("server", serverDaemon));
|
||||
command.Parameters.Add(database.CreateParameter("target",target));
|
||||
command.Parameters.Add(database.CreateParameter("method", methodCall));
|
||||
command.Parameters.Add(database.CreateParameter("arguments", arguments));
|
||||
command.Parameters.Add(database.CreateParameter("priority", priority.ToString()));
|
||||
command.Parameters.Add(database.CreateParameter("message", logMessage));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//Are we not in a loop here
|
||||
//m_log.Error(e.ToString());
|
||||
Console.WriteLine("[LOG DB] Error logging : " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +185,7 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
// Do nothing.
|
||||
database = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -33,7 +33,6 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data.MSSQL
|
||||
{
|
||||
|
@ -83,49 +82,7 @@ namespace OpenSim.Data.MSSQL
|
|||
return conn;
|
||||
}
|
||||
|
||||
//private DataTable createRegionsTable()
|
||||
//{
|
||||
// DataTable regions = new DataTable("regions");
|
||||
|
||||
// createCol(regions, "regionHandle", typeof (ulong));
|
||||
// createCol(regions, "regionName", typeof (String));
|
||||
// createCol(regions, "uuid", typeof (String));
|
||||
|
||||
// createCol(regions, "regionRecvKey", typeof (String));
|
||||
// createCol(regions, "regionSecret", typeof (String));
|
||||
// createCol(regions, "regionSendKey", typeof (String));
|
||||
|
||||
// createCol(regions, "regionDataURI", typeof (String));
|
||||
// createCol(regions, "serverIP", typeof (String));
|
||||
// createCol(regions, "serverPort", typeof (String));
|
||||
// createCol(regions, "serverURI", typeof (String));
|
||||
|
||||
|
||||
// createCol(regions, "locX", typeof (uint));
|
||||
// createCol(regions, "locY", typeof (uint));
|
||||
// createCol(regions, "locZ", typeof (uint));
|
||||
|
||||
// createCol(regions, "eastOverrideHandle", typeof (ulong));
|
||||
// createCol(regions, "westOverrideHandle", typeof (ulong));
|
||||
// createCol(regions, "southOverrideHandle", typeof (ulong));
|
||||
// createCol(regions, "northOverrideHandle", typeof (ulong));
|
||||
|
||||
// createCol(regions, "regionAssetURI", typeof (String));
|
||||
// createCol(regions, "regionAssetRecvKey", typeof (String));
|
||||
// createCol(regions, "regionAssetSendKey", typeof (String));
|
||||
|
||||
// createCol(regions, "regionUserURI", typeof (String));
|
||||
// createCol(regions, "regionUserRecvKey", typeof (String));
|
||||
// createCol(regions, "regionUserSendKey", typeof (String));
|
||||
|
||||
// createCol(regions, "regionMapTexture", typeof (String));
|
||||
// createCol(regions, "serverHttpPort", typeof (String));
|
||||
// createCol(regions, "serverRemotingPort", typeof (uint));
|
||||
|
||||
// // Add in contraints
|
||||
// regions.PrimaryKey = new DataColumn[] {regions.Columns["UUID"]};
|
||||
// return regions;
|
||||
//}
|
||||
#region Obsolete functions, can be removed!
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -133,6 +90,7 @@ namespace OpenSim.Data.MSSQL
|
|||
/// <param name="dt"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
[Obsolete("Do not use!")]
|
||||
protected static void createCol(DataTable dt, string name, Type type)
|
||||
{
|
||||
DataColumn col = new DataColumn(name, type);
|
||||
|
@ -144,6 +102,7 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("Do not use!")]
|
||||
protected static string defineTable(DataTable dt)
|
||||
{
|
||||
string sql = "create table " + dt.TableName + "(";
|
||||
|
@ -167,34 +126,34 @@ namespace OpenSim.Data.MSSQL
|
|||
return sql;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Type conversion function
|
||||
/// </summary>
|
||||
/// <param name="type">a type</param>
|
||||
/// <returns>a sqltype</returns>
|
||||
/// <remarks>this is something we'll need to implement for each db slightly differently.</remarks>
|
||||
[Obsolete("Used by a obsolete methods")]
|
||||
public static string SqlType(Type type)
|
||||
{
|
||||
if (type == typeof(String))
|
||||
{
|
||||
return "varchar(255)";
|
||||
}
|
||||
else if (type == typeof(Int32))
|
||||
if (type == typeof(Int32))
|
||||
{
|
||||
return "integer";
|
||||
}
|
||||
else if (type == typeof(Double))
|
||||
if (type == typeof(Double))
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
else if (type == typeof(Byte[]))
|
||||
if (type == typeof(Byte[]))
|
||||
{
|
||||
return "image";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "varchar(255)";
|
||||
}
|
||||
return "varchar(255)";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -224,14 +183,22 @@ namespace OpenSim.Data.MSSQL
|
|||
{
|
||||
return SqlDbType.VarChar;
|
||||
}
|
||||
if (type == typeof(sbyte))
|
||||
{
|
||||
return SqlDbType.TinyInt;
|
||||
}
|
||||
if (type == typeof(Byte[]))
|
||||
{
|
||||
return SqlDbType.Image;
|
||||
}
|
||||
if (type == typeof(uint))
|
||||
if (type == typeof(uint) || type == typeof(ushort))
|
||||
{
|
||||
return SqlDbType.Int;
|
||||
}
|
||||
if (type == typeof(ulong))
|
||||
{
|
||||
return SqlDbType.BigInt;
|
||||
}
|
||||
return SqlDbType.VarChar;
|
||||
}
|
||||
|
||||
|
@ -282,6 +249,9 @@ namespace OpenSim.Data.MSSQL
|
|||
//Tweak so we dont always have to add @ sign
|
||||
if (!parameterName.StartsWith("@")) parameterName = "@" + parameterName;
|
||||
|
||||
//HACK if object is null, it is turned into a string, there are no nullable type till now
|
||||
if (parameterObject == null) parameterObject = "";
|
||||
|
||||
SqlParameter parameter = new SqlParameter(parameterName, DbtypeFromType(parameterObject.GetType()));
|
||||
|
||||
if (parameterOut)
|
||||
|
@ -298,6 +268,7 @@ namespace OpenSim.Data.MSSQL
|
|||
}
|
||||
|
||||
private static readonly Dictionary<string, string> emptyDictionary = new Dictionary<string, string>();
|
||||
|
||||
internal AutoClosingSqlCommand Query(string sql)
|
||||
{
|
||||
return Query(sql, emptyDictionary);
|
||||
|
@ -322,252 +293,51 @@ namespace OpenSim.Data.MSSQL
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs a database reader object and returns a region row
|
||||
/// Runs a query with protection against SQL Injection by using parameterised input.
|
||||
/// </summary>
|
||||
/// <param name="reader">An active database reader</param>
|
||||
/// <returns>A region row</returns>
|
||||
public RegionProfileData getRegionRow(IDataReader reader)
|
||||
{
|
||||
RegionProfileData regionprofile = new RegionProfileData();
|
||||
|
||||
if (reader.Read())
|
||||
{
|
||||
// Region Main
|
||||
regionprofile.regionHandle = Convert.ToUInt64(reader["regionHandle"]);
|
||||
regionprofile.regionName = (string)reader["regionName"];
|
||||
regionprofile.UUID = new UUID((string)reader["uuid"]);
|
||||
|
||||
// Secrets
|
||||
regionprofile.regionRecvKey = (string)reader["regionRecvKey"];
|
||||
regionprofile.regionSecret = (string)reader["regionSecret"];
|
||||
regionprofile.regionSendKey = (string)reader["regionSendKey"];
|
||||
|
||||
// Region Server
|
||||
regionprofile.regionDataURI = (string)reader["regionDataURI"];
|
||||
regionprofile.regionOnline = false; // Needs to be pinged before this can be set.
|
||||
regionprofile.serverIP = (string)reader["serverIP"];
|
||||
regionprofile.serverPort = Convert.ToUInt32(reader["serverPort"]);
|
||||
regionprofile.serverURI = (string)reader["serverURI"];
|
||||
regionprofile.httpPort = Convert.ToUInt32(reader["serverHttpPort"]);
|
||||
regionprofile.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"]);
|
||||
|
||||
|
||||
// Location
|
||||
regionprofile.regionLocX = Convert.ToUInt32(reader["locX"]);
|
||||
regionprofile.regionLocY = Convert.ToUInt32(reader["locY"]);
|
||||
regionprofile.regionLocZ = Convert.ToUInt32(reader["locZ"]);
|
||||
|
||||
// Neighbours - 0 = No Override
|
||||
regionprofile.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"]);
|
||||
regionprofile.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"]);
|
||||
regionprofile.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"]);
|
||||
regionprofile.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"]);
|
||||
|
||||
// Assets
|
||||
regionprofile.regionAssetURI = (string)reader["regionAssetURI"];
|
||||
regionprofile.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
|
||||
regionprofile.regionAssetSendKey = (string)reader["regionAssetSendKey"];
|
||||
|
||||
// Userserver
|
||||
regionprofile.regionUserURI = (string)reader["regionUserURI"];
|
||||
regionprofile.regionUserRecvKey = (string)reader["regionUserRecvKey"];
|
||||
regionprofile.regionUserSendKey = (string)reader["regionUserSendKey"];
|
||||
regionprofile.owner_uuid = new UUID((string) reader["owner_uuid"]);
|
||||
// World Map Addition
|
||||
string tempRegionMap = reader["regionMapTexture"].ToString();
|
||||
if (tempRegionMap != String.Empty)
|
||||
{
|
||||
regionprofile.regionMapTextureID = new UUID(tempRegionMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
regionprofile.regionMapTextureID = new UUID();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Close();
|
||||
throw new Exception("No rows to return");
|
||||
}
|
||||
return regionprofile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a user profile from an active data reader
|
||||
/// </summary>
|
||||
/// <param name="reader">An active database reader</param>
|
||||
/// <returns>A user profile</returns>
|
||||
public UserProfileData readUserRow(IDataReader reader)
|
||||
{
|
||||
UserProfileData retval = new UserProfileData();
|
||||
|
||||
if (reader.Read())
|
||||
{
|
||||
retval.ID = new UUID((string)reader["UUID"]);
|
||||
retval.FirstName = (string)reader["username"];
|
||||
retval.SurName = (string)reader["lastname"];
|
||||
|
||||
retval.PasswordHash = (string)reader["passwordHash"];
|
||||
retval.PasswordSalt = (string)reader["passwordSalt"];
|
||||
|
||||
retval.HomeRegion = Convert.ToUInt64(reader["homeRegion"].ToString());
|
||||
retval.HomeLocation = new Vector3(
|
||||
Convert.ToSingle(reader["homeLocationX"].ToString()),
|
||||
Convert.ToSingle(reader["homeLocationY"].ToString()),
|
||||
Convert.ToSingle(reader["homeLocationZ"].ToString()));
|
||||
retval.HomeLookAt = new Vector3(
|
||||
Convert.ToSingle(reader["homeLookAtX"].ToString()),
|
||||
Convert.ToSingle(reader["homeLookAtY"].ToString()),
|
||||
Convert.ToSingle(reader["homeLookAtZ"].ToString()));
|
||||
|
||||
retval.Created = Convert.ToInt32(reader["created"].ToString());
|
||||
retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
|
||||
|
||||
retval.UserInventoryURI = (string)reader["userInventoryURI"];
|
||||
retval.UserAssetURI = (string)reader["userAssetURI"];
|
||||
|
||||
retval.CanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
|
||||
retval.WantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
|
||||
|
||||
retval.AboutText = (string)reader["profileAboutText"];
|
||||
retval.FirstLifeAboutText = (string)reader["profileFirstText"];
|
||||
|
||||
retval.Image = new UUID((string)reader["profileImage"]);
|
||||
retval.FirstLifeImage = new UUID((string)reader["profileFirstImage"]);
|
||||
retval.WebLoginKey = new UUID((string)reader["webLoginKey"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an agent row from a database reader
|
||||
/// </summary>
|
||||
/// <param name="reader">An active database reader</param>
|
||||
/// <returns>A user session agent</returns>
|
||||
public UserAgentData readAgentRow(IDataReader reader)
|
||||
{
|
||||
UserAgentData retval = new UserAgentData();
|
||||
|
||||
if (reader.Read())
|
||||
{
|
||||
// Agent IDs
|
||||
retval.ProfileID = new UUID((string)reader["UUID"]);
|
||||
retval.SessionID = new UUID((string)reader["sessionID"]);
|
||||
retval.SecureSessionID = new UUID((string)reader["secureSessionID"]);
|
||||
|
||||
// Agent Who?
|
||||
retval.AgentIP = (string)reader["agentIP"];
|
||||
retval.AgentPort = Convert.ToUInt32(reader["agentPort"].ToString());
|
||||
retval.AgentOnline = Convert.ToInt32(reader["agentOnline"].ToString()) != 0;
|
||||
|
||||
// Login/Logout times (UNIX Epoch)
|
||||
retval.LoginTime = Convert.ToInt32(reader["loginTime"].ToString());
|
||||
retval.LogoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
|
||||
|
||||
// Current position
|
||||
retval.Region = (string)reader["currentRegion"];
|
||||
retval.Handle = Convert.ToUInt64(reader["currentHandle"].ToString());
|
||||
Vector3 tmp_v;
|
||||
Vector3.TryParse((string)reader["currentPos"], out tmp_v);
|
||||
retval.Position = tmp_v;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="reader"></param>
|
||||
/// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param>
|
||||
/// <param name="sqlParameter">A parameter - use createparameter to create parameter</param>
|
||||
/// <returns></returns>
|
||||
public AssetBase getAssetRow(IDataReader reader)
|
||||
internal AutoClosingSqlCommand Query(string sql, SqlParameter sqlParameter)
|
||||
{
|
||||
AssetBase asset = new AssetBase();
|
||||
if (reader.Read())
|
||||
{
|
||||
// Region Main
|
||||
asset = new AssetBase();
|
||||
asset.Data = (byte[])reader["data"];
|
||||
asset.Description = (string)reader["description"];
|
||||
asset.FullID = new UUID((string)reader["id"]);
|
||||
asset.Local = Convert.ToBoolean(reader["local"]); // ((sbyte)reader["local"]) != 0 ? true : false;
|
||||
asset.Name = (string)reader["name"];
|
||||
asset.Type = Convert.ToSByte(reader["assetType"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null; // throw new Exception("No rows to return");
|
||||
}
|
||||
return asset;
|
||||
}
|
||||
SqlCommand dbcommand = DatabaseConnection().CreateCommand();
|
||||
dbcommand.CommandText = sql;
|
||||
dbcommand.Parameters.Add(sqlParameter);
|
||||
|
||||
return new AutoClosingSqlCommand(dbcommand);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a new row into the log database
|
||||
/// Checks if we need to do some migrations to the database
|
||||
/// </summary>
|
||||
/// <param name="serverDaemon">The daemon which triggered this event</param>
|
||||
/// <param name="target">Who were we operating on when this occured (region UUID, user UUID, etc)</param>
|
||||
/// <param name="methodCall">The method call where the problem occured</param>
|
||||
/// <param name="arguments">The arguments passed to the method</param>
|
||||
/// <param name="priority">How critical is this?</param>
|
||||
/// <param name="logMessage">Extra message info</param>
|
||||
/// <returns>Saved successfully?</returns>
|
||||
public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority,
|
||||
string logMessage)
|
||||
/// <param name="migrationStore">migrationStore.</param>
|
||||
public void CheckMigration(string migrationStore)
|
||||
{
|
||||
string sql = "INSERT INTO logs ([target], [server], [method], [arguments], [priority], [message]) VALUES ";
|
||||
sql += "(@target, @server, @method, @arguments, @priority, @message);";
|
||||
|
||||
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||
parameters["server"] = serverDaemon;
|
||||
parameters["target"] = target;
|
||||
parameters["method"] = methodCall;
|
||||
parameters["arguments"] = arguments;
|
||||
parameters["priority"] = priority.ToString();
|
||||
parameters["message"] = logMessage;
|
||||
|
||||
bool returnval = false;
|
||||
|
||||
using (IDbCommand result = Query(sql, parameters))
|
||||
using (SqlConnection connection = DatabaseConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
Assembly assem = GetType().Assembly;
|
||||
MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore);
|
||||
|
||||
if (result.ExecuteNonQuery() == 1)
|
||||
returnval = true;
|
||||
migration.Update();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.ToString());
|
||||
return false;
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
return returnval;
|
||||
}
|
||||
|
||||
#region Old Testtable functions
|
||||
|
||||
/// <summary>
|
||||
/// Execute a SQL statement stored in a resource, as a string
|
||||
/// </summary>
|
||||
/// <param name="name">the ressource string</param>
|
||||
public void ExecuteResourceSql(string name)
|
||||
{
|
||||
using (IDbCommand cmd = Query(getResourceString(name), new Dictionary<string,string>()))
|
||||
using (IDbCommand cmd = Query(getResourceString(name), new Dictionary<string, string>()))
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Given a list of tables, return the version of the tables, as seen in the database
|
||||
/// </summary>
|
||||
|
@ -622,6 +392,8 @@ namespace OpenSim.Data.MSSQL
|
|||
throw new Exception(string.Format("Resource '{0}' was not found", name));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Returns the version of this DB provider
|
||||
/// </summary>
|
||||
|
@ -636,63 +408,5 @@ namespace OpenSim.Data.MSSQL
|
|||
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
|
||||
dllVersion.Revision);
|
||||
}
|
||||
|
||||
public bool insertAgentRow(UserAgentData agentdata)
|
||||
{
|
||||
string sql = @"
|
||||
|
||||
IF EXISTS (SELECT * FROM agents WHERE UUID = @UUID)
|
||||
BEGIN
|
||||
UPDATE agents SET UUID = @UUID, sessionID = @sessionID, secureSessionID = @secureSessionID, agentIP = @agentIP, agentPort = @agentPort, agentOnline = @agentOnline, loginTime = @loginTime, logoutTime = @logoutTime, currentRegion = @currentRegion, currentHandle = @currentHandle, currentPos = @currentPos
|
||||
WHERE UUID = @UUID
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
INSERT INTO
|
||||
agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) VALUES
|
||||
(@UUID, @sessionID, @secureSessionID, @agentIP, @agentPort, @agentOnline, @loginTime, @logoutTime, @currentRegion, @currentHandle, @currentPos)
|
||||
END
|
||||
";
|
||||
|
||||
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||
|
||||
parameters["@UUID"] = agentdata.ProfileID.ToString();
|
||||
parameters["@sessionID"] = agentdata.SessionID.ToString();
|
||||
parameters["@secureSessionID"] = agentdata.SecureSessionID.ToString();
|
||||
parameters["@agentIP"] = agentdata.AgentIP.ToString();
|
||||
parameters["@agentPort"] = agentdata.AgentPort.ToString();
|
||||
parameters["@agentOnline"] = (agentdata.AgentOnline == true) ? "1" : "0";
|
||||
parameters["@loginTime"] = agentdata.LoginTime.ToString();
|
||||
parameters["@logoutTime"] = agentdata.LogoutTime.ToString();
|
||||
parameters["@currentRegion"] = agentdata.Region.ToString();
|
||||
parameters["@currentHandle"] = agentdata.Handle.ToString();
|
||||
parameters["@currentPos"] = "<" + ((int)agentdata.Position.X).ToString() + "," + ((int)agentdata.Position.Y).ToString() + "," + ((int)agentdata.Position.Z).ToString() + ">";
|
||||
|
||||
|
||||
using (IDbCommand result = Query(sql, parameters))
|
||||
{
|
||||
result.Transaction = result.Connection.BeginTransaction(IsolationLevel.Serializable);
|
||||
try
|
||||
{
|
||||
if (result.ExecuteNonQuery() > 0)
|
||||
{
|
||||
result.Transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.Transaction.Rollback();
|
||||
m_log.Error(e.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,14 +44,19 @@ namespace OpenSim.Data.MSSQL
|
|||
/// </summary>
|
||||
public class MSSQLRegionDataStore : IRegionDataStore
|
||||
{
|
||||
private const string _migrationStore = "RegionStore";
|
||||
|
||||
// private static FileSystemDataStore Instance = new FileSystemDataStore();
|
||||
private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// The database manager
|
||||
/// </summary>
|
||||
private MSSQLManager _Database;
|
||||
|
||||
// private const string _PrimSelect = "SELECT * FROM PRIMS WHERE RegionUUID = @RegionUUID AND (SceneGroupID LIKE @SceneGroupID OR UUID = @UUID)";
|
||||
// private const string _ShapeSelect = "SELECT * FROM PRIMSHAPES WHERE UUID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID AND (SceneGroupID LIKE @SceneGroupID OR UUID = @UUID))";
|
||||
// private const string _ItemsSelect = "SELECT * FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID AND (SceneGroupID LIKE @SceneGroupID OR UUID = @UUID))";
|
||||
/// <summary>
|
||||
/// Const for the prim store..
|
||||
/// </summary>
|
||||
private const string _PrimSelect = "SELECT * FROM PRIMS WHERE RegionUUID = @RegionUUID AND (SceneGroupID LIKE @SceneGroupID OR UUID IN (@UUID))";
|
||||
private const string _ShapeSelect = "SELECT * FROM PRIMSHAPES WHERE UUID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID AND (SceneGroupID LIKE @SceneGroupID OR UUID IN (@UUID)))";
|
||||
private const string _ItemsSelect = "SELECT * FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID AND (SceneGroupID LIKE @SceneGroupID OR UUID IN (@UUID)))";
|
||||
|
@ -81,31 +86,14 @@ namespace OpenSim.Data.MSSQL
|
|||
string settingUserId = iniFile.ParseFileReadValue("user_id");
|
||||
string settingPassword = iniFile.ParseFileReadValue("password");
|
||||
|
||||
_Database =
|
||||
new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
|
||||
settingPassword);
|
||||
|
||||
|
||||
SqlConnectionStringBuilder conBuilder = new SqlConnectionStringBuilder();
|
||||
conBuilder.DataSource = settingDataSource;
|
||||
conBuilder.InitialCatalog = settingInitialCatalog;
|
||||
conBuilder.PersistSecurityInfo = Convert.ToBoolean(settingPersistSecurityInfo);
|
||||
conBuilder.UserID = settingUserId;
|
||||
conBuilder.Password = settingPassword;
|
||||
conBuilder.ApplicationName = Assembly.GetEntryAssembly().Location;
|
||||
|
||||
connectionString = conBuilder.ToString();
|
||||
_Database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword);
|
||||
}
|
||||
|
||||
//Migration settings
|
||||
Assembly assem = GetType().Assembly;
|
||||
_Database.CheckMigration(_migrationStore);
|
||||
|
||||
using (SqlConnection connection = _Database.DatabaseConnection())
|
||||
{
|
||||
MSSQLMigration m = new MSSQLMigration(connection, assem, "RegionStore");
|
||||
|
||||
m.Update();
|
||||
|
||||
//Create Dataset. Not filled!!!
|
||||
_PrimsDataSet = new DataSet("primsdata");
|
||||
|
||||
|
@ -243,7 +231,7 @@ namespace OpenSim.Data.MSSQL
|
|||
catch (Exception e)
|
||||
{
|
||||
_Log.Error("[REGION DB]: Failed create prim object, exception and data follows");
|
||||
_Log.Info("[REGION DB]: " + e.ToString());
|
||||
_Log.Info("[REGION DB]: " + e.Message);
|
||||
foreach (DataColumn col in prims.Columns)
|
||||
{
|
||||
_Log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]);
|
||||
|
@ -259,71 +247,76 @@ namespace OpenSim.Data.MSSQL
|
|||
|
||||
#region Experimental
|
||||
|
||||
//
|
||||
// //Get all prims
|
||||
// string sql = "select * from prims where RegionUUID = @RegionUUID";
|
||||
//
|
||||
// using (AutoClosingSqlCommand cmdPrims = _Database.Query(sql))
|
||||
// {
|
||||
// cmdPrims.Parameters.AddWithValue("@RegionUUID", regionUUID.ToString());
|
||||
// using (SqlDataReader readerPrims = cmdPrims.ExecuteReader())
|
||||
// {
|
||||
// while (readerPrims.Read())
|
||||
// {
|
||||
// string uuid = (string)readerPrims["UUID"];
|
||||
// string objID = (string)readerPrims["SceneGroupID"];
|
||||
// SceneObjectPart prim = buildPrim(readerPrims);
|
||||
//
|
||||
// //Setting default shape, will change shape ltr
|
||||
// prim.Shape = PrimitiveBaseShape.Default;
|
||||
//
|
||||
// //Load inventory items of prim
|
||||
// //LoadItems(prim);
|
||||
//
|
||||
// if (uuid == objID)
|
||||
// {
|
||||
// SceneObjectGroup group = new SceneObjectGroup();
|
||||
//
|
||||
// group.AddPart(prim);
|
||||
// group.RootPart = prim;
|
||||
//
|
||||
// createdObjects.Add(group.UUID, group);
|
||||
// retvals.Add(group);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// createdObjects[new UUID(objID)].AddPart(prim);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// m_log.Info("[REGION DB]: Loaded " + retvals.Count + " prim objects for region: " + regionUUID);
|
||||
//
|
||||
// //Find all shapes related with prims
|
||||
// sql = "select * from primshapes";
|
||||
// using (AutoClosingSqlCommand cmdShapes = _Database.Query(sql))
|
||||
// {
|
||||
// using (SqlDataReader readerShapes = cmdShapes.ExecuteReader())
|
||||
// {
|
||||
// while (readerShapes.Read())
|
||||
// {
|
||||
// UUID UUID = new UUID((string) readerShapes["UUID"]);
|
||||
//
|
||||
// foreach (SceneObjectGroup objectGroup in createdObjects.Values)
|
||||
// {
|
||||
// if (objectGroup.Children.ContainsKey(UUID))
|
||||
// {
|
||||
// objectGroup.Children[UUID].Shape = buildShape(readerShapes);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return retvals;
|
||||
//
|
||||
// //Get all prims
|
||||
// string sql = "select * from prims where RegionUUID = @RegionUUID";
|
||||
//
|
||||
// using (AutoClosingSqlCommand cmdPrims = _Database.Query(sql))
|
||||
// {
|
||||
// cmdPrims.Parameters.AddWithValue("@RegionUUID", regionUUID.ToString());
|
||||
// using (SqlDataReader readerPrims = cmdPrims.ExecuteReader())
|
||||
// {
|
||||
// while (readerPrims.Read())
|
||||
// {
|
||||
// string uuid = (string)readerPrims["UUID"];
|
||||
// string objID = (string)readerPrims["SceneGroupID"];
|
||||
// SceneObjectPart prim = buildPrim(readerPrims);
|
||||
//
|
||||
// //Setting default shape, will change shape ltr
|
||||
// prim.Shape = PrimitiveBaseShape.Default;
|
||||
//
|
||||
// //Load inventory items of prim
|
||||
// //LoadItems(prim);
|
||||
//
|
||||
// if (uuid == objID)
|
||||
// {
|
||||
// SceneObjectGroup group = new SceneObjectGroup();
|
||||
//
|
||||
// group.AddPart(prim);
|
||||
// group.RootPart = prim;
|
||||
//
|
||||
// createdObjects.Add(group.UUID, group);
|
||||
// retvals.Add(group);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// createdObjects[new UUID(objID)].AddPart(prim);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// m_log.Info("[REGION DB]: Loaded " + retvals.Count + " prim objects for region: " + regionUUID);
|
||||
//
|
||||
// //Find all shapes related with prims
|
||||
// sql = "select * from primshapes";
|
||||
// using (AutoClosingSqlCommand cmdShapes = _Database.Query(sql))
|
||||
// {
|
||||
// using (SqlDataReader readerShapes = cmdShapes.ExecuteReader())
|
||||
// {
|
||||
// while (readerShapes.Read())
|
||||
// {
|
||||
// UUID UUID = new UUID((string) readerShapes["UUID"]);
|
||||
//
|
||||
// foreach (SceneObjectGroup objectGroup in createdObjects.Values)
|
||||
// {
|
||||
// if (objectGroup.Children.ContainsKey(UUID))
|
||||
// {
|
||||
// objectGroup.Children[UUID].Shape = buildShape(readerShapes);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return retvals;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores all object's details apart from inventory
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="regionUUID"></param>
|
||||
public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
|
||||
{
|
||||
//Retrieve all values of current region, and current scene/or prims
|
||||
|
@ -375,10 +368,6 @@ namespace OpenSim.Data.MSSQL
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
|
||||
}
|
||||
}
|
||||
|
||||
//Save changes
|
||||
|
@ -430,7 +419,7 @@ namespace OpenSim.Data.MSSQL
|
|||
//TODO add index on PrimID in DB, if not already exist
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query("DELETE PRIMITEMS WHERE primID = @primID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@primID", primID.ToString());
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@primID", primID));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
@ -470,7 +459,7 @@ namespace OpenSim.Data.MSSQL
|
|||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
int rev = 0;
|
||||
int rev;
|
||||
if (reader.Read())
|
||||
{
|
||||
MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]);
|
||||
|
@ -509,22 +498,21 @@ namespace OpenSim.Data.MSSQL
|
|||
string sql = "delete from terrain where RegionUUID=@RegionUUID";
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@RegionUUID", regionID.ToString());
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
sql = "insert into terrain(RegionUUID, Revision, Heightfield)" +
|
||||
" values(@RegionUUID, @Revision, @Heightfield)";
|
||||
sql = "insert into terrain(RegionUUID, Revision, Heightfield) values(@RegionUUID, @Revision, @Heightfield)";
|
||||
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@RegionUUID", regionID.ToString());
|
||||
cmd.Parameters.AddWithValue("@Revision", revision);
|
||||
cmd.Parameters.AddWithValue("@Heightfield", serializeTerrain(terrain));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Revision", revision));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", serializeTerrain(terrain)));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
_Log.Info("[REGION DB]: Stored terrain revision r" + revision);
|
||||
_Log.Info("[REGION DB]: Stored terrain revision r " + revision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -541,12 +529,13 @@ namespace OpenSim.Data.MSSQL
|
|||
//Retrieve all land data from region
|
||||
using (AutoClosingSqlCommand cmdLandData = _Database.Query(sql))
|
||||
{
|
||||
cmdLandData.Parameters.AddWithValue("@RegionUUID", regionUUID.ToString());
|
||||
cmdLandData.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionUUID));
|
||||
|
||||
using (SqlDataReader readerLandData = cmdLandData.ExecuteReader())
|
||||
{
|
||||
while (readerLandData.Read())
|
||||
{
|
||||
// LandData data = buildLandData(readerLandData);
|
||||
landDataForRegion.Add(buildLandData(readerLandData));
|
||||
}
|
||||
}
|
||||
|
@ -558,7 +547,7 @@ namespace OpenSim.Data.MSSQL
|
|||
sql = "select * from landaccesslist where LandUUID = @LandUUID";
|
||||
using (AutoClosingSqlCommand cmdAccessList = _Database.Query(sql))
|
||||
{
|
||||
cmdAccessList.Parameters.AddWithValue("@LandUUID", landData.GlobalID.ToString());
|
||||
cmdAccessList.Parameters.Add(_Database.CreateParameter("@LandUUID", landData.GlobalID));
|
||||
using (SqlDataReader readerAccessList = cmdAccessList.ExecuteReader())
|
||||
{
|
||||
while (readerAccessList.Read())
|
||||
|
@ -643,7 +632,7 @@ VALUES
|
|||
RegionSettings regionSettings;
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query(sql))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID.ToString()));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID));
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
|
@ -674,7 +663,7 @@ VALUES
|
|||
public void StoreRegionSettings(RegionSettings regionSettings)
|
||||
{
|
||||
//Little check if regionUUID already exist in DB
|
||||
string regionUUID = null;
|
||||
string regionUUID;
|
||||
using (AutoClosingSqlCommand cmd = _Database.Query("SELECT regionUUID FROM regionsettings WHERE regionUUID = @regionUUID"))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionSettings.RegionUUID));
|
||||
|
@ -724,7 +713,7 @@ VALUES
|
|||
{
|
||||
DataTable dbItems = _PrimsDataSet.Tables["primitems"];
|
||||
|
||||
String sql = String.Format("primID = '{0}'", prim.UUID.ToString());
|
||||
String sql = String.Format("primID = '{0}'", prim.UUID);
|
||||
DataRow[] dbItemRows = dbItems.Select(sql);
|
||||
|
||||
IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
|
||||
|
@ -1446,6 +1435,12 @@ VALUES
|
|||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the prims data for region.
|
||||
/// </summary>
|
||||
/// <param name="regionUUID">The region UUID.</param>
|
||||
/// <param name="sceneGroupID">The scene group ID.</param>
|
||||
/// <param name="primID">The prim ID.</param>
|
||||
private void RetrievePrimsDataForRegion(UUID regionUUID, UUID sceneGroupID, string primID)
|
||||
{
|
||||
using (SqlConnection connection = _Database.DatabaseConnection())
|
||||
|
@ -1482,6 +1477,9 @@ VALUES
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Commits the dataset.
|
||||
/// </summary>
|
||||
private void CommitDataSet()
|
||||
{
|
||||
lock (_PrimsDataSet)
|
||||
|
@ -1513,6 +1511,10 @@ VALUES
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create commands for a dataadapter.
|
||||
/// </summary>
|
||||
/// <param name="dataAdapter">The data adapter.</param>
|
||||
private static void SetupCommands(SqlDataAdapter dataAdapter)
|
||||
{
|
||||
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,13 @@
|
|||
CREATE TABLE [assets] (
|
||||
[id] [varchar](36) NOT NULL,
|
||||
[name] [varchar](64) NOT NULL,
|
||||
[description] [varchar](64) NOT NULL,
|
||||
[assetType] [tinyint] NOT NULL,
|
||||
[local] [tinyint] NOT NULL,
|
||||
[temporary] [tinyint] NOT NULL,
|
||||
[data] [image] NOT NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[id] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
|
@ -0,0 +1,37 @@
|
|||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE [dbo].[regions](
|
||||
[regionHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionName] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[uuid] [varchar](255) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
[regionRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionSecret] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionDataURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverIP] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[locX] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[locY] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[locZ] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[eastOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[westOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[southOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[northOverrideHandle] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionAssetURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionAssetRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionAssetSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionUserURI] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionUserRecvKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionUserSendKey] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[regionMapTexture] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverHttpPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[serverRemotingPort] [varchar](255) COLLATE Latin1_General_CI_AS NULL,
|
||||
[owner_uuid] [varchar](36) COLLATE Latin1_General_CI_AS NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[uuid] ASC
|
||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
|
@ -0,0 +1,64 @@
|
|||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE [inventoryfolders] (
|
||||
[folderID] [varchar](36) NOT NULL default '',
|
||||
[agentID] [varchar](36) default NULL,
|
||||
[parentFolderID] [varchar](36) default NULL,
|
||||
[folderName] [varchar](64) default NULL,
|
||||
[type] [smallint] NOT NULL default 0,
|
||||
[version] [int] NOT NULL default 0,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[folderID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [owner] ON [inventoryfolders]
|
||||
(
|
||||
[agentID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [parent] ON [inventoryfolders]
|
||||
(
|
||||
[parentFolderID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE TABLE [inventoryitems] (
|
||||
[inventoryID] [varchar](36) NOT NULL default '',
|
||||
[assetID] [varchar](36) default NULL,
|
||||
[assetType] [int] default NULL,
|
||||
[parentFolderID] [varchar](36) default NULL,
|
||||
[avatarID] [varchar](36) default NULL,
|
||||
[inventoryName] [varchar](64) default NULL,
|
||||
[inventoryDescription] [varchar](128) default NULL,
|
||||
[inventoryNextPermissions] [int] default NULL,
|
||||
[inventoryCurrentPermissions] [int] default NULL,
|
||||
[invType] [int] default NULL,
|
||||
[creatorID] [varchar](36) default NULL,
|
||||
[inventoryBasePermissions] [int] NOT NULL default 0,
|
||||
[inventoryEveryOnePermissions] [int] NOT NULL default 0,
|
||||
[salePrice] [int] default NULL,
|
||||
[saleType] [tinyint] default NULL,
|
||||
[creationDate] [int] default NULL,
|
||||
[groupID] [varchar](36) default NULL,
|
||||
[groupOwned] [bit] default NULL,
|
||||
[flags] [int] default NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[inventoryID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [owner] ON [inventoryitems]
|
||||
(
|
||||
[avatarID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [folder] ON [inventoryitems]
|
||||
(
|
||||
[parentFolderID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
|
@ -0,0 +1,224 @@
|
|||
CREATE TABLE [users] (
|
||||
[UUID] [varchar](36) NOT NULL default '',
|
||||
[username] [varchar](32) NOT NULL,
|
||||
[lastname] [varchar](32) NOT NULL,
|
||||
[passwordHash] [varchar](32) NOT NULL,
|
||||
[passwordSalt] [varchar](32) NOT NULL,
|
||||
[homeRegion] [bigint] default NULL,
|
||||
[homeLocationX] [float] default NULL,
|
||||
[homeLocationY] [float] default NULL,
|
||||
[homeLocationZ] [float] default NULL,
|
||||
[homeLookAtX] [float] default NULL,
|
||||
[homeLookAtY] [float] default NULL,
|
||||
[homeLookAtZ] [float] default NULL,
|
||||
[created] [int] NOT NULL,
|
||||
[lastLogin] [int] NOT NULL,
|
||||
[userInventoryURI] [varchar](255) default NULL,
|
||||
[userAssetURI] [varchar](255) default NULL,
|
||||
[profileCanDoMask] [int] default NULL,
|
||||
[profileWantDoMask] [int] default NULL,
|
||||
[profileAboutText] [ntext],
|
||||
[profileFirstText] [ntext],
|
||||
[profileImage] [varchar](36) default NULL,
|
||||
[profileFirstImage] [varchar](36) default NULL,
|
||||
[webLoginKey] [varchar](36) default NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[UUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [usernames] ON [users]
|
||||
(
|
||||
[username] ASC,
|
||||
[lastname] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE TABLE [agents] (
|
||||
[UUID] [varchar](36) NOT NULL,
|
||||
[sessionID] [varchar](36) NOT NULL,
|
||||
[secureSessionID] [varchar](36) NOT NULL,
|
||||
[agentIP] [varchar](16) NOT NULL,
|
||||
[agentPort] [int] NOT NULL,
|
||||
[agentOnline] [tinyint] NOT NULL,
|
||||
[loginTime] [int] NOT NULL,
|
||||
[logoutTime] [int] NOT NULL,
|
||||
[currentRegion] [varchar](36) NOT NULL,
|
||||
[currentHandle] [bigint] NOT NULL,
|
||||
[currentPos] [varchar](64) NOT NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[UUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [session] ON [agents]
|
||||
(
|
||||
[sessionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [ssession] ON [agents]
|
||||
(
|
||||
[secureSessionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE TABLE [dbo].[userfriends](
|
||||
[ownerID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
[friendID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
[friendPerms] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
|
||||
[datetimestamp] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
CREATE TABLE [avatarappearance] (
|
||||
[Owner] [varchar](36) NOT NULL,
|
||||
[Serial] int NOT NULL,
|
||||
[Visual_Params] [image] NOT NULL,
|
||||
[Texture] [image] NOT NULL,
|
||||
[Avatar_Height] float NOT NULL,
|
||||
[Body_Item] [varchar](36) NOT NULL,
|
||||
[Body_Asset] [varchar](36) NOT NULL,
|
||||
[Skin_Item] [varchar](36) NOT NULL,
|
||||
[Skin_Asset] [varchar](36) NOT NULL,
|
||||
[Hair_Item] [varchar](36) NOT NULL,
|
||||
[Hair_Asset] [varchar](36) NOT NULL,
|
||||
[Eyes_Item] [varchar](36) NOT NULL,
|
||||
[Eyes_Asset] [varchar](36) NOT NULL,
|
||||
[Shirt_Item] [varchar](36) NOT NULL,
|
||||
[Shirt_Asset] [varchar](36) NOT NULL,
|
||||
[Pants_Item] [varchar](36) NOT NULL,
|
||||
[Pants_Asset] [varchar](36) NOT NULL,
|
||||
[Shoes_Item] [varchar](36) NOT NULL,
|
||||
[Shoes_Asset] [varchar](36) NOT NULL,
|
||||
[Socks_Item] [varchar](36) NOT NULL,
|
||||
[Socks_Asset] [varchar](36) NOT NULL,
|
||||
[Jacket_Item] [varchar](36) NOT NULL,
|
||||
[Jacket_Asset] [varchar](36) NOT NULL,
|
||||
[Gloves_Item] [varchar](36) NOT NULL,
|
||||
[Gloves_Asset] [varchar](36) NOT NULL,
|
||||
[Undershirt_Item] [varchar](36) NOT NULL,
|
||||
[Undershirt_Asset] [varchar](36) NOT NULL,
|
||||
[Underpants_Item] [varchar](36) NOT NULL,
|
||||
[Underpants_Asset] [varchar](36) NOT NULL,
|
||||
[Skirt_Item] [varchar](36) NOT NULL,
|
||||
[Skirt_Asset] [varchar](36) NOT NULL,
|
||||
|
||||
PRIMARY KEY CLUSTERED (
|
||||
[Owner]
|
||||
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
CREATE TABLE [users] (
|
||||
[UUID] [varchar](36) NOT NULL default '',
|
||||
[username] [varchar](32) NOT NULL,
|
||||
[lastname] [varchar](32) NOT NULL,
|
||||
[passwordHash] [varchar](32) NOT NULL,
|
||||
[passwordSalt] [varchar](32) NOT NULL,
|
||||
[homeRegion] [bigint] default NULL,
|
||||
[homeLocationX] [float] default NULL,
|
||||
[homeLocationY] [float] default NULL,
|
||||
[homeLocationZ] [float] default NULL,
|
||||
[homeLookAtX] [float] default NULL,
|
||||
[homeLookAtY] [float] default NULL,
|
||||
[homeLookAtZ] [float] default NULL,
|
||||
[created] [int] NOT NULL,
|
||||
[lastLogin] [int] NOT NULL,
|
||||
[userInventoryURI] [varchar](255) default NULL,
|
||||
[userAssetURI] [varchar](255) default NULL,
|
||||
[profileCanDoMask] [int] default NULL,
|
||||
[profileWantDoMask] [int] default NULL,
|
||||
[profileAboutText] [ntext],
|
||||
[profileFirstText] [ntext],
|
||||
[profileImage] [varchar](36) default NULL,
|
||||
[profileFirstImage] [varchar](36) default NULL,
|
||||
[webLoginKey] [varchar](36) default NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[UUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [usernames] ON [users]
|
||||
(
|
||||
[username] ASC,
|
||||
[lastname] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE TABLE [agents] (
|
||||
[UUID] [varchar](36) NOT NULL,
|
||||
[sessionID] [varchar](36) NOT NULL,
|
||||
[secureSessionID] [varchar](36) NOT NULL,
|
||||
[agentIP] [varchar](16) NOT NULL,
|
||||
[agentPort] [int] NOT NULL,
|
||||
[agentOnline] [tinyint] NOT NULL,
|
||||
[loginTime] [int] NOT NULL,
|
||||
[logoutTime] [int] NOT NULL,
|
||||
[currentRegion] [varchar](36) NOT NULL,
|
||||
[currentHandle] [bigint] NOT NULL,
|
||||
[currentPos] [varchar](64) NOT NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[UUID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX [session] ON [agents]
|
||||
(
|
||||
[sessionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX [ssession] ON [agents]
|
||||
(
|
||||
[secureSessionID] ASC
|
||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE TABLE [dbo].[userfriends](
|
||||
[ownerID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
[friendID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL,
|
||||
[friendPerms] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
|
||||
[datetimestamp] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
CREATE TABLE [avatarappearance] (
|
||||
[Owner] [varchar](36) NOT NULL,
|
||||
[Serial] int NOT NULL,
|
||||
[Visual_Params] [image] NOT NULL,
|
||||
[Texture] [image] NOT NULL,
|
||||
[Avatar_Height] float NOT NULL,
|
||||
[Body_Item] [varchar](36) NOT NULL,
|
||||
[Body_Asset] [varchar](36) NOT NULL,
|
||||
[Skin_Item] [varchar](36) NOT NULL,
|
||||
[Skin_Asset] [varchar](36) NOT NULL,
|
||||
[Hair_Item] [varchar](36) NOT NULL,
|
||||
[Hair_Asset] [varchar](36) NOT NULL,
|
||||
[Eyes_Item] [varchar](36) NOT NULL,
|
||||
[Eyes_Asset] [varchar](36) NOT NULL,
|
||||
[Shirt_Item] [varchar](36) NOT NULL,
|
||||
[Shirt_Asset] [varchar](36) NOT NULL,
|
||||
[Pants_Item] [varchar](36) NOT NULL,
|
||||
[Pants_Asset] [varchar](36) NOT NULL,
|
||||
[Shoes_Item] [varchar](36) NOT NULL,
|
||||
[Shoes_Asset] [varchar](36) NOT NULL,
|
||||
[Socks_Item] [varchar](36) NOT NULL,
|
||||
[Socks_Asset] [varchar](36) NOT NULL,
|
||||
[Jacket_Item] [varchar](36) NOT NULL,
|
||||
[Jacket_Asset] [varchar](36) NOT NULL,
|
||||
[Gloves_Item] [varchar](36) NOT NULL,
|
||||
[Gloves_Asset] [varchar](36) NOT NULL,
|
||||
[Undershirt_Item] [varchar](36) NOT NULL,
|
||||
[Undershirt_Asset] [varchar](36) NOT NULL,
|
||||
[Underpants_Item] [varchar](36) NOT NULL,
|
||||
[Underpants_Asset] [varchar](36) NOT NULL,
|
||||
[Skirt_Item] [varchar](36) NOT NULL,
|
||||
[Skirt_Asset] [varchar](36) NOT NULL,
|
||||
|
||||
PRIMARY KEY CLUSTERED (
|
||||
[Owner]
|
||||
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY]
|
|
@ -0,0 +1,29 @@
|
|||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE Tmp_assets
|
||||
(
|
||||
id varchar(36) NOT NULL,
|
||||
name varchar(64) NOT NULL,
|
||||
description varchar(64) NOT NULL,
|
||||
assetType tinyint NOT NULL,
|
||||
local bit NOT NULL,
|
||||
temporary bit NOT NULL,
|
||||
data image NOT NULL
|
||||
) ON [PRIMARY]
|
||||
TEXTIMAGE_ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM assets)
|
||||
EXEC('INSERT INTO Tmp_assets (id, name, description, assetType, local, temporary, data)
|
||||
SELECT id, name, description, assetType, CONVERT(bit, local), CONVERT(bit, temporary), data FROM assets WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE assets
|
||||
|
||||
EXECUTE sp_rename N'Tmp_assets', N'assets', 'OBJECT'
|
||||
|
||||
ALTER TABLE dbo.assets ADD CONSTRAINT
|
||||
PK__assets__id PRIMARY KEY CLUSTERED
|
||||
(
|
||||
id
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
|
@ -0,0 +1,18 @@
|
|||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE users ADD homeRegionID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000';
|
||||
ALTER TABLE users ADD userFlags int NOT NULL default 0;
|
||||
ALTER TABLE users ADD godLevel int NOT NULL default 0;
|
||||
ALTER TABLE users ADD customType varchar(32) not null default '';
|
||||
ALTER TABLE users ADD partner varchar(36) not null default '00000000-0000-0000-0000-000000000000';
|
||||
|
||||
COMMIT
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE users ADD homeRegionID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000';
|
||||
ALTER TABLE users ADD userFlags int NOT NULL default 0;
|
||||
ALTER TABLE users ADD godLevel int NOT NULL default 0;
|
||||
ALTER TABLE users ADD customType varchar(32) not null default '';
|
||||
ALTER TABLE users ADD partner varchar(36) not null default '00000000-0000-0000-0000-000000000000';
|
||||
|
||||
COMMIT
|
|
@ -0,0 +1,22 @@
|
|||
BEGIN TRANSACTION
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_regions_name ON dbo.regions
|
||||
(
|
||||
regionName
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_regions_handle ON dbo.regions
|
||||
(
|
||||
regionHandle
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_regions_override ON dbo.regions
|
||||
(
|
||||
eastOverrideHandle,
|
||||
westOverrideHandle,
|
||||
southOverrideHandle,
|
||||
northOverrideHandle
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
|
@ -0,0 +1,30 @@
|
|||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE [avatarattachments] (
|
||||
[UUID] varchar(36) NOT NULL
|
||||
, [attachpoint] int NOT NULL
|
||||
, [item] varchar(36) NOT NULL
|
||||
, [asset] varchar(36) NOT NULL)
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_avatarattachments ON dbo.avatarattachments
|
||||
(
|
||||
UUID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
COMMIT
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE [avatarattachments] (
|
||||
[UUID] varchar(36) NOT NULL
|
||||
, [attachpoint] int NOT NULL
|
||||
, [item] varchar(36) NOT NULL
|
||||
, [asset] varchar(36) NOT NULL)
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_avatarattachments ON dbo.avatarattachments
|
||||
(
|
||||
UUID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
|
||||
COMMIT
|
|
@ -1,6 +1,6 @@
|
|||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE dbo.Tmp_primitems
|
||||
CREATE TABLE Tmp_primitems
|
||||
(
|
||||
itemID varchar(36) NOT NULL,
|
||||
primID varchar(36) NULL,
|
||||
|
@ -22,15 +22,15 @@ CREATE TABLE dbo.Tmp_primitems
|
|||
groupPermissions int NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.primitems)
|
||||
EXEC('INSERT INTO dbo.Tmp_primitems (itemID, primID, assetID, parentFolderID, invType, assetType, name, description, creationDate, creatorID, ownerID, lastOwnerID, groupID, nextPermissions, currentPermissions, basePermissions, everyonePermissions, groupPermissions)
|
||||
IF EXISTS(SELECT * FROM primitems)
|
||||
EXEC('INSERT INTO Tmp_primitems (itemID, primID, assetID, parentFolderID, invType, assetType, name, description, creationDate, creatorID, ownerID, lastOwnerID, groupID, nextPermissions, currentPermissions, basePermissions, everyonePermissions, groupPermissions)
|
||||
SELECT CONVERT(varchar(36), itemID), CONVERT(varchar(36), primID), CONVERT(varchar(36), assetID), CONVERT(varchar(36), parentFolderID), invType, assetType, name, description, creationDate, CONVERT(varchar(36), creatorID), CONVERT(varchar(36), ownerID), CONVERT(varchar(36), lastOwnerID), CONVERT(varchar(36), groupID), nextPermissions, currentPermissions, basePermissions, everyonePermissions, groupPermissions')
|
||||
|
||||
DROP TABLE dbo.primitems
|
||||
DROP TABLE primitems
|
||||
|
||||
EXECUTE sp_rename N'dbo.Tmp_primitems', N'primitems', 'OBJECT'
|
||||
EXECUTE sp_rename N'Tmp_primitems', N'primitems', 'OBJECT'
|
||||
|
||||
ALTER TABLE dbo.primitems ADD CONSTRAINT
|
||||
ALTER TABLE primitems ADD CONSTRAINT
|
||||
PK__primitems__0A688BB1 PRIMARY KEY CLUSTERED
|
||||
(
|
||||
itemID
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE Tmp_userfriends
|
||||
(
|
||||
ownerID varchar(36) NOT NULL,
|
||||
friendID varchar(36) NOT NULL,
|
||||
friendPerms int NOT NULL,
|
||||
datetimestamp int NOT NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM userfriends)
|
||||
EXEC('INSERT INTO dbo.Tmp_userfriends (ownerID, friendID, friendPerms, datetimestamp)
|
||||
SELECT CONVERT(varchar(36), ownerID), CONVERT(varchar(36), friendID), CONVERT(int, friendPerms), CONVERT(int, datetimestamp) FROM dbo.userfriends WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE dbo.userfriends
|
||||
|
||||
EXECUTE sp_rename N'Tmp_userfriends', N'userfriends', 'OBJECT'
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_userfriends_ownerID ON userfriends
|
||||
(
|
||||
ownerID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_userfriends_friendID ON userfriends
|
||||
(
|
||||
friendID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE Tmp_userfriends
|
||||
(
|
||||
ownerID varchar(36) NOT NULL,
|
||||
friendID varchar(36) NOT NULL,
|
||||
friendPerms int NOT NULL,
|
||||
datetimestamp int NOT NULL
|
||||
) ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.userfriends)
|
||||
EXEC('INSERT INTO dbo.Tmp_userfriends (ownerID, friendID, friendPerms, datetimestamp)
|
||||
SELECT CONVERT(varchar(36), ownerID), CONVERT(varchar(36), friendID), CONVERT(int, friendPerms), CONVERT(int, datetimestamp) FROM dbo.userfriends WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE dbo.userfriends
|
||||
|
||||
EXECUTE sp_rename N'Tmp_userfriends', N'userfriends', 'OBJECT'
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_userfriends_ownerID ON userfriends
|
||||
(
|
||||
ownerID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
CREATE NONCLUSTERED INDEX IX_userfriends_friendID ON userfriends
|
||||
(
|
||||
friendID
|
||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
|
||||
COMMIT
|
|
@ -1,6 +1,6 @@
|
|||
BEGIN TRANSACTION
|
||||
|
||||
CREATE TABLE dbo.Tmp_primshapes
|
||||
CREATE TABLE Tmp_primshapes
|
||||
(
|
||||
UUID varchar(36) NOT NULL,
|
||||
Shape int NULL,
|
||||
|
@ -32,15 +32,15 @@ CREATE TABLE dbo.Tmp_primshapes
|
|||
) ON [PRIMARY]
|
||||
TEXTIMAGE_ON [PRIMARY]
|
||||
|
||||
IF EXISTS(SELECT * FROM dbo.primshapes)
|
||||
EXEC('INSERT INTO dbo.Tmp_primshapes (UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, ProfileEnd, ProfileCurve, ProfileHollow, State, Texture, ExtraParams)
|
||||
SELECT CONVERT(varchar(36), UUID), Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, ProfileEnd, ProfileCurve, ProfileHollow, State, Texture, ExtraParams FROM dbo.primshapes WITH (HOLDLOCK TABLOCKX)')
|
||||
IF EXISTS(SELECT * FROM primshapes)
|
||||
EXEC('INSERT INTO Tmp_primshapes (UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, ProfileEnd, ProfileCurve, ProfileHollow, State, Texture, ExtraParams)
|
||||
SELECT CONVERT(varchar(36), UUID), Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, ProfileEnd, ProfileCurve, ProfileHollow, State, Texture, ExtraParams FROM primshapes WITH (HOLDLOCK TABLOCKX)')
|
||||
|
||||
DROP TABLE dbo.primshapes
|
||||
DROP TABLE primshapes
|
||||
|
||||
EXECUTE sp_rename N'dbo.Tmp_primshapes', N'primshapes', 'OBJECT'
|
||||
EXECUTE sp_rename N'Tmp_primshapes', N'primshapes', 'OBJECT'
|
||||
|
||||
ALTER TABLE dbo.primshapes ADD CONSTRAINT
|
||||
ALTER TABLE primshapes ADD CONSTRAINT
|
||||
PK__primshapes__0880433F PRIMARY KEY CLUSTERED
|
||||
(
|
||||
UUID
|
||||
|
|
|
@ -434,7 +434,7 @@ namespace OpenSim.Data.MySQL
|
|||
/// <param name="uuid">the sim UUID</param>
|
||||
/// <returns>Successful?</returns>
|
||||
//public DataResponse DeleteProfile(RegionProfileData profile)
|
||||
public DataResponse DeleteProfile(string uuid)
|
||||
override public DataResponse DeleteProfile(string uuid)
|
||||
{
|
||||
MySQLSuperManager dbm = GetLockedConnection();
|
||||
|
||||
|
|
|
@ -210,6 +210,25 @@ namespace OpenSim.Data.SQLite
|
|||
return AddProfile(profile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a sim profile from the database
|
||||
/// </summary>
|
||||
/// <param name="uuid">the sim UUID</param>
|
||||
/// <returns>Successful?</returns>
|
||||
//public DataResponse DeleteProfile(RegionProfileData profile)
|
||||
override public DataResponse DeleteProfile(string uuid)
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["uuid"] = uuid;
|
||||
|
||||
IDbCommand result = database.Query("DELETE FROM regions WHERE uuid = @uuid", param);
|
||||
if (result.ExecuteNonQuery() > 0)
|
||||
{
|
||||
return DataResponse.RESPONSE_OK;
|
||||
}
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
|
||||
/// </summary>
|
||||
|
|
|
@ -136,8 +136,9 @@ namespace OpenSim.Grid.GridServer
|
|||
{
|
||||
return plugin.GetProfileByHandle(handle);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Debug("[storage]: " + ex.Message);
|
||||
m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name);
|
||||
}
|
||||
}
|
||||
|
@ -500,14 +501,11 @@ namespace OpenSim.Grid.GridServer
|
|||
RegionProfileData neighbour;
|
||||
Hashtable NeighbourBlock;
|
||||
|
||||
bool fastMode = false; // Only compatible with MySQL right now
|
||||
//First use the fast method. (not implemented in SQLLite)
|
||||
Dictionary<ulong, RegionProfileData> neighbours = GetRegions(sim.regionLocX - 1, sim.regionLocY - 1, sim.regionLocX + 1, sim.regionLocY + 1);
|
||||
|
||||
if (fastMode)
|
||||
if (neighbours.Count > 0)
|
||||
{
|
||||
Dictionary<ulong, RegionProfileData> neighbours =
|
||||
GetRegions(sim.regionLocX - 1, sim.regionLocY - 1, sim.regionLocX + 1,
|
||||
sim.regionLocY + 1);
|
||||
|
||||
foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours)
|
||||
{
|
||||
NeighbourBlock = new Hashtable();
|
||||
|
@ -657,8 +655,7 @@ namespace OpenSim.Grid.GridServer
|
|||
//TheSim = GetRegion(new UUID((string) requestData["UUID"]));
|
||||
uuid = requestData["UUID"].ToString();
|
||||
m_log.InfoFormat("[LOGOUT]: Logging out region: {0}", uuid);
|
||||
|
||||
// logToDB((new UUID((string)requestData["UUID"])).ToString(),"XmlRpcDeleteRegionMethod","", 5,"Attempting delete with UUID.");
|
||||
// logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcDeleteRegionMethod","", 5,"Attempting delete with UUID.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -671,9 +668,12 @@ namespace OpenSim.Grid.GridServer
|
|||
//OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData();
|
||||
try
|
||||
{
|
||||
MySQLGridData mysqldata = (MySQLGridData)(plugin);
|
||||
//Nice are we not using multiple databases?
|
||||
//MySQLGridData mysqldata = (MySQLGridData)(plugin);
|
||||
|
||||
//DataResponse insertResponse = mysqldata.DeleteProfile(TheSim);
|
||||
DataResponse insertResponse = mysqldata.DeleteProfile(uuid);
|
||||
DataResponse insertResponse = plugin.DeleteProfile(uuid);
|
||||
|
||||
switch (insertResponse)
|
||||
{
|
||||
case DataResponse.RESPONSE_OK:
|
||||
|
@ -696,7 +696,7 @@ namespace OpenSim.Grid.GridServer
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
m_log.Error("storage Unable to delete region " + uuid + " via MySQL");
|
||||
m_log.Error("storage Unable to delete region " + uuid + " via " + plugin.Name);
|
||||
//MainLog.Instance.Warn("storage", e.ToString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue