aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/IMuteListData.cs44
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs47
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs36
-rw-r--r--OpenSim/Data/MySQL/MySQLEstateData.cs12
-rw-r--r--OpenSim/Data/MySQL/MySQLFSAssetData.cs12
-rw-r--r--OpenSim/Data/MySQL/MySQLFramework.cs9
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs40
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs14
-rw-r--r--OpenSim/Data/MySQL/MySQLMuteListData.cs67
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs3
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs305
-rw-r--r--OpenSim/Data/MySQL/MySQLUserProfilesData.cs417
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs57
-rw-r--r--OpenSim/Data/MySQL/MySQLXInventoryData.cs1
-rw-r--r--OpenSim/Data/MySQL/Resources/MuteListStore.migrations16
-rw-r--r--OpenSim/Data/MySQL/Resources/RegionStore.migrations6
-rw-r--r--OpenSim/Data/MySQL/Resources/os_groups_Store.migrations2
-rw-r--r--OpenSim/Data/PGSQL/PGSQLFSAssetData.cs316
-rwxr-xr-xOpenSim/Data/PGSQL/PGSQLGroupsData.cs4
-rwxr-xr-xOpenSim/Data/PGSQL/PGSQLSimulationData.cs47
-rw-r--r--OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs2
-rw-r--r--OpenSim/Data/PGSQL/PGSQLXAssetData.cs20
-rw-r--r--OpenSim/Data/PGSQL/PGSQLXInventoryData.cs2
-rw-r--r--OpenSim/Data/PGSQL/Resources/AgentPrefs.migrations19
-rw-r--r--OpenSim/Data/PGSQL/Resources/EstateStore.migrations410
-rw-r--r--OpenSim/Data/PGSQL/Resources/FSAssetStore.migrations14
-rw-r--r--OpenSim/Data/PGSQL/Resources/RegionStore.migrations30
-rw-r--r--OpenSim/Data/SQLite/Resources/MuteListStore.migrations16
-rw-r--r--OpenSim/Data/SQLite/Resources/RegionStore.migrations6
-rw-r--r--OpenSim/Data/SQLite/SQLiteMuteListData.cs71
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs11
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserProfilesData.cs4
-rw-r--r--OpenSim/Data/SQLite/SQLiteXInventoryData.cs10
33 files changed, 1303 insertions, 767 deletions
diff --git a/OpenSim/Data/IMuteListData.cs b/OpenSim/Data/IMuteListData.cs
new file mode 100644
index 0000000..b0235b2
--- /dev/null
+++ b/OpenSim/Data/IMuteListData.cs
@@ -0,0 +1,44 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Data
34{
35 /// <summary>
36 /// An interface for connecting to the Mute List datastore
37 /// </summary>
38 public interface IMuteListData
39 {
40 bool Store(MuteData data);
41 MuteData[] Get(UUID agentID);
42 bool Delete(UUID agentID, UUID muteID, string muteName);
43 }
44}
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index f16cd91..8569c90 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -75,6 +75,7 @@ namespace OpenSim.Data.MySQL
75 dbcon.Open(); 75 dbcon.Open();
76 Migration m = new Migration(dbcon, Assembly, "AssetStore"); 76 Migration m = new Migration(dbcon, Assembly, "AssetStore");
77 m.Update(); 77 m.Update();
78 dbcon.Close();
78 } 79 }
79 } 80 }
80 81
@@ -144,6 +145,7 @@ namespace OpenSim.Data.MySQL
144 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); 145 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e);
145 } 146 }
146 } 147 }
148 dbcon.Close();
147 } 149 }
148 150
149 return asset; 151 return asset;
@@ -156,28 +158,27 @@ namespace OpenSim.Data.MySQL
156 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> 158 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
157 override public bool StoreAsset(AssetBase asset) 159 override public bool StoreAsset(AssetBase asset)
158 { 160 {
159 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 161 string assetName = asset.Name;
162 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
160 { 163 {
161 dbcon.Open(); 164 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
162 165 m_log.WarnFormat(
163 string assetName = asset.Name; 166 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
164 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) 167 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
165 { 168 }
166 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
167 m_log.WarnFormat(
168 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
169 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
170 }
171 169
172 string assetDescription = asset.Description; 170 string assetDescription = asset.Description;
173 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) 171 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
174 { 172 {
175 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); 173 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
176 m_log.WarnFormat( 174 m_log.WarnFormat(
177 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", 175 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
178 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); 176 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
179 } 177 }
180 178
179 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
180 {
181 dbcon.Open();
181 using (MySqlCommand cmd = 182 using (MySqlCommand cmd =
182 new MySqlCommand( 183 new MySqlCommand(
183 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + 184 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
@@ -200,15 +201,17 @@ namespace OpenSim.Data.MySQL
200 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); 201 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
201 cmd.Parameters.AddWithValue("?data", asset.Data); 202 cmd.Parameters.AddWithValue("?data", asset.Data);
202 cmd.ExecuteNonQuery(); 203 cmd.ExecuteNonQuery();
204 dbcon.Close();
203 return true; 205 return true;
204 } 206 }
205 catch (Exception e) 207 catch (Exception e)
206 { 208 {
207 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", 209 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
208 asset.FullID, asset.Name, e.Message); 210 asset.FullID, asset.Name, e.Message);
211 dbcon.Close();
209 return false; 212 return false;
210 } 213 }
211 } 214 }
212 } 215 }
213 } 216 }
214 217
@@ -238,6 +241,7 @@ namespace OpenSim.Data.MySQL
238 e); 241 e);
239 } 242 }
240 } 243 }
244 dbcon.Close();
241 } 245 }
242 } 246 }
243 247
@@ -270,6 +274,7 @@ namespace OpenSim.Data.MySQL
270 } 274 }
271 } 275 }
272 } 276 }
277 dbcon.Close();
273 } 278 }
274 279
275 bool[] results = new bool[uuids.Length]; 280 bool[] results = new bool[uuids.Length];
@@ -334,6 +339,7 @@ namespace OpenSim.Data.MySQL
334 e); 339 e);
335 } 340 }
336 } 341 }
342 dbcon.Close();
337 } 343 }
338 344
339 return retList; 345 return retList;
@@ -350,6 +356,7 @@ namespace OpenSim.Data.MySQL
350 cmd.Parameters.AddWithValue("?id", id); 356 cmd.Parameters.AddWithValue("?id", id);
351 cmd.ExecuteNonQuery(); 357 cmd.ExecuteNonQuery();
352 } 358 }
359 dbcon.Close();
353 } 360 }
354 361
355 return true; 362 return true;
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index af6be75..fef582e 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -59,6 +59,7 @@ namespace OpenSim.Data.MySQL
59 dbcon.Open(); 59 dbcon.Open();
60 Migration m = new Migration(dbcon, Assembly, "AuthStore"); 60 Migration m = new Migration(dbcon, Assembly, "AuthStore");
61 m.Update(); 61 m.Update();
62 dbcon.Close();
62 } 63 }
63 } 64 }
64 65
@@ -76,27 +77,30 @@ namespace OpenSim.Data.MySQL
76 { 77 {
77 cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); 78 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
78 79
79 IDataReader result = cmd.ExecuteReader(); 80 using(IDataReader result = cmd.ExecuteReader())
80
81 if (result.Read())
82 { 81 {
83 ret.PrincipalID = principalID; 82 if(result.Read())
83 {
84 ret.PrincipalID = principalID;
84 85
85 CheckColumnNames(result); 86 CheckColumnNames(result);
86 87
87 foreach (string s in m_ColumnNames) 88 foreach(string s in m_ColumnNames)
88 { 89 {
89 if (s == "UUID") 90 if(s == "UUID")
90 continue; 91 continue;
91 92
92 ret.Data[s] = result[s].ToString(); 93 ret.Data[s] = result[s].ToString();
93 } 94 }
94 95
95 return ret; 96 dbcon.Close();
96 } 97 return ret;
97 else 98 }
98 { 99 else
99 return null; 100 {
101 dbcon.Close();
102 return null;
103 }
100 } 104 }
101 } 105 }
102 } 106 }
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs
index a5c8d24..eeedf02 100644
--- a/OpenSim/Data/MySQL/MySQLEstateData.cs
+++ b/OpenSim/Data/MySQL/MySQLEstateData.cs
@@ -82,6 +82,7 @@ namespace OpenSim.Data.MySQL
82 82
83 Migration m = new Migration(dbcon, Assembly, "EstateStore"); 83 Migration m = new Migration(dbcon, Assembly, "EstateStore");
84 m.Update(); 84 m.Update();
85 dbcon.Close();
85 86
86 Type t = typeof(EstateSettings); 87 Type t = typeof(EstateSettings);
87 m_Fields = t.GetFields(BindingFlags.NonPublic | 88 m_Fields = t.GetFields(BindingFlags.NonPublic |
@@ -143,7 +144,6 @@ namespace OpenSim.Data.MySQL
143 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 144 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
144 { 145 {
145 dbcon.Open(); 146 dbcon.Open();
146
147 cmd.Connection = dbcon; 147 cmd.Connection = dbcon;
148 148
149 bool found = false; 149 bool found = false;
@@ -171,6 +171,8 @@ namespace OpenSim.Data.MySQL
171 } 171 }
172 } 172 }
173 } 173 }
174 dbcon.Close();
175 cmd.Connection = null;
174 176
175 if (!found && create) 177 if (!found && create)
176 { 178 {
@@ -231,6 +233,7 @@ namespace OpenSim.Data.MySQL
231 233
232 es.Save(); 234 es.Save();
233 } 235 }
236 dbcon.Close();
234 } 237 }
235 } 238 }
236 239
@@ -263,6 +266,7 @@ namespace OpenSim.Data.MySQL
263 266
264 cmd.ExecuteNonQuery(); 267 cmd.ExecuteNonQuery();
265 } 268 }
269 dbcon.Close();
266 } 270 }
267 271
268 SaveBanList(es); 272 SaveBanList(es);
@@ -300,6 +304,7 @@ namespace OpenSim.Data.MySQL
300 } 304 }
301 } 305 }
302 } 306 }
307 dbcon.Close();
303 } 308 }
304 } 309 }
305 310
@@ -329,6 +334,7 @@ namespace OpenSim.Data.MySQL
329 cmd.Parameters.Clear(); 334 cmd.Parameters.Clear();
330 } 335 }
331 } 336 }
337 dbcon.Close();
332 } 338 }
333 } 339 }
334 340
@@ -358,6 +364,7 @@ namespace OpenSim.Data.MySQL
358 cmd.Parameters.Clear(); 364 cmd.Parameters.Clear();
359 } 365 }
360 } 366 }
367 dbcon.Close();
361 } 368 }
362 } 369 }
363 370
@@ -383,6 +390,7 @@ namespace OpenSim.Data.MySQL
383 } 390 }
384 } 391 }
385 } 392 }
393 dbcon.Close();
386 } 394 }
387 395
388 return uuids.ToArray(); 396 return uuids.ToArray();
@@ -437,7 +445,6 @@ namespace OpenSim.Data.MySQL
437 reader.Close(); 445 reader.Close();
438 } 446 }
439 } 447 }
440
441 dbcon.Close(); 448 dbcon.Close();
442 } 449 }
443 450
@@ -466,7 +473,6 @@ namespace OpenSim.Data.MySQL
466 reader.Close(); 473 reader.Close();
467 } 474 }
468 } 475 }
469
470 dbcon.Close(); 476 dbcon.Close();
471 } 477 }
472 478
diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs
index 2837ce3..6c48607 100644
--- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs
@@ -78,6 +78,7 @@ namespace OpenSim.Data.MySQL
78 conn.Open(); 78 conn.Open();
79 Migration m = new Migration(conn, Assembly, "FSAssetStore"); 79 Migration m = new Migration(conn, Assembly, "FSAssetStore");
80 m.Update(); 80 m.Update();
81 conn.Close();
81 } 82 }
82 } 83 }
83 catch (MySqlException e) 84 catch (MySqlException e)
@@ -121,9 +122,13 @@ namespace OpenSim.Data.MySQL
121 } 122 }
122 catch (MySqlException e) 123 catch (MySqlException e)
123 { 124 {
125 cmd.Connection = null;
126 conn.Close();
124 m_log.ErrorFormat("[FSASSETS]: Query {0} failed with {1}", cmd.CommandText, e.ToString()); 127 m_log.ErrorFormat("[FSASSETS]: Query {0} failed with {1}", cmd.CommandText, e.ToString());
125 return false; 128 return false;
126 } 129 }
130 conn.Close();
131 cmd.Connection = null;
127 } 132 }
128 133
129 return true; 134 return true;
@@ -175,7 +180,7 @@ namespace OpenSim.Data.MySQL
175 UpdateAccessTime(id, AccessTime); 180 UpdateAccessTime(id, AccessTime);
176 } 181 }
177 } 182 }
178 183 conn.Close();
179 } 184 }
180 185
181 return meta; 186 return meta;
@@ -206,6 +211,7 @@ namespace OpenSim.Data.MySQL
206 cmd.Parameters.AddWithValue("?id", AssetID); 211 cmd.Parameters.AddWithValue("?id", AssetID);
207 cmd.ExecuteNonQuery(); 212 cmd.ExecuteNonQuery();
208 } 213 }
214 conn.Close();
209 } 215 }
210 } 216 }
211 217
@@ -299,6 +305,7 @@ namespace OpenSim.Data.MySQL
299 } 305 }
300 } 306 }
301 } 307 }
308 conn.Close();
302 } 309 }
303 310
304 for (int i = 0; i < uuids.Length; i++) 311 for (int i = 0; i < uuids.Length; i++)
@@ -333,6 +340,7 @@ namespace OpenSim.Data.MySQL
333 count = Convert.ToInt32(reader["count"]); 340 count = Convert.ToInt32(reader["count"]);
334 } 341 }
335 } 342 }
343 conn.Close();
336 } 344 }
337 345
338 return count; 346 return count;
@@ -413,8 +421,8 @@ namespace OpenSim.Data.MySQL
413 imported++; 421 imported++;
414 } 422 }
415 } 423 }
416
417 } 424 }
425 importConn.Close();
418 } 426 }
419 427
420 MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); 428 MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported));
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs
index 93662db..98106f0 100644
--- a/OpenSim/Data/MySQL/MySQLFramework.cs
+++ b/OpenSim/Data/MySQL/MySQLFramework.cs
@@ -74,7 +74,9 @@ namespace OpenSim.Data.MySQL
74 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 74 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
75 { 75 {
76 dbcon.Open(); 76 dbcon.Open();
77 return ExecuteNonQueryWithConnection(cmd, dbcon); 77 int ret = ExecuteNonQueryWithConnection(cmd, dbcon);
78 dbcon.Close();
79 return ret;
78 } 80 }
79 } 81 }
80 else 82 else
@@ -97,12 +99,15 @@ namespace OpenSim.Data.MySQL
97 99
98 try 100 try
99 { 101 {
100 return cmd.ExecuteNonQuery(); 102 int ret = cmd.ExecuteNonQuery();
103 cmd.Connection = null;
104 return ret;
101 } 105 }
102 catch (Exception e) 106 catch (Exception e)
103 { 107 {
104 m_log.Error(e.Message, e); 108 m_log.Error(e.Message, e);
105 m_log.Error(Environment.StackTrace.ToString()); 109 m_log.Error(Environment.StackTrace.ToString());
110 cmd.Connection = null;
106 return 0; 111 return 0;
107 } 112 }
108 } 113 }
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index bd8bbd5..1564140 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -29,11 +29,9 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Data; 30using System.Data;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using System.Text;
33using MySql.Data.MySqlClient; 33using MySql.Data.MySqlClient;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37 35
38namespace OpenSim.Data.MySQL 36namespace OpenSim.Data.MySQL
39{ 37{
@@ -129,25 +127,27 @@ namespace OpenSim.Data.MySQL
129 127
130 public virtual T[] Get(string[] fields, string[] keys, string options) 128 public virtual T[] Get(string[] fields, string[] keys, string options)
131 { 129 {
132 if (fields.Length != keys.Length) 130 int flen = fields.Length;
131 if (flen == 0 || flen != keys.Length)
133 return new T[0]; 132 return new T[0];
134 133
135 List<string> terms = new List<string>(); 134 int flast = flen - 1;
135 StringBuilder sb = new StringBuilder(1024);
136 sb.AppendFormat("select * from {0} where ", m_Realm);
136 137
137 using (MySqlCommand cmd = new MySqlCommand()) 138 using (MySqlCommand cmd = new MySqlCommand())
138 { 139 {
139 for (int i = 0 ; i < fields.Length ; i++) 140 for (int i = 0 ; i < flen ; i++)
140 { 141 {
141 cmd.Parameters.AddWithValue(fields[i], keys[i]); 142 cmd.Parameters.AddWithValue(fields[i], keys[i]);
142 terms.Add("`" + fields[i] + "` = ?" + fields[i]); 143 if(i< flast)
144 sb.AppendFormat("`{0}` = ?{0} and ", fields[i]);
145 else
146 sb.AppendFormat("`{0}` = ?{0} ", fields[i]);
143 } 147 }
144 148
145 string where = String.Join(" and ", terms.ToArray()); 149 sb.Append(options);
146 150 cmd.CommandText = sb.ToString();
147 string query = String.Format("select * from {0} where {1} {2}",
148 m_Realm, where, options);
149
150 cmd.CommandText = query;
151 151
152 return DoQuery(cmd); 152 return DoQuery(cmd);
153 } 153 }
@@ -160,8 +160,9 @@ namespace OpenSim.Data.MySQL
160 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 160 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
161 { 161 {
162 dbcon.Open(); 162 dbcon.Open();
163 163 T[] ret = DoQueryWithConnection(cmd, dbcon);
164 return DoQueryWithConnection(cmd, dbcon); 164 dbcon.Close();
165 return ret;
165 } 166 }
166 } 167 }
167 else 168 else
@@ -203,7 +204,7 @@ namespace OpenSim.Data.MySQL
203 if (m_Fields[name].FieldType == typeof(bool)) 204 if (m_Fields[name].FieldType == typeof(bool))
204 { 205 {
205 int v = Convert.ToInt32(reader[name]); 206 int v = Convert.ToInt32(reader[name]);
206 m_Fields[name].SetValue(row, v != 0 ? true : false); 207 m_Fields[name].SetValue(row, v != 0);
207 } 208 }
208 else if (m_Fields[name].FieldType == typeof(UUID)) 209 else if (m_Fields[name].FieldType == typeof(UUID))
209 { 210 {
@@ -243,7 +244,7 @@ namespace OpenSim.Data.MySQL
243 result.Add(row); 244 result.Add(row);
244 } 245 }
245 } 246 }
246 247 cmd.Connection = null;
247 return result.ToArray(); 248 return result.ToArray();
248 } 249 }
249 250
@@ -402,7 +403,10 @@ namespace OpenSim.Data.MySQL
402 dbcon.Open(); 403 dbcon.Open();
403 cmd.Connection = dbcon; 404 cmd.Connection = dbcon;
404 405
405 return cmd.ExecuteScalar(); 406 Object ret = cmd.ExecuteScalar();
407 cmd.Connection = null;
408 dbcon.Close();
409 return ret;
406 } 410 }
407 } 411 }
408 else 412 else
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 382d4a5..cc787cc 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -78,6 +78,7 @@ namespace OpenSim.Data.MySQL
78 dbcon.Open(); 78 dbcon.Open();
79 Migration m = new Migration(dbcon, assem, "InventoryStore"); 79 Migration m = new Migration(dbcon, assem, "InventoryStore");
80 m.Update(); 80 m.Update();
81 dbcon.Close();
81 } 82 }
82 } 83 }
83 84
@@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
130 items.Add(item); 131 items.Add(item);
131 } 132 }
132 133
134 dbcon.Close();
133 return items; 135 return items;
134 } 136 }
135 } 137 }
@@ -170,6 +172,7 @@ namespace OpenSim.Data.MySQL
170 while (reader.Read()) 172 while (reader.Read())
171 items.Add(readInventoryFolder(reader)); 173 items.Add(readInventoryFolder(reader));
172 174
175 dbcon.Close();
173 return items; 176 return items;
174 } 177 }
175 } 178 }
@@ -221,6 +224,7 @@ namespace OpenSim.Data.MySQL
221 if (items.Count > 0) 224 if (items.Count > 0)
222 rootFolder = items[0]; 225 rootFolder = items[0];
223 226
227 dbcon.Close();
224 return rootFolder; 228 return rootFolder;
225 } 229 }
226 } 230 }
@@ -261,6 +265,7 @@ namespace OpenSim.Data.MySQL
261 while (reader.Read()) 265 while (reader.Read())
262 items.Add(readInventoryFolder(reader)); 266 items.Add(readInventoryFolder(reader));
263 267
268 dbcon.Close();
264 return items; 269 return items;
265 } 270 }
266 } 271 }
@@ -352,6 +357,7 @@ namespace OpenSim.Data.MySQL
352 if (reader.Read()) 357 if (reader.Read())
353 item = readInventoryItem(reader); 358 item = readInventoryItem(reader);
354 359
360 dbcon.Close();
355 return item; 361 return item;
356 } 362 }
357 } 363 }
@@ -417,6 +423,7 @@ namespace OpenSim.Data.MySQL
417 if (reader.Read()) 423 if (reader.Read())
418 folder = readInventoryFolder(reader); 424 folder = readInventoryFolder(reader);
419 425
426 dbcon.Close();
420 return folder; 427 return folder;
421 } 428 }
422 } 429 }
@@ -504,6 +511,7 @@ namespace OpenSim.Data.MySQL
504 lock (m_dbLock) 511 lock (m_dbLock)
505 result.ExecuteNonQuery(); 512 result.ExecuteNonQuery();
506 } 513 }
514 dbcon.Close();
507 } 515 }
508 } 516 }
509 catch (MySqlException e) 517 catch (MySqlException e)
@@ -540,6 +548,7 @@ namespace OpenSim.Data.MySQL
540 lock (m_dbLock) 548 lock (m_dbLock)
541 cmd.ExecuteNonQuery(); 549 cmd.ExecuteNonQuery();
542 } 550 }
551 dbcon.Close();
543 } 552 }
544 } 553 }
545 catch (MySqlException e) 554 catch (MySqlException e)
@@ -600,6 +609,7 @@ namespace OpenSim.Data.MySQL
600 m_log.Error(e.ToString()); 609 m_log.Error(e.ToString());
601 } 610 }
602 } 611 }
612 dbcon.Close();
603 } 613 }
604 } 614 }
605 615
@@ -643,6 +653,7 @@ namespace OpenSim.Data.MySQL
643 m_log.Error(e.ToString()); 653 m_log.Error(e.ToString());
644 } 654 }
645 } 655 }
656 dbcon.Close();
646 } 657 }
647 } 658 }
648 659
@@ -806,6 +817,7 @@ namespace OpenSim.Data.MySQL
806 lock (m_dbLock) 817 lock (m_dbLock)
807 cmd.ExecuteNonQuery(); 818 cmd.ExecuteNonQuery();
808 } 819 }
820 dbcon.Close();
809 } 821 }
810 } 822 }
811 catch (MySqlException e) 823 catch (MySqlException e)
@@ -833,6 +845,7 @@ namespace OpenSim.Data.MySQL
833 lock (m_dbLock) 845 lock (m_dbLock)
834 cmd.ExecuteNonQuery(); 846 cmd.ExecuteNonQuery();
835 } 847 }
848 dbcon.Close();
836 } 849 }
837 } 850 }
838 catch (MySqlException e) 851 catch (MySqlException e)
@@ -886,6 +899,7 @@ namespace OpenSim.Data.MySQL
886 if (item != null) 899 if (item != null)
887 list.Add(item); 900 list.Add(item);
888 } 901 }
902 dbcon.Close();
889 return list; 903 return list;
890 } 904 }
891 } 905 }
diff --git a/OpenSim/Data/MySQL/MySQLMuteListData.cs b/OpenSim/Data/MySQL/MySQLMuteListData.cs
new file mode 100644
index 0000000..a5935a3
--- /dev/null
+++ b/OpenSim/Data/MySQL/MySQLMuteListData.cs
@@ -0,0 +1,67 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34using MySql.Data.MySqlClient;
35
36namespace OpenSim.Data.MySQL
37{
38 public class MySqlMuteListData : MySQLGenericTableHandler<MuteData>, IMuteListData
39 {
40 public MySqlMuteListData(string connectionString)
41 : base(connectionString, "MuteList", "MuteListStore")
42 {
43 }
44
45 public MuteData[] Get(UUID agentID)
46 {
47 MuteData[] data = base.Get("AgentID", agentID.ToString());
48 return data;
49 }
50
51 public bool Delete(UUID agentID, UUID muteID, string muteName)
52 {
53 string cmnd ="delete from MuteList where AgentID = ?AgentID and MuteID = ?MuteID and MuteName = ?MuteName";
54
55 using (MySqlCommand cmd = new MySqlCommand(cmnd))
56 {
57 cmd.Parameters.AddWithValue("?AgentID", agentID.ToString());
58 cmd.Parameters.AddWithValue("?MuteID", muteID.ToString());
59 cmd.Parameters.AddWithValue("?MuteName", muteName);
60
61 if (ExecuteNonQuery(cmd) > 0)
62 return true;
63 return false;
64 }
65 }
66 }
67} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 0e55285..46df421 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Data.MySQL
60 dbcon.Open(); 60 dbcon.Open();
61 Migration m = new Migration(dbcon, Assembly, "GridStore"); 61 Migration m = new Migration(dbcon, Assembly, "GridStore");
62 m.Update(); 62 m.Update();
63 dbcon.Close();
63 } 64 }
64 } 65 }
65 66
@@ -260,6 +261,8 @@ namespace OpenSim.Data.MySQL
260 retList.Add(ret); 261 retList.Add(ret);
261 } 262 }
262 } 263 }
264 cmd.Connection = null;
265 dbcon.Close();
263 } 266 }
264 267
265 return retList; 268 return retList;
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 8278c0e..e754522 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -88,6 +88,7 @@ namespace OpenSim.Data.MySQL
88 // 88 //
89 Migration m = new Migration(dbcon, Assembly, "RegionStore"); 89 Migration m = new Migration(dbcon, Assembly, "RegionStore");
90 m.Update(); 90 m.Update();
91 dbcon.Close();
91 } 92 }
92 } 93 }
93 94
@@ -187,7 +188,7 @@ namespace OpenSim.Data.MySQL
187 "LinkNumber, MediaURL, KeyframeMotion, AttachedPosX, " + 188 "LinkNumber, MediaURL, KeyframeMotion, AttachedPosX, " +
188 "AttachedPosY, AttachedPosZ, " + 189 "AttachedPosY, AttachedPosZ, " +
189 "PhysicsShapeType, Density, GravityModifier, " + 190 "PhysicsShapeType, Density, GravityModifier, " +
190 "Friction, Restitution, Vehicle, DynAttrs, " + 191 "Friction, Restitution, Vehicle, PhysInertia, DynAttrs, " +
191 "RotationAxisLocks" + 192 "RotationAxisLocks" +
192 ") values (" + "?UUID, " + 193 ") values (" + "?UUID, " +
193 "?CreationDate, ?Name, ?Text, " + 194 "?CreationDate, ?Name, ?Text, " +
@@ -224,7 +225,7 @@ namespace OpenSim.Data.MySQL
224 "?LinkNumber, ?MediaURL, ?KeyframeMotion, ?AttachedPosX, " + 225 "?LinkNumber, ?MediaURL, ?KeyframeMotion, ?AttachedPosX, " +
225 "?AttachedPosY, ?AttachedPosZ, " + 226 "?AttachedPosY, ?AttachedPosZ, " +
226 "?PhysicsShapeType, ?Density, ?GravityModifier, " + 227 "?PhysicsShapeType, ?Density, ?GravityModifier, " +
227 "?Friction, ?Restitution, ?Vehicle, ?DynAttrs," + 228 "?Friction, ?Restitution, ?Vehicle, ?PhysInertia, ?DynAttrs," +
228 "?RotationAxisLocks)"; 229 "?RotationAxisLocks)";
229 230
230 FillPrimCommand(cmd, prim, obj.UUID, regionUUID); 231 FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
@@ -261,6 +262,7 @@ namespace OpenSim.Data.MySQL
261 ExecuteNonQuery(cmd); 262 ExecuteNonQuery(cmd);
262 } 263 }
263 } 264 }
265 dbcon.Close();
264 } 266 }
265 } 267 }
266 } 268 }
@@ -300,6 +302,7 @@ namespace OpenSim.Data.MySQL
300 cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; 302 cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
301 ExecuteNonQuery(cmd); 303 ExecuteNonQuery(cmd);
302 } 304 }
305 dbcon.Close();
303 } 306 }
304 } 307 }
305 308
@@ -334,6 +337,7 @@ namespace OpenSim.Data.MySQL
334 337
335 ExecuteNonQuery(cmd); 338 ExecuteNonQuery(cmd);
336 } 339 }
340 dbcon.Close();
337 } 341 }
338 } 342 }
339 } 343 }
@@ -372,6 +376,7 @@ namespace OpenSim.Data.MySQL
372 376
373 ExecuteNonQuery(cmd); 377 ExecuteNonQuery(cmd);
374 } 378 }
379 dbcon.Close();
375 } 380 }
376 } 381 }
377 } 382 }
@@ -411,6 +416,7 @@ namespace OpenSim.Data.MySQL
411 416
412 ExecuteNonQuery(cmd); 417 ExecuteNonQuery(cmd);
413 } 418 }
419 dbcon.Close();
414 } 420 }
415 } 421 }
416 } 422 }
@@ -460,6 +466,7 @@ namespace OpenSim.Data.MySQL
460 } 466 }
461 } 467 }
462 } 468 }
469 dbcon.Close();
463 } 470 }
464 } 471 }
465 472
@@ -535,6 +542,7 @@ namespace OpenSim.Data.MySQL
535 } 542 }
536 } 543 }
537 } 544 }
545 dbcon.Close();
538 } 546 }
539 } 547 }
540 548
@@ -580,6 +588,7 @@ namespace OpenSim.Data.MySQL
580 } 588 }
581 } 589 }
582 } 590 }
591 dbcon.Close();
583 } 592 }
584 593
585 prim.Inventory.RestoreInventoryItems(inventory); 594 prim.Inventory.RestoreInventoryItems(inventory);
@@ -598,6 +607,10 @@ namespace OpenSim.Data.MySQL
598 { 607 {
599 m_log.Info("[REGION DB]: Storing terrain"); 608 m_log.Info("[REGION DB]: Storing terrain");
600 609
610 int terrainDBRevision;
611 Array terrainDBblob;
612 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
613
601 lock (m_dbLock) 614 lock (m_dbLock)
602 { 615 {
603 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 616 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
@@ -617,10 +630,6 @@ namespace OpenSim.Data.MySQL
617 "Revision, Heightfield) values (?RegionUUID, " + 630 "Revision, Heightfield) values (?RegionUUID, " +
618 "?Revision, ?Heightfield)"; 631 "?Revision, ?Heightfield)";
619 632
620 int terrainDBRevision;
621 Array terrainDBblob;
622 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
623
624 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); 633 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
625 cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); 634 cmd2.Parameters.AddWithValue("Revision", terrainDBRevision);
626 cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); 635 cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob);
@@ -634,6 +643,7 @@ namespace OpenSim.Data.MySQL
634 } 643 }
635 } 644 }
636 } 645 }
646 dbcon.Close();
637 } 647 }
638 } 648 }
639 }); 649 });
@@ -645,6 +655,10 @@ namespace OpenSim.Data.MySQL
645 { 655 {
646 m_log.Info("[REGION DB]: Storing Baked terrain"); 656 m_log.Info("[REGION DB]: Storing Baked terrain");
647 657
658 int terrainDBRevision;
659 Array terrainDBblob;
660 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
661
648 lock (m_dbLock) 662 lock (m_dbLock)
649 { 663 {
650 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 664 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
@@ -664,10 +678,6 @@ namespace OpenSim.Data.MySQL
664 "Revision, Heightfield) values (?RegionUUID, " + 678 "Revision, Heightfield) values (?RegionUUID, " +
665 "?Revision, ?Heightfield)"; 679 "?Revision, ?Heightfield)";
666 680
667 int terrainDBRevision;
668 Array terrainDBblob;
669 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
670
671 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); 681 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
672 cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); 682 cmd2.Parameters.AddWithValue("Revision", terrainDBRevision);
673 cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); 683 cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob);
@@ -681,6 +691,7 @@ namespace OpenSim.Data.MySQL
681 } 691 }
682 } 692 }
683 } 693 }
694 dbcon.Close();
684 } 695 }
685 } 696 }
686 }); 697 });
@@ -700,9 +711,12 @@ namespace OpenSim.Data.MySQL
700 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) 711 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
701 { 712 {
702 TerrainData terrData = null; 713 TerrainData terrData = null;
714 byte[] blob = null;
715 int rev = 0;
703 716
704 lock (m_dbLock) 717 lock (m_dbLock)
705 { 718 {
719
706 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 720 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
707 { 721 {
708 dbcon.Open(); 722 dbcon.Open();
@@ -718,24 +732,29 @@ namespace OpenSim.Data.MySQL
718 { 732 {
719 while (reader.Read()) 733 while (reader.Read())
720 { 734 {
721 int rev = Convert.ToInt32(reader["Revision"]); 735 rev = Convert.ToInt32(reader["Revision"]);
722 if ((reader["Heightfield"] != DBNull.Value)) 736 if ((reader["Heightfield"] != DBNull.Value))
723 { 737 {
724 byte[] blob = (byte[])reader["Heightfield"]; 738 blob = (byte[])reader["Heightfield"];
725 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
726 } 739 }
727 } 740 }
728 } 741 }
729 } 742 }
743 dbcon.Close();
730 } 744 }
731 } 745 }
732 746
747 if(blob != null)
748 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
749
733 return terrData; 750 return terrData;
734 } 751 }
735 752
736 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) 753 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
737 { 754 {
738 TerrainData terrData = null; 755 TerrainData terrData = null;
756 byte[] blob = null;
757 int rev = 0;
739 758
740 lock (m_dbLock) 759 lock (m_dbLock)
741 { 760 {
@@ -753,17 +772,19 @@ namespace OpenSim.Data.MySQL
753 { 772 {
754 while (reader.Read()) 773 while (reader.Read())
755 { 774 {
756 int rev = Convert.ToInt32(reader["Revision"]); 775 rev = Convert.ToInt32(reader["Revision"]);
757 if ((reader["Heightfield"] != DBNull.Value)) 776 if ((reader["Heightfield"] != DBNull.Value))
758 { 777 {
759 byte[] blob = (byte[])reader["Heightfield"]; 778 blob = (byte[])reader["Heightfield"];
760 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
761 } 779 }
762 } 780 }
763 } 781 }
764 } 782 }
783 dbcon.Close();
765 } 784 }
766 } 785 }
786 if(blob != null)
787 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
767 788
768 return terrData; 789 return terrData;
769 } 790 }
@@ -783,6 +804,7 @@ namespace OpenSim.Data.MySQL
783 804
784 ExecuteNonQuery(cmd); 805 ExecuteNonQuery(cmd);
785 } 806 }
807 dbcon.Close();
786 } 808 }
787 } 809 }
788 } 810 }
@@ -842,6 +864,7 @@ namespace OpenSim.Data.MySQL
842 cmd.Parameters.Clear(); 864 cmd.Parameters.Clear();
843 } 865 }
844 } 866 }
867 dbcon.Close();
845 } 868 }
846 } 869 }
847 } 870 }
@@ -863,82 +886,85 @@ namespace OpenSim.Data.MySQL
863 886
864 cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); 887 cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
865 888
866 IDataReader result = ExecuteReader(cmd); 889 using(IDataReader result = ExecuteReader(cmd))
867 if (!result.Read())
868 { 890 {
869 //No result, so store our default windlight profile and return it 891 if(!result.Read())
870 nWP.regionID = regionUUID; 892 {
871// StoreRegionWindlightSettings(nWP); 893 //No result, so store our default windlight profile and return it
872 return nWP; 894 nWP.regionID = regionUUID;
873 } 895 // StoreRegionWindlightSettings(nWP);
874 else 896 return nWP;
875 { 897 }
876 nWP.regionID = DBGuid.FromDB(result["region_id"]); 898 else
877 nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); 899 {
878 nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); 900 nWP.regionID = DBGuid.FromDB(result["region_id"]);
879 nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); 901 nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
880 nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); 902 nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
881 nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); 903 nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
882 nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); 904 nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
883 nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); 905 nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
884 nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); 906 nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
885 nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); 907 nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
886 nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); 908 nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
887 nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); 909 nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
888 nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); 910 nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
889 nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); 911 nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
890 nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); 912 nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
891 nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); 913 nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
892 nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); 914 nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
893 nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); 915 nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
894 UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); 916 nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
895 nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); 917 nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
896 nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); 918 UUID.TryParse(result["normal_map_texture"].ToString(),out nWP.normalMapTexture);
897 nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); 919 nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
898 nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); 920 nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
899 nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); 921 nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
900 nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); 922 nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
901 nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); 923 nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
902 nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); 924 nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
903 nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); 925 nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
904 nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); 926 nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
905 nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); 927 nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
906 nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); 928 nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
907 nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); 929 nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
908 nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); 930 nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
909 nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); 931 nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
910 nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); 932 nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
911 nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); 933 nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
912 nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); 934 nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
913 nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); 935 nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
914 nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); 936 nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
915 nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); 937 nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
916 nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); 938 nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
917 nWP.eastAngle = Convert.ToSingle(result["east_angle"]); 939 nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
918 nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); 940 nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
919 nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); 941 nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
920 nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); 942 nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
921 nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); 943 nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
922 nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); 944 nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
923 nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); 945 nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
924 nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); 946 nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
925 nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); 947 nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
926 nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); 948 nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
927 nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); 949 nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
928 nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); 950 nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
929 nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); 951 nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
930 nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); 952 nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
931 nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); 953 nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
932 nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); 954 nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
933 nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); 955 nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
934 nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); 956 nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
935 nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); 957 nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
936 nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); 958 nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
937 nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); 959 nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
938 nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); 960 nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
939 nWP.valid = true; 961 nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
962 nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
963 nWP.valid = true;
964 }
940 } 965 }
941 } 966 }
967 dbcon.Close();
942 } 968 }
943 969
944 return nWP; 970 return nWP;
@@ -947,6 +973,7 @@ namespace OpenSim.Data.MySQL
947 public virtual RegionSettings LoadRegionSettings(UUID regionUUID) 973 public virtual RegionSettings LoadRegionSettings(UUID regionUUID)
948 { 974 {
949 RegionSettings rs = null; 975 RegionSettings rs = null;
976 bool needStore = false;
950 977
951 lock (m_dbLock) 978 lock (m_dbLock)
952 { 979 {
@@ -972,13 +999,17 @@ namespace OpenSim.Data.MySQL
972 rs.RegionUUID = regionUUID; 999 rs.RegionUUID = regionUUID;
973 rs.OnSave += StoreRegionSettings; 1000 rs.OnSave += StoreRegionSettings;
974 1001
975 StoreRegionSettings(rs); 1002 needStore = true;
976 } 1003 }
977 } 1004 }
978 } 1005 }
1006 dbcon.Close();
979 } 1007 }
980 } 1008 }
981 1009
1010 if(needStore)
1011 StoreRegionSettings(rs);
1012
982 LoadSpawnPoints(rs); 1013 LoadSpawnPoints(rs);
983 1014
984 return rs; 1015 return rs;
@@ -992,31 +1023,32 @@ namespace OpenSim.Data.MySQL
992 1023
993 using (MySqlCommand cmd = dbcon.CreateCommand()) 1024 using (MySqlCommand cmd = dbcon.CreateCommand())
994 { 1025 {
995 cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; 1026 cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "
996 cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; 1027 + "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "
997 cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; 1028 + "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "
998 cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; 1029 + "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "
999 cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; 1030 + "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "
1000 cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; 1031 + "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "
1001 cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; 1032 + "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "
1002 cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; 1033 + "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "
1003 cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; 1034 + "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "
1004 cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; 1035 + "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "
1005 cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; 1036 + "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "
1006 cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; 1037 + "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "
1007 cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; 1038 + "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "
1008 cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; 1039 + "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "
1009 cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; 1040 + "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "
1010 cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; 1041 + "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "
1011 cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; 1042 + "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "
1012 cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; 1043 + "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "
1013 cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; 1044 + "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "
1014 cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; 1045 + "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "
1015 cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; 1046 + "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "
1016 cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; 1047 + "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "
1017 cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; 1048 + "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "
1018 cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; 1049 + "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "
1019 cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; 1050 + "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"
1051 ;
1020 1052
1021 cmd.Parameters.AddWithValue("region_id", wl.regionID); 1053 cmd.Parameters.AddWithValue("region_id", wl.regionID);
1022 cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); 1054 cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
@@ -1084,6 +1116,7 @@ namespace OpenSim.Data.MySQL
1084 1116
1085 ExecuteNonQuery(cmd); 1117 ExecuteNonQuery(cmd);
1086 } 1118 }
1119 dbcon.Close();
1087 } 1120 }
1088 } 1121 }
1089 1122
@@ -1099,6 +1132,7 @@ namespace OpenSim.Data.MySQL
1099 cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); 1132 cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
1100 ExecuteNonQuery(cmd); 1133 ExecuteNonQuery(cmd);
1101 } 1134 }
1135 dbcon.Close();
1102 } 1136 }
1103 } 1137 }
1104 1138
@@ -1117,14 +1151,19 @@ namespace OpenSim.Data.MySQL
1117 1151
1118 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); 1152 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
1119 1153
1120 IDataReader result = ExecuteReader(cmd); 1154 using(IDataReader result = ExecuteReader(cmd))
1121 if (!result.Read())
1122 {
1123 return String.Empty;
1124 }
1125 else
1126 { 1155 {
1127 return Convert.ToString(result["llsd_settings"]); 1156 if(!result.Read())
1157 {
1158 dbcon.Close();
1159 return String.Empty;
1160 }
1161 else
1162 {
1163 string ret = Convert.ToString(result["llsd_settings"]);
1164 dbcon.Close();
1165 return ret;
1166 }
1128 } 1167 }
1129 } 1168 }
1130 } 1169 }
@@ -1145,6 +1184,7 @@ namespace OpenSim.Data.MySQL
1145 1184
1146 ExecuteNonQuery(cmd); 1185 ExecuteNonQuery(cmd);
1147 } 1186 }
1187 dbcon.Close();
1148 } 1188 }
1149 } 1189 }
1150 1190
@@ -1160,6 +1200,7 @@ namespace OpenSim.Data.MySQL
1160 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); 1200 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
1161 ExecuteNonQuery(cmd); 1201 ExecuteNonQuery(cmd);
1162 } 1202 }
1203 dbcon.Close();
1163 } 1204 }
1164 } 1205 }
1165 #endregion 1206 #endregion
@@ -1212,7 +1253,7 @@ namespace OpenSim.Data.MySQL
1212 FillRegionSettingsCommand(cmd, rs); 1253 FillRegionSettingsCommand(cmd, rs);
1213 ExecuteNonQuery(cmd); 1254 ExecuteNonQuery(cmd);
1214 } 1255 }
1215 1256 dbcon.Close();
1216 SaveSpawnPoints(rs); 1257 SaveSpawnPoints(rs);
1217 } 1258 }
1218 } 1259 }
@@ -1259,6 +1300,7 @@ namespace OpenSim.Data.MySQL
1259 } 1300 }
1260 } 1301 }
1261 } 1302 }
1303 dbcon.Close();
1262 } 1304 }
1263 } 1305 }
1264 1306
@@ -1452,6 +1494,11 @@ namespace OpenSim.Data.MySQL
1452 prim.VehicleParams = vehicle; 1494 prim.VehicleParams = vehicle;
1453 } 1495 }
1454 1496
1497 PhysicsInertiaData pdata = null;
1498 if (row["PhysInertia"].ToString() != String.Empty)
1499 pdata = PhysicsInertiaData.FromXml2(row["PhysInertia"].ToString());
1500 prim.PhysicsInertia = pdata;
1501
1455 return prim; 1502 return prim;
1456 } 1503 }
1457 1504
@@ -1810,6 +1857,11 @@ namespace OpenSim.Data.MySQL
1810 else 1857 else
1811 cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); 1858 cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]);
1812 1859
1860 if (prim.PhysicsInertia != null)
1861 cmd.Parameters.AddWithValue("PhysInertia", prim.PhysicsInertia.ToXml2());
1862 else
1863 cmd.Parameters.AddWithValue("PhysInertia", String.Empty);
1864
1813 if (prim.VehicleParams != null) 1865 if (prim.VehicleParams != null)
1814 cmd.Parameters.AddWithValue("Vehicle", prim.VehicleParams.ToXml2()); 1866 cmd.Parameters.AddWithValue("Vehicle", prim.VehicleParams.ToXml2());
1815 else 1867 else
@@ -2113,6 +2165,7 @@ namespace OpenSim.Data.MySQL
2113 ExecuteNonQuery(cmd); 2165 ExecuteNonQuery(cmd);
2114 } 2166 }
2115 } 2167 }
2168 dbcon.Close();
2116 } 2169 }
2117 } 2170 }
2118 } 2171 }
@@ -2142,6 +2195,7 @@ namespace OpenSim.Data.MySQL
2142 } 2195 }
2143 } 2196 }
2144 } 2197 }
2198 dbcon.Close();
2145 } 2199 }
2146 } 2200 }
2147 2201
@@ -2177,6 +2231,7 @@ namespace OpenSim.Data.MySQL
2177 } 2231 }
2178 } 2232 }
2179 } 2233 }
2234 dbcon.Close();
2180 } 2235 }
2181 } 2236 }
2182 } 2237 }
@@ -2211,6 +2266,7 @@ namespace OpenSim.Data.MySQL
2211 cmd.Parameters.Clear(); 2266 cmd.Parameters.Clear();
2212 } 2267 }
2213 } 2268 }
2269 dbcon.Close();
2214 } 2270 }
2215 } 2271 }
2216 } 2272 }
@@ -2230,6 +2286,7 @@ namespace OpenSim.Data.MySQL
2230 2286
2231 cmd.ExecuteNonQuery(); 2287 cmd.ExecuteNonQuery();
2232 } 2288 }
2289 dbcon.Close();
2233 } 2290 }
2234 } 2291 }
2235 2292
@@ -2247,6 +2304,7 @@ namespace OpenSim.Data.MySQL
2247 2304
2248 cmd.ExecuteNonQuery(); 2305 cmd.ExecuteNonQuery();
2249 } 2306 }
2307 dbcon.Close();
2250 } 2308 }
2251 } 2309 }
2252 2310
@@ -2270,6 +2328,7 @@ namespace OpenSim.Data.MySQL
2270 } 2328 }
2271 } 2329 }
2272 } 2330 }
2331 dbcon.Close();
2273 } 2332 }
2274 2333
2275 return ret; 2334 return ret;
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
index 8af2a3e..2669aca 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -69,6 +69,7 @@ namespace OpenSim.Data.MySQL
69 69
70 Migration m = new Migration(dbcon, Assembly, "UserProfiles"); 70 Migration m = new Migration(dbcon, Assembly, "UserProfiles");
71 m.Update(); 71 m.Update();
72 dbcon.Close();
72 } 73 }
73 } 74 }
74 #endregion Member Functions 75 #endregion Member Functions
@@ -89,7 +90,7 @@ namespace OpenSim.Data.MySQL
89 90
90 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 91 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
91 { 92 {
92 string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; 93 const string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id";
93 dbcon.Open(); 94 dbcon.Open();
94 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 95 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
95 { 96 {
@@ -111,8 +112,7 @@ namespace OpenSim.Data.MySQL
111 } 112 }
112 catch (Exception e) 113 catch (Exception e)
113 { 114 {
114 m_log.ErrorFormat("[PROFILES_DATA]" + 115 m_log.ErrorFormat("[PROFILES_DATA] GetClassifiedRecords exception {0}", e.Message);
115 ": UserAccount exception {0}", e.Message);
116 } 116 }
117 n.Add("classifieduuid", OSD.FromUUID(Id)); 117 n.Add("classifieduuid", OSD.FromUUID(Id));
118 n.Add("name", OSD.FromString(Name)); 118 n.Add("name", OSD.FromString(Name));
@@ -121,58 +121,58 @@ namespace OpenSim.Data.MySQL
121 } 121 }
122 } 122 }
123 } 123 }
124 dbcon.Close();
124 } 125 }
125 return data; 126 return data;
126 } 127 }
127 128
128 public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) 129 public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result)
129 { 130 {
130 string query = string.Empty; 131 const string query =
131 132 "INSERT INTO classifieds ("
132 133 + "`classifieduuid`,"
133 query += "INSERT INTO classifieds ("; 134 + "`creatoruuid`,"
134 query += "`classifieduuid`,"; 135 + "`creationdate`,"
135 query += "`creatoruuid`,"; 136 + "`expirationdate`,"
136 query += "`creationdate`,"; 137 + "`category`,"
137 query += "`expirationdate`,"; 138 + "`name`,"
138 query += "`category`,"; 139 + "`description`,"
139 query += "`name`,"; 140 + "`parceluuid`,"
140 query += "`description`,"; 141 + "`parentestate`,"
141 query += "`parceluuid`,"; 142 + "`snapshotuuid`,"
142 query += "`parentestate`,"; 143 + "`simname`,"
143 query += "`snapshotuuid`,"; 144 + "`posglobal`,"
144 query += "`simname`,"; 145 + "`parcelname`,"
145 query += "`posglobal`,"; 146 + "`classifiedflags`,"
146 query += "`parcelname`,"; 147 + "`priceforlisting`) "
147 query += "`classifiedflags`,"; 148 + "VALUES ("
148 query += "`priceforlisting`) "; 149 + "?ClassifiedId,"
149 query += "VALUES ("; 150 + "?CreatorId,"
150 query += "?ClassifiedId,"; 151 + "?CreatedDate,"
151 query += "?CreatorId,"; 152 + "?ExpirationDate,"
152 query += "?CreatedDate,"; 153 + "?Category,"
153 query += "?ExpirationDate,"; 154 + "?Name,"
154 query += "?Category,"; 155 + "?Description,"
155 query += "?Name,"; 156 + "?ParcelId,"
156 query += "?Description,"; 157 + "?ParentEstate,"
157 query += "?ParcelId,"; 158 + "?SnapshotId,"
158 query += "?ParentEstate,"; 159 + "?SimName,"
159 query += "?SnapshotId,"; 160 + "?GlobalPos,"
160 query += "?SimName,"; 161 + "?ParcelName,"
161 query += "?GlobalPos,"; 162 + "?Flags,"
162 query += "?ParcelName,"; 163 + "?ListingPrice ) "
163 query += "?Flags,"; 164 + "ON DUPLICATE KEY UPDATE "
164 query += "?ListingPrice ) "; 165 + "category=?Category, "
165 query += "ON DUPLICATE KEY UPDATE "; 166 + "expirationdate=?ExpirationDate, "
166 query += "category=?Category, "; 167 + "name=?Name, "
167 query += "expirationdate=?ExpirationDate, "; 168 + "description=?Description, "
168 query += "name=?Name, "; 169 + "parentestate=?ParentEstate, "
169 query += "description=?Description, "; 170 + "posglobal=?GlobalPos, "
170 query += "parentestate=?ParentEstate, "; 171 + "parcelname=?ParcelName, "
171 query += "posglobal=?GlobalPos, "; 172 + "classifiedflags=?Flags, "
172 query += "parcelname=?ParcelName, "; 173 + "priceforlisting=?ListingPrice, "
173 query += "classifiedflags=?Flags, "; 174 + "snapshotuuid=?SnapshotId"
174 query += "priceforlisting=?ListingPrice, "; 175 ;
175 query += "snapshotuuid=?SnapshotId";
176 176
177 if(string.IsNullOrEmpty(ad.ParcelName)) 177 if(string.IsNullOrEmpty(ad.ParcelName))
178 ad.ParcelName = "Unknown"; 178 ad.ParcelName = "Unknown";
@@ -228,12 +228,12 @@ namespace OpenSim.Data.MySQL
228 228
229 cmd.ExecuteNonQuery(); 229 cmd.ExecuteNonQuery();
230 } 230 }
231 dbcon.Close();
231 } 232 }
232 } 233 }
233 catch (Exception e) 234 catch (Exception e)
234 { 235 {
235 m_log.ErrorFormat("[PROFILES_DATA]" + 236 m_log.ErrorFormat("[PROFILES_DATA]: UpdateClassifiedRecord exception {0}", e.Message);
236 ": ClassifiedesUpdate exception {0}", e.Message);
237 result = e.Message; 237 result = e.Message;
238 return false; 238 return false;
239 } 239 }
@@ -242,10 +242,7 @@ namespace OpenSim.Data.MySQL
242 242
243 public bool DeleteClassifiedRecord(UUID recordId) 243 public bool DeleteClassifiedRecord(UUID recordId)
244 { 244 {
245 string query = string.Empty; 245 const string query = "DELETE FROM classifieds WHERE classifieduuid = ?recordId";
246
247 query += "DELETE FROM classifieds WHERE ";
248 query += "classifieduuid = ?recordId";
249 246
250 try 247 try
251 { 248 {
@@ -258,12 +255,12 @@ namespace OpenSim.Data.MySQL
258 cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); 255 cmd.Parameters.AddWithValue("?recordId", recordId.ToString());
259 cmd.ExecuteNonQuery(); 256 cmd.ExecuteNonQuery();
260 } 257 }
258 dbcon.Close();
261 } 259 }
262 } 260 }
263 catch (Exception e) 261 catch (Exception e)
264 { 262 {
265 m_log.ErrorFormat("[PROFILES_DATA]" + 263 m_log.ErrorFormat("[PROFILES_DATA]: DeleteClassifiedRecord exception {0}", e.Message);
266 ": DeleteClassifiedRecord exception {0}", e.Message);
267 return false; 264 return false;
268 } 265 }
269 return true; 266 return true;
@@ -271,10 +268,8 @@ namespace OpenSim.Data.MySQL
271 268
272 public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) 269 public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result)
273 { 270 {
274 string query = string.Empty;
275 271
276 query += "SELECT * FROM classifieds WHERE "; 272 const string query = "SELECT * FROM classifieds WHERE classifieduuid = ?AdId";
277 query += "classifieduuid = ?AdId";
278 273
279 try 274 try
280 { 275 {
@@ -312,8 +307,7 @@ namespace OpenSim.Data.MySQL
312 } 307 }
313 catch (Exception e) 308 catch (Exception e)
314 { 309 {
315 m_log.ErrorFormat("[PROFILES_DATA]" + 310 m_log.ErrorFormat("[PROFILES_DATA]: GetClassifiedInfo exception {0}", e.Message);
316 ": GetPickInfo exception {0}", e.Message);
317 } 311 }
318 return true; 312 return true;
319 } 313 }
@@ -322,10 +316,8 @@ namespace OpenSim.Data.MySQL
322 #region Picks Queries 316 #region Picks Queries
323 public OSDArray GetAvatarPicks(UUID avatarId) 317 public OSDArray GetAvatarPicks(UUID avatarId)
324 { 318 {
325 string query = string.Empty; 319 const string query = "SELECT `pickuuid`,`name` FROM userpicks WHERE creatoruuid = ?Id";
326 320
327 query += "SELECT `pickuuid`,`name` FROM userpicks WHERE ";
328 query += "creatoruuid = ?Id";
329 OSDArray data = new OSDArray(); 321 OSDArray data = new OSDArray();
330 322
331 try 323 try
@@ -352,24 +344,20 @@ namespace OpenSim.Data.MySQL
352 } 344 }
353 } 345 }
354 } 346 }
347 dbcon.Close();
355 } 348 }
356 } 349 }
357 catch (Exception e) 350 catch (Exception e)
358 { 351 {
359 m_log.ErrorFormat("[PROFILES_DATA]" + 352 m_log.ErrorFormat("[PROFILES_DATA]: GetAvatarPicks exception {0}", e.Message);
360 ": GetAvatarPicks exception {0}", e.Message);
361 } 353 }
362 return data; 354 return data;
363 } 355 }
364 356
365 public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) 357 public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId)
366 { 358 {
367 string query = string.Empty;
368 UserProfilePick pick = new UserProfilePick(); 359 UserProfilePick pick = new UserProfilePick();
369 360 const string query = "SELECT * FROM userpicks WHERE creatoruuid = ?CreatorId AND pickuuid = ?PickId";
370 query += "SELECT * FROM userpicks WHERE ";
371 query += "creatoruuid = ?CreatorId AND ";
372 query += "pickuuid = ?PickId";
373 361
374 try 362 try
375 { 363 {
@@ -414,41 +402,40 @@ namespace OpenSim.Data.MySQL
414 } 402 }
415 catch (Exception e) 403 catch (Exception e)
416 { 404 {
417 m_log.ErrorFormat("[PROFILES_DATA]" + 405 m_log.ErrorFormat("[PROFILES_DATA]: GetPickInfo exception {0}", e.Message);
418 ": GetPickInfo exception {0}", e.Message);
419 } 406 }
420 return pick; 407 return pick;
421 } 408 }
422 409
423 public bool UpdatePicksRecord(UserProfilePick pick) 410 public bool UpdatePicksRecord(UserProfilePick pick)
424 { 411 {
425 string query = string.Empty; 412 const string query =
426 413 "INSERT INTO userpicks VALUES ("
427 query += "INSERT INTO userpicks VALUES ("; 414 + "?PickId,"
428 query += "?PickId,"; 415 + "?CreatorId,"
429 query += "?CreatorId,"; 416 + "?TopPick,"
430 query += "?TopPick,"; 417 + "?ParcelId,"
431 query += "?ParcelId,"; 418 + "?Name,"
432 query += "?Name,"; 419 + "?Desc,"
433 query += "?Desc,"; 420 + "?SnapshotId,"
434 query += "?SnapshotId,"; 421 + "?User,"
435 query += "?User,"; 422 + "?Original,"
436 query += "?Original,"; 423 + "?SimName,"
437 query += "?SimName,"; 424 + "?GlobalPos,"
438 query += "?GlobalPos,"; 425 + "?SortOrder,"
439 query += "?SortOrder,"; 426 + "?Enabled,"
440 query += "?Enabled,"; 427 + "?Gatekeeper)"
441 query += "?Gatekeeper)"; 428 + "ON DUPLICATE KEY UPDATE "
442 query += "ON DUPLICATE KEY UPDATE "; 429 + "parceluuid=?ParcelId,"
443 query += "parceluuid=?ParcelId,"; 430 + "name=?Name,"
444 query += "name=?Name,"; 431 + "description=?Desc,"
445 query += "description=?Desc,"; 432 + "user=?User,"
446 query += "user=?User,"; 433 + "simname=?SimName,"
447 query += "simname=?SimName,"; 434 + "snapshotuuid=?SnapshotId,"
448 query += "snapshotuuid=?SnapshotId,"; 435 + "pickuuid=?PickId,"
449 query += "pickuuid=?PickId,"; 436 + "posglobal=?GlobalPos,"
450 query += "posglobal=?GlobalPos,"; 437 + "gatekeeper=?Gatekeeper"
451 query += "gatekeeper=?Gatekeeper"; 438 ;
452 439
453 try 440 try
454 { 441 {
@@ -474,12 +461,12 @@ namespace OpenSim.Data.MySQL
474 461
475 cmd.ExecuteNonQuery(); 462 cmd.ExecuteNonQuery();
476 } 463 }
464 dbcon.Close();
477 } 465 }
478 } 466 }
479 catch (Exception e) 467 catch (Exception e)
480 { 468 {
481 m_log.ErrorFormat("[PROFILES_DATA]" + 469 m_log.ErrorFormat("[PROFILES_DATA]: UpdatePicksRecord exception {0}", e.Message);
482 ": UpdateAvatarNotes exception {0}", e.Message);
483 return false; 470 return false;
484 } 471 }
485 return true; 472 return true;
@@ -487,10 +474,7 @@ namespace OpenSim.Data.MySQL
487 474
488 public bool DeletePicksRecord(UUID pickId) 475 public bool DeletePicksRecord(UUID pickId)
489 { 476 {
490 string query = string.Empty; 477 string query = "DELETE FROM userpicks WHERE pickuuid = ?PickId";
491
492 query += "DELETE FROM userpicks WHERE ";
493 query += "pickuuid = ?PickId";
494 478
495 try 479 try
496 { 480 {
@@ -504,12 +488,12 @@ namespace OpenSim.Data.MySQL
504 488
505 cmd.ExecuteNonQuery(); 489 cmd.ExecuteNonQuery();
506 } 490 }
491 dbcon.Close();
507 } 492 }
508 } 493 }
509 catch (Exception e) 494 catch (Exception e)
510 { 495 {
511 m_log.ErrorFormat("[PROFILES_DATA]" + 496 m_log.ErrorFormat("[PROFILES_DATA]: DeletePicksRecord exception {0}", e.Message);
512 ": DeleteUserPickRecord exception {0}", e.Message);
513 return false; 497 return false;
514 } 498 }
515 return true; 499 return true;
@@ -519,11 +503,7 @@ namespace OpenSim.Data.MySQL
519 #region Avatar Notes Queries 503 #region Avatar Notes Queries
520 public bool GetAvatarNotes(ref UserProfileNotes notes) 504 public bool GetAvatarNotes(ref UserProfileNotes notes)
521 { // WIP 505 { // WIP
522 string query = string.Empty; 506 const string query = "SELECT `notes` FROM usernotes WHERE useruuid = ?Id AND targetuuid = ?TargetId";
523
524 query += "SELECT `notes` FROM usernotes WHERE ";
525 query += "useruuid = ?Id AND ";
526 query += "targetuuid = ?TargetId";
527 507
528 try 508 try
529 { 509 {
@@ -548,38 +528,37 @@ namespace OpenSim.Data.MySQL
548 } 528 }
549 } 529 }
550 } 530 }
531 dbcon.Close();
551 } 532 }
552 } 533 }
553 catch (Exception e) 534 catch (Exception e)
554 { 535 {
555 m_log.ErrorFormat("[PROFILES_DATA]" + 536 m_log.ErrorFormat("[PROFILES_DATA]: GetAvatarNotes exception {0}", e.Message);
556 ": GetAvatarNotes exception {0}", e.Message);
557 } 537 }
558 return true; 538 return true;
559 } 539 }
560 540
561 public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) 541 public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result)
562 { 542 {
563 string query = string.Empty; 543 string query;
564 bool remove; 544 bool remove;
565 545
566 if(string.IsNullOrEmpty(note.Notes)) 546 if(string.IsNullOrEmpty(note.Notes))
567 { 547 {
568 remove = true; 548 remove = true;
569 query += "DELETE FROM usernotes WHERE "; 549 query = "DELETE FROM usernotes WHERE useruuid=?UserId AND targetuuid=?TargetId";
570 query += "useruuid=?UserId AND ";
571 query += "targetuuid=?TargetId";
572 } 550 }
573 else 551 else
574 { 552 {
575 remove = false; 553 remove = false;
576 query += "INSERT INTO usernotes VALUES ( "; 554 query = "INSERT INTO usernotes VALUES ("
577 query += "?UserId,"; 555 + "?UserId,"
578 query += "?TargetId,"; 556 + "?TargetId,"
579 query += "?Notes )"; 557 + "?Notes )"
580 query += "ON DUPLICATE KEY "; 558 + "ON DUPLICATE KEY "
581 query += "UPDATE "; 559 + "UPDATE "
582 query += "notes=?Notes"; 560 + "notes=?Notes"
561 ;
583 } 562 }
584 563
585 try 564 try
@@ -596,12 +575,12 @@ namespace OpenSim.Data.MySQL
596 575
597 cmd.ExecuteNonQuery(); 576 cmd.ExecuteNonQuery();
598 } 577 }
578 dbcon.Close();
599 } 579 }
600 } 580 }
601 catch (Exception e) 581 catch (Exception e)
602 { 582 {
603 m_log.ErrorFormat("[PROFILES_DATA]" + 583 m_log.ErrorFormat("[PROFILES_DATA]: UpdateAvatarNotes exception {0}", e.Message);
604 ": UpdateAvatarNotes exception {0}", e.Message);
605 return false; 584 return false;
606 } 585 }
607 return true; 586 return true;
@@ -612,10 +591,7 @@ namespace OpenSim.Data.MySQL
612 #region Avatar Properties 591 #region Avatar Properties
613 public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) 592 public bool GetAvatarProperties(ref UserProfileProperties props, ref string result)
614 { 593 {
615 string query = string.Empty; 594 string query = "SELECT * FROM userprofile WHERE useruuid = ?Id";
616
617 query += "SELECT * FROM userprofile WHERE ";
618 query += "useruuid = ?Id";
619 595
620 try 596 try
621 { 597 {
@@ -664,35 +640,36 @@ namespace OpenSim.Data.MySQL
664 props.PublishProfile = false; 640 props.PublishProfile = false;
665 props.PublishMature = false; 641 props.PublishMature = false;
666 642
667 query = "INSERT INTO userprofile ("; 643 query = "INSERT INTO userprofile ("
668 query += "useruuid, "; 644 + "useruuid, "
669 query += "profilePartner, "; 645 + "profilePartner, "
670 query += "profileAllowPublish, "; 646 + "profileAllowPublish, "
671 query += "profileMaturePublish, "; 647 + "profileMaturePublish, "
672 query += "profileURL, "; 648 + "profileURL, "
673 query += "profileWantToMask, "; 649 + "profileWantToMask, "
674 query += "profileWantToText, "; 650 + "profileWantToText, "
675 query += "profileSkillsMask, "; 651 + "profileSkillsMask, "
676 query += "profileSkillsText, "; 652 + "profileSkillsText, "
677 query += "profileLanguages, "; 653 + "profileLanguages, "
678 query += "profileImage, "; 654 + "profileImage, "
679 query += "profileAboutText, "; 655 + "profileAboutText, "
680 query += "profileFirstImage, "; 656 + "profileFirstImage, "
681 query += "profileFirstText) VALUES ("; 657 + "profileFirstText) VALUES ("
682 query += "?userId, "; 658 + "?userId, "
683 query += "?profilePartner, "; 659 + "?profilePartner, "
684 query += "?profileAllowPublish, "; 660 + "?profileAllowPublish, "
685 query += "?profileMaturePublish, "; 661 + "?profileMaturePublish, "
686 query += "?profileURL, "; 662 + "?profileURL, "
687 query += "?profileWantToMask, "; 663 + "?profileWantToMask, "
688 query += "?profileWantToText, "; 664 + "?profileWantToText, "
689 query += "?profileSkillsMask, "; 665 + "?profileSkillsMask, "
690 query += "?profileSkillsText, "; 666 + "?profileSkillsText, "
691 query += "?profileLanguages, "; 667 + "?profileLanguages, "
692 query += "?profileImage, "; 668 + "?profileImage, "
693 query += "?profileAboutText, "; 669 + "?profileAboutText, "
694 query += "?profileFirstImage, "; 670 + "?profileFirstImage, "
695 query += "?profileFirstText)"; 671 + "?profileFirstText)"
672 ;
696 673
697 dbcon.Close(); 674 dbcon.Close();
698 dbcon.Open(); 675 dbcon.Open();
@@ -719,12 +696,12 @@ namespace OpenSim.Data.MySQL
719 } 696 }
720 } 697 }
721 } 698 }
699 dbcon.Close();
722 } 700 }
723 } 701 }
724 catch (Exception e) 702 catch (Exception e)
725 { 703 {
726 m_log.ErrorFormat("[PROFILES_DATA]" + 704 m_log.ErrorFormat("[PROFILES_DATA]: GetAvatarProperties exception {0}", e.Message);
727 ": Requst properties exception {0}", e.Message);
728 result = e.Message; 705 result = e.Message;
729 return false; 706 return false;
730 } 707 }
@@ -733,15 +710,10 @@ namespace OpenSim.Data.MySQL
733 710
734 public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) 711 public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result)
735 { 712 {
736 string query = string.Empty; 713 const string query = "UPDATE userprofile SET profileURL=?profileURL,"
737 714 + "profileImage=?image, profileAboutText=?abouttext,"
738 query += "UPDATE userprofile SET "; 715 + "profileFirstImage=?firstlifeimage, profileFirstText=?firstlifetext "
739 query += "profileURL=?profileURL, "; 716 + "WHERE useruuid=?uuid";
740 query += "profileImage=?image, ";
741 query += "profileAboutText=?abouttext,";
742 query += "profileFirstImage=?firstlifeimage,";
743 query += "profileFirstText=?firstlifetext ";
744 query += "WHERE useruuid=?uuid";
745 717
746 try 718 try
747 { 719 {
@@ -759,12 +731,12 @@ namespace OpenSim.Data.MySQL
759 731
760 cmd.ExecuteNonQuery(); 732 cmd.ExecuteNonQuery();
761 } 733 }
734 dbcon.Close();
762 } 735 }
763 } 736 }
764 catch (Exception e) 737 catch (Exception e)
765 { 738 {
766 m_log.ErrorFormat("[PROFILES_DATA]" + 739 m_log.ErrorFormat("[PROFILES_DATA]: UpdateAvatarProperties exception {0}", e.Message);
767 ": AgentPropertiesUpdate exception {0}", e.Message);
768 740
769 return false; 741 return false;
770 } 742 }
@@ -775,15 +747,13 @@ namespace OpenSim.Data.MySQL
775 #region Avatar Interests 747 #region Avatar Interests
776 public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) 748 public bool UpdateAvatarInterests(UserProfileProperties up, ref string result)
777 { 749 {
778 string query = string.Empty; 750 const string query = "UPDATE userprofile SET "
779 751 + "profileWantToMask=?WantMask, "
780 query += "UPDATE userprofile SET "; 752 + "profileWantToText=?WantText,"
781 query += "profileWantToMask=?WantMask, "; 753 + "profileSkillsMask=?SkillsMask,"
782 query += "profileWantToText=?WantText,"; 754 + "profileSkillsText=?SkillsText, "
783 query += "profileSkillsMask=?SkillsMask,"; 755 + "profileLanguages=?Languages "
784 query += "profileSkillsText=?SkillsText, "; 756 + "WHERE useruuid=?uuid";
785 query += "profileLanguages=?Languages ";
786 query += "WHERE useruuid=?uuid";
787 757
788 try 758 try
789 { 759 {
@@ -805,8 +775,7 @@ namespace OpenSim.Data.MySQL
805 } 775 }
806 catch (Exception e) 776 catch (Exception e)
807 { 777 {
808 m_log.ErrorFormat("[PROFILES_DATA]" + 778 m_log.ErrorFormat("[PROFILES_DATA]: UpdateAvatarInterests exception {0}", e.Message);
809 ": AgentInterestsUpdate exception {0}", e.Message);
810 result = e.Message; 779 result = e.Message;
811 return false; 780 return false;
812 } 781 }
@@ -817,18 +786,17 @@ namespace OpenSim.Data.MySQL
817 public OSDArray GetUserImageAssets(UUID avatarId) 786 public OSDArray GetUserImageAssets(UUID avatarId)
818 { 787 {
819 OSDArray data = new OSDArray(); 788 OSDArray data = new OSDArray();
820 string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; 789 const string queryA = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id";
821 790
822 // Get classified image assets 791 // Get classified image assets
823 792
824
825 try 793 try
826 { 794 {
827 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 795 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
828 { 796 {
829 dbcon.Open(); 797 dbcon.Open();
830 798
831 using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon)) 799 using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`classifieds`"), dbcon))
832 { 800 {
833 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 801 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
834 802
@@ -847,7 +815,7 @@ namespace OpenSim.Data.MySQL
847 dbcon.Close(); 815 dbcon.Close();
848 dbcon.Open(); 816 dbcon.Open();
849 817
850 using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) 818 using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`userpicks`"), dbcon))
851 { 819 {
852 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 820 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
853 821
@@ -866,9 +834,9 @@ namespace OpenSim.Data.MySQL
866 dbcon.Close(); 834 dbcon.Close();
867 dbcon.Open(); 835 dbcon.Open();
868 836
869 query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; 837 const string queryB = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id";
870 838
871 using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) 839 using (MySqlCommand cmd = new MySqlCommand(queryB, dbcon))
872 { 840 {
873 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 841 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
874 842
@@ -884,12 +852,12 @@ namespace OpenSim.Data.MySQL
884 } 852 }
885 } 853 }
886 } 854 }
855 dbcon.Close();
887 } 856 }
888 } 857 }
889 catch (Exception e) 858 catch (Exception e)
890 { 859 {
891 m_log.ErrorFormat("[PROFILES_DATA]" + 860 m_log.ErrorFormat("[PROFILES_DATA]: GetUserImageAssets exception {0}", e.Message);
892 ": GetAvatarNotes exception {0}", e.Message);
893 } 861 }
894 return data; 862 return data;
895 } 863 }
@@ -897,11 +865,7 @@ namespace OpenSim.Data.MySQL
897 #region User Preferences 865 #region User Preferences
898 public bool GetUserPreferences(ref UserPreferences pref, ref string result) 866 public bool GetUserPreferences(ref UserPreferences pref, ref string result)
899 { 867 {
900 string query = string.Empty; 868 const string query = "SELECT imviaemail,visible,email FROM usersettings WHERE useruuid = ?Id";
901
902 query += "SELECT imviaemail,visible,email FROM ";
903 query += "usersettings WHERE ";
904 query += "useruuid = ?Id";
905 869
906 try 870 try
907 { 871 {
@@ -925,10 +889,9 @@ namespace OpenSim.Data.MySQL
925 dbcon.Close(); 889 dbcon.Close();
926 dbcon.Open(); 890 dbcon.Open();
927 891
928 query = "INSERT INTO usersettings VALUES "; 892 const string queryB = "INSERT INTO usersettings VALUES (?uuid,'false','false', ?Email)";
929 query += "(?uuid,'false','false', ?Email)";
930 893
931 using (MySqlCommand put = new MySqlCommand(query, dbcon)) 894 using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
932 { 895 {
933 896
934 put.Parameters.AddWithValue("?Email", pref.EMail); 897 put.Parameters.AddWithValue("?Email", pref.EMail);
@@ -939,12 +902,12 @@ namespace OpenSim.Data.MySQL
939 } 902 }
940 } 903 }
941 } 904 }
905 dbcon.Close();
942 } 906 }
943 } 907 }
944 catch (Exception e) 908 catch (Exception e)
945 { 909 {
946 m_log.ErrorFormat("[PROFILES_DATA]" + 910 m_log.ErrorFormat("[PROFILES_DATA]: GetUserPreferences exception {0}", e.Message);
947 ": Get preferences exception {0}", e.Message);
948 result = e.Message; 911 result = e.Message;
949 return false; 912 return false;
950 } 913 }
@@ -953,13 +916,9 @@ namespace OpenSim.Data.MySQL
953 916
954 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) 917 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
955 { 918 {
956 string query = string.Empty; 919 const string query = "UPDATE usersettings SET imviaemail=?ImViaEmail,"
957 920 + "visible=?Visible, email=?EMail "
958 query += "UPDATE usersettings SET "; 921 + "WHERE useruuid=?uuid";
959 query += "imviaemail=?ImViaEmail, ";
960 query += "visible=?Visible, ";
961 query += "email=?EMail ";
962 query += "WHERE useruuid=?uuid";
963 922
964 try 923 try
965 { 924 {
@@ -975,12 +934,12 @@ namespace OpenSim.Data.MySQL
975 934
976 cmd.ExecuteNonQuery(); 935 cmd.ExecuteNonQuery();
977 } 936 }
937 dbcon.Close();
978 } 938 }
979 } 939 }
980 catch (Exception e) 940 catch (Exception e)
981 { 941 {
982 m_log.ErrorFormat("[PROFILES_DATA]" + 942 m_log.ErrorFormat("[PROFILES_DATA]: UpdateUserPreferences exception {0} {1}", e.Message, e.InnerException);
983 ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException);
984 result = e.Message; 943 result = e.Message;
985 return false; 944 return false;
986 } 945 }
@@ -991,11 +950,7 @@ namespace OpenSim.Data.MySQL
991 #region Integration 950 #region Integration
992 public bool GetUserAppData(ref UserAppData props, ref string result) 951 public bool GetUserAppData(ref UserAppData props, ref string result)
993 { 952 {
994 string query = string.Empty; 953 const string query = "SELECT * FROM `userdata` WHERE UserId = ?Id AND TagId = ?TagId";
995
996 query += "SELECT * FROM `userdata` WHERE ";
997 query += "UserId = ?Id AND ";
998 query += "TagId = ?TagId";
999 954
1000 try 955 try
1001 { 956 {
@@ -1017,13 +972,8 @@ namespace OpenSim.Data.MySQL
1017 } 972 }
1018 else 973 else
1019 { 974 {
1020 query += "INSERT INTO userdata VALUES ( "; 975 const string queryB = "INSERT INTO userdata VALUES (?UserId, ?TagId, ?DataKey, ?DataVal)";
1021 query += "?UserId,"; 976 using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
1022 query += "?TagId,";
1023 query += "?DataKey,";
1024 query += "?DataVal) ";
1025
1026 using (MySqlCommand put = new MySqlCommand(query, dbcon))
1027 { 977 {
1028 put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); 978 put.Parameters.AddWithValue("?UserId", props.UserId.ToString());
1029 put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); 979 put.Parameters.AddWithValue("?TagId", props.TagId.ToString());
@@ -1035,12 +985,12 @@ namespace OpenSim.Data.MySQL
1035 } 985 }
1036 } 986 }
1037 } 987 }
988 dbcon.Close();
1038 } 989 }
1039 } 990 }
1040 catch (Exception e) 991 catch (Exception e)
1041 { 992 {
1042 m_log.ErrorFormat("[PROFILES_DATA]" + 993 m_log.ErrorFormat("[PROFILES_DATA]: GetUserAppData exception {0}", e.Message);
1043 ": Requst application data exception {0}", e.Message);
1044 result = e.Message; 994 result = e.Message;
1045 return false; 995 return false;
1046 } 996 }
@@ -1049,14 +999,7 @@ namespace OpenSim.Data.MySQL
1049 999
1050 public bool SetUserAppData(UserAppData props, ref string result) 1000 public bool SetUserAppData(UserAppData props, ref string result)
1051 { 1001 {
1052 string query = string.Empty; 1002 const string query = "UPDATE userdata SET TagId = ?TagId, DataKey = ?DataKey, DataVal = ?DataVal WHERE UserId = ?UserId AND TagId = ?TagId";
1053
1054 query += "UPDATE userdata SET ";
1055 query += "TagId = ?TagId, ";
1056 query += "DataKey = ?DataKey, ";
1057 query += "DataVal = ?DataVal WHERE ";
1058 query += "UserId = ?UserId AND ";
1059 query += "TagId = ?TagId";
1060 1003
1061 try 1004 try
1062 { 1005 {
@@ -1072,12 +1015,12 @@ namespace OpenSim.Data.MySQL
1072 1015
1073 cmd.ExecuteNonQuery(); 1016 cmd.ExecuteNonQuery();
1074 } 1017 }
1018 dbcon.Close();
1075 } 1019 }
1076 } 1020 }
1077 catch (Exception e) 1021 catch (Exception e)
1078 { 1022 {
1079 m_log.ErrorFormat("[PROFILES_DATA]" + 1023 m_log.ErrorFormat("[PROFILES_DATA]: SetUserAppData exception {0}", e.Message);
1080 ": SetUserData exception {0}", e.Message);
1081 return false; 1024 return false;
1082 } 1025 }
1083 return true; 1026 return true;
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index 2c6acde..9f9c9cf 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -97,6 +97,7 @@ namespace OpenSim.Data.MySQL
97 dbcon.Open(); 97 dbcon.Open();
98 Migration m = new Migration(dbcon, Assembly, "XAssetStore"); 98 Migration m = new Migration(dbcon, Assembly, "XAssetStore");
99 m.Update(); 99 m.Update();
100 dbcon.Close();
100 } 101 }
101 } 102 }
102 103
@@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
130// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); 131// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
131 132
132 AssetBase asset = null; 133 AssetBase asset = null;
134 int accessTime = 0;
133 135
134 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 136 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
135 { 137 {
@@ -140,7 +142,6 @@ namespace OpenSim.Data.MySQL
140 dbcon)) 142 dbcon))
141 { 143 {
142 cmd.Parameters.AddWithValue("?ID", assetID.ToString()); 144 cmd.Parameters.AddWithValue("?ID", assetID.ToString());
143
144 try 145 try
145 { 146 {
146 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 147 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
@@ -159,23 +160,7 @@ namespace OpenSim.Data.MySQL
159 160
160 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); 161 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
161 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); 162 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
162 163 accessTime = (int)dbReader["AccessTime"];
163 if (m_enableCompression)
164 {
165 using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
166 {
167 MemoryStream outputStream = new MemoryStream();
168 WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue);
169// int compressedLength = asset.Data.Length;
170 asset.Data = outputStream.ToArray();
171
172// m_log.DebugFormat(
173// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
174// asset.ID, asset.Name, asset.Data.Length, compressedLength);
175 }
176 }
177
178 UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
179 } 164 }
180 } 165 }
181 } 166 }
@@ -184,9 +169,38 @@ namespace OpenSim.Data.MySQL
184 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); 169 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
185 } 170 }
186 } 171 }
172 dbcon.Close();
187 } 173 }
188 174
189 return asset; 175 if(asset == null)
176 return asset;
177
178 if(accessTime > 0)
179 {
180 try
181 {
182 UpdateAccessTime(asset.Metadata, accessTime);
183 }
184 catch { }
185 }
186
187 if (m_enableCompression && asset.Data != null)
188 {
189 using(MemoryStream ms = new MemoryStream(asset.Data))
190 using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
191 {
192 using(MemoryStream outputStream = new MemoryStream())
193 {
194 decompressionStream.CopyTo(outputStream, int.MaxValue);
195// int compressedLength = asset.Data.Length;
196 asset.Data = outputStream.ToArray();
197 }
198// m_log.DebugFormat(
199// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
200// asset.ID, asset.Name, asset.Data.Length, compressedLength);
201 }
202 }
203 return asset;
190 } 204 }
191 205
192 /// <summary> 206 /// <summary>
@@ -303,6 +317,7 @@ namespace OpenSim.Data.MySQL
303 317
304 transaction.Commit(); 318 transaction.Commit();
305 } 319 }
320 dbcon.Close();
306 } 321 }
307 } 322 }
308 323
@@ -344,6 +359,7 @@ namespace OpenSim.Data.MySQL
344 "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", 359 "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
345 assetMetadata.ID, assetMetadata.Name); 360 assetMetadata.ID, assetMetadata.Name);
346 } 361 }
362 dbcon.Close();
347 } 363 }
348 } 364 }
349 365
@@ -474,6 +490,7 @@ namespace OpenSim.Data.MySQL
474 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); 490 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
475 } 491 }
476 } 492 }
493 dbcon.Close();
477 } 494 }
478 495
479 return retList; 496 return retList;
@@ -492,9 +509,9 @@ namespace OpenSim.Data.MySQL
492 cmd.Parameters.AddWithValue("?ID", id); 509 cmd.Parameters.AddWithValue("?ID", id);
493 cmd.ExecuteNonQuery(); 510 cmd.ExecuteNonQuery();
494 } 511 }
495
496 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we 512 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
497 // keep a reference count (?) 513 // keep a reference count (?)
514 dbcon.Close();
498 } 515 }
499 516
500 return true; 517 return true;
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index 4e41fec..5019994 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -328,7 +328,6 @@ namespace OpenSim.Data.MySQL
328 { 328 {
329 return false; 329 return false;
330 } 330 }
331 cmd.Dispose();
332 } 331 }
333 332
334 dbcon.Close(); 333 dbcon.Close();
diff --git a/OpenSim/Data/MySQL/Resources/MuteListStore.migrations b/OpenSim/Data/MySQL/Resources/MuteListStore.migrations
new file mode 100644
index 0000000..5bde63e
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/MuteListStore.migrations
@@ -0,0 +1,16 @@
1:VERSION 1
2
3BEGIN;
4
5CREATE TABLE `MuteList` (
6 `AgentID` char(36) NOT NULL,
7 `MuteID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
8 `MuteName` varchar(64) NOT NULL DEFAULT '',
9 `MuteType` int(11) NOT NULL DEFAULT '1',
10 `MuteFlags` int(11) NOT NULL DEFAULT '0',
11 `Stamp` int(11) NOT NULL,
12 UNIQUE KEY `AgentID_2` (`AgentID`,`MuteID`,`MuteName`),
13 KEY `AgentID` (`AgentID`)
14);
15
16COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index c63cc95..0577392 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -461,3 +461,9 @@ BEGIN;
461ALTER TABLE `prims` ADD COLUMN `RezzerID` char(36) DEFAULT NULL; 461ALTER TABLE `prims` ADD COLUMN `RezzerID` char(36) DEFAULT NULL;
462 462
463COMMIT; 463COMMIT;
464
465:VERSION 57 #----- Add physics inertia data
466
467BEGIN;
468ALTER TABLE `prims` ADD COLUMN `PhysInertia` TEXT default NULL;
469COMMIT;
diff --git a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
index 1a49900..6ec8914 100644
--- a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
+++ b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
@@ -18,7 +18,7 @@ CREATE TABLE `os_groups_groups` (
18 PRIMARY KEY (`GroupID`), 18 PRIMARY KEY (`GroupID`),
19 UNIQUE KEY `Name` (`Name`), 19 UNIQUE KEY `Name` (`Name`),
20 FULLTEXT KEY `Name_2` (`Name`) 20 FULLTEXT KEY `Name_2` (`Name`)
21) ENGINE=InnoDB; 21) ENGINE=MyISAM;
22 22
23 23
24CREATE TABLE `os_groups_membership` ( 24CREATE TABLE `os_groups_membership` (
diff --git a/OpenSim/Data/PGSQL/PGSQLFSAssetData.cs b/OpenSim/Data/PGSQL/PGSQLFSAssetData.cs
new file mode 100644
index 0000000..59b857c
--- /dev/null
+++ b/OpenSim/Data/PGSQL/PGSQLFSAssetData.cs
@@ -0,0 +1,316 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Collections.Generic;
31using System.Data;
32using OpenSim.Framework;
33using OpenSim.Framework.Console;
34using log4net;
35using OpenMetaverse;
36using Npgsql;
37using NpgsqlTypes;
38
39namespace OpenSim.Data.PGSQL
40{
41 public class PGSQLFSAssetData : IFSAssetDataPlugin
42 {
43 private const string _migrationStore = "FSAssetStore";
44 private static string m_Table = "fsassets";
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private long m_ticksToEpoch;
47
48 private PGSQLManager m_database;
49 private string m_connectionString;
50
51 public PGSQLFSAssetData()
52 {
53 }
54
55 public void Initialise(string connect, string realm, int UpdateAccessTime)
56 {
57 DaysBetweenAccessTimeUpdates = UpdateAccessTime;
58
59 m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
60
61 m_connectionString = connect;
62 m_database = new PGSQLManager(m_connectionString);
63
64 //New migration to check for DB changes
65 m_database.CheckMigration(_migrationStore);
66 }
67
68 public void Initialise()
69 {
70 throw new NotImplementedException();
71 }
72
73 /// <summary>
74 /// Number of days that must pass before we update the access time on an asset when it has been fetched
75 /// Config option to change this is "DaysBetweenAccessTimeUpdates"
76 /// </summary>
77 private int DaysBetweenAccessTimeUpdates = 0;
78
79 protected virtual Assembly Assembly
80 {
81 get { return GetType().Assembly; }
82 }
83
84 #region IPlugin Members
85
86 public string Version { get { return "1.0.0.0"; } }
87
88 public void Dispose() { }
89
90 public string Name
91 {
92 get { return "PGSQL FSAsset storage engine"; }
93 }
94
95 #endregion
96
97 #region IFSAssetDataPlugin Members
98
99 public AssetMetadata Get(string id, out string hash)
100 {
101 hash = String.Empty;
102 AssetMetadata meta = null;
103 UUID uuid = new UUID(id);
104
105 string query = String.Format("select \"id\", \"type\", \"hash\", \"create_time\", \"access_time\", \"asset_flags\" from {0} where \"id\" = :id", m_Table);
106 using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
107 using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
108 {
109 dbcon.Open();
110 cmd.Parameters.Add(m_database.CreateParameter("id", uuid));
111 using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
112 {
113 if (reader.Read())
114 {
115 meta = new AssetMetadata();
116 hash = reader["hash"].ToString();
117 meta.ID = id;
118 meta.FullID = uuid;
119 meta.Name = String.Empty;
120 meta.Description = String.Empty;
121 meta.Type = (sbyte)Convert.ToInt32(reader["type"]);
122 meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type);
123 meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"]));
124 meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]);
125 int atime = Convert.ToInt32(reader["access_time"]);
126 UpdateAccessTime(atime, uuid);
127 }
128 }
129 }
130
131 return meta;
132 }
133
134 private void UpdateAccessTime(int AccessTime, UUID id)
135 {
136 // Reduce DB work by only updating access time if asset hasn't recently been accessed
137 // 0 By Default, Config option is "DaysBetweenAccessTimeUpdates"
138 if (DaysBetweenAccessTimeUpdates > 0 && (DateTime.UtcNow - Utils.UnixTimeToDateTime(AccessTime)).TotalDays < DaysBetweenAccessTimeUpdates)
139 return;
140
141 string query = String.Format("UPDATE {0} SET \"access_time\" = :access_time WHERE \"id\" = :id", m_Table);
142 using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
143 using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
144 {
145 dbcon.Open();
146 int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
147 cmd.Parameters.Add(m_database.CreateParameter("id", id));
148 cmd.Parameters.Add(m_database.CreateParameter("access_time", now));
149 cmd.ExecuteNonQuery();
150 }
151 }
152
153 public bool Store(AssetMetadata meta, string hash)
154 {
155 try
156 {
157 bool found = false;
158 string oldhash;
159 AssetMetadata existingAsset = Get(meta.ID, out oldhash);
160
161 string query = String.Format("UPDATE {0} SET \"access_time\" = :access_time WHERE \"id\" = :id", m_Table);
162 if (existingAsset == null)
163 {
164 query = String.Format("insert into {0} (\"id\", \"type\", \"hash\", \"asset_flags\", \"create_time\", \"access_time\") values ( :id, :type, :hash, :asset_flags, :create_time, :access_time)", m_Table);
165 found = true;
166 }
167
168 using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
169 using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
170 {
171 dbcon.Open();
172 int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
173 cmd.Parameters.Add(m_database.CreateParameter("id", meta.FullID));
174 cmd.Parameters.Add(m_database.CreateParameter("type", meta.Type));
175 cmd.Parameters.Add(m_database.CreateParameter("hash", hash));
176 cmd.Parameters.Add(m_database.CreateParameter("asset_flags", Convert.ToInt32(meta.Flags)));
177 cmd.Parameters.Add(m_database.CreateParameter("create_time", now));
178 cmd.Parameters.Add(m_database.CreateParameter("access_time", now));
179 cmd.ExecuteNonQuery();
180 }
181 return found;
182 }
183 catch(Exception e)
184 {
185 m_log.Error("[PGSQL FSASSETS] Failed to store asset with ID " + meta.ID);
186 m_log.Error(e.ToString());
187 return false;
188 }
189 }
190
191 /// <summary>
192 /// Check if the assets exist in the database.
193 /// </summary>
194 /// <param name="uuids">The asset UUID's</param>
195 /// <returns>For each asset: true if it exists, false otherwise</returns>
196 public bool[] AssetsExist(UUID[] uuids)
197 {
198 if (uuids.Length == 0)
199 return new bool[0];
200
201 HashSet<UUID> exists = new HashSet<UUID>();
202
203 string ids = "'" + string.Join("','", uuids) + "'";
204 string query = string.Format("select \"id\" from {1} where id in ({0})", ids, m_Table);
205 using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
206 using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
207 {
208 dbcon.Open();
209 using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
210 {
211 while (reader.Read())
212 {
213 UUID id = DBGuid.FromDB(reader["id"]);;
214 exists.Add(id);
215 }
216 }
217 }
218
219 bool[] results = new bool[uuids.Length];
220 for (int i = 0; i < uuids.Length; i++)
221 results[i] = exists.Contains(uuids[i]);
222 return results;
223 }
224
225 public int Count()
226 {
227 int count = 0;
228 string query = String.Format("select count(*) as count from {0}", m_Table);
229 using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
230 using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
231 {
232 dbcon.Open();
233 IDataReader reader = cmd.ExecuteReader();
234 reader.Read();
235 count = Convert.ToInt32(reader["count"]);
236 reader.Close();
237 }
238
239 return count;
240 }
241
242 public bool Delete(string id)
243 {
244 string query = String.Format("delete from {0} where \"id\" = :id", m_Table);
245 using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
246 using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
247 {
248 dbcon.Open();
249 cmd.Parameters.Add(m_database.CreateParameter("id", new UUID(id)));
250 cmd.ExecuteNonQuery();
251 }
252
253 return true;
254 }
255
256 public void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store)
257 {
258 int imported = 0;
259 string limit = String.Empty;
260 if(count != -1)
261 {
262 limit = String.Format(" limit {0} offset {1}", start, count);
263 }
264 string query = String.Format("select * from {0}{1}", table, limit);
265 try
266 {
267 using (NpgsqlConnection remote = new NpgsqlConnection(conn))
268 using (NpgsqlCommand cmd = new NpgsqlCommand(query, remote))
269 {
270 remote.Open();
271 MainConsole.Instance.Output("Querying database");
272 MainConsole.Instance.Output("Reading data");
273 using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
274 {
275 while (reader.Read())
276 {
277 if ((imported % 100) == 0)
278 {
279 MainConsole.Instance.Output(String.Format("{0} assets imported so far", imported));
280 }
281
282 AssetBase asset = new AssetBase();
283 AssetMetadata meta = new AssetMetadata();
284
285 meta.ID = reader["id"].ToString();
286 meta.FullID = new UUID(meta.ID);
287
288 meta.Name = String.Empty;
289 meta.Description = String.Empty;
290 meta.Type = (sbyte)Convert.ToInt32(reader["assetType"]);
291 meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type);
292 meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"]));
293
294 asset.Metadata = meta;
295 asset.Data = (byte[])reader["data"];
296
297 store(asset, force);
298
299 imported++;
300 }
301 }
302 }
303 }
304 catch (Exception e)
305 {
306 m_log.ErrorFormat("[PGSQL FSASSETS]: Error importing assets: {0}",
307 e.Message.ToString());
308 return;
309 }
310
311 MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported));
312 }
313
314 #endregion
315 }
316}
diff --git a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs
index 6ef576b..f398256 100755
--- a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs
@@ -435,7 +435,7 @@ namespace OpenSim.Data.PGSQL
435 435
436 using (NpgsqlCommand cmd = new NpgsqlCommand()) 436 using (NpgsqlCommand cmd = new NpgsqlCommand())
437 { 437 {
438 cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); 438 cmd.CommandText = String.Format("delete from {0} where \"TMStamp\"::abstime::timestamp < now() - INTERVAL '2 week'", m_Realm);
439 439
440 ExecuteNonQuery(cmd); 440 ExecuteNonQuery(cmd);
441 } 441 }
@@ -461,7 +461,7 @@ namespace OpenSim.Data.PGSQL
461 461
462 using (NpgsqlCommand cmd = new NpgsqlCommand()) 462 using (NpgsqlCommand cmd = new NpgsqlCommand())
463 { 463 {
464 cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); 464 cmd.CommandText = String.Format("delete from {0} where \"TMStamp\"::abstime::timestamp < now() - INTERVAL '2 week'", m_Realm);
465 465
466 ExecuteNonQuery(cmd); 466 ExecuteNonQuery(cmd);
467 } 467 }
diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
index 33d12bd..f4af40b 100755
--- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
@@ -350,10 +350,11 @@ namespace OpenSim.Data.PGSQL
350 ""CameraEyeOffsetY"" = :CameraEyeOffsetY, ""CameraEyeOffsetZ"" = :CameraEyeOffsetZ, ""CameraAtOffsetX"" = :CameraAtOffsetX, 350 ""CameraEyeOffsetY"" = :CameraEyeOffsetY, ""CameraEyeOffsetZ"" = :CameraEyeOffsetZ, ""CameraAtOffsetX"" = :CameraAtOffsetX,
351 ""CameraAtOffsetY"" = :CameraAtOffsetY, ""CameraAtOffsetZ"" = :CameraAtOffsetZ, ""ForceMouselook"" = :ForceMouselook, 351 ""CameraAtOffsetY"" = :CameraAtOffsetY, ""CameraAtOffsetZ"" = :CameraAtOffsetZ, ""ForceMouselook"" = :ForceMouselook,
352 ""ScriptAccessPin"" = :ScriptAccessPin, ""AllowedDrop"" = :AllowedDrop, ""DieAtEdge"" = :DieAtEdge, ""SalePrice"" = :SalePrice, 352 ""ScriptAccessPin"" = :ScriptAccessPin, ""AllowedDrop"" = :AllowedDrop, ""DieAtEdge"" = :DieAtEdge, ""SalePrice"" = :SalePrice,
353 ""SaleType"" = :SaleType, ""ColorR"" = :ColorR, ""ColorG"" = :ColorG, ""ColorB"" = :ColorB, ""ColorA"" = :ColorA, ""ParticleSystem"" = :ParticleSystem, 353 ""PhysicsShapeType"" = :PhysicsShapeType, ""Density"" = :Density, ""GravityModifier"" = :GravityModifier, ""Friction"" = :Friction, ""Restitution"" = :Restitution,
354 ""PassCollisions"" = :PassCollisions, ""RotationAxisLocks"" = :RotationAxisLocks, ""RezzerID"" = :RezzerID,
354 ""ClickAction"" = :ClickAction, ""Material"" = :Material, ""CollisionSound"" = :CollisionSound, ""CollisionSoundVolume"" = :CollisionSoundVolume, ""PassTouches"" = :PassTouches, 355 ""ClickAction"" = :ClickAction, ""Material"" = :Material, ""CollisionSound"" = :CollisionSound, ""CollisionSoundVolume"" = :CollisionSoundVolume, ""PassTouches"" = :PassTouches,
355 ""LinkNumber"" = :LinkNumber, ""MediaURL"" = :MediaURL, ""DynAttrs"" = :DynAttrs, 356 ""LinkNumber"" = :LinkNumber, ""MediaURL"" = :MediaURL, ""DynAttrs"" = :DynAttrs,
356 ""PhysicsShapeType"" = :PhysicsShapeType, ""Density"" = :Density, ""GravityModifier"" = :GravityModifier, ""Friction"" = :Friction, ""Restitution"" = :Restitution 357 ""PhysInertia"" = :PhysInertia
357 WHERE ""UUID"" = :UUID ; 358 WHERE ""UUID"" = :UUID ;
358 359
359 INSERT INTO 360 INSERT INTO
@@ -367,7 +368,7 @@ namespace OpenSim.Data.PGSQL
367 ""OmegaY"", ""OmegaZ"", ""CameraEyeOffsetX"", ""CameraEyeOffsetY"", ""CameraEyeOffsetZ"", ""CameraAtOffsetX"", ""CameraAtOffsetY"", ""CameraAtOffsetZ"", 368 ""OmegaY"", ""OmegaZ"", ""CameraEyeOffsetX"", ""CameraEyeOffsetY"", ""CameraEyeOffsetZ"", ""CameraAtOffsetX"", ""CameraAtOffsetY"", ""CameraAtOffsetZ"",
368 ""ForceMouselook"", ""ScriptAccessPin"", ""AllowedDrop"", ""DieAtEdge"", ""SalePrice"", ""SaleType"", ""ColorR"", ""ColorG"", ""ColorB"", ""ColorA"", 369 ""ForceMouselook"", ""ScriptAccessPin"", ""AllowedDrop"", ""DieAtEdge"", ""SalePrice"", ""SaleType"", ""ColorR"", ""ColorG"", ""ColorB"", ""ColorA"",
369 ""ParticleSystem"", ""ClickAction"", ""Material"", ""CollisionSound"", ""CollisionSoundVolume"", ""PassTouches"", ""LinkNumber"", ""MediaURL"", ""DynAttrs"", 370 ""ParticleSystem"", ""ClickAction"", ""Material"", ""CollisionSound"", ""CollisionSoundVolume"", ""PassTouches"", ""LinkNumber"", ""MediaURL"", ""DynAttrs"",
370 ""PhysicsShapeType"", ""Density"", ""GravityModifier"", ""Friction"", ""Restitution"" 371 ""PhysicsShapeType"", ""Density"", ""GravityModifier"", ""Friction"", ""Restitution"", ""PassCollisions"", ""RotationAxisLocks"", ""RezzerID"" , ""PhysInertia""
371 ) Select 372 ) Select
372 :UUID, :CreationDate, :Name, :Text, :Description, :SitName, :TouchName, :ObjectFlags, :OwnerMask, :NextOwnerMask, :GroupMask, 373 :UUID, :CreationDate, :Name, :Text, :Description, :SitName, :TouchName, :ObjectFlags, :OwnerMask, :NextOwnerMask, :GroupMask,
373 :EveryoneMask, :BaseMask, :PositionX, :PositionY, :PositionZ, :GroupPositionX, :GroupPositionY, :GroupPositionZ, :VelocityX, 374 :EveryoneMask, :BaseMask, :PositionX, :PositionY, :PositionZ, :GroupPositionX, :GroupPositionY, :GroupPositionZ, :VelocityX,
@@ -378,7 +379,7 @@ namespace OpenSim.Data.PGSQL
378 :OmegaY, :OmegaZ, :CameraEyeOffsetX, :CameraEyeOffsetY, :CameraEyeOffsetZ, :CameraAtOffsetX, :CameraAtOffsetY, :CameraAtOffsetZ, 379 :OmegaY, :OmegaZ, :CameraEyeOffsetX, :CameraEyeOffsetY, :CameraEyeOffsetZ, :CameraAtOffsetX, :CameraAtOffsetY, :CameraAtOffsetZ,
379 :ForceMouselook, :ScriptAccessPin, :AllowedDrop, :DieAtEdge, :SalePrice, :SaleType, :ColorR, :ColorG, :ColorB, :ColorA, 380 :ForceMouselook, :ScriptAccessPin, :AllowedDrop, :DieAtEdge, :SalePrice, :SaleType, :ColorR, :ColorG, :ColorB, :ColorA,
380 :ParticleSystem, :ClickAction, :Material, :CollisionSound, :CollisionSoundVolume, :PassTouches, :LinkNumber, :MediaURL, :DynAttrs, 381 :ParticleSystem, :ClickAction, :Material, :CollisionSound, :CollisionSoundVolume, :PassTouches, :LinkNumber, :MediaURL, :DynAttrs,
381 :PhysicsShapeType, :Density, :GravityModifier, :Friction, :Restitution 382 :PhysicsShapeType, :Density, :GravityModifier, :Friction, :Restitution, :PassCollisions, :RotationAxisLocks, :RezzerID, :PhysInertia
382 where not EXISTS (SELECT ""UUID"" FROM prims WHERE ""UUID"" = :UUID); 383 where not EXISTS (SELECT ""UUID"" FROM prims WHERE ""UUID"" = :UUID);
383 "; 384 ";
384 385
@@ -1678,6 +1679,12 @@ namespace OpenSim.Data.PGSQL
1678 prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); 1679 prim.OwnerID = new UUID((Guid)primRow["OwnerID"]);
1679 prim.GroupID = new UUID((Guid)primRow["GroupID"]); 1680 prim.GroupID = new UUID((Guid)primRow["GroupID"]);
1680 prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]); 1681 prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]);
1682
1683 if (primRow["RezzerID"] != DBNull.Value)
1684 prim.RezzerID = new UUID((Guid)primRow["RezzerID"]);
1685 else
1686 prim.RezzerID = UUID.Zero;
1687
1681 prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]); 1688 prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]);
1682 prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]); 1689 prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]);
1683 prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]); 1690 prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]);
@@ -1782,6 +1789,7 @@ namespace OpenSim.Data.PGSQL
1782 prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); 1789 prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]);
1783 1790
1784 prim.PassTouches = (bool)primRow["PassTouches"]; 1791 prim.PassTouches = (bool)primRow["PassTouches"];
1792 prim.PassCollisions = (bool)primRow["PassCollisions"];
1785 1793
1786 if (!(primRow["MediaURL"] is System.DBNull)) 1794 if (!(primRow["MediaURL"] is System.DBNull))
1787 prim.MediaUrl = (string)primRow["MediaURL"]; 1795 prim.MediaUrl = (string)primRow["MediaURL"];
@@ -1796,6 +1804,13 @@ namespace OpenSim.Data.PGSQL
1796 prim.GravityModifier = Convert.ToSingle(primRow["GravityModifier"]); 1804 prim.GravityModifier = Convert.ToSingle(primRow["GravityModifier"]);
1797 prim.Friction = Convert.ToSingle(primRow["Friction"]); 1805 prim.Friction = Convert.ToSingle(primRow["Friction"]);
1798 prim.Restitution = Convert.ToSingle(primRow["Restitution"]); 1806 prim.Restitution = Convert.ToSingle(primRow["Restitution"]);
1807 prim.RotationAxisLocks = Convert.ToByte(primRow["RotationAxisLocks"]);
1808
1809
1810 PhysicsInertiaData pdata = null;
1811 if (!(primRow["PhysInertia"] is System.DBNull))
1812 pdata = PhysicsInertiaData.FromXml2(primRow["PhysInertia"].ToString());
1813 prim.PhysicsInertia = pdata;
1799 1814
1800 return prim; 1815 return prim;
1801 } 1816 }
@@ -2097,6 +2112,7 @@ namespace OpenSim.Data.PGSQL
2097 parameters.Add(_Database.CreateParameter("OwnerID", prim.OwnerID)); 2112 parameters.Add(_Database.CreateParameter("OwnerID", prim.OwnerID));
2098 parameters.Add(_Database.CreateParameter("GroupID", prim.GroupID)); 2113 parameters.Add(_Database.CreateParameter("GroupID", prim.GroupID));
2099 parameters.Add(_Database.CreateParameter("LastOwnerID", prim.LastOwnerID)); 2114 parameters.Add(_Database.CreateParameter("LastOwnerID", prim.LastOwnerID));
2115 parameters.Add(_Database.CreateParameter("RezzerID", prim.RezzerID));
2100 parameters.Add(_Database.CreateParameter("OwnerMask", prim.OwnerMask)); 2116 parameters.Add(_Database.CreateParameter("OwnerMask", prim.OwnerMask));
2101 parameters.Add(_Database.CreateParameter("NextOwnerMask", prim.NextOwnerMask)); 2117 parameters.Add(_Database.CreateParameter("NextOwnerMask", prim.NextOwnerMask));
2102 parameters.Add(_Database.CreateParameter("GroupMask", prim.GroupMask)); 2118 parameters.Add(_Database.CreateParameter("GroupMask", prim.GroupMask));
@@ -2196,10 +2212,28 @@ namespace OpenSim.Data.PGSQL
2196 parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound)); 2212 parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound));
2197 parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume)); 2213 parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume));
2198 2214
2199 parameters.Add(_Database.CreateParameter("PassTouches", prim.PassTouches)); 2215 parameters.Add(_Database.CreateParameter("PassTouches", (bool)prim.PassTouches));
2216 parameters.Add(_Database.CreateParameter("PassCollisions", (bool)prim.PassCollisions));
2217
2218
2219 if (prim.PassTouches)
2220 parameters.Add(_Database.CreateParameter("PassTouches", true));
2221 else
2222 parameters.Add(_Database.CreateParameter("PassTouches", false));
2223
2224 if (prim.PassCollisions)
2225 parameters.Add(_Database.CreateParameter("PassCollisions", true));
2226 else
2227 parameters.Add(_Database.CreateParameter("PassCollisions", false));
2200 2228
2201 parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); 2229 parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum));
2202 parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); 2230 parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl));
2231
2232 if (prim.PhysicsInertia != null)
2233 parameters.Add(_Database.CreateParameter("PhysInertia", prim.PhysicsInertia.ToXml2()));
2234 else
2235 parameters.Add(_Database.CreateParameter("PhysInertia", String.Empty));
2236
2203 2237
2204 if (prim.DynAttrs.CountNamespaces > 0) 2238 if (prim.DynAttrs.CountNamespaces > 0)
2205 parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml())); 2239 parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml()));
@@ -2211,12 +2245,13 @@ namespace OpenSim.Data.PGSQL
2211 parameters.Add(_Database.CreateParameter("GravityModifier", (double)prim.GravityModifier)); 2245 parameters.Add(_Database.CreateParameter("GravityModifier", (double)prim.GravityModifier));
2212 parameters.Add(_Database.CreateParameter("Friction", (double)prim.Friction)); 2246 parameters.Add(_Database.CreateParameter("Friction", (double)prim.Friction));
2213 parameters.Add(_Database.CreateParameter("Restitution", (double)prim.Restitution)); 2247 parameters.Add(_Database.CreateParameter("Restitution", (double)prim.Restitution));
2248 parameters.Add(_Database.CreateParameter("RotationAxisLocks", prim.RotationAxisLocks));
2214 2249
2215 return parameters.ToArray(); 2250 return parameters.ToArray();
2216 } 2251 }
2217 2252
2218 /// <summary> 2253 /// <summary>
2219 /// Creates the primshape parameters for stroing in DB. 2254 /// Creates the primshape parameters for storing in DB.
2220 /// </summary> 2255 /// </summary>
2221 /// <param name="prim">Basic data of SceneObjectpart prim.</param> 2256 /// <param name="prim">Basic data of SceneObjectpart prim.</param>
2222 /// <param name="sceneGroupID">The scene group ID.</param> 2257 /// <param name="sceneGroupID">The scene group ID.</param>
diff --git a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
index 75a51e2..5800de9 100644
--- a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
@@ -845,7 +845,7 @@ namespace OpenSim.Data.PGSQL
845 845
846 query = "SELECT \"profileImage\", \"profileFirstImage\" FROM \"userprofile\" WHERE \"useruuid\" = :Id"; 846 query = "SELECT \"profileImage\", \"profileFirstImage\" FROM \"userprofile\" WHERE \"useruuid\" = :Id";
847 847
848 using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format(query, "\"userpicks\""), dbcon)) 848 using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
849 { 849 {
850 cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); 850 cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId));
851 851
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
index 6e88489..1798d20 100644
--- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
@@ -173,16 +173,18 @@ namespace OpenSim.Data.PGSQL
173 173
174 if (m_enableCompression) 174 if (m_enableCompression)
175 { 175 {
176 using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) 176 using(MemoryStream ms = new MemoryStream(asset.Data))
177 using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
177 { 178 {
178 MemoryStream outputStream = new MemoryStream(); 179 using(MemoryStream outputStream = new MemoryStream())
179 WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); 180 {
180 // int compressedLength = asset.Data.Length; 181 decompressionStream.CopyTo(outputStream,int.MaxValue);
181 asset.Data = outputStream.ToArray(); 182 // int compressedLength = asset.Data.Length;
182 183 asset.Data = outputStream.ToArray();
183 // m_log.DebugFormat( 184 }
184 // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", 185 // m_log.DebugFormat(
185 // asset.ID, asset.Name, asset.Data.Length, compressedLength); 186 // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
187 // asset.ID, asset.Name, asset.Data.Length, compressedLength);
186 } 188 }
187 } 189 }
188 190
diff --git a/OpenSim/Data/PGSQL/PGSQLXInventoryData.cs b/OpenSim/Data/PGSQL/PGSQLXInventoryData.cs
index 55a1996..4c10ac9 100644
--- a/OpenSim/Data/PGSQL/PGSQLXInventoryData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLXInventoryData.cs
@@ -206,7 +206,7 @@ namespace OpenSim.Data.PGSQL
206 cmd.CommandText = String.Format(@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions"" 206 cmd.CommandText = String.Format(@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions""
207 from inventoryitems 207 from inventoryitems
208 where ""avatarID""::uuid = :PrincipalID 208 where ""avatarID""::uuid = :PrincipalID
209 and ""assetID"" = :AssetID 209 and ""assetID""::uuid = :AssetID
210 group by ""assetID"" "); 210 group by ""assetID"" ");
211 211
212 cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID)); 212 cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID));
diff --git a/OpenSim/Data/PGSQL/Resources/AgentPrefs.migrations b/OpenSim/Data/PGSQL/Resources/AgentPrefs.migrations
new file mode 100644
index 0000000..ca3cca2
--- /dev/null
+++ b/OpenSim/Data/PGSQL/Resources/AgentPrefs.migrations
@@ -0,0 +1,19 @@
1:VERSION 1
2
3BEGIN TRANSACTION;
4
5CREATE TABLE IF NOT EXISTS "public"."agentprefs" (
6 "PrincipalID" uuid NOT NULL,
7 "AccessPrefs" char(2) NOT NULL DEFAULT 'M'::bpchar COLLATE "default",
8 "HoverHeight" float8 NOT NULL DEFAULT 0,
9 "Language" char(5) NOT NULL DEFAULT 'en-us'::bpchar COLLATE "default",
10 "LanguageIsPublic" bool NOT NULL DEFAULT true,
11 "PermEveryone" int4 NOT NULL DEFAULT 0,
12 "PermGroup" int4 NOT NULL DEFAULT 0,
13 "PermNextOwner" int4 NOT NULL DEFAULT 532480
14)
15WITH (OIDS=FALSE);
16
17ALTER TABLE "public"."agentprefs" ADD PRIMARY KEY ("PrincipalID") NOT DEFERRABLE INITIALLY IMMEDIATE;
18
19COMMIT;
diff --git a/OpenSim/Data/PGSQL/Resources/EstateStore.migrations b/OpenSim/Data/PGSQL/Resources/EstateStore.migrations
index 59270f8..5b450aa 100644
--- a/OpenSim/Data/PGSQL/Resources/EstateStore.migrations
+++ b/OpenSim/Data/PGSQL/Resources/EstateStore.migrations
@@ -1,307 +1,127 @@
1:VERSION 1 1:VERSION 12
2 2
3BEGIN TRANSACTION; 3BEGIN TRANSACTION;
4 4
5CREATE TABLE estate_managers( 5-- ----------------------------
6 "EstateID" int NOT NULL Primary Key, 6-- Table structure for estate_groups
7 uuid varchar(36) NOT NULL 7-- ----------------------------
8 ); 8CREATE TABLE IF NOT EXISTS "public"."estate_groups" (
9 9 "EstateID" int4 NOT NULL,
10CREATE TABLE estate_groups( 10 "uuid" uuid NOT NULL
11 "EstateID" int NOT NULL, 11)
12 uuid varchar(36) NOT NULL 12WITH (OIDS=FALSE);
13 ); 13
14 14-- Indexes structure for table estate_groups
15 15-- ----------------------------
16CREATE TABLE estate_users( 16CREATE INDEX IF NOT EXISTS "ix_estate_groups" ON "public"."estate_groups" USING btree("EstateID" "pg_catalog"."int4_ops" ASC NULLS LAST);
17 "EstateID" int NOT NULL, 17
18 uuid varchar(36) NOT NULL 18-- ----------------------------
19 ); 19-- Table structure for estate_managers
20 20-- ----------------------------
21 21CREATE TABLE IF NOT EXISTS "public"."estate_managers" (
22CREATE TABLE estateban( 22 "EstateID" int4 NOT NULL,
23 "EstateID" int NOT NULL, 23 "uuid" uuid NOT NULL
24 "bannedUUID" varchar(36) NOT NULL, 24)
25 "bannedIp" varchar(16) NOT NULL, 25WITH (OIDS=FALSE);
26 "bannedIpHostMask" varchar(16) NOT NULL, 26
27 "bannedNameMask" varchar(64) NULL DEFAULT NULL 27-- Indexes structure for table estate_managers
28 ); 28-- ----------------------------
29 29CREATE INDEX IF NOT EXISTS "ix_estate_managers" ON "public"."estate_managers" USING btree("EstateID" "pg_catalog"."int4_ops" ASC NULLS LAST);
30Create Sequence estate_settings_id increment by 100 start with 100; 30
31 31-- ----------------------------
32CREATE TABLE estate_settings( 32-- Table structure for estate_map
33 "EstateID" integer DEFAULT nextval('estate_settings_id') NOT NULL, 33-- ----------------------------
34 "EstateName" varchar(64) NULL DEFAULT (NULL), 34CREATE TABLE IF NOT EXISTS "public"."estate_map" (
35 "AbuseEmailToEstateOwner" boolean NOT NULL, 35 "RegionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
36 "DenyAnonymous" boolean NOT NULL, 36 "EstateID" int4 NOT NULL
37 "ResetHomeOnTeleport" boolean NOT NULL, 37)
38 "FixedSun" boolean NOT NULL, 38WITH (OIDS=FALSE);
39 "DenyTransacted" boolean NOT NULL, 39
40 "BlockDwell" boolean NOT NULL, 40-- Primary key structure for table estate_map
41 "DenyIdentified" boolean NOT NULL, 41-- ----------------------------
42 "AllowVoice" boolean NOT NULL, 42ALTER TABLE "public"."estate_map" ADD PRIMARY KEY ("RegionID") NOT DEFERRABLE INITIALLY IMMEDIATE;
43 "UseGlobalTime" boolean NOT NULL, 43
44 "PricePerMeter" int NOT NULL, 44-- ----------------------------
45 "TaxFree" boolean NOT NULL, 45-- Table structure for estate_settings
46 "AllowDirectTeleport" boolean NOT NULL, 46-- ----------------------------
47 "RedirectGridX" int NOT NULL, 47CREATE TABLE IF NOT EXISTS "public"."estate_settings" (
48 "RedirectGridY" int NOT NULL, 48 "EstateID" int4 NOT NULL DEFAULT nextval('estate_settings_id'::regclass),
49 "ParentEstateID" int NOT NULL, 49 "EstateName" varchar(64) DEFAULT NULL::character varying COLLATE "default",
50 "SunPosition" double precision NOT NULL, 50 "AbuseEmailToEstateOwner" bool NOT NULL,
51 "EstateSkipScripts" boolean NOT NULL, 51 "DenyAnonymous" bool NOT NULL,
52 "BillableFactor" double precision NOT NULL, 52 "ResetHomeOnTeleport" bool NOT NULL,
53 "PublicAccess" boolean NOT NULL, 53 "FixedSun" bool NOT NULL,
54 "AbuseEmail" varchar(255) NOT NULL, 54 "DenyTransacted" bool NOT NULL,
55 "EstateOwner" varchar(36) NOT NULL, 55 "BlockDwell" bool NOT NULL,
56 "DenyMinors" boolean NOT NULL 56 "DenyIdentified" bool NOT NULL,
57 ); 57 "AllowVoice" bool NOT NULL,
58 58 "UseGlobalTime" bool NOT NULL,
59 59 "PricePerMeter" int4 NOT NULL,
60CREATE TABLE estate_map( 60 "TaxFree" bool NOT NULL,
61 "RegionID" varchar(36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'), 61 "AllowDirectTeleport" bool NOT NULL,
62 "EstateID" int NOT NULL 62 "RedirectGridX" int4 NOT NULL,
63 ); 63 "RedirectGridY" int4 NOT NULL,
64 64 "ParentEstateID" int4 NOT NULL,
65COMMIT; 65 "SunPosition" float8 NOT NULL,
66 66 "EstateSkipScripts" bool NOT NULL,
67:VERSION 2 67 "BillableFactor" float8 NOT NULL,
68 68 "PublicAccess" bool NOT NULL,
69BEGIN TRANSACTION; 69 "AbuseEmail" varchar(255) NOT NULL COLLATE "default",
70
71CREATE INDEX IX_estate_managers ON estate_managers
72 (
73 "EstateID"
74 );
75
76
77CREATE INDEX IX_estate_groups ON estate_groups
78 (
79 "EstateID"
80 );
81
82
83CREATE INDEX IX_estate_users ON estate_users
84 (
85 "EstateID"
86 );
87
88COMMIT;
89
90:VERSION 3
91
92BEGIN TRANSACTION;
93
94CREATE TABLE Tmp_estateban
95 (
96 "EstateID" int NOT NULL,
97 "bannedUUID" varchar(36) NOT NULL,
98 "bannedIp" varchar(16) NULL,
99 "bannedIpHostMask" varchar(16) NULL,
100 "bannedNameMask" varchar(64) NULL
101 );
102
103 INSERT INTO Tmp_estateban ("EstateID", "bannedUUID", "bannedIp", "bannedIpHostMask", "bannedNameMask")
104 SELECT "EstateID", "bannedUUID", "bannedIp", "bannedIpHostMask", "bannedNameMask" FROM estateban;
105
106DROP TABLE estateban;
107
108Alter table Tmp_estateban
109 rename to estateban;
110
111CREATE INDEX IX_estateban ON estateban
112 (
113 "EstateID"
114 );
115
116COMMIT;
117
118
119:VERSION 4
120
121BEGIN TRANSACTION;
122
123CREATE TABLE Tmp_estate_managers
124 (
125 "EstateID" int NOT NULL,
126 uuid uuid NOT NULL
127 );
128
129INSERT INTO Tmp_estate_managers ("EstateID", uuid)
130 SELECT "EstateID", cast(uuid as uuid) FROM estate_managers;
131
132DROP TABLE estate_managers;
133
134Alter table Tmp_estate_managers
135 rename to estate_managers;
136
137CREATE INDEX IX_estate_managers ON estate_managers
138 (
139 "EstateID"
140 );
141
142COMMIT;
143
144
145:VERSION 5
146
147BEGIN TRANSACTION;
148
149CREATE TABLE Tmp_estate_groups
150 (
151 "EstateID" int NOT NULL,
152 uuid uuid NOT NULL
153 ) ;
154
155 INSERT INTO Tmp_estate_groups ("EstateID", uuid)
156 SELECT "EstateID", cast(uuid as uuid) FROM estate_groups;
157
158DROP TABLE estate_groups;
159
160Alter table Tmp_estate_groups
161 rename to estate_groups;
162
163CREATE INDEX IX_estate_groups ON estate_groups
164 (
165 "EstateID"
166 );
167
168COMMIT;
169
170
171:VERSION 6
172
173BEGIN TRANSACTION;
174
175CREATE TABLE Tmp_estate_users
176 (
177 "EstateID" int NOT NULL,
178 uuid uuid NOT NULL
179 );
180
181INSERT INTO Tmp_estate_users ("EstateID", uuid)
182 SELECT "EstateID", cast(uuid as uuid) FROM estate_users ;
183
184DROP TABLE estate_users;
185
186Alter table Tmp_estate_users
187 rename to estate_users;
188
189CREATE INDEX IX_estate_users ON estate_users
190 (
191 "EstateID"
192 );
193
194COMMIT;
195
196
197:VERSION 7
198
199BEGIN TRANSACTION;
200
201CREATE TABLE Tmp_estateban
202 (
203 "EstateID" int NOT NULL,
204 "bannedUUID" uuid NOT NULL,
205 "bannedIp" varchar(16) NULL,
206 "bannedIpHostMask" varchar(16) NULL,
207 "bannedNameMask" varchar(64) NULL
208 );
209
210INSERT INTO Tmp_estateban ("EstateID", "bannedUUID", "bannedIp", "bannedIpHostMask", "bannedNameMask")
211 SELECT "EstateID", cast("bannedUUID" as uuid), "bannedIp", "bannedIpHostMask", "bannedNameMask" FROM estateban ;
212
213DROP TABLE estateban;
214
215Alter table Tmp_estateban
216 rename to estateban;
217
218CREATE INDEX IX_estateban ON estateban
219 (
220 "EstateID"
221 );
222
223COMMIT;
224
225
226:VERSION 8
227
228BEGIN TRANSACTION;
229
230CREATE TABLE Tmp_estate_settings
231 (
232 "EstateID" integer default nextval('estate_settings_id') NOT NULL,
233 "EstateName" varchar(64) NULL DEFAULT (NULL),
234 "AbuseEmailToEstateOwner" boolean NOT NULL,
235 "DenyAnonymous" boolean NOT NULL,
236 "ResetHomeOnTeleport" boolean NOT NULL,
237 "FixedSun" boolean NOT NULL,
238 "DenyTransacted" boolean NOT NULL,
239 "BlockDwell" boolean NOT NULL,
240 "DenyIdentified" boolean NOT NULL,
241 "AllowVoice" boolean NOT NULL,
242 "UseGlobalTime" boolean NOT NULL,
243 "PricePerMeter" int NOT NULL,
244 "TaxFree" boolean NOT NULL,
245 "AllowDirectTeleport" boolean NOT NULL,
246 "RedirectGridX" int NOT NULL,
247 "RedirectGridY" int NOT NULL,
248 "ParentEstateID" int NOT NULL,
249 "SunPosition" double precision NOT NULL,
250 "EstateSkipScripts" boolean NOT NULL,
251 "BillableFactor" double precision NOT NULL,
252 "PublicAccess" boolean NOT NULL,
253 "AbuseEmail" varchar(255) NOT NULL,
254 "EstateOwner" uuid NOT NULL, 70 "EstateOwner" uuid NOT NULL,
255 "DenyMinors" boolean NOT NULL 71 "DenyMinors" bool NOT NULL,
256 ); 72 "AllowLandmark" bool NOT NULL DEFAULT true,
257 73 "AllowParcelChanges" bool NOT NULL DEFAULT true,
258INSERT INTO Tmp_estate_settings ("EstateID", "EstateName", "AbuseEmailToEstateOwner", "DenyAnonymous", "ResetHomeOnTeleport", "FixedSun", "DenyTransacted", "BlockDwell", "DenyIdentified", "AllowVoice", "UseGlobalTime", "PricePerMeter", "TaxFree", "AllowDirectTeleport", "RedirectGridX", "RedirectGridY", "ParentEstateID", "SunPosition", "EstateSkipScripts", "BillableFactor", "PublicAccess", "AbuseEmail", "EstateOwner", "DenyMinors") 74 "AllowSetHome" bool NOT NULL DEFAULT true
259 SELECT "EstateID", "EstateName", "AbuseEmailToEstateOwner", "DenyAnonymous", "ResetHomeOnTeleport", "FixedSun", "DenyTransacted", "BlockDwell", "DenyIdentified", "AllowVoice", "UseGlobalTime", "PricePerMeter", "TaxFree", "AllowDirectTeleport", "RedirectGridX", "RedirectGridY", "ParentEstateID", "SunPosition", "EstateSkipScripts", "BillableFactor", "PublicAccess", "AbuseEmail", cast("EstateOwner" as uuid), "DenyMinors" FROM estate_settings ; 75)
260 76WITH (OIDS=FALSE);
261DROP TABLE estate_settings; 77
262 78-- Primary key structure for table estate_settings
263 79-- ----------------------------
264Alter table Tmp_estate_settings 80ALTER TABLE "public"."estate_settings" ADD PRIMARY KEY ("EstateID") NOT DEFERRABLE INITIALLY IMMEDIATE;
265 rename to estate_settings; 81
266 82-- ----------------------------
83-- Table structure for estate_users
84-- ----------------------------
85CREATE TABLE IF NOT EXISTS "public"."estate_users" (
86 "EstateID" int4 NOT NULL,
87 "uuid" uuid NOT NULL
88)
89WITH (OIDS=FALSE);
90
91-- Indexes structure for table estate_users
92-- ----------------------------
93CREATE INDEX IF NOT EXISTS "ix_estate_users" ON "public"."estate_users" USING btree("EstateID" "pg_catalog"."int4_ops" ASC NULLS LAST);
94
95-- ----------------------------
96-- Table structure for estateban
97-- ----------------------------
98CREATE TABLE IF NOT EXISTS "public"."estateban" (
99 "EstateID" int4 NOT NULL,
100 "bannedUUID" uuid NOT NULL,
101 "bannedIp" varchar(16) COLLATE "default",
102 "bannedIpHostMask" varchar(16) COLLATE "default",
103 "bannedNameMask" varchar(64) COLLATE "default"
104)
105WITH (OIDS=FALSE);
267 106
268Create index on estate_settings (lower("EstateName")); 107-- Indexes structure for table estateban
108-- ----------------------------
109CREATE INDEX IF NOT EXISTS "ix_estateban" ON "public"."estateban" USING btree("EstateID" "pg_catalog"."int4_ops" ASC NULLS LAST);
269 110
270COMMIT; 111COMMIT;
271 112
113:VERSION 13
272 114
273:VERSION 9 115 BEGIN TRASACTION;
274
275BEGIN TRANSACTION;
276
277CREATE TABLE Tmp_estate_map
278 (
279 "RegionID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
280 "EstateID" int NOT NULL
281 );
282
283INSERT INTO Tmp_estate_map ("RegionID", "EstateID")
284 SELECT cast("RegionID" as uuid), "EstateID" FROM estate_map ;
285
286DROP TABLE estate_map;
287
288Alter table Tmp_estate_map
289 rename to estate_map;
290
291COMMIT;
292 116
293:VERSION 10 117-- ----------------------------
118-- SEQUENCE estate_settings_id
119-- ----------------------------
120CREATE SEQUENCE IF NOT EXISTS "public"."estate_settings_id"
121 INCREMENT 100
122 MINVALUE 1
123 MAXVALUE 9223372036854775807
124 START 100
125 CACHE 1;
294 126
295BEGIN TRANSACTION;
296ALTER TABLE estate_settings ADD COLUMN "AllowLandmark" boolean NOT NULL default true;
297ALTER TABLE estate_settings ADD COLUMN "AllowParcelChanges" boolean NOT NULL default true;
298ALTER TABLE estate_settings ADD COLUMN "AllowSetHome" boolean NOT NULL default true;
299COMMIT; 127COMMIT;
300
301:VERSION 11
302
303Begin transaction;
304
305
306Commit;
307
diff --git a/OpenSim/Data/PGSQL/Resources/FSAssetStore.migrations b/OpenSim/Data/PGSQL/Resources/FSAssetStore.migrations
new file mode 100644
index 0000000..3a072e5
--- /dev/null
+++ b/OpenSim/Data/PGSQL/Resources/FSAssetStore.migrations
@@ -0,0 +1,14 @@
1:VERSION 1
2
3BEGIN TRANSACTION;
4
5CREATE TABLE fsassets (
6 "id" uuid NOT NULL PRIMARY KEY,
7 "type" integer NOT NULL,
8 "hash" char(64) NOT NULL,
9 "create_time" integer NOT NULL DEFAULT '0',
10 "access_time" integer NOT NULL DEFAULT '0',
11 "asset_flags" integer NOT NULL DEFAULT '0'
12);
13
14COMMIT;
diff --git a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations
index c085939..fcefb6b 100644
--- a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations
@@ -1195,3 +1195,33 @@ CREATE TABLE bakedterrain
1195 ); 1195 );
1196 1196
1197COMMIT; 1197COMMIT;
1198
1199:VERSION 45 #---- Add RezzerID filed in table prims
1200
1201BEGIN TRANSACTION;
1202
1203ALTER TABLE prims ADD "RezzerID" uuid NULL;
1204
1205COMMIT;
1206
1207:VERSION 46 #---- Add physics inertia data to table prims
1208
1209BEGIN TRANSACTION;
1210
1211ALTER TABLE prims ADD "PhysInertia" TEXT;
1212
1213COMMIT;
1214
1215
1216:VERSION 47 #---- Convert field PassCollisions in table prims to BOOLEAN
1217
1218BEGIN TRANSACTION;
1219
1220ALTER TABLE "public"."prims" ALTER COLUMN "PassCollisions" DROP DEFAULT;
1221ALTER TABLE "public"."prims"
1222 ALTER COLUMN "PassCollisions" TYPE BOOLEAN
1223 USING CASE WHEN "PassCollisions" = 0 THEN FALSE
1224 WHEN "PassCollisions" = 1 THEN TRUE
1225 ELSE NULL
1226 END;
1227COMMIT;
diff --git a/OpenSim/Data/SQLite/Resources/MuteListStore.migrations b/OpenSim/Data/SQLite/Resources/MuteListStore.migrations
new file mode 100644
index 0000000..f981ded
--- /dev/null
+++ b/OpenSim/Data/SQLite/Resources/MuteListStore.migrations
@@ -0,0 +1,16 @@
1:VERSION 1
2
3BEGIN TRANSACTION;
4
5CREATE TABLE MuteList (
6 AgentID char(36) NOT NULL,
7 MuteID char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
8 MuteName varchar(64) NOT NULL DEFAULT '',
9 MuteType int(11) NOT NULL DEFAULT '1',
10 MuteFlags int(11) NOT NULL DEFAULT '0',
11 Stamp int(11) NOT NULL,
12 UNIQUE (AgentID, MuteID, MuteName),
13 PRIMARY KEY(AgentID)
14);
15
16COMMIT;
diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
index eef14d6..fb154cf 100644
--- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations
+++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
@@ -371,3 +371,9 @@ BEGIN;
371ALTER TABLE `prims` ADD COLUMN `RezzerID` char(36) DEFAULT NULL; 371ALTER TABLE `prims` ADD COLUMN `RezzerID` char(36) DEFAULT NULL;
372 372
373COMMIT; 373COMMIT;
374
375:VERSION 36 #----- Add physics inertia data
376
377BEGIN;
378ALTER TABLE `prims` ADD COLUMN `PhysInertia` TEXT default NULL;
379COMMIT;
diff --git a/OpenSim/Data/SQLite/SQLiteMuteListData.cs b/OpenSim/Data/SQLite/SQLiteMuteListData.cs
new file mode 100644
index 0000000..80fd019
--- /dev/null
+++ b/OpenSim/Data/SQLite/SQLiteMuteListData.cs
@@ -0,0 +1,71 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34#if CSharpSqlite
35 using Community.CsharpSqlite.Sqlite;
36#else
37 using Mono.Data.Sqlite;
38#endif
39
40namespace OpenSim.Data.SQLite
41{
42 public class SQLiteMuteListData : SQLiteGenericTableHandler<MuteData>, IMuteListData
43 {
44 public SQLiteMuteListData(string connectionString)
45 : base(connectionString, "MuteList", "MuteListStore")
46 {
47 }
48
49 public MuteData[] Get(UUID agentID)
50 {
51 MuteData[] data = base.Get("AgentID", agentID.ToString());
52 return data;
53 }
54
55 public bool Delete(UUID agentID, UUID muteID, string muteName)
56 {
57 using (SqliteCommand cmd = new SqliteCommand())
58 {
59 cmd.CommandText = "delete from MuteList where `AgentID` = :AgentID and `MuteID` = :MuteID and `MuteName` = :MuteName";
60
61 cmd.Parameters.AddWithValue(":AgentID", agentID.ToString());
62 cmd.Parameters.AddWithValue(":MuteID", muteID.ToString());
63 cmd.Parameters.AddWithValue(":MuteName", muteName);
64
65 if (ExecuteNonQuery(cmd, m_Connection) > 0)
66 return true;
67 return false;
68 }
69 }
70 }
71} \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index eec386f..19880de 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -1843,6 +1843,12 @@ namespace OpenSim.Data.SQLite
1843 if (vehicle != null) 1843 if (vehicle != null)
1844 prim.VehicleParams = vehicle; 1844 prim.VehicleParams = vehicle;
1845 } 1845 }
1846
1847 PhysicsInertiaData pdata = null;
1848 if (!(row["PhysInertia"] is DBNull) && row["PhysInertia"].ToString() != String.Empty)
1849 pdata = PhysicsInertiaData.FromXml2(row["PhysInertia"].ToString());
1850 prim.PhysicsInertia = pdata;
1851
1846 return prim; 1852 return prim;
1847 } 1853 }
1848 1854
@@ -2266,6 +2272,11 @@ namespace OpenSim.Data.SQLite
2266 else 2272 else
2267 row["Vehicle"] = String.Empty; 2273 row["Vehicle"] = String.Empty;
2268 2274
2275 if (prim.PhysicsInertia != null)
2276 row["PhysInertia"] = prim.PhysicsInertia.ToXml2();
2277 else
2278 row["PhysInertia"] = String.Empty;
2279
2269 } 2280 }
2270 2281
2271 /// <summary> 2282 /// <summary>
diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs
index 13aac79..2f22d54 100644
--- a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs
+++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs
@@ -926,7 +926,7 @@ namespace OpenSim.Data.SQLite
926 { 926 {
927 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 927 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
928 { 928 {
929 cmd.CommandText = query; 929 cmd.CommandText = string.Format(query, "\"classifieds\"");
930 cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); 930 cmd.Parameters.AddWithValue(":Id", avatarId.ToString());
931 931
932 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 932 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
@@ -940,7 +940,7 @@ namespace OpenSim.Data.SQLite
940 940
941 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) 941 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
942 { 942 {
943 cmd.CommandText = query; 943 cmd.CommandText = string.Format(query, "\"userpicks\"");
944 cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); 944 cmd.Parameters.AddWithValue(":Id", avatarId.ToString());
945 945
946 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 946 using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
index 7f44a65..4ef1f30 100644
--- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
+++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
@@ -305,17 +305,11 @@ namespace OpenSim.Data.SQLite
305 305
306 using (SqliteCommand cmd = new SqliteCommand()) 306 using (SqliteCommand cmd = new SqliteCommand())
307 { 307 {
308 cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID"; 308 cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = :folderID";
309 cmd.Parameters.Add(new SqliteParameter(":folderID", folderID)); 309 cmd.Parameters.Add(new SqliteParameter(":folderID", folderID));
310 310
311 try 311 if(ExecuteNonQuery(cmd, m_Connection) == 0)
312 {
313 cmd.ExecuteNonQuery();
314 }
315 catch (Exception)
316 {
317 return false; 312 return false;
318 }
319 } 313 }
320 314
321 return true; 315 return true;