diff options
Diffstat (limited to 'OpenSim/Region/Storage')
-rw-r--r-- | OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index 005da7a..f2c7daa 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | |||
@@ -21,12 +21,11 @@ using Mono.Data.SqliteClient; | |||
21 | 21 | ||
22 | namespace OpenSim.DataStore.MonoSqliteStorage | 22 | namespace OpenSim.DataStore.MonoSqliteStorage |
23 | { | 23 | { |
24 | |||
25 | public class MonoSqliteDataStore : IRegionDataStore | 24 | public class MonoSqliteDataStore : IRegionDataStore |
26 | { | 25 | { |
27 | private const string primSelect = "select * from prims"; | 26 | private const string primSelect = "select * from prims"; |
28 | private const string shapeSelect = "select * from primshapes"; | 27 | private const string shapeSelect = "select * from primshapes"; |
29 | 28 | ||
30 | private DataSet ds; | 29 | private DataSet ds; |
31 | private SqliteDataAdapter primDa; | 30 | private SqliteDataAdapter primDa; |
32 | private SqliteDataAdapter shapeDa; | 31 | private SqliteDataAdapter shapeDa; |
@@ -76,7 +75,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
76 | { | 75 | { |
77 | foreach (SceneObjectPart prim in obj.Children.Values) | 76 | foreach (SceneObjectPart prim in obj.Children.Values) |
78 | { | 77 | { |
79 | addPrim(prim, obj.UUID); | 78 | addPrim(prim, obj.UUID, regionUUID); |
80 | } | 79 | } |
81 | 80 | ||
82 | // MainLog.Instance.Verbose("Attempting to do database update...."); | 81 | // MainLog.Instance.Verbose("Attempting to do database update...."); |
@@ -84,7 +83,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
84 | shapeDa.Update(ds, "primshapes"); | 83 | shapeDa.Update(ds, "primshapes"); |
85 | // MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); | 84 | // MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); |
86 | } | 85 | } |
87 | 86 | ||
88 | public void RemoveObject(LLUUID obj, LLUUID regionUUID) | 87 | public void RemoveObject(LLUUID obj, LLUUID regionUUID) |
89 | { | 88 | { |
90 | DataTable prims = ds.Tables["prims"]; | 89 | DataTable prims = ds.Tables["prims"]; |
@@ -115,7 +114,8 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
115 | DataTable prims = ds.Tables["prims"]; | 114 | DataTable prims = ds.Tables["prims"]; |
116 | DataTable shapes = ds.Tables["primshapes"]; | 115 | DataTable shapes = ds.Tables["primshapes"]; |
117 | 116 | ||
118 | foreach (DataRow primRow in prims.Rows) | 117 | string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'"; |
118 | foreach (DataRow primRow in prims.Select(byRegion)) | ||
119 | { | 119 | { |
120 | string uuid = (string)primRow["UUID"]; | 120 | string uuid = (string)primRow["UUID"]; |
121 | string objID = (string)primRow["SceneGroupID"]; | 121 | string objID = (string)primRow["SceneGroupID"]; |
@@ -191,42 +191,42 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
191 | // TODO: DataSet commit | 191 | // TODO: DataSet commit |
192 | } | 192 | } |
193 | 193 | ||
194 | public class TextureBlock | 194 | // public class TextureBlock |
195 | { | 195 | // { |
196 | public byte[] TextureData; | 196 | // public byte[] TextureData; |
197 | public byte[] ExtraParams = new byte[1]; | 197 | // public byte[] ExtraParams = new byte[1]; |
198 | 198 | ||
199 | public TextureBlock(byte[] data) | 199 | // public TextureBlock(byte[] data) |
200 | { | 200 | // { |
201 | TextureData = data; | 201 | // TextureData = data; |
202 | } | 202 | // } |
203 | 203 | ||
204 | public TextureBlock() | 204 | // public TextureBlock() |
205 | { | 205 | // { |
206 | 206 | ||
207 | } | 207 | // } |
208 | 208 | ||
209 | public string ToXMLString() | 209 | // public string ToXMLString() |
210 | { | 210 | // { |
211 | StringWriter sw = new StringWriter(); | 211 | // StringWriter sw = new StringWriter(); |
212 | XmlTextWriter writer = new XmlTextWriter(sw); | 212 | // XmlTextWriter writer = new XmlTextWriter(sw); |
213 | XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock)); | 213 | // XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock)); |
214 | serializer.Serialize(writer, this); | 214 | // serializer.Serialize(writer, this); |
215 | return sw.ToString(); | 215 | // return sw.ToString(); |
216 | } | 216 | // } |
217 | 217 | ||
218 | public static TextureBlock FromXmlString(string xmlData) | 218 | // public static TextureBlock FromXmlString(string xmlData) |
219 | { | 219 | // { |
220 | TextureBlock textureEntry = null; | 220 | // TextureBlock textureEntry = null; |
221 | StringReader sr = new StringReader(xmlData); | 221 | // StringReader sr = new StringReader(xmlData); |
222 | XmlTextReader reader = new XmlTextReader(sr); | 222 | // XmlTextReader reader = new XmlTextReader(sr); |
223 | XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock)); | 223 | // XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock)); |
224 | textureEntry = (TextureBlock)serializer.Deserialize(reader); | 224 | // textureEntry = (TextureBlock)serializer.Deserialize(reader); |
225 | reader.Close(); | 225 | // reader.Close(); |
226 | sr.Close(); | 226 | // sr.Close(); |
227 | return textureEntry; | 227 | // return textureEntry; |
228 | } | 228 | // } |
229 | } | 229 | // } |
230 | 230 | ||
231 | /*********************************************************************** | 231 | /*********************************************************************** |
232 | * | 232 | * |
@@ -247,6 +247,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
247 | DataTable prims = new DataTable("prims"); | 247 | DataTable prims = new DataTable("prims"); |
248 | 248 | ||
249 | createCol(prims, "UUID", typeof(System.String)); | 249 | createCol(prims, "UUID", typeof(System.String)); |
250 | createCol(prims, "RegionUUID", typeof(System.String)); | ||
250 | createCol(prims, "ParentID", typeof(System.Int32)); | 251 | createCol(prims, "ParentID", typeof(System.Int32)); |
251 | createCol(prims, "CreationDate", typeof(System.Int32)); | 252 | createCol(prims, "CreationDate", typeof(System.Int32)); |
252 | createCol(prims, "Name", typeof(System.String)); | 253 | createCol(prims, "Name", typeof(System.String)); |
@@ -407,9 +408,10 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
407 | return prim; | 408 | return prim; |
408 | } | 409 | } |
409 | 410 | ||
410 | private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID) | 411 | private void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) |
411 | { | 412 | { |
412 | row["UUID"] = prim.UUID; | 413 | row["UUID"] = prim.UUID; |
414 | row["RegionUUID"] = regionUUID; | ||
413 | row["ParentID"] = prim.ParentID; | 415 | row["ParentID"] = prim.ParentID; |
414 | row["CreationDate"] = prim.CreationDate; | 416 | row["CreationDate"] = prim.CreationDate; |
415 | row["Name"] = prim.Name; | 417 | row["Name"] = prim.Name; |
@@ -500,10 +502,10 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
500 | // s.TextureEntry = textureEntry.TextureData; | 502 | // s.TextureEntry = textureEntry.TextureData; |
501 | // s.ExtraParams = textureEntry.ExtraParams; | 503 | // s.ExtraParams = textureEntry.ExtraParams; |
502 | // } | 504 | // } |
503 | 505 | ||
504 | return s; | 506 | return s; |
505 | } | 507 | } |
506 | 508 | ||
507 | private void fillShapeRow(DataRow row, SceneObjectPart prim) | 509 | private void fillShapeRow(DataRow row, SceneObjectPart prim) |
508 | { | 510 | { |
509 | PrimitiveBaseShape s = prim.Shape; | 511 | PrimitiveBaseShape s = prim.Shape; |
@@ -553,21 +555,21 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
553 | // row["Texture"] = encoding.GetBytes(textureBlock.ToXMLString()); | 555 | // row["Texture"] = encoding.GetBytes(textureBlock.ToXMLString()); |
554 | } | 556 | } |
555 | 557 | ||
556 | private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID) | 558 | private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) |
557 | { | 559 | { |
558 | DataTable prims = ds.Tables["prims"]; | 560 | DataTable prims = ds.Tables["prims"]; |
559 | DataTable shapes = ds.Tables["primshapes"]; | 561 | DataTable shapes = ds.Tables["primshapes"]; |
560 | 562 | ||
561 | DataRow primRow = prims.Rows.Find(prim.UUID); | 563 | DataRow primRow = prims.Rows.Find(prim.UUID); |
562 | if (primRow == null) | 564 | if (primRow == null) |
563 | { | 565 | { |
564 | primRow = prims.NewRow(); | 566 | primRow = prims.NewRow(); |
565 | fillPrimRow(primRow, prim, sceneGroupID); | 567 | fillPrimRow(primRow, prim, sceneGroupID, regionUUID); |
566 | prims.Rows.Add(primRow); | 568 | prims.Rows.Add(primRow); |
567 | } | 569 | } |
568 | else | 570 | else |
569 | { | 571 | { |
570 | fillPrimRow(primRow, prim, sceneGroupID); | 572 | fillPrimRow(primRow, prim, sceneGroupID, regionUUID); |
571 | } | 573 | } |
572 | 574 | ||
573 | DataRow shapeRow = shapes.Rows.Find(prim.UUID); | 575 | DataRow shapeRow = shapes.Rows.Find(prim.UUID); |