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