aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLSimulationData.cs66
-rw-r--r--OpenSim/Data/MSSQL/Resources/RegionStore.migrations14
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs182
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs182
-rw-r--r--OpenSim/Data/MySQL/MySQLAvatarData.cs17
-rw-r--r--OpenSim/Data/MySQL/MySQLFriendsData.cs36
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs6
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs130
-rw-r--r--OpenSim/Data/MySQL/MySQLPresenceData.cs36
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs48
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs333
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs48
-rw-r--r--OpenSim/Data/MySQL/Resources/RegionStore.migrations12
-rw-r--r--OpenSim/Data/Null/NullSimulationData.cs22
-rw-r--r--OpenSim/Data/SQLite/Resources/RegionStore.migrations11
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs101
-rw-r--r--OpenSim/Data/Tests/RegionTests.cs4
17 files changed, 782 insertions, 466 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
index df496a7..47fb6d7 100644
--- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
@@ -1181,6 +1181,72 @@ VALUES
1181 // } 1181 // }
1182 #endregion 1182 #endregion
1183 } 1183 }
1184
1185 #region Environment Settings
1186 public string LoadRegionEnvironmentSettings(UUID regionUUID)
1187 {
1188 string sql = "select * from [regionenvironment] where region_id = @region_id";
1189 using (SqlConnection conn = new SqlConnection(m_connectionString))
1190 using (SqlCommand cmd = new SqlCommand(sql, conn))
1191 {
1192 cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID));
1193 conn.Open();
1194 using (SqlDataReader result = cmd.ExecuteReader())
1195 {
1196 if (!result.Read())
1197 {
1198 return String.Empty;
1199 }
1200 else
1201 {
1202 return Convert.ToString(result["llsd_settings"]);
1203 }
1204 }
1205 }
1206 }
1207
1208 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
1209 {
1210 {
1211 string sql = "DELETE FROM [regionenvironment] WHERE region_id = @region_id";
1212 using (SqlConnection conn = new SqlConnection(m_connectionString))
1213
1214 using (SqlCommand cmd = new SqlCommand(sql, conn))
1215 {
1216 cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID));
1217 conn.Open();
1218 cmd.ExecuteNonQuery();
1219 }
1220
1221 sql = "INSERT INTO [regionenvironment] (region_id, llsd_settings) VALUES (@region_id, @llsd_settings)";
1222
1223 using (SqlConnection conn = new SqlConnection(m_connectionString))
1224
1225 using (SqlCommand cmd = new SqlCommand(sql, conn))
1226 {
1227 cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID));
1228 cmd.Parameters.Add(_Database.CreateParameter("@llsd_settings", settings));
1229
1230 conn.Open();
1231 cmd.ExecuteNonQuery();
1232 }
1233 }
1234 }
1235
1236 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
1237 {
1238 string sql = "delete from [regionenvironment] where region_id = @region_id";
1239 using (SqlConnection conn = new SqlConnection(m_connectionString))
1240 using (SqlCommand cmd = new SqlCommand(sql, conn))
1241 {
1242 cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID));
1243
1244 conn.Open();
1245 cmd.ExecuteNonQuery();
1246 }
1247 }
1248 #endregion
1249
1184 /// <summary> 1250 /// <summary>
1185 /// Loads the settings of a region. 1251 /// Loads the settings of a region.
1186 /// </summary> 1252 /// </summary>
diff --git a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
index d6a3be9..350e548 100644
--- a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
@@ -1134,3 +1134,17 @@ ALTER TABLE landaccesslist ADD Expires integer NOT NULL DEFAULT 0;
1134 1134
1135COMMIT 1135COMMIT
1136 1136
1137:VERSION 37 #---------------- Environment Settings
1138
1139BEGIN TRANSACTION
1140
1141CREATE TABLE [dbo].[regionenvironment](
1142 [region_id] [uniqueidentifier] NOT NULL,
1143 [llsd_settings] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
1144 PRIMARY KEY CLUSTERED
1145(
1146 [region_id] ASC
1147)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
1148) ON [PRIMARY]
1149
1150COMMIT
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index a22dc0a..20df234 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -163,54 +163,53 @@ namespace OpenSim.Data.MySQL
163 { 163 {
164 dbcon.Open(); 164 dbcon.Open();
165 165
166 MySqlCommand cmd = 166 using (MySqlCommand cmd =
167 new MySqlCommand( 167 new MySqlCommand(
168 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + 168 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
169 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", 169 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
170 dbcon); 170 dbcon))
171
172 string assetName = asset.Name;
173 if (asset.Name.Length > 64)
174 {
175 assetName = asset.Name.Substring(0, 64);
176 m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add");
177 }
178
179 string assetDescription = asset.Description;
180 if (asset.Description.Length > 64)
181 {
182 assetDescription = asset.Description.Substring(0, 64);
183 m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add");
184 }
185
186 // need to ensure we dispose
187 try
188 { 171 {
189 using (cmd) 172 string assetName = asset.Name;
173 if (asset.Name.Length > 64)
190 { 174 {
191 // create unix epoch time 175 assetName = asset.Name.Substring(0, 64);
192 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 176 m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add");
193 cmd.Parameters.AddWithValue("?id", asset.ID); 177 }
194 cmd.Parameters.AddWithValue("?name", assetName); 178
195 cmd.Parameters.AddWithValue("?description", assetDescription); 179 string assetDescription = asset.Description;
196 cmd.Parameters.AddWithValue("?assetType", asset.Type); 180 if (asset.Description.Length > 64)
197 cmd.Parameters.AddWithValue("?local", asset.Local); 181 {
198 cmd.Parameters.AddWithValue("?temporary", asset.Temporary); 182 assetDescription = asset.Description.Substring(0, 64);
199 cmd.Parameters.AddWithValue("?create_time", now); 183 m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add");
200 cmd.Parameters.AddWithValue("?access_time", now); 184 }
201 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); 185
202 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); 186 try
203 cmd.Parameters.AddWithValue("?data", asset.Data); 187 {
204 cmd.ExecuteNonQuery(); 188 using (cmd)
205 cmd.Dispose(); 189 {
206 return true; 190 // create unix epoch time
191 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
192 cmd.Parameters.AddWithValue("?id", asset.ID);
193 cmd.Parameters.AddWithValue("?name", assetName);
194 cmd.Parameters.AddWithValue("?description", assetDescription);
195 cmd.Parameters.AddWithValue("?assetType", asset.Type);
196 cmd.Parameters.AddWithValue("?local", asset.Local);
197 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
198 cmd.Parameters.AddWithValue("?create_time", now);
199 cmd.Parameters.AddWithValue("?access_time", now);
200 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
201 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
202 cmd.Parameters.AddWithValue("?data", asset.Data);
203 cmd.ExecuteNonQuery();
204 return true;
205 }
206 }
207 catch (Exception e)
208 {
209 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
210 asset.FullID, asset.Name, e.Message);
211 return false;
207 } 212 }
208 }
209 catch (Exception e)
210 {
211 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
212 asset.FullID, asset.Name, e.Message);
213 return false;
214 } 213 }
215 } 214 }
216 } 215 }
@@ -223,33 +222,31 @@ namespace OpenSim.Data.MySQL
223 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 222 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
224 { 223 {
225 dbcon.Open(); 224 dbcon.Open();
226 MySqlCommand cmd =
227 new MySqlCommand("update assets set access_time=?access_time where id=?id",
228 dbcon);
229 225
230 // need to ensure we dispose 226 using (MySqlCommand cmd
231 try 227 = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon))
232 { 228 {
233 using (cmd) 229 try
234 { 230 {
235 // create unix epoch time 231 using (cmd)
236 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 232 {
237 cmd.Parameters.AddWithValue("?id", asset.ID); 233 // create unix epoch time
238 cmd.Parameters.AddWithValue("?access_time", now); 234 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
239 cmd.ExecuteNonQuery(); 235 cmd.Parameters.AddWithValue("?id", asset.ID);
240 cmd.Dispose(); 236 cmd.Parameters.AddWithValue("?access_time", now);
237 cmd.ExecuteNonQuery();
238 }
239 }
240 catch (Exception e)
241 {
242 m_log.ErrorFormat(
243 "[ASSETS DB]: " +
244 "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString()
245 + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
241 } 246 }
242 }
243 catch (Exception e)
244 {
245 m_log.ErrorFormat(
246 "[ASSETS DB]: " +
247 "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString()
248 + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
249 } 247 }
250 } 248 }
251 } 249 }
252
253 } 250 }
254 251
255 /// <summary> 252 /// <summary>
@@ -312,35 +309,41 @@ namespace OpenSim.Data.MySQL
312 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 309 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
313 { 310 {
314 dbcon.Open(); 311 dbcon.Open();
315 MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", dbcon);
316 cmd.Parameters.AddWithValue("?start", start);
317 cmd.Parameters.AddWithValue("?count", count);
318 312
319 try 313 using (MySqlCommand cmd
314 = new MySqlCommand(
315 "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count",
316 dbcon))
320 { 317 {
321 using (MySqlDataReader dbReader = cmd.ExecuteReader()) 318 cmd.Parameters.AddWithValue("?start", start);
319 cmd.Parameters.AddWithValue("?count", count);
320
321 try
322 { 322 {
323 while (dbReader.Read()) 323 using (MySqlDataReader dbReader = cmd.ExecuteReader())
324 { 324 {
325 AssetMetadata metadata = new AssetMetadata(); 325 while (dbReader.Read())
326 metadata.Name = (string)dbReader["name"]; 326 {
327 metadata.Description = (string)dbReader["description"]; 327 AssetMetadata metadata = new AssetMetadata();
328 metadata.Type = (sbyte)dbReader["assetType"]; 328 metadata.Name = (string)dbReader["name"];
329 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. 329 metadata.Description = (string)dbReader["description"];
330 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); 330 metadata.Type = (sbyte)dbReader["assetType"];
331 metadata.FullID = DBGuid.FromDB(dbReader["id"]); 331 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct.
332 metadata.CreatorID = dbReader["CreatorID"].ToString(); 332 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
333 333 metadata.FullID = DBGuid.FromDB(dbReader["id"]);
334 // Current SHA1s are not stored/computed. 334 metadata.CreatorID = dbReader["CreatorID"].ToString();
335 metadata.SHA1 = new byte[] { }; 335
336 336 // Current SHA1s are not stored/computed.
337 retList.Add(metadata); 337 metadata.SHA1 = new byte[] { };
338
339 retList.Add(metadata);
340 }
338 } 341 }
339 } 342 }
340 } 343 catch (Exception e)
341 catch (Exception e) 344 {
342 { 345 m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
343 m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); 346 }
344 } 347 }
345 } 348 }
346 } 349 }
@@ -355,11 +358,12 @@ namespace OpenSim.Data.MySQL
355 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 358 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
356 { 359 {
357 dbcon.Open(); 360 dbcon.Open();
358 MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon);
359 cmd.Parameters.AddWithValue("?id", id);
360 cmd.ExecuteNonQuery();
361 361
362 cmd.Dispose(); 362 using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon))
363 {
364 cmd.Parameters.AddWithValue("?id", id);
365 cmd.ExecuteNonQuery();
366 }
363 } 367 }
364 } 368 }
365 369
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index 8d82f61..7627497 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -70,99 +70,106 @@ namespace OpenSim.Data.MySQL
70 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 70 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
71 { 71 {
72 dbcon.Open(); 72 dbcon.Open();
73 MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon);
74 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
75
76 IDataReader result = cmd.ExecuteReader();
77 73
78 if (result.Read()) 74 using (MySqlCommand cmd
75 = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon))
79 { 76 {
80 ret.PrincipalID = principalID; 77 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
81 78
82 if (m_ColumnNames == null) 79 IDataReader result = cmd.ExecuteReader();
80
81 if (result.Read())
83 { 82 {
84 m_ColumnNames = new List<string>(); 83 ret.PrincipalID = principalID;
85 84
86 DataTable schemaTable = result.GetSchemaTable(); 85 CheckColumnNames(result);
87 foreach (DataRow row in schemaTable.Rows) 86
88 m_ColumnNames.Add(row["ColumnName"].ToString()); 87 foreach (string s in m_ColumnNames)
88 {
89 if (s == "UUID")
90 continue;
91
92 ret.Data[s] = result[s].ToString();
93 }
94
95 return ret;
89 } 96 }
90 97 else
91 foreach (string s in m_ColumnNames)
92 { 98 {
93 if (s == "UUID") 99 return null;
94 continue;
95
96 ret.Data[s] = result[s].ToString();
97 } 100 }
98
99 return ret;
100 }
101 else
102 {
103 return null;
104 } 101 }
105 } 102 }
106 } 103 }
107 104
108 public bool Store(AuthenticationData data) 105 private void CheckColumnNames(IDataReader result)
109 { 106 {
110 if (data.Data.ContainsKey("UUID")) 107 if (m_ColumnNames != null)
111 data.Data.Remove("UUID"); 108 return;
112 109
113 string[] fields = new List<string>(data.Data.Keys).ToArray(); 110 List<string> columnNames = new List<string>();
114
115 MySqlCommand cmd = new MySqlCommand();
116 111
117 string update = "update `"+m_Realm+"` set "; 112 DataTable schemaTable = result.GetSchemaTable();
118 bool first = true; 113 foreach (DataRow row in schemaTable.Rows)
119 foreach (string field in fields) 114 columnNames.Add(row["ColumnName"].ToString());
120 {
121 if (!first)
122 update += ", ";
123 update += "`" + field + "` = ?"+field;
124 115
125 first = false; 116 m_ColumnNames = columnNames;
126 117 }
127 cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
128 }
129 118
130 update += " where UUID = ?principalID"; 119 public bool Store(AuthenticationData data)
120 {
121 if (data.Data.ContainsKey("UUID"))
122 data.Data.Remove("UUID");
131 123
132 cmd.CommandText = update; 124 string[] fields = new List<string>(data.Data.Keys).ToArray();
133 cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
134 125
135 if (ExecuteNonQuery(cmd) < 1) 126 using (MySqlCommand cmd = new MySqlCommand())
136 { 127 {
137 string insert = "insert into `" + m_Realm + "` (`UUID`, `" + 128 string update = "update `"+m_Realm+"` set ";
138 String.Join("`, `", fields) + 129 bool first = true;
139 "`) values (?principalID, ?" + String.Join(", ?", fields) + ")"; 130 foreach (string field in fields)
140 131 {
141 cmd.CommandText = insert; 132 if (!first)
142 133 update += ", ";
134 update += "`" + field + "` = ?"+field;
135
136 first = false;
137
138 cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
139 }
140
141 update += " where UUID = ?principalID";
142
143 cmd.CommandText = update;
144 cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
145
143 if (ExecuteNonQuery(cmd) < 1) 146 if (ExecuteNonQuery(cmd) < 1)
144 { 147 {
145 cmd.Dispose(); 148 string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
146 return false; 149 String.Join("`, `", fields) +
150 "`) values (?principalID, ?" + String.Join(", ?", fields) + ")";
151
152 cmd.CommandText = insert;
153
154 if (ExecuteNonQuery(cmd) < 1)
155 return false;
147 } 156 }
148 } 157 }
149 158
150 cmd.Dispose();
151
152 return true; 159 return true;
153 } 160 }
154 161
155 public bool SetDataItem(UUID principalID, string item, string value) 162 public bool SetDataItem(UUID principalID, string item, string value)
156 { 163 {
157 MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + 164 using (MySqlCommand cmd
158 "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); 165 = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where UUID = ?UUID"))
159 166 {
160 167 cmd.Parameters.AddWithValue("?"+item, value);
161 cmd.Parameters.AddWithValue("?"+item, value); 168 cmd.Parameters.AddWithValue("?UUID", principalID.ToString());
162 cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); 169
163 170 if (ExecuteNonQuery(cmd) > 0)
164 if (ExecuteNonQuery(cmd) > 0) 171 return true;
165 return true; 172 }
166 173
167 return false; 174 return false;
168 } 175 }
@@ -172,18 +179,18 @@ namespace OpenSim.Data.MySQL
172 if (System.Environment.TickCount - m_LastExpire > 30000) 179 if (System.Environment.TickCount - m_LastExpire > 30000)
173 DoExpire(); 180 DoExpire();
174 181
175 MySqlCommand cmd = new MySqlCommand("insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))"); 182 using (MySqlCommand cmd
176 cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); 183 = new MySqlCommand(
177 cmd.Parameters.AddWithValue("?token", token); 184 "insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))"))
178 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
179
180 if (ExecuteNonQuery(cmd) > 0)
181 { 185 {
182 cmd.Dispose(); 186 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
183 return true; 187 cmd.Parameters.AddWithValue("?token", token);
188 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
189
190 if (ExecuteNonQuery(cmd) > 0)
191 return true;
184 } 192 }
185 193
186 cmd.Dispose();
187 return false; 194 return false;
188 } 195 }
189 196
@@ -192,30 +199,29 @@ namespace OpenSim.Data.MySQL
192 if (System.Environment.TickCount - m_LastExpire > 30000) 199 if (System.Environment.TickCount - m_LastExpire > 30000)
193 DoExpire(); 200 DoExpire();
194 201
195 MySqlCommand cmd = new MySqlCommand("update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()"); 202 using (MySqlCommand cmd
196 cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); 203 = new MySqlCommand(
197 cmd.Parameters.AddWithValue("?token", token); 204 "update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()"))
198 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
199
200 if (ExecuteNonQuery(cmd) > 0)
201 { 205 {
202 cmd.Dispose(); 206 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
203 return true; 207 cmd.Parameters.AddWithValue("?token", token);
204 } 208 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
205 209
206 cmd.Dispose(); 210 if (ExecuteNonQuery(cmd) > 0)
211 return true;
212 }
207 213
208 return false; 214 return false;
209 } 215 }
210 216
211 private void DoExpire() 217 private void DoExpire()
212 { 218 {
213 MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()"); 219 using (MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()"))
214 ExecuteNonQuery(cmd); 220 {
215 221 ExecuteNonQuery(cmd);
216 cmd.Dispose(); 222 }
217 223
218 m_LastExpire = System.Environment.TickCount; 224 m_LastExpire = System.Environment.TickCount;
219 } 225 }
220 } 226 }
221} 227} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs
index 8c841ab..6a2f5d8 100644
--- a/OpenSim/Data/MySQL/MySQLAvatarData.cs
+++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs
@@ -52,14 +52,15 @@ namespace OpenSim.Data.MySQL
52 52
53 public bool Delete(UUID principalID, string name) 53 public bool Delete(UUID principalID, string name)
54 { 54 {
55 MySqlCommand cmd = new MySqlCommand(); 55 using (MySqlCommand cmd = new MySqlCommand())
56 56 {
57 cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); 57 cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm);
58 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); 58 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
59 cmd.Parameters.AddWithValue("?Name", name); 59 cmd.Parameters.AddWithValue("?Name", name);
60 60
61 if (ExecuteNonQuery(cmd) > 0) 61 if (ExecuteNonQuery(cmd) > 0)
62 return true; 62 return true;
63 }
63 64
64 return false; 65 return false;
65 } 66 }
diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs
index 130ba5e..3cd6b8f 100644
--- a/OpenSim/Data/MySQL/MySQLFriendsData.cs
+++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs
@@ -49,34 +49,38 @@ namespace OpenSim.Data.MySQL
49 49
50 public bool Delete(string principalID, string friend) 50 public bool Delete(string principalID, string friend)
51 { 51 {
52 MySqlCommand cmd = new MySqlCommand(); 52 using (MySqlCommand cmd = new MySqlCommand())
53 {
54 cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm);
55 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
56 cmd.Parameters.AddWithValue("?Friend", friend);
53 57
54 cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); 58 ExecuteNonQuery(cmd);
55 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); 59 }
56 cmd.Parameters.AddWithValue("?Friend", friend);
57
58 ExecuteNonQuery(cmd);
59 60
60 return true; 61 return true;
61 } 62 }
62 63
63 public FriendsData[] GetFriends(UUID principalID) 64 public FriendsData[] GetFriends(UUID principalID)
64 { 65 {
65 MySqlCommand cmd = new MySqlCommand(); 66 using (MySqlCommand cmd = new MySqlCommand())
66 67 {
67 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); 68 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm);
68 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); 69 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
69 70
70 return DoQuery(cmd); 71 return DoQuery(cmd);
72 }
71 } 73 }
72 74
73 public FriendsData[] GetFriends(string principalID) 75 public FriendsData[] GetFriends(string principalID)
74 { 76 {
75 MySqlCommand cmd = new MySqlCommand(); 77 using (MySqlCommand cmd = new MySqlCommand())
78 {
79 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm);
80 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%');
76 81
77 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm); 82 return DoQuery(cmd);
78 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); 83 }
79 return DoQuery(cmd);
80 } 84 }
81 } 85 }
82} 86} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 786b955..86367a1 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -91,15 +91,17 @@ namespace OpenSim.Data.MySQL
91 if (m_ColumnNames != null) 91 if (m_ColumnNames != null)
92 return; 92 return;
93 93
94 m_ColumnNames = new List<string>(); 94 List<string> columnNames = new List<string>();
95 95
96 DataTable schemaTable = reader.GetSchemaTable(); 96 DataTable schemaTable = reader.GetSchemaTable();
97 foreach (DataRow row in schemaTable.Rows) 97 foreach (DataRow row in schemaTable.Rows)
98 { 98 {
99 if (row["ColumnName"] != null && 99 if (row["ColumnName"] != null &&
100 (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) 100 (!m_Fields.ContainsKey(row["ColumnName"].ToString())))
101 m_ColumnNames.Add(row["ColumnName"].ToString()); 101 columnNames.Add(row["ColumnName"].ToString());
102 } 102 }
103
104 m_ColumnNames = columnNames;
103 } 105 }
104 106
105 public virtual T[] Get(string field, string key) 107 public virtual T[] Get(string field, string key)
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 1a634e5..e9b10f3 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -467,43 +467,43 @@ namespace OpenSim.Data.MySQL
467 { 467 {
468 dbcon.Open(); 468 dbcon.Open();
469 469
470 MySqlCommand result = new MySqlCommand(sql, dbcon); 470 using (MySqlCommand result = new MySqlCommand(sql, dbcon))
471 result.Parameters.AddWithValue("?inventoryID", item.ID.ToString());
472 result.Parameters.AddWithValue("?assetID", item.AssetID.ToString());
473 result.Parameters.AddWithValue("?assetType", item.AssetType.ToString());
474 result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString());
475 result.Parameters.AddWithValue("?avatarID", item.Owner.ToString());
476 result.Parameters.AddWithValue("?inventoryName", itemName);
477 result.Parameters.AddWithValue("?inventoryDescription", itemDesc);
478 result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString());
479 result.Parameters.AddWithValue("?inventoryCurrentPermissions",
480 item.CurrentPermissions.ToString());
481 result.Parameters.AddWithValue("?invType", item.InvType);
482 result.Parameters.AddWithValue("?creatorID", item.CreatorId);
483 result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
484 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
485 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
486 result.Parameters.AddWithValue("?salePrice", item.SalePrice);
487 result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
488 result.Parameters.AddWithValue("?creationDate", item.CreationDate);
489 result.Parameters.AddWithValue("?groupID", item.GroupID);
490 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
491 result.Parameters.AddWithValue("?flags", item.Flags);
492
493 lock (m_dbLock)
494 { 471 {
495 result.ExecuteNonQuery(); 472 result.Parameters.AddWithValue("?inventoryID", item.ID.ToString());
473 result.Parameters.AddWithValue("?assetID", item.AssetID.ToString());
474 result.Parameters.AddWithValue("?assetType", item.AssetType.ToString());
475 result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString());
476 result.Parameters.AddWithValue("?avatarID", item.Owner.ToString());
477 result.Parameters.AddWithValue("?inventoryName", itemName);
478 result.Parameters.AddWithValue("?inventoryDescription", itemDesc);
479 result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString());
480 result.Parameters.AddWithValue("?inventoryCurrentPermissions",
481 item.CurrentPermissions.ToString());
482 result.Parameters.AddWithValue("?invType", item.InvType);
483 result.Parameters.AddWithValue("?creatorID", item.CreatorId);
484 result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
485 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
486 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
487 result.Parameters.AddWithValue("?salePrice", item.SalePrice);
488 result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
489 result.Parameters.AddWithValue("?creationDate", item.CreationDate);
490 result.Parameters.AddWithValue("?groupID", item.GroupID);
491 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
492 result.Parameters.AddWithValue("?flags", item.Flags);
493
494 lock (m_dbLock)
495 result.ExecuteNonQuery();
496
497 result.Dispose();
496 } 498 }
497 499
498 result.Dispose(); 500 using (MySqlCommand result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon))
499
500 result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon);
501 result.Parameters.AddWithValue("?folderID", item.Folder.ToString());
502 lock (m_dbLock)
503 { 501 {
504 result.ExecuteNonQuery(); 502 result.Parameters.AddWithValue("?folderID", item.Folder.ToString());
503
504 lock (m_dbLock)
505 result.ExecuteNonQuery();
505 } 506 }
506 result.Dispose();
507 } 507 }
508 } 508 }
509 catch (MySqlException e) 509 catch (MySqlException e)
@@ -533,12 +533,12 @@ namespace OpenSim.Data.MySQL
533 { 533 {
534 dbcon.Open(); 534 dbcon.Open();
535 535
536 MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon); 536 using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon))
537 cmd.Parameters.AddWithValue("?uuid", itemID.ToString());
538
539 lock (m_dbLock)
540 { 537 {
541 cmd.ExecuteNonQuery(); 538 cmd.Parameters.AddWithValue("?uuid", itemID.ToString());
539
540 lock (m_dbLock)
541 cmd.ExecuteNonQuery();
542 } 542 }
543 } 543 }
544 } 544 }
@@ -579,24 +579,26 @@ namespace OpenSim.Data.MySQL
579 { 579 {
580 dbcon.Open(); 580 dbcon.Open();
581 581
582 MySqlCommand cmd = new MySqlCommand(sql, dbcon); 582 using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
583 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
584 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
585 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
586 cmd.Parameters.AddWithValue("?folderName", folderName);
587 cmd.Parameters.AddWithValue("?type", folder.Type);
588 cmd.Parameters.AddWithValue("?version", folder.Version);
589
590 try
591 { 583 {
592 lock (m_dbLock) 584 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
585 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
586 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
587 cmd.Parameters.AddWithValue("?folderName", folderName);
588 cmd.Parameters.AddWithValue("?type", folder.Type);
589 cmd.Parameters.AddWithValue("?version", folder.Version);
590
591 try
593 { 592 {
594 cmd.ExecuteNonQuery(); 593 lock (m_dbLock)
594 {
595 cmd.ExecuteNonQuery();
596 }
597 }
598 catch (Exception e)
599 {
600 m_log.Error(e.ToString());
595 } 601 }
596 }
597 catch (Exception e)
598 {
599 m_log.Error(e.ToString());
600 } 602 }
601 } 603 }
602 } 604 }
@@ -624,20 +626,22 @@ namespace OpenSim.Data.MySQL
624 { 626 {
625 dbcon.Open(); 627 dbcon.Open();
626 628
627 MySqlCommand cmd = new MySqlCommand(sql, dbcon); 629 using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
628 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
629 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
630
631 try
632 { 630 {
633 lock (m_dbLock) 631 cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString());
632 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
633
634 try
634 { 635 {
635 cmd.ExecuteNonQuery(); 636 lock (m_dbLock)
637 {
638 cmd.ExecuteNonQuery();
639 }
640 }
641 catch (Exception e)
642 {
643 m_log.Error(e.ToString());
636 } 644 }
637 }
638 catch (Exception e)
639 {
640 m_log.Error(e.ToString());
641 } 645 }
642 } 646 }
643 } 647 }
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs
index fc625f0..7808060 100644
--- a/OpenSim/Data/MySQL/MySQLPresenceData.cs
+++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs
@@ -63,13 +63,14 @@ namespace OpenSim.Data.MySQL
63 63
64 public void LogoutRegionAgents(UUID regionID) 64 public void LogoutRegionAgents(UUID regionID)
65 { 65 {
66 MySqlCommand cmd = new MySqlCommand(); 66 using (MySqlCommand cmd = new MySqlCommand())
67 67 {
68 cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); 68 cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm);
69 69
70 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 70 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
71 71
72 ExecuteNonQuery(cmd); 72 ExecuteNonQuery(cmd);
73 }
73 } 74 }
74 75
75 public bool ReportAgent(UUID sessionID, UUID regionID) 76 public bool ReportAgent(UUID sessionID, UUID regionID)
@@ -81,17 +82,18 @@ namespace OpenSim.Data.MySQL
81 if (regionID == UUID.Zero) 82 if (regionID == UUID.Zero)
82 return false; 83 return false;
83 84
84 MySqlCommand cmd = new MySqlCommand(); 85 using (MySqlCommand cmd = new MySqlCommand())
85 86 {
86 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); 87 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm);
87 88
88 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); 89 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString());
89 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 90 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
90 91
91 if (ExecuteNonQuery(cmd) == 0) 92 if (ExecuteNonQuery(cmd) == 0)
92 return false; 93 return false;
94 }
93 95
94 return true; 96 return true;
95 } 97 }
96 } 98 }
97} 99} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index c20c392..0614879 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -162,17 +162,7 @@ namespace OpenSim.Data.MySQL
162 ret.sizeX = Convert.ToInt32(result["sizeX"]); 162 ret.sizeX = Convert.ToInt32(result["sizeX"]);
163 ret.sizeY = Convert.ToInt32(result["sizeY"]); 163 ret.sizeY = Convert.ToInt32(result["sizeY"]);
164 164
165 if (m_ColumnNames == null) 165 CheckColumnNames(result);
166 {
167 m_ColumnNames = new List<string>();
168
169 DataTable schemaTable = result.GetSchemaTable();
170 foreach (DataRow row in schemaTable.Rows)
171 {
172 if (row["ColumnName"] != null)
173 m_ColumnNames.Add(row["ColumnName"].ToString());
174 }
175 }
176 166
177 foreach (string s in m_ColumnNames) 167 foreach (string s in m_ColumnNames)
178 { 168 {
@@ -187,7 +177,11 @@ namespace OpenSim.Data.MySQL
187 if (s == "locY") 177 if (s == "locY")
188 continue; 178 continue;
189 179
190 ret.Data[s] = result[s].ToString(); 180 object value = result[s];
181 if (value is DBNull)
182 ret.Data[s] = null;
183 else
184 ret.Data[s] = result[s].ToString();
191 } 185 }
192 186
193 retList.Add(ret); 187 retList.Add(ret);
@@ -198,6 +192,23 @@ namespace OpenSim.Data.MySQL
198 return retList; 192 return retList;
199 } 193 }
200 194
195 private void CheckColumnNames(IDataReader result)
196 {
197 if (m_ColumnNames != null)
198 return;
199
200 List<string> columnNames = new List<string>();
201
202 DataTable schemaTable = result.GetSchemaTable();
203 foreach (DataRow row in schemaTable.Rows)
204 {
205 if (row["ColumnName"] != null)
206 columnNames.Add(row["ColumnName"].ToString());
207 }
208
209 m_ColumnNames = columnNames;
210 }
211
201 public bool Store(RegionData data) 212 public bool Store(RegionData data)
202 { 213 {
203 if (data.Data.ContainsKey("uuid")) 214 if (data.Data.ContainsKey("uuid"))
@@ -318,11 +329,12 @@ namespace OpenSim.Data.MySQL
318 if (scopeID != UUID.Zero) 329 if (scopeID != UUID.Zero)
319 command += " and ScopeID = ?scopeID"; 330 command += " and ScopeID = ?scopeID";
320 331
321 MySqlCommand cmd = new MySqlCommand(command); 332 using (MySqlCommand cmd = new MySqlCommand(command))
322 333 {
323 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 334 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
324 335
325 return RunCommand(cmd); 336 return RunCommand(cmd);
337 }
326 } 338 }
327 } 339 }
328} 340} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 7df5a81..29bd6b6 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -131,121 +131,121 @@ namespace OpenSim.Data.MySQL
131 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 131 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
132 { 132 {
133 dbcon.Open(); 133 dbcon.Open();
134 MySqlCommand cmd = dbcon.CreateCommand();
135 134
136 foreach (SceneObjectPart prim in obj.Parts) 135 using (MySqlCommand cmd = dbcon.CreateCommand())
137 { 136 {
138 cmd.Parameters.Clear(); 137 foreach (SceneObjectPart prim in obj.Parts)
138 {
139 cmd.Parameters.Clear();
139 140
140 cmd.CommandText = "replace into prims (" + 141 cmd.CommandText = "replace into prims (" +
141 "UUID, CreationDate, " + 142 "UUID, CreationDate, " +
142 "Name, Text, Description, " + 143 "Name, Text, Description, " +
143 "SitName, TouchName, ObjectFlags, " + 144 "SitName, TouchName, ObjectFlags, " +
144 "OwnerMask, NextOwnerMask, GroupMask, " + 145 "OwnerMask, NextOwnerMask, GroupMask, " +
145 "EveryoneMask, BaseMask, PositionX, " + 146 "EveryoneMask, BaseMask, PositionX, " +
146 "PositionY, PositionZ, GroupPositionX, " + 147 "PositionY, PositionZ, GroupPositionX, " +
147 "GroupPositionY, GroupPositionZ, VelocityX, " + 148 "GroupPositionY, GroupPositionZ, VelocityX, " +
148 "VelocityY, VelocityZ, AngularVelocityX, " + 149 "VelocityY, VelocityZ, AngularVelocityX, " +
149 "AngularVelocityY, AngularVelocityZ, " + 150 "AngularVelocityY, AngularVelocityZ, " +
150 "AccelerationX, AccelerationY, " + 151 "AccelerationX, AccelerationY, " +
151 "AccelerationZ, RotationX, " + 152 "AccelerationZ, RotationX, " +
152 "RotationY, RotationZ, " + 153 "RotationY, RotationZ, " +
153 "RotationW, SitTargetOffsetX, " + 154 "RotationW, SitTargetOffsetX, " +
154 "SitTargetOffsetY, SitTargetOffsetZ, " + 155 "SitTargetOffsetY, SitTargetOffsetZ, " +
155 "SitTargetOrientW, SitTargetOrientX, " + 156 "SitTargetOrientW, SitTargetOrientX, " +
156 "SitTargetOrientY, SitTargetOrientZ, " + 157 "SitTargetOrientY, SitTargetOrientZ, " +
157 "RegionUUID, CreatorID, " + 158 "RegionUUID, CreatorID, " +
158 "OwnerID, GroupID, " + 159 "OwnerID, GroupID, " +
159 "LastOwnerID, SceneGroupID, " + 160 "LastOwnerID, SceneGroupID, " +
160 "PayPrice, PayButton1, " + 161 "PayPrice, PayButton1, " +
161 "PayButton2, PayButton3, " + 162 "PayButton2, PayButton3, " +
162 "PayButton4, LoopedSound, " + 163 "PayButton4, LoopedSound, " +
163 "LoopedSoundGain, TextureAnimation, " + 164 "LoopedSoundGain, TextureAnimation, " +
164 "OmegaX, OmegaY, OmegaZ, " + 165 "OmegaX, OmegaY, OmegaZ, " +
165 "CameraEyeOffsetX, CameraEyeOffsetY, " + 166 "CameraEyeOffsetX, CameraEyeOffsetY, " +
166 "CameraEyeOffsetZ, CameraAtOffsetX, " + 167 "CameraEyeOffsetZ, CameraAtOffsetX, " +
167 "CameraAtOffsetY, CameraAtOffsetZ, " + 168 "CameraAtOffsetY, CameraAtOffsetZ, " +
168 "ForceMouselook, ScriptAccessPin, " + 169 "ForceMouselook, ScriptAccessPin, " +
169 "AllowedDrop, DieAtEdge, " + 170 "AllowedDrop, DieAtEdge, " +
170 "SalePrice, SaleType, " + 171 "SalePrice, SaleType, " +
171 "ColorR, ColorG, ColorB, ColorA, " + 172 "ColorR, ColorG, ColorB, ColorA, " +
172 "ParticleSystem, ClickAction, Material, " + 173 "ParticleSystem, ClickAction, Material, " +
173 "CollisionSound, CollisionSoundVolume, " + 174 "CollisionSound, CollisionSoundVolume, " +
174 "PassTouches, " + 175 "PassTouches, " +
175 "PassCollisions, " + 176 "PassCollisions, " +
176 "LinkNumber, MediaURL, KeyframeMotion, " + 177 "LinkNumber, MediaURL, KeyframeMotion, " +
177 "PhysicsShapeType, Density, GravityModifier, " + 178 "PhysicsShapeType, Density, GravityModifier, " +
178 "Friction, Restitution, Vehicle " + 179 "Friction, Restitution, Vehicle " +
179 ") values (" + "?UUID, " + 180 ") values (" + "?UUID, " +
180 "?CreationDate, ?Name, ?Text, " + 181 "?CreationDate, ?Name, ?Text, " +
181 "?Description, ?SitName, ?TouchName, " + 182 "?Description, ?SitName, ?TouchName, " +
182 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + 183 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " +
183 "?GroupMask, ?EveryoneMask, ?BaseMask, " + 184 "?GroupMask, ?EveryoneMask, ?BaseMask, " +
184 "?PositionX, ?PositionY, ?PositionZ, " + 185 "?PositionX, ?PositionY, ?PositionZ, " +
185 "?GroupPositionX, ?GroupPositionY, " + 186 "?GroupPositionX, ?GroupPositionY, " +
186 "?GroupPositionZ, ?VelocityX, " + 187 "?GroupPositionZ, ?VelocityX, " +
187 "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + 188 "?VelocityY, ?VelocityZ, ?AngularVelocityX, " +
188 "?AngularVelocityY, ?AngularVelocityZ, " + 189 "?AngularVelocityY, ?AngularVelocityZ, " +
189 "?AccelerationX, ?AccelerationY, " + 190 "?AccelerationX, ?AccelerationY, " +
190 "?AccelerationZ, ?RotationX, " + 191 "?AccelerationZ, ?RotationX, " +
191 "?RotationY, ?RotationZ, " + 192 "?RotationY, ?RotationZ, " +
192 "?RotationW, ?SitTargetOffsetX, " + 193 "?RotationW, ?SitTargetOffsetX, " +
193 "?SitTargetOffsetY, ?SitTargetOffsetZ, " + 194 "?SitTargetOffsetY, ?SitTargetOffsetZ, " +
194 "?SitTargetOrientW, ?SitTargetOrientX, " + 195 "?SitTargetOrientW, ?SitTargetOrientX, " +
195 "?SitTargetOrientY, ?SitTargetOrientZ, " + 196 "?SitTargetOrientY, ?SitTargetOrientZ, " +
196 "?RegionUUID, ?CreatorID, ?OwnerID, " + 197 "?RegionUUID, ?CreatorID, ?OwnerID, " +
197 "?GroupID, ?LastOwnerID, ?SceneGroupID, " + 198 "?GroupID, ?LastOwnerID, ?SceneGroupID, " +
198 "?PayPrice, ?PayButton1, ?PayButton2, " + 199 "?PayPrice, ?PayButton1, ?PayButton2, " +
199 "?PayButton3, ?PayButton4, ?LoopedSound, " + 200 "?PayButton3, ?PayButton4, ?LoopedSound, " +
200 "?LoopedSoundGain, ?TextureAnimation, " + 201 "?LoopedSoundGain, ?TextureAnimation, " +
201 "?OmegaX, ?OmegaY, ?OmegaZ, " + 202 "?OmegaX, ?OmegaY, ?OmegaZ, " +
202 "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + 203 "?CameraEyeOffsetX, ?CameraEyeOffsetY, " +
203 "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + 204 "?CameraEyeOffsetZ, ?CameraAtOffsetX, " +
204 "?CameraAtOffsetY, ?CameraAtOffsetZ, " + 205 "?CameraAtOffsetY, ?CameraAtOffsetZ, " +
205 "?ForceMouselook, ?ScriptAccessPin, " + 206 "?ForceMouselook, ?ScriptAccessPin, " +
206 "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + 207 "?AllowedDrop, ?DieAtEdge, ?SalePrice, " +
207 "?SaleType, ?ColorR, ?ColorG, " + 208 "?SaleType, ?ColorR, ?ColorG, " +
208 "?ColorB, ?ColorA, ?ParticleSystem, " + 209 "?ColorB, ?ColorA, ?ParticleSystem, " +
209 "?ClickAction, ?Material, ?CollisionSound, " + 210 "?ClickAction, ?Material, ?CollisionSound, " +
210 "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " + 211 "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " +
211 "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + 212 "?LinkNumber, ?MediaURL, ?KeyframeMotion, " +
212 "?PhysicsShapeType, ?Density, ?GravityModifier, " + 213 "?PhysicsShapeType, ?Density, ?GravityModifier, " +
213 "?Friction, ?Restitution, ?Vehicle)"; 214 "?Friction, ?Restitution, ?Vehicle)";
214 215
215 FillPrimCommand(cmd, prim, obj.UUID, regionUUID); 216 FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
216 217
217 ExecuteNonQuery(cmd); 218 ExecuteNonQuery(cmd);
218 219
219 cmd.Parameters.Clear(); 220 cmd.Parameters.Clear();
220 221
221 cmd.CommandText = "replace into primshapes (" + 222 cmd.CommandText = "replace into primshapes (" +
222 "UUID, Shape, ScaleX, ScaleY, " + 223 "UUID, Shape, ScaleX, ScaleY, " +
223 "ScaleZ, PCode, PathBegin, PathEnd, " + 224 "ScaleZ, PCode, PathBegin, PathEnd, " +
224 "PathScaleX, PathScaleY, PathShearX, " + 225 "PathScaleX, PathScaleY, PathShearX, " +
225 "PathShearY, PathSkew, PathCurve, " + 226 "PathShearY, PathSkew, PathCurve, " +
226 "PathRadiusOffset, PathRevolutions, " + 227 "PathRadiusOffset, PathRevolutions, " +
227 "PathTaperX, PathTaperY, PathTwist, " + 228 "PathTaperX, PathTaperY, PathTwist, " +
228 "PathTwistBegin, ProfileBegin, ProfileEnd, " + 229 "PathTwistBegin, ProfileBegin, ProfileEnd, " +
229 "ProfileCurve, ProfileHollow, Texture, " + 230 "ProfileCurve, ProfileHollow, Texture, " +
230 "ExtraParams, State, Media) values (?UUID, " + 231 "ExtraParams, State, Media) values (?UUID, " +
231 "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + 232 "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " +
232 "?PCode, ?PathBegin, ?PathEnd, " + 233 "?PCode, ?PathBegin, ?PathEnd, " +
233 "?PathScaleX, ?PathScaleY, " + 234 "?PathScaleX, ?PathScaleY, " +
234 "?PathShearX, ?PathShearY, " + 235 "?PathShearX, ?PathShearY, " +
235 "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + 236 "?PathSkew, ?PathCurve, ?PathRadiusOffset, " +
236 "?PathRevolutions, ?PathTaperX, " + 237 "?PathRevolutions, ?PathTaperX, " +
237 "?PathTaperY, ?PathTwist, " + 238 "?PathTaperY, ?PathTwist, " +
238 "?PathTwistBegin, ?ProfileBegin, " + 239 "?PathTwistBegin, ?ProfileBegin, " +
239 "?ProfileEnd, ?ProfileCurve, " + 240 "?ProfileEnd, ?ProfileCurve, " +
240 "?ProfileHollow, ?Texture, ?ExtraParams, " + 241 "?ProfileHollow, ?Texture, ?ExtraParams, " +
241 "?State, ?Media)"; 242 "?State, ?Media)";
242 243
243 FillShapeCommand(cmd, prim); 244 FillShapeCommand(cmd, prim);
244 245
245 ExecuteNonQuery(cmd); 246 ExecuteNonQuery(cmd);
247 }
246 } 248 }
247
248 cmd.Dispose();
249 } 249 }
250 } 250 }
251 } 251 }
@@ -997,6 +997,68 @@ namespace OpenSim.Data.MySQL
997 } 997 }
998 } 998 }
999 999
1000 #region RegionEnvironmentSettings
1001 public string LoadRegionEnvironmentSettings(UUID regionUUID)
1002 {
1003 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1004 {
1005 dbcon.Open();
1006
1007 string command = "select * from `regionenvironment` where region_id = ?region_id";
1008
1009 using (MySqlCommand cmd = new MySqlCommand(command))
1010 {
1011 cmd.Connection = dbcon;
1012
1013 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
1014
1015 IDataReader result = ExecuteReader(cmd);
1016 if (!result.Read())
1017 {
1018 return String.Empty;
1019 }
1020 else
1021 {
1022 return Convert.ToString(result["llsd_settings"]);
1023 }
1024 }
1025 }
1026 }
1027
1028 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
1029 {
1030 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1031 {
1032 dbcon.Open();
1033
1034 using (MySqlCommand cmd = dbcon.CreateCommand())
1035 {
1036 cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)";
1037
1038 cmd.Parameters.AddWithValue("region_id", regionUUID);
1039 cmd.Parameters.AddWithValue("llsd_settings", settings);
1040
1041 ExecuteNonQuery(cmd);
1042 }
1043 }
1044 }
1045
1046 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
1047 {
1048 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1049 {
1050 dbcon.Open();
1051
1052 using (MySqlCommand cmd = dbcon.CreateCommand())
1053 {
1054 cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id";
1055 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
1056 ExecuteNonQuery(cmd);
1057 }
1058 }
1059 }
1060 #endregion
1061
1000 public virtual void StoreRegionSettings(RegionSettings rs) 1062 public virtual void StoreRegionSettings(RegionSettings rs)
1001 { 1063 {
1002 lock (m_dbLock) 1064 lock (m_dbLock)
@@ -1897,41 +1959,40 @@ namespace OpenSim.Data.MySQL
1897 { 1959 {
1898 RemoveItems(primID); 1960 RemoveItems(primID);
1899 1961
1962 if (items.Count == 0)
1963 return;
1964
1900 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 1965 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1901 { 1966 {
1902 dbcon.Open(); 1967 dbcon.Open();
1903 1968
1904 MySqlCommand cmd = dbcon.CreateCommand(); 1969 using (MySqlCommand cmd = dbcon.CreateCommand())
1905
1906 if (items.Count == 0)
1907 return;
1908
1909 cmd.CommandText = "insert into primitems (" +
1910 "invType, assetType, name, " +
1911 "description, creationDate, nextPermissions, " +
1912 "currentPermissions, basePermissions, " +
1913 "everyonePermissions, groupPermissions, " +
1914 "flags, itemID, primID, assetID, " +
1915 "parentFolderID, creatorID, ownerID, " +
1916 "groupID, lastOwnerID) values (?invType, " +
1917 "?assetType, ?name, ?description, " +
1918 "?creationDate, ?nextPermissions, " +
1919 "?currentPermissions, ?basePermissions, " +
1920 "?everyonePermissions, ?groupPermissions, " +
1921 "?flags, ?itemID, ?primID, ?assetID, " +
1922 "?parentFolderID, ?creatorID, ?ownerID, " +
1923 "?groupID, ?lastOwnerID)";
1924
1925 foreach (TaskInventoryItem item in items)
1926 { 1970 {
1927 cmd.Parameters.Clear(); 1971 cmd.CommandText = "insert into primitems (" +
1928 1972 "invType, assetType, name, " +
1929 FillItemCommand(cmd, item); 1973 "description, creationDate, nextPermissions, " +
1930 1974 "currentPermissions, basePermissions, " +
1931 ExecuteNonQuery(cmd); 1975 "everyonePermissions, groupPermissions, " +
1976 "flags, itemID, primID, assetID, " +
1977 "parentFolderID, creatorID, ownerID, " +
1978 "groupID, lastOwnerID) values (?invType, " +
1979 "?assetType, ?name, ?description, " +
1980 "?creationDate, ?nextPermissions, " +
1981 "?currentPermissions, ?basePermissions, " +
1982 "?everyonePermissions, ?groupPermissions, " +
1983 "?flags, ?itemID, ?primID, ?assetID, " +
1984 "?parentFolderID, ?creatorID, ?ownerID, " +
1985 "?groupID, ?lastOwnerID)";
1986
1987 foreach (TaskInventoryItem item in items)
1988 {
1989 cmd.Parameters.Clear();
1990
1991 FillItemCommand(cmd, item);
1992
1993 ExecuteNonQuery(cmd);
1994 }
1932 } 1995 }
1933
1934 cmd.Dispose();
1935 } 1996 }
1936 } 1997 }
1937 } 1998 }
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index a18ac66..4ff3175 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -66,38 +66,40 @@ namespace OpenSim.Data.MySQL
66 if (words.Length > 2) 66 if (words.Length > 2)
67 return new UserAccountData[0]; 67 return new UserAccountData[0];
68 68
69 MySqlCommand cmd = new MySqlCommand(); 69 using (MySqlCommand cmd = new MySqlCommand())
70
71 if (words.Length == 1)
72 {
73 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm);
74 cmd.Parameters.AddWithValue("?search", words[0] + "%");
75 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
76 }
77 else
78 { 70 {
79 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm); 71 if (words.Length == 1)
80 cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%"); 72 {
81 cmd.Parameters.AddWithValue("?searchLast", words[1] + "%"); 73 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm);
82 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 74 cmd.Parameters.AddWithValue("?search", words[0] + "%");
83 } 75 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
76 }
77 else
78 {
79 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm);
80 cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%");
81 cmd.Parameters.AddWithValue("?searchLast", words[1] + "%");
82 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
83 }
84 84
85 return DoQuery(cmd); 85 return DoQuery(cmd);
86 }
86 } 87 }
87 88
88 public UserAccountData[] GetUsersWhere(UUID scopeID, string where) 89 public UserAccountData[] GetUsersWhere(UUID scopeID, string where)
89 { 90 {
90 MySqlCommand cmd = new MySqlCommand(); 91 using (MySqlCommand cmd = new MySqlCommand())
91
92 if (scopeID != UUID.Zero)
93 { 92 {
94 where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")"; 93 if (scopeID != UUID.Zero)
95 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 94 {
96 } 95 where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")";
96 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
97 }
97 98
98 cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm); 99 cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm);
99 100
100 return DoQuery(cmd); 101 return DoQuery(cmd);
102 }
101 } 103 }
102 } 104 }
103} 105}
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index ef99ef8..db0d0ec 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -883,3 +883,15 @@ ALTER TABLE `regionsettings` MODIFY COLUMN `TelehubObject` VARCHAR(36) NOT NULL
883 883
884COMMIT; 884COMMIT;
885 885
886:VERSION 44 #--------------------- Environment Settings
887
888BEGIN;
889
890CREATE TABLE `regionenvironment` (
891 `region_id` varchar(36) NOT NULL,
892 `llsd_settings` TEXT NOT NULL,
893 PRIMARY KEY (`region_id`)
894) ENGINE=InnoDB DEFAULT CHARSET=utf8;
895
896COMMIT;
897
diff --git a/OpenSim/Data/Null/NullSimulationData.cs b/OpenSim/Data/Null/NullSimulationData.cs
index 24b4511..a39ef0b 100644
--- a/OpenSim/Data/Null/NullSimulationData.cs
+++ b/OpenSim/Data/Null/NullSimulationData.cs
@@ -76,9 +76,27 @@ namespace OpenSim.Data.Null
76 //This connector doesn't support the windlight module yet 76 //This connector doesn't support the windlight module yet
77 } 77 }
78 78
79 #region Environment Settings
80 public string LoadRegionEnvironmentSettings(UUID regionUUID)
81 {
82 //This connector doesn't support the Environment module yet
83 return string.Empty;
84 }
85
86 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
87 {
88 //This connector doesn't support the Environment module yet
89 }
90
91 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
92 {
93 //This connector doesn't support the Environment module yet
94 }
95 #endregion
96
79 public RegionSettings LoadRegionSettings(UUID regionUUID) 97 public RegionSettings LoadRegionSettings(UUID regionUUID)
80 { 98 {
81 RegionSettings rs = new RegionSettings(); 99 RegionSettings rs = new RegionSettings();
82 rs.RegionUUID = regionUUID; 100 rs.RegionUUID = regionUUID;
83 return rs; 101 return rs;
84 } 102 }
diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
index 1ceddf9..e872977 100644
--- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations
+++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
@@ -564,3 +564,14 @@ COMMIT;
564BEGIN; 564BEGIN;
565ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; 565ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
566COMMIT; 566COMMIT;
567
568:VERSION 26
569
570BEGIN;
571
572CREATE TABLE `regionenvironment` (
573 `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000' PRIMARY KEY,
574 `llsd_settings` TEXT NOT NULL
575);
576
577COMMIT;
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index 9ec285c..9175a8f 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -61,6 +61,7 @@ namespace OpenSim.Data.SQLite
61 private const string regionbanListSelect = "select * from regionban"; 61 private const string regionbanListSelect = "select * from regionban";
62 private const string regionSettingsSelect = "select * from regionsettings"; 62 private const string regionSettingsSelect = "select * from regionsettings";
63 private const string regionWindlightSelect = "select * from regionwindlight"; 63 private const string regionWindlightSelect = "select * from regionwindlight";
64 private const string regionEnvironmentSelect = "select * from regionenvironment";
64 private const string regionSpawnPointsSelect = "select * from spawn_points"; 65 private const string regionSpawnPointsSelect = "select * from spawn_points";
65 66
66 private DataSet ds; 67 private DataSet ds;
@@ -72,6 +73,7 @@ namespace OpenSim.Data.SQLite
72 private SqliteDataAdapter landAccessListDa; 73 private SqliteDataAdapter landAccessListDa;
73 private SqliteDataAdapter regionSettingsDa; 74 private SqliteDataAdapter regionSettingsDa;
74 private SqliteDataAdapter regionWindlightDa; 75 private SqliteDataAdapter regionWindlightDa;
76 private SqliteDataAdapter regionEnvironmentDa;
75 private SqliteDataAdapter regionSpawnPointsDa; 77 private SqliteDataAdapter regionSpawnPointsDa;
76 78
77 private SqliteConnection m_conn; 79 private SqliteConnection m_conn;
@@ -146,6 +148,9 @@ namespace OpenSim.Data.SQLite
146 SqliteCommand regionWindlightSelectCmd = new SqliteCommand(regionWindlightSelect, m_conn); 148 SqliteCommand regionWindlightSelectCmd = new SqliteCommand(regionWindlightSelect, m_conn);
147 regionWindlightDa = new SqliteDataAdapter(regionWindlightSelectCmd); 149 regionWindlightDa = new SqliteDataAdapter(regionWindlightSelectCmd);
148 150
151 SqliteCommand regionEnvironmentSelectCmd = new SqliteCommand(regionEnvironmentSelect, m_conn);
152 regionEnvironmentDa = new SqliteDataAdapter(regionEnvironmentSelectCmd);
153
149 SqliteCommand regionSpawnPointsSelectCmd = new SqliteCommand(regionSpawnPointsSelect, m_conn); 154 SqliteCommand regionSpawnPointsSelectCmd = new SqliteCommand(regionSpawnPointsSelect, m_conn);
150 regionSpawnPointsDa = new SqliteDataAdapter(regionSpawnPointsSelectCmd); 155 regionSpawnPointsDa = new SqliteDataAdapter(regionSpawnPointsSelectCmd);
151 156
@@ -179,6 +184,9 @@ namespace OpenSim.Data.SQLite
179 ds.Tables.Add(createRegionWindlightTable()); 184 ds.Tables.Add(createRegionWindlightTable());
180 setupRegionWindlightCommands(regionWindlightDa, m_conn); 185 setupRegionWindlightCommands(regionWindlightDa, m_conn);
181 186
187 ds.Tables.Add(createRegionEnvironmentTable());
188 setupRegionEnvironmentCommands(regionEnvironmentDa, m_conn);
189
182 ds.Tables.Add(createRegionSpawnPointsTable()); 190 ds.Tables.Add(createRegionSpawnPointsTable());
183 setupRegionSpawnPointsCommands(regionSpawnPointsDa, m_conn); 191 setupRegionSpawnPointsCommands(regionSpawnPointsDa, m_conn);
184 192
@@ -260,6 +268,15 @@ namespace OpenSim.Data.SQLite
260 268
261 try 269 try
262 { 270 {
271 regionEnvironmentDa.Fill(ds.Tables["regionenvironment"]);
272 }
273 catch (Exception e)
274 {
275 m_log.ErrorFormat("[SQLITE REGION DB]: Caught fill error on regionenvironment table :{0}", e.Message);
276 }
277
278 try
279 {
263 regionSpawnPointsDa.Fill(ds.Tables["spawn_points"]); 280 regionSpawnPointsDa.Fill(ds.Tables["spawn_points"]);
264 } 281 }
265 catch (Exception e) 282 catch (Exception e)
@@ -278,12 +295,13 @@ namespace OpenSim.Data.SQLite
278 CreateDataSetMapping(landAccessListDa, "landaccesslist"); 295 CreateDataSetMapping(landAccessListDa, "landaccesslist");
279 CreateDataSetMapping(regionSettingsDa, "regionsettings"); 296 CreateDataSetMapping(regionSettingsDa, "regionsettings");
280 CreateDataSetMapping(regionWindlightDa, "regionwindlight"); 297 CreateDataSetMapping(regionWindlightDa, "regionwindlight");
298 CreateDataSetMapping(regionEnvironmentDa, "regionenvironment");
281 CreateDataSetMapping(regionSpawnPointsDa, "spawn_points"); 299 CreateDataSetMapping(regionSpawnPointsDa, "spawn_points");
282 } 300 }
283 } 301 }
284 catch (Exception e) 302 catch (Exception e)
285 { 303 {
286 m_log.ErrorFormat("[SQLITE REGION DB]: ", e); 304 m_log.ErrorFormat("[SQLITE REGION DB]: {0} - {1}", e.Message, e.StackTrace);
287 Environment.Exit(23); 305 Environment.Exit(23);
288 } 306 }
289 return; 307 return;
@@ -341,6 +359,11 @@ namespace OpenSim.Data.SQLite
341 regionWindlightDa.Dispose(); 359 regionWindlightDa.Dispose();
342 regionWindlightDa = null; 360 regionWindlightDa = null;
343 } 361 }
362 if (regionEnvironmentDa != null)
363 {
364 regionEnvironmentDa.Dispose();
365 regionEnvironmentDa = null;
366 }
344 if (regionSpawnPointsDa != null) 367 if (regionSpawnPointsDa != null)
345 { 368 {
346 regionSpawnPointsDa.Dispose(); 369 regionSpawnPointsDa.Dispose();
@@ -474,6 +497,63 @@ namespace OpenSim.Data.SQLite
474 } 497 }
475 } 498 }
476 499
500 #region Region Environment Settings
501 public string LoadRegionEnvironmentSettings(UUID regionUUID)
502 {
503 lock (ds)
504 {
505 DataTable environmentTable = ds.Tables["regionenvironment"];
506 DataRow row = environmentTable.Rows.Find(regionUUID.ToString());
507 if (row == null)
508 {
509 return String.Empty;
510 }
511
512 return (String)row["llsd_settings"];
513 }
514 }
515
516 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
517 {
518 lock (ds)
519 {
520 DataTable environmentTable = ds.Tables["regionenvironment"];
521 DataRow row = environmentTable.Rows.Find(regionUUID.ToString());
522
523 if (row == null)
524 {
525 row = environmentTable.NewRow();
526 row["region_id"] = regionUUID.ToString();
527 row["llsd_settings"] = settings;
528 environmentTable.Rows.Add(row);
529 }
530 else
531 {
532 row["llsd_settings"] = settings;
533 }
534
535 regionEnvironmentDa.Update(ds, "regionenvironment");
536 }
537 }
538
539 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
540 {
541 lock (ds)
542 {
543 DataTable environmentTable = ds.Tables["regionenvironment"];
544 DataRow row = environmentTable.Rows.Find(regionUUID.ToString());
545
546 if (row != null)
547 {
548 row.Delete();
549 }
550
551 regionEnvironmentDa.Update(ds, "regionenvironment");
552 }
553 }
554
555 #endregion
556
477 public RegionSettings LoadRegionSettings(UUID regionUUID) 557 public RegionSettings LoadRegionSettings(UUID regionUUID)
478 { 558 {
479 lock (ds) 559 lock (ds)
@@ -1430,6 +1510,17 @@ namespace OpenSim.Data.SQLite
1430 return regionwindlight; 1510 return regionwindlight;
1431 } 1511 }
1432 1512
1513 private static DataTable createRegionEnvironmentTable()
1514 {
1515 DataTable regionEnvironment = new DataTable("regionenvironment");
1516 createCol(regionEnvironment, "region_id", typeof(String));
1517 createCol(regionEnvironment, "llsd_settings", typeof(String));
1518
1519 regionEnvironment.PrimaryKey = new DataColumn[] { regionEnvironment.Columns["region_id"] };
1520
1521 return regionEnvironment;
1522 }
1523
1433 private static DataTable createRegionSpawnPointsTable() 1524 private static DataTable createRegionSpawnPointsTable()
1434 { 1525 {
1435 DataTable spawn_points = new DataTable("spawn_points"); 1526 DataTable spawn_points = new DataTable("spawn_points");
@@ -2691,6 +2782,14 @@ namespace OpenSim.Data.SQLite
2691 da.UpdateCommand.Connection = conn; 2782 da.UpdateCommand.Connection = conn;
2692 } 2783 }
2693 2784
2785 private void setupRegionEnvironmentCommands(SqliteDataAdapter da, SqliteConnection conn)
2786 {
2787 da.InsertCommand = createInsertCommand("regionenvironment", ds.Tables["regionenvironment"]);
2788 da.InsertCommand.Connection = conn;
2789 da.UpdateCommand = createUpdateCommand("regionenvironment", "region_id=:region_id", ds.Tables["regionenvironment"]);
2790 da.UpdateCommand.Connection = conn;
2791 }
2792
2694 private void setupRegionSpawnPointsCommands(SqliteDataAdapter da, SqliteConnection conn) 2793 private void setupRegionSpawnPointsCommands(SqliteDataAdapter da, SqliteConnection conn)
2695 { 2794 {
2696 da.InsertCommand = createInsertCommand("spawn_points", ds.Tables["spawn_points"]); 2795 da.InsertCommand = createInsertCommand("spawn_points", ds.Tables["spawn_points"]);
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
index 474609b..dbed8f6 100644
--- a/OpenSim/Data/Tests/RegionTests.cs
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -1069,8 +1069,6 @@ namespace OpenSim.Data.Tests
1069 regionInfo.RegionLocX = 0; 1069 regionInfo.RegionLocX = 0;
1070 regionInfo.RegionLocY = 0; 1070 regionInfo.RegionLocY = 0;
1071 1071
1072 Scene scene = new Scene(regionInfo);
1073
1074 SceneObjectPart sop = new SceneObjectPart(); 1072 SceneObjectPart sop = new SceneObjectPart();
1075 sop.Name = name; 1073 sop.Name = name;
1076 sop.Description = name; 1074 sop.Description = name;
@@ -1081,7 +1079,7 @@ namespace OpenSim.Data.Tests
1081 sop.Shape = PrimitiveBaseShape.Default; 1079 sop.Shape = PrimitiveBaseShape.Default;
1082 1080
1083 SceneObjectGroup sog = new SceneObjectGroup(sop); 1081 SceneObjectGroup sog = new SceneObjectGroup(sop);
1084 sog.SetScene(scene); 1082// sog.SetScene(scene);
1085 1083
1086 return sog; 1084 return sog;
1087 } 1085 }