From 54d9fbc0fe419dfb19da587d7b27d9a152a42946 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 27 Dec 2007 00:53:13 +0000
Subject: Prim inventory persistence phase 1: Creation of preliminary table in
sqlite. No user functionality yet. This code is not turned on, so there is
no possibility of disruption to existing databases.
---
OpenSim/Framework/Data.MySQL/MySQLDataStore.cs | 3 +-
.../Environment/Interfaces/IRegionDataStore.cs | 7 +-
.../Region/Environment/Scenes/SceneObjectPart.cs | 26 +++----
OpenSim/Region/Environment/StorageManager.cs | 2 +-
.../OpenSim.DataStore.MSSQL/MSSQLDataStore.cs | 8 +-
.../MonoSqliteDataStore.cs | 85 +++++++++++++++++++++-
.../OpenSim.DataStore.NullStorage/NullDataStore.cs | 2 +-
7 files changed, 103 insertions(+), 30 deletions(-)
diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
index e74643d..962d573 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
@@ -70,7 +70,8 @@ namespace OpenSim.Framework.Data.MySQL
*
**********************************************************************/
- public void Initialise(string connectionstring)
+ // see IRegionDataStore
+ public void Initialise(string connectionstring, bool persistPrimInventories)
{
m_dataSet = new DataSet();
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
index 7c63027..91aa5ff 100644
--- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
+++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs
@@ -38,9 +38,10 @@ namespace OpenSim.Region.Environment.Interfaces
///
/// Initialises the data storage engine
///
- /// The file to save the database to (may not be applicable)
- /// The name of the database to store to (may not be applicable)
- void Initialise(string filename);
+ /// The file to save the database to (may not be applicable). Alternatively,
+ /// a connection string for the database
+ /// Temporary switch while this option is immature
+ void Initialise(string filename, bool persistPrimInventories);
void StoreObject(SceneObjectGroup obj, LLUUID regionUUID);
void RemoveObject(LLUUID uuid, LLUUID regionUUID);
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 33f481d..34705db 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -1008,21 +1008,17 @@ namespace OpenSim.Region.Environment.Scenes
///
public bool GetInventoryFileName(IClientAPI client, uint localID)
{
-// if (localID == m_localID)
-// {
- if (m_inventorySerial > 0)
- {
- client.SendTaskInventory(m_uuid, (short)m_inventorySerial,
- Helpers.StringToField(m_inventoryFileName));
- return true;
- }
- else
- {
- client.SendTaskInventory(m_uuid, 0, new byte[0]);
- return false;
- }
-// }
- return false;
+ if (m_inventorySerial > 0)
+ {
+ client.SendTaskInventory(m_uuid, (short)m_inventorySerial,
+ Helpers.StringToField(m_inventoryFileName));
+ return true;
+ }
+ else
+ {
+ client.SendTaskInventory(m_uuid, 0, new byte[0]);
+ return false;
+ }
}
public string RequestInventoryFile(IXfer xferManager)
diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs
index b7bd8cc..2c04309 100644
--- a/OpenSim/Region/Environment/StorageManager.cs
+++ b/OpenSim/Region/Environment/StorageManager.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Region.Environment
{
IRegionDataStore plug =
(IRegionDataStore) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
- plug.Initialise(connectionstring);
+ plug.Initialise(connectionstring, false);
m_dataStore = plug;
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs
index 00b8924..c6210f7 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs
@@ -52,12 +52,8 @@ namespace OpenSim.DataStore.MSSQL
private SqlDataAdapter shapeDa;
private SqlDataAdapter terrainDa;
- ///
- ///
- ///
- ///
- ///
- public void Initialise(string dbfile)
+ // see IRegionDataStore
+ public void Initialise(string dbfile, bool persistPrimInventories)
{
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
index af2fb85..6750e4d 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
@@ -44,6 +44,7 @@ namespace OpenSim.DataStore.MonoSqlite
{
private const string primSelect = "select * from prims";
private const string shapeSelect = "select * from primshapes";
+ private const string itemsSelect = "select * from primitems";
private const string terrainSelect = "select * from terrain limit 1";
private const string landSelect = "select * from land";
private const string landAccessListSelect = "select * from landaccesslist";
@@ -56,6 +57,8 @@ namespace OpenSim.DataStore.MonoSqlite
private SqliteDataAdapter landAccessListDa;
private String m_connectionString;
+
+ private bool persistPrimInventories;
/***********************************************************************
*
@@ -63,9 +66,11 @@ namespace OpenSim.DataStore.MonoSqlite
*
**********************************************************************/
- public void Initialise(string connectionString)
+ // see IRegionDataStore
+ public void Initialise(string connectionString, bool persistPrimInventories)
{
- m_connectionString = connectionString;
+ m_connectionString = connectionString;
+ this.persistPrimInventories = persistPrimInventories;
ds = new DataSet();
@@ -601,10 +606,40 @@ namespace OpenSim.DataStore.MonoSqlite
createCol(shapes, "Texture", typeof (Byte[]));
createCol(shapes, "ExtraParams", typeof (Byte[]));
- shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]};
+ shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] };
return shapes;
}
+
+ private DataTable createItemsTable()
+ {
+ DataTable items = new DataTable("primitems");
+
+ createCol(items, "UUID", typeof (String));
+ createCol(items, "invType", typeof (Int32));
+ createCol(items, "assetID", typeof (String));
+ createCol(items, "assetType", typeof (Int32));
+ createCol(items, "parentFolderID", typeof (String));
+
+ createCol(items, "name", typeof (String));
+ createCol(items, "description", typeof (String));
+
+ createCol(items, "creationDate", typeof (Int64));
+ createCol(items, "creatorID", typeof (String));
+ createCol(items, "ownerID", typeof (String));
+ createCol(items, "lastOwnerID", typeof (String));
+ createCol(items, "groupID", typeof (String));
+
+ createCol(items, "nextPermissions", typeof (Int32));
+ createCol(items, "currentPermissions", typeof (Int32));
+ createCol(items, "basePermissions", typeof (Int32));
+ createCol(items, "everyonePermissions", typeof (Int32));
+ createCol(items, "groupPermissions", typeof (Int32));
+
+ items.PrimaryKey = new DataColumn[] { items.Columns["UUID"] };
+
+ return items;
+ }
private DataTable createLandTable()
{
@@ -1192,16 +1227,22 @@ namespace OpenSim.DataStore.MonoSqlite
da.DeleteCommand = delete;
}
+ ///
+ /// Create the necessary database tables.
+ ///
+ ///
private void InitDB(SqliteConnection conn)
{
string createPrims = defineTable(createPrimTable());
string createShapes = defineTable(createShapeTable());
+ string createItems = defineTable(createItemsTable());
string createTerrain = defineTable(createTerrainTable());
string createLand = defineTable(createLandTable());
string createLandAccessList = defineTable(createLandAccessListTable());
SqliteCommand pcmd = new SqliteCommand(createPrims, conn);
SqliteCommand scmd = new SqliteCommand(createShapes, conn);
+ SqliteCommand icmd = new SqliteCommand(createItems, conn);
SqliteCommand tcmd = new SqliteCommand(createTerrain, conn);
SqliteCommand lcmd = new SqliteCommand(createLand, conn);
SqliteCommand lalcmd = new SqliteCommand(createLandAccessList, conn);
@@ -1225,6 +1266,18 @@ namespace OpenSim.DataStore.MonoSqlite
{
MainLog.Instance.Warn("SQLITE", "Shapes Table Already Exists");
}
+
+ if (persistPrimInventories)
+ {
+ try
+ {
+ icmd.ExecuteNonQuery();
+ }
+ catch (SqliteSyntaxException)
+ {
+ MainLog.Instance.Warn("SQLITE", "Primitives Inventory Table Already Exists");
+ }
+ }
try
{
@@ -1259,12 +1312,19 @@ namespace OpenSim.DataStore.MonoSqlite
{
SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn);
SqliteDataAdapter pDa = new SqliteDataAdapter(primSelectCmd);
+
SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn);
SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd);
+
+ SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, conn);
+ SqliteDataAdapter iDa = new SqliteDataAdapter(itemsSelectCmd);
+
SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, conn);
SqliteDataAdapter tDa = new SqliteDataAdapter(terrainSelectCmd);
+
SqliteCommand landSelectCmd = new SqliteCommand(landSelect, conn);
SqliteDataAdapter lDa = new SqliteDataAdapter(landSelectCmd);
+
SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, conn);
SqliteDataAdapter lalDa = new SqliteDataAdapter(landAccessListSelectCmd);
@@ -1273,6 +1333,10 @@ namespace OpenSim.DataStore.MonoSqlite
{
pDa.Fill(tmpDS, "prims");
sDa.Fill(tmpDS, "primshapes");
+
+ if (persistPrimInventories)
+ iDa.Fill(tmpDS, "primitems");
+
tDa.Fill(tmpDS, "terrain");
lDa.Fill(tmpDS, "land");
lalDa.Fill(tmpDS, "landaccesslist");
@@ -1285,6 +1349,10 @@ namespace OpenSim.DataStore.MonoSqlite
pDa.Fill(tmpDS, "prims");
sDa.Fill(tmpDS, "primshapes");
+
+ if (persistPrimInventories)
+ iDa.Fill(tmpDS, "primitems");
+
tDa.Fill(tmpDS, "terrain");
lDa.Fill(tmpDS, "land");
lalDa.Fill(tmpDS,"landaccesslist");
@@ -1297,6 +1365,7 @@ namespace OpenSim.DataStore.MonoSqlite
return false;
}
}
+
foreach (DataColumn col in createShapeTable().Columns)
{
if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
@@ -1305,6 +1374,9 @@ namespace OpenSim.DataStore.MonoSqlite
return false;
}
}
+
+ // TODO Not restoring prim inventories quite yet
+
foreach (DataColumn col in createTerrainTable().Columns)
{
if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName))
@@ -1313,6 +1385,7 @@ namespace OpenSim.DataStore.MonoSqlite
return false;
}
}
+
foreach (DataColumn col in createLandTable().Columns)
{
if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName))
@@ -1321,6 +1394,7 @@ namespace OpenSim.DataStore.MonoSqlite
return false;
}
}
+
foreach (DataColumn col in createLandAccessListTable().Columns)
{
if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName))
@@ -1329,6 +1403,7 @@ namespace OpenSim.DataStore.MonoSqlite
return false;
}
}
+
return true;
}
@@ -1382,6 +1457,10 @@ namespace OpenSim.DataStore.MonoSqlite
{
return "integer";
}
+ else if (type == typeof (Int64))
+ {
+ return "integer";
+ }
else if (type == typeof (Double))
{
return "float";
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
index 158912b..da05018 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs
@@ -36,7 +36,7 @@ namespace OpenSim.DataStore.NullStorage
{
public class NullDataStore : IRegionDataStore
{
- public void Initialise(string dbfile)
+ public void Initialise(string dbfile, bool persistPrimInventories)
{
return;
}
--
cgit v1.1