aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs210
1 files changed, 93 insertions, 117 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
index 6971cc8..b6771c7 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
@@ -48,40 +48,41 @@ namespace OpenSim.DataStore.MonoSqlite
48 // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema"); 48 // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema");
49 TestTables(conn); 49 TestTables(conn);
50 50
51 ds.Tables.Add(createPrimTable()); 51 lock(ds) {
52 setupPrimCommands(primDa, conn); 52 ds.Tables.Add(createPrimTable());
53 primDa.Fill(ds.Tables["prims"]); 53 setupPrimCommands(primDa, conn);
54 54 primDa.Fill(ds.Tables["prims"]);
55 ds.Tables.Add(createShapeTable()); 55
56 setupShapeCommands(shapeDa, conn); 56 ds.Tables.Add(createShapeTable());
57 57 setupShapeCommands(shapeDa, conn);
58 // WORKAROUND: This is a work around for sqlite on 58
59 // windows, which gets really unhappy with blob columns 59 // WORKAROUND: This is a work around for sqlite on
60 // that have no sample data in them. At some point we 60 // windows, which gets really unhappy with blob columns
61 // need to actually find a proper way to handle this. 61 // that have no sample data in them. At some point we
62 try 62 // need to actually find a proper way to handle this.
63 { 63 try
64 shapeDa.Fill(ds.Tables["primshapes"]); 64 {
65 } 65 shapeDa.Fill(ds.Tables["primshapes"]);
66 catch (Exception) 66 }
67 { 67 catch (Exception)
68 MainLog.Instance.Verbose("DATASTORE", "Caught fill error on primshapes table"); 68 {
69 MainLog.Instance.Verbose("DATASTORE", "Caught fill error on primshapes table");
70 }
71 return;
69 } 72 }
70 return;
71 } 73 }
72 74
73 public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) 75 public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID)
74 { 76 {
75 foreach (SceneObjectPart prim in obj.Children.Values) 77 lock (ds) {
76 { 78 foreach (SceneObjectPart prim in obj.Children.Values)
77 MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); 79 {
78 addPrim(prim, obj.UUID, regionUUID); 80 MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID);
81 addPrim(prim, obj.UUID, regionUUID);
82 }
79 } 83 }
80 84
81 // MainLog.Instance.Verbose("Attempting to do database update...."); 85 Commit();
82 primDa.Update(ds, "prims");
83 shapeDa.Update(ds, "primshapes");
84 ds.AcceptChanges();
85 // MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); 86 // MainLog.Instance.Verbose("Dump of prims:", ds.GetXml());
86 } 87 }
87 88
@@ -91,20 +92,21 @@ namespace OpenSim.DataStore.MonoSqlite
91 DataTable shapes = ds.Tables["primshapes"]; 92 DataTable shapes = ds.Tables["primshapes"];
92 93
93 string selectExp = "SceneGroupID = '" + obj.ToString() + "'"; 94 string selectExp = "SceneGroupID = '" + obj.ToString() + "'";
94 DataRow[] primRows = prims.Select(selectExp); 95 lock (ds) {
95 foreach (DataRow row in primRows) 96 DataRow[] primRows = prims.Select(selectExp);
96 { 97 foreach (DataRow row in primRows)
97 LLUUID uuid = new LLUUID((string)row["UUID"]);
98 DataRow shapeRow = shapes.Rows.Find(uuid);
99 if (shapeRow != null)
100 { 98 {
101 shapeRow.Delete(); 99 LLUUID uuid = new LLUUID((string)row["UUID"]);
100 DataRow shapeRow = shapes.Rows.Find(uuid);
101 if (shapeRow != null)
102 {
103 shapeRow.Delete();
104 }
105 row.Delete();
102 } 106 }
103 row.Delete();
104 } 107 }
105 108
106 primDa.Update(ds, "prims"); 109 Commit();
107 shapeDa.Update(ds, "primshapes");
108 } 110 }
109 111
110 public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID) 112 public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID)
@@ -118,59 +120,61 @@ namespace OpenSim.DataStore.MonoSqlite
118 120
119 string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'"; 121 string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'";
120 string orderByParent = "ParentID ASC"; 122 string orderByParent = "ParentID ASC";
121 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent);
122 MainLog.Instance.Verbose("DATASTORE", "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
123 123
124 foreach (DataRow primRow in primsForRegion) 124 lock (ds) {
125 { 125 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent);
126 try 126 MainLog.Instance.Verbose("DATASTORE", "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
127
128 foreach (DataRow primRow in primsForRegion)
127 { 129 {
128 string uuid = (string)primRow["UUID"]; 130 try
129 string objID = (string)primRow["SceneGroupID"];
130 if (uuid == objID) //is new SceneObjectGroup ?
131 { 131 {
132 SceneObjectGroup group = new SceneObjectGroup(); 132 string uuid = (string)primRow["UUID"];
133 SceneObjectPart prim = buildPrim(primRow); 133 string objID = (string)primRow["SceneGroupID"];
134 DataRow shapeRow = shapes.Rows.Find(prim.UUID); 134 if (uuid == objID) //is new SceneObjectGroup ?
135 if (shapeRow != null)
136 { 135 {
137 prim.Shape = buildShape(shapeRow); 136 SceneObjectGroup group = new SceneObjectGroup();
137 SceneObjectPart prim = buildPrim(primRow);
138 DataRow shapeRow = shapes.Rows.Find(prim.UUID);
139 if (shapeRow != null)
140 {
141 prim.Shape = buildShape(shapeRow);
142 }
143 else
144 {
145 Console.WriteLine("No shape found for prim in storage, so setting default box shape");
146 prim.Shape = BoxShape.Default;
147 }
148 group.AddPart(prim);
149 group.RootPart = prim;
150
151 createdObjects.Add(group.UUID, group);
152 retvals.Add(group);
138 } 153 }
139 else 154 else
140 { 155 {
141 Console.WriteLine("No shape found for prim in storage, so setting default box shape"); 156 SceneObjectPart prim = buildPrim(primRow);
142 prim.Shape = BoxShape.Default; 157 DataRow shapeRow = shapes.Rows.Find(prim.UUID);
158 if (shapeRow != null)
159 {
160 prim.Shape = buildShape(shapeRow);
161 }
162 else
163 {
164 Console.WriteLine("No shape found for prim in storage, so setting default box shape");
165 prim.Shape = BoxShape.Default;
166 }
167 createdObjects[new LLUUID(objID)].AddPart(prim);
143 } 168 }
144 group.AddPart(prim);
145 group.RootPart = prim;
146
147 createdObjects.Add(group.UUID, group);
148 retvals.Add(group);
149 } 169 }
150 else 170 catch (Exception e)
151 { 171 {
152 SceneObjectPart prim = buildPrim(primRow); 172 MainLog.Instance.Error("DATASTORE", "Failed create prim object, exception and data follows");
153 DataRow shapeRow = shapes.Rows.Find(prim.UUID); 173 MainLog.Instance.Verbose(e.ToString());
154 if (shapeRow != null) 174 foreach (DataColumn col in prims.Columns)
155 { 175 {
156 prim.Shape = buildShape(shapeRow); 176 MainLog.Instance.Verbose("Col: " + col.ColumnName + " => " + primRow[col]);
157 } 177 }
158 else
159 {
160 Console.WriteLine("No shape found for prim in storage, so setting default box shape");
161 prim.Shape = BoxShape.Default;
162 }
163 createdObjects[new LLUUID(objID)].AddPart(prim);
164 }
165 }
166 catch (Exception e)
167 {
168
169 MainLog.Instance.Error("DATASTORE", "Failed create prim object, exception and data follows");
170 MainLog.Instance.Verbose(e.ToString());
171 foreach (DataColumn col in prims.Columns)
172 {
173 MainLog.Instance.Verbose("Col: " + col.ColumnName + " => " + primRow[col]);
174 } 178 }
175 } 179 }
176 } 180 }
@@ -203,47 +207,19 @@ namespace OpenSim.DataStore.MonoSqlite
203 return new List<Land>(); 207 return new List<Land>();
204 } 208 }
205 209
206 public void Shutdown() 210 public void Commit()
207 { 211 {
208 // TODO: DataSet commit 212 lock (ds) {
213 primDa.Update(ds, "prims");
214 shapeDa.Update(ds, "primshapes");
215 ds.AcceptChanges();
216 }
209 } 217 }
210 218
211 // public class TextureBlock 219 public void Shutdown()
212 // { 220 {
213 // public byte[] TextureData; 221 Commit();
214 // public byte[] ExtraParams = new byte[1]; 222 }
215
216 // public TextureBlock(byte[] data)
217 // {
218 // TextureData = data;
219 // }
220
221 // public TextureBlock()
222 // {
223
224 // }
225
226 // public string ToXMLString()
227 // {
228 // StringWriter sw = new StringWriter();
229 // XmlTextWriter writer = new XmlTextWriter(sw);
230 // XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock));
231 // serializer.Serialize(writer, this);
232 // return sw.ToString();
233 // }
234
235 // public static TextureBlock FromXmlString(string xmlData)
236 // {
237 // TextureBlock textureEntry = null;
238 // StringReader sr = new StringReader(xmlData);
239 // XmlTextReader reader = new XmlTextReader(sr);
240 // XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock));
241 // textureEntry = (TextureBlock)serializer.Deserialize(reader);
242 // reader.Close();
243 // sr.Close();
244 // return textureEntry;
245 // }
246 // }
247 223
248 /*********************************************************************** 224 /***********************************************************************
249 * 225 *