aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLRegionData.cs
diff options
context:
space:
mode:
authorJeff Ames2008-08-18 00:39:10 +0000
committerJeff Ames2008-08-18 00:39:10 +0000
commit6ef9d4da901a346c232458317cca6268da888e2e (patch)
treedd1d935b10f34f261839da9f9879c02322e8ede7 /OpenSim/Data/MySQL/MySQLRegionData.cs
parentUpdate svn properties, minor formatting cleanup. (diff)
downloadopensim-SC_OLD-6ef9d4da901a346c232458317cca6268da888e2e.zip
opensim-SC_OLD-6ef9d4da901a346c232458317cca6268da888e2e.tar.gz
opensim-SC_OLD-6ef9d4da901a346c232458317cca6268da888e2e.tar.bz2
opensim-SC_OLD-6ef9d4da901a346c232458317cca6268da888e2e.tar.xz
Formatting cleanup.
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLRegionData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs119
1 files changed, 59 insertions, 60 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 70b6d3c..85af5df 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -53,27 +53,27 @@ namespace OpenSim.Data.MySQL
53 private const string m_terrainSelect = "select * from terrain limit 1"; 53 private const string m_terrainSelect = "select * from terrain limit 1";
54 private const string m_landSelect = "select * from land"; 54 private const string m_landSelect = "select * from land";
55 private const string m_landAccessListSelect = "select * from landaccesslist"; 55 private const string m_landAccessListSelect = "select * from landaccesslist";
56 private const string m_regionSettingsSelect = "select * from regionsettings"; 56 private const string m_regionSettingsSelect = "select * from regionsettings";
57 private const string m_waitTimeoutSelect = "select @@wait_timeout"; 57 private const string m_waitTimeoutSelect = "select @@wait_timeout";
58 58
59 private MySqlConnection m_connection; 59 private MySqlConnection m_connection;
60 private string m_connectionString; 60 private string m_connectionString;
61 61
62 /// <summary> 62 /// <summary>
63 /// Wait timeout for our connection in ticks. 63 /// Wait timeout for our connection in ticks.
64 /// </summary> 64 /// </summary>
65 private long m_waitTimeout; 65 private long m_waitTimeout;
66 66
67 /// <summary> 67 /// <summary>
68 /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long 68 /// Make our storage of the timeout this amount smaller than it actually is, to give us a margin on long
69 /// running database operations. 69 /// running database operations.
70 /// </summary> 70 /// </summary>
71 private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; 71 private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond;
72 72
73 /// <summary> 73 /// <summary>
74 /// Holds the last tick time that the connection was used. 74 /// Holds the last tick time that the connection was used.
75 /// </summary> 75 /// </summary>
76 private long m_lastConnectionUse; 76 private long m_lastConnectionUse;
77 77
78 private DataSet m_dataSet; 78 private DataSet m_dataSet;
79 private MySqlDataAdapter m_primDataAdapter; 79 private MySqlDataAdapter m_primDataAdapter;
@@ -105,7 +105,7 @@ namespace OpenSim.Data.MySQL
105 public void Initialise(string connectionString) 105 public void Initialise(string connectionString)
106 { 106 {
107 m_connectionString = connectionString; 107 m_connectionString = connectionString;
108 108
109 m_dataSet = new DataSet(); 109 m_dataSet = new DataSet();
110 110
111 int passPosition = 0; 111 int passPosition = 0;
@@ -132,8 +132,8 @@ namespace OpenSim.Data.MySQL
132 m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); 132 m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString);
133 m_connection = new MySqlConnection(m_connectionString); 133 m_connection = new MySqlConnection(m_connectionString);
134 m_connection.Open(); 134 m_connection.Open();
135 135
136 GetWaitTimeout(); 136 GetWaitTimeout();
137 137
138 // This actually does the roll forward assembly stuff 138 // This actually does the roll forward assembly stuff
139 Assembly assem = GetType().Assembly; 139 Assembly assem = GetType().Assembly;
@@ -177,12 +177,11 @@ namespace OpenSim.Data.MySQL
177 m_dataSet.Tables.Add(m_shapeTable); 177 m_dataSet.Tables.Add(m_shapeTable);
178 SetupShapeCommands(m_shapeDataAdapter, m_connection); 178 SetupShapeCommands(m_shapeDataAdapter, m_connection);
179 m_shapeDataAdapter.Fill(m_shapeTable); 179 m_shapeDataAdapter.Fill(m_shapeTable);
180
181 180
182 m_itemsTable = createItemsTable(); 181 m_itemsTable = createItemsTable();
183 m_dataSet.Tables.Add(m_itemsTable); 182 m_dataSet.Tables.Add(m_itemsTable);
184 SetupItemsCommands(m_itemsDataAdapter, m_connection); 183 SetupItemsCommands(m_itemsDataAdapter, m_connection);
185 m_itemsDataAdapter.Fill(m_itemsTable); 184 m_itemsDataAdapter.Fill(m_itemsTable);
186 185
187 m_terrainTable = createTerrainTable(); 186 m_terrainTable = createTerrainTable();
188 m_dataSet.Tables.Add(m_terrainTable); 187 m_dataSet.Tables.Add(m_terrainTable);
@@ -205,58 +204,58 @@ namespace OpenSim.Data.MySQL
205 m_regionSettingsDataAdapter.Fill(m_regionSettingsTable); 204 m_regionSettingsDataAdapter.Fill(m_regionSettingsTable);
206 } 205 }
207 } 206 }
208 207
209 /// <summary> 208 /// <summary>
210 /// Get the wait_timeout value for our connection 209 /// Get the wait_timeout value for our connection
211 /// </summary> 210 /// </summary>
212 protected void GetWaitTimeout() 211 protected void GetWaitTimeout()
213 { 212 {
214 MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection); 213 MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection);
215 214
216 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 215 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
217 { 216 {
218 if (dbReader.Read()) 217 if (dbReader.Read())
219 { 218 {
220 m_waitTimeout 219 m_waitTimeout
221 = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; 220 = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
222 } 221 }
223 222
224 dbReader.Close(); 223 dbReader.Close();
225 cmd.Dispose(); 224 cmd.Dispose();
226 } 225 }
227 226
228 m_lastConnectionUse = System.DateTime.Now.Ticks; 227 m_lastConnectionUse = System.DateTime.Now.Ticks;
229 228
230 m_log.DebugFormat( 229 m_log.DebugFormat(
231 "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond); 230 "[REGION DB]: Connection wait timeout {0} seconds", m_waitTimeout / TimeSpan.TicksPerSecond);
232 } 231 }
233 232
234 /// <summary> 233 /// <summary>
235 /// Should be called before any db operation. This checks to see if the connection has not timed out 234 /// Should be called before any db operation. This checks to see if the connection has not timed out
236 /// </summary> 235 /// </summary>
237 protected void CheckConnection() 236 protected void CheckConnection()
238 { 237 {
239 //m_log.Debug("[REGION DB]: Checking connection"); 238 //m_log.Debug("[REGION DB]: Checking connection");
240 239
241 long timeNow = System.DateTime.Now.Ticks; 240 long timeNow = System.DateTime.Now.Ticks;
242 if (timeNow - m_lastConnectionUse > m_waitTimeout || m_connection.State != ConnectionState.Open) 241 if (timeNow - m_lastConnectionUse > m_waitTimeout || m_connection.State != ConnectionState.Open)
243 { 242 {
244 m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); 243 m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting");
245 244
246 lock (m_connection) 245 lock (m_connection)
247 { 246 {
248 m_connection.Close(); 247 m_connection.Close();
249 m_connection = new MySqlConnection(m_connectionString); 248 m_connection = new MySqlConnection(m_connectionString);
250 m_connection.Open(); 249 m_connection.Open();
251 } 250 }
252 } 251 }
253 252
254 // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather 253 // Strictly, we should set this after the actual db operation. But it's more convenient to set here rather
255 // than require the code to call another method - the timeout leeway should be large enough to cover the 254 // than require the code to call another method - the timeout leeway should be large enough to cover the
256 // inaccuracy. 255 // inaccuracy.
257 m_lastConnectionUse = timeNow; 256 m_lastConnectionUse = timeNow;
258 } 257 }
259 258
260 /// <summary> 259 /// <summary>
261 /// Given a list of tables, return the version of the tables, as seen in the database 260 /// Given a list of tables, return the version of the tables, as seen in the database
262 /// </summary> 261 /// </summary>
@@ -271,7 +270,7 @@ namespace OpenSim.Data.MySQL
271 "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", 270 "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
272 dbcon); 271 dbcon);
273 tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); 272 tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
274 273
275 CheckConnection(); 274 CheckConnection();
276 using (MySqlDataReader tables = tablesCmd.ExecuteReader()) 275 using (MySqlDataReader tables = tablesCmd.ExecuteReader())
277 { 276 {
@@ -465,7 +464,7 @@ namespace OpenSim.Data.MySQL
465 464
466 lock (m_dataSet) 465 lock (m_dataSet)
467 { 466 {
468 CheckConnection(); 467 CheckConnection();
469 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); 468 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent);
470 m_log.Info("[REGION DB]: " + 469 m_log.Info("[REGION DB]: " +
471 "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); 470 "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
@@ -587,10 +586,10 @@ namespace OpenSim.Data.MySQL
587 using (cmd) 586 using (cmd)
588 { 587 {
589 delete.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); 588 delete.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID)));
590 589
591 CheckConnection(); 590 CheckConnection();
592 delete.ExecuteNonQuery(); 591 delete.ExecuteNonQuery();
593 592
594 cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); 593 cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID)));
595 cmd.Parameters.Add(new MySqlParameter("?Revision", revision)); 594 cmd.Parameters.Add(new MySqlParameter("?Revision", revision));
596 cmd.Parameters.Add(new MySqlParameter("?Heightfield", serializeTerrain(ter))); 595 cmd.Parameters.Add(new MySqlParameter("?Heightfield", serializeTerrain(ter)));
@@ -774,7 +773,7 @@ namespace OpenSim.Data.MySQL
774 } 773 }
775 774
776 /// <summary> 775 /// <summary>
777 /// 776 ///
778 /// </summary> 777 /// </summary>
779 /// <param name="regionUUID"></param> 778 /// <param name="regionUUID"></param>
780 /// <returns></returns> 779 /// <returns></returns>
@@ -805,7 +804,7 @@ namespace OpenSim.Data.MySQL
805 } 804 }
806 805
807 /// <summary> 806 /// <summary>
808 /// 807 ///
809 /// </summary> 808 /// </summary>
810 public void Commit() 809 public void Commit()
811 { 810 {
@@ -845,7 +844,7 @@ namespace OpenSim.Data.MySQL
845 **********************************************************************/ 844 **********************************************************************/
846 845
847 /// <summary> 846 /// <summary>
848 /// 847 ///
849 /// </summary> 848 /// </summary>
850 /// <param name="dt"></param> 849 /// <param name="dt"></param>
851 /// <param name="name"></param> 850 /// <param name="name"></param>
@@ -1139,7 +1138,7 @@ namespace OpenSim.Data.MySQL
1139 **********************************************************************/ 1138 **********************************************************************/
1140 1139
1141 /// <summary> 1140 /// <summary>
1142 /// 1141 ///
1143 /// </summary> 1142 /// </summary>
1144 /// <param name="row"></param> 1143 /// <param name="row"></param>
1145 /// <returns></returns> 1144 /// <returns></returns>
@@ -1315,7 +1314,7 @@ namespace OpenSim.Data.MySQL
1315 } 1314 }
1316 1315
1317 /// <summary> 1316 /// <summary>
1318 /// 1317 ///
1319 /// </summary> 1318 /// </summary>
1320 /// <param name="row"></param> 1319 /// <param name="row"></param>
1321 /// <returns></returns> 1320 /// <returns></returns>
@@ -1374,14 +1373,14 @@ namespace OpenSim.Data.MySQL
1374 newData.UserLookAt = LLVector3.Zero; 1373 newData.UserLookAt = LLVector3.Zero;
1375 m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); 1374 m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name);
1376 } 1375 }
1377 1376
1378 newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); 1377 newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
1379 1378
1380 return newData; 1379 return newData;
1381 } 1380 }
1382 1381
1383 /// <summary> 1382 /// <summary>
1384 /// 1383 ///
1385 /// </summary> 1384 /// </summary>
1386 /// <param name="row"></param> 1385 /// <param name="row"></param>
1387 /// <returns></returns> 1386 /// <returns></returns>
@@ -1395,7 +1394,7 @@ namespace OpenSim.Data.MySQL
1395 } 1394 }
1396 1395
1397 /// <summary> 1396 /// <summary>
1398 /// 1397 ///
1399 /// </summary> 1398 /// </summary>
1400 /// <param name="val"></param> 1399 /// <param name="val"></param>
1401 /// <returns></returns> 1400 /// <returns></returns>
@@ -1419,7 +1418,7 @@ namespace OpenSim.Data.MySQL
1419 } 1418 }
1420 1419
1421 /// <summary> 1420 /// <summary>
1422 /// 1421 ///
1423 /// </summary> 1422 /// </summary>
1424 /// <param name="row"></param> 1423 /// <param name="row"></param>
1425 /// <param name="prim"></param> 1424 /// <param name="prim"></param>
@@ -1502,7 +1501,7 @@ namespace OpenSim.Data.MySQL
1502 } 1501 }
1503 1502
1504 /// <summary> 1503 /// <summary>
1505 /// 1504 ///
1506 /// </summary> 1505 /// </summary>
1507 /// <param name="row"></param> 1506 /// <param name="row"></param>
1508 /// <param name="taskItem"></param> 1507 /// <param name="taskItem"></param>
@@ -1532,7 +1531,7 @@ namespace OpenSim.Data.MySQL
1532 } 1531 }
1533 1532
1534 /// <summary> 1533 /// <summary>
1535 /// 1534 ///
1536 /// </summary> 1535 /// </summary>
1537 private static void fillRegionSettingsRow(DataRow row, RegionSettings settings) 1536 private static void fillRegionSettingsRow(DataRow row, RegionSettings settings)
1538 { 1537 {
@@ -1573,7 +1572,7 @@ namespace OpenSim.Data.MySQL
1573 } 1572 }
1574 1573
1575 /// <summary> 1574 /// <summary>
1576 /// 1575 ///
1577 /// </summary> 1576 /// </summary>
1578 /// <param name="row"></param> 1577 /// <param name="row"></param>
1579 /// <param name="land"></param> 1578 /// <param name="land"></param>
@@ -1618,7 +1617,7 @@ namespace OpenSim.Data.MySQL
1618 } 1617 }
1619 1618
1620 /// <summary> 1619 /// <summary>
1621 /// 1620 ///
1622 /// </summary> 1621 /// </summary>
1623 /// <param name="row"></param> 1622 /// <param name="row"></param>
1624 /// <param name="entry"></param> 1623 /// <param name="entry"></param>
@@ -1631,7 +1630,7 @@ namespace OpenSim.Data.MySQL
1631 } 1630 }
1632 1631
1633 /// <summary> 1632 /// <summary>
1634 /// 1633 ///
1635 /// </summary> 1634 /// </summary>
1636 /// <param name="row"></param> 1635 /// <param name="row"></param>
1637 /// <returns></returns> 1636 /// <returns></returns>
@@ -1694,7 +1693,7 @@ namespace OpenSim.Data.MySQL
1694 } 1693 }
1695 1694
1696 /// <summary> 1695 /// <summary>
1697 /// 1696 ///
1698 /// </summary> 1697 /// </summary>
1699 /// <param name="row"></param> 1698 /// <param name="row"></param>
1700 /// <param name="prim"></param> 1699 /// <param name="prim"></param>
@@ -1731,7 +1730,7 @@ namespace OpenSim.Data.MySQL
1731 row["ProfileHollow"] = s.ProfileHollow; 1730 row["ProfileHollow"] = s.ProfileHollow;
1732 row["Texture"] = s.TextureEntry; 1731 row["Texture"] = s.TextureEntry;
1733 row["ExtraParams"] = s.ExtraParams; 1732 row["ExtraParams"] = s.ExtraParams;
1734 1733
1735 try 1734 try
1736 { 1735 {
1737 row["State"] = s.State; 1736 row["State"] = s.State;
@@ -1754,7 +1753,7 @@ namespace OpenSim.Data.MySQL
1754 } 1753 }
1755 1754
1756 /// <summary> 1755 /// <summary>
1757 /// 1756 ///
1758 /// </summary> 1757 /// </summary>
1759 /// <param name="prim"></param> 1758 /// <param name="prim"></param>
1760 /// <param name="sceneGroupID"></param> 1759 /// <param name="sceneGroupID"></param>
@@ -1911,7 +1910,7 @@ namespace OpenSim.Data.MySQL
1911 } 1910 }
1912 1911
1913 /// <summary> 1912 /// <summary>
1914 /// 1913 ///
1915 /// </summary> 1914 /// </summary>
1916 /// <param name="dt"></param> 1915 /// <param name="dt"></param>
1917 /// <returns></returns> 1916 /// <returns></returns>
@@ -1973,7 +1972,7 @@ namespace OpenSim.Data.MySQL
1973 } 1972 }
1974 1973
1975 /// <summary> 1974 /// <summary>
1976 /// 1975 ///
1977 /// </summary> 1976 /// </summary>
1978 /// <param name="da"></param> 1977 /// <param name="da"></param>
1979 /// <param name="conn"></param> 1978 /// <param name="conn"></param>
@@ -1994,7 +1993,7 @@ namespace OpenSim.Data.MySQL
1994 } 1993 }
1995 1994
1996 /// <summary> 1995 /// <summary>
1997 /// 1996 ///
1998 /// </summary> 1997 /// </summary>
1999 /// <param name="da"></param> 1998 /// <param name="da"></param>
2000 /// <param name="conn"></param> 1999 /// <param name="conn"></param>
@@ -2027,7 +2026,7 @@ namespace OpenSim.Data.MySQL
2027 } 2026 }
2028 2027
2029 /// <summary> 2028 /// <summary>
2030 /// 2029 ///
2031 /// </summary> 2030 /// </summary>
2032 /// <param name="da"></param> 2031 /// <param name="da"></param>
2033 /// <param name="conn"></param> 2032 /// <param name="conn"></param>
@@ -2038,7 +2037,7 @@ namespace OpenSim.Data.MySQL
2038 } 2037 }
2039 2038
2040 /// <summary> 2039 /// <summary>
2041 /// 2040 ///
2042 /// </summary> 2041 /// </summary>
2043 /// <param name="da"></param> 2042 /// <param name="da"></param>
2044 /// <param name="conn"></param> 2043 /// <param name="conn"></param>
@@ -2052,7 +2051,7 @@ namespace OpenSim.Data.MySQL
2052 } 2051 }
2053 2052
2054 /// <summary> 2053 /// <summary>
2055 /// 2054 ///
2056 /// </summary> 2055 /// </summary>
2057 /// <param name="da"></param> 2056 /// <param name="da"></param>
2058 /// <param name="conn"></param> 2057 /// <param name="conn"></param>
@@ -2063,7 +2062,7 @@ namespace OpenSim.Data.MySQL
2063 } 2062 }
2064 2063
2065 /// <summary> 2064 /// <summary>
2066 /// 2065 ///
2067 /// </summary> 2066 /// </summary>
2068 /// <param name="da"></param> 2067 /// <param name="da"></param>
2069 /// <param name="conn"></param> 2068 /// <param name="conn"></param>
@@ -2082,7 +2081,7 @@ namespace OpenSim.Data.MySQL
2082 } 2081 }
2083 2082
2084 /// <summary> 2083 /// <summary>
2085 /// 2084 ///
2086 /// </summary> 2085 /// </summary>
2087 /// <param name="conn">MySQL connection handler</param> 2086 /// <param name="conn">MySQL connection handler</param>
2088 // private static void InitDB(MySqlConnection conn) 2087 // private static void InitDB(MySqlConnection conn)
@@ -2174,7 +2173,7 @@ namespace OpenSim.Data.MySQL
2174 // } 2173 // }
2175 2174
2176 /// <summary> 2175 /// <summary>
2177 /// 2176 ///
2178 /// </summary> 2177 /// </summary>
2179 /// <param name="conn"></param> 2178 /// <param name="conn"></param>
2180 /// <param name="m"></param> 2179 /// <param name="m"></param>