Apply patch from bug #1609 -- Documentation for Data/MSSQL. Thanks kerunix_Flan!

0.6.0-stable
Jeff Ames 2008-06-26 20:25:57 +00:00
parent d96caaa14e
commit f8ccf00f1c
6 changed files with 446 additions and 29 deletions

View File

@ -36,6 +36,9 @@ using OpenSim.Framework;
namespace OpenSim.Data.MSSQL namespace OpenSim.Data.MSSQL
{ {
/// <summary>
/// A MSSQL Interface for the Asset server
/// </summary>
internal class MSSQLAssetData : AssetDataBase internal class MSSQLAssetData : AssetDataBase
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -44,6 +47,13 @@ namespace OpenSim.Data.MSSQL
#region IAssetProvider Members #region IAssetProvider Members
/// <summary>
/// Migration method
/// <list type="bullet">
/// <item>Execute "CreateAssetsTable.sql" if tableName == null</item>
/// </list>
/// </summary>
/// <param name="tableName">Name of table</param>
private void UpgradeAssetsTable(string tableName) private void UpgradeAssetsTable(string tableName)
{ {
// null as the version, indicates that the table didn't exist // null as the version, indicates that the table didn't exist
@ -68,6 +78,11 @@ namespace OpenSim.Data.MSSQL
UpgradeAssetsTable(tableList["assets"]); UpgradeAssetsTable(tableList["assets"]);
} }
/// <summary>
/// Fetch Asset from database
/// </summary>
/// <param name="assetID">the asset UUID</param>
/// <returns></returns>
override public AssetBase FetchAsset(LLUUID assetID) override public AssetBase FetchAsset(LLUUID assetID)
{ {
AssetBase asset = null; AssetBase asset = null;
@ -85,6 +100,10 @@ namespace OpenSim.Data.MSSQL
return asset; return asset;
} }
/// <summary>
/// Create asset in database
/// </summary>
/// <param name="asset">the asset</param>
override public void CreateAsset(AssetBase asset) override public void CreateAsset(AssetBase asset)
{ {
if (ExistsAsset((LLUUID) asset.FullID)) if (ExistsAsset((LLUUID) asset.FullID))
@ -130,7 +149,10 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Update asset in database
/// </summary>
/// <param name="asset">the asset</param>
override public void UpdateAsset(AssetBase asset) override public void UpdateAsset(AssetBase asset)
{ {
SqlCommand command = new SqlCommand("UPDATE assets set id = @id, " + SqlCommand command = new SqlCommand("UPDATE assets set id = @id, " +
@ -171,6 +193,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Check if asset exist in database
/// </summary>
/// <param name="uuid"></param>
/// <returns>true if exist.</returns>
override public bool ExistsAsset(LLUUID uuid) override public bool ExistsAsset(LLUUID uuid)
{ {
if (FetchAsset(uuid) != null) if (FetchAsset(uuid) != null)
@ -191,13 +218,23 @@ namespace OpenSim.Data.MSSQL
#region IPlugin Members #region IPlugin Members
/// <summary>
/// <para>Initialises asset interface</para>
/// <para>
/// TODO: this would allow you to pass in connnect info as
/// a string instead of file, if someone writes the support
/// </para>
/// </summary>
/// <param name="connect">connect string</param>
override public void Initialise(string connect) override public void Initialise(string connect)
{ {
// TODO: this would allow you to pass in connnect info as
// a string instead of file, if someone writes the support
Initialise(); Initialise();
} }
/// <summary>
/// Initialises asset interface
/// </summary>
/// <remarks>it use mssql_connection.ini</remarks>
override public void Initialise() override public void Initialise()
{ {
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini"); IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
@ -214,12 +251,17 @@ namespace OpenSim.Data.MSSQL
TestTables(); TestTables();
} }
/// <summary>
/// Database provider version.
/// </summary>
override public string Version override public string Version
{ {
// get { return database.getVersion(); }
get { return database.getVersion(); } get { return database.getVersion(); }
} }
/// <summary>
/// The name of this DB provider.
/// </summary>
override public string Name override public string Name
{ {
get { return "MSSQL Asset storage engine"; } get { return "MSSQL Asset storage engine"; }

View File

@ -39,6 +39,9 @@ using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Data.MSSQL namespace OpenSim.Data.MSSQL
{ {
/// <summary>
/// A MSSQL Interface for the Region Server.
/// </summary>
public class MSSQLDataStore : IRegionDataStore public class MSSQLDataStore : IRegionDataStore
{ {
// private static FileSystemDataStore Instance = new FileSystemDataStore(); // private static FileSystemDataStore Instance = new FileSystemDataStore();
@ -67,7 +70,7 @@ namespace OpenSim.Data.MSSQL
private DataTable m_landTable; private DataTable m_landTable;
private DataTable m_landAccessListTable; private DataTable m_landAccessListTable;
// Temporary attribute while this is experimental /// <summary>Temporary attribute while this is experimental</summary>
private bool persistPrimInventories; private bool persistPrimInventories;
/*********************************************************************** /***********************************************************************
@ -76,7 +79,11 @@ namespace OpenSim.Data.MSSQL
* *
**********************************************************************/ **********************************************************************/
// see IRegionDataStore /// <summary>
/// see IRegionDataStore
/// </summary>
/// <param name="connectionString"></param>
/// <param name="persistPrimInventories"></param>
public void Initialise(string connectionString, bool persistPrimInventories) public void Initialise(string connectionString, bool persistPrimInventories)
{ {
// Instance.Initialise("", true); // Instance.Initialise("", true);
@ -144,6 +151,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <param name="regionUUID"></param>
public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID)
{ {
// Instance.StoreObject(obj, regionUUID); // Instance.StoreObject(obj, regionUUID);
@ -169,6 +181,11 @@ namespace OpenSim.Data.MSSQL
Commit(); Commit();
} }
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
/// <param name="regionUUID"></param>
public void RemoveObject(LLUUID obj, LLUUID regionUUID) public void RemoveObject(LLUUID obj, LLUUID regionUUID)
{ {
// Instance.RemoveObject(obj, regionUUID); // Instance.RemoveObject(obj, regionUUID);
@ -209,6 +226,7 @@ namespace OpenSim.Data.MSSQL
/// Remove all persisted items of the given prim. /// Remove all persisted items of the given prim.
/// The caller must acquire the necessrary synchronization locks and commit or rollback changes. /// The caller must acquire the necessrary synchronization locks and commit or rollback changes.
/// </summary> /// </summary>
/// <param name="uuid">The item UUID</param>
private void RemoveItems(LLUUID uuid) private void RemoveItems(LLUUID uuid)
{ {
String sql = String.Format("primID = '{0}'", uuid); String sql = String.Format("primID = '{0}'", uuid);
@ -223,6 +241,7 @@ namespace OpenSim.Data.MSSQL
/// <summary> /// <summary>
/// Load persisted objects from region storage. /// Load persisted objects from region storage.
/// </summary> /// </summary>
/// <param name="regionUUID">The region UUID</param>
public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID) public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID)
{ {
// return Instance.LoadObjects(regionUUID); // return Instance.LoadObjects(regionUUID);
@ -341,6 +360,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Store a terrain revision in region storage.
/// </summary>
/// <param name="ter">HeightField data</param>
/// <param name="regionID">Region UUID</param>
public void StoreTerrain(double[,] ter, LLUUID regionID) public void StoreTerrain(double[,] ter, LLUUID regionID)
{ {
int revision = Util.UnixTimeSinceEpoch(); int revision = Util.UnixTimeSinceEpoch();
@ -361,6 +385,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Load the latest terrain revision from region storage.
/// </summary>
/// <param name="regionID">The Region UUID</param>
/// <returns>HeightField Data</returns>
public double[,] LoadTerrain(LLUUID regionID) public double[,] LoadTerrain(LLUUID regionID)
{ {
double[,] terret = new double[256, 256]; double[,] terret = new double[256, 256];
@ -407,6 +436,10 @@ namespace OpenSim.Data.MSSQL
return terret; return terret;
} }
/// <summary>
///
/// </summary>
/// <param name="globalID"></param>
public void RemoveLandObject(LLUUID globalID) public void RemoveLandObject(LLUUID globalID)
{ {
// Instance.RemoveLandObject(globalID); // Instance.RemoveLandObject(globalID);
@ -429,6 +462,10 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
///
/// </summary>
/// <param name="parcel"></param>
public void StoreLandObject(ILandObject parcel) public void StoreLandObject(ILandObject parcel)
{ {
lock (m_dataSet) lock (m_dataSet)
@ -467,6 +504,11 @@ namespace OpenSim.Data.MSSQL
Commit(); Commit();
} }
/// <summary>
///
/// </summary>
/// <param name="regionUUID">The region UUID</param>
/// <returns></returns>
public List<LandData> LoadLandObjects(LLUUID regionUUID) public List<LandData> LoadLandObjects(LLUUID regionUUID)
{ {
List<LandData> landDataForRegion = new List<LandData>(); List<LandData> landDataForRegion = new List<LandData>();
@ -492,22 +534,38 @@ namespace OpenSim.Data.MSSQL
return landDataForRegion; return landDataForRegion;
} }
/// <summary>
/// Load (fetch?) the region banlist
/// </summary>
/// <param name="regionUUID">the region UUID</param>
/// <returns>the banlist list</returns>
public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID) public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID)
{ {
List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>(); List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>();
return regionbanlist; return regionbanlist;
} }
/// <summary>
/// STUB, add an item into region banlist
/// </summary>
/// <param name="item">the item</param>
public void AddToRegionBanlist(RegionBanListItem item) public void AddToRegionBanlist(RegionBanListItem item)
{ {
} }
/// <summary>
/// STUB, remove an item from region banlist
/// </summary>
/// <param name="item"></param>
public void RemoveFromRegionBanlist(RegionBanListItem item) public void RemoveFromRegionBanlist(RegionBanListItem item)
{ {
} }
/// <summary>
/// Commit
/// </summary>
public void Commit() public void Commit()
{ {
if (m_connection.State != ConnectionState.Open) if (m_connection.State != ConnectionState.Open)
@ -535,6 +593,9 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// See <see cref="Commit"/>
/// </summary>
public void Shutdown() public void Shutdown()
{ {
Commit(); Commit();
@ -548,6 +609,13 @@ namespace OpenSim.Data.MSSQL
* *
**********************************************************************/ **********************************************************************/
/// <summary>
///
/// </summary>
/// <param name="dt"></param>
/// <param name="name"></param>
/// <param name="type"></param>
/// <returns></returns>
private static DataColumn createCol(DataTable dt, string name, Type type) private static DataColumn createCol(DataTable dt, string name, Type type)
{ {
DataColumn col = new DataColumn(name, type); DataColumn col = new DataColumn(name, type);
@ -555,6 +623,10 @@ namespace OpenSim.Data.MSSQL
return col; return col;
} }
/// <summary>
/// Create the "terrain" table
/// </summary>
/// <returns>the datatable</returns>
private static DataTable createTerrainTable() private static DataTable createTerrainTable()
{ {
DataTable terrain = new DataTable("terrain"); DataTable terrain = new DataTable("terrain");
@ -566,6 +638,10 @@ namespace OpenSim.Data.MSSQL
return terrain; return terrain;
} }
/// <summary>
/// Create the "prims" table
/// </summary>
/// <returns>the datatable</returns>
private static DataTable createPrimTable() private static DataTable createPrimTable()
{ {
DataTable prims = new DataTable("prims"); DataTable prims = new DataTable("prims");
@ -630,6 +706,10 @@ namespace OpenSim.Data.MSSQL
return prims; return prims;
} }
/// <summary>
/// Create the "land" table
/// </summary>
/// <returns>the datatable</returns>
private static DataTable createLandTable() private static DataTable createLandTable()
{ {
DataTable land = new DataTable("land"); DataTable land = new DataTable("land");
@ -673,6 +753,10 @@ namespace OpenSim.Data.MSSQL
return land; return land;
} }
/// <summary>
/// Create "landacceslist" table
/// </summary>
/// <returns>the datatable</returns>
private static DataTable createLandAccessListTable() private static DataTable createLandAccessListTable()
{ {
DataTable landaccess = new DataTable("landaccesslist"); DataTable landaccess = new DataTable("landaccesslist");
@ -683,6 +767,10 @@ namespace OpenSim.Data.MSSQL
return landaccess; return landaccess;
} }
/// <summary>
/// Create "primsshapes" table
/// </summary>
/// <returns>the datatable</returns>
private static DataTable createShapeTable() private static DataTable createShapeTable()
{ {
DataTable shapes = new DataTable("primshapes"); DataTable shapes = new DataTable("primshapes");
@ -725,6 +813,10 @@ namespace OpenSim.Data.MSSQL
return shapes; return shapes;
} }
/// <summary>
/// Create "primitems" table
/// </summary>
/// <returns>the datatable</returns>
private static DataTable createItemsTable() private static DataTable createItemsTable()
{ {
DataTable items = new DataTable("primitems"); DataTable items = new DataTable("primitems");
@ -766,6 +858,11 @@ namespace OpenSim.Data.MSSQL
* *
**********************************************************************/ **********************************************************************/
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <returns></returns>
private SceneObjectPart buildPrim(DataRow row) private SceneObjectPart buildPrim(DataRow row)
{ {
SceneObjectPart prim = new SceneObjectPart(); SceneObjectPart prim = new SceneObjectPart();
@ -891,6 +988,11 @@ namespace OpenSim.Data.MSSQL
return taskItem; return taskItem;
} }
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <returns></returns>
private static LandData buildLandData(DataRow row) private static LandData buildLandData(DataRow row)
{ {
LandData newData = new LandData(); LandData newData = new LandData();
@ -936,6 +1038,11 @@ namespace OpenSim.Data.MSSQL
return newData; return newData;
} }
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <returns></returns>
private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row)
{ {
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
@ -945,6 +1052,11 @@ namespace OpenSim.Data.MSSQL
return entry; return entry;
} }
/// <summary>
/// Serialize terrain HeightField
/// </summary>
/// <param name="val">the terrain heightfield</param>
/// <returns></returns>
private static Array serializeTerrain(double[,] val) private static Array serializeTerrain(double[,] val)
{ {
MemoryStream str = new MemoryStream(65536 * sizeof(double)); MemoryStream str = new MemoryStream(65536 * sizeof(double));
@ -958,6 +1070,13 @@ namespace OpenSim.Data.MSSQL
return str.ToArray(); return str.ToArray();
} }
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <param name="prim"></param>
/// <param name="sceneGroupID"></param>
/// <param name="regionUUID"></param>
private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID)
{ {
row["UUID"] = prim.UUID; row["UUID"] = prim.UUID;
@ -1034,6 +1153,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <param name="taskItem"></param>
private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) private static void fillItemRow(DataRow row, TaskInventoryItem taskItem)
{ {
row["itemID"] = taskItem.ItemID; row["itemID"] = taskItem.ItemID;
@ -1059,6 +1183,12 @@ namespace OpenSim.Data.MSSQL
// row["flags"] = taskItem.Flags; // row["flags"] = taskItem.Flags;
} }
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <param name="land"></param>
/// <param name="regionUUID"></param>
private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID)
{ {
row["UUID"] = land.globalID.UUID; row["UUID"] = land.globalID.UUID;
@ -1097,6 +1227,12 @@ namespace OpenSim.Data.MSSQL
row["UserLookAtZ"] = land.userLookAt.Z; row["UserLookAtZ"] = land.userLookAt.Z;
} }
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <param name="entry"></param>
/// <param name="parcelID"></param>
private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID)
{ {
row["LandUUID"] = parcelID.UUID; row["LandUUID"] = parcelID.UUID;
@ -1104,6 +1240,11 @@ namespace OpenSim.Data.MSSQL
row["Flags"] = entry.Flags; row["Flags"] = entry.Flags;
} }
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <returns></returns>
private static PrimitiveBaseShape buildShape(DataRow row) private static PrimitiveBaseShape buildShape(DataRow row)
{ {
PrimitiveBaseShape s = new PrimitiveBaseShape(); PrimitiveBaseShape s = new PrimitiveBaseShape();
@ -1143,6 +1284,11 @@ namespace OpenSim.Data.MSSQL
return s; return s;
} }
/// <summary>
///
/// </summary>
/// <param name="row"></param>
/// <param name="prim"></param>
private static void fillShapeRow(DataRow row, SceneObjectPart prim) private static void fillShapeRow(DataRow row, SceneObjectPart prim)
{ {
PrimitiveBaseShape s = prim.Shape; PrimitiveBaseShape s = prim.Shape;
@ -1179,6 +1325,12 @@ namespace OpenSim.Data.MSSQL
row["ExtraParams"] = s.ExtraParams; row["ExtraParams"] = s.ExtraParams;
} }
/// <summary>
///
/// </summary>
/// <param name="prim"></param>
/// <param name="sceneGroupID"></param>
/// <param name="regionUUID"></param>
private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID)
{ {
DataTable prims = m_dataSet.Tables["prims"]; DataTable prims = m_dataSet.Tables["prims"];
@ -1209,7 +1361,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
// see IRegionDatastore /// <summary>
/// See <see cref="IRegionDatastore"/>
/// </summary>
/// <param name="primID"></param>
/// <param name="items"></param>
public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items) public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items)
{ {
if (!persistPrimInventories) if (!persistPrimInventories)
@ -1250,6 +1406,12 @@ namespace OpenSim.Data.MSSQL
* *
**********************************************************************/ **********************************************************************/
/// <summary>
/// Create an Insert command
/// </summary>
/// <param name="table"></param>
/// <param name="dt"></param>
/// <returns>the sql command</returns>
private static SqlCommand createInsertCommand(string table, DataTable dt) private static SqlCommand createInsertCommand(string table, DataTable dt)
{ {
/** /**
@ -1285,6 +1447,13 @@ namespace OpenSim.Data.MSSQL
return cmd; return cmd;
} }
/// <summary>
/// Create an update command
/// </summary>
/// <param name="table"></param>
/// <param name="pk"></param>
/// <param name="dt"></param>
/// <returns>the sql command</returns>
private static SqlCommand createUpdateCommand(string table, string pk, DataTable dt) private static SqlCommand createUpdateCommand(string table, string pk, DataTable dt)
{ {
string sql = "update " + table + " set "; string sql = "update " + table + " set ";
@ -1312,6 +1481,11 @@ namespace OpenSim.Data.MSSQL
return cmd; return cmd;
} }
/// <summary>
///
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
private static string defineTable(DataTable dt) private static string defineTable(DataTable dt)
{ {
string sql = "create table " + dt.TableName + "("; string sql = "create table " + dt.TableName + "(";
@ -1345,14 +1519,18 @@ namespace OpenSim.Data.MSSQL
**********************************************************************/ **********************************************************************/
///<summary> ///<summary>
/// <para>
/// This is a convenience function that collapses 5 repetitive /// This is a convenience function that collapses 5 repetitive
/// lines for defining SqlParameters to 2 parameters: /// lines for defining SqlParameters to 2 parameters:
/// column name and database type. /// column name and database type.
/// </para>
/// ///
/// <para>
/// It assumes certain conventions like :param as the param /// It assumes certain conventions like :param as the param
/// name to replace in parametrized queries, and that source /// name to replace in parametrized queries, and that source
/// version is always current version, both of which are fine /// version is always current version, both of which are fine
/// for us. /// for us.
/// </para>
///</summary> ///</summary>
///<returns>a built Sql parameter</returns> ///<returns>a built Sql parameter</returns>
private static SqlParameter createSqlParameter(string name, Type type) private static SqlParameter createSqlParameter(string name, Type type)
@ -1365,6 +1543,11 @@ namespace OpenSim.Data.MSSQL
return param; return param;
} }
/// <summary>
///
/// </summary>
/// <param name="da"></param>
/// <param name="conn"></param>
private void setupPrimCommands(SqlDataAdapter da, SqlConnection conn) private void setupPrimCommands(SqlDataAdapter da, SqlConnection conn)
{ {
da.InsertCommand = createInsertCommand("prims", m_dataSet.Tables["prims"]); da.InsertCommand = createInsertCommand("prims", m_dataSet.Tables["prims"]);
@ -1379,6 +1562,11 @@ namespace OpenSim.Data.MSSQL
da.DeleteCommand = delete; da.DeleteCommand = delete;
} }
/// <summary>
///
/// </summary>
/// <param name="da"></param>
/// <param name="conn"></param>
private void SetupItemsCommands(SqlDataAdapter da, SqlConnection conn) private void SetupItemsCommands(SqlDataAdapter da, SqlConnection conn)
{ {
da.InsertCommand = createInsertCommand("primitems", m_itemsTable); da.InsertCommand = createInsertCommand("primitems", m_itemsTable);
@ -1393,12 +1581,22 @@ namespace OpenSim.Data.MSSQL
da.DeleteCommand = delete; da.DeleteCommand = delete;
} }
/// <summary>
///
/// </summary>
/// <param name="da"></param>
/// <param name="conn"></param>
private void setupTerrainCommands(SqlDataAdapter da, SqlConnection conn) private void setupTerrainCommands(SqlDataAdapter da, SqlConnection conn)
{ {
da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]);
da.InsertCommand.Connection = conn; da.InsertCommand.Connection = conn;
} }
/// <summary>
///
/// </summary>
/// <param name="da"></param>
/// <param name="conn"></param>
private void setupLandCommands(SqlDataAdapter da, SqlConnection conn) private void setupLandCommands(SqlDataAdapter da, SqlConnection conn)
{ {
da.InsertCommand = createInsertCommand("land", m_dataSet.Tables["land"]); da.InsertCommand = createInsertCommand("land", m_dataSet.Tables["land"]);
@ -1408,12 +1606,22 @@ namespace OpenSim.Data.MSSQL
da.UpdateCommand.Connection = conn; da.UpdateCommand.Connection = conn;
} }
/// <summary>
///
/// </summary>
/// <param name="da"></param>
/// <param name="conn"></param>
private void setupLandAccessCommands(SqlDataAdapter da, SqlConnection conn) private void setupLandAccessCommands(SqlDataAdapter da, SqlConnection conn)
{ {
da.InsertCommand = createInsertCommand("landaccesslist", m_dataSet.Tables["landaccesslist"]); da.InsertCommand = createInsertCommand("landaccesslist", m_dataSet.Tables["landaccesslist"]);
da.InsertCommand.Connection = conn; da.InsertCommand.Connection = conn;
} }
/// <summary>
///
/// </summary>
/// <param name="da"></param>
/// <param name="conn"></param>
private void setupShapeCommands(SqlDataAdapter da, SqlConnection conn) private void setupShapeCommands(SqlDataAdapter da, SqlConnection conn)
{ {
da.InsertCommand = createInsertCommand("primshapes", m_dataSet.Tables["primshapes"]); da.InsertCommand = createInsertCommand("primshapes", m_dataSet.Tables["primshapes"]);
@ -1428,6 +1636,10 @@ namespace OpenSim.Data.MSSQL
da.DeleteCommand = delete; da.DeleteCommand = delete;
} }
/// <summary>
///
/// </summary>
/// <param name="conn"></param>
private static void InitDB(SqlConnection conn) private static void InitDB(SqlConnection conn)
{ {
string createPrims = defineTable(createPrimTable()); string createPrims = defineTable(createPrimTable());
@ -1501,6 +1713,11 @@ namespace OpenSim.Data.MSSQL
conn.Close(); conn.Close();
} }
/// <summary>
///
/// </summary>
/// <param name="conn"></param>
/// <returns></returns>
private bool TestTables(SqlConnection conn) private bool TestTables(SqlConnection conn)
{ {
SqlCommand primSelectCmd = new SqlCommand(m_primSelect, conn); SqlCommand primSelectCmd = new SqlCommand(m_primSelect, conn);
@ -1601,6 +1818,11 @@ namespace OpenSim.Data.MSSQL
* *
**********************************************************************/ **********************************************************************/
/// <summary>
/// Type conversion function
/// </summary>
/// <param name="type">a Type</param>
/// <returns>a DbType</returns>
private static DbType dbtypeFromType(Type type) private static DbType dbtypeFromType(Type type)
{ {
if (type == typeof(String)) if (type == typeof(String))

View File

@ -37,7 +37,7 @@ using log4net;
namespace OpenSim.Data.MSSQL namespace OpenSim.Data.MSSQL
{ {
/// <summary> /// <summary>
/// A grid data interface for Microsoft SQL Server /// A grid data interface for MSSQL Server
/// </summary> /// </summary>
public class MSSQLGridData : GridDataBase public class MSSQLGridData : GridDataBase
{ {
@ -53,6 +53,8 @@ namespace OpenSim.Data.MSSQL
/// <summary> /// <summary>
/// Initialises the Grid Interface /// Initialises the Grid Interface
/// </summary> /// </summary>
/// <param name="connect">connect string</param>
/// <remarks>use mssql_connection.ini</remarks>
override public void Initialise(string connect) override public void Initialise(string connect)
{ {
// TODO: make the connect string actually do something // TODO: make the connect string actually do something
@ -77,6 +79,9 @@ namespace OpenSim.Data.MSSQL
TestTables(); TestTables();
} }
/// <summary>
///
/// </summary>
private void TestTables() private void TestTables()
{ {
IDbCommand cmd = database.Query("SELECT TOP 1 * FROM "+m_regionsTableName, new Dictionary<string, string>()); IDbCommand cmd = database.Query("SELECT TOP 1 * FROM "+m_regionsTableName, new Dictionary<string, string>());
@ -102,7 +107,7 @@ namespace OpenSim.Data.MSSQL
} }
/// <summary> /// <summary>
/// Returns the storage system name /// The name of this DB provider.
/// </summary> /// </summary>
/// <returns>A string containing the storage system name</returns> /// <returns>A string containing the storage system name</returns>
override public string getName() override public string getName()
@ -111,7 +116,7 @@ namespace OpenSim.Data.MSSQL
} }
/// <summary> /// <summary>
/// Returns the storage system version /// Database provider version.
/// </summary> /// </summary>
/// <returns>A string containing the storage system version</returns> /// <returns>A string containing the storage system version</returns>
override public string getVersion() override public string getVersion()
@ -120,13 +125,15 @@ namespace OpenSim.Data.MSSQL
} }
/// <summary> /// <summary>
/// NOT IMPLEMENTED,
/// Returns a list of regions within the specified ranges /// Returns a list of regions within the specified ranges
/// </summary> /// </summary>
/// <param name="a">minimum X coordinate</param> /// <param name="a">minimum X coordinate</param>
/// <param name="b">minimum Y coordinate</param> /// <param name="b">minimum Y coordinate</param>
/// <param name="c">maximum X coordinate</param> /// <param name="c">maximum X coordinate</param>
/// <param name="d">maximum Y coordinate</param> /// <param name="d">maximum Y coordinate</param>
/// <returns>An array of region profiles</returns> /// <returns>null</returns>
/// <remarks>always return null</remarks>
override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
{ {
return null; return null;
@ -240,6 +247,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Update the specified region in the database
/// </summary>
/// <param name="profile">The profile to update</param>
/// <returns>A dataresponse enum indicating success</returns>
public override DataResponse UpdateProfile(RegionProfileData profile) public override DataResponse UpdateProfile(RegionProfileData profile)
{ {
if (updateRegionRow(profile)) if (updateRegionRow(profile))
@ -252,6 +264,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Update the specified region in the database
/// </summary>
/// <param name="profile">The profile to update</param>
/// <returns>success ?</returns>
public bool updateRegionRow(RegionProfileData profile) public bool updateRegionRow(RegionProfileData profile)
{ {
//Insert new region //Insert new region
@ -425,6 +442,12 @@ namespace OpenSim.Data.MSSQL
return false; return false;
} }
/// <summary>
/// NOT IMPLEMENTED
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns>null</returns>
override public ReservationData GetReservationAtPoint(uint x, uint y) override public ReservationData GetReservationAtPoint(uint x, uint y)
{ {
return null; return null;

View File

@ -37,7 +37,7 @@ using OpenSim.Framework;
namespace OpenSim.Data.MSSQL namespace OpenSim.Data.MSSQL
{ {
/// <summary> /// <summary>
/// A MySQL interface for the inventory server /// A MSSQL interface for the inventory server
/// </summary> /// </summary>
public class MSSQLInventoryData : IInventoryData public class MSSQLInventoryData : IInventoryData
{ {
@ -59,6 +59,11 @@ namespace OpenSim.Data.MSSQL
/// </summary> /// </summary>
private MSSQLManager database; private MSSQLManager database;
/// <summary>
/// Loads and initialises the MSSQL inventory storage interface
/// </summary>
/// <param name="connect">connect string</param>
/// <remarks>use mssql_connection.ini</remarks>
public void Initialise(string connect) public void Initialise(string connect)
{ {
// TODO: actually use the provided connect string // TODO: actually use the provided connect string
@ -77,6 +82,10 @@ namespace OpenSim.Data.MSSQL
#region Test and initialization code #region Test and initialization code
/// <summary>
/// Execute "CreateFoldersTable.sql" if tableName == null
/// </summary>
/// <param name="tableName">the table name</param>
private void UpgradeFoldersTable(string tableName) private void UpgradeFoldersTable(string tableName)
{ {
// null as the version, indicates that the table didn't exist // null as the version, indicates that the table didn't exist
@ -88,6 +97,10 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Execute "CreateItemsTable.sql" if tableName = null
/// </summary>
/// <param name="tableName">the table name</param>
private void UpgradeItemsTable(string tableName) private void UpgradeItemsTable(string tableName)
{ {
// null as the version, indicates that the table didn't exist // null as the version, indicates that the table didn't exist
@ -99,6 +112,9 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
///
/// </summary>
private void TestTables() private void TestTables()
{ {
Dictionary<string, string> tableList = new Dictionary<string, string>(); Dictionary<string, string> tableList = new Dictionary<string, string>();
@ -117,7 +133,7 @@ namespace OpenSim.Data.MSSQL
/// <summary> /// <summary>
/// The name of this DB provider /// The name of this DB provider
/// </summary> /// </summary>
/// <returns>Name of DB provider</returns> /// <returns>A string containing the name of the DB provider</returns>
public string getName() public string getName()
{ {
return "MSSQL Inventory Data Interface"; return "MSSQL Inventory Data Interface";
@ -215,7 +231,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
// see InventoryItemBase.getUserRootFolder /// <summary>
/// see InventoryItemBase.getUserRootFolder
/// </summary>
/// <param name="user">the User UUID</param>
/// <returns></returns>
public InventoryFolderBase getUserRootFolder(LLUUID user) public InventoryFolderBase getUserRootFolder(LLUUID user)
{ {
try try
@ -549,9 +569,9 @@ namespace OpenSim.Data.MSSQL
} }
/// <summary> /// <summary>
/// /// Delete an item in inventory database
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item">the item UUID</param>
public void deleteInventoryItem(LLUUID itemID) public void deleteInventoryItem(LLUUID itemID)
{ {
try try
@ -690,6 +710,10 @@ namespace OpenSim.Data.MSSQL
return folders; return folders;
} }
/// <summary>
/// Delete a folder in inventory databasae
/// </summary>
/// <param name="folderID">the folder UUID</param>
protected void deleteOneFolder(LLUUID folderID) protected void deleteOneFolder(LLUUID folderID)
{ {
try try
@ -708,6 +732,10 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Delete an item in inventory database
/// </summary>
/// <param name="folderID">the item ID</param>
protected void deleteItemsInFolder(LLUUID folderID) protected void deleteItemsInFolder(LLUUID folderID)
{ {
try try

View File

@ -108,12 +108,23 @@ namespace OpenSim.Data.MSSQL
// return regions; // return regions;
//} //}
/// <summary>
///
/// </summary>
/// <param name="dt"></param>
/// <param name="name"></param>
/// <param name="type"></param>
protected static void createCol(DataTable dt, string name, Type type) protected static void createCol(DataTable dt, string name, Type type)
{ {
DataColumn col = new DataColumn(name, type); DataColumn col = new DataColumn(name, type);
dt.Columns.Add(col); dt.Columns.Add(col);
} }
/// <summary>
///
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
protected static string defineTable(DataTable dt) protected static string defineTable(DataTable dt)
{ {
string sql = "create table " + dt.TableName + "("; string sql = "create table " + dt.TableName + "(";
@ -137,9 +148,12 @@ namespace OpenSim.Data.MSSQL
return sql; return sql;
} }
/// <summary>
// this is something we'll need to implement for each db /// Type conversion function
// slightly differently. /// </summary>
/// <param name="type">a type</param>
/// <returns>a sqltype</returns>
/// <remarks>this is something we'll need to implement for each db slightly differently.</remarks>
public static string SqlType(Type type) public static string SqlType(Type type)
{ {
if (type == typeof(String)) if (type == typeof(String))
@ -375,6 +389,11 @@ namespace OpenSim.Data.MSSQL
return retval; return retval;
} }
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <returns></returns>
public AssetBase getAssetRow(IDataReader reader) public AssetBase getAssetRow(IDataReader reader)
{ {
AssetBase asset = new AssetBase(); AssetBase asset = new AssetBase();
@ -446,7 +465,7 @@ namespace OpenSim.Data.MSSQL
/// <summary> /// <summary>
/// Execute a SQL statement stored in a resource, as a string /// Execute a SQL statement stored in a resource, as a string
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name">the ressource string</param>
public void ExecuteResourceSql(string name) public void ExecuteResourceSql(string name)
{ {
SqlCommand cmd = new SqlCommand(getResourceString(name), (SqlConnection)dbcon); SqlCommand cmd = new SqlCommand(getResourceString(name), (SqlConnection)dbcon);
@ -454,6 +473,10 @@ namespace OpenSim.Data.MSSQL
cmd.Dispose(); cmd.Dispose();
} }
/// <summary>
///
/// </summary>
/// <returns>The actual SqlConnection</returns>
public SqlConnection getConnection() public SqlConnection getConnection()
{ {
return (SqlConnection)dbcon; return (SqlConnection)dbcon;
@ -491,6 +514,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
private string getResourceString(string name) private string getResourceString(string name)
{ {
Assembly assem = GetType().Assembly; Assembly assem = GetType().Assembly;

View File

@ -53,8 +53,10 @@ namespace OpenSim.Data.MSSQL
private string m_userFriendsTableName; private string m_userFriendsTableName;
/// <summary> /// <summary>
/// Loads and initialises the MySQL storage plugin /// Loads and initialises the MSSQL storage plugin
/// </summary> /// </summary>
/// <param name="connect">TODO: do something with the connect string instead of ignoring it.</param>
/// <remarks>use mssql_connection.ini</remarks>
override public void Initialise(string connect) override public void Initialise(string connect)
{ {
// TODO: do something with the connect string instead of // TODO: do something with the connect string instead of
@ -92,6 +94,10 @@ namespace OpenSim.Data.MSSQL
TestTables(); TestTables();
} }
/// <summary>
///
/// </summary>
/// <returns></returns>
private bool TestTables() private bool TestTables()
{ {
IDbCommand cmd; IDbCommand cmd;
@ -128,6 +134,7 @@ namespace OpenSim.Data.MSSQL
return true; return true;
} }
/// <summary> /// <summary>
/// Searches the database for a specified user profile by name components /// Searches the database for a specified user profile by name components
/// </summary> /// </summary>
@ -166,6 +173,12 @@ namespace OpenSim.Data.MSSQL
#region User Friends List Data #region User Friends List Data
/// <summary>
/// Add a new friend in the friendlist
/// </summary>
/// <param name="friendlistowner">UUID of the friendlist owner</param>
/// <param name="friend">Friend's UUID</param>
/// <param name="perms">Permission flag</param>
override public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) override public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
{ {
int dtvalue = Util.UnixTimeSinceEpoch(); int dtvalue = Util.UnixTimeSinceEpoch();
@ -209,6 +222,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Remove an friend from the friendlist
/// </summary>
/// <param name="friendlistowner">UUID of the friendlist owner</param>
/// <param name="friend">UUID of the not-so-friendly user to remove from the list</param>
override public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) override public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, string> param = new Dictionary<string, string>();
@ -242,6 +260,12 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Update friendlist permission flag for a friend
/// </summary>
/// <param name="friendlistowner">UUID of the friendlist owner</param>
/// <param name="friend">UUID of the friend</param>
/// <param name="perms">new permission flag</param>
override public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) override public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, string> param = new Dictionary<string, string>();
@ -272,7 +296,11 @@ namespace OpenSim.Data.MSSQL
} }
} }
/// <summary>
/// Get (fetch?) the user's friendlist
/// </summary>
/// <param name="friendlistowner">UUID of the friendlist owner</param>
/// <returns>Friendlist list</returns>
override public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner) override public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
{ {
List<FriendListItem> Lfli = new List<FriendListItem>(); List<FriendListItem> Lfli = new List<FriendListItem>();
@ -321,13 +349,23 @@ namespace OpenSim.Data.MSSQL
#endregion #endregion
/// <summary>
/// STUB ! Update current region
/// </summary>
/// <param name="avatarid">avatar uuid</param>
/// <param name="regionuuid">region uuid</param>
/// <param name="regionhandle">region handle</param>
override public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle) override public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle)
{ {
//m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); //m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called");
} }
/// <summary>
///
/// </summary>
/// <param name="queryID"></param>
/// <param name="query"></param>
/// <returns></returns>
override public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) override public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
{ {
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
@ -407,7 +445,11 @@ namespace OpenSim.Data.MSSQL
return returnlist; return returnlist;
} }
// See IUserData /// <summary>
/// See IUserData
/// </summary>
/// <param name="uuid"></param>
/// <returns></returns>
override public UserProfileData GetUserByUUID(LLUUID uuid) override public UserProfileData GetUserByUUID(LLUUID uuid)
{ {
try try
@ -490,6 +532,13 @@ namespace OpenSim.Data.MSSQL
return null; return null;
} }
} }
/// <summary>
/// Store a weblogin key
/// </summary>
/// <param name="AgentID">The agent UUID</param>
/// <param name="WebLoginKey">the WebLogin Key</param>
/// <remarks>unused ?</remarks>
override public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) override public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey)
{ {
UserProfileData user = GetUserByUUID(AgentID); UserProfileData user = GetUserByUUID(AgentID);
@ -626,7 +675,11 @@ namespace OpenSim.Data.MSSQL
// Do nothing. // Do nothing.
} }
/// <summary>
/// update a user profile
/// </summary>
/// <param name="user">the profile to update</param>
/// <returns></returns>
override public bool UpdateUserProfile(UserProfileData user) override public bool UpdateUserProfile(UserProfileData user)
{ {
SqlCommand command = new SqlCommand("UPDATE " + m_usersTableName + " set UUID = @uuid, " + SqlCommand command = new SqlCommand("UPDATE " + m_usersTableName + " set UUID = @uuid, " +
@ -726,7 +779,7 @@ namespace OpenSim.Data.MSSQL
/// <param name="from">The senders account ID</param> /// <param name="from">The senders account ID</param>
/// <param name="to">The receivers account ID</param> /// <param name="to">The receivers account ID</param>
/// <param name="amount">The amount to transfer</param> /// <param name="amount">The amount to transfer</param>
/// <returns>Success?</returns> /// <returns>false</returns>
override public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount) override public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount)
{ {
return false; return false;
@ -739,7 +792,7 @@ namespace OpenSim.Data.MSSQL
/// <param name="from">The senders account ID</param> /// <param name="from">The senders account ID</param>
/// <param name="to">The receivers account ID</param> /// <param name="to">The receivers account ID</param>
/// <param name="item">The item to transfer</param> /// <param name="item">The item to transfer</param>
/// <returns>Success?</returns> /// <returns>false</returns>
override public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) override public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
{ {
return false; return false;
@ -832,6 +885,11 @@ namespace OpenSim.Data.MSSQL
return null; return null;
} }
/// <summary>
/// Update a user appearence into database
/// </summary>
/// <param name="user">the used UUID</param>
/// <param name="appearance">the appearence</param>
override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
{ {
string sql = String.Empty; string sql = String.Empty;
@ -893,16 +951,32 @@ namespace OpenSim.Data.MSSQL
return; return;
} }
/// <summary>
/// add an attachement to an avatar
/// </summary>
/// <param name="user">the avatar UUID</param>
/// <param name="item">the item UUID</param>
override public void AddAttachment(LLUUID user, LLUUID item) override public void AddAttachment(LLUUID user, LLUUID item)
{ {
return; return;
} }
/// <summary>
/// Remove an attachement from an avatar
/// </summary>
/// <param name="user">the avatar UUID</param>
/// <param name="item">the item UUID</param>
override public void RemoveAttachment(LLUUID user, LLUUID item) override public void RemoveAttachment(LLUUID user, LLUUID item)
{ {
return; return;
} }
/// <summary>
/// get (fetch?) all attached item to an avatar
/// </summary>
/// <param name="user">the avatar UUID</param>
/// <returns>List of attached item</returns>
/// <remarks>return an empty list</remarks>
override public List<LLUUID> GetAttachments(LLUUID user) override public List<LLUUID> GetAttachments(LLUUID user)
{ {
return new List<LLUUID>(); return new List<LLUUID>();