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
fa1c688342
commit
aea5d3a842
|
@ -576,7 +576,7 @@ ELSE
|
|||
/// <param name="regionID">regionID.</param>
|
||||
public void StoreTerrain(double[,] terrain, UUID regionID)
|
||||
{
|
||||
int revision = Util.UnixTimeSinceEpoch();
|
||||
int revision = (int)DBTerrainRevision.Legacy256;
|
||||
|
||||
//Delete old terrain map
|
||||
string sql = "delete from terrain where RegionUUID=@RegionUUID";
|
||||
|
|
|
@ -575,6 +575,7 @@ namespace OpenSim.Data.MySQL
|
|||
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||
{
|
||||
m_log.Info("[REGION DB]: Storing terrain");
|
||||
int revision = (int)DBTerrainRevision.Legacy256;
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
|
@ -589,10 +590,10 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
ExecuteNonQuery(cmd);
|
||||
|
||||
cmd.CommandText = "insert into terrain (RegionUUID, " +
|
||||
"Revision, Heightfield) values (?RegionUUID, " +
|
||||
"1, ?Heightfield)";
|
||||
cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)"
|
||||
+ "values (?RegionUUID, ?Revision, ?Heightfield)";
|
||||
|
||||
cmd.Parameters.AddWithValue("Revision", revision);
|
||||
cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
|
|
|
@ -828,22 +828,12 @@ namespace OpenSim.Data.SQLite
|
|||
{
|
||||
lock (ds)
|
||||
{
|
||||
int revision = Util.UnixTimeSinceEpoch();
|
||||
|
||||
// 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.
|
||||
int revision = (int)DBTerrainRevision.Legacy256;
|
||||
|
||||
using (
|
||||
SqliteCommand cmd =
|
||||
new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision",
|
||||
m_conn))
|
||||
SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID", m_conn))
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
|
||||
cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
|
|
@ -135,4 +135,25 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
|
||||
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