Remove time based terrain storage in SQLite so revision number can be used
to denote terrain format revision. Add terrain DB format revision codes to ISimulationDataStore.cs. Setup so legacy compatible terrain storage and fetch is possible while allowing future format extensions.varregion
parent
ab1474b5de
commit
7fa64cce7d
|
@ -576,7 +576,7 @@ ELSE
|
||||||
/// <param name="regionID">regionID.</param>
|
/// <param name="regionID">regionID.</param>
|
||||||
public void StoreTerrain(double[,] terrain, UUID regionID)
|
public void StoreTerrain(double[,] terrain, UUID regionID)
|
||||||
{
|
{
|
||||||
int revision = Util.UnixTimeSinceEpoch();
|
int revision = (int)DBTerrainRevision.Legacy256;
|
||||||
|
|
||||||
//Delete old terrain map
|
//Delete old terrain map
|
||||||
string sql = "delete from terrain where RegionUUID=@RegionUUID";
|
string sql = "delete from terrain where RegionUUID=@RegionUUID";
|
||||||
|
|
|
@ -575,6 +575,7 @@ namespace OpenSim.Data.MySQL
|
||||||
public void StoreTerrain(double[,] ter, UUID regionID)
|
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||||
{
|
{
|
||||||
m_log.Info("[REGION DB]: Storing terrain");
|
m_log.Info("[REGION DB]: Storing terrain");
|
||||||
|
int revision = (int)DBTerrainRevision.Legacy256;
|
||||||
|
|
||||||
lock (m_dbLock)
|
lock (m_dbLock)
|
||||||
{
|
{
|
||||||
|
@ -589,10 +590,10 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
ExecuteNonQuery(cmd);
|
||||||
|
|
||||||
cmd.CommandText = "insert into terrain (RegionUUID, " +
|
cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)"
|
||||||
"Revision, Heightfield) values (?RegionUUID, " +
|
+ "values (?RegionUUID, ?Revision, ?Heightfield)";
|
||||||
"1, ?Heightfield)";
|
|
||||||
|
|
||||||
|
cmd.Parameters.AddWithValue("Revision", revision);
|
||||||
cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
|
cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
|
||||||
|
|
||||||
ExecuteNonQuery(cmd);
|
ExecuteNonQuery(cmd);
|
||||||
|
|
|
@ -828,22 +828,12 @@ namespace OpenSim.Data.SQLite
|
||||||
{
|
{
|
||||||
lock (ds)
|
lock (ds)
|
||||||
{
|
{
|
||||||
int revision = Util.UnixTimeSinceEpoch();
|
int revision = (int)DBTerrainRevision.Legacy256;
|
||||||
|
|
||||||
// This is added to get rid of the infinitely growing
|
|
||||||
// terrain databases which negatively impact on SQLite
|
|
||||||
// over time. Before reenabling this feature there
|
|
||||||
// needs to be a limitter put on the number of
|
|
||||||
// revisions in the database, as this old
|
|
||||||
// implementation is a DOS attack waiting to happen.
|
|
||||||
|
|
||||||
using (
|
using (
|
||||||
SqliteCommand cmd =
|
SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID", m_conn))
|
||||||
new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision",
|
|
||||||
m_conn))
|
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
|
cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,5 +134,26 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
Dictionary<string, string> GetExtra(UUID regionID);
|
Dictionary<string, string> GetExtra(UUID regionID);
|
||||||
|
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The terrain is stored as a blob in the database with a 'revision' field.
|
||||||
|
// Some implementations of terrain storage would fill the revision field with
|
||||||
|
// the time the terrain was stored. When real revisions were added and this
|
||||||
|
// feature removed, that left some old entries with the time in the revision
|
||||||
|
// field.
|
||||||
|
// Thus, if revision is greater than 'RevisionHigh' then terrain db entry is
|
||||||
|
// left over and it is presumed to be 'Legacy256'.
|
||||||
|
// Numbers are arbitrary and are chosen to to reduce possible mis-interpretation.
|
||||||
|
// If a revision does not match any of these, it is assumed to be Legacy256.
|
||||||
|
public enum DBTerrainRevision
|
||||||
|
{
|
||||||
|
// Terrain is 'double[256,256]'
|
||||||
|
Legacy256 = 11,
|
||||||
|
// Terrain is 'int32, int32, float[,]' where the shorts are X and Y dimensions
|
||||||
|
// The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256.
|
||||||
|
Variable2D = 22,
|
||||||
|
// A revision that is not listed above or any revision greater than this value is 'Legacy256'.
|
||||||
|
RevisionHigh = 1234
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue