aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteRegionData.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-05-07 13:20:29 +0000
committerJustin Clarke Casey2009-05-07 13:20:29 +0000
commite033f4028db387dc7162e8f5ae1abb781dbfb920 (patch)
tree24e0f2583e7943a230397a28a623968fd0e2622d /OpenSim/Data/SQLite/SQLiteRegionData.cs
parentFrom: Alan M Webb <alan_webb@us.ibm.com> (diff)
downloadopensim-SC-e033f4028db387dc7162e8f5ae1abb781dbfb920.zip
opensim-SC-e033f4028db387dc7162e8f5ae1abb781dbfb920.tar.gz
opensim-SC-e033f4028db387dc7162e8f5ae1abb781dbfb920.tar.bz2
opensim-SC-e033f4028db387dc7162e8f5ae1abb781dbfb920.tar.xz
* Consistently use dashed uuid format for sqlite region data, as was previously done for sqlite inventory data.
* This revision contains a data migration. Please backup your sqlite region db as a precaution before using this code * I also advise that you do a runprebuild[.sh|.bat] and a clean build ("nant clean build" if you're using the command line). * This change is needed for future id schemes
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteRegionData.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs73
1 files changed, 35 insertions, 38 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index 2d0f6d8..476d8db 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -321,7 +321,7 @@ namespace OpenSim.Data.SQLite
321 { 321 {
322 //m_log.Info("[DATASTORE]: " + 322 //m_log.Info("[DATASTORE]: " +
323 //"Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); 323 //"Adding stopped obj: " + obj.UUID + " to region: " + regionUUID);
324 //addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); 324 //addPrim(prim, obj.UUID.ToString(), regionUUID.ToString());
325 } 325 }
326 else 326 else
327 { 327 {
@@ -346,7 +346,7 @@ namespace OpenSim.Data.SQLite
346 DataTable prims = ds.Tables["prims"]; 346 DataTable prims = ds.Tables["prims"];
347 DataTable shapes = ds.Tables["primshapes"]; 347 DataTable shapes = ds.Tables["primshapes"];
348 348
349 string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "' and RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; 349 string selectExp = "SceneGroupID = '" + obj + "' and RegionUUID = '" + regionUUID + "'";
350 lock (ds) 350 lock (ds)
351 { 351 {
352 DataRow[] primRows = prims.Select(selectExp); 352 DataRow[] primRows = prims.Select(selectExp);
@@ -354,7 +354,7 @@ namespace OpenSim.Data.SQLite
354 { 354 {
355 // Remove shape rows 355 // Remove shape rows
356 UUID uuid = new UUID((string) row["UUID"]); 356 UUID uuid = new UUID((string) row["UUID"]);
357 DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(uuid)); 357 DataRow shapeRow = shapes.Rows.Find(uuid.ToString());
358 if (shapeRow != null) 358 if (shapeRow != null)
359 { 359 {
360 shapeRow.Delete(); 360 shapeRow.Delete();
@@ -402,7 +402,7 @@ namespace OpenSim.Data.SQLite
402 DataTable prims = ds.Tables["prims"]; 402 DataTable prims = ds.Tables["prims"];
403 DataTable shapes = ds.Tables["primshapes"]; 403 DataTable shapes = ds.Tables["primshapes"];
404 404
405 string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; 405 string byRegion = "RegionUUID = '" + regionUUID + "'";
406 406
407 lock (ds) 407 lock (ds)
408 { 408 {
@@ -423,7 +423,7 @@ namespace OpenSim.Data.SQLite
423 { 423 {
424 SceneObjectGroup group = new SceneObjectGroup(); 424 SceneObjectGroup group = new SceneObjectGroup();
425 prim = buildPrim(primRow); 425 prim = buildPrim(primRow);
426 DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); 426 DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString());
427 if (shapeRow != null) 427 if (shapeRow != null)
428 { 428 {
429 prim.Shape = buildShape(shapeRow); 429 prim.Shape = buildShape(shapeRow);
@@ -464,7 +464,7 @@ namespace OpenSim.Data.SQLite
464 if (uuid != objID) //is new SceneObjectGroup ? 464 if (uuid != objID) //is new SceneObjectGroup ?
465 { 465 {
466 prim = buildPrim(primRow); 466 prim = buildPrim(primRow);
467 DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); 467 DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString());
468 if (shapeRow != null) 468 if (shapeRow != null)
469 { 469 {
470 prim.Shape = buildShape(shapeRow); 470 prim.Shape = buildShape(shapeRow);
@@ -541,7 +541,7 @@ namespace OpenSim.Data.SQLite
541 new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision", 541 new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision",
542 m_conn)) 542 m_conn))
543 { 543 {
544 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); 544 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
545 cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); 545 cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
546 cmd.ExecuteNonQuery(); 546 cmd.ExecuteNonQuery();
547 } 547 }
@@ -554,7 +554,7 @@ namespace OpenSim.Data.SQLite
554 554
555 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) 555 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
556 { 556 {
557 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); 557 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
558 cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); 558 cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
559 cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter))); 559 cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter)));
560 cmd.ExecuteNonQuery(); 560 cmd.ExecuteNonQuery();
@@ -579,7 +579,7 @@ namespace OpenSim.Data.SQLite
579 579
580 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) 580 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
581 { 581 {
582 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); 582 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
583 583
584 using (IDataReader row = cmd.ExecuteReader()) 584 using (IDataReader row = cmd.ExecuteReader())
585 { 585 {
@@ -621,13 +621,13 @@ namespace OpenSim.Data.SQLite
621 { 621 {
622 using (SqliteCommand cmd = new SqliteCommand("delete from land where UUID=:UUID", m_conn)) 622 using (SqliteCommand cmd = new SqliteCommand("delete from land where UUID=:UUID", m_conn))
623 { 623 {
624 cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(globalID))); 624 cmd.Parameters.Add(new SqliteParameter(":UUID", globalID.ToString()));
625 cmd.ExecuteNonQuery(); 625 cmd.ExecuteNonQuery();
626 } 626 }
627 627
628 using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:UUID", m_conn)) 628 using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:UUID", m_conn))
629 { 629 {
630 cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(globalID))); 630 cmd.Parameters.Add(new SqliteParameter(":UUID", globalID.ToString()));
631 cmd.ExecuteNonQuery(); 631 cmd.ExecuteNonQuery();
632 } 632 }
633 } 633 }
@@ -644,7 +644,7 @@ namespace OpenSim.Data.SQLite
644 DataTable land = ds.Tables["land"]; 644 DataTable land = ds.Tables["land"];
645 DataTable landaccesslist = ds.Tables["landaccesslist"]; 645 DataTable landaccesslist = ds.Tables["landaccesslist"];
646 646
647 DataRow landRow = land.Rows.Find(Util.ToRawUuidString(parcel.landData.GlobalID)); 647 DataRow landRow = land.Rows.Find(parcel.landData.GlobalID.ToString());
648 if (landRow == null) 648 if (landRow == null)
649 { 649 {
650 landRow = land.NewRow(); 650 landRow = land.NewRow();
@@ -659,7 +659,7 @@ namespace OpenSim.Data.SQLite
659 // I know this caused someone issues before, but OpenSim is unusable if we leave this stuff around 659 // I know this caused someone issues before, but OpenSim is unusable if we leave this stuff around
660 using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", m_conn)) 660 using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", m_conn))
661 { 661 {
662 cmd.Parameters.Add(new SqliteParameter(":LandUUID", Util.ToRawUuidString(parcel.landData.GlobalID))); 662 cmd.Parameters.Add(new SqliteParameter(":LandUUID", parcel.landData.GlobalID.ToString()));
663 cmd.ExecuteNonQuery(); 663 cmd.ExecuteNonQuery();
664 } 664 }
665 665
@@ -686,12 +686,12 @@ namespace OpenSim.Data.SQLite
686 { 686 {
687 DataTable land = ds.Tables["land"]; 687 DataTable land = ds.Tables["land"];
688 DataTable landaccesslist = ds.Tables["landaccesslist"]; 688 DataTable landaccesslist = ds.Tables["landaccesslist"];
689 string searchExp = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; 689 string searchExp = "RegionUUID = '" + regionUUID + "'";
690 DataRow[] rawDataForRegion = land.Select(searchExp); 690 DataRow[] rawDataForRegion = land.Select(searchExp);
691 foreach (DataRow rawDataLand in rawDataForRegion) 691 foreach (DataRow rawDataLand in rawDataForRegion)
692 { 692 {
693 LandData newLand = buildLandData(rawDataLand); 693 LandData newLand = buildLandData(rawDataLand);
694 string accessListSearchExp = "LandUUID = '" + Util.ToRawUuidString(newLand.GlobalID) + "'"; 694 string accessListSearchExp = "LandUUID = '" + newLand.GlobalID + "'";
695 DataRow[] rawDataForLandAccessList = landaccesslist.Select(accessListSearchExp); 695 DataRow[] rawDataForLandAccessList = landaccesslist.Select(accessListSearchExp);
696 foreach (DataRow rawDataLandAccess in rawDataForLandAccessList) 696 foreach (DataRow rawDataLandAccess in rawDataForLandAccessList)
697 { 697 {
@@ -1447,11 +1447,11 @@ namespace OpenSim.Data.SQLite
1447 /// <param name="regionUUID"></param> 1447 /// <param name="regionUUID"></param>
1448 private static void fillPrimRow(DataRow row, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) 1448 private static void fillPrimRow(DataRow row, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
1449 { 1449 {
1450 row["UUID"] = Util.ToRawUuidString(prim.UUID); 1450 row["UUID"] = prim.UUID.ToString();
1451 row["RegionUUID"] = Util.ToRawUuidString(regionUUID); 1451 row["RegionUUID"] = regionUUID.ToString();
1452 row["CreationDate"] = prim.CreationDate; 1452 row["CreationDate"] = prim.CreationDate;
1453 row["Name"] = prim.Name; 1453 row["Name"] = prim.Name;
1454 row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); 1454 row["SceneGroupID"] = sceneGroupID.ToString();
1455 // the UUID of the root part for this SceneObjectGroup 1455 // the UUID of the root part for this SceneObjectGroup
1456 // various text fields 1456 // various text fields
1457 row["Text"] = prim.Text; 1457 row["Text"] = prim.Text;
@@ -1460,10 +1460,10 @@ namespace OpenSim.Data.SQLite
1460 row["TouchName"] = prim.TouchName; 1460 row["TouchName"] = prim.TouchName;
1461 // permissions 1461 // permissions
1462 row["ObjectFlags"] = prim.ObjectFlags; 1462 row["ObjectFlags"] = prim.ObjectFlags;
1463 row["CreatorID"] = Util.ToRawUuidString(prim.CreatorID); 1463 row["CreatorID"] = prim.CreatorID.ToString();
1464 row["OwnerID"] = Util.ToRawUuidString(prim.OwnerID); 1464 row["OwnerID"] = prim.OwnerID.ToString();
1465 row["GroupID"] = Util.ToRawUuidString(prim.GroupID); 1465 row["GroupID"] = prim.GroupID.ToString();
1466 row["LastOwnerID"] = Util.ToRawUuidString(prim.LastOwnerID); 1466 row["LastOwnerID"] = prim.LastOwnerID.ToString();
1467 row["OwnerMask"] = prim.OwnerMask; 1467 row["OwnerMask"] = prim.OwnerMask;
1468 row["NextOwnerMask"] = prim.NextOwnerMask; 1468 row["NextOwnerMask"] = prim.NextOwnerMask;
1469 row["GroupMask"] = prim.GroupMask; 1469 row["GroupMask"] = prim.GroupMask;
@@ -1613,8 +1613,8 @@ namespace OpenSim.Data.SQLite
1613 /// <param name="regionUUID"></param> 1613 /// <param name="regionUUID"></param>
1614 private static void fillLandRow(DataRow row, LandData land, UUID regionUUID) 1614 private static void fillLandRow(DataRow row, LandData land, UUID regionUUID)
1615 { 1615 {
1616 row["UUID"] = Util.ToRawUuidString(land.GlobalID); 1616 row["UUID"] = land.GlobalID.ToString();
1617 row["RegionUUID"] = Util.ToRawUuidString(regionUUID); 1617 row["RegionUUID"] = regionUUID.ToString();
1618 row["LocalLandID"] = land.LocalID; 1618 row["LocalLandID"] = land.LocalID;
1619 1619
1620 // Bitmap is a byte[512] 1620 // Bitmap is a byte[512]
@@ -1622,32 +1622,32 @@ namespace OpenSim.Data.SQLite
1622 1622
1623 row["Name"] = land.Name; 1623 row["Name"] = land.Name;
1624 row["Desc"] = land.Description; 1624 row["Desc"] = land.Description;
1625 row["OwnerUUID"] = Util.ToRawUuidString(land.OwnerID); 1625 row["OwnerUUID"] = land.OwnerID.ToString();
1626 row["IsGroupOwned"] = land.IsGroupOwned; 1626 row["IsGroupOwned"] = land.IsGroupOwned;
1627 row["Area"] = land.Area; 1627 row["Area"] = land.Area;
1628 row["AuctionID"] = land.AuctionID; //Unemplemented 1628 row["AuctionID"] = land.AuctionID; //Unemplemented
1629 row["Category"] = land.Category; //Enum OpenMetaverse.Parcel.ParcelCategory 1629 row["Category"] = land.Category; //Enum OpenMetaverse.Parcel.ParcelCategory
1630 row["ClaimDate"] = land.ClaimDate; 1630 row["ClaimDate"] = land.ClaimDate;
1631 row["ClaimPrice"] = land.ClaimPrice; 1631 row["ClaimPrice"] = land.ClaimPrice;
1632 row["GroupUUID"] = Util.ToRawUuidString(land.GroupID); 1632 row["GroupUUID"] = land.GroupID.ToString();
1633 row["SalePrice"] = land.SalePrice; 1633 row["SalePrice"] = land.SalePrice;
1634 row["LandStatus"] = land.Status; //Enum. OpenMetaverse.Parcel.ParcelStatus 1634 row["LandStatus"] = land.Status; //Enum. OpenMetaverse.Parcel.ParcelStatus
1635 row["LandFlags"] = land.Flags; 1635 row["LandFlags"] = land.Flags;
1636 row["LandingType"] = land.LandingType; 1636 row["LandingType"] = land.LandingType;
1637 row["MediaAutoScale"] = land.MediaAutoScale; 1637 row["MediaAutoScale"] = land.MediaAutoScale;
1638 row["MediaTextureUUID"] = Util.ToRawUuidString(land.MediaID); 1638 row["MediaTextureUUID"] = land.MediaID.ToString();
1639 row["MediaURL"] = land.MediaURL; 1639 row["MediaURL"] = land.MediaURL;
1640 row["MusicURL"] = land.MusicURL; 1640 row["MusicURL"] = land.MusicURL;
1641 row["PassHours"] = land.PassHours; 1641 row["PassHours"] = land.PassHours;
1642 row["PassPrice"] = land.PassPrice; 1642 row["PassPrice"] = land.PassPrice;
1643 row["SnapshotUUID"] = Util.ToRawUuidString(land.SnapshotID); 1643 row["SnapshotUUID"] = land.SnapshotID.ToString();
1644 row["UserLocationX"] = land.UserLocation.X; 1644 row["UserLocationX"] = land.UserLocation.X;
1645 row["UserLocationY"] = land.UserLocation.Y; 1645 row["UserLocationY"] = land.UserLocation.Y;
1646 row["UserLocationZ"] = land.UserLocation.Z; 1646 row["UserLocationZ"] = land.UserLocation.Z;
1647 row["UserLookAtX"] = land.UserLookAt.X; 1647 row["UserLookAtX"] = land.UserLookAt.X;
1648 row["UserLookAtY"] = land.UserLookAt.Y; 1648 row["UserLookAtY"] = land.UserLookAt.Y;
1649 row["UserLookAtZ"] = land.UserLookAt.Z; 1649 row["UserLookAtZ"] = land.UserLookAt.Z;
1650 row["AuthbuyerID"] = Util.ToRawUuidString(land.AuthBuyerID); 1650 row["AuthbuyerID"] = land.AuthBuyerID.ToString();
1651 row["OtherCleanTime"] = land.OtherCleanTime; 1651 row["OtherCleanTime"] = land.OtherCleanTime;
1652 row["Dwell"] = land.Dwell; 1652 row["Dwell"] = land.Dwell;
1653 } 1653 }
@@ -1660,8 +1660,8 @@ namespace OpenSim.Data.SQLite
1660 /// <param name="parcelID"></param> 1660 /// <param name="parcelID"></param>
1661 private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, UUID parcelID) 1661 private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, UUID parcelID)
1662 { 1662 {
1663 row["LandUUID"] = Util.ToRawUuidString(parcelID); 1663 row["LandUUID"] = parcelID.ToString();
1664 row["AccessUUID"] = Util.ToRawUuidString(entry.AgentID); 1664 row["AccessUUID"] = entry.AgentID.ToString();
1665 row["Flags"] = entry.Flags; 1665 row["Flags"] = entry.Flags;
1666 } 1666 }
1667 1667
@@ -1742,10 +1742,7 @@ namespace OpenSim.Data.SQLite
1742 s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); 1742 s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]);
1743 s.State = Convert.ToByte(row["State"]); 1743 s.State = Convert.ToByte(row["State"]);
1744 1744
1745 // text TODO: this isn't right] = but I'm not sure the right 1745 byte[] textureEntry = (byte[])row["Texture"];
1746 // way to specify this as a blob atm
1747
1748 byte[] textureEntry = (byte[]) row["Texture"];
1749 s.TextureEntry = textureEntry; 1746 s.TextureEntry = textureEntry;
1750 1747
1751 s.ExtraParams = (byte[]) row["ExtraParams"]; 1748 s.ExtraParams = (byte[]) row["ExtraParams"];
@@ -1760,7 +1757,7 @@ namespace OpenSim.Data.SQLite
1760 private static void fillShapeRow(DataRow row, SceneObjectPart prim) 1757 private static void fillShapeRow(DataRow row, SceneObjectPart prim)
1761 { 1758 {
1762 PrimitiveBaseShape s = prim.Shape; 1759 PrimitiveBaseShape s = prim.Shape;
1763 row["UUID"] = Util.ToRawUuidString(prim.UUID); 1760 row["UUID"] = prim.UUID.ToString();
1764 // shape is an enum 1761 // shape is an enum
1765 row["Shape"] = 0; 1762 row["Shape"] = 0;
1766 // vectors 1763 // vectors
@@ -1805,7 +1802,7 @@ namespace OpenSim.Data.SQLite
1805 DataTable prims = ds.Tables["prims"]; 1802 DataTable prims = ds.Tables["prims"];
1806 DataTable shapes = ds.Tables["primshapes"]; 1803 DataTable shapes = ds.Tables["primshapes"];
1807 1804
1808 DataRow primRow = prims.Rows.Find(Util.ToRawUuidString(prim.UUID)); 1805 DataRow primRow = prims.Rows.Find(prim.UUID.ToString());
1809 if (primRow == null) 1806 if (primRow == null)
1810 { 1807 {
1811 primRow = prims.NewRow(); 1808 primRow = prims.NewRow();
@@ -1817,7 +1814,7 @@ namespace OpenSim.Data.SQLite
1817 fillPrimRow(primRow, prim, sceneGroupID, regionUUID); 1814 fillPrimRow(primRow, prim, sceneGroupID, regionUUID);
1818 } 1815 }
1819 1816
1820 DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); 1817 DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString());
1821 if (shapeRow == null) 1818 if (shapeRow == null)
1822 { 1819 {
1823 shapeRow = shapes.NewRow(); 1820 shapeRow = shapes.NewRow();