aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteRegionData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs113
1 files changed, 101 insertions, 12 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index 83fd775..81c0703 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -626,18 +626,42 @@ namespace OpenSim.Data.SQLite
626 { 626 {
627 lock (ds) 627 lock (ds)
628 { 628 {
629 using (SqliteCommand cmd = new SqliteCommand("delete from land where UUID=:UUID", m_conn)) 629 // Can't use blanket SQL statements when using SqlAdapters unless you re-read the data into the adapter
630 // after you're done.
631 // replaced below code with the SqliteAdapter version.
632 //using (SqliteCommand cmd = new SqliteCommand("delete from land where UUID=:UUID", m_conn))
633 //{
634 // cmd.Parameters.Add(new SqliteParameter(":UUID", globalID.ToString()));
635 // cmd.ExecuteNonQuery();
636 //}
637
638 //using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:UUID", m_conn))
639 //{
640 // cmd.Parameters.Add(new SqliteParameter(":UUID", globalID.ToString()));
641 // cmd.ExecuteNonQuery();
642 //}
643
644 DataTable land = ds.Tables["land"];
645 DataTable landaccesslist = ds.Tables["landaccesslist"];
646 DataRow landRow = land.Rows.Find(globalID.ToString());
647 if (landRow != null)
630 { 648 {
631 cmd.Parameters.Add(new SqliteParameter(":UUID", globalID.ToString())); 649 land.Rows.Remove(landRow);
632 cmd.ExecuteNonQuery();
633 } 650 }
634 651 List<DataRow> rowsToDelete = new List<DataRow>();
635 using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:UUID", m_conn)) 652 foreach (DataRow rowToCheck in landaccesslist.Rows)
636 { 653 {
637 cmd.Parameters.Add(new SqliteParameter(":UUID", globalID.ToString())); 654 if (rowToCheck["LandUUID"].ToString() == globalID.ToString())
638 cmd.ExecuteNonQuery(); 655 rowsToDelete.Add(rowToCheck);
656 }
657 for (int iter = 0; iter < rowsToDelete.Count; iter++)
658 {
659 landaccesslist.Rows.Remove(rowsToDelete[iter]);
639 } 660 }
661
662
640 } 663 }
664 Commit();
641 } 665 }
642 666
643 /// <summary> 667 /// <summary>
@@ -664,12 +688,27 @@ namespace OpenSim.Data.SQLite
664 } 688 }
665 689
666 // I know this caused someone issues before, but OpenSim is unusable if we leave this stuff around 690 // I know this caused someone issues before, but OpenSim is unusable if we leave this stuff around
667 using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", m_conn)) 691 //using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", m_conn))
692 //{
693 // cmd.Parameters.Add(new SqliteParameter(":LandUUID", parcel.LandData.GlobalID.ToString()));
694 // cmd.ExecuteNonQuery();
695
696// }
697
698 // This is the slower.. but more appropriate thing to do
699
700 // We can't modify the table with direct queries before calling Commit() and re-filling them.
701 List<DataRow> rowsToDelete = new List<DataRow>();
702 foreach (DataRow rowToCheck in landaccesslist.Rows)
668 { 703 {
669 cmd.Parameters.Add(new SqliteParameter(":LandUUID", parcel.LandData.GlobalID.ToString())); 704 if (rowToCheck["LandUUID"].ToString() == parcel.LandData.GlobalID.ToString())
670 cmd.ExecuteNonQuery(); 705 rowsToDelete.Add(rowToCheck);
671 } 706 }
672 707 for (int iter = 0; iter < rowsToDelete.Count; iter++)
708 {
709 landaccesslist.Rows.Remove(rowsToDelete[iter]);
710 }
711 rowsToDelete.Clear();
673 foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) 712 foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList)
674 { 713 {
675 DataRow newAccessRow = landaccesslist.NewRow(); 714 DataRow newAccessRow = landaccesslist.NewRow();
@@ -1720,7 +1759,7 @@ namespace OpenSim.Data.SQLite
1720 row["terrain_raise_limit"] = settings.TerrainRaiseLimit; 1759 row["terrain_raise_limit"] = settings.TerrainRaiseLimit;
1721 row["terrain_lower_limit"] = settings.TerrainLowerLimit; 1760 row["terrain_lower_limit"] = settings.TerrainLowerLimit;
1722 row["use_estate_sun"] = settings.UseEstateSun; 1761 row["use_estate_sun"] = settings.UseEstateSun;
1723 row["sandbox"] = settings.Sandbox; 1762 row["Sandbox"] = settings.Sandbox; // database uses upper case S for sandbox
1724 row["sunvectorx"] = settings.SunVector.X; 1763 row["sunvectorx"] = settings.SunVector.X;
1725 row["sunvectory"] = settings.SunVector.Y; 1764 row["sunvectory"] = settings.SunVector.Y;
1726 row["sunvectorz"] = settings.SunVector.Z; 1765 row["sunvectorz"] = settings.SunVector.Z;
@@ -1822,6 +1861,7 @@ namespace OpenSim.Data.SQLite
1822 /// <param name="regionUUID"></param> 1861 /// <param name="regionUUID"></param>
1823 private void addPrim(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) 1862 private void addPrim(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
1824 { 1863 {
1864
1825 DataTable prims = ds.Tables["prims"]; 1865 DataTable prims = ds.Tables["prims"];
1826 DataTable shapes = ds.Tables["primshapes"]; 1866 DataTable shapes = ds.Tables["primshapes"];
1827 1867
@@ -1971,6 +2011,40 @@ namespace OpenSim.Data.SQLite
1971 } 2011 }
1972 2012
1973 /// <summary> 2013 /// <summary>
2014 /// create an update command
2015 /// </summary>
2016 /// <param name="table">table name</param>
2017 /// <param name="pk"></param>
2018 /// <param name="dt"></param>
2019 /// <returns>the created command</returns>
2020 private static SqliteCommand createUpdateCommand(string table, string pk1, string pk2, DataTable dt)
2021 {
2022 string sql = "update " + table + " set ";
2023 string subsql = String.Empty;
2024 foreach (DataColumn col in dt.Columns)
2025 {
2026 if (subsql.Length > 0)
2027 {
2028 // a map function would rock so much here
2029 subsql += ", ";
2030 }
2031 subsql += col.ColumnName + "= :" + col.ColumnName;
2032 }
2033 sql += subsql;
2034 sql += " where " + pk1 + " and " + pk2;
2035 SqliteCommand cmd = new SqliteCommand(sql);
2036
2037 // this provides the binding for all our parameters, so
2038 // much less code than it used to be
2039
2040 foreach (DataColumn col in dt.Columns)
2041 {
2042 cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType));
2043 }
2044 return cmd;
2045 }
2046
2047 /// <summary>
1974 /// 2048 ///
1975 /// </summary> 2049 /// </summary>
1976 /// <param name="dt">Data Table</param> 2050 /// <param name="dt">Data Table</param>
@@ -2088,6 +2162,11 @@ namespace OpenSim.Data.SQLite
2088 2162
2089 da.UpdateCommand = createUpdateCommand("land", "UUID=:UUID", ds.Tables["land"]); 2163 da.UpdateCommand = createUpdateCommand("land", "UUID=:UUID", ds.Tables["land"]);
2090 da.UpdateCommand.Connection = conn; 2164 da.UpdateCommand.Connection = conn;
2165
2166 SqliteCommand delete = new SqliteCommand("delete from land where UUID=:UUID");
2167 delete.Parameters.Add(createSqliteParameter("UUID", typeof(String)));
2168 da.DeleteCommand = delete;
2169 da.DeleteCommand.Connection = conn;
2091 } 2170 }
2092 2171
2093 /// <summary> 2172 /// <summary>
@@ -2099,6 +2178,16 @@ namespace OpenSim.Data.SQLite
2099 { 2178 {
2100 da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]); 2179 da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]);
2101 da.InsertCommand.Connection = conn; 2180 da.InsertCommand.Connection = conn;
2181
2182 da.UpdateCommand = createUpdateCommand("landaccesslist", "LandUUID=:landUUID", "AccessUUID=:AccessUUID", ds.Tables["landaccesslist"]);
2183 da.UpdateCommand.Connection = conn;
2184
2185 SqliteCommand delete = new SqliteCommand("delete from landaccesslist where LandUUID= :LandUUID and AccessUUID= :AccessUUID");
2186 delete.Parameters.Add(createSqliteParameter("LandUUID", typeof(String)));
2187 delete.Parameters.Add(createSqliteParameter("AccessUUID", typeof(String)));
2188 da.DeleteCommand = delete;
2189 da.DeleteCommand.Connection = conn;
2190
2102 } 2191 }
2103 2192
2104 private void setupRegionSettingsCommands(SqliteDataAdapter da, SqliteConnection conn) 2193 private void setupRegionSettingsCommands(SqliteDataAdapter da, SqliteConnection conn)