aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteRegionData.cs
diff options
context:
space:
mode:
authorJeff Ames2008-05-16 01:22:11 +0000
committerJeff Ames2008-05-16 01:22:11 +0000
commit65c5efe43b68700bad94076d4cd421160203c5de (patch)
tree589b56649ed02f4942671fd6e51c6dc43f682e0d /OpenSim/Data/SQLite/SQLiteRegionData.cs
parentThank you very much, mjm for : (diff)
downloadopensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.zip
opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.tar.gz
opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.tar.bz2
opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.tar.xz
Formatting cleanup.
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteRegionData.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs116
1 files changed, 58 insertions, 58 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index 1b577db..6a16a88 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -90,11 +90,11 @@ namespace OpenSim.Data.SQLite
90 90
91 SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn); 91 SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, m_conn);
92 shapeDa = new SqliteDataAdapter(shapeSelectCmd); 92 shapeDa = new SqliteDataAdapter(shapeSelectCmd);
93 // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); 93 // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa);
94 94
95 SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn); 95 SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, m_conn);
96 itemsDa = new SqliteDataAdapter(itemsSelectCmd); 96 itemsDa = new SqliteDataAdapter(itemsSelectCmd);
97 97
98 SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn); 98 SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, m_conn);
99 terrainDa = new SqliteDataAdapter(terrainSelectCmd); 99 terrainDa = new SqliteDataAdapter(terrainSelectCmd);
100 100
@@ -117,7 +117,7 @@ namespace OpenSim.Data.SQLite
117 117
118 ds.Tables.Add(createShapeTable()); 118 ds.Tables.Add(createShapeTable());
119 setupShapeCommands(shapeDa, m_conn); 119 setupShapeCommands(shapeDa, m_conn);
120 120
121 if (persistPrimInventories) 121 if (persistPrimInventories)
122 { 122 {
123 ds.Tables.Add(createItemsTable()); 123 ds.Tables.Add(createItemsTable());
@@ -183,8 +183,8 @@ namespace OpenSim.Data.SQLite
183 { 183 {
184 foreach (SceneObjectPart prim in obj.Children.Values) 184 foreach (SceneObjectPart prim in obj.Children.Values)
185 { 185 {
186 if ((prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == 0 186 if ((prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == 0
187 && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Temporary) == 0 187 && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Temporary) == 0
188 && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) == 0) 188 && (prim.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) == 0)
189 { 189 {
190 m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); 190 m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
@@ -210,7 +210,7 @@ namespace OpenSim.Data.SQLite
210 public void RemoveObject(LLUUID obj, LLUUID regionUUID) 210 public void RemoveObject(LLUUID obj, LLUUID regionUUID)
211 { 211 {
212 m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); 212 m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID);
213 213
214 DataTable prims = ds.Tables["prims"]; 214 DataTable prims = ds.Tables["prims"];
215 DataTable shapes = ds.Tables["primshapes"]; 215 DataTable shapes = ds.Tables["primshapes"];
216 216
@@ -234,7 +234,7 @@ namespace OpenSim.Data.SQLite
234 } 234 }
235 235
236 // Remove prim row 236 // Remove prim row
237 row.Delete(); 237 row.Delete();
238 } 238 }
239 } 239 }
240 240
@@ -247,11 +247,11 @@ namespace OpenSim.Data.SQLite
247 /// </summary> 247 /// </summary>
248 private void RemoveItems(LLUUID uuid) 248 private void RemoveItems(LLUUID uuid)
249 { 249 {
250 DataTable items = ds.Tables["primitems"]; 250 DataTable items = ds.Tables["primitems"];
251 251
252 String sql = String.Format("primID = '{0}'", uuid); 252 String sql = String.Format("primID = '{0}'", uuid);
253 DataRow[] itemRows = items.Select(sql); 253 DataRow[] itemRows = items.Select(sql);
254 254
255 foreach (DataRow itemRow in itemRows) 255 foreach (DataRow itemRow in itemRows)
256 { 256 {
257 itemRow.Delete(); 257 itemRow.Delete();
@@ -286,7 +286,7 @@ namespace OpenSim.Data.SQLite
286 try 286 try
287 { 287 {
288 SceneObjectPart prim = null; 288 SceneObjectPart prim = null;
289 289
290 string uuid = (string) primRow["UUID"]; 290 string uuid = (string) primRow["UUID"];
291 string objID = (string) primRow["SceneGroupID"]; 291 string objID = (string) primRow["SceneGroupID"];
292 if (uuid == objID) //is new SceneObjectGroup ? 292 if (uuid == objID) //is new SceneObjectGroup ?
@@ -353,25 +353,25 @@ namespace OpenSim.Data.SQLite
353 private void LoadItems(SceneObjectPart prim) 353 private void LoadItems(SceneObjectPart prim)
354 { 354 {
355 //m_log.DebugFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); 355 //m_log.DebugFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID);
356 356
357 DataTable dbItems = ds.Tables["primitems"]; 357 DataTable dbItems = ds.Tables["primitems"];
358 358
359 String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); 359 String sql = String.Format("primID = '{0}'", prim.UUID.ToString());
360 DataRow[] dbItemRows = dbItems.Select(sql); 360 DataRow[] dbItemRows = dbItems.Select(sql);
361 361
362 IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); 362 IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
363 363
364 foreach (DataRow row in dbItemRows) 364 foreach (DataRow row in dbItemRows)
365 { 365 {
366 TaskInventoryItem item = buildItem(row); 366 TaskInventoryItem item = buildItem(row);
367 inventory.Add(item); 367 inventory.Add(item);
368 368
369 //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); 369 //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID);
370 } 370 }
371 371
372 prim.RestoreInventoryItems(inventory); 372 prim.RestoreInventoryItems(inventory);
373 373
374 // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in 374 // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in
375 // every item). This data should really be stored in the prim table itself. 375 // every item). This data should really be stored in the prim table itself.
376 if (dbItemRows.Length > 0) 376 if (dbItemRows.Length > 0)
377 { 377 {
@@ -548,12 +548,12 @@ namespace OpenSim.Data.SQLite
548 { 548 {
549 primDa.Update(ds, "prims"); 549 primDa.Update(ds, "prims");
550 shapeDa.Update(ds, "primshapes"); 550 shapeDa.Update(ds, "primshapes");
551 551
552 if (persistPrimInventories) 552 if (persistPrimInventories)
553 { 553 {
554 itemsDa.Update(ds, "primitems"); 554 itemsDa.Update(ds, "primitems");
555 } 555 }
556 556
557 terrainDa.Update(ds, "terrain"); 557 terrainDa.Update(ds, "terrain");
558 landDa.Update(ds, "land"); 558 landDa.Update(ds, "land");
559 landAccessListDa.Update(ds, "landaccesslist"); 559 landAccessListDa.Update(ds, "landaccesslist");
@@ -569,7 +569,7 @@ namespace OpenSim.Data.SQLite
569 /*********************************************************************** 569 /***********************************************************************
570 * 570 *
571 * Database Definition Functions 571 * Database Definition Functions
572 * 572 *
573 * This should be db agnostic as we define them in ADO.NET terms 573 * This should be db agnostic as we define them in ADO.NET terms
574 * 574 *
575 **********************************************************************/ 575 **********************************************************************/
@@ -705,8 +705,8 @@ namespace OpenSim.Data.SQLite
705 createCol(items, "primID", typeof (String)); 705 createCol(items, "primID", typeof (String));
706 createCol(items, "assetID", typeof (String)); 706 createCol(items, "assetID", typeof (String));
707 createCol(items, "parentFolderID", typeof (String)); 707 createCol(items, "parentFolderID", typeof (String));
708 708
709 createCol(items, "invType", typeof (Int32)); 709 createCol(items, "invType", typeof (Int32));
710 createCol(items, "assetType", typeof (Int32)); 710 createCol(items, "assetType", typeof (Int32));
711 711
712 createCol(items, "name", typeof (String)); 712 createCol(items, "name", typeof (String));
@@ -784,7 +784,7 @@ namespace OpenSim.Data.SQLite
784 } 784 }
785 785
786 /*********************************************************************** 786 /***********************************************************************
787 * 787 *
788 * Convert between ADO.NET <=> OpenSim Objects 788 * Convert between ADO.NET <=> OpenSim Objects
789 * 789 *
790 * These should be database independant 790 * These should be database independant
@@ -897,7 +897,7 @@ namespace OpenSim.Data.SQLite
897 897
898 return prim; 898 return prim;
899 } 899 }
900 900
901 /// <summary> 901 /// <summary>
902 /// Build a prim inventory item from the persisted data. 902 /// Build a prim inventory item from the persisted data.
903 /// </summary> 903 /// </summary>
@@ -906,15 +906,15 @@ namespace OpenSim.Data.SQLite
906 private static TaskInventoryItem buildItem(DataRow row) 906 private static TaskInventoryItem buildItem(DataRow row)
907 { 907 {
908 TaskInventoryItem taskItem = new TaskInventoryItem(); 908 TaskInventoryItem taskItem = new TaskInventoryItem();
909 909
910 taskItem.ItemID = new LLUUID((String)row["itemID"]); 910 taskItem.ItemID = new LLUUID((String)row["itemID"]);
911 taskItem.ParentPartID = new LLUUID((String)row["primID"]); 911 taskItem.ParentPartID = new LLUUID((String)row["primID"]);
912 taskItem.AssetID = new LLUUID((String)row["assetID"]); 912 taskItem.AssetID = new LLUUID((String)row["assetID"]);
913 taskItem.ParentID = new LLUUID((String)row["parentFolderID"]); 913 taskItem.ParentID = new LLUUID((String)row["parentFolderID"]);
914 914
915 taskItem.InvType = Convert.ToInt32(row["invType"]); 915 taskItem.InvType = Convert.ToInt32(row["invType"]);
916 taskItem.Type = Convert.ToInt32(row["assetType"]); 916 taskItem.Type = Convert.ToInt32(row["assetType"]);
917 917
918 taskItem.Name = (String)row["name"]; 918 taskItem.Name = (String)row["name"];
919 taskItem.Description = (String)row["description"]; 919 taskItem.Description = (String)row["description"];
920 taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); 920 taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]);
@@ -922,13 +922,13 @@ namespace OpenSim.Data.SQLite
922 taskItem.OwnerID = new LLUUID((String)row["ownerID"]); 922 taskItem.OwnerID = new LLUUID((String)row["ownerID"]);
923 taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]); 923 taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]);
924 taskItem.GroupID = new LLUUID((String)row["groupID"]); 924 taskItem.GroupID = new LLUUID((String)row["groupID"]);
925 925
926 taskItem.NextOwnerMask = Convert.ToUInt32(row["nextPermissions"]); 926 taskItem.NextOwnerMask = Convert.ToUInt32(row["nextPermissions"]);
927 taskItem.OwnerMask = Convert.ToUInt32(row["currentPermissions"]); 927 taskItem.OwnerMask = Convert.ToUInt32(row["currentPermissions"]);
928 taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]); 928 taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]);
929 taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]); 929 taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]);
930 taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]); 930 taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]);
931 931
932 return taskItem; 932 return taskItem;
933 } 933 }
934 934
@@ -990,14 +990,14 @@ namespace OpenSim.Data.SQLite
990 cmd.ExecuteNonQuery(); 990 cmd.ExecuteNonQuery();
991 m_conn.Close(); 991 m_conn.Close();
992 m_conn.Dispose(); 992 m_conn.Dispose();
993 993
994 m_log.Error("[REGION DB]: The land table was recently updated. You need to restart the simulator. Exiting now."); 994 m_log.Error("[REGION DB]: The land table was recently updated. You need to restart the simulator. Exiting now.");
995 995
996 Thread.Sleep(10000); 996 Thread.Sleep(10000);
997 997
998 // ICK! but it's better then A thousand red SQLITE error messages! 998 // ICK! but it's better then A thousand red SQLITE error messages!
999 Environment.Exit(0); 999 Environment.Exit(0);
1000 1000
1001 } 1001 }
1002 catch (Exception) 1002 catch (Exception)
1003 { 1003 {
@@ -1006,7 +1006,7 @@ namespace OpenSim.Data.SQLite
1006 Environment.Exit(0); 1006 Environment.Exit(0);
1007 } 1007 }
1008 } 1008 }
1009 1009
1010 return newData; 1010 return newData;
1011 } 1011 }
1012 1012
@@ -1107,17 +1107,17 @@ namespace OpenSim.Data.SQLite
1107 row["SitTargetOrientY"] = sitTargetOrient.Y; 1107 row["SitTargetOrientY"] = sitTargetOrient.Y;
1108 row["SitTargetOrientZ"] = sitTargetOrient.Z; 1108 row["SitTargetOrientZ"] = sitTargetOrient.Z;
1109 } 1109 }
1110 1110
1111 private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) 1111 private static void fillItemRow(DataRow row, TaskInventoryItem taskItem)
1112 { 1112 {
1113 row["itemID"] = taskItem.ItemID; 1113 row["itemID"] = taskItem.ItemID;
1114 row["primID"] = taskItem.ParentPartID; 1114 row["primID"] = taskItem.ParentPartID;
1115 row["assetID"] = taskItem.AssetID; 1115 row["assetID"] = taskItem.AssetID;
1116 row["parentFolderID"] = taskItem.ParentID; 1116 row["parentFolderID"] = taskItem.ParentID;
1117 1117
1118 row["invType"] = taskItem.InvType; 1118 row["invType"] = taskItem.InvType;
1119 row["assetType"] = taskItem.Type; 1119 row["assetType"] = taskItem.Type;
1120 1120
1121 row["name"] = taskItem.Name; 1121 row["name"] = taskItem.Name;
1122 row["description"] = taskItem.Description; 1122 row["description"] = taskItem.Description;
1123 row["creationDate"] = taskItem.CreationDate; 1123 row["creationDate"] = taskItem.CreationDate;
@@ -1294,37 +1294,37 @@ namespace OpenSim.Data.SQLite
1294 fillShapeRow(shapeRow, prim); 1294 fillShapeRow(shapeRow, prim);
1295 } 1295 }
1296 } 1296 }
1297 1297
1298 // see IRegionDatastore 1298 // see IRegionDatastore
1299 public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items) 1299 public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items)
1300 { 1300 {
1301 if (!persistPrimInventories) 1301 if (!persistPrimInventories)
1302 return; 1302 return;
1303 1303
1304 m_log.InfoFormat("[REGION DB]: Entered StorePrimInventory with prim ID {0}", primID); 1304 m_log.InfoFormat("[REGION DB]: Entered StorePrimInventory with prim ID {0}", primID);
1305 1305
1306 DataTable dbItems = ds.Tables["primitems"]; 1306 DataTable dbItems = ds.Tables["primitems"];
1307 1307
1308 // For now, we're just going to crudely remove all the previous inventory items 1308 // For now, we're just going to crudely remove all the previous inventory items
1309 // no matter whether they have changed or not, and replace them with the current set. 1309 // no matter whether they have changed or not, and replace them with the current set.
1310 lock (ds) 1310 lock (ds)
1311 { 1311 {
1312 RemoveItems(primID); 1312 RemoveItems(primID);
1313 1313
1314 // repalce with current inventory details 1314 // repalce with current inventory details
1315 foreach (TaskInventoryItem newItem in items) 1315 foreach (TaskInventoryItem newItem in items)
1316 { 1316 {
1317// m_log.InfoFormat( 1317// m_log.InfoFormat(
1318// "[DATASTORE]: ", 1318// "[DATASTORE]: ",
1319// "Adding item {0}, {1} to prim ID {2}", 1319// "Adding item {0}, {1} to prim ID {2}",
1320// newItem.Name, newItem.ItemID, newItem.ParentPartID); 1320// newItem.Name, newItem.ItemID, newItem.ParentPartID);
1321 1321
1322 DataRow newItemRow = dbItems.NewRow(); 1322 DataRow newItemRow = dbItems.NewRow();
1323 fillItemRow(newItemRow, newItem); 1323 fillItemRow(newItemRow, newItem);
1324 dbItems.Rows.Add(newItemRow); 1324 dbItems.Rows.Add(newItemRow);
1325 } 1325 }
1326 } 1326 }
1327 1327
1328 Commit(); 1328 Commit();
1329 } 1329 }
1330 1330
@@ -1436,7 +1436,7 @@ namespace OpenSim.Data.SQLite
1436 /// This is a convenience function that collapses 5 repetitive 1436 /// This is a convenience function that collapses 5 repetitive
1437 /// lines for defining SqliteParameters to 2 parameters: 1437 /// lines for defining SqliteParameters to 2 parameters:
1438 /// column name and database type. 1438 /// column name and database type.
1439 /// 1439 ///
1440 /// It assumes certain conventions like :param as the param 1440 /// It assumes certain conventions like :param as the param
1441 /// name to replace in parametrized queries, and that source 1441 /// name to replace in parametrized queries, and that source
1442 /// version is always current version, both of which are fine 1442 /// version is always current version, both of which are fine
@@ -1451,7 +1451,7 @@ namespace OpenSim.Data.SQLite
1451 param.SourceColumn = name; 1451 param.SourceColumn = name;
1452 param.SourceVersion = DataRowVersion.Current; 1452 param.SourceVersion = DataRowVersion.Current;
1453 return param; 1453 return param;
1454 } 1454 }
1455 1455
1456 private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn) 1456 private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn)
1457 { 1457 {
@@ -1466,7 +1466,7 @@ namespace OpenSim.Data.SQLite
1466 delete.Connection = conn; 1466 delete.Connection = conn;
1467 da.DeleteCommand = delete; 1467 da.DeleteCommand = delete;
1468 } 1468 }
1469 1469
1470 private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn) 1470 private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn)
1471 { 1471 {
1472 da.InsertCommand = createInsertCommand("primitems", ds.Tables["primitems"]); 1472 da.InsertCommand = createInsertCommand("primitems", ds.Tables["primitems"]);
@@ -1479,7 +1479,7 @@ namespace OpenSim.Data.SQLite
1479 delete.Parameters.Add(createSqliteParameter("itemID", typeof (String))); 1479 delete.Parameters.Add(createSqliteParameter("itemID", typeof (String)));
1480 delete.Connection = conn; 1480 delete.Connection = conn;
1481 da.DeleteCommand = delete; 1481 da.DeleteCommand = delete;
1482 } 1482 }
1483 1483
1484 private void setupTerrainCommands(SqliteDataAdapter da, SqliteConnection conn) 1484 private void setupTerrainCommands(SqliteDataAdapter da, SqliteConnection conn)
1485 { 1485 {
@@ -1660,7 +1660,7 @@ namespace OpenSim.Data.SQLite
1660 return false; 1660 return false;
1661 } 1661 }
1662 } 1662 }
1663 1663
1664 // XXX primitems should probably go here eventually 1664 // XXX primitems should probably go here eventually
1665 1665
1666 foreach (DataColumn col in createTerrainTable().Columns) 1666 foreach (DataColumn col in createTerrainTable().Columns)