aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs10
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs190
2 files changed, 118 insertions, 82 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index cb6355f..75fdccf 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -363,7 +363,10 @@ namespace OpenSim.Region.Environment.Scenes
363 /// </summary> 363 /// </summary>
364 public void ScheduleFullUpdate() 364 public void ScheduleFullUpdate()
365 { 365 {
366 m_parentGroup.HasChanged = true; 366 if (m_parentGroup != null)
367 {
368 m_parentGroup.HasChanged = true;
369 }
367 m_updateFlag = 2; 370 m_updateFlag = 2;
368 } 371 }
369 372
@@ -374,7 +377,10 @@ namespace OpenSim.Region.Environment.Scenes
374 { 377 {
375 if (m_updateFlag < 1) 378 if (m_updateFlag < 1)
376 { 379 {
377 m_parentGroup.HasChanged = true; 380 if (m_parentGroup != null)
381 {
382 m_parentGroup.HasChanged = true;
383 }
378 m_updateFlag = 1; 384 m_updateFlag = 1;
379 } 385 }
380 } 386 }
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
index 86df632..ab7bda8 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
@@ -25,7 +25,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
25 { 25 {
26 private const string primSelect = "select * from prims"; 26 private const string primSelect = "select * from prims";
27 private const string shapeSelect = "select * from primshapes"; 27 private const string shapeSelect = "select * from primshapes";
28 28
29 private DataSet ds; 29 private DataSet ds;
30 private SqliteDataAdapter primDa; 30 private SqliteDataAdapter primDa;
31 private SqliteDataAdapter shapeDa; 31 private SqliteDataAdapter shapeDa;
@@ -38,7 +38,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
38 public void Initialise(string dbfile, string dbname) 38 public void Initialise(string dbfile, string dbname)
39 { 39 {
40 string connectionString = "URI=file:" + dbfile + ",version=3"; 40 string connectionString = "URI=file:" + dbfile + ",version=3";
41 41
42 ds = new DataSet(); 42 ds = new DataSet();
43 43
44 MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + dbfile); 44 MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + dbfile);
@@ -89,14 +89,14 @@ namespace OpenSim.DataStore.MonoSqliteStorage
89 MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); 89 MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID);
90 addPrim(prim, obj.UUID, regionUUID); 90 addPrim(prim, obj.UUID, regionUUID);
91 } 91 }
92 92
93 // MainLog.Instance.Verbose("Attempting to do database update...."); 93 // MainLog.Instance.Verbose("Attempting to do database update....");
94 primDa.Update(ds, "prims"); 94 primDa.Update(ds, "prims");
95 shapeDa.Update(ds, "primshapes"); 95 shapeDa.Update(ds, "primshapes");
96 ds.AcceptChanges(); 96 ds.AcceptChanges();
97 // MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); 97 // MainLog.Instance.Verbose("Dump of prims:", ds.GetXml());
98 } 98 }
99 99
100 public void RemoveObject(LLUUID obj, LLUUID regionUUID) 100 public void RemoveObject(LLUUID obj, LLUUID regionUUID)
101 { 101 {
102 DataTable prims = ds.Tables["prims"]; 102 DataTable prims = ds.Tables["prims"];
@@ -122,20 +122,21 @@ namespace OpenSim.DataStore.MonoSqliteStorage
122 public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID) 122 public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID)
123 { 123 {
124 Dictionary<LLUUID, SceneObjectGroup> createdObjects = new Dictionary<LLUUID, SceneObjectGroup>(); 124 Dictionary<LLUUID, SceneObjectGroup> createdObjects = new Dictionary<LLUUID, SceneObjectGroup>();
125 125
126 List<SceneObjectGroup> retvals = new List<SceneObjectGroup>(); 126 List<SceneObjectGroup> retvals = new List<SceneObjectGroup>();
127 127
128 DataTable prims = ds.Tables["prims"]; 128 DataTable prims = ds.Tables["prims"];
129 DataTable shapes = ds.Tables["primshapes"]; 129 DataTable shapes = ds.Tables["primshapes"];
130 130
131 string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'"; 131 string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'";
132 string orderByParent = "ParentID ASC"; 132 string orderByParent = "ParentID ASC";
133 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); 133 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent);
134 MainLog.Instance.Verbose("DATASTORE", "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); 134 MainLog.Instance.Verbose("DATASTORE", "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
135 135
136 foreach (DataRow primRow in primsForRegion) 136 foreach (DataRow primRow in primsForRegion)
137 { 137 {
138 try { 138 try
139 {
139 string uuid = (string)primRow["UUID"]; 140 string uuid = (string)primRow["UUID"];
140 string objID = (string)primRow["SceneGroupID"]; 141 string objID = (string)primRow["SceneGroupID"];
141 if (uuid == objID) //is new SceneObjectGroup ? 142 if (uuid == objID) //is new SceneObjectGroup ?
@@ -154,7 +155,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
154 } 155 }
155 group.AddPart(prim); 156 group.AddPart(prim);
156 group.RootPart = prim; 157 group.RootPart = prim;
157 158
158 createdObjects.Add(group.UUID, group); 159 createdObjects.Add(group.UUID, group);
159 retvals.Add(group); 160 retvals.Add(group);
160 } 161 }
@@ -173,14 +174,17 @@ namespace OpenSim.DataStore.MonoSqliteStorage
173 } 174 }
174 createdObjects[new LLUUID(objID)].AddPart(prim); 175 createdObjects[new LLUUID(objID)].AddPart(prim);
175 } 176 }
176 } catch(Exception) { 177 }
177 foreach (DataColumn col in prims.Columns) { 178 catch (Exception)
179 {
180 foreach (DataColumn col in prims.Columns)
181 {
178 MainLog.Instance.Verbose("Col: " + col.ColumnName + " => " + primRow[col]); 182 MainLog.Instance.Verbose("Col: " + col.ColumnName + " => " + primRow[col]);
179 } 183 }
180 } 184 }
181 } 185 }
182 MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " primitives"); 186 MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " primitives");
183 187 MainLog.Instance.Verbose("DATASTORE", "Sqlite - Number of sceneObjects" + retvals.Count);
184 return retvals; 188 return retvals;
185 } 189 }
186 190
@@ -214,42 +218,42 @@ namespace OpenSim.DataStore.MonoSqliteStorage
214 // TODO: DataSet commit 218 // TODO: DataSet commit
215 } 219 }
216 220
217// public class TextureBlock 221 // public class TextureBlock
218// { 222 // {
219// public byte[] TextureData; 223 // public byte[] TextureData;
220// public byte[] ExtraParams = new byte[1]; 224 // public byte[] ExtraParams = new byte[1];
221 225
222// public TextureBlock(byte[] data) 226 // public TextureBlock(byte[] data)
223// { 227 // {
224// TextureData = data; 228 // TextureData = data;
225// } 229 // }
226 230
227// public TextureBlock() 231 // public TextureBlock()
228// { 232 // {
229 233
230// } 234 // }
231 235
232// public string ToXMLString() 236 // public string ToXMLString()
233// { 237 // {
234// StringWriter sw = new StringWriter(); 238 // StringWriter sw = new StringWriter();
235// XmlTextWriter writer = new XmlTextWriter(sw); 239 // XmlTextWriter writer = new XmlTextWriter(sw);
236// XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock)); 240 // XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock));
237// serializer.Serialize(writer, this); 241 // serializer.Serialize(writer, this);
238// return sw.ToString(); 242 // return sw.ToString();
239// } 243 // }
240 244
241// public static TextureBlock FromXmlString(string xmlData) 245 // public static TextureBlock FromXmlString(string xmlData)
242// { 246 // {
243// TextureBlock textureEntry = null; 247 // TextureBlock textureEntry = null;
244// StringReader sr = new StringReader(xmlData); 248 // StringReader sr = new StringReader(xmlData);
245// XmlTextReader reader = new XmlTextReader(sr); 249 // XmlTextReader reader = new XmlTextReader(sr);
246// XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock)); 250 // XmlSerializer serializer = new XmlSerializer(typeof(TextureBlock));
247// textureEntry = (TextureBlock)serializer.Deserialize(reader); 251 // textureEntry = (TextureBlock)serializer.Deserialize(reader);
248// reader.Close(); 252 // reader.Close();
249// sr.Close(); 253 // sr.Close();
250// return textureEntry; 254 // return textureEntry;
251// } 255 // }
252// } 256 // }
253 257
254 /*********************************************************************** 258 /***********************************************************************
255 * 259 *
@@ -258,7 +262,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
258 * This should be db agnostic as we define them in ADO.NET terms 262 * This should be db agnostic as we define them in ADO.NET terms
259 * 263 *
260 **********************************************************************/ 264 **********************************************************************/
261 265
262 private void createCol(DataTable dt, string name, System.Type type) 266 private void createCol(DataTable dt, string name, System.Type type)
263 { 267 {
264 DataColumn col = new DataColumn(name, type); 268 DataColumn col = new DataColumn(name, type);
@@ -312,7 +316,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
312 createCol(prims, "RotationY", typeof(System.Double)); 316 createCol(prims, "RotationY", typeof(System.Double));
313 createCol(prims, "RotationZ", typeof(System.Double)); 317 createCol(prims, "RotationZ", typeof(System.Double));
314 createCol(prims, "RotationW", typeof(System.Double)); 318 createCol(prims, "RotationW", typeof(System.Double));
315 319
316 // Add in contraints 320 // Add in contraints
317 prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; 321 prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] };
318 322
@@ -359,7 +363,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
359 363
360 return shapes; 364 return shapes;
361 } 365 }
362 366
363 /*********************************************************************** 367 /***********************************************************************
364 * 368 *
365 * Convert between ADO.NET <=> OpenSim Objects 369 * Convert between ADO.NET <=> OpenSim Objects
@@ -528,10 +532,10 @@ namespace OpenSim.DataStore.MonoSqliteStorage
528 // s.TextureEntry = textureEntry.TextureData; 532 // s.TextureEntry = textureEntry.TextureData;
529 // s.ExtraParams = textureEntry.ExtraParams; 533 // s.ExtraParams = textureEntry.ExtraParams;
530 // } 534 // }
531 535
532 return s; 536 return s;
533 } 537 }
534 538
535 private void fillShapeRow(DataRow row, SceneObjectPart prim) 539 private void fillShapeRow(DataRow row, SceneObjectPart prim)
536 { 540 {
537 PrimitiveBaseShape s = prim.Shape; 541 PrimitiveBaseShape s = prim.Shape;
@@ -585,7 +589,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
585 { 589 {
586 DataTable prims = ds.Tables["prims"]; 590 DataTable prims = ds.Tables["prims"];
587 DataTable shapes = ds.Tables["primshapes"]; 591 DataTable shapes = ds.Tables["primshapes"];
588 592
589 DataRow primRow = prims.Rows.Find(prim.UUID); 593 DataRow primRow = prims.Rows.Find(prim.UUID);
590 if (primRow == null) 594 if (primRow == null)
591 { 595 {
@@ -610,7 +614,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
610 fillShapeRow(shapeRow, prim); 614 fillShapeRow(shapeRow, prim);
611 } 615 }
612 } 616 }
613 617
614 /*********************************************************************** 618 /***********************************************************************
615 * 619 *
616 * SQL Statement Creation Functions 620 * SQL Statement Creation Functions
@@ -633,7 +637,8 @@ namespace OpenSim.DataStore.MonoSqliteStorage
633 * generate these strings instead of typing them out. 637 * generate these strings instead of typing them out.
634 */ 638 */
635 string[] cols = new string[dt.Columns.Count]; 639 string[] cols = new string[dt.Columns.Count];
636 for (int i = 0; i < dt.Columns.Count; i++) { 640 for (int i = 0; i < dt.Columns.Count; i++)
641 {
637 DataColumn col = dt.Columns[i]; 642 DataColumn col = dt.Columns[i];
638 cols[i] = col.ColumnName; 643 cols[i] = col.ColumnName;
639 } 644 }
@@ -648,7 +653,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
648 653
649 // this provides the binding for all our parameters, so 654 // this provides the binding for all our parameters, so
650 // much less code than it used to be 655 // much less code than it used to be
651 foreach (DataColumn col in dt.Columns) 656 foreach (DataColumn col in dt.Columns)
652 { 657 {
653 cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); 658 cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
654 } 659 }
@@ -674,7 +679,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
674 // this provides the binding for all our parameters, so 679 // this provides the binding for all our parameters, so
675 // much less code than it used to be 680 // much less code than it used to be
676 681
677 foreach (DataColumn col in dt.Columns) 682 foreach (DataColumn col in dt.Columns)
678 { 683 {
679 cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); 684 cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
680 } 685 }
@@ -693,7 +698,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
693 subsql += ",\n"; 698 subsql += ",\n";
694 } 699 }
695 subsql += col.ColumnName + " " + sqliteType(col.DataType); 700 subsql += col.ColumnName + " " + sqliteType(col.DataType);
696 if(col == dt.PrimaryKey[0]) 701 if (col == dt.PrimaryKey[0])
697 { 702 {
698 subsql += " primary key"; 703 subsql += " primary key";
699 } 704 }
@@ -746,7 +751,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage
746 delete.Connection = conn; 751 delete.Connection = conn;
747 da.DeleteCommand = delete; 752 da.DeleteCommand = delete;
748 } 753 }
749 754
750 private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) 755 private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn)
751 { 756 {
752 da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); 757 da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]);
@@ -765,13 +770,13 @@ namespace OpenSim.DataStore.MonoSqliteStorage
765 { 770 {
766 string createPrims = defineTable(createPrimTable()); 771 string createPrims = defineTable(createPrimTable());
767 string createShapes = defineTable(createShapeTable()); 772 string createShapes = defineTable(createShapeTable());
768 773
769 SqliteCommand pcmd = new SqliteCommand(createPrims, conn); 774 SqliteCommand pcmd = new SqliteCommand(createPrims, conn);
770 SqliteCommand scmd = new SqliteCommand(createShapes, conn); 775 SqliteCommand scmd = new SqliteCommand(createShapes, conn);
771 conn.Open(); 776 conn.Open();
772 pcmd.ExecuteNonQuery(); 777 pcmd.ExecuteNonQuery();
773 scmd.ExecuteNonQuery(); 778 scmd.ExecuteNonQuery();
774 conn.Close(); 779 conn.Close();
775 } 780 }
776 781
777 private bool TestTables(SqliteConnection conn) 782 private bool TestTables(SqliteConnection conn)
@@ -782,10 +787,13 @@ namespace OpenSim.DataStore.MonoSqliteStorage
782 SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd); 787 SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd);
783 788
784 DataSet tmpDS = new DataSet(); 789 DataSet tmpDS = new DataSet();
785 try { 790 try
791 {
786 pDa.Fill(tmpDS, "prims"); 792 pDa.Fill(tmpDS, "prims");
787 sDa.Fill(tmpDS, "primshapes"); 793 sDa.Fill(tmpDS, "primshapes");
788 } catch (Mono.Data.SqliteClient.SqliteSyntaxException) { 794 }
795 catch (Mono.Data.SqliteClient.SqliteSyntaxException)
796 {
789 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); 797 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
790 InitDB(conn); 798 InitDB(conn);
791 } 799 }
@@ -793,14 +801,18 @@ namespace OpenSim.DataStore.MonoSqliteStorage
793 pDa.Fill(tmpDS, "prims"); 801 pDa.Fill(tmpDS, "prims");
794 sDa.Fill(tmpDS, "primshapes"); 802 sDa.Fill(tmpDS, "primshapes");
795 803
796 foreach (DataColumn col in createPrimTable().Columns) { 804 foreach (DataColumn col in createPrimTable().Columns)
797 if (! tmpDS.Tables["prims"].Columns.Contains(col.ColumnName) ) { 805 {
806 if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
807 {
798 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); 808 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName);
799 return false; 809 return false;
800 } 810 }
801 } 811 }
802 foreach (DataColumn col in createShapeTable().Columns) { 812 foreach (DataColumn col in createShapeTable().Columns)
803 if (! tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName) ) { 813 {
814 if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
815 {
804 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); 816 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName);
805 return false; 817 return false;
806 } 818 }
@@ -813,35 +825,53 @@ namespace OpenSim.DataStore.MonoSqliteStorage
813 * Type conversion functions 825 * Type conversion functions
814 * 826 *
815 **********************************************************************/ 827 **********************************************************************/
816 828
817 private DbType dbtypeFromType(Type type) 829 private DbType dbtypeFromType(Type type)
818 { 830 {
819 if (type == typeof(System.String)) { 831 if (type == typeof(System.String))
832 {
820 return DbType.String; 833 return DbType.String;
821 } else if (type == typeof(System.Int32)) { 834 }
835 else if (type == typeof(System.Int32))
836 {
822 return DbType.Int32; 837 return DbType.Int32;
823 } else if (type == typeof(System.Double)) { 838 }
839 else if (type == typeof(System.Double))
840 {
824 return DbType.Double; 841 return DbType.Double;
825 } else if (type == typeof(System.Byte[])) { 842 }
843 else if (type == typeof(System.Byte[]))
844 {
826 return DbType.Binary; 845 return DbType.Binary;
827 } else { 846 }
847 else
848 {
828 return DbType.String; 849 return DbType.String;
829 } 850 }
830 } 851 }
831 852
832 // this is something we'll need to implement for each db 853 // this is something we'll need to implement for each db
833 // slightly differently. 854 // slightly differently.
834 private string sqliteType(Type type) 855 private string sqliteType(Type type)
835 { 856 {
836 if (type == typeof(System.String)) { 857 if (type == typeof(System.String))
858 {
837 return "varchar(255)"; 859 return "varchar(255)";
838 } else if (type == typeof(System.Int32)) { 860 }
861 else if (type == typeof(System.Int32))
862 {
839 return "integer"; 863 return "integer";
840 } else if (type == typeof(System.Double)) { 864 }
865 else if (type == typeof(System.Double))
866 {
841 return "float"; 867 return "float";
842 } else if (type == typeof(System.Byte[])) { 868 }
869 else if (type == typeof(System.Byte[]))
870 {
843 return "blob"; 871 return "blob";
844 } else { 872 }
873 else
874 {
845 return "string"; 875 return "string";
846 } 876 }
847 } 877 }