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.
afrisby
Justin Clarke Casey 2007-12-27 00:53:13 +00:00
parent 9f2fb5ba70
commit 54d9fbc0fe
7 changed files with 103 additions and 30 deletions

View File

@ -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();

View File

@ -38,9 +38,10 @@ namespace OpenSim.Region.Environment.Interfaces
/// <summary>
/// Initialises the data storage engine
/// </summary>
/// <param name="filename">The file to save the database to (may not be applicable)</param>
/// <param name="dbname">The name of the database to store to (may not be applicable)</param>
void Initialise(string filename);
/// <param name="filename">The file to save the database to (may not be applicable). Alternatively,
/// a connection string for the database</param>
/// <param name="persistPrimInventories">Temporary switch while this option is immature</param>
void Initialise(string filename, bool persistPrimInventories);
void StoreObject(SceneObjectGroup obj, LLUUID regionUUID);
void RemoveObject(LLUUID uuid, LLUUID regionUUID);

View File

@ -1008,21 +1008,17 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="localID"></param>
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)

View File

@ -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;

View File

@ -52,12 +52,8 @@ namespace OpenSim.DataStore.MSSQL
private SqlDataAdapter shapeDa;
private SqlDataAdapter terrainDa;
/// <summary>
///
/// </summary>
/// <param name="dbfile"></param>
/// <param name="dbname"></param>
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");

View File

@ -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;
}
/// <summary>
/// Create the necessary database tables.
/// </summary>
/// <param name="conn"></param>
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";

View File

@ -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;
}