aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
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
parentUpdate svn properties, minor formatting cleanup. (diff)
downloadopensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.zip
opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.tar.gz
opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.tar.bz2
opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.tar.xz
Formatting cleanup.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs8
-rw-r--r--OpenSim/Data/MySQL/MySQLEstateData.cs62
-rw-r--r--OpenSim/Data/MySQL/MySQLGridData.cs6
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs18
-rw-r--r--OpenSim/Data/MySQL/MySQLLogData.cs8
-rw-r--r--OpenSim/Data/MySQL/MySQLManager.cs18
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs119
7 files changed, 119 insertions, 120 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index cec736a..bdb1571 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -144,11 +144,11 @@ namespace OpenSim.Data.MySQL
144 _dbConnection.GetTableVersion(tableList); 144 _dbConnection.GetTableVersion(tableList);
145 145
146 // if there is no table, return, migrations will handle it. 146 // if there is no table, return, migrations will handle it.
147 if (tableList["assets"] == null) 147 if (tableList["assets"] == null)
148 return; 148 return;
149 149
150 // if there is a table, and we don't have a migration, set it to 1 150 // if there is a table, and we don't have a migration, set it to 1
151 if (m.Version == 0) 151 if (m.Version == 0)
152 m.Version = 1; 152 m.Version = 1;
153 } 153 }
154 154
@@ -272,12 +272,12 @@ namespace OpenSim.Data.MySQL
272 lock (_dbConnection) 272 lock (_dbConnection)
273 { 273 {
274 _dbConnection.CheckConnection(); 274 _dbConnection.CheckConnection();
275 275
276 MySqlCommand cmd = 276 MySqlCommand cmd =
277 new MySqlCommand( 277 new MySqlCommand(
278 "SELECT id FROM assets WHERE id=?id", 278 "SELECT id FROM assets WHERE id=?id",
279 _dbConnection.Connection); 279 _dbConnection.Connection);
280 280
281 cmd.Parameters.AddWithValue("?id", uuid.ToString()); 281 cmd.Parameters.AddWithValue("?id", uuid.ToString());
282 282
283 try 283 try
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs
index 8991e02..2ab7d40 100644
--- a/OpenSim/Data/MySQL/MySQLEstateData.cs
+++ b/OpenSim/Data/MySQL/MySQLEstateData.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Data.MySQL
51 private string m_connectionString; 51 private string m_connectionString;
52 private long m_waitTimeout; 52 private long m_waitTimeout;
53 private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; 53 private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond;
54 private long m_lastConnectionUse; 54 private long m_lastConnectionUse;
55 55
56 private FieldInfo[] m_Fields; 56 private FieldInfo[] m_Fields;
57 private Dictionary<string, FieldInfo> m_FieldMap = 57 private Dictionary<string, FieldInfo> m_FieldMap =
@@ -83,13 +83,13 @@ namespace OpenSim.Data.MySQL
83 } 83 }
84 84
85 m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); 85 m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString);
86 86
87 //m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); 87 //m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString);
88 88
89 m_connection = new MySqlConnection(m_connectionString); 89 m_connection = new MySqlConnection(m_connectionString);
90 m_connection.Open(); 90 m_connection.Open();
91 91
92 GetWaitTimeout(); 92 GetWaitTimeout();
93 93
94 Assembly assem = GetType().Assembly; 94 Assembly assem = GetType().Assembly;
95 Migration m = new Migration(m_connection, assem, "EstateStore"); 95 Migration m = new Migration(m_connection, assem, "EstateStore");
@@ -106,7 +106,7 @@ namespace OpenSim.Data.MySQL
106 m_FieldMap[f.Name.Substring(2)] = f; 106 m_FieldMap[f.Name.Substring(2)] = f;
107 } 107 }
108 } 108 }
109 109
110 private string[] FieldList 110 private string[] FieldList
111 { 111 {
112 get { return new List<string>(m_FieldMap.Keys).ToArray(); } 112 get { return new List<string>(m_FieldMap.Keys).ToArray(); }
@@ -116,28 +116,28 @@ namespace OpenSim.Data.MySQL
116 { 116 {
117 MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, 117 MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect,
118 m_connection); 118 m_connection);
119 119
120 using (MySqlDataReader dbReader = 120 using (MySqlDataReader dbReader =
121 cmd.ExecuteReader(CommandBehavior.SingleRow)) 121 cmd.ExecuteReader(CommandBehavior.SingleRow))
122 { 122 {
123 if (dbReader.Read()) 123 if (dbReader.Read())
124 { 124 {
125 m_waitTimeout 125 m_waitTimeout
126 = Convert.ToInt32(dbReader["@@wait_timeout"]) * 126 = Convert.ToInt32(dbReader["@@wait_timeout"]) *
127 TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; 127 TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
128 } 128 }
129 129
130 dbReader.Close(); 130 dbReader.Close();
131 cmd.Dispose(); 131 cmd.Dispose();
132 } 132 }
133 133
134 m_lastConnectionUse = System.DateTime.Now.Ticks; 134 m_lastConnectionUse = System.DateTime.Now.Ticks;
135 135
136 m_log.DebugFormat( 136 m_log.DebugFormat(
137 "[REGION DB]: Connection wait timeout {0} seconds", 137 "[REGION DB]: Connection wait timeout {0} seconds",
138 m_waitTimeout / TimeSpan.TicksPerSecond); 138 m_waitTimeout / TimeSpan.TicksPerSecond);
139 } 139 }
140 140
141 protected void CheckConnection() 141 protected void CheckConnection()
142 { 142 {
143 long timeNow = System.DateTime.Now.Ticks; 143 long timeNow = System.DateTime.Now.Ticks;
@@ -145,17 +145,17 @@ namespace OpenSim.Data.MySQL
145 m_connection.State != ConnectionState.Open) 145 m_connection.State != ConnectionState.Open)
146 { 146 {
147 m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); 147 m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting");
148 148
149 lock (m_connection) 149 lock (m_connection)
150 { 150 {
151 m_connection.Close(); 151 m_connection.Close();
152 m_connection = new MySqlConnection(m_connectionString); 152 m_connection = new MySqlConnection(m_connectionString);
153 m_connection.Open(); 153 m_connection.Open();
154 } 154 }
155 } 155 }
156 156
157 m_lastConnectionUse = timeNow; 157 m_lastConnectionUse = timeNow;
158 } 158 }
159 159
160 public EstateSettings LoadEstateSettings(LLUUID regionID) 160 public EstateSettings LoadEstateSettings(LLUUID regionID)
161 { 161 {
@@ -210,7 +210,7 @@ namespace OpenSim.Data.MySQL
210 names.Remove("EstateID"); 210 names.Remove("EstateID");
211 211
212 sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( ?"+String.Join(", ?", names.ToArray())+")"; 212 sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( ?"+String.Join(", ?", names.ToArray())+")";
213 213
214 cmd.CommandText = sql; 214 cmd.CommandText = sql;
215 cmd.Parameters.Clear(); 215 cmd.Parameters.Clear();
216 216
@@ -318,7 +318,7 @@ namespace OpenSim.Data.MySQL
318 es.ClearBans(); 318 es.ClearBans();
319 319
320 CheckConnection(); 320 CheckConnection();
321 321
322 MySqlCommand cmd = m_connection.CreateCommand(); 322 MySqlCommand cmd = m_connection.CreateCommand();
323 323
324 cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; 324 cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID";
@@ -344,18 +344,18 @@ namespace OpenSim.Data.MySQL
344 private void SaveBanList(EstateSettings es) 344 private void SaveBanList(EstateSettings es)
345 { 345 {
346 CheckConnection(); 346 CheckConnection();
347 347
348 MySqlCommand cmd = m_connection.CreateCommand(); 348 MySqlCommand cmd = m_connection.CreateCommand();
349 349
350 cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; 350 cmd.CommandText = "delete from estateban where EstateID = ?EstateID";
351 cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); 351 cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
352 352
353 cmd.ExecuteNonQuery(); 353 cmd.ExecuteNonQuery();
354 354
355 cmd.Parameters.Clear(); 355 cmd.Parameters.Clear();
356 356
357 cmd.CommandText = "insert into estateban (EstateID, bannedUUID) values ( ?EstateID, ?bannedUUID )"; 357 cmd.CommandText = "insert into estateban (EstateID, bannedUUID) values ( ?EstateID, ?bannedUUID )";
358 358
359 foreach (EstateBan b in es.EstateBans) 359 foreach (EstateBan b in es.EstateBans)
360 { 360 {
361 cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); 361 cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
@@ -369,18 +369,18 @@ namespace OpenSim.Data.MySQL
369 void SaveUUIDList(uint EstateID, string table, LLUUID[] data) 369 void SaveUUIDList(uint EstateID, string table, LLUUID[] data)
370 { 370 {
371 CheckConnection(); 371 CheckConnection();
372 372
373 MySqlCommand cmd = m_connection.CreateCommand(); 373 MySqlCommand cmd = m_connection.CreateCommand();
374 374
375 cmd.CommandText = "delete from "+table+" where EstateID = ?EstateID"; 375 cmd.CommandText = "delete from "+table+" where EstateID = ?EstateID";
376 cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); 376 cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString());
377 377
378 cmd.ExecuteNonQuery(); 378 cmd.ExecuteNonQuery();
379 379
380 cmd.Parameters.Clear(); 380 cmd.Parameters.Clear();
381 381
382 cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( ?EstateID, ?uuid )"; 382 cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( ?EstateID, ?uuid )";
383 383
384 foreach (LLUUID uuid in data) 384 foreach (LLUUID uuid in data)
385 { 385 {
386 cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); 386 cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString());
@@ -396,7 +396,7 @@ namespace OpenSim.Data.MySQL
396 List<LLUUID> uuids = new List<LLUUID>(); 396 List<LLUUID> uuids = new List<LLUUID>();
397 397
398 CheckConnection(); 398 CheckConnection();
399 399
400 MySqlCommand cmd = m_connection.CreateCommand(); 400 MySqlCommand cmd = m_connection.CreateCommand();
401 401
402 cmd.CommandText = "select uuid from "+table+" where EstateID = ?EstateID"; 402 cmd.CommandText = "select uuid from "+table+" where EstateID = ?EstateID";
@@ -414,7 +414,7 @@ namespace OpenSim.Data.MySQL
414 uuids.Add(uuid); 414 uuids.Add(uuid);
415 } 415 }
416 r.Close(); 416 r.Close();
417 417
418 return uuids.ToArray(); 418 return uuids.ToArray();
419 } 419 }
420 } 420 }
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs
index 4cddbe5..fcbceb8 100644
--- a/OpenSim/Data/MySQL/MySQLGridData.cs
+++ b/OpenSim/Data/MySQL/MySQLGridData.cs
@@ -49,8 +49,8 @@ namespace OpenSim.Data.MySQL
49 /// </summary> 49 /// </summary>
50 private MySQLManager database; 50 private MySQLManager database;
51 51
52 override public void Initialise() 52 override public void Initialise()
53 { 53 {
54 m_log.Info("[MySQLGridData]: " + Name + " cannot be default-initialized!"); 54 m_log.Info("[MySQLGridData]: " + Name + " cannot be default-initialized!");
55 throw new PluginNotInitialisedException (Name); 55 throw new PluginNotInitialisedException (Name);
56 } 56 }
@@ -253,7 +253,7 @@ namespace OpenSim.Data.MySQL
253 return null; 253 return null;
254 } 254 }
255 } 255 }
256 256
257 /// <summary> 257 /// <summary>
258 /// Returns a sim profile from it's UUID 258 /// Returns a sim profile from it's UUID
259 /// </summary> 259 /// </summary>
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index dd4d804..4e8200b 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -48,8 +48,8 @@ namespace OpenSim.Data.MySQL
48 /// </summary> 48 /// </summary>
49 private MySQLManager database; 49 private MySQLManager database;
50 50
51 public void Initialise() 51 public void Initialise()
52 { 52 {
53 m_log.Info("[MySQLInventoryData]: " + Name + " cannot be default-initialized!"); 53 m_log.Info("[MySQLInventoryData]: " + Name + " cannot be default-initialized!");
54 throw new PluginNotInitialisedException (Name); 54 throw new PluginNotInitialisedException (Name);
55 } 55 }
@@ -81,7 +81,7 @@ namespace OpenSim.Data.MySQL
81 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); 81 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
82 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); 82 string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
83 string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); 83 string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
84 84
85 database = 85 database =
86 new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, 86 new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
87 settingPort); 87 settingPort);
@@ -147,7 +147,7 @@ namespace OpenSim.Data.MySQL
147 } 147 }
148 148
149 /// <summary> 149 /// <summary>
150 /// 150 ///
151 /// </summary> 151 /// </summary>
152 /// <param name="conn">MySQL connection handler</param> 152 /// <param name="conn">MySQL connection handler</param>
153 /// <param name="m"></param> 153 /// <param name="m"></param>
@@ -180,7 +180,7 @@ namespace OpenSim.Data.MySQL
180 // ... and set the version 180 // ... and set the version
181 if (m.Version == 0) 181 if (m.Version == 0)
182 m.Version = 1; 182 m.Version = 1;
183 183
184 } 184 }
185 185
186 #endregion 186 #endregion
@@ -290,7 +290,7 @@ namespace OpenSim.Data.MySQL
290 } 290 }
291 } 291 }
292 292
293 293
294 /// <summary> 294 /// <summary>
295 /// see <see cref="InventoryItemBase.getUserRootFolder"/> 295 /// see <see cref="InventoryItemBase.getUserRootFolder"/>
296 /// </summary> 296 /// </summary>
@@ -708,10 +708,10 @@ namespace OpenSim.Data.MySQL
708 * - We will only need to hit the database twice instead of n times. 708 * - We will only need to hit the database twice instead of n times.
709 * - We assume the database is well-formed - no stranded/dangling folders, all folders in heirarchy owned 709 * - We assume the database is well-formed - no stranded/dangling folders, all folders in heirarchy owned
710 * by the same person, each user only has 1 inventory heirarchy 710 * by the same person, each user only has 1 inventory heirarchy
711 * - The returned list is not ordered, instead of breadth-first ordered 711 * - The returned list is not ordered, instead of breadth-first ordered
712 There are basically 2 usage cases for getFolderHeirarchy: 712 There are basically 2 usage cases for getFolderHeirarchy:
713 1) Getting the user's entire inventory heirarchy when they log in 713 1) Getting the user's entire inventory heirarchy when they log in
714 2) Finding a subfolder heirarchy to delete when emptying the trash. 714 2) Finding a subfolder heirarchy to delete when emptying the trash.
715 This implementation will pull all inventory folders from the database, and then prune away any folder that 715 This implementation will pull all inventory folders from the database, and then prune away any folder that
716 is not part of the requested sub-heirarchy. The theory is that it is cheaper to make 1 request from the 716 is not part of the requested sub-heirarchy. The theory is that it is cheaper to make 1 request from the
717 database than to make n requests. This pays off only if requested heirarchy is large. 717 database than to make n requests. This pays off only if requested heirarchy is large.
@@ -774,7 +774,7 @@ namespace OpenSim.Data.MySQL
774 while (reader.Read()) 774 while (reader.Read())
775 { 775 {
776 InventoryFolderBase curFolder = readInventoryFolder(reader); 776 InventoryFolderBase curFolder = readInventoryFolder(reader);
777 if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling 777 if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling
778 hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list 778 hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list
779 else // else current folder has no known (yet) siblings 779 else // else current folder has no known (yet) siblings
780 { 780 {
diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs
index 456cfd2..c02016c 100644
--- a/OpenSim/Data/MySQL/MySQLLogData.cs
+++ b/OpenSim/Data/MySQL/MySQLLogData.cs
@@ -44,12 +44,12 @@ namespace OpenSim.Data.MySQL
44 /// </summary> 44 /// </summary>
45 public MySQLManager database; 45 public MySQLManager database;
46 46
47 public void Initialise() 47 public void Initialise()
48 { 48 {
49 m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!"); 49 m_log.Info("[MySQLLogData]: " + Name + " cannot be default-initialized!");
50 throw new PluginNotInitialisedException (Name); 50 throw new PluginNotInitialisedException (Name);
51 } 51 }
52 52
53 /// <summary> 53 /// <summary>
54 /// Artificial constructor called when the plugin is loaded 54 /// Artificial constructor called when the plugin is loaded
55 /// Uses the obsolete mysql_connection.ini if connect string is empty. 55 /// Uses the obsolete mysql_connection.ini if connect string is empty.
@@ -100,7 +100,7 @@ namespace OpenSim.Data.MySQL
100 Dictionary<string, string> tableList = new Dictionary<string, string>(); 100 Dictionary<string, string> tableList = new Dictionary<string, string>();
101 tableList["logs"] = null; 101 tableList["logs"] = null;
102 database.GetTableVersion(tableList); 102 database.GetTableVersion(tableList);
103 103
104 // migrations will handle it 104 // migrations will handle it
105 if (tableList["logs"] == null) 105 if (tableList["logs"] == null)
106 return; 106 return;
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs
index 58599a8..6ad6609 100644
--- a/OpenSim/Data/MySQL/MySQLManager.cs
+++ b/OpenSim/Data/MySQL/MySQLManager.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Data.MySQL
55 private string connectionString; 55 private string connectionString;
56 56
57 private const string m_waitTimeoutSelect = "select @@wait_timeout"; 57 private const string m_waitTimeoutSelect = "select @@wait_timeout";
58 58
59 /// <summary> 59 /// <summary>
60 /// Wait timeout for our connection in ticks. 60 /// Wait timeout for our connection in ticks.
61 /// </summary> 61 /// </summary>
@@ -70,7 +70,7 @@ namespace OpenSim.Data.MySQL
70 /// <summary> 70 /// <summary>
71 /// Holds the last tick time that the connection was used. 71 /// Holds the last tick time that the connection was used.
72 /// </summary> 72 /// </summary>
73 private long m_lastConnectionUse; 73 private long m_lastConnectionUse;
74 74
75 /// <summary> 75 /// <summary>
76 /// Initialises and creates a new MySQL connection and maintains it. 76 /// Initialises and creates a new MySQL connection and maintains it.
@@ -172,7 +172,7 @@ namespace OpenSim.Data.MySQL
172 // inaccuracy. 172 // inaccuracy.
173 m_lastConnectionUse = timeNow; 173 m_lastConnectionUse = timeNow;
174 } 174 }
175 175
176 /// <summary> 176 /// <summary>
177 /// Get the connection being used 177 /// Get the connection being used
178 /// </summary> 178 /// </summary>
@@ -287,14 +287,14 @@ namespace OpenSim.Data.MySQL
287 { 287 {
288 lock (dbcon) 288 lock (dbcon)
289 { 289 {
290 CheckConnection(); 290 CheckConnection();
291 291
292 MySqlCommand tablesCmd = 292 MySqlCommand tablesCmd =
293 new MySqlCommand( 293 new MySqlCommand(
294 "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", 294 "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
295 dbcon); 295 dbcon);
296 tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); 296 tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
297 297
298 using (MySqlDataReader tables = tablesCmd.ExecuteReader()) 298 using (MySqlDataReader tables = tablesCmd.ExecuteReader())
299 { 299 {
300 while (tables.Read()) 300 while (tables.Read())
@@ -541,7 +541,7 @@ namespace OpenSim.Data.MySQL
541 LLUUID regionID = LLUUID.Zero; 541 LLUUID regionID = LLUUID.Zero;
542 LLUUID.TryParse(reader["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use LLUUID.Zero 542 LLUUID.TryParse(reader["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use LLUUID.Zero
543 retval.HomeRegionID = regionID; 543 retval.HomeRegionID = regionID;
544 544
545 retval.Created = Convert.ToInt32(reader["created"].ToString()); 545 retval.Created = Convert.ToInt32(reader["created"].ToString());
546 retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); 546 retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
547 547
@@ -1124,7 +1124,7 @@ namespace OpenSim.Data.MySQL
1124 sql += "?skirt_item, ?skirt_asset)"; 1124 sql += "?skirt_item, ?skirt_asset)";
1125 1125
1126 bool returnval = false; 1126 bool returnval = false;
1127 1127
1128 // we want to send in byte data, which means we can't just pass down strings 1128 // we want to send in byte data, which means we can't just pass down strings
1129 try { 1129 try {
1130 MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); 1130 MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand();
@@ -1160,7 +1160,7 @@ namespace OpenSim.Data.MySQL
1160 cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString()); 1160 cmd.Parameters.AddWithValue("?underpants_asset", appearance.UnderPantsAsset.ToString());
1161 cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString()); 1161 cmd.Parameters.AddWithValue("?skirt_item", appearance.SkirtItem.ToString());
1162 cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString()); 1162 cmd.Parameters.AddWithValue("?skirt_asset", appearance.SkirtAsset.ToString());
1163 1163
1164 if (cmd.ExecuteNonQuery() > 0) 1164 if (cmd.ExecuteNonQuery() > 0)
1165 returnval = true; 1165 returnval = true;
1166 1166
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>