Apply patch from bug #1605 -- Documentation for Data/SQLite. Thanks kerunix_Flan!
parent
56802afff4
commit
9fae975a53
|
@ -130,13 +130,16 @@ namespace OpenSim.Data
|
|||
/// </summary>
|
||||
public LLUUID originUUID;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get Sim profile data from grid server when in grid mode
|
||||
/// Request sim profile information from a grid server, by Region UUID
|
||||
/// </summary>
|
||||
/// <param name="region_uuid"></param>
|
||||
/// <param name="region_uuid">The region UUID to look for</param>
|
||||
/// <param name="gridserver_url"></param>
|
||||
/// <param name="?"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="gridserver_sendkey"></param>
|
||||
/// <param name="gridserver_recvkey"></param>
|
||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
||||
/// <remarks>This method should be statics</remarks>
|
||||
public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url,
|
||||
string gridserver_sendkey, string gridserver_recvkey)
|
||||
{
|
||||
|
@ -172,9 +175,9 @@ namespace OpenSim.Data
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request sim profile information from a grid server
|
||||
/// Request sim profile information from a grid server, by Region Handle
|
||||
/// </summary>
|
||||
/// <param name="region_handle"></param>
|
||||
/// <param name="region_handle">the region handle to look for</param>
|
||||
/// <param name="gridserver_url"></param>
|
||||
/// <param name="gridserver_sendkey"></param>
|
||||
/// <param name="gridserver_recvkey"></param>
|
||||
|
@ -214,9 +217,9 @@ namespace OpenSim.Data
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request sim profile information from a grid server
|
||||
/// Request sim profile information from a grid server, by Region Name
|
||||
/// </summary>
|
||||
/// <param name="region_handle"></param>
|
||||
/// <param name="region_handle">the region name to look for</param>
|
||||
/// <param name="gridserver_url"></param>
|
||||
/// <param name="gridserver_sendkey"></param>
|
||||
/// <param name="gridserver_recvkey"></param>
|
||||
|
|
|
@ -56,6 +56,14 @@ namespace OpenSim.Data.SQLite
|
|||
|
||||
private SqliteConnection m_conn;
|
||||
|
||||
/// <summary>
|
||||
/// <list type="bullet">
|
||||
/// <item>Initialises AssetData interface</item>
|
||||
/// <item>Loads and initialises a new SQLite connection and maintains it.</item>
|
||||
/// <item>use default URI if connect string is empty.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
/// <param name="dbconnect">connect string</param>
|
||||
override public void Initialise(string dbconnect)
|
||||
{
|
||||
if (dbconnect == string.Empty)
|
||||
|
@ -65,9 +73,6 @@ namespace OpenSim.Data.SQLite
|
|||
m_conn = new SqliteConnection(dbconnect);
|
||||
m_conn.Open();
|
||||
|
||||
|
||||
|
||||
|
||||
Assembly assem = GetType().Assembly;
|
||||
Migration m = new Migration(m_conn, assem, "AssetStore");
|
||||
// TODO: remove this next line after changeset 6000,
|
||||
|
@ -80,6 +85,11 @@ namespace OpenSim.Data.SQLite
|
|||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetch Asset
|
||||
/// </summary>
|
||||
/// <param name="uuid">UUID of ... ?</param>
|
||||
/// <returns>Asset base</returns>
|
||||
override public AssetBase FetchAsset(LLUUID uuid)
|
||||
{
|
||||
|
||||
|
@ -103,6 +113,10 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an asset
|
||||
/// </summary>
|
||||
/// <param name="asset">Asset Base</param>
|
||||
override public void CreateAsset(AssetBase asset)
|
||||
{
|
||||
m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.FullID));
|
||||
|
@ -128,6 +142,10 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update an asset
|
||||
/// </summary>
|
||||
/// <param name="asset"></param>
|
||||
override public void UpdateAsset(AssetBase asset)
|
||||
{
|
||||
LogAssetLoad(asset);
|
||||
|
@ -148,6 +166,10 @@ namespace OpenSim.Data.SQLite
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Some... logging functionnality
|
||||
/// </summary>
|
||||
/// <param name="asset"></param>
|
||||
private static void LogAssetLoad(AssetBase asset)
|
||||
{
|
||||
string temporary = asset.Temporary ? "Temporary" : "Stored";
|
||||
|
@ -161,6 +183,11 @@ namespace OpenSim.Data.SQLite
|
|||
asset.InvType, temporary, local, assetLength));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if an asset exist in database
|
||||
/// </summary>
|
||||
/// <param name="uuid">The asset UUID</param>
|
||||
/// <returns>True if exist, or false.</returns>
|
||||
override public bool ExistsAsset(LLUUID uuid)
|
||||
{
|
||||
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
|
||||
|
@ -182,6 +209,10 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete an asset from database
|
||||
/// </summary>
|
||||
/// <param name="uuid"></param>
|
||||
public void DeleteAsset(LLUUID uuid)
|
||||
{
|
||||
using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
|
||||
|
@ -192,6 +223,9 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// commit
|
||||
/// </summary>
|
||||
override public void CommitAssets() // force a sync to the database
|
||||
{
|
||||
m_log.Info("[ASSET DB]: Attempting commit");
|
||||
|
@ -210,6 +244,10 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Create the "assets" table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static DataTable createAssetsTable()
|
||||
{
|
||||
DataTable assets = new DataTable("assets");
|
||||
|
@ -235,6 +273,11 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
private static AssetBase buildAsset(IDataReader row)
|
||||
{
|
||||
// TODO: this doesn't work yet because something more
|
||||
|
@ -263,6 +306,10 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="conn"></param>
|
||||
private static void InitDB(SqliteConnection conn)
|
||||
{
|
||||
string createAssets = SQLiteUtil.defineTable(createAssetsTable());
|
||||
|
@ -270,6 +317,12 @@ namespace OpenSim.Data.SQLite
|
|||
pcmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="conn"></param>
|
||||
/// <param name="m"></param>
|
||||
/// <returns></returns>
|
||||
private static bool TestTables(SqliteConnection conn, Migration m)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand(assetSelect, conn);
|
||||
|
@ -295,6 +348,9 @@ namespace OpenSim.Data.SQLite
|
|||
|
||||
#region IPlugin interface
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
override public string Version
|
||||
{
|
||||
get
|
||||
|
@ -309,11 +365,17 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialise the AssetData interface using default URI
|
||||
/// </summary>
|
||||
override public void Initialise()
|
||||
{
|
||||
Initialise("URI=file:AssetStorage.db,version=3");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of this DB provider
|
||||
/// </summary>
|
||||
override public string Name
|
||||
{
|
||||
get { return "SQLite Asset storage engine"; }
|
||||
|
|
|
@ -41,13 +41,18 @@ namespace OpenSim.Data.SQLite
|
|||
public class SQLiteGridData : GridDataBase
|
||||
{
|
||||
/// <summary>
|
||||
/// A database manager
|
||||
/// SQLite database manager
|
||||
/// </summary>
|
||||
private SQLiteManager database;
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the Grid Interface
|
||||
/// <list type="bullet">
|
||||
/// <item>Initialises Inventory interface</item>
|
||||
/// <item>Loads and initialises a new SQLite connection and maintains it.</item>
|
||||
/// <item>use default URI if connect string is empty.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
/// <param name="dbconnect">connect string</param>
|
||||
override public void Initialise(string connect)
|
||||
{
|
||||
database = new SQLiteManager(connect);
|
||||
|
@ -87,13 +92,14 @@ namespace OpenSim.Data.SQLite
|
|||
/// <param name="c">maximum X coordinate</param>
|
||||
/// <param name="d">maximum Y coordinate</param>
|
||||
/// <returns>An array of region profiles</returns>
|
||||
/// <remarks>NOT IMPLEMENTED ? always return null</remarks>
|
||||
override public RegionProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from it's location
|
||||
/// Returns a sim profile from it's handle
|
||||
/// </summary>
|
||||
/// <param name="handle">Region location handle</param>
|
||||
/// <returns>Sim profile</returns>
|
||||
|
@ -162,8 +168,9 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// // Returns a list of avatar and UUIDs that match the query
|
||||
/// Returns a list of avatar and UUIDs that match the query
|
||||
/// </summary>
|
||||
/// <remarks>do nothing yet</remarks>
|
||||
public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
|
||||
{
|
||||
//Do nothing yet
|
||||
|
@ -232,6 +239,12 @@ namespace OpenSim.Data.SQLite
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NOT IMPLEMENTED
|
||||
/// </summary>
|
||||
/// <param name="x">x coordinate</param>
|
||||
/// <param name="y">y coordinate</param>
|
||||
/// <returns>always return null</returns>
|
||||
override public ReservationData GetReservationAtPoint(uint x, uint y)
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -36,6 +36,9 @@ using OpenSim.Framework;
|
|||
|
||||
namespace OpenSim.Data.SQLite
|
||||
{
|
||||
/// <summary>
|
||||
/// An Inventory Interface to the SQLite database
|
||||
/// </summary>
|
||||
public class SQLiteInventoryStore : SQLiteUtil, IInventoryData
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
@ -48,8 +51,13 @@ namespace OpenSim.Data.SQLite
|
|||
private SqliteDataAdapter invFoldersDa;
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the interface
|
||||
/// <list type="bullet">
|
||||
/// <item>Initialises Inventory interface</item>
|
||||
/// <item>Loads and initialises a new SQLite connection and maintains it.</item>
|
||||
/// <item>use default URI if connect string string is empty.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
/// <param name="dbconnect">connect string</param>
|
||||
public void Initialise(string dbconnect)
|
||||
{
|
||||
if (dbconnect == string.Empty)
|
||||
|
@ -90,6 +98,11 @@ namespace OpenSim.Data.SQLite
|
|||
ds.AcceptChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
public InventoryItemBase buildItem(DataRow row)
|
||||
{
|
||||
InventoryItemBase item = new InventoryItemBase();
|
||||
|
@ -130,6 +143,11 @@ namespace OpenSim.Data.SQLite
|
|||
return item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="item"></param>
|
||||
private static void fillItemRow(DataRow row, InventoryItemBase item)
|
||||
{
|
||||
row["UUID"] = Util.ToRawUuidString(item.ID);
|
||||
|
@ -156,6 +174,12 @@ namespace OpenSim.Data.SQLite
|
|||
row["flags"] = item.Flags;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folder">Folder base</param>
|
||||
/// <param name="add">true=create folder. false=update existing folder</param>
|
||||
/// <remarks>nasty</remarks>
|
||||
private void addFolder(InventoryFolderBase folder, bool add)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -184,6 +208,10 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move an inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folder">folder base</param>
|
||||
private void moveFolder(InventoryFolderBase folder)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -206,6 +234,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add an item in inventory
|
||||
/// </summary>
|
||||
/// <param name="item">the item</param>
|
||||
/// <param name="add">true=add item ; false=update existing item</param>
|
||||
private void addItem(InventoryItemBase item, bool add)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -233,31 +266,34 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TODO : DataSet commit
|
||||
/// </summary>
|
||||
public void Shutdown()
|
||||
{
|
||||
// TODO: DataSet commit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the interface
|
||||
/// Closes the inventory interface
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The plugin being loaded
|
||||
/// The name of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the plugin name</returns>
|
||||
/// <returns>Name of DB provider</returns>
|
||||
public string getName()
|
||||
{
|
||||
return "SQLite Inventory Data Interface";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The plugins version
|
||||
/// Returns the version of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the plugin version</returns>
|
||||
/// <returns>A string containing the DB provider version</returns>
|
||||
public string getVersion()
|
||||
{
|
||||
Module module = GetType().Module;
|
||||
|
@ -362,7 +398,11 @@ namespace OpenSim.Data.SQLite
|
|||
return folders;
|
||||
}
|
||||
|
||||
// See IInventoryData
|
||||
/// <summary>
|
||||
/// See IInventoryData
|
||||
/// </summary>
|
||||
/// <param name="parentID"></param>
|
||||
/// <returns></returns>
|
||||
public List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID)
|
||||
{
|
||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||
|
@ -440,9 +480,9 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Delete an inventory item
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="item">The item UUID</param>
|
||||
public void deleteInventoryItem(LLUUID itemID)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -463,7 +503,7 @@ namespace OpenSim.Data.SQLite
|
|||
/// Delete all items in the specified folder
|
||||
/// </summary>
|
||||
/// <param name="folderId">id of the folder, whose item content should be deleted</param>
|
||||
//!TODO, this is horribly inefficient, but I don't want to ruin the overall structure of this implementation
|
||||
/// <todo>this is horribly inefficient, but I don't want to ruin the overall structure of this implementation</todo>
|
||||
private void deleteItemsInFolder(LLUUID folderId)
|
||||
{
|
||||
List<InventoryItemBase> items = getInventoryInFolder(Util.ToRawUuidString(folderId));
|
||||
|
@ -505,7 +545,7 @@ namespace OpenSim.Data.SQLite
|
|||
/// <remarks>
|
||||
/// This will clean-up any child folders and child items as well
|
||||
/// </remarks>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="folderID">the folder UUID</param>
|
||||
public void deleteInventoryFolder(LLUUID folderID)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -544,6 +584,9 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Create the "inventoryitems" table
|
||||
/// </summary>
|
||||
private static DataTable createInventoryItemsTable()
|
||||
{
|
||||
DataTable inv = new DataTable("inventoryitems");
|
||||
|
@ -582,6 +625,10 @@ namespace OpenSim.Data.SQLite
|
|||
return inv;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the "inventoryfolders" table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static DataTable createInventoryFoldersTable()
|
||||
{
|
||||
DataTable fol = new DataTable("inventoryfolders");
|
||||
|
@ -597,6 +644,11 @@ namespace OpenSim.Data.SQLite
|
|||
return fol;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -614,6 +666,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupFoldersCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -631,6 +688,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
private static InventoryFolderBase buildFolder(DataRow row)
|
||||
{
|
||||
InventoryFolderBase folder = new InventoryFolderBase();
|
||||
|
@ -643,6 +705,11 @@ namespace OpenSim.Data.SQLite
|
|||
return folder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="folder"></param>
|
||||
private static void fillFolderRow(DataRow row, InventoryFolderBase folder)
|
||||
{
|
||||
row["UUID"] = Util.ToRawUuidString(folder.ID);
|
||||
|
@ -653,6 +720,11 @@ namespace OpenSim.Data.SQLite
|
|||
row["version"] = folder.Version;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="folder"></param>
|
||||
private static void moveFolderRow(DataRow row, InventoryFolderBase folder)
|
||||
{
|
||||
row["UUID"] = Util.ToRawUuidString(folder.ID);
|
||||
|
@ -665,6 +737,10 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="conn"></param>
|
||||
private static void InitDB(SqliteConnection conn)
|
||||
{
|
||||
string createInventoryItems = defineTable(createInventoryItemsTable());
|
||||
|
@ -677,6 +753,12 @@ namespace OpenSim.Data.SQLite
|
|||
scmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="conn"></param>
|
||||
/// <param name="m"></param>
|
||||
/// <returns></returns>
|
||||
private static bool TestTables(SqliteConnection conn, Migration m)
|
||||
{
|
||||
SqliteCommand invItemsSelectCmd = new SqliteCommand(invItemsSelect, conn);
|
||||
|
|
|
@ -35,6 +35,9 @@ using log4net;
|
|||
|
||||
namespace OpenSim.Data.SQLite
|
||||
{
|
||||
/// <summary>
|
||||
/// SQLite Manager
|
||||
/// </summary>
|
||||
internal class SQLiteManager : SQLiteUtil
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
@ -42,13 +45,12 @@ namespace OpenSim.Data.SQLite
|
|||
private IDbConnection dbcon;
|
||||
|
||||
/// <summary>
|
||||
/// Initialises and creates a new SQLite connection and maintains it.
|
||||
/// <list type="bullet">
|
||||
/// <item>Initialises and creates a new SQLite connection and maintains it.</item>
|
||||
/// <item>use default URI if connect string is empty.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
/// <param name="hostname">The SQLite server being connected to</param>
|
||||
/// <param name="database">The name of the SQLite database being used</param>
|
||||
/// <param name="username">The username logging into the database</param>
|
||||
/// <param name="password">The password for the user logging in</param>
|
||||
/// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
|
||||
/// <param name="connect">connect string</param>
|
||||
public SQLiteManager(string connect)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -40,6 +40,9 @@ using OpenSim.Region.Environment.Scenes;
|
|||
|
||||
namespace OpenSim.Data.SQLite
|
||||
{
|
||||
/// <summary>
|
||||
/// A RegionData Interface to the SQLite database
|
||||
/// </summary>
|
||||
public class SQLiteRegionData : IRegionDataStore
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
@ -74,7 +77,15 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
// see IRegionDataStore
|
||||
/// <summary>
|
||||
/// See IRegionDataStore
|
||||
/// <list type="bullet">
|
||||
/// <item>Initialises RegionData Interface</item>
|
||||
/// <item>Loads and initialises a new SQLite connection and maintains it.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
/// <param name="connectionString">the connection string</param>
|
||||
/// <param name="persistPrimInventories">?</param>
|
||||
public void Initialise(string connectionString, bool persistPrimInventories)
|
||||
{
|
||||
m_connectionString = connectionString;
|
||||
|
@ -203,6 +214,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an object into region storage
|
||||
/// </summary>
|
||||
/// <param name="obj">the object</param>
|
||||
/// <param name="regionUUID">the region UUID</param>
|
||||
public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -233,6 +249,11 @@ namespace OpenSim.Data.SQLite
|
|||
// m_log.Info("[Dump of prims]: " + ds.GetXml());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an object from region storage
|
||||
/// </summary>
|
||||
/// <param name="obj">the object</param>
|
||||
/// <param name="regionUUID">the region UUID</param>
|
||||
public void RemoveObject(LLUUID obj, LLUUID regionUUID)
|
||||
{
|
||||
m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID);
|
||||
|
@ -271,6 +292,7 @@ namespace OpenSim.Data.SQLite
|
|||
/// Remove all persisted items of the given prim.
|
||||
/// The caller must acquire the necessrary synchronization locks and commit or rollback changes.
|
||||
/// </summary>
|
||||
/// <param name="uuid">The item UUID</param>
|
||||
private void RemoveItems(LLUUID uuid)
|
||||
{
|
||||
DataTable items = ds.Tables["primitems"];
|
||||
|
@ -287,7 +309,7 @@ namespace OpenSim.Data.SQLite
|
|||
/// <summary>
|
||||
/// Load persisted objects from region storage.
|
||||
/// </summary>
|
||||
/// <param name="regionUUID"></param>
|
||||
/// <param name="regionUUID">The region UUID</param>
|
||||
/// <returns>List of loaded groups</returns>
|
||||
public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID)
|
||||
{
|
||||
|
@ -375,7 +397,7 @@ namespace OpenSim.Data.SQLite
|
|||
/// <summary>
|
||||
/// Load in a prim's persisted inventory.
|
||||
/// </summary>
|
||||
/// <param name="prim"></param>
|
||||
/// <param name="prim">the prim</param>
|
||||
private void LoadItems(SceneObjectPart prim)
|
||||
{
|
||||
//m_log.DebugFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID);
|
||||
|
@ -405,6 +427,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Store a terrain revision in region storage
|
||||
/// </summary>
|
||||
/// <param name="ter">terrain heightfield</param>
|
||||
/// <param name="regionID">region UUID</param>
|
||||
public void StoreTerrain(double[,] ter, LLUUID regionID)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -444,6 +471,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -488,6 +520,10 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="globalID"></param>
|
||||
public void RemoveLandObject(LLUUID globalID)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -506,6 +542,10 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="parcel"></param>
|
||||
public void StoreLandObject(ILandObject parcel)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -543,6 +583,11 @@ namespace OpenSim.Data.SQLite
|
|||
Commit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="regionUUID"></param>
|
||||
/// <returns></returns>
|
||||
public List<LandData> LoadLandObjects(LLUUID regionUUID)
|
||||
{
|
||||
List<LandData> landDataForRegion = new List<LandData>();
|
||||
|
@ -568,6 +613,9 @@ namespace OpenSim.Data.SQLite
|
|||
return landDataForRegion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Commit()
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -587,6 +635,9 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="Commit"/>
|
||||
/// </summary>
|
||||
public void Shutdown()
|
||||
{
|
||||
Commit();
|
||||
|
@ -600,12 +651,22 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
private static void createCol(DataTable dt, string name, Type type)
|
||||
{
|
||||
DataColumn col = new DataColumn(name, type);
|
||||
dt.Columns.Add(col);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the "terrain" table
|
||||
/// </summary>
|
||||
/// <returns>terrain table DataTable</returns>
|
||||
private static DataTable createTerrainTable()
|
||||
{
|
||||
DataTable terrain = new DataTable("terrain");
|
||||
|
@ -617,6 +678,10 @@ namespace OpenSim.Data.SQLite
|
|||
return terrain;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the "prims" table
|
||||
/// </summary>
|
||||
/// <returns>prim table DataTable</returns>
|
||||
private static DataTable createPrimTable()
|
||||
{
|
||||
DataTable prims = new DataTable("prims");
|
||||
|
@ -681,6 +746,10 @@ namespace OpenSim.Data.SQLite
|
|||
return prims;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates "primshapes" table
|
||||
/// </summary>
|
||||
/// <returns>shape table DataTable</returns>
|
||||
private static DataTable createShapeTable()
|
||||
{
|
||||
DataTable shapes = new DataTable("primshapes");
|
||||
|
@ -723,6 +792,10 @@ namespace OpenSim.Data.SQLite
|
|||
return shapes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// creates "primitems" table
|
||||
/// </summary>
|
||||
/// <returns>item table DataTable</returns>
|
||||
private static DataTable createItemsTable()
|
||||
{
|
||||
DataTable items = new DataTable("primitems");
|
||||
|
@ -756,6 +829,10 @@ namespace OpenSim.Data.SQLite
|
|||
return items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates "land" table
|
||||
/// </summary>
|
||||
/// <returns>land table DataTable</returns>
|
||||
private static DataTable createLandTable()
|
||||
{
|
||||
DataTable land = new DataTable("land");
|
||||
|
@ -800,6 +877,10 @@ namespace OpenSim.Data.SQLite
|
|||
return land;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create "landaccesslist" table
|
||||
/// </summary>
|
||||
/// <returns>Landacceslist DataTable</returns>
|
||||
private static DataTable createLandAccessListTable()
|
||||
{
|
||||
DataTable landaccess = new DataTable("landaccesslist");
|
||||
|
@ -810,6 +891,10 @@ namespace OpenSim.Data.SQLite
|
|||
return landaccess;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create "regionban" table
|
||||
/// </summary>
|
||||
/// <returns>regionban datatable</returns>
|
||||
private static DataTable createRegionBanListTable()
|
||||
{
|
||||
DataTable regionbanlist = new DataTable("regionban");
|
||||
|
@ -829,6 +914,11 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
private SceneObjectPart buildPrim(DataRow row)
|
||||
{
|
||||
// TODO: this doesn't work yet because something more
|
||||
|
@ -971,6 +1061,11 @@ namespace OpenSim.Data.SQLite
|
|||
return taskItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build a Land Data from the persisted data.
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
private LandData buildLandData(DataRow row)
|
||||
{
|
||||
LandData newData = new LandData();
|
||||
|
@ -1059,6 +1154,11 @@ namespace OpenSim.Data.SQLite
|
|||
return newData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build a land access entry from the persisted data.
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row)
|
||||
{
|
||||
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
|
||||
|
@ -1069,7 +1169,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Load a region banlist
|
||||
/// </summary>
|
||||
/// <param name="regionUUID">the region UUID</param>
|
||||
/// <returns>The banlist</returns>
|
||||
public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID)
|
||||
{
|
||||
List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>();
|
||||
|
@ -1096,6 +1200,10 @@ namespace OpenSim.Data.SQLite
|
|||
return regionbanlist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add en entry into region banlist
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void AddToRegionBanlist(RegionBanListItem item)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -1111,6 +1219,10 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove an entry from the region banlist
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void RemoveFromRegionBanlist(RegionBanListItem item)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -1124,6 +1236,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="val"></param>
|
||||
/// <returns></returns>
|
||||
private static Array serializeTerrain(double[,] val)
|
||||
{
|
||||
MemoryStream str = new MemoryStream(65536*sizeof (double));
|
||||
|
@ -1153,6 +1270,13 @@ namespace OpenSim.Data.SQLite
|
|||
// row["Heightfield"] = str.ToArray();
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="prim"></param>
|
||||
/// <param name="sceneGroupID"></param>
|
||||
/// <param name="regionUUID"></param>
|
||||
private static void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID)
|
||||
{
|
||||
row["UUID"] = Util.ToRawUuidString(prim.UUID);
|
||||
|
@ -1213,6 +1337,11 @@ namespace OpenSim.Data.SQLite
|
|||
row["SitTargetOrientZ"] = sitTargetOrient.Z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="taskItem"></param>
|
||||
private static void fillItemRow(DataRow row, TaskInventoryItem taskItem)
|
||||
{
|
||||
row["itemID"] = taskItem.ItemID;
|
||||
|
@ -1238,6 +1367,12 @@ namespace OpenSim.Data.SQLite
|
|||
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)
|
||||
{
|
||||
row["UUID"] = Util.ToRawUuidString(land.globalID);
|
||||
|
@ -1277,6 +1412,12 @@ namespace OpenSim.Data.SQLite
|
|||
row["AuthbuyerID"] = Util.ToRawUuidString(land.authBuyerID);
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
row["LandUUID"] = Util.ToRawUuidString(parcelID);
|
||||
|
@ -1284,6 +1425,11 @@ namespace OpenSim.Data.SQLite
|
|||
row["Flags"] = entry.Flags;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
private PrimitiveBaseShape buildShape(DataRow row)
|
||||
{
|
||||
PrimitiveBaseShape s = new PrimitiveBaseShape();
|
||||
|
@ -1334,6 +1480,11 @@ namespace OpenSim.Data.SQLite
|
|||
return s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="prim"></param>
|
||||
private static void fillShapeRow(DataRow row, SceneObjectPart prim)
|
||||
{
|
||||
PrimitiveBaseShape s = prim.Shape;
|
||||
|
@ -1371,6 +1522,12 @@ namespace OpenSim.Data.SQLite
|
|||
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)
|
||||
{
|
||||
DataTable prims = ds.Tables["prims"];
|
||||
|
@ -1401,7 +1558,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
// see IRegionDatastore
|
||||
/// <summary>
|
||||
/// see IRegionDatastore
|
||||
/// </summary>
|
||||
/// <param name="primID"></param>
|
||||
/// <param name="items"></param>
|
||||
public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items)
|
||||
{
|
||||
if (!persistPrimInventories)
|
||||
|
@ -1444,17 +1605,23 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Create an insert command
|
||||
/// </summary>
|
||||
/// <param name="table">table name</param>
|
||||
/// <param name="dt">data table</param>
|
||||
/// <returns>the created command</returns>
|
||||
/// <remarks>
|
||||
/// This is subtle enough to deserve some commentary.
|
||||
/// Instead of doing *lots* and *lots of hardcoded strings
|
||||
/// for database definitions we'll use the fact that
|
||||
/// realistically all insert statements look like "insert
|
||||
/// into A(b, c) values(:b, :c) on the parameterized query
|
||||
/// front. If we just have a list of b, c, etc... we can
|
||||
/// generate these strings instead of typing them out.
|
||||
/// </remarks>
|
||||
private static SqliteCommand createInsertCommand(string table, DataTable dt)
|
||||
{
|
||||
/**
|
||||
* This is subtle enough to deserve some commentary.
|
||||
* Instead of doing *lots* and *lots of hardcoded strings
|
||||
* for database definitions we'll use the fact that
|
||||
* realistically all insert statements look like "insert
|
||||
* into A(b, c) values(:b, :c) on the parameterized query
|
||||
* front. If we just have a list of b, c, etc... we can
|
||||
* generate these strings instead of typing them out.
|
||||
*/
|
||||
string[] cols = new string[dt.Columns.Count];
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
{
|
||||
|
@ -1479,6 +1646,14 @@ namespace OpenSim.Data.SQLite
|
|||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// create an update command
|
||||
/// </summary>
|
||||
/// <param name="table">table name</param>
|
||||
/// <param name="pk"></param>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns>the created command</returns>
|
||||
private static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt)
|
||||
{
|
||||
string sql = "update " + table + " set ";
|
||||
|
@ -1506,7 +1681,11 @@ namespace OpenSim.Data.SQLite
|
|||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dt">Data Table</param>
|
||||
/// <returns></returns>
|
||||
private static string defineTable(DataTable dt)
|
||||
{
|
||||
string sql = "create table " + dt.TableName + "(";
|
||||
|
@ -1559,6 +1738,11 @@ namespace OpenSim.Data.SQLite
|
|||
return param;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
da.InsertCommand = createInsertCommand("prims", ds.Tables["prims"]);
|
||||
|
@ -1573,6 +1757,11 @@ namespace OpenSim.Data.SQLite
|
|||
da.DeleteCommand = delete;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
da.InsertCommand = createInsertCommand("primitems", ds.Tables["primitems"]);
|
||||
|
@ -1587,12 +1776,22 @@ namespace OpenSim.Data.SQLite
|
|||
da.DeleteCommand = delete;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupTerrainCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
da.InsertCommand = createInsertCommand("terrain", ds.Tables["terrain"]);
|
||||
da.InsertCommand.Connection = conn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupLandCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
da.InsertCommand = createInsertCommand("land", ds.Tables["land"]);
|
||||
|
@ -1602,12 +1801,22 @@ namespace OpenSim.Data.SQLite
|
|||
da.UpdateCommand.Connection = conn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupLandAccessCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]);
|
||||
da.InsertCommand.Connection = conn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupRegionBanCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
da.InsertCommand = createInsertCommand("regionban", ds.Tables["regionban"]);
|
||||
|
@ -1617,7 +1826,11 @@ namespace OpenSim.Data.SQLite
|
|||
da.UpdateCommand.Connection = conn;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]);
|
||||
|
@ -1710,6 +1923,12 @@ namespace OpenSim.Data.SQLite
|
|||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="conn"></param>
|
||||
/// <param name="m"></param>
|
||||
/// <returns></returns>
|
||||
private bool TestTables(SqliteConnection conn, Migration m)
|
||||
{
|
||||
SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn);
|
||||
|
@ -1822,6 +2041,11 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Type conversion function
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
private static DbType dbtypeFromType(Type type)
|
||||
{
|
||||
if (type == typeof (String))
|
||||
|
@ -1854,8 +2078,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
// this is something we'll need to implement for each db
|
||||
// slightly differently.
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="type">a Type</param>
|
||||
/// <returns>an sqliteType</returns>
|
||||
/// <remarks>this is something we'll need to implement for each db slightly differently.</remarks>
|
||||
private static string sqliteType(Type type)
|
||||
{
|
||||
if (type == typeof (String))
|
||||
|
|
|
@ -65,6 +65,14 @@ namespace OpenSim.Data.SQLite
|
|||
private SqliteDataAdapter daf;
|
||||
SqliteConnection g_conn;
|
||||
|
||||
/// <summary>
|
||||
/// <list type="bullet">
|
||||
/// <item>Initialises User Interface</item>
|
||||
/// <item>Loads and initialises a new SQLite connection and maintains it.</item>
|
||||
/// <item>use default URI if connect string string is empty.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
/// <param name="connect">connect string</param>
|
||||
override public void Initialise(string connect)
|
||||
{
|
||||
// default to something sensible
|
||||
|
@ -116,7 +124,12 @@ namespace OpenSim.Data.SQLite
|
|||
return;
|
||||
}
|
||||
|
||||
// see IUserData
|
||||
/// <summary>
|
||||
/// see IUserData,
|
||||
/// Get user data profile by UUID
|
||||
/// </summary>
|
||||
/// <param name="uuid">User UUID</param>
|
||||
/// <returns>user profile data</returns>
|
||||
override public UserProfileData GetUserByUUID(LLUUID uuid)
|
||||
{
|
||||
lock (ds)
|
||||
|
@ -139,7 +152,13 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
// see IUserData
|
||||
/// <summary>
|
||||
/// see IUserData,
|
||||
/// Get user data profile by name
|
||||
/// </summary>
|
||||
/// <param name="fname">first name</param>
|
||||
/// <param name="lname">last name</param>
|
||||
/// <returns>user profile data</returns>
|
||||
override public UserProfileData GetUserByName(string fname, string lname)
|
||||
{
|
||||
string select = "surname = '" + lname + "' and username = '" + fname + "'";
|
||||
|
@ -165,6 +184,12 @@ namespace OpenSim.Data.SQLite
|
|||
|
||||
#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">UUID of the friend to add</param>
|
||||
/// <param name="perms">permission flag</param>
|
||||
override public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
|
||||
{
|
||||
string InsertFriends = "insert into userfriends(ownerID, friendID, friendPerms) values(:ownerID, :friendID, :perms)";
|
||||
|
@ -185,6 +210,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a user from the friendlist
|
||||
/// </summary>
|
||||
/// <param name="friendlistowner">UUID of the friendlist owner</param>
|
||||
/// <param name="friend">UUID of the friend to remove</param>
|
||||
override public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
|
||||
{
|
||||
string DeletePerms = "delete from friendlist where (ownerID=:ownerID and friendID=:friendID) or (ownerID=:friendID and friendID=:ownerID)";
|
||||
|
@ -196,6 +226,12 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the friendlist permission
|
||||
/// </summary>
|
||||
/// <param name="friendlistowner">UUID of the friendlist owner</param>
|
||||
/// <param name="friend">UUID of the friend to modify</param>
|
||||
/// <param name="perms">updated permission flag</param>
|
||||
override public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
|
||||
{
|
||||
string UpdatePerms = "update friendlist set perms=:perms where ownerID=:ownerID and friendID=:friendID";
|
||||
|
@ -208,6 +244,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get (fetch?) the friendlist for a user
|
||||
/// </summary>
|
||||
/// <param name="friendlistowner">UUID of the friendlist owner</param>
|
||||
/// <returns>The friendlist list</returns>
|
||||
override public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
|
||||
{
|
||||
List<FriendListItem> returnlist = new List<FriendListItem>();
|
||||
|
@ -246,12 +287,24 @@ namespace OpenSim.Data.SQLite
|
|||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// STUB, Update the user's current region
|
||||
/// </summary>
|
||||
/// <param name="avatarid">UUID of the user</param>
|
||||
/// <param name="regionuuid">UUID of the region</param>
|
||||
/// <param name="regionhandle">region handle</param>
|
||||
/// <remarks>DO NOTHING</remarks>
|
||||
override public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle)
|
||||
{
|
||||
//m_log.Info("[USER DB]: Stub UpdateUserCUrrentRegion called");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="queryID"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
override public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
|
||||
{
|
||||
List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
|
||||
|
@ -347,7 +400,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// DEPRECATED? Store the weblogin key
|
||||
/// </summary>
|
||||
/// <param name="AgentID">UUID of the user</param>
|
||||
/// <param name="WebLoginKey">UUID of the weblogin</param>
|
||||
override public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey)
|
||||
{
|
||||
DataTable users = ds.Tables["users"];
|
||||
|
@ -487,8 +544,13 @@ namespace OpenSim.Data.SQLite
|
|||
return true;
|
||||
}
|
||||
|
||||
/// Appearance
|
||||
|
||||
/// <summary>
|
||||
/// Appearance.
|
||||
/// TODO: stubs for now to do in memory appearance.
|
||||
/// </summary>
|
||||
/// <param name="user">The user UUID</param>
|
||||
/// <returns>Avatar Appearence</returns>
|
||||
override public AvatarAppearance GetUserAppearance(LLUUID user)
|
||||
{
|
||||
AvatarAppearance aa = null;
|
||||
|
@ -501,22 +563,45 @@ namespace OpenSim.Data.SQLite
|
|||
return aa;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a user appearence
|
||||
/// </summary>
|
||||
/// <param name="user">the user UUID</param>
|
||||
/// <param name="appearance">appearence</param>
|
||||
override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
|
||||
{
|
||||
appearance.Owner = user;
|
||||
aplist[user] = appearance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an attachment item to an avatar
|
||||
/// </summary>
|
||||
/// <param name="user">the user UUID</param>
|
||||
/// <param name="item">the item UUID</param>
|
||||
/// <remarks>DO NOTHING ?</remarks>
|
||||
override public void AddAttachment(LLUUID user, LLUUID item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove an attachement item from an avatar
|
||||
/// </summary>
|
||||
/// <param name="user">the user UUID</param>
|
||||
/// <param name="item">the item UUID</param>
|
||||
/// <remarks>DO NOTHING ?</remarks>
|
||||
override public void RemoveAttachment(LLUUID user, LLUUID item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list of attached item
|
||||
/// </summary>
|
||||
/// <param name="user">the user UUID</param>
|
||||
/// <returns>List of attached item</returns>
|
||||
/// <remarks>DO NOTHING ?</remarks>
|
||||
override public List<LLUUID> GetAttachments(LLUUID user)
|
||||
{
|
||||
return new List<LLUUID>();
|
||||
|
@ -553,6 +638,10 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Create the "users" table
|
||||
/// </summary>
|
||||
/// <returns>DataTable</returns>
|
||||
private static DataTable createUsersTable()
|
||||
{
|
||||
DataTable users = new DataTable("users");
|
||||
|
@ -588,6 +677,10 @@ namespace OpenSim.Data.SQLite
|
|||
return users;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the "useragents" table
|
||||
/// </summary>
|
||||
/// <returns>Data Table</returns>
|
||||
private static DataTable createUserAgentsTable()
|
||||
{
|
||||
DataTable ua = new DataTable("useragents");
|
||||
|
@ -613,6 +706,10 @@ namespace OpenSim.Data.SQLite
|
|||
return ua;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the "userfriends" table
|
||||
/// </summary>
|
||||
/// <returns>Data Table</returns>
|
||||
private static DataTable createUserFriendsTable()
|
||||
{
|
||||
DataTable ua = new DataTable("userfriends");
|
||||
|
@ -634,11 +731,15 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// TODO: this doesn't work yet because something more
|
||||
/// interesting has to be done to actually get these values
|
||||
/// back out. Not enough time to figure it out yet.
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
private static UserProfileData buildUserProfile(DataRow row)
|
||||
{
|
||||
// TODO: this doesn't work yet because something more
|
||||
// interesting has to be done to actually get these values
|
||||
// back out. Not enough time to figure it out yet.
|
||||
UserProfileData user = new UserProfileData();
|
||||
LLUUID tmp;
|
||||
LLUUID.TryParse((String)row["UUID"], out tmp);
|
||||
|
@ -678,6 +779,11 @@ namespace OpenSim.Data.SQLite
|
|||
return user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="user"></param>
|
||||
private void fillUserRow(DataRow row, UserProfileData user)
|
||||
{
|
||||
row["UUID"] = Util.ToRawUuidString(user.ID);
|
||||
|
@ -719,6 +825,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <returns></returns>
|
||||
private static UserAgentData buildUserAgent(DataRow row)
|
||||
{
|
||||
UserAgentData ua = new UserAgentData();
|
||||
|
@ -742,6 +853,11 @@ namespace OpenSim.Data.SQLite
|
|||
return ua;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="ua"></param>
|
||||
private static void fillUserAgentRow(DataRow row, UserAgentData ua)
|
||||
{
|
||||
row["UUID"] = ua.ProfileID;
|
||||
|
@ -770,6 +886,11 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="da"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupUserCommands(SqliteDataAdapter da, SqliteConnection conn)
|
||||
{
|
||||
da.InsertCommand = SQLiteUtil.createInsertCommand("users", ds.Tables["users"]);
|
||||
|
@ -784,6 +905,11 @@ namespace OpenSim.Data.SQLite
|
|||
da.DeleteCommand = delete;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="daf"></param>
|
||||
/// <param name="conn"></param>
|
||||
private void setupUserFriendsCommands(SqliteDataAdapter daf, SqliteConnection conn)
|
||||
{
|
||||
daf.InsertCommand = SQLiteUtil.createInsertCommand("userfriends", ds.Tables["userfriends"]);
|
||||
|
@ -800,6 +926,10 @@ namespace OpenSim.Data.SQLite
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="conn"></param>
|
||||
private static void InitDB(SqliteConnection conn)
|
||||
{
|
||||
string createUsers = SQLiteUtil.defineTable(createUsersTable());
|
||||
|
@ -832,6 +962,12 @@ namespace OpenSim.Data.SQLite
|
|||
conn.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="conn"></param>
|
||||
/// <param name="m"></param>
|
||||
/// <returns></returns>
|
||||
private static bool TestTables(SqliteConnection conn, Migration m)
|
||||
{
|
||||
SqliteCommand cmd = new SqliteCommand(userSelect, conn);
|
||||
|
|
|
@ -44,6 +44,12 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
public static void createCol(DataTable dt, string name, Type type)
|
||||
{
|
||||
DataColumn col = new DataColumn(name, type);
|
||||
|
@ -60,17 +66,24 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Create an insert command
|
||||
/// </summary>
|
||||
/// <param name="table">table name</param>
|
||||
/// <param name="dt">data table</param>
|
||||
/// <returns>the created command</returns>
|
||||
/// <remarks>
|
||||
/// This is subtle enough to deserve some commentary.
|
||||
/// Instead of doing *lots* and *lots of hardcoded strings
|
||||
/// for database definitions we'll use the fact that
|
||||
/// realistically all insert statements look like "insert
|
||||
/// into A(b, c) values(:b, :c) on the parameterized query
|
||||
/// front. If we just have a list of b, c, etc... we can
|
||||
/// generate these strings instead of typing them out.
|
||||
/// </remarks>
|
||||
public static SqliteCommand createInsertCommand(string table, DataTable dt)
|
||||
{
|
||||
/**
|
||||
* This is subtle enough to deserve some commentary.
|
||||
* Instead of doing *lots* and *lots of hardcoded strings
|
||||
* for database definitions we'll use the fact that
|
||||
* realistically all insert statements look like "insert
|
||||
* into A(b, c) values(:b, :c) on the parameterized query
|
||||
* front. If we just have a list of b, c, etc... we can
|
||||
* generate these strings instead of typing them out.
|
||||
*/
|
||||
|
||||
string[] cols = new string[dt.Columns.Count];
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
{
|
||||
|
@ -95,6 +108,13 @@ namespace OpenSim.Data.SQLite
|
|||
return cmd;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create an update command
|
||||
/// </summary>
|
||||
/// <param name="table">table name</param>
|
||||
/// <param name="pk"></param>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns>the created command</returns>
|
||||
public static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt)
|
||||
{
|
||||
string sql = "update " + table + " set ";
|
||||
|
@ -122,7 +142,11 @@ namespace OpenSim.Data.SQLite
|
|||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dt">Data Table</param>
|
||||
/// <returns></returns>
|
||||
public static string defineTable(DataTable dt)
|
||||
{
|
||||
string sql = "create table " + dt.TableName + "(";
|
||||
|
@ -158,15 +182,21 @@ namespace OpenSim.Data.SQLite
|
|||
**********************************************************************/
|
||||
|
||||
///<summary>
|
||||
/// <para>
|
||||
/// This is a convenience function that collapses 5 repetitive
|
||||
/// lines for defining SqliteParameters to 2 parameters:
|
||||
/// column name and database type.
|
||||
///
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// 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.
|
||||
/// </para>
|
||||
///</summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
///<returns>a built sqlite parameter</returns>
|
||||
public static SqliteParameter createSqliteParameter(string name, Type type)
|
||||
{
|
||||
|
@ -184,6 +214,11 @@ namespace OpenSim.Data.SQLite
|
|||
*
|
||||
**********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Type conversion function
|
||||
/// </summary>
|
||||
/// <param name="type">a type</param>
|
||||
/// <returns>a DbType</returns>
|
||||
public static DbType dbtypeFromType(Type type)
|
||||
{
|
||||
if (type == typeof (String))
|
||||
|
@ -224,8 +259,11 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
// this is something we'll need to implement for each db
|
||||
// slightly differently.
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="type">a Type</param>
|
||||
/// <returns>a string</returns>
|
||||
/// <remarks>this is something we'll need to implement for each db slightly differently.</remarks>
|
||||
public static string sqliteType(Type type)
|
||||
{
|
||||
if (type == typeof (String))
|
||||
|
|
Loading…
Reference in New Issue