Remove unmaintained MSSQL support.
This has not been maintained for more than 2 years, is unimplemented for newer features (e.g. built-in groups) and has no core developers using it. If somebody fixes these issues then it could be reinstated.mb-throttle-test
parent
73234e2098
commit
d9f7aa41c1
|
@ -1,314 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Data;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using log4net;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A MSSQL Interface for the Asset server
|
|
||||||
/// </summary>
|
|
||||||
public class MSSQLAssetData : AssetDataBase
|
|
||||||
{
|
|
||||||
private const string _migrationStore = "AssetStore";
|
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
private long m_ticksToEpoch;
|
|
||||||
/// <summary>
|
|
||||||
/// Database manager
|
|
||||||
/// </summary>
|
|
||||||
private MSSQLManager m_database;
|
|
||||||
private string m_connectionString;
|
|
||||||
|
|
||||||
#region IPlugin Members
|
|
||||||
|
|
||||||
override public void Dispose() { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <para>Initialises asset interface</para>
|
|
||||||
/// </summary>
|
|
||||||
// [Obsolete("Cannot be default-initialized!")]
|
|
||||||
override public void Initialise()
|
|
||||||
{
|
|
||||||
m_log.Info("[MSSQLAssetData]: " + 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)
|
|
||||||
{
|
|
||||||
m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
|
|
||||||
|
|
||||||
m_database = new MSSQLManager(connectionString);
|
|
||||||
m_connectionString = connectionString;
|
|
||||||
|
|
||||||
//New migration to check for DB changes
|
|
||||||
m_database.CheckMigration(_migrationStore);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Database provider version.
|
|
||||||
/// </summary>
|
|
||||||
override public string Version
|
|
||||||
{
|
|
||||||
get { return m_database.getVersion(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The name of this DB provider.
|
|
||||||
/// </summary>
|
|
||||||
override public string Name
|
|
||||||
{
|
|
||||||
get { return "MSSQL Asset storage engine"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IAssetDataPlugin Members
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Fetch Asset from m_database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assetID">the asset UUID</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
override public AssetBase GetAsset(UUID assetID)
|
|
||||||
{
|
|
||||||
string sql = "SELECT * FROM assets WHERE id = @id";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("id", assetID));
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
AssetBase asset = new AssetBase(
|
|
||||||
DBGuid.FromDB(reader["id"]),
|
|
||||||
(string)reader["name"],
|
|
||||||
Convert.ToSByte(reader["assetType"]),
|
|
||||||
reader["creatorid"].ToString()
|
|
||||||
);
|
|
||||||
// Region Main
|
|
||||||
asset.Description = (string)reader["description"];
|
|
||||||
asset.Local = Convert.ToBoolean(reader["local"]);
|
|
||||||
asset.Temporary = Convert.ToBoolean(reader["temporary"]);
|
|
||||||
asset.Flags = (AssetFlags)(Convert.ToInt32(reader["asset_flags"]));
|
|
||||||
asset.Data = (byte[])reader["data"];
|
|
||||||
return asset;
|
|
||||||
}
|
|
||||||
return null; // throw new Exception("No rows to return");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create asset in m_database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="asset">the asset</param>
|
|
||||||
override public void StoreAsset(AssetBase asset)
|
|
||||||
{
|
|
||||||
|
|
||||||
string sql =
|
|
||||||
@"IF EXISTS(SELECT * FROM assets WHERE id=@id)
|
|
||||||
UPDATE assets set name = @name, description = @description, assetType = @assetType,
|
|
||||||
local = @local, temporary = @temporary, creatorid = @creatorid, data = @data
|
|
||||||
WHERE id=@id
|
|
||||||
ELSE
|
|
||||||
INSERT INTO assets
|
|
||||||
([id], [name], [description], [assetType], [local],
|
|
||||||
[temporary], [create_time], [access_time], [creatorid], [asset_flags], [data])
|
|
||||||
VALUES
|
|
||||||
(@id, @name, @description, @assetType, @local,
|
|
||||||
@temporary, @create_time, @access_time, @creatorid, @asset_flags, @data)";
|
|
||||||
|
|
||||||
string assetName = asset.Name;
|
|
||||||
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
|
|
||||||
{
|
|
||||||
assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
|
|
||||||
m_log.WarnFormat(
|
|
||||||
"[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
|
||||||
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
string assetDescription = asset.Description;
|
|
||||||
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
|
|
||||||
{
|
|
||||||
assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
|
|
||||||
m_log.WarnFormat(
|
|
||||||
"[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
|
||||||
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("name", assetName));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("description", assetDescription));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("access_time", now));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("create_time", now));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("asset_flags", (int)asset.Flags));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("creatorid", asset.Metadata.CreatorID));
|
|
||||||
command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
|
|
||||||
conn.Open();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[ASSET DB]: Error storing item :" + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Commented out since currently unused - this probably should be called in GetAsset()
|
|
||||||
// private void UpdateAccessTime(AssetBase asset)
|
|
||||||
// {
|
|
||||||
// using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id"))
|
|
||||||
// {
|
|
||||||
// int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
|
|
||||||
// cmd.Parameters.AddWithValue("@id", asset.FullID.ToString());
|
|
||||||
// cmd.Parameters.AddWithValue("@access_time", now);
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// cmd.ExecuteNonQuery();
|
|
||||||
// }
|
|
||||||
// catch (Exception e)
|
|
||||||
// {
|
|
||||||
// m_log.Error(e.ToString());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if the assets exist in the database.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uuids">The assets' IDs</param>
|
|
||||||
/// <returns>For each asset: true if it exists, false otherwise</returns>
|
|
||||||
public override bool[] AssetsExist(UUID[] uuids)
|
|
||||||
{
|
|
||||||
if (uuids.Length == 0)
|
|
||||||
return new bool[0];
|
|
||||||
|
|
||||||
HashSet<UUID> exist = new HashSet<UUID>();
|
|
||||||
|
|
||||||
string ids = "'" + string.Join("','", uuids) + "'";
|
|
||||||
string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
UUID id = DBGuid.FromDB(reader["id"]);
|
|
||||||
exist.Add(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool[] results = new bool[uuids.Length];
|
|
||||||
for (int i = 0; i < uuids.Length; i++)
|
|
||||||
results[i] = exist.Contains(uuids[i]);
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of AssetMetadata objects. The list is a subset of
|
|
||||||
/// the entire data set offset by <paramref name="start" /> containing
|
|
||||||
/// <paramref name="count" /> elements.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="start">The number of results to discard from the total data set.</param>
|
|
||||||
/// <param name="count">The number of rows the returned list should contain.</param>
|
|
||||||
/// <returns>A list of AssetMetadata objects.</returns>
|
|
||||||
public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
|
|
||||||
{
|
|
||||||
List<AssetMetadata> retList = new List<AssetMetadata>(count);
|
|
||||||
string sql = @"WITH OrderedAssets AS
|
|
||||||
(
|
|
||||||
SELECT id, name, description, assetType, temporary, creatorid,
|
|
||||||
RowNumber = ROW_NUMBER() OVER (ORDER BY id)
|
|
||||||
FROM assets
|
|
||||||
)
|
|
||||||
SELECT *
|
|
||||||
FROM OrderedAssets
|
|
||||||
WHERE RowNumber BETWEEN @start AND @stop;";
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("start", start));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("stop", start + count - 1));
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
AssetMetadata metadata = new AssetMetadata();
|
|
||||||
metadata.FullID = DBGuid.FromDB(reader["id"]);
|
|
||||||
metadata.Name = (string)reader["name"];
|
|
||||||
metadata.Description = (string)reader["description"];
|
|
||||||
metadata.Type = Convert.ToSByte(reader["assetType"]);
|
|
||||||
metadata.Temporary = Convert.ToBoolean(reader["temporary"]);
|
|
||||||
metadata.CreatorID = (string)reader["creatorid"];
|
|
||||||
retList.Add(metadata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Delete(string id)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,227 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
public class MSSQLAuthenticationData : IAuthenticationData
|
|
||||||
{
|
|
||||||
private string m_Realm;
|
|
||||||
private List<string> m_ColumnNames = null;
|
|
||||||
private int m_LastExpire = 0;
|
|
||||||
private string m_ConnectionString;
|
|
||||||
private MSSQLManager m_database;
|
|
||||||
|
|
||||||
public MSSQLAuthenticationData(string connectionString, string realm)
|
|
||||||
{
|
|
||||||
m_Realm = realm;
|
|
||||||
m_ConnectionString = connectionString;
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
Migration m = new Migration(conn, GetType().Assembly, "AuthStore");
|
|
||||||
m_database = new MSSQLManager(m_ConnectionString);
|
|
||||||
m.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthenticationData Get(UUID principalID)
|
|
||||||
{
|
|
||||||
AuthenticationData ret = new AuthenticationData();
|
|
||||||
ret.Data = new Dictionary<string, object>();
|
|
||||||
|
|
||||||
string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm);
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader result = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (result.Read())
|
|
||||||
{
|
|
||||||
ret.PrincipalID = principalID;
|
|
||||||
|
|
||||||
if (m_ColumnNames == null)
|
|
||||||
{
|
|
||||||
m_ColumnNames = new List<string>();
|
|
||||||
|
|
||||||
DataTable schemaTable = result.GetSchemaTable();
|
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string s in m_ColumnNames)
|
|
||||||
{
|
|
||||||
if (s == "UUID")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ret.Data[s] = result[s].ToString();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Store(AuthenticationData data)
|
|
||||||
{
|
|
||||||
if (data.Data.ContainsKey("UUID"))
|
|
||||||
data.Data.Remove("UUID");
|
|
||||||
|
|
||||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
|
||||||
StringBuilder updateBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
updateBuilder.AppendFormat("update {0} set ", m_Realm);
|
|
||||||
|
|
||||||
bool first = true;
|
|
||||||
foreach (string field in fields)
|
|
||||||
{
|
|
||||||
if (!first)
|
|
||||||
updateBuilder.Append(", ");
|
|
||||||
updateBuilder.AppendFormat("{0} = @{0}",field);
|
|
||||||
|
|
||||||
first = false;
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field]));
|
|
||||||
}
|
|
||||||
|
|
||||||
updateBuilder.Append(" where UUID = @principalID");
|
|
||||||
|
|
||||||
cmd.CommandText = updateBuilder.ToString();
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID));
|
|
||||||
|
|
||||||
conn.Open();
|
|
||||||
if (cmd.ExecuteNonQuery() < 1)
|
|
||||||
{
|
|
||||||
StringBuilder insertBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
insertBuilder.AppendFormat("insert into {0} (UUID, ", m_Realm);
|
|
||||||
insertBuilder.Append(String.Join(", ", fields));
|
|
||||||
insertBuilder.Append(") values (@principalID, @");
|
|
||||||
insertBuilder.Append(String.Join(", @", fields));
|
|
||||||
insertBuilder.Append(")");
|
|
||||||
|
|
||||||
cmd.CommandText = insertBuilder.ToString();
|
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetDataItem(UUID principalID, string item, string value)
|
|
||||||
{
|
|
||||||
string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item);
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@" + item, value));
|
|
||||||
conn.Open();
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetToken(UUID principalID, string token, int lifetime)
|
|
||||||
{
|
|
||||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
|
||||||
DoExpire();
|
|
||||||
|
|
||||||
string sql = "insert into tokens (UUID, token, validity) values (@principalID, @token, @lifetime)";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@token", token));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@lifetime", DateTime.Now.AddMinutes(lifetime)));
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CheckToken(UUID principalID, string token, int lifetime)
|
|
||||||
{
|
|
||||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
|
||||||
DoExpire();
|
|
||||||
|
|
||||||
DateTime validDate = DateTime.Now.AddMinutes(lifetime);
|
|
||||||
string sql = "update tokens set validity = @validDate where UUID = @principalID and token = @token and validity > GetDate()";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@token", token));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@validDate", validDate));
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DoExpire()
|
|
||||||
{
|
|
||||||
DateTime currentDateTime = DateTime.Now;
|
|
||||||
string sql = "delete from tokens where validity < @currentDateTime";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@currentDateTime", currentDateTime));
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
m_LastExpire = System.Environment.TickCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A MSSQL Interface for Avatar Storage
|
|
||||||
/// </summary>
|
|
||||||
public class MSSQLAvatarData : MSSQLGenericTableHandler<AvatarBaseData>,
|
|
||||||
IAvatarData
|
|
||||||
{
|
|
||||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public MSSQLAvatarData(string connectionString, string realm) :
|
|
||||||
base(connectionString, realm, "Avatar")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(UUID principalID, string name)
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
cmd.CommandText = String.Format("DELETE FROM {0} where [PrincipalID] = @PrincipalID and [Name] = @Name", m_Realm);
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@Name", name));
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,577 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
public class MSSQLEstateStore : IEstateDataStore
|
|
||||||
{
|
|
||||||
private const string _migrationStore = "EstateStore";
|
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private MSSQLManager _Database;
|
|
||||||
private string m_connectionString;
|
|
||||||
private FieldInfo[] _Fields;
|
|
||||||
private Dictionary<string, FieldInfo> _FieldMap = new Dictionary<string, FieldInfo>();
|
|
||||||
|
|
||||||
#region Public methods
|
|
||||||
|
|
||||||
public MSSQLEstateStore()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public MSSQLEstateStore(string connectionString)
|
|
||||||
{
|
|
||||||
Initialise(connectionString);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initialises the estatedata class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connectionString">connectionString.</param>
|
|
||||||
public void Initialise(string connectionString)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(connectionString))
|
|
||||||
{
|
|
||||||
m_connectionString = connectionString;
|
|
||||||
_Database = new MSSQLManager(connectionString);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Migration settings
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
Migration m = new Migration(conn, GetType().Assembly, "EstateStore");
|
|
||||||
m.Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Interesting way to get parameters! Maybe implement that also with other types
|
|
||||||
Type t = typeof(EstateSettings);
|
|
||||||
_Fields = t.GetFields(BindingFlags.NonPublic |
|
|
||||||
BindingFlags.Instance |
|
|
||||||
BindingFlags.DeclaredOnly);
|
|
||||||
|
|
||||||
foreach (FieldInfo f in _Fields)
|
|
||||||
{
|
|
||||||
if (f.Name.Substring(0, 2) == "m_")
|
|
||||||
_FieldMap[f.Name.Substring(2)] = f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Loads the estate settings.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionID">region ID.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public EstateSettings LoadEstateSettings(UUID regionID, bool create)
|
|
||||||
{
|
|
||||||
EstateSettings es = new EstateSettings();
|
|
||||||
|
|
||||||
string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = @RegionID";
|
|
||||||
|
|
||||||
bool insertEstate = false;
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionID", regionID));
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
foreach (string name in FieldList)
|
|
||||||
{
|
|
||||||
FieldInfo f = _FieldMap[name];
|
|
||||||
object v = reader[name];
|
|
||||||
if (f.FieldType == typeof(bool))
|
|
||||||
{
|
|
||||||
f.SetValue(es, Convert.ToInt32(v) != 0);
|
|
||||||
}
|
|
||||||
else if (f.FieldType == typeof(UUID))
|
|
||||||
{
|
|
||||||
f.SetValue(es, new UUID((Guid)v)); // uuid);
|
|
||||||
}
|
|
||||||
else if (f.FieldType == typeof(string))
|
|
||||||
{
|
|
||||||
f.SetValue(es, v.ToString());
|
|
||||||
}
|
|
||||||
else if (f.FieldType == typeof(UInt32))
|
|
||||||
{
|
|
||||||
f.SetValue(es, Convert.ToUInt32(v));
|
|
||||||
}
|
|
||||||
else if (f.FieldType == typeof(Single))
|
|
||||||
{
|
|
||||||
f.SetValue(es, Convert.ToSingle(v));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
f.SetValue(es, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
insertEstate = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (insertEstate && create)
|
|
||||||
{
|
|
||||||
DoCreate(es);
|
|
||||||
LinkRegion(regionID, (int)es.EstateID);
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadBanList(es);
|
|
||||||
|
|
||||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
|
||||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
|
||||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
|
||||||
|
|
||||||
//Set event
|
|
||||||
es.OnSave += StoreEstateSettings;
|
|
||||||
return es;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EstateSettings CreateNewEstate()
|
|
||||||
{
|
|
||||||
EstateSettings es = new EstateSettings();
|
|
||||||
es.OnSave += StoreEstateSettings;
|
|
||||||
|
|
||||||
DoCreate(es);
|
|
||||||
|
|
||||||
LoadBanList(es);
|
|
||||||
|
|
||||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
|
||||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
|
||||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
|
||||||
|
|
||||||
return es;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DoCreate(EstateSettings es)
|
|
||||||
{
|
|
||||||
List<string> names = new List<string>(FieldList);
|
|
||||||
|
|
||||||
names.Remove("EstateID");
|
|
||||||
|
|
||||||
string sql = string.Format("insert into estate_settings ({0}) values ( @{1})", String.Join(",", names.ToArray()), String.Join(", @", names.ToArray()));
|
|
||||||
|
|
||||||
//_Log.Debug("[DB ESTATE]: SQL: " + sql);
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand insertCommand = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
insertCommand.CommandText = sql + " SET @ID = SCOPE_IDENTITY()";
|
|
||||||
|
|
||||||
foreach (string name in names)
|
|
||||||
{
|
|
||||||
insertCommand.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es)));
|
|
||||||
}
|
|
||||||
SqlParameter idParameter = new SqlParameter("@ID", SqlDbType.Int);
|
|
||||||
idParameter.Direction = ParameterDirection.Output;
|
|
||||||
insertCommand.Parameters.Add(idParameter);
|
|
||||||
conn.Open();
|
|
||||||
insertCommand.ExecuteNonQuery();
|
|
||||||
|
|
||||||
es.EstateID = Convert.ToUInt32(idParameter.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO check if this is needed??
|
|
||||||
es.Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stores the estate settings.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="es">estate settings</param>
|
|
||||||
public void StoreEstateSettings(EstateSettings es)
|
|
||||||
{
|
|
||||||
List<string> names = new List<string>(FieldList);
|
|
||||||
|
|
||||||
names.Remove("EstateID");
|
|
||||||
|
|
||||||
string sql = string.Format("UPDATE estate_settings SET ");
|
|
||||||
foreach (string name in names)
|
|
||||||
{
|
|
||||||
sql += name + " = @" + name + ", ";
|
|
||||||
}
|
|
||||||
sql = sql.Remove(sql.LastIndexOf(","));
|
|
||||||
sql += " WHERE EstateID = @EstateID";
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
foreach (string name in names)
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(_Database.CreateParameter("@" + name, _FieldMap[name].GetValue(es)));
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID));
|
|
||||||
conn.Open();
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveBanList(es);
|
|
||||||
SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers);
|
|
||||||
SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess);
|
|
||||||
SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private methods
|
|
||||||
|
|
||||||
private string[] FieldList
|
|
||||||
{
|
|
||||||
get { return new List<string>(_FieldMap.Keys).ToArray(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadBanList(EstateSettings es)
|
|
||||||
{
|
|
||||||
es.ClearBans();
|
|
||||||
|
|
||||||
string sql = "select bannedUUID from estateban where EstateID = @EstateID";
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
SqlParameter idParameter = new SqlParameter("@EstateID", SqlDbType.Int);
|
|
||||||
idParameter.Value = es.EstateID;
|
|
||||||
cmd.Parameters.Add(idParameter);
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
EstateBan eb = new EstateBan();
|
|
||||||
|
|
||||||
eb.BannedUserID = new UUID((Guid)reader["bannedUUID"]); //uuid;
|
|
||||||
eb.BannedHostAddress = "0.0.0.0";
|
|
||||||
eb.BannedHostIPMask = "0.0.0.0";
|
|
||||||
es.AddBan(eb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private UUID[] LoadUUIDList(uint estateID, string table)
|
|
||||||
{
|
|
||||||
List<UUID> uuids = new List<UUID>();
|
|
||||||
|
|
||||||
string sql = string.Format("select uuid from {0} where EstateID = @EstateID", table);
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", estateID));
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
uuids.Add(new UUID((Guid)reader["uuid"])); //uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return uuids.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveBanList(EstateSettings es)
|
|
||||||
{
|
|
||||||
//Delete first
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
using (SqlCommand cmd = conn.CreateCommand())
|
|
||||||
{
|
|
||||||
cmd.CommandText = "delete from estateban where EstateID = @EstateID";
|
|
||||||
cmd.Parameters.AddWithValue("@EstateID", (int)es.EstateID);
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
//Insert after
|
|
||||||
cmd.CommandText = "insert into estateban (EstateID, bannedUUID,bannedIp, bannedIpHostMask, bannedNameMask) values ( @EstateID, @bannedUUID, '','','' )";
|
|
||||||
cmd.Parameters.AddWithValue("@bannedUUID", Guid.Empty);
|
|
||||||
foreach (EstateBan b in es.EstateBans)
|
|
||||||
{
|
|
||||||
cmd.Parameters["@bannedUUID"].Value = b.BannedUserID.Guid;
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveUUIDList(uint estateID, string table, UUID[] data)
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
using (SqlCommand cmd = conn.CreateCommand())
|
|
||||||
{
|
|
||||||
cmd.Parameters.AddWithValue("@EstateID", (int)estateID);
|
|
||||||
cmd.CommandText = string.Format("delete from {0} where EstateID = @EstateID", table);
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
cmd.CommandText = string.Format("insert into {0} (EstateID, uuid) values ( @EstateID, @uuid )", table);
|
|
||||||
cmd.Parameters.AddWithValue("@uuid", Guid.Empty);
|
|
||||||
foreach (UUID uuid in data)
|
|
||||||
{
|
|
||||||
cmd.Parameters["@uuid"].Value = uuid.Guid; //.ToString(); //TODO check if this works
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public EstateSettings LoadEstateSettings(int estateID)
|
|
||||||
{
|
|
||||||
EstateSettings es = new EstateSettings();
|
|
||||||
string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_settings where EstateID = @EstateID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.AddWithValue("@EstateID", (int)estateID);
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
foreach (string name in FieldList)
|
|
||||||
{
|
|
||||||
FieldInfo f = _FieldMap[name];
|
|
||||||
object v = reader[name];
|
|
||||||
if (f.FieldType == typeof(bool))
|
|
||||||
{
|
|
||||||
f.SetValue(es, Convert.ToInt32(v) != 0);
|
|
||||||
}
|
|
||||||
else if (f.FieldType == typeof(UUID))
|
|
||||||
{
|
|
||||||
f.SetValue(es, new UUID((Guid)v)); // uuid);
|
|
||||||
}
|
|
||||||
else if (f.FieldType == typeof(string))
|
|
||||||
{
|
|
||||||
f.SetValue(es, v.ToString());
|
|
||||||
}
|
|
||||||
else if (f.FieldType == typeof(UInt32))
|
|
||||||
{
|
|
||||||
f.SetValue(es, Convert.ToUInt32(v));
|
|
||||||
}
|
|
||||||
else if (f.FieldType == typeof(Single))
|
|
||||||
{
|
|
||||||
f.SetValue(es, Convert.ToSingle(v));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
f.SetValue(es, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LoadBanList(es);
|
|
||||||
|
|
||||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
|
||||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
|
||||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
|
||||||
|
|
||||||
//Set event
|
|
||||||
es.OnSave += StoreEstateSettings;
|
|
||||||
return es;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<EstateSettings> LoadEstateSettingsAll()
|
|
||||||
{
|
|
||||||
List<EstateSettings> allEstateSettings = new List<EstateSettings>();
|
|
||||||
|
|
||||||
List<int> allEstateIds = GetEstatesAll();
|
|
||||||
|
|
||||||
foreach (int estateId in allEstateIds)
|
|
||||||
allEstateSettings.Add(LoadEstateSettings(estateId));
|
|
||||||
|
|
||||||
return allEstateSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<int> GetEstates(string search)
|
|
||||||
{
|
|
||||||
List<int> result = new List<int>();
|
|
||||||
string sql = "select estateID from estate_settings where EstateName = @EstateName";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.AddWithValue("@EstateName", search);
|
|
||||||
|
|
||||||
using (IDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<int> GetEstatesAll()
|
|
||||||
{
|
|
||||||
List<int> result = new List<int>();
|
|
||||||
string sql = "select estateID from estate_settings";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
using (IDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<int> GetEstatesByOwner(UUID ownerID)
|
|
||||||
{
|
|
||||||
List<int> result = new List<int>();
|
|
||||||
string sql = "select estateID from estate_settings where EstateOwner = @EstateOwner";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.AddWithValue("@EstateOwner", ownerID);
|
|
||||||
|
|
||||||
using (IDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool LinkRegion(UUID regionID, int estateID)
|
|
||||||
{
|
|
||||||
string deleteSQL = "delete from estate_map where RegionID = @RegionID";
|
|
||||||
string insertSQL = "insert into estate_map values (@RegionID, @EstateID)";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
SqlTransaction transaction = conn.BeginTransaction();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (SqlCommand cmd = new SqlCommand(deleteSQL, conn))
|
|
||||||
{
|
|
||||||
cmd.Transaction = transaction;
|
|
||||||
cmd.Parameters.AddWithValue("@RegionID", regionID.Guid);
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
using (SqlCommand cmd = new SqlCommand(insertSQL, conn))
|
|
||||||
{
|
|
||||||
cmd.Transaction = transaction;
|
|
||||||
cmd.Parameters.AddWithValue("@RegionID", regionID.Guid);
|
|
||||||
cmd.Parameters.AddWithValue("@EstateID", estateID);
|
|
||||||
|
|
||||||
int ret = cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
if (ret != 0)
|
|
||||||
transaction.Commit();
|
|
||||||
else
|
|
||||||
transaction.Rollback();
|
|
||||||
|
|
||||||
return (ret != 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
m_log.Error("[REGION DB]: LinkRegion failed: " + ex.Message);
|
|
||||||
transaction.Rollback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UUID> GetRegions(int estateID)
|
|
||||||
{
|
|
||||||
List<UUID> result = new List<UUID>();
|
|
||||||
string sql = "select RegionID from estate_map where EstateID = @EstateID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.AddWithValue("@EstateID", estateID);
|
|
||||||
|
|
||||||
using (IDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
result.Add(DBGuid.FromDB(reader["RegionID"]));
|
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeleteEstate(int estateID)
|
|
||||||
{
|
|
||||||
// TODO: Implementation!
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
public class MSSQLFriendsData : MSSQLGenericTableHandler<FriendsData>, IFriendsData
|
|
||||||
{
|
|
||||||
public MSSQLFriendsData(string connectionString, string realm)
|
|
||||||
: base(connectionString, realm, "FriendsStore")
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
Migration m = new Migration(conn, GetType().Assembly, "FriendsStore");
|
|
||||||
m.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(UUID principalID, string friend)
|
|
||||||
{
|
|
||||||
return Delete(principalID.ToString(), friend);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Delete(string principalID, string friend)
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
cmd.CommandText = String.Format("delete from {0} where PrincipalID = @PrincipalID and Friend = @Friend", m_Realm);
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@Friend", friend));
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FriendsData[] GetFriends(UUID principalID)
|
|
||||||
{
|
|
||||||
return GetFriends(principalID.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public FriendsData[] GetFriends(string principalID)
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = @PrincipalID", m_Realm);
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
return DoQuery(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FriendsData[] GetFriends(Guid principalID)
|
|
||||||
{
|
|
||||||
return GetFriends(principalID.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,384 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
public class MSSQLGenericTableHandler<T> where T : class, new()
|
|
||||||
{
|
|
||||||
// private static readonly ILog m_log =
|
|
||||||
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
protected string m_ConnectionString;
|
|
||||||
protected MSSQLManager m_database; //used for parameter type translation
|
|
||||||
protected Dictionary<string, FieldInfo> m_Fields =
|
|
||||||
new Dictionary<string, FieldInfo>();
|
|
||||||
|
|
||||||
protected List<string> m_ColumnNames = null;
|
|
||||||
protected string m_Realm;
|
|
||||||
protected FieldInfo m_DataField = null;
|
|
||||||
|
|
||||||
public MSSQLGenericTableHandler(string connectionString,
|
|
||||||
string realm, string storeName)
|
|
||||||
{
|
|
||||||
m_Realm = realm;
|
|
||||||
|
|
||||||
m_ConnectionString = connectionString;
|
|
||||||
|
|
||||||
if (storeName != String.Empty)
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
Migration m = new Migration(conn, GetType().Assembly, storeName);
|
|
||||||
m.Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
m_database = new MSSQLManager(m_ConnectionString);
|
|
||||||
|
|
||||||
Type t = typeof(T);
|
|
||||||
FieldInfo[] fields = t.GetFields(BindingFlags.Public |
|
|
||||||
BindingFlags.Instance |
|
|
||||||
BindingFlags.DeclaredOnly);
|
|
||||||
|
|
||||||
if (fields.Length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (FieldInfo f in fields)
|
|
||||||
{
|
|
||||||
if (f.Name != "Data")
|
|
||||||
m_Fields[f.Name] = f;
|
|
||||||
else
|
|
||||||
m_DataField = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckColumnNames(SqlDataReader reader)
|
|
||||||
{
|
|
||||||
if (m_ColumnNames != null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_ColumnNames = new List<string>();
|
|
||||||
|
|
||||||
DataTable schemaTable = reader.GetSchemaTable();
|
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
|
||||||
{
|
|
||||||
if (row["ColumnName"] != null &&
|
|
||||||
(!m_Fields.ContainsKey(row["ColumnName"].ToString())))
|
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string> GetConstraints()
|
|
||||||
{
|
|
||||||
List<string> constraints = new List<string>();
|
|
||||||
string query = string.Format(@"SELECT
|
|
||||||
COL_NAME(ic.object_id,ic.column_id) AS column_name
|
|
||||||
FROM sys.indexes AS i
|
|
||||||
INNER JOIN sys.index_columns AS ic
|
|
||||||
ON i.object_id = ic.object_id AND i.index_id = ic.index_id
|
|
||||||
WHERE i.is_primary_key = 1
|
|
||||||
AND i.object_id = OBJECT_ID('{0}');", m_Realm);
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(query, conn))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader rdr = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (rdr.Read())
|
|
||||||
{
|
|
||||||
// query produces 0 to many rows of single column, so always add the first item in each row
|
|
||||||
constraints.Add((string)rdr[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return constraints;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual T[] Get(string field, string key)
|
|
||||||
{
|
|
||||||
return Get(new string[] { field }, new string[] { key });
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual T[] Get(string[] fields, string[] keys)
|
|
||||||
{
|
|
||||||
if (fields.Length != keys.Length)
|
|
||||||
return new T[0];
|
|
||||||
|
|
||||||
List<string> terms = new List<string>();
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
for (int i = 0; i < fields.Length; i++)
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
|
||||||
terms.Add("[" + fields[i] + "] = @" + fields[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
string where = String.Join(" AND ", terms.ToArray());
|
|
||||||
|
|
||||||
string query = String.Format("SELECT * FROM {0} WHERE {1}",
|
|
||||||
m_Realm, where);
|
|
||||||
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.CommandText = query;
|
|
||||||
conn.Open();
|
|
||||||
return DoQuery(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected T[] DoQuery(SqlCommand cmd)
|
|
||||||
{
|
|
||||||
List<T> result = new List<T>();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader == null)
|
|
||||||
return new T[0];
|
|
||||||
|
|
||||||
CheckColumnNames(reader);
|
|
||||||
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
T row = new T();
|
|
||||||
|
|
||||||
foreach (string name in m_Fields.Keys)
|
|
||||||
{
|
|
||||||
if (m_Fields[name].GetValue(row) is bool)
|
|
||||||
{
|
|
||||||
int v = Convert.ToInt32(reader[name]);
|
|
||||||
m_Fields[name].SetValue(row, v != 0 ? true : false);
|
|
||||||
}
|
|
||||||
else if (m_Fields[name].GetValue(row) is UUID)
|
|
||||||
{
|
|
||||||
UUID uuid = UUID.Zero;
|
|
||||||
|
|
||||||
UUID.TryParse(reader[name].ToString(), out uuid);
|
|
||||||
m_Fields[name].SetValue(row, uuid);
|
|
||||||
}
|
|
||||||
else if (m_Fields[name].GetValue(row) is int)
|
|
||||||
{
|
|
||||||
int v = Convert.ToInt32(reader[name]);
|
|
||||||
m_Fields[name].SetValue(row, v);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Fields[name].SetValue(row, reader[name]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_DataField != null)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> data =
|
|
||||||
new Dictionary<string, string>();
|
|
||||||
|
|
||||||
foreach (string col in m_ColumnNames)
|
|
||||||
{
|
|
||||||
data[col] = reader[col].ToString();
|
|
||||||
if (data[col] == null)
|
|
||||||
data[col] = String.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_DataField.SetValue(row, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Add(row);
|
|
||||||
}
|
|
||||||
return result.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual T[] Get(string where)
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
string query = String.Format("SELECT * FROM {0} WHERE {1}",
|
|
||||||
m_Realm, where);
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.CommandText = query;
|
|
||||||
|
|
||||||
//m_log.WarnFormat("[MSSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where);
|
|
||||||
|
|
||||||
conn.Open();
|
|
||||||
return DoQuery(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool Store(T row)
|
|
||||||
{
|
|
||||||
List<string> constraintFields = GetConstraints();
|
|
||||||
List<KeyValuePair<string, string>> constraints = new List<KeyValuePair<string, string>>();
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
StringBuilder query = new StringBuilder();
|
|
||||||
List<String> names = new List<String>();
|
|
||||||
List<String> values = new List<String>();
|
|
||||||
|
|
||||||
foreach (FieldInfo fi in m_Fields.Values)
|
|
||||||
{
|
|
||||||
names.Add(fi.Name);
|
|
||||||
values.Add("@" + fi.Name);
|
|
||||||
// Temporarily return more information about what field is unexpectedly null for
|
|
||||||
// http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the
|
|
||||||
// InventoryTransferModule or we may be required to substitute a DBNull here.
|
|
||||||
if (fi.GetValue(row) == null)
|
|
||||||
throw new NullReferenceException(
|
|
||||||
string.Format(
|
|
||||||
"[MSSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null",
|
|
||||||
fi.Name, row));
|
|
||||||
|
|
||||||
if (constraintFields.Count > 0 && constraintFields.Contains(fi.Name))
|
|
||||||
{
|
|
||||||
constraints.Add(new KeyValuePair<string, string>(fi.Name, fi.GetValue(row).ToString()));
|
|
||||||
}
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row).ToString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_DataField != null)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> data =
|
|
||||||
(Dictionary<string, string>)m_DataField.GetValue(row);
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> kvp in data)
|
|
||||||
{
|
|
||||||
if (constraintFields.Count > 0 && constraintFields.Contains(kvp.Key))
|
|
||||||
{
|
|
||||||
constraints.Add(new KeyValuePair<string, string>(kvp.Key, kvp.Key));
|
|
||||||
}
|
|
||||||
names.Add(kvp.Key);
|
|
||||||
values.Add("@" + kvp.Key);
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@" + kvp.Key, kvp.Value));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
query.AppendFormat("UPDATE {0} SET ", m_Realm);
|
|
||||||
int i = 0;
|
|
||||||
for (i = 0; i < names.Count - 1; i++)
|
|
||||||
{
|
|
||||||
query.AppendFormat("[{0}] = {1}, ", names[i], values[i]);
|
|
||||||
}
|
|
||||||
query.AppendFormat("[{0}] = {1} ", names[i], values[i]);
|
|
||||||
if (constraints.Count > 0)
|
|
||||||
{
|
|
||||||
List<string> terms = new List<string>();
|
|
||||||
for (int j = 0; j < constraints.Count; j++)
|
|
||||||
{
|
|
||||||
terms.Add(" [" + constraints[j].Key + "] = @" + constraints[j].Key);
|
|
||||||
}
|
|
||||||
string where = String.Join(" AND ", terms.ToArray());
|
|
||||||
query.AppendFormat(" WHERE {0} ", where);
|
|
||||||
|
|
||||||
}
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.CommandText = query.ToString();
|
|
||||||
|
|
||||||
conn.Open();
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
{
|
|
||||||
//m_log.WarnFormat("[MSSQLGenericTable]: Updating {0}", m_Realm);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// assume record has not yet been inserted
|
|
||||||
|
|
||||||
query = new StringBuilder();
|
|
||||||
query.AppendFormat("INSERT INTO {0} ([", m_Realm);
|
|
||||||
query.Append(String.Join("],[", names.ToArray()));
|
|
||||||
query.Append("]) values (" + String.Join(",", values.ToArray()) + ")");
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.CommandText = query.ToString();
|
|
||||||
//m_log.WarnFormat("[MSSQLGenericTable]: Inserting into {0}", m_Realm);
|
|
||||||
if (conn.State != ConnectionState.Open)
|
|
||||||
conn.Open();
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool Delete(string field, string key)
|
|
||||||
{
|
|
||||||
return Delete(new string[] { field }, new string[] { key });
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool Delete(string[] fields, string[] keys)
|
|
||||||
{
|
|
||||||
if (fields.Length != keys.Length)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
List<string> terms = new List<string>();
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
for (int i = 0; i < fields.Length; i++)
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
|
||||||
terms.Add("[" + fields[i] + "] = @" + fields[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
string where = String.Join(" AND ", terms.ToArray());
|
|
||||||
|
|
||||||
string query = String.Format("DELETE FROM {0} WHERE {1}", m_Realm, where);
|
|
||||||
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.CommandText = query;
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
{
|
|
||||||
//m_log.Warn("[MSSQLGenericTable]: " + deleteCommand);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A MSSQL Interface for Avatar Storage
|
|
||||||
/// </summary>
|
|
||||||
public class MSSQLGridUserData : MSSQLGenericTableHandler<GridUserData>,
|
|
||||||
IGridUserData
|
|
||||||
{
|
|
||||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public MSSQLGridUserData(string connectionString, string realm) :
|
|
||||||
base(connectionString, realm, "GridUserStore")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public new GridUserData Get(string userID)
|
|
||||||
{
|
|
||||||
GridUserData[] ret = Get("UserID", userID);
|
|
||||||
|
|
||||||
if (ret.Length == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return ret[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridUserData[] GetAll(string userID)
|
|
||||||
{
|
|
||||||
return base.Get(String.Format("UserID LIKE '{0}%'", userID));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,831 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A MSSQL interface for the inventory server
|
|
||||||
/// </summary>
|
|
||||||
public class MSSQLInventoryData : IInventoryDataPlugin
|
|
||||||
{
|
|
||||||
private const string _migrationStore = "InventoryStore";
|
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The database manager
|
|
||||||
/// </summary>
|
|
||||||
private MSSQLManager database;
|
|
||||||
private string m_connectionString;
|
|
||||||
|
|
||||||
#region IPlugin members
|
|
||||||
|
|
||||||
[Obsolete("Cannot be default-initialized!")]
|
|
||||||
public void Initialise()
|
|
||||||
{
|
|
||||||
m_log.Info("[MSSQLInventoryData]: " + Name + " cannot be default-initialized!");
|
|
||||||
throw new PluginNotInitialisedException(Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Loads and initialises the MSSQL inventory storage interface
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connectionString">connect string</param>
|
|
||||||
/// <remarks>use mssql_connection.ini</remarks>
|
|
||||||
public void Initialise(string connectionString)
|
|
||||||
{
|
|
||||||
m_connectionString = connectionString;
|
|
||||||
database = new MSSQLManager(connectionString);
|
|
||||||
|
|
||||||
//New migrations check of store
|
|
||||||
database.CheckMigration(_migrationStore);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The name of this DB provider
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the name of the DB provider</returns>
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get { return "MSSQL Inventory Data Interface"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Closes this DB provider
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
database = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the version of this DB provider
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the DB provider</returns>
|
|
||||||
public string Version
|
|
||||||
{
|
|
||||||
get { return database.getVersion(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Folder methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of the root folders within a users inventory
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">The user whos inventory is to be searched</param>
|
|
||||||
/// <returns>A list of folder objects</returns>
|
|
||||||
public List<InventoryFolderBase> getUserRootFolders(UUID user)
|
|
||||||
{
|
|
||||||
if (user == UUID.Zero)
|
|
||||||
return new List<InventoryFolderBase>();
|
|
||||||
|
|
||||||
return getInventoryFolders(UUID.Zero, user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// see InventoryItemBase.getUserRootFolder
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">the User UUID</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public InventoryFolderBase getUserRootFolder(UUID user)
|
|
||||||
{
|
|
||||||
List<InventoryFolderBase> items = getUserRootFolders(user);
|
|
||||||
|
|
||||||
InventoryFolderBase rootFolder = null;
|
|
||||||
|
|
||||||
// There should only ever be one root folder for a user. However, if there's more
|
|
||||||
// than one we'll simply use the first one rather than failing. It would be even
|
|
||||||
// nicer to print some message to this effect, but this feels like it's too low a
|
|
||||||
// to put such a message out, and it's too minor right now to spare the time to
|
|
||||||
// suitably refactor.
|
|
||||||
if (items.Count > 0)
|
|
||||||
{
|
|
||||||
rootFolder = items[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return rootFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of folders in a users inventory contained within the specified folder
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parentID">The folder to search</param>
|
|
||||||
/// <returns>A list of inventory folders</returns>
|
|
||||||
public List<InventoryFolderBase> getInventoryFolders(UUID parentID)
|
|
||||||
{
|
|
||||||
return getInventoryFolders(parentID, UUID.Zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a specified inventory folder
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folderID">The folder to return</param>
|
|
||||||
/// <returns>A folder class</returns>
|
|
||||||
public InventoryFolderBase getInventoryFolder(UUID folderID)
|
|
||||||
{
|
|
||||||
string sql = "SELECT * FROM inventoryfolders WHERE folderID = @folderID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("folderID", folderID));
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
return readInventoryFolder(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_log.InfoFormat("[INVENTORY DB] : Found no inventory folder with ID : {0}", folderID);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns all child folders in the hierarchy from the parent folder and down.
|
|
||||||
/// Does not return the parent folder itself.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parentID">The folder to get subfolders for</param>
|
|
||||||
/// <returns>A list of inventory folders</returns>
|
|
||||||
public List<InventoryFolderBase> getFolderHierarchy(UUID parentID)
|
|
||||||
{
|
|
||||||
//Note maybe change this to use a Dataset that loading in all folders of a user and then go throw it that way.
|
|
||||||
//Note this is changed so it opens only one connection to the database and not everytime it wants to get data.
|
|
||||||
|
|
||||||
/* NOTE: the implementation below is very inefficient (makes a separate request to get subfolders for
|
|
||||||
* every found folder, recursively). Inventory code for other DBs has been already rewritten to get ALL
|
|
||||||
* inventory for a specific user at once.
|
|
||||||
*
|
|
||||||
* Meanwhile, one little thing is corrected: getFolderHierarchy(UUID.Zero) doesn't make sense and should never
|
|
||||||
* be used, so check for that and return an empty list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
|
||||||
|
|
||||||
if (parentID == UUID.Zero)
|
|
||||||
return folders;
|
|
||||||
|
|
||||||
string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("@parentID", parentID));
|
|
||||||
conn.Open();
|
|
||||||
folders.AddRange(getInventoryFolders(cmd));
|
|
||||||
|
|
||||||
List<InventoryFolderBase> tempFolders = new List<InventoryFolderBase>();
|
|
||||||
|
|
||||||
foreach (InventoryFolderBase folderBase in folders)
|
|
||||||
{
|
|
||||||
tempFolders.AddRange(getFolderHierarchy(folderBase.ID, cmd));
|
|
||||||
}
|
|
||||||
if (tempFolders.Count > 0)
|
|
||||||
{
|
|
||||||
folders.AddRange(tempFolders);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return folders;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new inventory folder
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folder">Folder to create</param>
|
|
||||||
public void addInventoryFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
string sql = @"INSERT INTO inventoryfolders ([folderID], [agentID], [parentFolderID], [folderName], [type], [version])
|
|
||||||
VALUES (@folderID, @agentID, @parentFolderID, @folderName, @type, @version);";
|
|
||||||
|
|
||||||
string folderName = folder.Name;
|
|
||||||
if (folderName.Length > 64)
|
|
||||||
{
|
|
||||||
folderName = folderName.Substring(0, 64);
|
|
||||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on add");
|
|
||||||
}
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("folderName", folderName));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("type", folder.Type));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("version", folder.Version));
|
|
||||||
conn.Open();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[INVENTORY DB]: Error : {0}", e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates an inventory folder
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folder">Folder to update</param>
|
|
||||||
public void updateInventoryFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
string sql = @"UPDATE inventoryfolders SET agentID = @agentID,
|
|
||||||
parentFolderID = @parentFolderID,
|
|
||||||
folderName = @folderName,
|
|
||||||
type = @type,
|
|
||||||
version = @version
|
|
||||||
WHERE folderID = @folderID";
|
|
||||||
|
|
||||||
string folderName = folder.Name;
|
|
||||||
if (folderName.Length > 64)
|
|
||||||
{
|
|
||||||
folderName = folderName.Substring(0, 64);
|
|
||||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on update");
|
|
||||||
}
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("folderName", folderName));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("type", folder.Type));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("version", folder.Version));
|
|
||||||
conn.Open();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[INVENTORY DB]: Error : {0}", e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates an inventory folder
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folder">Folder to update</param>
|
|
||||||
public void moveInventoryFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
string sql = @"UPDATE inventoryfolders SET parentFolderID = @parentFolderID WHERE folderID = @folderID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
|
||||||
conn.Open();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[INVENTORY DB]: Error : {0}", e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete an inventory folder
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folderID">Id of folder to delete</param>
|
|
||||||
public void deleteInventoryFolder(UUID folderID)
|
|
||||||
{
|
|
||||||
string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID";
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
List<InventoryFolderBase> subFolders;
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("@parentID", UUID.Zero));
|
|
||||||
conn.Open();
|
|
||||||
subFolders = getFolderHierarchy(folderID, cmd);
|
|
||||||
|
|
||||||
|
|
||||||
//Delete all sub-folders
|
|
||||||
foreach (InventoryFolderBase f in subFolders)
|
|
||||||
{
|
|
||||||
DeleteOneFolder(f.ID, conn);
|
|
||||||
DeleteItemsInFolder(f.ID, conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Delete the actual row
|
|
||||||
DeleteOneFolder(folderID, conn);
|
|
||||||
DeleteItemsInFolder(folderID, conn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Item Methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list of items in a specified folder
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folderID">The folder to search</param>
|
|
||||||
/// <returns>A list containing inventory items</returns>
|
|
||||||
public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
|
|
||||||
{
|
|
||||||
string sql = "SELECT * FROM inventoryitems WHERE parentFolderID = @parentFolderID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folderID));
|
|
||||||
conn.Open();
|
|
||||||
List<InventoryItemBase> items = new List<InventoryItemBase>();
|
|
||||||
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
items.Add(readInventoryItem(reader));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a specified inventory item
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="itemID">The item ID</param>
|
|
||||||
/// <returns>An inventory item</returns>
|
|
||||||
public InventoryItemBase getInventoryItem(UUID itemID)
|
|
||||||
{
|
|
||||||
string sql = "SELECT * FROM inventoryitems WHERE inventoryID = @inventoryID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
return readInventoryItem(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.InfoFormat("[INVENTORY DB]: Found no inventory item with ID : {0}", itemID);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a specified item to the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item">The inventory item</param>
|
|
||||||
public void addInventoryItem(InventoryItemBase item)
|
|
||||||
{
|
|
||||||
if (getInventoryItem(item.ID) != null)
|
|
||||||
{
|
|
||||||
updateInventoryItem(item);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string sql = @"INSERT INTO inventoryitems
|
|
||||||
([inventoryID], [assetID], [assetType], [parentFolderID], [avatarID], [inventoryName],
|
|
||||||
[inventoryDescription], [inventoryNextPermissions], [inventoryCurrentPermissions],
|
|
||||||
[invType], [creatorID], [inventoryBasePermissions], [inventoryEveryOnePermissions], [inventoryGroupPermissions],
|
|
||||||
[salePrice], [saleType], [creationDate], [groupID], [groupOwned], [flags])
|
|
||||||
VALUES
|
|
||||||
(@inventoryID, @assetID, @assetType, @parentFolderID, @avatarID, @inventoryName, @inventoryDescription,
|
|
||||||
@inventoryNextPermissions, @inventoryCurrentPermissions, @invType, @creatorID,
|
|
||||||
@inventoryBasePermissions, @inventoryEveryOnePermissions, @inventoryGroupPermissions, @salePrice, @saleType,
|
|
||||||
@creationDate, @groupID, @groupOwned, @flags)";
|
|
||||||
|
|
||||||
string itemName = item.Name;
|
|
||||||
if (item.Name.Length > 64)
|
|
||||||
{
|
|
||||||
itemName = item.Name.Substring(0, 64);
|
|
||||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters");
|
|
||||||
}
|
|
||||||
|
|
||||||
string itemDesc = item.Description;
|
|
||||||
if (item.Description.Length > 128)
|
|
||||||
{
|
|
||||||
itemDesc = item.Description.Substring(0, 128);
|
|
||||||
m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters");
|
|
||||||
}
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryID", item.ID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("assetID", item.AssetID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("assetType", item.AssetType));
|
|
||||||
command.Parameters.Add(database.CreateParameter("parentFolderID", item.Folder));
|
|
||||||
command.Parameters.Add(database.CreateParameter("avatarID", item.Owner));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryName", itemName));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryDescription", itemDesc));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("invType", item.InvType));
|
|
||||||
command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorId));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("salePrice", item.SalePrice));
|
|
||||||
command.Parameters.Add(database.CreateParameter("saleType", item.SaleType));
|
|
||||||
command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate));
|
|
||||||
command.Parameters.Add(database.CreateParameter("groupID", item.GroupID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned));
|
|
||||||
command.Parameters.Add(database.CreateParameter("flags", item.Flags));
|
|
||||||
conn.Open();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[INVENTORY DB]: Error inserting item :" + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sql = "UPDATE inventoryfolders SET version = version + 1 WHERE folderID = @folderID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("folderID", item.Folder.ToString()));
|
|
||||||
conn.Open();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[INVENTORY DB] Error updating inventory folder for new item :" + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the specified inventory item
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item">Inventory item to update</param>
|
|
||||||
public void updateInventoryItem(InventoryItemBase item)
|
|
||||||
{
|
|
||||||
string sql = @"UPDATE inventoryitems SET assetID = @assetID,
|
|
||||||
assetType = @assetType,
|
|
||||||
parentFolderID = @parentFolderID,
|
|
||||||
avatarID = @avatarID,
|
|
||||||
inventoryName = @inventoryName,
|
|
||||||
inventoryDescription = @inventoryDescription,
|
|
||||||
inventoryNextPermissions = @inventoryNextPermissions,
|
|
||||||
inventoryCurrentPermissions = @inventoryCurrentPermissions,
|
|
||||||
invType = @invType,
|
|
||||||
creatorID = @creatorID,
|
|
||||||
inventoryBasePermissions = @inventoryBasePermissions,
|
|
||||||
inventoryEveryOnePermissions = @inventoryEveryOnePermissions,
|
|
||||||
inventoryGroupPermissions = @inventoryGroupPermissions,
|
|
||||||
salePrice = @salePrice,
|
|
||||||
saleType = @saleType,
|
|
||||||
creationDate = @creationDate,
|
|
||||||
groupID = @groupID,
|
|
||||||
groupOwned = @groupOwned,
|
|
||||||
flags = @flags
|
|
||||||
WHERE inventoryID = @inventoryID";
|
|
||||||
|
|
||||||
string itemName = item.Name;
|
|
||||||
if (item.Name.Length > 64)
|
|
||||||
{
|
|
||||||
itemName = item.Name.Substring(0, 64);
|
|
||||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters on update");
|
|
||||||
}
|
|
||||||
|
|
||||||
string itemDesc = item.Description;
|
|
||||||
if (item.Description.Length > 128)
|
|
||||||
{
|
|
||||||
itemDesc = item.Description.Substring(0, 128);
|
|
||||||
m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters on update");
|
|
||||||
}
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryID", item.ID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("assetID", item.AssetID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("assetType", item.AssetType));
|
|
||||||
command.Parameters.Add(database.CreateParameter("parentFolderID", item.Folder));
|
|
||||||
command.Parameters.Add(database.CreateParameter("avatarID", item.Owner));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryName", itemName));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryDescription", itemDesc));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("invType", item.InvType));
|
|
||||||
command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorId));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions));
|
|
||||||
command.Parameters.Add(database.CreateParameter("salePrice", item.SalePrice));
|
|
||||||
command.Parameters.Add(database.CreateParameter("saleType", item.SaleType));
|
|
||||||
command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate));
|
|
||||||
command.Parameters.Add(database.CreateParameter("groupID", item.GroupID));
|
|
||||||
command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned));
|
|
||||||
command.Parameters.Add(database.CreateParameter("flags", item.Flags));
|
|
||||||
conn.Open();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[INVENTORY DB]: Error updating item :" + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// See IInventoryDataPlugin
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete an item in inventory database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="itemID">the item UUID</param>
|
|
||||||
public void deleteInventoryItem(UUID itemID)
|
|
||||||
{
|
|
||||||
string sql = "DELETE FROM inventoryitems WHERE inventoryID=@inventoryID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[INVENTORY DB]: Error deleting item :" + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public InventoryItemBase queryInventoryItem(UUID itemID)
|
|
||||||
{
|
|
||||||
return getInventoryItem(itemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InventoryFolderBase queryInventoryFolder(UUID folderID)
|
|
||||||
{
|
|
||||||
return getInventoryFolder(folderID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns all activated gesture-items in the inventory of the specified avatar.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="avatarID">The <see cref="UUID"/> of the avatar</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The list of gestures (<see cref="InventoryItemBase"/>s)
|
|
||||||
/// </returns>
|
|
||||||
public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
|
|
||||||
{
|
|
||||||
string sql = "SELECT * FROM inventoryitems WHERE avatarId = @uuid AND assetType = @assetType and flags = 1";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("uuid", avatarID));
|
|
||||||
cmd.Parameters.Add(database.CreateParameter("assetType", (int)AssetType.Gesture));
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
List<InventoryItemBase> gestureList = new List<InventoryItemBase>();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
gestureList.Add(readInventoryItem(reader));
|
|
||||||
}
|
|
||||||
return gestureList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete an item in inventory database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folderID">the item ID</param>
|
|
||||||
/// <param name="connection">connection to the database</param>
|
|
||||||
private void DeleteItemsInFolder(UUID folderID, SqlConnection connection)
|
|
||||||
{
|
|
||||||
using (SqlCommand command = new SqlCommand("DELETE FROM inventoryitems WHERE folderID=@folderID", connection))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("folderID", folderID));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[INVENTORY DB] Error deleting item :" + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the folder hierarchy in a loop.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parentID">parent ID.</param>
|
|
||||||
/// <param name="command">SQL command/connection to database</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static List<InventoryFolderBase> getFolderHierarchy(UUID parentID, SqlCommand command)
|
|
||||||
{
|
|
||||||
command.Parameters["@parentID"].Value = parentID.Guid; //.ToString();
|
|
||||||
|
|
||||||
List<InventoryFolderBase> folders = getInventoryFolders(command);
|
|
||||||
|
|
||||||
if (folders.Count > 0)
|
|
||||||
{
|
|
||||||
List<InventoryFolderBase> tempFolders = new List<InventoryFolderBase>();
|
|
||||||
|
|
||||||
foreach (InventoryFolderBase folderBase in folders)
|
|
||||||
{
|
|
||||||
tempFolders.AddRange(getFolderHierarchy(folderBase.ID, command));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tempFolders.Count > 0)
|
|
||||||
{
|
|
||||||
folders.AddRange(tempFolders);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return folders;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the inventory folders.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parentID">parentID, use UUID.Zero to get root</param>
|
|
||||||
/// <param name="user">user id, use UUID.Zero, if you want all folders from a parentID.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private List<InventoryFolderBase> getInventoryFolders(UUID parentID, UUID user)
|
|
||||||
{
|
|
||||||
string sql = "SELECT * FROM inventoryfolders WHERE parentFolderID = @parentID AND agentID LIKE @uuid";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
|
||||||
using (SqlCommand command = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
if (user == UUID.Zero)
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("uuid", "%"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("uuid", user));
|
|
||||||
}
|
|
||||||
command.Parameters.Add(database.CreateParameter("parentID", parentID));
|
|
||||||
conn.Open();
|
|
||||||
return getInventoryFolders(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the inventory folders.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="command">SQLcommand.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static List<InventoryFolderBase> getInventoryFolders(SqlCommand command)
|
|
||||||
{
|
|
||||||
using (SqlDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
|
||||||
|
|
||||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
items.Add(readInventoryFolder(reader));
|
|
||||||
}
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads a list of inventory folders returned by a query.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="reader">A MSSQL Data Reader</param>
|
|
||||||
/// <returns>A List containing inventory folders</returns>
|
|
||||||
protected static InventoryFolderBase readInventoryFolder(SqlDataReader reader)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
InventoryFolderBase folder = new InventoryFolderBase();
|
|
||||||
folder.Owner = DBGuid.FromDB(reader["agentID"]);
|
|
||||||
folder.ParentID = DBGuid.FromDB(reader["parentFolderID"]);
|
|
||||||
folder.ID = DBGuid.FromDB(reader["folderID"]);
|
|
||||||
folder.Name = (string)reader["folderName"];
|
|
||||||
folder.Type = (short)reader["type"];
|
|
||||||
folder.Version = Convert.ToUInt16(reader["version"]);
|
|
||||||
|
|
||||||
return folder;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error("[INVENTORY DB] Error reading inventory folder :" + e.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads a one item from an SQL result
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="reader">The SQL Result</param>
|
|
||||||
/// <returns>the item read</returns>
|
|
||||||
private static InventoryItemBase readInventoryItem(IDataRecord reader)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
InventoryItemBase item = new InventoryItemBase();
|
|
||||||
|
|
||||||
item.ID = DBGuid.FromDB(reader["inventoryID"]);
|
|
||||||
item.AssetID = DBGuid.FromDB(reader["assetID"]);
|
|
||||||
item.AssetType = Convert.ToInt32(reader["assetType"].ToString());
|
|
||||||
item.Folder = DBGuid.FromDB(reader["parentFolderID"]);
|
|
||||||
item.Owner = DBGuid.FromDB(reader["avatarID"]);
|
|
||||||
item.Name = reader["inventoryName"].ToString();
|
|
||||||
item.Description = reader["inventoryDescription"].ToString();
|
|
||||||
item.NextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]);
|
|
||||||
item.CurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]);
|
|
||||||
item.InvType = Convert.ToInt32(reader["invType"].ToString());
|
|
||||||
item.CreatorId = reader["creatorID"].ToString();
|
|
||||||
item.BasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]);
|
|
||||||
item.EveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]);
|
|
||||||
item.GroupPermissions = Convert.ToUInt32(reader["inventoryGroupPermissions"]);
|
|
||||||
item.SalePrice = Convert.ToInt32(reader["salePrice"]);
|
|
||||||
item.SaleType = Convert.ToByte(reader["saleType"]);
|
|
||||||
item.CreationDate = Convert.ToInt32(reader["creationDate"]);
|
|
||||||
item.GroupID = DBGuid.FromDB(reader["groupID"]);
|
|
||||||
item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
|
|
||||||
item.Flags = Convert.ToUInt32(reader["flags"]);
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
catch (SqlException e)
|
|
||||||
{
|
|
||||||
m_log.Error("[INVENTORY DB]: Error reading inventory item :" + e.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete a folder in inventory databasae
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folderID">the folder UUID</param>
|
|
||||||
/// <param name="connection">connection to database</param>
|
|
||||||
private void DeleteOneFolder(UUID folderID, SqlConnection connection)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (SqlCommand command = new SqlCommand("DELETE FROM inventoryfolders WHERE folderID=@folderID and type=-1", connection))
|
|
||||||
{
|
|
||||||
command.Parameters.Add(database.CreateParameter("folderID", folderID));
|
|
||||||
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SqlException e)
|
|
||||||
{
|
|
||||||
m_log.Error("[INVENTORY DB]: Error deleting folder :" + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,219 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A management class for the MS SQL Storage Engine
|
|
||||||
/// </summary>
|
|
||||||
public class MSSQLManager
|
|
||||||
{
|
|
||||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Connection string for ADO.net
|
|
||||||
/// </summary>
|
|
||||||
private readonly string connectionString;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initialize the manager and set the connectionstring
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connection"></param>
|
|
||||||
public MSSQLManager(string connection)
|
|
||||||
{
|
|
||||||
connectionString = connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Type conversion to a SQLDbType functions
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
internal SqlDbType DbtypeFromType(Type type)
|
|
||||||
{
|
|
||||||
if (type == typeof(string))
|
|
||||||
{
|
|
||||||
return SqlDbType.VarChar;
|
|
||||||
}
|
|
||||||
if (type == typeof(double))
|
|
||||||
{
|
|
||||||
return SqlDbType.Float;
|
|
||||||
}
|
|
||||||
if (type == typeof(Single))
|
|
||||||
{
|
|
||||||
return SqlDbType.Float;
|
|
||||||
}
|
|
||||||
if (type == typeof(int))
|
|
||||||
{
|
|
||||||
return SqlDbType.Int;
|
|
||||||
}
|
|
||||||
if (type == typeof(bool))
|
|
||||||
{
|
|
||||||
return SqlDbType.Bit;
|
|
||||||
}
|
|
||||||
if (type == typeof(UUID))
|
|
||||||
{
|
|
||||||
return SqlDbType.UniqueIdentifier;
|
|
||||||
}
|
|
||||||
if (type == typeof(sbyte))
|
|
||||||
{
|
|
||||||
return SqlDbType.Int;
|
|
||||||
}
|
|
||||||
if (type == typeof(Byte[]))
|
|
||||||
{
|
|
||||||
return SqlDbType.Image;
|
|
||||||
}
|
|
||||||
if (type == typeof(uint) || type == typeof(ushort))
|
|
||||||
{
|
|
||||||
return SqlDbType.Int;
|
|
||||||
}
|
|
||||||
if (type == typeof(ulong))
|
|
||||||
{
|
|
||||||
return SqlDbType.BigInt;
|
|
||||||
}
|
|
||||||
if (type == typeof(DateTime))
|
|
||||||
{
|
|
||||||
return SqlDbType.DateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SqlDbType.VarChar;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates value for parameter.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The value.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static object CreateParameterValue(object value)
|
|
||||||
{
|
|
||||||
Type valueType = value.GetType();
|
|
||||||
|
|
||||||
if (valueType == typeof(UUID)) //TODO check if this works
|
|
||||||
{
|
|
||||||
return ((UUID) value).Guid;
|
|
||||||
}
|
|
||||||
if (valueType == typeof(UUID))
|
|
||||||
{
|
|
||||||
return ((UUID)value).Guid;
|
|
||||||
}
|
|
||||||
if (valueType == typeof(bool))
|
|
||||||
{
|
|
||||||
return (bool)value ? 1 : 0;
|
|
||||||
}
|
|
||||||
if (valueType == typeof(Byte[]))
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
if (valueType == typeof(int))
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a parameter for a command
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parameterName">Name of the parameter.</param>
|
|
||||||
/// <param name="parameterObject">parameter object.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
internal SqlParameter CreateParameter(string parameterName, object parameterObject)
|
|
||||||
{
|
|
||||||
return CreateParameter(parameterName, parameterObject, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates the parameter for a command.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parameterName">Name of the parameter.</param>
|
|
||||||
/// <param name="parameterObject">parameter object.</param>
|
|
||||||
/// <param name="parameterOut">if set to <c>true</c> parameter is a output parameter</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
internal SqlParameter CreateParameter(string parameterName, object parameterObject, bool parameterOut)
|
|
||||||
{
|
|
||||||
//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)
|
|
||||||
{
|
|
||||||
parameter.Direction = ParameterDirection.Output;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
parameter.Direction = ParameterDirection.Input;
|
|
||||||
parameter.Value = CreateParameterValue(parameterObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
return parameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks if we need to do some migrations to the database
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="migrationStore">migrationStore.</param>
|
|
||||||
public void CheckMigration(string migrationStore)
|
|
||||||
{
|
|
||||||
using (SqlConnection connection = new SqlConnection(connectionString))
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
Assembly assem = GetType().Assembly;
|
|
||||||
MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore);
|
|
||||||
|
|
||||||
migration.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the version of this DB provider
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string containing the DB provider</returns>
|
|
||||||
public string getVersion()
|
|
||||||
{
|
|
||||||
Module module = GetType().Module;
|
|
||||||
// string dllName = module.Assembly.ManifestModule.Name;
|
|
||||||
Version dllVersion = module.Assembly.GetName().Version;
|
|
||||||
|
|
||||||
return
|
|
||||||
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
|
|
||||||
dllVersion.Revision);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Data;
|
|
||||||
using System.Data.Common;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
public class MSSQLMigration : Migration
|
|
||||||
{
|
|
||||||
public MSSQLMigration(DbConnection conn, Assembly assem, string type)
|
|
||||||
: base(conn, assem, type)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public MSSQLMigration(DbConnection conn, Assembly assem, string subtype, string type)
|
|
||||||
: base(conn, assem, subtype, type)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override int FindVersion(DbConnection conn, string type)
|
|
||||||
{
|
|
||||||
int version = 0;
|
|
||||||
using (DbCommand cmd = conn.CreateCommand())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
cmd.CommandText = "select top 1 version from migrations where name = '" + type + "' order by version desc"; //Must be
|
|
||||||
using (IDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
version = Convert.ToInt32(reader["version"]);
|
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Return -1 to indicate table does not exist
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ExecuteScript(DbConnection conn, string[] script)
|
|
||||||
{
|
|
||||||
if (!(conn is SqlConnection))
|
|
||||||
{
|
|
||||||
base.ExecuteScript(conn, script);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string sql in script)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, (SqlConnection)conn))
|
|
||||||
{
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw new Exception(sql);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,117 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A MySQL Interface for the Presence Server
|
|
||||||
/// </summary>
|
|
||||||
public class MSSQLPresenceData : MSSQLGenericTableHandler<PresenceData>,
|
|
||||||
IPresenceData
|
|
||||||
{
|
|
||||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public MSSQLPresenceData(string connectionString, string realm) :
|
|
||||||
base(connectionString, realm, "Presence")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public PresenceData Get(UUID sessionID)
|
|
||||||
{
|
|
||||||
PresenceData[] ret = Get("SessionID",
|
|
||||||
sessionID.ToString());
|
|
||||||
|
|
||||||
if (ret.Length == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return ret[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LogoutRegionAgents(UUID regionID)
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
cmd.CommandText = String.Format("DELETE FROM {0} WHERE [RegionID]=@RegionID", m_Realm);
|
|
||||||
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString()));
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ReportAgent(UUID sessionID, UUID regionID)
|
|
||||||
{
|
|
||||||
PresenceData[] pd = Get("SessionID", sessionID.ToString());
|
|
||||||
if (pd.Length == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
cmd.CommandText = String.Format(@"UPDATE {0} SET
|
|
||||||
[RegionID] = @RegionID
|
|
||||||
WHERE [SessionID] = @SessionID", m_Realm);
|
|
||||||
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString()));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString()));
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
if (cmd.ExecuteNonQuery() == 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool VerifyAgent(UUID agentId, UUID secureSessionID)
|
|
||||||
{
|
|
||||||
PresenceData[] ret = Get("SecureSessionID",
|
|
||||||
secureSessionID.ToString());
|
|
||||||
|
|
||||||
if (ret.Length == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(ret[0].UserID != agentId.ToString())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,352 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
using RegionFlags = OpenSim.Framework.RegionFlags;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A MSSQL Interface for the Region Server.
|
|
||||||
/// </summary>
|
|
||||||
public class MSSQLRegionData : IRegionData
|
|
||||||
{
|
|
||||||
private string m_Realm;
|
|
||||||
private List<string> m_ColumnNames = null;
|
|
||||||
private string m_ConnectionString;
|
|
||||||
private MSSQLManager m_database;
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public MSSQLRegionData(string connectionString, string realm)
|
|
||||||
{
|
|
||||||
m_Realm = realm;
|
|
||||||
m_ConnectionString = connectionString;
|
|
||||||
m_database = new MSSQLManager(connectionString);
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
Migration m = new Migration(conn, GetType().Assembly, "GridStore");
|
|
||||||
m.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RegionData> Get(string regionName, UUID scopeID)
|
|
||||||
{
|
|
||||||
string sql = "select * from ["+m_Realm+"] where regionName like @regionName";
|
|
||||||
if (scopeID != UUID.Zero)
|
|
||||||
sql += " and ScopeID = @scopeID";
|
|
||||||
sql += " order by regionName";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@regionName", regionName));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
|
||||||
conn.Open();
|
|
||||||
return RunCommand(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegionData Get(int posX, int posY, UUID scopeID)
|
|
||||||
{
|
|
||||||
string sql = "select * from ["+m_Realm+"] where locX = @posX and locY = @posY";
|
|
||||||
if (scopeID != UUID.Zero)
|
|
||||||
sql += " and ScopeID = @scopeID";
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@posX", posX.ToString()));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@posY", posY.ToString()));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
|
||||||
conn.Open();
|
|
||||||
List<RegionData> ret = RunCommand(cmd);
|
|
||||||
if (ret.Count == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return ret[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegionData Get(UUID regionID, UUID scopeID)
|
|
||||||
{
|
|
||||||
string sql = "select * from ["+m_Realm+"] where uuid = @regionID";
|
|
||||||
if (scopeID != UUID.Zero)
|
|
||||||
sql += " and ScopeID = @scopeID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@regionID", regionID));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
|
||||||
conn.Open();
|
|
||||||
List<RegionData> ret = RunCommand(cmd);
|
|
||||||
if (ret.Count == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return ret[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
|
|
||||||
{
|
|
||||||
string sql = "select * from ["+m_Realm+"] where locX between @startX and @endX and locY between @startY and @endY";
|
|
||||||
if (scopeID != UUID.Zero)
|
|
||||||
sql += " and ScopeID = @scopeID";
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@startX", startX));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@startY", startY));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@endX", endX));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@endY", endY));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
|
||||||
conn.Open();
|
|
||||||
return RunCommand(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RegionData> RunCommand(SqlCommand cmd)
|
|
||||||
{
|
|
||||||
List<RegionData> retList = new List<RegionData>();
|
|
||||||
|
|
||||||
SqlDataReader result = cmd.ExecuteReader();
|
|
||||||
|
|
||||||
while (result.Read())
|
|
||||||
{
|
|
||||||
RegionData ret = new RegionData();
|
|
||||||
ret.Data = new Dictionary<string, object>();
|
|
||||||
|
|
||||||
UUID regionID;
|
|
||||||
UUID.TryParse(result["uuid"].ToString(), out regionID);
|
|
||||||
ret.RegionID = regionID;
|
|
||||||
UUID scope;
|
|
||||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
|
||||||
ret.ScopeID = scope;
|
|
||||||
ret.RegionName = result["regionName"].ToString();
|
|
||||||
ret.posX = Convert.ToInt32(result["locX"]);
|
|
||||||
ret.posY = Convert.ToInt32(result["locY"]);
|
|
||||||
ret.sizeX = Convert.ToInt32(result["sizeX"]);
|
|
||||||
ret.sizeY = Convert.ToInt32(result["sizeY"]);
|
|
||||||
|
|
||||||
if (m_ColumnNames == null)
|
|
||||||
{
|
|
||||||
m_ColumnNames = new List<string>();
|
|
||||||
|
|
||||||
DataTable schemaTable = result.GetSchemaTable();
|
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string s in m_ColumnNames)
|
|
||||||
{
|
|
||||||
if (s == "uuid")
|
|
||||||
continue;
|
|
||||||
if (s == "ScopeID")
|
|
||||||
continue;
|
|
||||||
if (s == "regionName")
|
|
||||||
continue;
|
|
||||||
if (s == "locX")
|
|
||||||
continue;
|
|
||||||
if (s == "locY")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ret.Data[s] = result[s].ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
retList.Add(ret);
|
|
||||||
}
|
|
||||||
return retList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Store(RegionData data)
|
|
||||||
{
|
|
||||||
if (data.Data.ContainsKey("uuid"))
|
|
||||||
data.Data.Remove("uuid");
|
|
||||||
if (data.Data.ContainsKey("ScopeID"))
|
|
||||||
data.Data.Remove("ScopeID");
|
|
||||||
if (data.Data.ContainsKey("regionName"))
|
|
||||||
data.Data.Remove("regionName");
|
|
||||||
if (data.Data.ContainsKey("posX"))
|
|
||||||
data.Data.Remove("posX");
|
|
||||||
if (data.Data.ContainsKey("posY"))
|
|
||||||
data.Data.Remove("posY");
|
|
||||||
if (data.Data.ContainsKey("sizeX"))
|
|
||||||
data.Data.Remove("sizeX");
|
|
||||||
if (data.Data.ContainsKey("sizeY"))
|
|
||||||
data.Data.Remove("sizeY");
|
|
||||||
if (data.Data.ContainsKey("locX"))
|
|
||||||
data.Data.Remove("locX");
|
|
||||||
if (data.Data.ContainsKey("locY"))
|
|
||||||
data.Data.Remove("locY");
|
|
||||||
|
|
||||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
string update = "update [" + m_Realm + "] set locX=@posX, locY=@posY, sizeX=@sizeX, sizeY=@sizeY ";
|
|
||||||
|
|
||||||
foreach (string field in fields)
|
|
||||||
{
|
|
||||||
|
|
||||||
update += ", ";
|
|
||||||
update += "[" + field + "] = @" + field;
|
|
||||||
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field]));
|
|
||||||
}
|
|
||||||
|
|
||||||
update += " where uuid = @regionID";
|
|
||||||
|
|
||||||
if (data.ScopeID != UUID.Zero)
|
|
||||||
update += " and ScopeID = @scopeID";
|
|
||||||
|
|
||||||
cmd.CommandText = update;
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@regionID", data.RegionID));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@regionName", data.RegionName));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", data.ScopeID));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@posX", data.posX));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@posY", data.posY));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@sizeX", data.sizeX));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@sizeY", data.sizeY));
|
|
||||||
conn.Open();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (cmd.ExecuteNonQuery() < 1)
|
|
||||||
{
|
|
||||||
string insert = "insert into [" + m_Realm + "] ([uuid], [ScopeID], [locX], [locY], [sizeX], [sizeY], [regionName], [" +
|
|
||||||
String.Join("], [", fields) +
|
|
||||||
"]) values (@regionID, @scopeID, @posX, @posY, @sizeX, @sizeY, @regionName, @" + String.Join(", @", fields) + ")";
|
|
||||||
|
|
||||||
cmd.CommandText = insert;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (cmd.ExecuteNonQuery() < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
m_log.Warn("[MSSQL Grid]: Error inserting into Regions table: " + ex.Message + ", INSERT sql: " + insert);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
m_log.Warn("[MSSQL Grid]: Error updating Regions table: " + ex.Message + ", UPDATE sql: " + update);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetDataItem(UUID regionID, string item, string value)
|
|
||||||
{
|
|
||||||
string sql = "update [" + m_Realm +
|
|
||||||
"] set [" + item + "] = @" + item + " where uuid = @UUID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@" + item, value));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@UUID", regionID));
|
|
||||||
conn.Open();
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(UUID regionID)
|
|
||||||
{
|
|
||||||
string sql = "delete from [" + m_Realm +
|
|
||||||
"] where uuid = @UUID";
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@UUID", regionID));
|
|
||||||
conn.Open();
|
|
||||||
if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RegionData> GetDefaultRegions(UUID scopeID)
|
|
||||||
{
|
|
||||||
return Get((int)RegionFlags.DefaultRegion, scopeID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
|
|
||||||
{
|
|
||||||
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
|
||||||
{
|
|
||||||
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
|
||||||
RegionDataDistanceCompare distanceComparer = new RegionDataDistanceCompare(x, y);
|
|
||||||
regions.Sort(distanceComparer);
|
|
||||||
|
|
||||||
return regions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RegionData> GetHyperlinks(UUID scopeID)
|
|
||||||
{
|
|
||||||
return Get((int)RegionFlags.Hyperlink, scopeID);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<RegionData> Get(int regionFlags, UUID scopeID)
|
|
||||||
{
|
|
||||||
string sql = "SELECT * FROM [" + m_Realm + "] WHERE (flags & " + regionFlags.ToString() + ") <> 0";
|
|
||||||
if (scopeID != UUID.Zero)
|
|
||||||
sql += " AND ScopeID = @scopeID";
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
|
||||||
conn.Open();
|
|
||||||
return RunCommand(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,246 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
public class MSSQLUserAccountData : MSSQLGenericTableHandler<UserAccountData>,IUserAccountData
|
|
||||||
{
|
|
||||||
public MSSQLUserAccountData(string connectionString, string realm) :
|
|
||||||
base(connectionString, realm, "UserAccount")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
//private string m_Realm;
|
|
||||||
//private List<string> m_ColumnNames = null;
|
|
||||||
//private MSSQLManager m_database;
|
|
||||||
|
|
||||||
//public MSSQLUserAccountData(string connectionString, string realm)
|
|
||||||
//{
|
|
||||||
// m_Realm = realm;
|
|
||||||
// m_ConnectionString = connectionString;
|
|
||||||
// m_database = new MSSQLManager(connectionString);
|
|
||||||
|
|
||||||
// using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
// {
|
|
||||||
// conn.Open();
|
|
||||||
// Migration m = new Migration(conn, GetType().Assembly, "UserStore");
|
|
||||||
// m.Update();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query)
|
|
||||||
//{
|
|
||||||
// return null;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public UserAccountData Get(UUID principalID, UUID scopeID)
|
|
||||||
//{
|
|
||||||
// UserAccountData ret = new UserAccountData();
|
|
||||||
// ret.Data = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
// string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm);
|
|
||||||
// if (scopeID != UUID.Zero)
|
|
||||||
// sql += " and ScopeID = @scopeID";
|
|
||||||
|
|
||||||
// using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
// using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
// {
|
|
||||||
// cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID));
|
|
||||||
// cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
|
||||||
|
|
||||||
// conn.Open();
|
|
||||||
// using (SqlDataReader result = cmd.ExecuteReader())
|
|
||||||
// {
|
|
||||||
// if (result.Read())
|
|
||||||
// {
|
|
||||||
// ret.PrincipalID = principalID;
|
|
||||||
// UUID scope;
|
|
||||||
// UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
|
||||||
// ret.ScopeID = scope;
|
|
||||||
|
|
||||||
// if (m_ColumnNames == null)
|
|
||||||
// {
|
|
||||||
// m_ColumnNames = new List<string>();
|
|
||||||
|
|
||||||
// DataTable schemaTable = result.GetSchemaTable();
|
|
||||||
// foreach (DataRow row in schemaTable.Rows)
|
|
||||||
// m_ColumnNames.Add(row["ColumnName"].ToString());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// foreach (string s in m_ColumnNames)
|
|
||||||
// {
|
|
||||||
// if (s == "UUID")
|
|
||||||
// continue;
|
|
||||||
// if (s == "ScopeID")
|
|
||||||
// continue;
|
|
||||||
|
|
||||||
// ret.Data[s] = result[s].ToString();
|
|
||||||
// }
|
|
||||||
// return ret;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public bool Store(UserAccountData data)
|
|
||||||
//{
|
|
||||||
// if (data.Data.ContainsKey("UUID"))
|
|
||||||
// data.Data.Remove("UUID");
|
|
||||||
// if (data.Data.ContainsKey("ScopeID"))
|
|
||||||
// data.Data.Remove("ScopeID");
|
|
||||||
|
|
||||||
// string[] fields = new List<string>(data.Data.Keys).ToArray();
|
|
||||||
|
|
||||||
// using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
// using (SqlCommand cmd = new SqlCommand())
|
|
||||||
// {
|
|
||||||
// StringBuilder updateBuilder = new StringBuilder();
|
|
||||||
// updateBuilder.AppendFormat("update {0} set ", m_Realm);
|
|
||||||
// bool first = true;
|
|
||||||
// foreach (string field in fields)
|
|
||||||
// {
|
|
||||||
// if (!first)
|
|
||||||
// updateBuilder.Append(", ");
|
|
||||||
// updateBuilder.AppendFormat("{0} = @{0}", field);
|
|
||||||
|
|
||||||
// first = false;
|
|
||||||
// cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field]));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// updateBuilder.Append(" where UUID = @principalID");
|
|
||||||
|
|
||||||
// if (data.ScopeID != UUID.Zero)
|
|
||||||
// updateBuilder.Append(" and ScopeID = @scopeID");
|
|
||||||
|
|
||||||
// cmd.CommandText = updateBuilder.ToString();
|
|
||||||
// cmd.Connection = conn;
|
|
||||||
// cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID));
|
|
||||||
// cmd.Parameters.Add(m_database.CreateParameter("@scopeID", data.ScopeID));
|
|
||||||
// conn.Open();
|
|
||||||
|
|
||||||
// if (cmd.ExecuteNonQuery() < 1)
|
|
||||||
// {
|
|
||||||
// StringBuilder insertBuilder = new StringBuilder();
|
|
||||||
// insertBuilder.AppendFormat("insert into {0} (UUID, ScopeID, ", m_Realm);
|
|
||||||
// insertBuilder.Append(String.Join(", ", fields));
|
|
||||||
// insertBuilder.Append(") values (@principalID, @scopeID, @");
|
|
||||||
// insertBuilder.Append(String.Join(", @", fields));
|
|
||||||
// insertBuilder.Append(")");
|
|
||||||
|
|
||||||
// cmd.CommandText = insertBuilder.ToString();
|
|
||||||
|
|
||||||
// if (cmd.ExecuteNonQuery() < 1)
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public bool Store(UserAccountData data, UUID principalID, string token)
|
|
||||||
//{
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public bool SetDataItem(UUID principalID, string item, string value)
|
|
||||||
//{
|
|
||||||
// string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item);
|
|
||||||
// using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
// using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
// {
|
|
||||||
// cmd.Parameters.Add(m_database.CreateParameter("@" + item, value));
|
|
||||||
// cmd.Parameters.Add(m_database.CreateParameter("@UUID", principalID));
|
|
||||||
|
|
||||||
// conn.Open();
|
|
||||||
|
|
||||||
// if (cmd.ExecuteNonQuery() > 0)
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public UserAccountData[] Get(string[] keys, string[] vals)
|
|
||||||
//{
|
|
||||||
// return null;
|
|
||||||
//}
|
|
||||||
|
|
||||||
public UserAccountData[] GetUsers(UUID scopeID, string query)
|
|
||||||
{
|
|
||||||
string[] words = query.Split(new char[] { ' ' });
|
|
||||||
|
|
||||||
for (int i = 0; i < words.Length; i++)
|
|
||||||
{
|
|
||||||
if (words[i].Length < 3)
|
|
||||||
{
|
|
||||||
if (i != words.Length - 1)
|
|
||||||
Array.Copy(words, i + 1, words, i, words.Length - i - 1);
|
|
||||||
Array.Resize(ref words, words.Length - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (words.Length == 0)
|
|
||||||
return new UserAccountData[0];
|
|
||||||
|
|
||||||
if (words.Length > 2)
|
|
||||||
return new UserAccountData[0];
|
|
||||||
|
|
||||||
string sql = "";
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
if (words.Length == 1)
|
|
||||||
{
|
|
||||||
sql = String.Format("select * from {0} where ([ScopeID]=@ScopeID or [ScopeID]='00000000-0000-0000-0000-000000000000') and ([FirstName] like @search or [LastName] like @search)", m_Realm);
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@search", "%" + words[0] + "%"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sql = String.Format("select * from {0} where ([ScopeID]=@ScopeID or [ScopeID]='00000000-0000-0000-0000-000000000000') and ([FirstName] like @searchFirst or [LastName] like @searchLast)", m_Realm);
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@searchFirst", "%" + words[0] + "%"));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@searchLast", "%" + words[1] + "%"));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@ScopeID", scopeID.ToString()));
|
|
||||||
}
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.CommandText = sql;
|
|
||||||
conn.Open();
|
|
||||||
return DoQuery(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,305 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using log4net;
|
|
||||||
|
|
||||||
namespace OpenSim.Data.MSSQL
|
|
||||||
{
|
|
||||||
public class MSSQLXInventoryData : IXInventoryData
|
|
||||||
{
|
|
||||||
// private static readonly ILog m_log = LogManager.GetLogger(
|
|
||||||
// MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private MSSQLFolderHandler m_Folders;
|
|
||||||
private MSSQLItemHandler m_Items;
|
|
||||||
|
|
||||||
public MSSQLXInventoryData(string conn, string realm)
|
|
||||||
{
|
|
||||||
m_Folders = new MSSQLFolderHandler(
|
|
||||||
conn, "inventoryfolders", "InventoryStore");
|
|
||||||
m_Items = new MSSQLItemHandler(
|
|
||||||
conn, "inventoryitems", String.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Folders.Get(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public XInventoryItem[] GetItems(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Items.Get(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool StoreFolder(XInventoryFolder folder)
|
|
||||||
{
|
|
||||||
if (folder.folderName.Length > 64)
|
|
||||||
folder.folderName = folder.folderName.Substring(0, 64);
|
|
||||||
return m_Folders.Store(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool StoreItem(XInventoryItem item)
|
|
||||||
{
|
|
||||||
if (item.inventoryName.Length > 64)
|
|
||||||
item.inventoryName = item.inventoryName.Substring(0, 64);
|
|
||||||
if (item.inventoryDescription.Length > 128)
|
|
||||||
item.inventoryDescription = item.inventoryDescription.Substring(0, 128);
|
|
||||||
|
|
||||||
return m_Items.Store(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeleteFolders(string field, string val)
|
|
||||||
{
|
|
||||||
return m_Folders.Delete(field, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeleteFolders(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Folders.Delete(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeleteItems(string field, string val)
|
|
||||||
{
|
|
||||||
return m_Items.Delete(field, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeleteItems(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Items.Delete(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveItem(string id, string newParent)
|
|
||||||
{
|
|
||||||
return m_Items.MoveItem(id, newParent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveFolder(string id, string newParent)
|
|
||||||
{
|
|
||||||
return m_Folders.MoveFolder(id, newParent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
|
||||||
{
|
|
||||||
return m_Items.GetActiveGestures(principalID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
|
||||||
{
|
|
||||||
return m_Items.GetAssetPermissions(principalID, assetID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MSSQLItemHandler : MSSQLInventoryHandler<XInventoryItem>
|
|
||||||
{
|
|
||||||
public MSSQLItemHandler(string c, string t, string m) :
|
|
||||||
base(c, t, m)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveItem(string id, string newParent)
|
|
||||||
{
|
|
||||||
XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
|
|
||||||
if (retrievedItems.Length == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
UUID oldParent = retrievedItems[0].parentFolderID;
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
{
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm);
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id));
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() == 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IncrementFolderVersion(oldParent);
|
|
||||||
IncrementFolderVersion(newParent);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
{
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm);
|
|
||||||
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString()));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture));
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
return DoQuery(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
|
||||||
{
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
{
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm);
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString()));
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
|
|
||||||
int perms = 0;
|
|
||||||
|
|
||||||
if (reader.Read())
|
|
||||||
{
|
|
||||||
perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return perms;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Store(XInventoryItem item)
|
|
||||||
{
|
|
||||||
if (!base.Store(item))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
IncrementFolderVersion(item.parentFolderID);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MSSQLFolderHandler : MSSQLInventoryHandler<XInventoryFolder>
|
|
||||||
{
|
|
||||||
public MSSQLFolderHandler(string c, string t, string m) :
|
|
||||||
base(c, t, m)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveFolder(string id, string newParentFolderID)
|
|
||||||
{
|
|
||||||
XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
|
|
||||||
|
|
||||||
if (folders.Length == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
UUID oldParentFolderUUID = folders[0].parentFolderID;
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
{
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
|
|
||||||
cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where folderID = @folderID", m_Realm);
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParentFolderID));
|
|
||||||
cmd.Parameters.Add(m_database.CreateParameter("@folderID", id));
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
if (cmd.ExecuteNonQuery() == 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IncrementFolderVersion(oldParentFolderUUID);
|
|
||||||
IncrementFolderVersion(newParentFolderID);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Store(XInventoryFolder folder)
|
|
||||||
{
|
|
||||||
if (!base.Store(folder))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
IncrementFolderVersion(folder.parentFolderID);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MSSQLInventoryHandler<T> : MSSQLGenericTableHandler<T> where T: class, new()
|
|
||||||
{
|
|
||||||
public MSSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {}
|
|
||||||
|
|
||||||
protected bool IncrementFolderVersion(UUID folderID)
|
|
||||||
{
|
|
||||||
return IncrementFolderVersion(folderID.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected bool IncrementFolderVersion(string folderID)
|
|
||||||
{
|
|
||||||
// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
|
|
||||||
// Util.PrintCallStack();
|
|
||||||
|
|
||||||
string sql = "update inventoryfolders set version=version+1 where folderID = @folderID";
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
|
||||||
{
|
|
||||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
cmd.Parameters.AddWithValue("@folderID", folderID);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
|
|
||||||
[assembly : AssemblyTitle("OpenSim.Data.MSSQL")]
|
|
||||||
[assembly : AssemblyDescription("")]
|
|
||||||
[assembly : AssemblyConfiguration("")]
|
|
||||||
[assembly : AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly : AssemblyProduct("OpenSim.Data.MSSQL")]
|
|
||||||
[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
|
|
||||||
[assembly : AssemblyTrademark("")]
|
|
||||||
[assembly : AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
|
|
||||||
[assembly : ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
|
|
||||||
[assembly : Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
|
|
||||||
[assembly : AssemblyVersion("0.8.1.*")]
|
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
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]
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 3
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE assets add create_time integer default 0
|
|
||||||
ALTER TABLE assets add access_time integer default 0
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 4
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_assets
|
|
||||||
(
|
|
||||||
id uniqueidentifier 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,
|
|
||||||
create_time int NULL,
|
|
||||||
access_time int NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
TEXTIMAGE_ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.assets)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_assets (id, name, description, assetType, local, temporary, data, create_time, access_time)
|
|
||||||
SELECT CONVERT(uniqueidentifier, id), name, description, assetType, local, temporary, data, create_time, access_time FROM dbo.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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 5
|
|
||||||
|
|
||||||
DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621';
|
|
||||||
|
|
||||||
:VERSION 6
|
|
||||||
|
|
||||||
ALTER TABLE assets ADD asset_flags INTEGER NOT NULL DEFAULT 0;
|
|
||||||
|
|
||||||
:VERSION 7
|
|
||||||
|
|
||||||
alter table assets add creatorid varchar(36) not null default '';
|
|
|
@ -1,32 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE [auth] (
|
|
||||||
[uuid] [uniqueidentifier] NOT NULL default '00000000-0000-0000-0000-000000000000',
|
|
||||||
[passwordHash] [varchar](32) NOT NULL,
|
|
||||||
[passwordSalt] [varchar](32) NOT NULL,
|
|
||||||
[webLoginKey] [varchar](255) NOT NULL,
|
|
||||||
[accountType] VARCHAR(32) NOT NULL DEFAULT 'UserAccount',
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
CREATE TABLE [tokens] (
|
|
||||||
[uuid] [uniqueidentifier] NOT NULL default '00000000-0000-0000-0000-000000000000',
|
|
||||||
[token] [varchar](255) NOT NULL,
|
|
||||||
[validity] [datetime] NOT NULL )
|
|
||||||
ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND type in (N'U'))
|
|
||||||
INSERT INTO auth (UUID, passwordHash, passwordSalt, webLoginKey, accountType) SELECT [UUID] AS UUID, [passwordHash] AS passwordHash, [passwordSalt] AS passwordSalt, [webLoginKey] AS webLoginKey, 'UserAccount' as [accountType] FROM users;
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE [Avatars] (
|
|
||||||
[PrincipalID] uniqueidentifier NOT NULL,
|
|
||||||
[Name] varchar(32) NOT NULL,
|
|
||||||
[Value] varchar(255) NOT NULL DEFAULT '',
|
|
||||||
PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[PrincipalID] ASC, [Name] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_Avatars
|
|
||||||
(
|
|
||||||
PrincipalID uniqueidentifier NOT NULL,
|
|
||||||
[Name] varchar(32) NOT NULL,
|
|
||||||
Value text NOT NULL DEFAULT '',
|
|
||||||
) ON [PRIMARY]
|
|
||||||
TEXTIMAGE_ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.Avatars)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_Avatars (PrincipalID, Name, Value)
|
|
||||||
SELECT PrincipalID, CONVERT(text, Name), Value FROM dbo.Avatars WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.Avatars
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_Avatars', N'Avatars', 'OBJECT'
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 3
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_Avatars
|
|
||||||
(
|
|
||||||
PrincipalID uniqueidentifier NOT NULL,
|
|
||||||
[Name] varchar(32) NOT NULL,
|
|
||||||
Value text NOT NULL DEFAULT '',
|
|
||||||
PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[PrincipalID] ASC, [Name] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY]
|
|
||||||
TEXTIMAGE_ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.Avatars)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_Avatars (PrincipalID, Name, Value)
|
|
||||||
SELECT PrincipalID, CONVERT(text, Name), Value FROM dbo.Avatars WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.Avatars
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_Avatars', N'Avatars', 'OBJECT'
|
|
||||||
COMMIT
|
|
||||||
|
|
|
@ -1,342 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE [dbo].[estate_managers](
|
|
||||||
[EstateID] [int] NOT NULL,
|
|
||||||
[uuid] [varchar](36) NOT NULL,
|
|
||||||
CONSTRAINT [PK_estate_managers] PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[EstateID] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY];
|
|
||||||
|
|
||||||
CREATE TABLE [dbo].[estate_groups](
|
|
||||||
[EstateID] [int] NOT NULL,
|
|
||||||
[uuid] [varchar](36) NOT NULL,
|
|
||||||
CONSTRAINT [PK_estate_groups] PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[EstateID] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY];
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE [dbo].[estate_users](
|
|
||||||
[EstateID] [int] NOT NULL,
|
|
||||||
[uuid] [varchar](36) NOT NULL,
|
|
||||||
CONSTRAINT [PK_estate_users] PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[EstateID] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY];
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE [dbo].[estateban](
|
|
||||||
[EstateID] [int] NOT NULL,
|
|
||||||
[bannedUUID] [varchar](36) NOT NULL,
|
|
||||||
[bannedIp] [varchar](16) NOT NULL,
|
|
||||||
[bannedIpHostMask] [varchar](16) NOT NULL,
|
|
||||||
[bannedNameMask] [varchar](64) NULL DEFAULT (NULL),
|
|
||||||
CONSTRAINT [PK_estateban] PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[EstateID] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY];
|
|
||||||
|
|
||||||
CREATE TABLE [dbo].[estate_settings](
|
|
||||||
[EstateID] [int] IDENTITY(1,100) NOT NULL,
|
|
||||||
[EstateName] [varchar](64) NULL DEFAULT (NULL),
|
|
||||||
[AbuseEmailToEstateOwner] [bit] NOT NULL,
|
|
||||||
[DenyAnonymous] [bit] NOT NULL,
|
|
||||||
[ResetHomeOnTeleport] [bit] NOT NULL,
|
|
||||||
[FixedSun] [bit] NOT NULL,
|
|
||||||
[DenyTransacted] [bit] NOT NULL,
|
|
||||||
[BlockDwell] [bit] NOT NULL,
|
|
||||||
[DenyIdentified] [bit] NOT NULL,
|
|
||||||
[AllowVoice] [bit] NOT NULL,
|
|
||||||
[UseGlobalTime] [bit] NOT NULL,
|
|
||||||
[PricePerMeter] [int] NOT NULL,
|
|
||||||
[TaxFree] [bit] NOT NULL,
|
|
||||||
[AllowDirectTeleport] [bit] NOT NULL,
|
|
||||||
[RedirectGridX] [int] NOT NULL,
|
|
||||||
[RedirectGridY] [int] NOT NULL,
|
|
||||||
[ParentEstateID] [int] NOT NULL,
|
|
||||||
[SunPosition] [float] NOT NULL,
|
|
||||||
[EstateSkipScripts] [bit] NOT NULL,
|
|
||||||
[BillableFactor] [float] NOT NULL,
|
|
||||||
[PublicAccess] [bit] NOT NULL,
|
|
||||||
[AbuseEmail] [varchar](255) NOT NULL,
|
|
||||||
[EstateOwner] [varchar](36) NOT NULL,
|
|
||||||
[DenyMinors] [bit] NOT NULL,
|
|
||||||
CONSTRAINT [PK_estate_settings] PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[EstateID] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY];
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE [dbo].[estate_map](
|
|
||||||
[RegionID] [varchar](36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
|
||||||
[EstateID] [int] NOT NULL,
|
|
||||||
CONSTRAINT [PK_estate_map] PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[RegionID] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY];
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE dbo.estate_managers DROP CONSTRAINT PK_estate_managers
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX IX_estate_managers ON dbo.estate_managers
|
|
||||||
(
|
|
||||||
EstateID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
ALTER TABLE dbo.estate_groups DROP CONSTRAINT PK_estate_groups
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX IX_estate_groups ON dbo.estate_groups
|
|
||||||
(
|
|
||||||
EstateID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE dbo.estate_users DROP CONSTRAINT PK_estate_users
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX IX_estate_users ON dbo.estate_users
|
|
||||||
(
|
|
||||||
EstateID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 3
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_estateban
|
|
||||||
(
|
|
||||||
EstateID int NOT NULL,
|
|
||||||
bannedUUID varchar(36) NOT NULL,
|
|
||||||
bannedIp varchar(16) NULL,
|
|
||||||
bannedIpHostMask varchar(16) NULL,
|
|
||||||
bannedNameMask varchar(64) NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.estateban)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask)
|
|
||||||
SELECT EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask FROM dbo.estateban')
|
|
||||||
|
|
||||||
DROP TABLE dbo.estateban
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_estateban', N'estateban', 'OBJECT'
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX IX_estateban ON dbo.estateban
|
|
||||||
(
|
|
||||||
EstateID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 4
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_estate_managers
|
|
||||||
(
|
|
||||||
EstateID int NOT NULL,
|
|
||||||
uuid uniqueidentifier NOT NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.estate_managers)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_estate_managers (EstateID, uuid)
|
|
||||||
SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_managers WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.estate_managers
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_estate_managers', N'estate_managers', 'OBJECT'
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX IX_estate_managers ON dbo.estate_managers
|
|
||||||
(
|
|
||||||
EstateID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 5
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_estate_groups
|
|
||||||
(
|
|
||||||
EstateID int NOT NULL,
|
|
||||||
uuid uniqueidentifier NOT NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.estate_groups)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_estate_groups (EstateID, uuid)
|
|
||||||
SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_groups WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.estate_groups
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_estate_groups', N'estate_groups', 'OBJECT'
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX IX_estate_groups ON dbo.estate_groups
|
|
||||||
(
|
|
||||||
EstateID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 6
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_estate_users
|
|
||||||
(
|
|
||||||
EstateID int NOT NULL,
|
|
||||||
uuid uniqueidentifier NOT NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.estate_users)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_estate_users (EstateID, uuid)
|
|
||||||
SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_users WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.estate_users
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_estate_users', N'estate_users', 'OBJECT'
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX IX_estate_users ON dbo.estate_users
|
|
||||||
(
|
|
||||||
EstateID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 7
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_estateban
|
|
||||||
(
|
|
||||||
EstateID int NOT NULL,
|
|
||||||
bannedUUID uniqueidentifier NOT NULL,
|
|
||||||
bannedIp varchar(16) NULL,
|
|
||||||
bannedIpHostMask varchar(16) NULL,
|
|
||||||
bannedNameMask varchar(64) NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.estateban)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask)
|
|
||||||
SELECT EstateID, CONVERT(uniqueidentifier, bannedUUID), bannedIp, bannedIpHostMask, bannedNameMask FROM dbo.estateban WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.estateban
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_estateban', N'estateban', 'OBJECT'
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX IX_estateban ON dbo.estateban
|
|
||||||
(
|
|
||||||
EstateID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 8
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_estate_settings
|
|
||||||
(
|
|
||||||
EstateID int NOT NULL IDENTITY (1, 100),
|
|
||||||
EstateName varchar(64) NULL DEFAULT (NULL),
|
|
||||||
AbuseEmailToEstateOwner bit NOT NULL,
|
|
||||||
DenyAnonymous bit NOT NULL,
|
|
||||||
ResetHomeOnTeleport bit NOT NULL,
|
|
||||||
FixedSun bit NOT NULL,
|
|
||||||
DenyTransacted bit NOT NULL,
|
|
||||||
BlockDwell bit NOT NULL,
|
|
||||||
DenyIdentified bit NOT NULL,
|
|
||||||
AllowVoice bit NOT NULL,
|
|
||||||
UseGlobalTime bit NOT NULL,
|
|
||||||
PricePerMeter int NOT NULL,
|
|
||||||
TaxFree bit NOT NULL,
|
|
||||||
AllowDirectTeleport bit NOT NULL,
|
|
||||||
RedirectGridX int NOT NULL,
|
|
||||||
RedirectGridY int NOT NULL,
|
|
||||||
ParentEstateID int NOT NULL,
|
|
||||||
SunPosition float(53) NOT NULL,
|
|
||||||
EstateSkipScripts bit NOT NULL,
|
|
||||||
BillableFactor float(53) NOT NULL,
|
|
||||||
PublicAccess bit NOT NULL,
|
|
||||||
AbuseEmail varchar(255) NOT NULL,
|
|
||||||
EstateOwner uniqueidentifier NOT NULL,
|
|
||||||
DenyMinors bit NOT NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
SET IDENTITY_INSERT dbo.Tmp_estate_settings ON
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.estate_settings)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_estate_settings (EstateID, EstateName, AbuseEmailToEstateOwner, DenyAnonymous, ResetHomeOnTeleport, FixedSun, DenyTransacted, BlockDwell, DenyIdentified, AllowVoice, UseGlobalTime, PricePerMeter, TaxFree, AllowDirectTeleport, RedirectGridX, RedirectGridY, ParentEstateID, SunPosition, EstateSkipScripts, BillableFactor, PublicAccess, AbuseEmail, EstateOwner, DenyMinors)
|
|
||||||
SELECT EstateID, EstateName, AbuseEmailToEstateOwner, DenyAnonymous, ResetHomeOnTeleport, FixedSun, DenyTransacted, BlockDwell, DenyIdentified, AllowVoice, UseGlobalTime, PricePerMeter, TaxFree, AllowDirectTeleport, RedirectGridX, RedirectGridY, ParentEstateID, SunPosition, EstateSkipScripts, BillableFactor, PublicAccess, AbuseEmail, CONVERT(uniqueidentifier, EstateOwner), DenyMinors FROM dbo.estate_settings WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
SET IDENTITY_INSERT dbo.Tmp_estate_settings OFF
|
|
||||||
|
|
||||||
DROP TABLE dbo.estate_settings
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_estate_settings', N'estate_settings', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE dbo.estate_settings ADD CONSTRAINT
|
|
||||||
PK_estate_settings PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
EstateID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 9
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_estate_map
|
|
||||||
(
|
|
||||||
RegionID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
|
||||||
EstateID int NOT NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.estate_map)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_estate_map (RegionID, EstateID)
|
|
||||||
SELECT CONVERT(uniqueidentifier, RegionID), EstateID FROM dbo.estate_map WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.estate_map
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_estate_map', N'estate_map', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE dbo.estate_map ADD CONSTRAINT
|
|
||||||
PK_estate_map PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
RegionID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 10
|
|
||||||
|
|
||||||
BEGIN transaction
|
|
||||||
|
|
||||||
ALTER TABLE estate_settings ADD AllowLandmark tinyint NOT NULL default 1;
|
|
||||||
ALTER TABLE estate_settings ADD AllowParcelChanges tinyint NOT NULL default 1;
|
|
||||||
ALTER TABLE estate_settings ADD AllowSetHome tinyint NOT NULL default 1;
|
|
||||||
|
|
||||||
COMMIT;
|
|
|
@ -1,50 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE [Friends] (
|
|
||||||
[PrincipalID] uniqueidentifier NOT NULL,
|
|
||||||
[Friend] varchar(255) NOT NULL,
|
|
||||||
[Flags] char(16) NOT NULL DEFAULT '0',
|
|
||||||
[Offered] varchar(32) NOT NULL DEFAULT 0)
|
|
||||||
ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[userfriends]') AND type in (N'U'))
|
|
||||||
INSERT INTO Friends (PrincipalID, Friend, Flags, Offered)
|
|
||||||
SELECT [ownerID], [friendID], [friendPerms], 0 FROM userfriends;
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 3
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE [Tmp_Friends]
|
|
||||||
([PrincipalID] varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
|
||||||
[Friend] varchar(255) NOT NULL,
|
|
||||||
[Flags] char(16) NOT NULL DEFAULT '0',
|
|
||||||
[Offered] varchar(32) NOT NULL DEFAULT 0)
|
|
||||||
ON [PRIMARY]
|
|
||||||
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.Friends)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_Friends (PrincipalID, Friend, Flags, Offered)
|
|
||||||
SELECT CONVERT(varchar(255),PrincipalID), Friend, Flags, Offered FROM dbo.Friends WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.Friends
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_Friends', N'Friends', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE dbo.Friends ADD
|
|
||||||
PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[PrincipalID] ASC, [Friend] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
|
@ -1,245 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE Tmp_regions
|
|
||||||
(
|
|
||||||
uuid varchar(36) COLLATE Latin1_General_CI_AS NOT NULL,
|
|
||||||
regionHandle bigint NULL,
|
|
||||||
regionName varchar(20) NULL,
|
|
||||||
regionRecvKey varchar(128) NULL,
|
|
||||||
regionSendKey varchar(128) NULL,
|
|
||||||
regionSecret varchar(128) NULL,
|
|
||||||
regionDataURI varchar(128) NULL,
|
|
||||||
serverIP varchar(64) NULL,
|
|
||||||
serverPort int NULL,
|
|
||||||
serverURI varchar(255) NULL,
|
|
||||||
locX int NULL,
|
|
||||||
locY int NULL,
|
|
||||||
locZ int NULL,
|
|
||||||
eastOverrideHandle bigint NULL,
|
|
||||||
westOverrideHandle bigint NULL,
|
|
||||||
southOverrideHandle bigint NULL,
|
|
||||||
northOverrideHandle bigint NULL,
|
|
||||||
regionAssetURI varchar(255) NULL,
|
|
||||||
regionAssetRecvKey varchar(128) NULL,
|
|
||||||
regionAssetSendKey varchar(128) NULL,
|
|
||||||
regionUserURI varchar(255) NULL,
|
|
||||||
regionUserRecvKey varchar(128) NULL,
|
|
||||||
regionUserSendKey varchar(128) NULL,
|
|
||||||
regionMapTexture varchar(36) NULL,
|
|
||||||
serverHttpPort int NULL,
|
|
||||||
serverRemotingPort int NULL,
|
|
||||||
owner_uuid varchar(36) NULL,
|
|
||||||
originUUID varchar(36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000')
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM regions)
|
|
||||||
EXEC('INSERT INTO Tmp_regions (uuid, regionHandle, regionName, regionRecvKey, regionSendKey, regionSecret, regionDataURI, serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid)
|
|
||||||
SELECT CONVERT(varchar(36), uuid), CONVERT(bigint, regionHandle), CONVERT(varchar(20), regionName), CONVERT(varchar(128), regionRecvKey), CONVERT(varchar(128), regionSendKey), CONVERT(varchar(128), regionSecret), CONVERT(varchar(128), regionDataURI), CONVERT(varchar(64), serverIP), CONVERT(int, serverPort), serverURI, CONVERT(int, locX), CONVERT(int, locY), CONVERT(int, locZ), CONVERT(bigint, eastOverrideHandle), CONVERT(bigint, westOverrideHandle), CONVERT(bigint, southOverrideHandle), CONVERT(bigint, northOverrideHandle), regionAssetURI, CONVERT(varchar(128), regionAssetRecvKey), CONVERT(varchar(128), regionAssetSendKey), regionUserURI, CONVERT(varchar(128), regionUserRecvKey), CONVERT(varchar(128), regionUserSendKey), CONVERT(varchar(36), regionMapTexture), CONVERT(int, serverHttpPort), CONVERT(int, serverRemotingPort), owner_uuid FROM regions')
|
|
||||||
|
|
||||||
DROP TABLE regions
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'Tmp_regions', N'regions', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE regions ADD CONSTRAINT
|
|
||||||
PK__regions__uuid PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
uuid
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 3
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 4
|
|
||||||
|
|
||||||
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_regions
|
|
||||||
(
|
|
||||||
uuid uniqueidentifier NOT NULL,
|
|
||||||
regionHandle bigint NULL,
|
|
||||||
regionName varchar(20) NULL,
|
|
||||||
regionRecvKey varchar(128) NULL,
|
|
||||||
regionSendKey varchar(128) NULL,
|
|
||||||
regionSecret varchar(128) NULL,
|
|
||||||
regionDataURI varchar(128) NULL,
|
|
||||||
serverIP varchar(64) NULL,
|
|
||||||
serverPort int NULL,
|
|
||||||
serverURI varchar(255) NULL,
|
|
||||||
locX int NULL,
|
|
||||||
locY int NULL,
|
|
||||||
locZ int NULL,
|
|
||||||
eastOverrideHandle bigint NULL,
|
|
||||||
westOverrideHandle bigint NULL,
|
|
||||||
southOverrideHandle bigint NULL,
|
|
||||||
northOverrideHandle bigint NULL,
|
|
||||||
regionAssetURI varchar(255) NULL,
|
|
||||||
regionAssetRecvKey varchar(128) NULL,
|
|
||||||
regionAssetSendKey varchar(128) NULL,
|
|
||||||
regionUserURI varchar(255) NULL,
|
|
||||||
regionUserRecvKey varchar(128) NULL,
|
|
||||||
regionUserSendKey varchar(128) NULL,
|
|
||||||
regionMapTexture uniqueidentifier NULL,
|
|
||||||
serverHttpPort int NULL,
|
|
||||||
serverRemotingPort int NULL,
|
|
||||||
owner_uuid uniqueidentifier NOT NULL,
|
|
||||||
originUUID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000')
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.regions)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_regions (uuid, regionHandle, regionName, regionRecvKey, regionSendKey, regionSecret, regionDataURI, serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort, owner_uuid, originUUID)
|
|
||||||
SELECT CONVERT(uniqueidentifier, uuid), regionHandle, regionName, regionRecvKey, regionSendKey, regionSecret, regionDataURI, serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, CONVERT(uniqueidentifier, regionMapTexture), serverHttpPort, serverRemotingPort, CONVERT(uniqueidentifier, owner_uuid), CONVERT(uniqueidentifier, originUUID) FROM dbo.regions WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.regions
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_regions', N'regions', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE dbo.regions ADD CONSTRAINT
|
|
||||||
PK__regions__uuid PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
uuid
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 5
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE regions ADD access int default 0;
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 6
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE regions ADD scopeid uniqueidentifier default '00000000-0000-0000-0000-000000000000';
|
|
||||||
ALTER TABLE regions ADD DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [owner_uuid];
|
|
||||||
ALTER TABLE regions ADD sizeX integer not null default 0;
|
|
||||||
ALTER TABLE regions ADD sizeY integer not null default 0;
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 7
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE regions ADD [flags] integer NOT NULL DEFAULT 0;
|
|
||||||
CREATE INDEX [flags] ON regions(flags);
|
|
||||||
ALTER TABLE [regions] ADD [last_seen] integer NOT NULL DEFAULT 0;
|
|
||||||
ALTER TABLE [regions] ADD [PrincipalID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
|
|
||||||
ALTER TABLE [regions] ADD [Token] varchar(255) NOT NULL DEFAULT 0;
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 8
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
ALTER TABLE regions ALTER COLUMN regionName VarChar(128)
|
|
||||||
|
|
||||||
DROP INDEX IX_regions_name ON dbo.regions
|
|
||||||
ALTER TABLE regions ALTER COLUMN regionName VarChar(128) null
|
|
||||||
|
|
||||||
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]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 9
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
ALTER TABLE regions ADD parcelMapTexture uniqueidentifier NULL;
|
|
||||||
|
|
||||||
COMMIT
|
|
|
@ -1,65 +0,0 @@
|
||||||
:VERSION 1 # --------------------------
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE "GridUser" (
|
|
||||||
"UserID" VARCHAR(255) NOT NULL,
|
|
||||||
"HomeRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
|
||||||
"HomePosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
|
||||||
"HomeLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
|
||||||
"LastRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
|
||||||
"LastPosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
|
||||||
"LastLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
|
||||||
"Online" CHAR(5) NOT NULL DEFAULT 'false',
|
|
||||||
"Login" CHAR(16) NOT NULL DEFAULT '0',
|
|
||||||
"Logout" CHAR(16) NOT NULL DEFAULT '0',
|
|
||||||
PRIMARY KEY ("UserID")
|
|
||||||
)
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 2 # --------------------------
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE [GridUser_tmp] (
|
|
||||||
[UserID] VARCHAR(255) NOT NULL,
|
|
||||||
[HomeRegionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
|
||||||
[HomePosition] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
|
||||||
[HomeLookAt] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
|
||||||
[LastRegionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
|
||||||
[LastPosition] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
|
||||||
[LastLookAt] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
|
||||||
[Online] CHAR(5) NOT NULL DEFAULT 'false',
|
|
||||||
[Login] CHAR(16) NOT NULL DEFAULT '0',
|
|
||||||
[Logout] CHAR(16) NOT NULL DEFAULT '0',
|
|
||||||
|
|
||||||
PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[UserID] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.GridUser)
|
|
||||||
EXEC('INSERT INTO dbo.GridUser_tmp ([UserID]
|
|
||||||
,[HomeRegionID]
|
|
||||||
,[HomePosition]
|
|
||||||
,[HomeLookAt]
|
|
||||||
,[LastRegionID]
|
|
||||||
,[LastPosition]
|
|
||||||
,[LastLookAt]
|
|
||||||
,[Online]
|
|
||||||
,[Login]
|
|
||||||
,[Logout])
|
|
||||||
SELECT CONVERT(varchar(36), [HomeRegionID]), [HomePosition] ,[HomeLookAt] , CONVERT(varchar(36),[LastRegionID])
|
|
||||||
,[LastPosition]
|
|
||||||
,[LastLookAt]
|
|
||||||
,[Online]
|
|
||||||
,[Login]
|
|
||||||
,[Logout] FROM dbo.GridUser WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.GridUser
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.GridUser_tmp', N'GridUser', 'OBJECT'
|
|
|
@ -1,279 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE inventoryitems ADD inventoryGroupPermissions INTEGER NOT NULL default 0
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 3
|
|
||||||
|
|
||||||
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_inventoryfolders
|
|
||||||
(
|
|
||||||
folderID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
|
||||||
agentID uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
parentFolderID uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
folderName varchar(64) NULL DEFAULT (NULL),
|
|
||||||
type smallint NOT NULL DEFAULT ((0)),
|
|
||||||
version int NOT NULL DEFAULT ((0))
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.inventoryfolders)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version)
|
|
||||||
SELECT CONVERT(uniqueidentifier, folderID), CONVERT(uniqueidentifier, agentID), CONVERT(uniqueidentifier, parentFolderID), folderName, type, version FROM dbo.inventoryfolders WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.inventoryfolders
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_inventoryfolders', N'inventoryfolders', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE dbo.inventoryfolders ADD CONSTRAINT
|
|
||||||
PK__inventor__C2FABFB3173876EA PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
folderID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX owner ON dbo.inventoryfolders
|
|
||||||
(
|
|
||||||
agentID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX parent ON dbo.inventoryfolders
|
|
||||||
(
|
|
||||||
parentFolderID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 4
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_inventoryitems
|
|
||||||
(
|
|
||||||
inventoryID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
|
||||||
assetID uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
assetType int NULL DEFAULT (NULL),
|
|
||||||
parentFolderID uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
avatarID uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
inventoryName varchar(64) NULL DEFAULT (NULL),
|
|
||||||
inventoryDescription varchar(128) NULL DEFAULT (NULL),
|
|
||||||
inventoryNextPermissions int NULL DEFAULT (NULL),
|
|
||||||
inventoryCurrentPermissions int NULL DEFAULT (NULL),
|
|
||||||
invType int NULL DEFAULT (NULL),
|
|
||||||
creatorID uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
inventoryBasePermissions int NOT NULL DEFAULT ((0)),
|
|
||||||
inventoryEveryOnePermissions int NOT NULL DEFAULT ((0)),
|
|
||||||
salePrice int NULL DEFAULT (NULL),
|
|
||||||
saleType tinyint NULL DEFAULT (NULL),
|
|
||||||
creationDate int NULL DEFAULT (NULL),
|
|
||||||
groupID uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
groupOwned bit NULL DEFAULT (NULL),
|
|
||||||
flags int NULL DEFAULT (NULL),
|
|
||||||
inventoryGroupPermissions int NOT NULL DEFAULT ((0))
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.inventoryitems)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType, creationDate, groupID, groupOwned, flags, inventoryGroupPermissions)
|
|
||||||
SELECT CONVERT(uniqueidentifier, inventoryID), CONVERT(uniqueidentifier, assetID), assetType, CONVERT(uniqueidentifier, parentFolderID), CONVERT(uniqueidentifier, avatarID), inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType, CONVERT(uniqueidentifier, creatorID), inventoryBasePermissions, inventoryEveryOnePermissions, salePrice, saleType, creationDate, CONVERT(uniqueidentifier, groupID), groupOwned, flags, inventoryGroupPermissions FROM dbo.inventoryitems WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.inventoryitems
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_inventoryitems', N'inventoryitems', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE dbo.inventoryitems ADD CONSTRAINT
|
|
||||||
PK__inventor__C4B7BC2220C1E124 PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
inventoryID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX owner ON dbo.inventoryitems
|
|
||||||
(
|
|
||||||
avatarID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX folder ON dbo.inventoryitems
|
|
||||||
(
|
|
||||||
parentFolderID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 5
|
|
||||||
|
|
||||||
# It would be totally crazy to have to recreate the whole table just to change one column type,
|
|
||||||
# just because MS SQL treats each DEFAULT as a constraint object that must be dropped
|
|
||||||
# before anything can be done to the column. Since all defaults here are unnamed, there is
|
|
||||||
# no easy way to drop them! The hairy piece of code below removes all DEFAULT constraints
|
|
||||||
# from InventoryItems.
|
|
||||||
|
|
||||||
# SO: anything that's NULLable is by default NULL, so please don't declare DEFAULT(NULL),
|
|
||||||
# they do nothing but prevent changes to the columns. If you really
|
|
||||||
# need to have DEFAULTs or other constraints, give them names so they can be dropped when needed!
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
DECLARE @nm varchar(80);
|
|
||||||
DECLARE x CURSOR LOCAL FORWARD_ONLY READ_ONLY
|
|
||||||
FOR SELECT name FROM sys.default_constraints where parent_object_id = OBJECT_ID('inventoryitems');
|
|
||||||
OPEN x;
|
|
||||||
FETCH NEXT FROM x INTO @nm;
|
|
||||||
WHILE @@FETCH_STATUS = 0
|
|
||||||
BEGIN
|
|
||||||
EXEC('alter table inventoryitems drop ' + @nm);
|
|
||||||
FETCH NEXT FROM x INTO @nm;
|
|
||||||
END
|
|
||||||
CLOSE x
|
|
||||||
DEALLOCATE x
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
# all DEFAULTs dropped!
|
|
||||||
|
|
||||||
:GO
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
# Restoring defaults:
|
|
||||||
# NOTE: [inventoryID] does NOT need one: it's NOT NULL PK and a unique Guid must be provided every time anyway!
|
|
||||||
|
|
||||||
alter table inventoryitems
|
|
||||||
add constraint def_baseperm default 0 for inventoryBasePermissions
|
|
||||||
alter table inventoryitems
|
|
||||||
add constraint def_allperm default 0 for inventoryEveryOnePermissions
|
|
||||||
alter table inventoryitems
|
|
||||||
add constraint def_grpperm default 0 for inventoryGroupPermissions
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 7
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
# CreatorID goes back to VARCHAR(36) (???)
|
|
||||||
|
|
||||||
exec sp_rename 'inventoryitems.CreatorID', 'cr_old', 'COLUMN'
|
|
||||||
|
|
||||||
:GO
|
|
||||||
|
|
||||||
alter table inventoryitems
|
|
||||||
add creatorID varchar(36) NULL
|
|
||||||
|
|
||||||
:GO
|
|
||||||
|
|
||||||
update inventoryitems set creatorID = CONVERT(VARCHAR(36), cr_old)
|
|
||||||
|
|
||||||
alter table inventoryitems
|
|
||||||
drop column cr_old
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 8
|
|
||||||
|
|
||||||
ALTER TABLE inventoryitems
|
|
||||||
ADD CONSTRAINT DF_inventoryitems_creatorID
|
|
||||||
DEFAULT '00000000-0000-0000-0000-000000000000' FOR creatorID
|
|
||||||
|
|
||||||
:GO
|
|
||||||
|
|
||||||
:VERSION 9
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
# CreatorID goes up to VARCHAR(255)
|
|
||||||
|
|
||||||
exec sp_rename 'inventoryitems.CreatorID', 'cr_old', 'COLUMN'
|
|
||||||
|
|
||||||
:GO
|
|
||||||
|
|
||||||
alter table inventoryitems
|
|
||||||
add creatorID varchar(255) NULL
|
|
||||||
|
|
||||||
:GO
|
|
||||||
|
|
||||||
update inventoryitems set creatorID = cr_old
|
|
||||||
|
|
||||||
alter table inventoryitems
|
|
||||||
drop CONSTRAINT DF_inventoryitems_creatorID
|
|
||||||
:GO
|
|
||||||
|
|
||||||
alter table inventoryitems
|
|
||||||
drop column cr_old
|
|
||||||
:GO
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
ALTER TABLE inventoryitems
|
|
||||||
ADD CONSTRAINT DF_inventoryitems_creatorID
|
|
||||||
DEFAULT '00000000-0000-0000-0000-000000000000' FOR creatorID
|
|
||||||
|
|
||||||
:GO
|
|
|
@ -1,19 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE [logs] (
|
|
||||||
[logID] [int] NOT NULL,
|
|
||||||
[target] [varchar](36) default NULL,
|
|
||||||
[server] [varchar](64) default NULL,
|
|
||||||
[method] [varchar](64) default NULL,
|
|
||||||
[arguments] [varchar](255) default NULL,
|
|
||||||
[priority] [int] default NULL,
|
|
||||||
[message] [ntext],
|
|
||||||
PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[logID] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
|
@ -1,39 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE [Presence] (
|
|
||||||
[UserID] varchar(255) NOT NULL,
|
|
||||||
[RegionID] uniqueidentifier NOT NULL,
|
|
||||||
[SessionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
|
||||||
[SecureSessionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
|
||||||
|
|
||||||
)
|
|
||||||
ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX SessionID ON Presence(SessionID);
|
|
||||||
CREATE INDEX UserID ON Presence(UserID);
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE Presence ADD LastSeen DateTime;
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 3
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE INDEX RegionID ON Presence(RegionID);
|
|
||||||
|
|
||||||
COMMIT
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,55 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
CREATE TABLE [UserAccounts] (
|
|
||||||
[PrincipalID] uniqueidentifier NOT NULL,
|
|
||||||
[ScopeID] uniqueidentifier NOT NULL,
|
|
||||||
[FirstName] [varchar](64) NOT NULL,
|
|
||||||
[LastName] [varchar](64) NOT NULL,
|
|
||||||
[Email] [varchar](64) NULL,
|
|
||||||
[ServiceURLs] [text] NULL,
|
|
||||||
[Created] [int] default NULL,
|
|
||||||
|
|
||||||
PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
[PrincipalID] ASC
|
|
||||||
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND type in (N'U'))
|
|
||||||
INSERT INTO UserAccounts (PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created) SELECT [UUID] AS PrincipalID, '00000000-0000-0000-0000-000000000000' AS ScopeID,
|
|
||||||
username AS FirstName,
|
|
||||||
lastname AS LastName,
|
|
||||||
email as Email, (
|
|
||||||
'AssetServerURI=' +
|
|
||||||
userAssetURI + ' InventoryServerURI=' + userInventoryURI + ' GatewayURI= HomeURI=') AS ServiceURLs,
|
|
||||||
created as Created FROM users;
|
|
||||||
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 3
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX PrincipalID ON UserAccounts(PrincipalID);
|
|
||||||
CREATE INDEX Email ON UserAccounts(Email);
|
|
||||||
CREATE INDEX FirstName ON UserAccounts(FirstName);
|
|
||||||
CREATE INDEX LastName ON UserAccounts(LastName);
|
|
||||||
CREATE INDEX Name ON UserAccounts(FirstName,LastName);
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
:VERSION 4
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE UserAccounts ADD UserLevel integer NOT NULL DEFAULT 0;
|
|
||||||
ALTER TABLE UserAccounts ADD UserFlags integer NOT NULL DEFAULT 0;
|
|
||||||
ALTER TABLE UserAccounts ADD UserTitle varchar(64) NOT NULL DEFAULT '';
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
|
@ -1,421 +0,0 @@
|
||||||
:VERSION 1
|
|
||||||
|
|
||||||
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]
|
|
||||||
|
|
||||||
:VERSION 2
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 3
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 4
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 5
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE users add email varchar(250);
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 6
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_users
|
|
||||||
(
|
|
||||||
UUID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
|
||||||
username varchar(32) NOT NULL,
|
|
||||||
lastname varchar(32) NOT NULL,
|
|
||||||
passwordHash varchar(32) NOT NULL,
|
|
||||||
passwordSalt varchar(32) NOT NULL,
|
|
||||||
homeRegion bigint NULL DEFAULT (NULL),
|
|
||||||
homeLocationX float(53) NULL DEFAULT (NULL),
|
|
||||||
homeLocationY float(53) NULL DEFAULT (NULL),
|
|
||||||
homeLocationZ float(53) NULL DEFAULT (NULL),
|
|
||||||
homeLookAtX float(53) NULL DEFAULT (NULL),
|
|
||||||
homeLookAtY float(53) NULL DEFAULT (NULL),
|
|
||||||
homeLookAtZ float(53) NULL DEFAULT (NULL),
|
|
||||||
created int NOT NULL,
|
|
||||||
lastLogin int NOT NULL,
|
|
||||||
userInventoryURI varchar(255) NULL DEFAULT (NULL),
|
|
||||||
userAssetURI varchar(255) NULL DEFAULT (NULL),
|
|
||||||
profileCanDoMask int NULL DEFAULT (NULL),
|
|
||||||
profileWantDoMask int NULL DEFAULT (NULL),
|
|
||||||
profileAboutText ntext NULL,
|
|
||||||
profileFirstText ntext NULL,
|
|
||||||
profileImage uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
profileFirstImage uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
webLoginKey uniqueidentifier NULL DEFAULT (NULL),
|
|
||||||
homeRegionID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
|
||||||
userFlags int NOT NULL DEFAULT ((0)),
|
|
||||||
godLevel int NOT NULL DEFAULT ((0)),
|
|
||||||
customType varchar(32) NOT NULL DEFAULT (''),
|
|
||||||
partner uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
|
||||||
email varchar(250) NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
TEXTIMAGE_ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.users)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_users (UUID, username, lastname, passwordHash, passwordSalt, homeRegion, homeLocationX, homeLocationY, homeLocationZ, homeLookAtX, homeLookAtY, homeLookAtZ, created, lastLogin, userInventoryURI, userAssetURI, profileCanDoMask, profileWantDoMask, profileAboutText, profileFirstText, profileImage, profileFirstImage, webLoginKey, homeRegionID, userFlags, godLevel, customType, partner, email)
|
|
||||||
SELECT CONVERT(uniqueidentifier, UUID), username, lastname, passwordHash, passwordSalt, homeRegion, homeLocationX, homeLocationY, homeLocationZ, homeLookAtX, homeLookAtY, homeLookAtZ, created, lastLogin, userInventoryURI, userAssetURI, profileCanDoMask, profileWantDoMask, profileAboutText, profileFirstText, CONVERT(uniqueidentifier, profileImage), CONVERT(uniqueidentifier, profileFirstImage), CONVERT(uniqueidentifier, webLoginKey), CONVERT(uniqueidentifier, homeRegionID), userFlags, godLevel, customType, CONVERT(uniqueidentifier, partner), email FROM dbo.users WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.users
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_users', N'users', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE dbo.users ADD CONSTRAINT
|
|
||||||
PK__users__65A475E737A5467C PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
UUID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX usernames ON dbo.users
|
|
||||||
(
|
|
||||||
username,
|
|
||||||
lastname
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 7
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_agents
|
|
||||||
(
|
|
||||||
UUID uniqueidentifier NOT NULL,
|
|
||||||
sessionID uniqueidentifier NOT NULL,
|
|
||||||
secureSessionID uniqueidentifier NOT NULL,
|
|
||||||
agentIP varchar(16) NOT NULL,
|
|
||||||
agentPort int NOT NULL,
|
|
||||||
agentOnline tinyint NOT NULL,
|
|
||||||
loginTime int NOT NULL,
|
|
||||||
logoutTime int NOT NULL,
|
|
||||||
currentRegion uniqueidentifier NOT NULL,
|
|
||||||
currentHandle bigint NOT NULL,
|
|
||||||
currentPos varchar(64) NOT NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.agents)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos)
|
|
||||||
SELECT CONVERT(uniqueidentifier, UUID), CONVERT(uniqueidentifier, sessionID), CONVERT(uniqueidentifier, secureSessionID), agentIP, agentPort, agentOnline, loginTime, logoutTime, CONVERT(uniqueidentifier, currentRegion), currentHandle, currentPos FROM dbo.agents WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.agents
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_agents', N'agents', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE dbo.agents ADD CONSTRAINT
|
|
||||||
PK__agents__65A475E749C3F6B7 PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
UUID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX session ON dbo.agents
|
|
||||||
(
|
|
||||||
sessionID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX ssession ON dbo.agents
|
|
||||||
(
|
|
||||||
secureSessionID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 8
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_userfriends
|
|
||||||
(
|
|
||||||
ownerID uniqueidentifier NOT NULL,
|
|
||||||
friendID uniqueidentifier 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(uniqueidentifier, ownerID), CONVERT(uniqueidentifier, friendID), friendPerms, datetimestamp FROM dbo.userfriends WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.userfriends
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_userfriends', N'userfriends', 'OBJECT'
|
|
||||||
|
|
||||||
CREATE NONCLUSTERED INDEX IX_userfriends_ownerID ON dbo.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 dbo.userfriends
|
|
||||||
(
|
|
||||||
friendID
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 9
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_avatarappearance
|
|
||||||
(
|
|
||||||
Owner uniqueidentifier NOT NULL,
|
|
||||||
Serial int NOT NULL,
|
|
||||||
Visual_Params image NOT NULL,
|
|
||||||
Texture image NOT NULL,
|
|
||||||
Avatar_Height float(53) NOT NULL,
|
|
||||||
Body_Item uniqueidentifier NOT NULL,
|
|
||||||
Body_Asset uniqueidentifier NOT NULL,
|
|
||||||
Skin_Item uniqueidentifier NOT NULL,
|
|
||||||
Skin_Asset uniqueidentifier NOT NULL,
|
|
||||||
Hair_Item uniqueidentifier NOT NULL,
|
|
||||||
Hair_Asset uniqueidentifier NOT NULL,
|
|
||||||
Eyes_Item uniqueidentifier NOT NULL,
|
|
||||||
Eyes_Asset uniqueidentifier NOT NULL,
|
|
||||||
Shirt_Item uniqueidentifier NOT NULL,
|
|
||||||
Shirt_Asset uniqueidentifier NOT NULL,
|
|
||||||
Pants_Item uniqueidentifier NOT NULL,
|
|
||||||
Pants_Asset uniqueidentifier NOT NULL,
|
|
||||||
Shoes_Item uniqueidentifier NOT NULL,
|
|
||||||
Shoes_Asset uniqueidentifier NOT NULL,
|
|
||||||
Socks_Item uniqueidentifier NOT NULL,
|
|
||||||
Socks_Asset uniqueidentifier NOT NULL,
|
|
||||||
Jacket_Item uniqueidentifier NOT NULL,
|
|
||||||
Jacket_Asset uniqueidentifier NOT NULL,
|
|
||||||
Gloves_Item uniqueidentifier NOT NULL,
|
|
||||||
Gloves_Asset uniqueidentifier NOT NULL,
|
|
||||||
Undershirt_Item uniqueidentifier NOT NULL,
|
|
||||||
Undershirt_Asset uniqueidentifier NOT NULL,
|
|
||||||
Underpants_Item uniqueidentifier NOT NULL,
|
|
||||||
Underpants_Asset uniqueidentifier NOT NULL,
|
|
||||||
Skirt_Item uniqueidentifier NOT NULL,
|
|
||||||
Skirt_Asset uniqueidentifier NOT NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
TEXTIMAGE_ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.avatarappearance)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_avatarappearance (Owner, Serial, Visual_Params, Texture, Avatar_Height, Body_Item, Body_Asset, Skin_Item, Skin_Asset, Hair_Item, Hair_Asset, Eyes_Item, Eyes_Asset, Shirt_Item, Shirt_Asset, Pants_Item, Pants_Asset, Shoes_Item, Shoes_Asset, Socks_Item, Socks_Asset, Jacket_Item, Jacket_Asset, Gloves_Item, Gloves_Asset, Undershirt_Item, Undershirt_Asset, Underpants_Item, Underpants_Asset, Skirt_Item, Skirt_Asset)
|
|
||||||
SELECT CONVERT(uniqueidentifier, Owner), Serial, Visual_Params, Texture, Avatar_Height, CONVERT(uniqueidentifier, Body_Item), CONVERT(uniqueidentifier, Body_Asset), CONVERT(uniqueidentifier, Skin_Item), CONVERT(uniqueidentifier, Skin_Asset), CONVERT(uniqueidentifier, Hair_Item), CONVERT(uniqueidentifier, Hair_Asset), CONVERT(uniqueidentifier, Eyes_Item), CONVERT(uniqueidentifier, Eyes_Asset), CONVERT(uniqueidentifier, Shirt_Item), CONVERT(uniqueidentifier, Shirt_Asset), CONVERT(uniqueidentifier, Pants_Item), CONVERT(uniqueidentifier, Pants_Asset), CONVERT(uniqueidentifier, Shoes_Item), CONVERT(uniqueidentifier, Shoes_Asset), CONVERT(uniqueidentifier, Socks_Item), CONVERT(uniqueidentifier, Socks_Asset), CONVERT(uniqueidentifier, Jacket_Item), CONVERT(uniqueidentifier, Jacket_Asset), CONVERT(uniqueidentifier, Gloves_Item), CONVERT(uniqueidentifier, Gloves_Asset), CONVERT(uniqueidentifier, Undershirt_Item), CONVERT(uniqueidentifier, Undershirt_Asset), CONVERT(uniqueidentifier, Underpants_Item), CONVERT(uniqueidentifier, Underpants_Asset), CONVERT(uniqueidentifier, Skirt_Item), CONVERT(uniqueidentifier, Skirt_Asset) FROM dbo.avatarappearance WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.avatarappearance
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_avatarappearance', N'avatarappearance', 'OBJECT'
|
|
||||||
|
|
||||||
ALTER TABLE dbo.avatarappearance ADD CONSTRAINT
|
|
||||||
PK__avatarap__7DD115CC4E88ABD4 PRIMARY KEY CLUSTERED
|
|
||||||
(
|
|
||||||
Owner
|
|
||||||
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
|
||||||
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 10
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
CREATE TABLE dbo.Tmp_avatarattachments
|
|
||||||
(
|
|
||||||
UUID uniqueidentifier NOT NULL,
|
|
||||||
attachpoint int NOT NULL,
|
|
||||||
item uniqueidentifier NOT NULL,
|
|
||||||
asset uniqueidentifier NOT NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
|
|
||||||
IF EXISTS(SELECT * FROM dbo.avatarattachments)
|
|
||||||
EXEC('INSERT INTO dbo.Tmp_avatarattachments (UUID, attachpoint, item, asset)
|
|
||||||
SELECT CONVERT(uniqueidentifier, UUID), attachpoint, CONVERT(uniqueidentifier, item), CONVERT(uniqueidentifier, asset) FROM dbo.avatarattachments WITH (HOLDLOCK TABLOCKX)')
|
|
||||||
|
|
||||||
DROP TABLE dbo.avatarattachments
|
|
||||||
|
|
||||||
EXECUTE sp_rename N'dbo.Tmp_avatarattachments', N'avatarattachments', 'OBJECT'
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
:VERSION 11
|
|
||||||
|
|
||||||
BEGIN TRANSACTION
|
|
||||||
|
|
||||||
ALTER TABLE users ADD scopeID uniqueidentifier not null default '00000000-0000-0000-0000-000000000000'
|
|
||||||
|
|
||||||
COMMIT
|
|
|
@ -40,9 +40,6 @@ using log4net;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using OpenSim.Data.MySQL;
|
using OpenSim.Data.MySQL;
|
||||||
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using OpenSim.Data.MSSQL;
|
|
||||||
|
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
using OpenSim.Data.SQLite;
|
using OpenSim.Data.SQLite;
|
||||||
|
|
||||||
|
@ -58,11 +55,6 @@ namespace OpenSim.Data.Tests
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestFixture(Description = "Asset store tests (MS SQL Server)")]
|
|
||||||
public class MSSQLAssetTests : AssetTests<SqlConnection, MSSQLAssetData>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData>
|
public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData>
|
||||||
where TConn : DbConnection, new()
|
where TConn : DbConnection, new()
|
||||||
where TAssetData : AssetDataBase, new()
|
where TAssetData : AssetDataBase, new()
|
||||||
|
|
|
@ -41,9 +41,6 @@ using System.Data.Common;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using OpenSim.Data.MySQL;
|
using OpenSim.Data.MySQL;
|
||||||
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using OpenSim.Data.MSSQL;
|
|
||||||
|
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
using OpenSim.Data.SQLite;
|
using OpenSim.Data.SQLite;
|
||||||
|
|
||||||
|
@ -59,11 +56,6 @@ namespace OpenSim.Data.Tests
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestFixture(Description = "Estate store tests (MS SQL Server)")]
|
|
||||||
public class MSSQLEstateTests : EstateTests<SqlConnection, MSSQLEstateStore>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore>
|
public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore>
|
||||||
where TConn : DbConnection, new()
|
where TConn : DbConnection, new()
|
||||||
where TEstateStore : class, IEstateDataStore, new()
|
where TEstateStore : class, IEstateDataStore, new()
|
||||||
|
|
|
@ -39,9 +39,6 @@ using System.Data.Common;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using OpenSim.Data.MySQL;
|
using OpenSim.Data.MySQL;
|
||||||
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using OpenSim.Data.MSSQL;
|
|
||||||
|
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
using OpenSim.Data.SQLite;
|
using OpenSim.Data.SQLite;
|
||||||
|
|
||||||
|
@ -57,11 +54,6 @@ namespace OpenSim.Data.Tests
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestFixture(Description = "Inventory store tests (MS SQL Server)")]
|
|
||||||
public class MSSQLInventoryTests : InventoryTests<SqlConnection, MSSQLInventoryData>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore>
|
public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore>
|
||||||
where TConn : DbConnection, new()
|
where TConn : DbConnection, new()
|
||||||
where TInvStore : class, IInventoryDataPlugin, new()
|
where TInvStore : class, IInventoryDataPlugin, new()
|
||||||
|
|
|
@ -44,9 +44,6 @@ using System.Data.Common;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using OpenSim.Data.MySQL;
|
using OpenSim.Data.MySQL;
|
||||||
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using OpenSim.Data.MSSQL;
|
|
||||||
|
|
||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
using OpenSim.Data.SQLite;
|
using OpenSim.Data.SQLite;
|
||||||
|
|
||||||
|
@ -62,11 +59,6 @@ namespace OpenSim.Data.Tests
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestFixture(Description = "Region store tests (MS SQL Server)")]
|
|
||||||
public class MSSQLRegionTests : RegionTests<SqlConnection, MSSQLSimulationData>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore>
|
public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore>
|
||||||
where TConn : DbConnection, new()
|
where TConn : DbConnection, new()
|
||||||
where TRegStore : class, ISimulationDataStore, new()
|
where TRegStore : class, ISimulationDataStore, new()
|
||||||
|
|
35
prebuild.xml
35
prebuild.xml
|
@ -2030,41 +2030,6 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
<Project frameworkVersion="v4_0" name="OpenSim.Data.MSSQL" path="OpenSim/Data/MSSQL" type="Library">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../bin/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Core"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Drawing"/>
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Data"/>
|
|
||||||
<Reference name="OpenSim.Region.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
|
|
||||||
<Reference name="OpenMetaverse" path="../../../bin/"/>
|
|
||||||
<Reference name="log4net" path="../../../bin/"/>
|
|
||||||
<Reference name="Mono.Addins" path="../../../bin/"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="true"/>
|
|
||||||
<Match buildAction="EmbeddedResource" path="Resources" pattern="*.sql"/>
|
|
||||||
<Match buildAction="EmbeddedResource" path="Resources" pattern="*.migrations"/>
|
|
||||||
<Match buildAction="EmbeddedResource" path="Resources" pattern="*.addin.xml" recurse="true"/>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v4_0" name="OpenSim.Data.PGSQL" path="OpenSim/Data/PGSQL" type="Library">
|
<Project frameworkVersion="v4_0" name="OpenSim.Data.PGSQL" path="OpenSim/Data/PGSQL" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
|
Loading…
Reference in New Issue