aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2013-09-24 13:41:44 -0700
committerRobert Adams2013-09-25 17:30:51 -0700
commit7fa64cce7dbf19d8b5886afd58e42be790f12dea (patch)
tree425a4223825f01f5f07be0b304cb7a9a45bc5117 /OpenSim
parentvarregion: go back to using Constants.RegionSize so as not to break (diff)
downloadopensim-SC_OLD-7fa64cce7dbf19d8b5886afd58e42be790f12dea.zip
opensim-SC_OLD-7fa64cce7dbf19d8b5886afd58e42be790f12dea.tar.gz
opensim-SC_OLD-7fa64cce7dbf19d8b5886afd58e42be790f12dea.tar.bz2
opensim-SC_OLD-7fa64cce7dbf19d8b5886afd58e42be790f12dea.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLSimulationData.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs7
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs14
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs21
4 files changed, 28 insertions, 16 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
index f41f60c..8adddc9 100644
--- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
@@ -576,7 +576,7 @@ ELSE
576 /// <param name="regionID">regionID.</param> 576 /// <param name="regionID">regionID.</param>
577 public void StoreTerrain(double[,] terrain, UUID regionID) 577 public void StoreTerrain(double[,] terrain, UUID regionID)
578 { 578 {
579 int revision = Util.UnixTimeSinceEpoch(); 579 int revision = (int)DBTerrainRevision.Legacy256;
580 580
581 //Delete old terrain map 581 //Delete old terrain map
582 string sql = "delete from terrain where RegionUUID=@RegionUUID"; 582 string sql = "delete from terrain where RegionUUID=@RegionUUID";
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index b03a904..5751dc8 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -575,6 +575,7 @@ namespace OpenSim.Data.MySQL
575 public void StoreTerrain(double[,] ter, UUID regionID) 575 public void StoreTerrain(double[,] ter, UUID regionID)
576 { 576 {
577 m_log.Info("[REGION DB]: Storing terrain"); 577 m_log.Info("[REGION DB]: Storing terrain");
578 int revision = (int)DBTerrainRevision.Legacy256;
578 579
579 lock (m_dbLock) 580 lock (m_dbLock)
580 { 581 {
@@ -589,10 +590,10 @@ namespace OpenSim.Data.MySQL
589 590
590 ExecuteNonQuery(cmd); 591 ExecuteNonQuery(cmd);
591 592
592 cmd.CommandText = "insert into terrain (RegionUUID, " + 593 cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)"
593 "Revision, Heightfield) values (?RegionUUID, " + 594 + "values (?RegionUUID, ?Revision, ?Heightfield)";
594 "1, ?Heightfield)";
595 595
596 cmd.Parameters.AddWithValue("Revision", revision);
596 cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); 597 cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
597 598
598 ExecuteNonQuery(cmd); 599 ExecuteNonQuery(cmd);
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index d938b6b..b70af6b 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -828,22 +828,12 @@ namespace OpenSim.Data.SQLite
828 { 828 {
829 lock (ds) 829 lock (ds)
830 { 830 {
831 int revision = Util.UnixTimeSinceEpoch(); 831 int revision = (int)DBTerrainRevision.Legacy256;
832
833 // This is added to get rid of the infinitely growing
834 // terrain databases which negatively impact on SQLite
835 // over time. Before reenabling this feature there
836 // needs to be a limitter put on the number of
837 // revisions in the database, as this old
838 // implementation is a DOS attack waiting to happen.
839 832
840 using ( 833 using (
841 SqliteCommand cmd = 834 SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID", m_conn))
842 new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision",
843 m_conn))
844 { 835 {
845 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); 836 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
846 cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
847 cmd.ExecuteNonQuery(); 837 cmd.ExecuteNonQuery();
848 } 838 }
849 839
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
index 3787ca0..c936a84 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
@@ -134,5 +134,26 @@ namespace OpenSim.Region.Framework.Interfaces
134 Dictionary<string, string> GetExtra(UUID regionID); 134 Dictionary<string, string> GetExtra(UUID regionID);
135 135
136 void Shutdown(); 136 void Shutdown();
137 }
138
139 // The terrain is stored as a blob in the database with a 'revision' field.
140 // Some implementations of terrain storage would fill the revision field with
141 // the time the terrain was stored. When real revisions were added and this
142 // feature removed, that left some old entries with the time in the revision
143 // field.
144 // Thus, if revision is greater than 'RevisionHigh' then terrain db entry is
145 // left over and it is presumed to be 'Legacy256'.
146 // Numbers are arbitrary and are chosen to to reduce possible mis-interpretation.
147 // If a revision does not match any of these, it is assumed to be Legacy256.
148 public enum DBTerrainRevision
149 {
150 // Terrain is 'double[256,256]'
151 Legacy256 = 11,
152 // Terrain is 'int32, int32, float[,]' where the shorts are X and Y dimensions
153 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256.
154 Variable2D = 22,
155 // A revision that is not listed above or any revision greater than this value is 'Legacy256'.
156 RevisionHigh = 1234
137 } 157 }
158
138} 159}