aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL
diff options
context:
space:
mode:
authoronefang2019-05-19 21:24:15 +1000
committeronefang2019-05-19 21:24:15 +1000
commit5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch)
treea9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Data/PGSQL
parentAdd a build script. (diff)
downloadopensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Data/PGSQL')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLAgentPreferencesData.cs16
-rw-r--r--OpenSim/Data/PGSQL/PGSQLAssetData.cs21
-rw-r--r--OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs6
-rw-r--r--OpenSim/Data/PGSQL/PGSQLAvatarData.cs2
-rw-r--r--OpenSim/Data/PGSQL/PGSQLEstateData.cs2
-rw-r--r--OpenSim/Data/PGSQL/PGSQLFSAssetData.cs316
-rw-r--r--OpenSim/Data/PGSQL/PGSQLFriendsData.cs6
-rw-r--r--OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs51
-rwxr-xr-x[-rw-r--r--]OpenSim/Data/PGSQL/PGSQLGroupsData.cs40
-rw-r--r--OpenSim/Data/PGSQL/PGSQLInventoryData.cs58
-rw-r--r--OpenSim/Data/PGSQL/PGSQLManager.cs4
-rw-r--r--OpenSim/Data/PGSQL/PGSQLMigration.cs4
-rw-r--r--OpenSim/Data/PGSQL/PGSQLOfflineIMData.cs2
-rwxr-xr-x[-rw-r--r--]OpenSim/Data/PGSQL/PGSQLPresenceData.cs4
-rw-r--r--OpenSim/Data/PGSQL/PGSQLRegionData.cs82
-rwxr-xr-x[-rw-r--r--]OpenSim/Data/PGSQL/PGSQLSimulationData.cs307
-rw-r--r--OpenSim/Data/PGSQL/PGSQLUserAccountData.cs25
-rw-r--r--OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs12
-rw-r--r--OpenSim/Data/PGSQL/PGSQLXAssetData.cs94
-rw-r--r--OpenSim/Data/PGSQL/PGSQLXInventoryData.cs19
-rw-r--r--OpenSim/Data/PGSQL/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Data/PGSQL/Resources/AgentPrefs.migrations19
-rw-r--r--OpenSim/Data/PGSQL/Resources/AuthStore.migrations8
-rw-r--r--OpenSim/Data/PGSQL/Resources/EstateStore.migrations410
-rw-r--r--OpenSim/Data/PGSQL/Resources/FSAssetStore.migrations14
-rwxr-xr-x[-rw-r--r--]OpenSim/Data/PGSQL/Resources/Presence.migrations0
-rw-r--r--OpenSim/Data/PGSQL/Resources/RegionStore.migrations67
-rw-r--r--OpenSim/Data/PGSQL/Resources/UserAccount.migrations6
-rw-r--r--OpenSim/Data/PGSQL/Resources/UserProfiles.migrations10
29 files changed, 1025 insertions, 582 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLAgentPreferencesData.cs b/OpenSim/Data/PGSQL/PGSQLAgentPreferencesData.cs
index 20612fe..4794c71 100644
--- a/OpenSim/Data/PGSQL/PGSQLAgentPreferencesData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLAgentPreferencesData.cs
@@ -44,20 +44,12 @@ namespace OpenSim.Data.PGSQL
44 44
45 public AgentPreferencesData GetPrefs(UUID agentID) 45 public AgentPreferencesData GetPrefs(UUID agentID)
46 { 46 {
47 // Until someone sends in a table that works
48 return null;
49 //AgentPreferencesData[] ret = Get("PrincipalID", agentID.ToString());
50 47
51 //if (ret.Length == 0) 48 AgentPreferencesData[] ret = Get("PrincipalID", agentID.ToString());
52 // return null;
53 49
54 //return ret[0]; 50 if (ret.Length == 0)
55 } 51 return null;
56 52 return ret[0];
57 public override bool Store(AgentPreferencesData row)
58 {
59 // Until someone sends in a table that works
60 return false;
61 } 53 }
62 54
63 } 55 }
diff --git a/OpenSim/Data/PGSQL/PGSQLAssetData.cs b/OpenSim/Data/PGSQL/PGSQLAssetData.cs
index 5d8b0a2..7b79521 100644
--- a/OpenSim/Data/PGSQL/PGSQLAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLAssetData.cs
@@ -149,37 +149,37 @@ namespace OpenSim.Data.PGSQL
149 /// Create asset in m_database 149 /// Create asset in m_database
150 /// </summary> 150 /// </summary>
151 /// <param name="asset">the asset</param> 151 /// <param name="asset">the asset</param>
152 override public void StoreAsset(AssetBase asset) 152 override public bool StoreAsset(AssetBase asset)
153 { 153 {
154 154
155 string sql = 155 string sql =
156 @"UPDATE assets set name = :name, description = :description, " + "\"assetType\" " + @" = :assetType, 156 @"UPDATE assets set name = :name, description = :description, " + "\"assetType\" " + @" = :assetType,
157 local = :local, temporary = :temporary, creatorid = :creatorid, data = :data 157 local = :local, temporary = :temporary, creatorid = :creatorid, data = :data
158 WHERE id=:id; 158 WHERE id=:id;
159 159
160 INSERT INTO assets 160 INSERT INTO assets
161 (id, name, description, " + "\"assetType\" " + @", local, 161 (id, name, description, " + "\"assetType\" " + @", local,
162 temporary, create_time, access_time, creatorid, asset_flags, data) 162 temporary, create_time, access_time, creatorid, asset_flags, data)
163 Select :id, :name, :description, :assetType, :local, 163 Select :id, :name, :description, :assetType, :local,
164 :temporary, :create_time, :access_time, :creatorid, :asset_flags, :data 164 :temporary, :create_time, :access_time, :creatorid, :asset_flags, :data
165 Where not EXISTS(SELECT * FROM assets WHERE id=:id) 165 Where not EXISTS(SELECT * FROM assets WHERE id=:id)
166 "; 166 ";
167 167
168 string assetName = asset.Name; 168 string assetName = asset.Name;
169 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) 169 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
170 { 170 {
171 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); 171 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
172 m_log.WarnFormat( 172 m_log.WarnFormat(
173 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", 173 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
174 asset.Name, asset.ID, asset.Name.Length, assetName.Length); 174 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
175 } 175 }
176 176
177 string assetDescription = asset.Description; 177 string assetDescription = asset.Description;
178 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) 178 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
179 { 179 {
180 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); 180 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
181 m_log.WarnFormat( 181 m_log.WarnFormat(
182 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", 182 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
183 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); 183 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
184 } 184 }
185 185
@@ -208,6 +208,7 @@ namespace OpenSim.Data.PGSQL
208 m_log.Error("[ASSET DB]: Error storing item :" + e.Message + " sql "+sql); 208 m_log.Error("[ASSET DB]: Error storing item :" + e.Message + " sql "+sql);
209 } 209 }
210 } 210 }
211 return true;
211 } 212 }
212 213
213 214
@@ -277,7 +278,7 @@ namespace OpenSim.Data.PGSQL
277 { 278 {
278 List<AssetMetadata> retList = new List<AssetMetadata>(count); 279 List<AssetMetadata> retList = new List<AssetMetadata>(count);
279 string sql = @" SELECT id, name, description, " + "\"assetType\"" + @", temporary, creatorid 280 string sql = @" SELECT id, name, description, " + "\"assetType\"" + @", temporary, creatorid
280 FROM assets 281 FROM assets
281 order by id 282 order by id
282 limit :stop 283 limit :stop
283 offset :start;"; 284 offset :start;";
diff --git a/OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs b/OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs
index d174112..8f83309 100644
--- a/OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs
@@ -145,7 +145,7 @@ namespace OpenSim.Data.PGSQL
145 updateBuilder.AppendFormat("\"{0}\" = :{0}",field); 145 updateBuilder.AppendFormat("\"{0}\" = :{0}",field);
146 146
147 first = false; 147 first = false;
148 148
149 cmd.Parameters.Add(m_database.CreateParameter("" + field, data.Data[field])); 149 cmd.Parameters.Add(m_database.CreateParameter("" + field, data.Data[field]));
150 } 150 }
151 151
@@ -154,7 +154,7 @@ namespace OpenSim.Data.PGSQL
154 cmd.CommandText = updateBuilder.ToString(); 154 cmd.CommandText = updateBuilder.ToString();
155 cmd.Connection = conn; 155 cmd.Connection = conn;
156 cmd.Parameters.Add(m_database.CreateParameter("principalID", data.PrincipalID)); 156 cmd.Parameters.Add(m_database.CreateParameter("principalID", data.PrincipalID));
157 157
158 conn.Open(); 158 conn.Open();
159 if (cmd.ExecuteNonQuery() < 1) 159 if (cmd.ExecuteNonQuery() < 1)
160 { 160 {
@@ -195,7 +195,7 @@ namespace OpenSim.Data.PGSQL
195 { 195 {
196 if (System.Environment.TickCount - m_LastExpire > 30000) 196 if (System.Environment.TickCount - m_LastExpire > 30000)
197 DoExpire(); 197 DoExpire();
198 198
199 string sql = "insert into tokens (uuid, token, validity) values (:principalID, :token, :lifetime)"; 199 string sql = "insert into tokens (uuid, token, validity) values (:principalID, :token, :lifetime)";
200 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) 200 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
201 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) 201 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
diff --git a/OpenSim/Data/PGSQL/PGSQLAvatarData.cs b/OpenSim/Data/PGSQL/PGSQLAvatarData.cs
index d9c4905..3d56d4d 100644
--- a/OpenSim/Data/PGSQL/PGSQLAvatarData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLAvatarData.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Data.PGSQL
45 IAvatarData 45 IAvatarData
46 { 46 {
47// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 public PGSQLAvatarData(string connectionString, string realm) : 49 public PGSQLAvatarData(string connectionString, string realm) :
50 base(connectionString, realm, "Avatar") 50 base(connectionString, realm, "Avatar")
51 { 51 {
diff --git a/OpenSim/Data/PGSQL/PGSQLEstateData.cs b/OpenSim/Data/PGSQL/PGSQLEstateData.cs
index b5ca235..9489d6c 100644
--- a/OpenSim/Data/PGSQL/PGSQLEstateData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLEstateData.cs
@@ -594,7 +594,7 @@ namespace OpenSim.Data.PGSQL
594 594
595 public bool DeleteEstate(int estateID) 595 public bool DeleteEstate(int estateID)
596 { 596 {
597 // TODO: Implementation! 597 // TODO: Implementation!
598 return false; 598 return false;
599 } 599 }
600 #endregion 600 #endregion
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/PGSQLFriendsData.cs b/OpenSim/Data/PGSQL/PGSQLFriendsData.cs
index a841353..58dffed 100644
--- a/OpenSim/Data/PGSQL/PGSQLFriendsData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLFriendsData.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Data.PGSQL
50 } 50 }
51 } 51 }
52 52
53 53
54 public override bool Delete(string principalID, string friend) 54 public override bool Delete(string principalID, string friend)
55 { 55 {
56 UUID princUUID = UUID.Zero; 56 UUID princUUID = UUID.Zero;
@@ -97,7 +97,7 @@ namespace OpenSim.Data.PGSQL
97 using (NpgsqlCommand cmd = new NpgsqlCommand()) 97 using (NpgsqlCommand cmd = new NpgsqlCommand())
98 { 98 {
99 99
100 cmd.CommandText = String.Format("select a.*,case when b.\"Flags\" is null then '-1' else b.\"Flags\" end as \"TheirFlags\" from {0} as a " + 100 cmd.CommandText = String.Format("select a.*,case when b.\"Flags\" is null then '-1' else b.\"Flags\" end as \"TheirFlags\" from {0} as a " +
101 " left join {0} as b on a.\"PrincipalID\" = b.\"Friend\" and a.\"Friend\" = b.\"PrincipalID\" " + 101 " left join {0} as b on a.\"PrincipalID\" = b.\"Friend\" and a.\"Friend\" = b.\"PrincipalID\" " +
102 " where a.\"PrincipalID\" = :PrincipalID", m_Realm); 102 " where a.\"PrincipalID\" = :PrincipalID", m_Realm);
103 cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString())); 103 cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString()));
@@ -111,6 +111,6 @@ namespace OpenSim.Data.PGSQL
111 { 111 {
112 return GetFriends(principalID); 112 return GetFriends(principalID);
113 } 113 }
114 114
115 } 115 }
116} 116}
diff --git a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
index 826c6fc..5b24720 100644
--- a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
+++ b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Data.PGSQL
64 : base(connectionString) 64 : base(connectionString)
65 { 65 {
66 m_Realm = realm; 66 m_Realm = realm;
67 67
68 m_ConnectionString = connectionString; 68 m_ConnectionString = connectionString;
69 69
70 if (storeName != String.Empty) 70 if (storeName != String.Empty)
@@ -104,7 +104,7 @@ namespace OpenSim.Data.PGSQL
104 m_FieldTypes = new Dictionary<string, string>(); 104 m_FieldTypes = new Dictionary<string, string>();
105 105
106 string query = string.Format(@"select column_name,data_type 106 string query = string.Format(@"select column_name,data_type
107 from INFORMATION_SCHEMA.COLUMNS 107 from INFORMATION_SCHEMA.COLUMNS
108 where table_name = lower('{0}'); 108 where table_name = lower('{0}');
109 109
110 ", m_Realm); 110 ", m_Realm);
@@ -145,27 +145,22 @@ namespace OpenSim.Data.PGSQL
145 private List<string> GetConstraints() 145 private List<string> GetConstraints()
146 { 146 {
147 List<string> constraints = new List<string>(); 147 List<string> constraints = new List<string>();
148 string query = string.Format(@"SELECT kcu.column_name 148 string query = string.Format(@"select
149 FROM information_schema.table_constraints tc 149 a.attname as column_name
150 LEFT JOIN information_schema.key_column_usage kcu 150 from
151 ON tc.constraint_catalog = kcu.constraint_catalog 151 pg_class t,
152 AND tc.constraint_schema = kcu.constraint_schema 152 pg_class i,
153 AND tc.constraint_name = kcu.constraint_name 153 pg_index ix,
154 154 pg_attribute a
155 LEFT JOIN information_schema.referential_constraints rc 155 where
156 ON tc.constraint_catalog = rc.constraint_catalog 156 t.oid = ix.indrelid
157 AND tc.constraint_schema = rc.constraint_schema 157 and i.oid = ix.indexrelid
158 AND tc.constraint_name = rc.constraint_name 158 and a.attrelid = t.oid
159 159 and a.attnum = ANY(ix.indkey)
160 LEFT JOIN information_schema.constraint_column_usage ccu 160 and t.relkind = 'r'
161 ON rc.unique_constraint_catalog = ccu.constraint_catalog 161 and ix.indisunique = true
162 AND rc.unique_constraint_schema = ccu.constraint_schema 162 and t.relname = lower('{0}')
163 AND rc.unique_constraint_name = ccu.constraint_name 163 ;", m_Realm);
164
165 where tc.table_name = lower('{0}')
166 and lower(tc.constraint_type) in ('primary key')
167 and kcu.column_name is not null
168 ;", m_Realm);
169 164
170 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) 165 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
171 using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn)) 166 using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn))
@@ -237,7 +232,7 @@ namespace OpenSim.Data.PGSQL
237 if (reader == null) 232 if (reader == null)
238 return new T[0]; 233 return new T[0];
239 234
240 CheckColumnNames(reader); 235 CheckColumnNames(reader);
241 236
242 while (reader.Read()) 237 while (reader.Read())
243 { 238 {
@@ -344,7 +339,7 @@ namespace OpenSim.Data.PGSQL
344 names.Add(fi.Name); 339 names.Add(fi.Name);
345 values.Add(":" + fi.Name); 340 values.Add(":" + fi.Name);
346 // Temporarily return more information about what field is unexpectedly null for 341 // Temporarily return more information about what field is unexpectedly null for
347 // http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the 342 // http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the
348 // InventoryTransferModule or we may be required to substitute a DBNull here. 343 // InventoryTransferModule or we may be required to substitute a DBNull here.
349 if (fi.GetValue(row) == null) 344 if (fi.GetValue(row) == null)
350 throw new NullReferenceException( 345 throw new NullReferenceException(
@@ -400,11 +395,11 @@ namespace OpenSim.Data.PGSQL
400 } 395 }
401 string where = String.Join(" AND ", terms.ToArray()); 396 string where = String.Join(" AND ", terms.ToArray());
402 query.AppendFormat(" WHERE {0} ", where); 397 query.AppendFormat(" WHERE {0} ", where);
403 398
404 } 399 }
405 cmd.Connection = conn; 400 cmd.Connection = conn;
406 cmd.CommandText = query.ToString(); 401 cmd.CommandText = query.ToString();
407 402
408 conn.Open(); 403 conn.Open();
409 if (cmd.ExecuteNonQuery() > 0) 404 if (cmd.ExecuteNonQuery() > 0)
410 { 405 {
@@ -421,7 +416,7 @@ namespace OpenSim.Data.PGSQL
421 query.Append("\") values (" + String.Join(",", values.ToArray()) + ")"); 416 query.Append("\") values (" + String.Join(",", values.ToArray()) + ")");
422 cmd.Connection = conn; 417 cmd.Connection = conn;
423 cmd.CommandText = query.ToString(); 418 cmd.CommandText = query.ToString();
424 419
425 // m_log.WarnFormat("[PGSQLGenericTable]: Inserting into {0} sql {1}", m_Realm, cmd.CommandText); 420 // m_log.WarnFormat("[PGSQLGenericTable]: Inserting into {0} sql {1}", m_Realm, cmd.CommandText);
426 421
427 if (conn.State != ConnectionState.Open) 422 if (conn.State != ConnectionState.Open)
diff --git a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs
index e257e7c..f398256 100644..100755
--- a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs
@@ -37,7 +37,7 @@ using Npgsql;
37namespace OpenSim.Data.PGSQL 37namespace OpenSim.Data.PGSQL
38{ 38{
39 public class PGSQLGroupsData : IGroupsData 39 public class PGSQLGroupsData : IGroupsData
40 { 40 {
41 private PGSqlGroupsGroupsHandler m_Groups; 41 private PGSqlGroupsGroupsHandler m_Groups;
42 private PGSqlGroupsMembershipHandler m_Membership; 42 private PGSqlGroupsMembershipHandler m_Membership;
43 private PGSqlGroupsRolesHandler m_Roles; 43 private PGSqlGroupsRolesHandler m_Roles;
@@ -83,17 +83,17 @@ namespace OpenSim.Data.PGSQL
83 83
84 public GroupData[] RetrieveGroups(string pattern) 84 public GroupData[] RetrieveGroups(string pattern)
85 { 85 {
86 86
87 if (string.IsNullOrEmpty(pattern)) // True for where clause 87 if (string.IsNullOrEmpty(pattern)) // True for where clause
88 { 88 {
89 pattern = " 1 ORDER BY lower(\"Name\") LIMIT 100"; 89 pattern = " 1 ORDER BY lower(\"Name\") LIMIT 100";
90 90
91 return m_Groups.Get(pattern); 91 return m_Groups.Get(pattern);
92 } 92 }
93 else 93 else
94 { 94 {
95 pattern = " \"ShowInList\" = 1 AND lower(\"Name\") LIKE lower('%" + pattern + "%') ORDER BY lower(\"Name\") LIMIT 100"; 95 pattern = " \"ShowInList\" = 1 AND lower(\"Name\") LIKE lower('%" + pattern + "%') ORDER BY lower(\"Name\") LIMIT 100";
96 96
97 return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern)); 97 return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern));
98 } 98 }
99 } 99 }
@@ -138,10 +138,10 @@ namespace OpenSim.Data.PGSQL
138 138
139 public bool DeleteMember(UUID groupID, string pricipalID) 139 public bool DeleteMember(UUID groupID, string pricipalID)
140 { 140 {
141 return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" }, 141 return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" },
142 new string[] { groupID.ToString(), pricipalID }); 142 new string[] { groupID.ToString(), pricipalID });
143 } 143 }
144 144
145 public int MemberCount(UUID groupID) 145 public int MemberCount(UUID groupID)
146 { 146 {
147 return (int)m_Membership.GetCount("GroupID", groupID.ToString()); 147 return (int)m_Membership.GetCount("GroupID", groupID.ToString());
@@ -173,7 +173,7 @@ namespace OpenSim.Data.PGSQL
173 173
174 public bool DeleteRole(UUID groupID, UUID roleID) 174 public bool DeleteRole(UUID groupID, UUID roleID)
175 { 175 {
176 return m_Roles.Delete(new string[] { "GroupID", "RoleID" }, 176 return m_Roles.Delete(new string[] { "GroupID", "RoleID" },
177 new string[] { groupID.ToString(), roleID.ToString() }); 177 new string[] { groupID.ToString(), roleID.ToString() });
178 } 178 }
179 179
@@ -365,7 +365,7 @@ namespace OpenSim.Data.PGSQL
365 get { return GetType().Assembly; } 365 get { return GetType().Assembly; }
366 } 366 }
367 367
368 public PGSqlGroupsGroupsHandler(string connectionString, string realm, string store) 368 public PGSqlGroupsGroupsHandler(string connectionString, string realm, string store)
369 : base(connectionString, realm, store) 369 : base(connectionString, realm, store)
370 { 370 {
371 } 371 }
@@ -380,7 +380,7 @@ namespace OpenSim.Data.PGSQL
380 get { return GetType().Assembly; } 380 get { return GetType().Assembly; }
381 } 381 }
382 382
383 public PGSqlGroupsMembershipHandler(string connectionString, string realm) 383 public PGSqlGroupsMembershipHandler(string connectionString, string realm)
384 : base(connectionString, realm, string.Empty) 384 : base(connectionString, realm, string.Empty)
385 { 385 {
386 } 386 }
@@ -395,7 +395,7 @@ namespace OpenSim.Data.PGSQL
395 get { return GetType().Assembly; } 395 get { return GetType().Assembly; }
396 } 396 }
397 397
398 public PGSqlGroupsRolesHandler(string connectionString, string realm) 398 public PGSqlGroupsRolesHandler(string connectionString, string realm)
399 : base(connectionString, realm, string.Empty) 399 : base(connectionString, realm, string.Empty)
400 { 400 {
401 } 401 }
@@ -410,7 +410,7 @@ namespace OpenSim.Data.PGSQL
410 get { return GetType().Assembly; } 410 get { return GetType().Assembly; }
411 } 411 }
412 412
413 public PGSqlGroupsRoleMembershipHandler(string connectionString, string realm) 413 public PGSqlGroupsRoleMembershipHandler(string connectionString, string realm)
414 : base(connectionString, realm, string.Empty) 414 : base(connectionString, realm, string.Empty)
415 { 415 {
416 } 416 }
@@ -425,7 +425,7 @@ namespace OpenSim.Data.PGSQL
425 get { return GetType().Assembly; } 425 get { return GetType().Assembly; }
426 } 426 }
427 427
428 public PGSqlGroupsInvitesHandler(string connectionString, string realm) 428 public PGSqlGroupsInvitesHandler(string connectionString, string realm)
429 : base(connectionString, realm, string.Empty) 429 : base(connectionString, realm, string.Empty)
430 { 430 {
431 } 431 }
@@ -435,8 +435,8 @@ 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 }
442 442
@@ -451,7 +451,7 @@ namespace OpenSim.Data.PGSQL
451 get { return GetType().Assembly; } 451 get { return GetType().Assembly; }
452 } 452 }
453 453
454 public PGSqlGroupsNoticesHandler(string connectionString, string realm) 454 public PGSqlGroupsNoticesHandler(string connectionString, string realm)
455 : base(connectionString, realm, string.Empty) 455 : base(connectionString, realm, string.Empty)
456 { 456 {
457 } 457 }
@@ -461,8 +461,8 @@ 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 }
468 468
@@ -477,7 +477,7 @@ namespace OpenSim.Data.PGSQL
477 get { return GetType().Assembly; } 477 get { return GetType().Assembly; }
478 } 478 }
479 479
480 public PGSqlGroupsPrincipalsHandler(string connectionString, string realm) 480 public PGSqlGroupsPrincipalsHandler(string connectionString, string realm)
481 : base(connectionString, realm, string.Empty) 481 : base(connectionString, realm, string.Empty)
482 { 482 {
483 } 483 }
diff --git a/OpenSim/Data/PGSQL/PGSQLInventoryData.cs b/OpenSim/Data/PGSQL/PGSQLInventoryData.cs
index c999433..30fc5ea 100644
--- a/OpenSim/Data/PGSQL/PGSQLInventoryData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLInventoryData.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Data.PGSQL
69 { 69 {
70 m_connectionString = connectionString; 70 m_connectionString = connectionString;
71 database = new PGSQLManager(connectionString); 71 database = new PGSQLManager(connectionString);
72 72
73 //New migrations check of store 73 //New migrations check of store
74 database.CheckMigration(_migrationStore); 74 database.CheckMigration(_migrationStore);
75 } 75 }
@@ -190,8 +190,8 @@ namespace OpenSim.Data.PGSQL
190 /* NOTE: the implementation below is very inefficient (makes a separate request to get subfolders for 190 /* NOTE: the implementation below is very inefficient (makes a separate request to get subfolders for
191 * every found folder, recursively). Inventory code for other DBs has been already rewritten to get ALL 191 * every found folder, recursively). Inventory code for other DBs has been already rewritten to get ALL
192 * inventory for a specific user at once. 192 * inventory for a specific user at once.
193 * 193 *
194 * Meanwhile, one little thing is corrected: getFolderHierarchy(UUID.Zero) doesn't make sense and should never 194 * Meanwhile, one little thing is corrected: getFolderHierarchy(UUID.Zero) doesn't make sense and should never
195 * be used, so check for that and return an empty list. 195 * be used, so check for that and return an empty list.
196 */ 196 */
197 197
@@ -264,11 +264,11 @@ namespace OpenSim.Data.PGSQL
264 /// <param name="folder">Folder to update</param> 264 /// <param name="folder">Folder to update</param>
265 public void updateInventoryFolder(InventoryFolderBase folder) 265 public void updateInventoryFolder(InventoryFolderBase folder)
266 { 266 {
267 string sql = @"UPDATE inventoryfolders SET ""agentID"" = :agentID, 267 string sql = @"UPDATE inventoryfolders SET ""agentID"" = :agentID,
268 ""parentFolderID"" = :parentFolderID, 268 ""parentFolderID"" = :parentFolderID,
269 ""folderName"" = :folderName, 269 ""folderName"" = :folderName,
270 type = :type, 270 type = :type,
271 version = :version 271 version = :version
272 WHERE folderID = :folderID"; 272 WHERE folderID = :folderID";
273 273
274 string folderName = folder.Name; 274 string folderName = folder.Name;
@@ -337,7 +337,7 @@ namespace OpenSim.Data.PGSQL
337 cmd.Parameters.Add(database.CreateParameter("parentID", UUID.Zero)); 337 cmd.Parameters.Add(database.CreateParameter("parentID", UUID.Zero));
338 conn.Open(); 338 conn.Open();
339 subFolders = getFolderHierarchy(folderID, cmd); 339 subFolders = getFolderHierarchy(folderID, cmd);
340 340
341 341
342 //Delete all sub-folders 342 //Delete all sub-folders
343 foreach (InventoryFolderBase f in subFolders) 343 foreach (InventoryFolderBase f in subFolders)
@@ -403,7 +403,7 @@ namespace OpenSim.Data.PGSQL
403 } 403 }
404 } 404 }
405 } 405 }
406 406
407 m_log.InfoFormat("[INVENTORY DB]: Found no inventory item with ID : {0}", itemID); 407 m_log.InfoFormat("[INVENTORY DB]: Found no inventory item with ID : {0}", itemID);
408 return null; 408 return null;
409 } 409 }
@@ -420,24 +420,24 @@ namespace OpenSim.Data.PGSQL
420 return; 420 return;
421 } 421 }
422 422
423 string sql = @"INSERT INTO inventoryitems 423 string sql = @"INSERT INTO inventoryitems
424 (""inventoryID"", ""assetID"", ""assetType"", ""parentFolderID"", ""avatarID"", ""inventoryName"", 424 (""inventoryID"", ""assetID"", ""assetType"", ""parentFolderID"", ""avatarID"", ""inventoryName"",
425 ""inventoryDescription"", ""inventoryNextPermissions"", ""inventoryCurrentPermissions"", 425 ""inventoryDescription"", ""inventoryNextPermissions"", ""inventoryCurrentPermissions"",
426 ""invType"", ""creatorID"", ""inventoryBasePermissions"", ""inventoryEveryOnePermissions"", ""inventoryGroupPermissions"", 426 ""invType"", ""creatorID"", ""inventoryBasePermissions"", ""inventoryEveryOnePermissions"", ""inventoryGroupPermissions"",
427 ""salePrice"", ""SaleType"", ""creationDate"", ""groupID"", ""groupOwned"", flags) 427 ""salePrice"", ""SaleType"", ""creationDate"", ""groupID"", ""groupOwned"", flags)
428 VALUES 428 VALUES
429 (:inventoryID, :assetID, :assetType, :parentFolderID, :avatarID, :inventoryName, :inventoryDescription, 429 (:inventoryID, :assetID, :assetType, :parentFolderID, :avatarID, :inventoryName, :inventoryDescription,
430 :inventoryNextPermissions, :inventoryCurrentPermissions, :invType, :creatorID, 430 :inventoryNextPermissions, :inventoryCurrentPermissions, :invType, :creatorID,
431 :inventoryBasePermissions, :inventoryEveryOnePermissions, :inventoryGroupPermissions, :SalePrice, :SaleType, 431 :inventoryBasePermissions, :inventoryEveryOnePermissions, :inventoryGroupPermissions, :SalePrice, :SaleType,
432 :creationDate, :groupID, :groupOwned, :flags)"; 432 :creationDate, :groupID, :groupOwned, :flags)";
433 433
434 string itemName = item.Name; 434 string itemName = item.Name;
435 if (item.Name.Length > 64) 435 if (item.Name.Length > 64)
436 { 436 {
437 itemName = item.Name.Substring(0, 64); 437 itemName = item.Name.Substring(0, 64);
438 m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters"); 438 m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters");
439 } 439 }
440 440
441 string itemDesc = item.Description; 441 string itemDesc = item.Description;
442 if (item.Description.Length > 128) 442 if (item.Description.Length > 128)
443 { 443 {
@@ -502,25 +502,25 @@ namespace OpenSim.Data.PGSQL
502 /// <param name="item">Inventory item to update</param> 502 /// <param name="item">Inventory item to update</param>
503 public void updateInventoryItem(InventoryItemBase item) 503 public void updateInventoryItem(InventoryItemBase item)
504 { 504 {
505 string sql = @"UPDATE inventoryitems SET ""assetID"" = :assetID, 505 string sql = @"UPDATE inventoryitems SET ""assetID"" = :assetID,
506 ""assetType"" = :assetType, 506 ""assetType"" = :assetType,
507 ""parentFolderID"" = :parentFolderID, 507 ""parentFolderID"" = :parentFolderID,
508 ""avatarID"" = :avatarID, 508 ""avatarID"" = :avatarID,
509 ""inventoryName"" = :inventoryName, 509 ""inventoryName"" = :inventoryName,
510 ""inventoryDescription"" = :inventoryDescription, 510 ""inventoryDescription"" = :inventoryDescription,
511 ""inventoryNextPermissions"" = :inventoryNextPermissions, 511 ""inventoryNextPermissions"" = :inventoryNextPermissions,
512 ""inventoryCurrentPermissions"" = :inventoryCurrentPermissions, 512 ""inventoryCurrentPermissions"" = :inventoryCurrentPermissions,
513 ""invType"" = :invType, 513 ""invType"" = :invType,
514 ""creatorID"" = :creatorID, 514 ""creatorID"" = :creatorID,
515 ""inventoryBasePermissions"" = :inventoryBasePermissions, 515 ""inventoryBasePermissions"" = :inventoryBasePermissions,
516 ""inventoryEveryOnePermissions"" = :inventoryEveryOnePermissions, 516 ""inventoryEveryOnePermissions"" = :inventoryEveryOnePermissions,
517 ""inventoryGroupPermissions"" = :inventoryGroupPermissions, 517 ""inventoryGroupPermissions"" = :inventoryGroupPermissions,
518 ""salePrice"" = :SalePrice, 518 ""salePrice"" = :SalePrice,
519 ""saleType"" = :SaleType, 519 ""saleType"" = :SaleType,
520 ""creationDate"" = :creationDate, 520 ""creationDate"" = :creationDate,
521 ""groupID"" = :groupID, 521 ""groupID"" = :groupID,
522 ""groupOwned"" = :groupOwned, 522 ""groupOwned"" = :groupOwned,
523 flags = :flags 523 flags = :flags
524 WHERE ""inventoryID"" = :inventoryID"; 524 WHERE ""inventoryID"" = :inventoryID";
525 525
526 string itemName = item.Name; 526 string itemName = item.Name;
@@ -529,7 +529,7 @@ namespace OpenSim.Data.PGSQL
529 itemName = item.Name.Substring(0, 64); 529 itemName = item.Name.Substring(0, 64);
530 m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters on update"); 530 m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters on update");
531 } 531 }
532 532
533 string itemDesc = item.Description; 533 string itemDesc = item.Description;
534 if (item.Description.Length > 128) 534 if (item.Description.Length > 128)
535 { 535 {
diff --git a/OpenSim/Data/PGSQL/PGSQLManager.cs b/OpenSim/Data/PGSQL/PGSQLManager.cs
index 46f835a..276a37c 100644
--- a/OpenSim/Data/PGSQL/PGSQLManager.cs
+++ b/OpenSim/Data/PGSQL/PGSQLManager.cs
@@ -251,7 +251,7 @@ namespace OpenSim.Data.PGSQL
251 } 251 }
252 if (PGFieldType == "double precision") 252 if (PGFieldType == "double precision")
253 { 253 {
254 return (Double)value; 254 return Convert.ToDouble(value);
255 } 255 }
256 return CreateParameterValue(value); 256 return CreateParameterValue(value);
257 } 257 }
@@ -326,7 +326,7 @@ namespace OpenSim.Data.PGSQL
326 /// <param name="migrationStore">migrationStore.</param> 326 /// <param name="migrationStore">migrationStore.</param>
327 public void CheckMigration(string migrationStore) 327 public void CheckMigration(string migrationStore)
328 { 328 {
329 using (NpgsqlConnection connection = new NpgsqlConnection(connectionString)) 329 using (NpgsqlConnection connection = new NpgsqlConnection(connectionString))
330 { 330 {
331 connection.Open(); 331 connection.Open();
332 Assembly assem = GetType().Assembly; 332 Assembly assem = GetType().Assembly;
diff --git a/OpenSim/Data/PGSQL/PGSQLMigration.cs b/OpenSim/Data/PGSQL/PGSQLMigration.cs
index 709fde0..749a3f2 100644
--- a/OpenSim/Data/PGSQL/PGSQLMigration.cs
+++ b/OpenSim/Data/PGSQL/PGSQLMigration.cs
@@ -54,8 +54,8 @@ namespace OpenSim.Data.PGSQL
54 { 54 {
55 try 55 try
56 { 56 {
57 cmd.CommandText = "select version from migrations where name = '" + type + "' " + 57 cmd.CommandText = "select version from migrations where name = '" + type + "' " +
58 " order by version desc limit 1"; //Must be 58 " order by version desc limit 1"; //Must be
59 using (NpgsqlDataReader reader = cmd.ExecuteReader()) 59 using (NpgsqlDataReader reader = cmd.ExecuteReader())
60 { 60 {
61 if (reader.Read()) 61 if (reader.Read())
diff --git a/OpenSim/Data/PGSQL/PGSQLOfflineIMData.cs b/OpenSim/Data/PGSQL/PGSQLOfflineIMData.cs
index 82e5ed8..a0c3542 100644
--- a/OpenSim/Data/PGSQL/PGSQLOfflineIMData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLOfflineIMData.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Data.PGSQL
47 using (NpgsqlCommand cmd = new NpgsqlCommand()) 47 using (NpgsqlCommand cmd = new NpgsqlCommand())
48 { 48 {
49 cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); 49 cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm);
50 50
51 ExecuteNonQuery(cmd); 51 ExecuteNonQuery(cmd);
52 } 52 }
53 53
diff --git a/OpenSim/Data/PGSQL/PGSQLPresenceData.cs b/OpenSim/Data/PGSQL/PGSQLPresenceData.cs
index 0376585..ebbe8d3 100644..100755
--- a/OpenSim/Data/PGSQL/PGSQLPresenceData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLPresenceData.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Data.PGSQL
80 PresenceData[] pd = Get("SessionID", sessionID.ToString()); 80 PresenceData[] pd = Get("SessionID", sessionID.ToString());
81 if (pd.Length == 0) 81 if (pd.Length == 0)
82 return false; 82 return false;
83 83
84 if (regionID == UUID.Zero) 84 if (regionID == UUID.Zero)
85 return false; 85 return false;
86 86
@@ -103,7 +103,7 @@ namespace OpenSim.Data.PGSQL
103 public bool VerifyAgent(UUID agentId, UUID secureSessionID) 103 public bool VerifyAgent(UUID agentId, UUID secureSessionID)
104 { 104 {
105 PresenceData[] ret = Get("SecureSessionID", secureSessionID.ToString()); 105 PresenceData[] ret = Get("SecureSessionID", secureSessionID.ToString());
106 106
107 if (ret.Length == 0) 107 if (ret.Length == 0)
108 return false; 108 return false;
109 109
diff --git a/OpenSim/Data/PGSQL/PGSQLRegionData.cs b/OpenSim/Data/PGSQL/PGSQLRegionData.cs
index b3076f0..1272e37 100644
--- a/OpenSim/Data/PGSQL/PGSQLRegionData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLRegionData.cs
@@ -26,16 +26,14 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Data; 31using System.Data;
31using System.Drawing;
32using System.IO;
33using System.Reflection; 32using System.Reflection;
34using log4net; 33using log4net;
35using OpenMetaverse; 34using OpenMetaverse;
36using OpenSim.Framework; 35using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Data;
38using OpenSim.Region.Framework.Scenes;
39using RegionFlags = OpenSim.Framework.RegionFlags; 37using RegionFlags = OpenSim.Framework.RegionFlags;
40using Npgsql; 38using Npgsql;
41 39
@@ -59,7 +57,7 @@ namespace OpenSim.Data.PGSQL
59 get { return GetType().Assembly; } 57 get { return GetType().Assembly; }
60 } 58 }
61 59
62 public PGSQLRegionData(string connectionString, string realm) 60 public PGSQLRegionData(string connectionString, string realm)
63 { 61 {
64 m_Realm = realm; 62 m_Realm = realm;
65 m_ConnectionString = connectionString; 63 m_ConnectionString = connectionString;
@@ -79,7 +77,7 @@ namespace OpenSim.Data.PGSQL
79 m_FieldTypes = new Dictionary<string, string>(); 77 m_FieldTypes = new Dictionary<string, string>();
80 78
81 string query = string.Format(@"select column_name,data_type 79 string query = string.Format(@"select column_name,data_type
82 from INFORMATION_SCHEMA.COLUMNS 80 from INFORMATION_SCHEMA.COLUMNS
83 where table_name = lower('{0}'); 81 where table_name = lower('{0}');
84 82
85 ", m_Realm); 83 ", m_Realm);
@@ -109,7 +107,7 @@ namespace OpenSim.Data.PGSQL
109 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) 107 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
110 { 108 {
111 cmd.Parameters.Add(m_database.CreateParameter("regionName", regionName)); 109 cmd.Parameters.Add(m_database.CreateParameter("regionName", regionName));
112 if (scopeID != UUID.Zero) 110 if (scopeID != UUID.Zero)
113 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); 111 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
114 conn.Open(); 112 conn.Open();
115 return RunCommand(cmd); 113 return RunCommand(cmd);
@@ -118,24 +116,46 @@ namespace OpenSim.Data.PGSQL
118 116
119 public RegionData Get(int posX, int posY, UUID scopeID) 117 public RegionData Get(int posX, int posY, UUID scopeID)
120 { 118 {
121 string sql = "select * from "+m_Realm+" where \"locX\" = :posX and \"locY\" = :posY"; 119 // extend database search for maximum region size area
120 string sql = "select * from "+m_Realm+" where \"locX\" between :startX and :endX and \"locY\" between :startY and :endY";
122 if (scopeID != UUID.Zero) 121 if (scopeID != UUID.Zero)
123 sql += " and \"ScopeID\" = :scopeID"; 122 sql += " and \"ScopeID\" = :scopeID";
124 123
124 int startX = posX - (int)Constants.MaximumRegionSize;
125 int startY = posY - (int)Constants.MaximumRegionSize;
126 int endX = posX;
127 int endY = posY;
128
129 List<RegionData> ret;
125 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) 130 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
126 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) 131 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
127 { 132 {
128 cmd.Parameters.Add(m_database.CreateParameter("posX", posX)); 133 cmd.Parameters.Add(m_database.CreateParameter("startX", startX));
129 cmd.Parameters.Add(m_database.CreateParameter("posY", posY)); 134 cmd.Parameters.Add(m_database.CreateParameter("startY", startY));
130 if (scopeID != UUID.Zero) 135 cmd.Parameters.Add(m_database.CreateParameter("endX", endX));
136 cmd.Parameters.Add(m_database.CreateParameter("endY", endY));
137 if (scopeID != UUID.Zero)
131 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); 138 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
132 conn.Open(); 139 conn.Open();
133 List<RegionData> ret = RunCommand(cmd); 140 ret = RunCommand(cmd);
134 if (ret.Count == 0) 141 }
135 return null;
136 142
137 return ret[0]; 143 if (ret.Count == 0)
144 return null;
145
146 // Find the first that contains pos
147 RegionData rg = null;
148 foreach (RegionData r in ret)
149 {
150 if (posX >= r.posX && posX < r.posX + r.sizeX
151 && posY >= r.posY && posY < r.posY + r.sizeY)
152 {
153 rg = r;
154 break;
155 }
138 } 156 }
157
158 return rg;
139 } 159 }
140 160
141 public RegionData Get(UUID regionID, UUID scopeID) 161 public RegionData Get(UUID regionID, UUID scopeID)
@@ -147,7 +167,7 @@ namespace OpenSim.Data.PGSQL
147 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) 167 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
148 { 168 {
149 cmd.Parameters.Add(m_database.CreateParameter("regionID", regionID)); 169 cmd.Parameters.Add(m_database.CreateParameter("regionID", regionID));
150 if (scopeID != UUID.Zero) 170 if (scopeID != UUID.Zero)
151 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); 171 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
152 conn.Open(); 172 conn.Open();
153 List<RegionData> ret = RunCommand(cmd); 173 List<RegionData> ret = RunCommand(cmd);
@@ -160,21 +180,41 @@ namespace OpenSim.Data.PGSQL
160 180
161 public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) 181 public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
162 { 182 {
183 // extend database search for maximum region size area
163 string sql = "select * from "+m_Realm+" where \"locX\" between :startX and :endX and \"locY\" between :startY and :endY"; 184 string sql = "select * from "+m_Realm+" where \"locX\" between :startX and :endX and \"locY\" between :startY and :endY";
164 if (scopeID != UUID.Zero) 185 if (scopeID != UUID.Zero)
165 sql += " and \"ScopeID\" = :scopeID"; 186 sql += " and \"ScopeID\" = :scopeID";
166 187
188 int qstartX = startX - (int)Constants.MaximumRegionSize;
189 int qstartY = startY - (int)Constants.MaximumRegionSize;
190
191 List<RegionData> dbret;
167 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) 192 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
168 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) 193 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
169 { 194 {
170 cmd.Parameters.Add(m_database.CreateParameter("startX", startX)); 195 cmd.Parameters.Add(m_database.CreateParameter("startX", qstartX));
171 cmd.Parameters.Add(m_database.CreateParameter("startY", startY)); 196 cmd.Parameters.Add(m_database.CreateParameter("startY", qstartY));
172 cmd.Parameters.Add(m_database.CreateParameter("endX", endX)); 197 cmd.Parameters.Add(m_database.CreateParameter("endX", endX));
173 cmd.Parameters.Add(m_database.CreateParameter("endY", endY)); 198 cmd.Parameters.Add(m_database.CreateParameter("endY", endY));
174 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); 199 if (scopeID != UUID.Zero)
200 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
175 conn.Open(); 201 conn.Open();
176 return RunCommand(cmd); 202
203 dbret = RunCommand(cmd);
177 } 204 }
205
206 List<RegionData> ret = new List<RegionData>();
207
208 if(dbret.Count == 0)
209 return ret;
210
211 foreach (RegionData r in dbret)
212 {
213 if (r.posX + r.sizeX > startX && r.posX <= endX
214 && r.posY + r.sizeY > startY && r.posY <= endY)
215 ret.Add(r);
216 }
217 return ret;
178 } 218 }
179 219
180 public List<RegionData> RunCommand(NpgsqlCommand cmd) 220 public List<RegionData> RunCommand(NpgsqlCommand cmd)
@@ -258,7 +298,7 @@ namespace OpenSim.Data.PGSQL
258 { 298 {
259 299
260 string update = "update " + m_Realm + " set \"locX\"=:posX, \"locY\"=:posY, \"sizeX\"=:sizeX, \"sizeY\"=:sizeY "; 300 string update = "update " + m_Realm + " set \"locX\"=:posX, \"locY\"=:posY, \"sizeX\"=:sizeX, \"sizeY\"=:sizeY ";
261 301
262 foreach (string field in fields) 302 foreach (string field in fields)
263 { 303 {
264 304
diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
index 77d87d4..f4af40b 100644..100755
--- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
@@ -31,11 +31,13 @@ using System.Data;
31using System.Drawing; 31using System.Drawing;
32using System.IO; 32using System.IO;
33using System.Reflection; 33using System.Reflection;
34using System.Threading;
34using log4net; 35using log4net;
35using OpenMetaverse; 36using OpenMetaverse;
36using OpenSim.Framework; 37using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Data;
39using Npgsql; 41using Npgsql;
40 42
41namespace OpenSim.Data.PGSQL 43namespace OpenSim.Data.PGSQL
@@ -108,11 +110,11 @@ namespace OpenSim.Data.PGSQL
108 Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); 110 Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>();
109 SceneObjectGroup grp = null; 111 SceneObjectGroup grp = null;
110 112
111 string sql = @"SELECT *, 113 string sql = @"SELECT *,
112 CASE WHEN prims.""UUID"" = prims.""SceneGroupID"" THEN 0 ELSE 1 END as sort 114 CASE WHEN prims.""UUID"" = prims.""SceneGroupID"" THEN 0 ELSE 1 END as sort
113 FROM prims 115 FROM prims
114 LEFT JOIN primshapes ON prims.""UUID"" = primshapes.""UUID"" 116 LEFT JOIN primshapes ON prims.""UUID"" = primshapes.""UUID""
115 WHERE ""RegionUUID"" = :RegionUUID 117 WHERE ""RegionUUID"" = :RegionUUID
116 ORDER BY ""SceneGroupID"" asc, sort asc, ""LinkNumber"" asc"; 118 ORDER BY ""SceneGroupID"" asc, sort asc, ""LinkNumber"" asc";
117 119
118 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) 120 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
@@ -144,7 +146,7 @@ namespace OpenSim.Data.PGSQL
144 // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are 146 // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are
145 // recorded as the root prim (for which the UUID must equal the persisted group UUID). In 147 // recorded as the root prim (for which the UUID must equal the persisted group UUID). In
146 // this case, force the UUID to be the same as the group UUID so that at least these can be 148 // this case, force the UUID to be the same as the group UUID so that at least these can be
147 // deleted (we need to change the UUID so that any other prims in the linkset can also be 149 // deleted (we need to change the UUID so that any other prims in the linkset can also be
148 // deleted). 150 // deleted).
149 if (sceneObjectPart.UUID != groupID && groupID != UUID.Zero) 151 if (sceneObjectPart.UUID != groupID && groupID != UUID.Zero)
150 { 152 {
@@ -176,7 +178,7 @@ namespace OpenSim.Data.PGSQL
176 objects[grp.UUID] = grp; 178 objects[grp.UUID] = grp;
177 179
178 // Instead of attempting to LoadItems on every prim, 180 // Instead of attempting to LoadItems on every prim,
179 // most of which probably have no items... get a 181 // most of which probably have no items... get a
180 // list from DB of all prims which have items and 182 // list from DB of all prims which have items and
181 // LoadItems only on those 183 // LoadItems only on those
182 List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); 184 List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>();
@@ -329,54 +331,55 @@ namespace OpenSim.Data.PGSQL
329 private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) 331 private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID)
330 { 332 {
331 //Big query to update or insert a new prim. 333 //Big query to update or insert a new prim.
332 334
333 string queryPrims = @" 335 string queryPrims = @"
334 UPDATE prims SET 336 UPDATE prims SET
335 ""CreationDate"" = :CreationDate, ""Name"" = :Name, ""Text"" = :Text, ""Description"" = :Description, ""SitName"" = :SitName, 337 ""CreationDate"" = :CreationDate, ""Name"" = :Name, ""Text"" = :Text, ""Description"" = :Description, ""SitName"" = :SitName,
336 ""TouchName"" = :TouchName, ""ObjectFlags"" = :ObjectFlags, ""OwnerMask"" = :OwnerMask, ""NextOwnerMask"" = :NextOwnerMask, ""GroupMask"" = :GroupMask, 338 ""TouchName"" = :TouchName, ""ObjectFlags"" = :ObjectFlags, ""OwnerMask"" = :OwnerMask, ""NextOwnerMask"" = :NextOwnerMask, ""GroupMask"" = :GroupMask,
337 ""EveryoneMask"" = :EveryoneMask, ""BaseMask"" = :BaseMask, ""PositionX"" = :PositionX, ""PositionY"" = :PositionY, ""PositionZ"" = :PositionZ, 339 ""EveryoneMask"" = :EveryoneMask, ""BaseMask"" = :BaseMask, ""PositionX"" = :PositionX, ""PositionY"" = :PositionY, ""PositionZ"" = :PositionZ,
338 ""GroupPositionX"" = :GroupPositionX, ""GroupPositionY"" = :GroupPositionY, ""GroupPositionZ"" = :GroupPositionZ, ""VelocityX"" = :VelocityX, 340 ""GroupPositionX"" = :GroupPositionX, ""GroupPositionY"" = :GroupPositionY, ""GroupPositionZ"" = :GroupPositionZ, ""VelocityX"" = :VelocityX,
339 ""VelocityY"" = :VelocityY, ""VelocityZ"" = :VelocityZ, ""AngularVelocityX"" = :AngularVelocityX, ""AngularVelocityY"" = :AngularVelocityY, 341 ""VelocityY"" = :VelocityY, ""VelocityZ"" = :VelocityZ, ""AngularVelocityX"" = :AngularVelocityX, ""AngularVelocityY"" = :AngularVelocityY,
340 ""AngularVelocityZ"" = :AngularVelocityZ, ""AccelerationX"" = :AccelerationX, ""AccelerationY"" = :AccelerationY, 342 ""AngularVelocityZ"" = :AngularVelocityZ, ""AccelerationX"" = :AccelerationX, ""AccelerationY"" = :AccelerationY,
341 ""AccelerationZ"" = :AccelerationZ, ""RotationX"" = :RotationX, ""RotationY"" = :RotationY, ""RotationZ"" = :RotationZ, ""RotationW"" = :RotationW, 343 ""AccelerationZ"" = :AccelerationZ, ""RotationX"" = :RotationX, ""RotationY"" = :RotationY, ""RotationZ"" = :RotationZ, ""RotationW"" = :RotationW,
342 ""SitTargetOffsetX"" = :SitTargetOffsetX, ""SitTargetOffsetY"" = :SitTargetOffsetY, ""SitTargetOffsetZ"" = :SitTargetOffsetZ, 344 ""SitTargetOffsetX"" = :SitTargetOffsetX, ""SitTargetOffsetY"" = :SitTargetOffsetY, ""SitTargetOffsetZ"" = :SitTargetOffsetZ,
343 ""SitTargetOrientW"" = :SitTargetOrientW, ""SitTargetOrientX"" = :SitTargetOrientX, ""SitTargetOrientY"" = :SitTargetOrientY, 345 ""SitTargetOrientW"" = :SitTargetOrientW, ""SitTargetOrientX"" = :SitTargetOrientX, ""SitTargetOrientY"" = :SitTargetOrientY,
344 ""SitTargetOrientZ"" = :SitTargetOrientZ, ""RegionUUID"" = :RegionUUID, ""CreatorID"" = :CreatorID, ""OwnerID"" = :OwnerID, ""GroupID"" = :GroupID, 346 ""SitTargetOrientZ"" = :SitTargetOrientZ, ""RegionUUID"" = :RegionUUID, ""CreatorID"" = :CreatorID, ""OwnerID"" = :OwnerID, ""GroupID"" = :GroupID,
345 ""LastOwnerID"" = :LastOwnerID, ""SceneGroupID"" = :SceneGroupID, ""PayPrice"" = :PayPrice, ""PayButton1"" = :PayButton1, ""PayButton2"" = :PayButton2, 347 ""LastOwnerID"" = :LastOwnerID, ""SceneGroupID"" = :SceneGroupID, ""PayPrice"" = :PayPrice, ""PayButton1"" = :PayButton1, ""PayButton2"" = :PayButton2,
346 ""PayButton3"" = :PayButton3, ""PayButton4"" = :PayButton4, ""LoopedSound"" = :LoopedSound, ""LoopedSoundGain"" = :LoopedSoundGain, 348 ""PayButton3"" = :PayButton3, ""PayButton4"" = :PayButton4, ""LoopedSound"" = :LoopedSound, ""LoopedSoundGain"" = :LoopedSoundGain,
347 ""TextureAnimation"" = :TextureAnimation, ""OmegaX"" = :OmegaX, ""OmegaY"" = :OmegaY, ""OmegaZ"" = :OmegaZ, ""CameraEyeOffsetX"" = :CameraEyeOffsetX, 349 ""TextureAnimation"" = :TextureAnimation, ""OmegaX"" = :OmegaX, ""OmegaY"" = :OmegaY, ""OmegaZ"" = :OmegaZ, ""CameraEyeOffsetX"" = :CameraEyeOffsetX,
348 ""CameraEyeOffsetY"" = :CameraEyeOffsetY, ""CameraEyeOffsetZ"" = :CameraEyeOffsetZ, ""CameraAtOffsetX"" = :CameraAtOffsetX, 350 ""CameraEyeOffsetY"" = :CameraEyeOffsetY, ""CameraEyeOffsetZ"" = :CameraEyeOffsetZ, ""CameraAtOffsetX"" = :CameraAtOffsetX,
349 ""CameraAtOffsetY"" = :CameraAtOffsetY, ""CameraAtOffsetZ"" = :CameraAtOffsetZ, ""ForceMouselook"" = :ForceMouselook, 351 ""CameraAtOffsetY"" = :CameraAtOffsetY, ""CameraAtOffsetZ"" = :CameraAtOffsetZ, ""ForceMouselook"" = :ForceMouselook,
350 ""ScriptAccessPin"" = :ScriptAccessPin, ""AllowedDrop"" = :AllowedDrop, ""DieAtEdge"" = :DieAtEdge, ""SalePrice"" = :SalePrice, 352 ""ScriptAccessPin"" = :ScriptAccessPin, ""AllowedDrop"" = :AllowedDrop, ""DieAtEdge"" = :DieAtEdge, ""SalePrice"" = :SalePrice,
351 ""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,
352 ""ClickAction"" = :ClickAction, ""Material"" = :Material, ""CollisionSound"" = :CollisionSound, ""CollisionSoundVolume"" = :CollisionSoundVolume, ""PassTouches"" = :PassTouches, 355 ""ClickAction"" = :ClickAction, ""Material"" = :Material, ""CollisionSound"" = :CollisionSound, ""CollisionSoundVolume"" = :CollisionSoundVolume, ""PassTouches"" = :PassTouches,
353 ""LinkNumber"" = :LinkNumber, ""MediaURL"" = :MediaURL, ""DynAttrs"" = :DynAttrs, 356 ""LinkNumber"" = :LinkNumber, ""MediaURL"" = :MediaURL, ""DynAttrs"" = :DynAttrs,
354 ""PhysicsShapeType"" = :PhysicsShapeType, ""Density"" = :Density, ""GravityModifier"" = :GravityModifier, ""Friction"" = :Friction, ""Restitution"" = :Restitution 357 ""PhysInertia"" = :PhysInertia
355 WHERE ""UUID"" = :UUID ; 358 WHERE ""UUID"" = :UUID ;
356 359
357 INSERT INTO 360 INSERT INTO
358 prims ( 361 prims (
359 ""UUID"", ""CreationDate"", ""Name"", ""Text"", ""Description"", ""SitName"", ""TouchName"", ""ObjectFlags"", ""OwnerMask"", ""NextOwnerMask"", ""GroupMask"", 362 ""UUID"", ""CreationDate"", ""Name"", ""Text"", ""Description"", ""SitName"", ""TouchName"", ""ObjectFlags"", ""OwnerMask"", ""NextOwnerMask"", ""GroupMask"",
360 ""EveryoneMask"", ""BaseMask"", ""PositionX"", ""PositionY"", ""PositionZ"", ""GroupPositionX"", ""GroupPositionY"", ""GroupPositionZ"", ""VelocityX"", 363 ""EveryoneMask"", ""BaseMask"", ""PositionX"", ""PositionY"", ""PositionZ"", ""GroupPositionX"", ""GroupPositionY"", ""GroupPositionZ"", ""VelocityX"",
361 ""VelocityY"", ""VelocityZ"", ""AngularVelocityX"", ""AngularVelocityY"", ""AngularVelocityZ"", ""AccelerationX"", ""AccelerationY"", ""AccelerationZ"", 364 ""VelocityY"", ""VelocityZ"", ""AngularVelocityX"", ""AngularVelocityY"", ""AngularVelocityZ"", ""AccelerationX"", ""AccelerationY"", ""AccelerationZ"",
362 ""RotationX"", ""RotationY"", ""RotationZ"", ""RotationW"", ""SitTargetOffsetX"", ""SitTargetOffsetY"", ""SitTargetOffsetZ"", ""SitTargetOrientW"", 365 ""RotationX"", ""RotationY"", ""RotationZ"", ""RotationW"", ""SitTargetOffsetX"", ""SitTargetOffsetY"", ""SitTargetOffsetZ"", ""SitTargetOrientW"",
363 ""SitTargetOrientX"", ""SitTargetOrientY"", ""SitTargetOrientZ"", ""RegionUUID"", ""CreatorID"", ""OwnerID"", ""GroupID"", ""LastOwnerID"", ""SceneGroupID"", 366 ""SitTargetOrientX"", ""SitTargetOrientY"", ""SitTargetOrientZ"", ""RegionUUID"", ""CreatorID"", ""OwnerID"", ""GroupID"", ""LastOwnerID"", ""SceneGroupID"",
364 ""PayPrice"", ""PayButton1"", ""PayButton2"", ""PayButton3"", ""PayButton4"", ""LoopedSound"", ""LoopedSoundGain"", ""TextureAnimation"", ""OmegaX"", 367 ""PayPrice"", ""PayButton1"", ""PayButton2"", ""PayButton3"", ""PayButton4"", ""LoopedSound"", ""LoopedSoundGain"", ""TextureAnimation"", ""OmegaX"",
365 ""OmegaY"", ""OmegaZ"", ""CameraEyeOffsetX"", ""CameraEyeOffsetY"", ""CameraEyeOffsetZ"", ""CameraAtOffsetX"", ""CameraAtOffsetY"", ""CameraAtOffsetZ"", 368 ""OmegaY"", ""OmegaZ"", ""CameraEyeOffsetX"", ""CameraEyeOffsetY"", ""CameraEyeOffsetZ"", ""CameraAtOffsetX"", ""CameraAtOffsetY"", ""CameraAtOffsetZ"",
366 ""ForceMouselook"", ""ScriptAccessPin"", ""AllowedDrop"", ""DieAtEdge"", ""SalePrice"", ""SaleType"", ""ColorR"", ""ColorG"", ""ColorB"", ""ColorA"", 369 ""ForceMouselook"", ""ScriptAccessPin"", ""AllowedDrop"", ""DieAtEdge"", ""SalePrice"", ""SaleType"", ""ColorR"", ""ColorG"", ""ColorB"", ""ColorA"",
367 ""ParticleSystem"", ""ClickAction"", ""Material"", ""CollisionSound"", ""CollisionSoundVolume"", ""PassTouches"", ""LinkNumber"", ""MediaURL"", ""DynAttrs"", 370 ""ParticleSystem"", ""ClickAction"", ""Material"", ""CollisionSound"", ""CollisionSoundVolume"", ""PassTouches"", ""LinkNumber"", ""MediaURL"", ""DynAttrs"",
368 ""PhysicsShapeType"", ""Density"", ""GravityModifier"", ""Friction"", ""Restitution"" 371 ""PhysicsShapeType"", ""Density"", ""GravityModifier"", ""Friction"", ""Restitution"", ""PassCollisions"", ""RotationAxisLocks"", ""RezzerID"" , ""PhysInertia""
369 ) Select 372 ) Select
370 :UUID, :CreationDate, :Name, :Text, :Description, :SitName, :TouchName, :ObjectFlags, :OwnerMask, :NextOwnerMask, :GroupMask, 373 :UUID, :CreationDate, :Name, :Text, :Description, :SitName, :TouchName, :ObjectFlags, :OwnerMask, :NextOwnerMask, :GroupMask,
371 :EveryoneMask, :BaseMask, :PositionX, :PositionY, :PositionZ, :GroupPositionX, :GroupPositionY, :GroupPositionZ, :VelocityX, 374 :EveryoneMask, :BaseMask, :PositionX, :PositionY, :PositionZ, :GroupPositionX, :GroupPositionY, :GroupPositionZ, :VelocityX,
372 :VelocityY, :VelocityZ, :AngularVelocityX, :AngularVelocityY, :AngularVelocityZ, :AccelerationX, :AccelerationY, :AccelerationZ, 375 :VelocityY, :VelocityZ, :AngularVelocityX, :AngularVelocityY, :AngularVelocityZ, :AccelerationX, :AccelerationY, :AccelerationZ,
373 :RotationX, :RotationY, :RotationZ, :RotationW, :SitTargetOffsetX, :SitTargetOffsetY, :SitTargetOffsetZ, :SitTargetOrientW, 376 :RotationX, :RotationY, :RotationZ, :RotationW, :SitTargetOffsetX, :SitTargetOffsetY, :SitTargetOffsetZ, :SitTargetOrientW,
374 :SitTargetOrientX, :SitTargetOrientY, :SitTargetOrientZ, :RegionUUID, :CreatorID, :OwnerID, :GroupID, :LastOwnerID, :SceneGroupID, 377 :SitTargetOrientX, :SitTargetOrientY, :SitTargetOrientZ, :RegionUUID, :CreatorID, :OwnerID, :GroupID, :LastOwnerID, :SceneGroupID,
375 :PayPrice, :PayButton1, :PayButton2, :PayButton3, :PayButton4, :LoopedSound, :LoopedSoundGain, :TextureAnimation, :OmegaX, 378 :PayPrice, :PayButton1, :PayButton2, :PayButton3, :PayButton4, :LoopedSound, :LoopedSoundGain, :TextureAnimation, :OmegaX,
376 :OmegaY, :OmegaZ, :CameraEyeOffsetX, :CameraEyeOffsetY, :CameraEyeOffsetZ, :CameraAtOffsetX, :CameraAtOffsetY, :CameraAtOffsetZ, 379 :OmegaY, :OmegaZ, :CameraEyeOffsetX, :CameraEyeOffsetY, :CameraEyeOffsetZ, :CameraAtOffsetX, :CameraAtOffsetY, :CameraAtOffsetZ,
377 :ForceMouselook, :ScriptAccessPin, :AllowedDrop, :DieAtEdge, :SalePrice, :SaleType, :ColorR, :ColorG, :ColorB, :ColorA, 380 :ForceMouselook, :ScriptAccessPin, :AllowedDrop, :DieAtEdge, :SalePrice, :SaleType, :ColorR, :ColorG, :ColorB, :ColorA,
378 :ParticleSystem, :ClickAction, :Material, :CollisionSound, :CollisionSoundVolume, :PassTouches, :LinkNumber, :MediaURL, :DynAttrs, 381 :ParticleSystem, :ClickAction, :Material, :CollisionSound, :CollisionSoundVolume, :PassTouches, :LinkNumber, :MediaURL, :DynAttrs,
379 :PhysicsShapeType, :Density, :GravityModifier, :Friction, :Restitution 382 :PhysicsShapeType, :Density, :GravityModifier, :Friction, :Restitution, :PassCollisions, :RotationAxisLocks, :RezzerID, :PhysInertia
380 where not EXISTS (SELECT ""UUID"" FROM prims WHERE ""UUID"" = :UUID); 383 where not EXISTS (SELECT ""UUID"" FROM prims WHERE ""UUID"" = :UUID);
381 "; 384 ";
382 385
@@ -399,26 +402,26 @@ namespace OpenSim.Data.PGSQL
399 private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) 402 private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID)
400 { 403 {
401 //Big query to or insert or update primshapes 404 //Big query to or insert or update primshapes
402 405
403 string queryPrimShapes = @" 406 string queryPrimShapes = @"
404 UPDATE primshapes SET 407 UPDATE primshapes SET
405 ""Shape"" = :Shape, ""ScaleX"" = :ScaleX, ""ScaleY"" = :ScaleY, ""ScaleZ"" = :ScaleZ, ""PCode"" = :PCode, ""PathBegin"" = :PathBegin, 408 ""Shape"" = :Shape, ""ScaleX"" = :ScaleX, ""ScaleY"" = :ScaleY, ""ScaleZ"" = :ScaleZ, ""PCode"" = :PCode, ""PathBegin"" = :PathBegin,
406 ""PathEnd"" = :PathEnd, ""PathScaleX"" = :PathScaleX, ""PathScaleY"" = :PathScaleY, ""PathShearX"" = :PathShearX, ""PathShearY"" = :PathShearY, 409 ""PathEnd"" = :PathEnd, ""PathScaleX"" = :PathScaleX, ""PathScaleY"" = :PathScaleY, ""PathShearX"" = :PathShearX, ""PathShearY"" = :PathShearY,
407 ""PathSkew"" = :PathSkew, ""PathCurve"" = :PathCurve, ""PathRadiusOffset"" = :PathRadiusOffset, ""PathRevolutions"" = :PathRevolutions, 410 ""PathSkew"" = :PathSkew, ""PathCurve"" = :PathCurve, ""PathRadiusOffset"" = :PathRadiusOffset, ""PathRevolutions"" = :PathRevolutions,
408 ""PathTaperX"" = :PathTaperX, ""PathTaperY"" = :PathTaperY, ""PathTwist"" = :PathTwist, ""PathTwistBegin"" = :PathTwistBegin, 411 ""PathTaperX"" = :PathTaperX, ""PathTaperY"" = :PathTaperY, ""PathTwist"" = :PathTwist, ""PathTwistBegin"" = :PathTwistBegin,
409 ""ProfileBegin"" = :ProfileBegin, ""ProfileEnd"" = :ProfileEnd, ""ProfileCurve"" = :ProfileCurve, ""ProfileHollow"" = :ProfileHollow, 412 ""ProfileBegin"" = :ProfileBegin, ""ProfileEnd"" = :ProfileEnd, ""ProfileCurve"" = :ProfileCurve, ""ProfileHollow"" = :ProfileHollow,
410 ""Texture"" = :Texture, ""ExtraParams"" = :ExtraParams, ""State"" = :State, ""Media"" = :Media 413 ""Texture"" = :Texture, ""ExtraParams"" = :ExtraParams, ""State"" = :State, ""Media"" = :Media
411 WHERE ""UUID"" = :UUID ; 414 WHERE ""UUID"" = :UUID ;
412 415
413 INSERT INTO 416 INSERT INTO
414 primshapes ( 417 primshapes (
415 ""UUID"", ""Shape"", ""ScaleX"", ""ScaleY"", ""ScaleZ"", ""PCode"", ""PathBegin"", ""PathEnd"", ""PathScaleX"", ""PathScaleY"", ""PathShearX"", ""PathShearY"", 418 ""UUID"", ""Shape"", ""ScaleX"", ""ScaleY"", ""ScaleZ"", ""PCode"", ""PathBegin"", ""PathEnd"", ""PathScaleX"", ""PathScaleY"", ""PathShearX"", ""PathShearY"",
416 ""PathSkew"", ""PathCurve"", ""PathRadiusOffset"", ""PathRevolutions"", ""PathTaperX"", ""PathTaperY"", ""PathTwist"", ""PathTwistBegin"", ""ProfileBegin"", 419 ""PathSkew"", ""PathCurve"", ""PathRadiusOffset"", ""PathRevolutions"", ""PathTaperX"", ""PathTaperY"", ""PathTwist"", ""PathTwistBegin"", ""ProfileBegin"",
417 ""ProfileEnd"", ""ProfileCurve"", ""ProfileHollow"", ""Texture"", ""ExtraParams"", ""State"", ""Media"" 420 ""ProfileEnd"", ""ProfileCurve"", ""ProfileHollow"", ""Texture"", ""ExtraParams"", ""State"", ""Media""
418 ) 421 )
419 Select 422 Select
420 :UUID, :Shape, :ScaleX, :ScaleY, :ScaleZ, :PCode, :PathBegin, :PathEnd, :PathScaleX, :PathScaleY, :PathShearX, :PathShearY, 423 :UUID, :Shape, :ScaleX, :ScaleY, :ScaleZ, :PCode, :PathBegin, :PathEnd, :PathScaleX, :PathScaleY, :PathShearX, :PathShearY,
421 :PathSkew, :PathCurve, :PathRadiusOffset, :PathRevolutions, :PathTaperX, :PathTaperY, :PathTwist, :PathTwistBegin, :ProfileBegin, 424 :PathSkew, :PathCurve, :PathRadiusOffset, :PathRevolutions, :PathTaperX, :PathTaperY, :PathTwist, :PathTwistBegin, :ProfileBegin,
422 :ProfileEnd, :ProfileCurve, :ProfileHollow, :Texture, :ExtraParams, :State, :Media 425 :ProfileEnd, :ProfileCurve, :ProfileHollow, :Texture, :ExtraParams, :State, :Media
423 where not EXISTS (SELECT ""UUID"" FROM primshapes WHERE ""UUID"" = :UUID); 426 where not EXISTS (SELECT ""UUID"" FROM primshapes WHERE ""UUID"" = :UUID);
424 "; 427 ";
@@ -498,7 +501,7 @@ namespace OpenSim.Data.PGSQL
498 sql = 501 sql =
499 @"INSERT INTO primitems ( 502 @"INSERT INTO primitems (
500 ""itemID"",""primID"",""assetID"",""parentFolderID"",""invType"",""assetType"",""name"",""description"",""creationDate"",""creatorID"",""ownerID"",""lastOwnerID"",""groupID"", 503 ""itemID"",""primID"",""assetID"",""parentFolderID"",""invType"",""assetType"",""name"",""description"",""creationDate"",""creatorID"",""ownerID"",""lastOwnerID"",""groupID"",
501 ""nextPermissions"",""currentPermissions"",""basePermissions"",""everyonePermissions"",""groupPermissions"",""flags"") 504 ""nextPermissions"",""currentPermissions"",""basePermissions"",""everyonePermissions"",""groupPermissions"",""flags"")
502 VALUES (:itemID,:primID,:assetID,:parentFolderID,:invType,:assetType,:name,:description,:creationDate,:creatorID,:ownerID, 505 VALUES (:itemID,:primID,:assetID,:parentFolderID,:invType,:assetType,:name,:description,:creationDate,:creatorID,:ownerID,
503 :lastOwnerID,:groupID,:nextPermissions,:currentPermissions,:basePermissions,:everyonePermissions,:groupPermissions,:flags)"; 506 :lastOwnerID,:groupID,:nextPermissions,:currentPermissions,:basePermissions,:everyonePermissions,:groupPermissions,:flags)";
504 507
@@ -536,7 +539,7 @@ namespace OpenSim.Data.PGSQL
536 { 539 {
537 TerrainData terrData = null; 540 TerrainData terrData = null;
538 541
539 string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from terrain 542 string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from terrain
540 where ""RegionUUID"" = :RegionUUID order by ""Revision"" desc limit 1; "; 543 where ""RegionUUID"" = :RegionUUID order by ""Revision"" desc limit 1; ";
541 544
542 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) 545 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
@@ -552,8 +555,11 @@ namespace OpenSim.Data.PGSQL
552 if (reader.Read()) 555 if (reader.Read())
553 { 556 {
554 rev = Convert.ToInt32(reader["Revision"]); 557 rev = Convert.ToInt32(reader["Revision"]);
555 byte[] blob = (byte[])reader["Heightfield"]; 558 if ((reader["Heightfield"] != DBNull.Value))
556 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); 559 {
560 byte[] blob = (byte[])reader["Heightfield"];
561 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
562 }
557 } 563 }
558 else 564 else
559 { 565 {
@@ -568,6 +574,39 @@ namespace OpenSim.Data.PGSQL
568 return terrData; 574 return terrData;
569 } 575 }
570 576
577 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
578 {
579 TerrainData terrData = null;
580
581 string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from bakedterrain
582 where ""RegionUUID"" = :RegionUUID; ";
583
584 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
585 {
586 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
587 {
588 // PGSqlParameter param = new PGSqlParameter();
589 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
590 conn.Open();
591 using (NpgsqlDataReader reader = cmd.ExecuteReader())
592 {
593 int rev;
594 if (reader.Read())
595 {
596 rev = Convert.ToInt32(reader["Revision"]);
597 if ((reader["Heightfield"] != DBNull.Value))
598 {
599 byte[] blob = (byte[])reader["Heightfield"];
600 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
601 }
602 }
603 }
604 }
605 }
606
607 return terrData;
608 }
609
571 // Legacy entry point for when terrain was always a 256x256 heightmap 610 // Legacy entry point for when terrain was always a 256x256 heightmap
572 public void StoreTerrain(double[,] terrain, UUID regionID) 611 public void StoreTerrain(double[,] terrain, UUID regionID)
573 { 612 {
@@ -619,6 +658,49 @@ namespace OpenSim.Data.PGSQL
619 } 658 }
620 659
621 /// <summary> 660 /// <summary>
661 /// Stores the baked terrain map to DB.
662 /// </summary>
663 /// <param name="terrain">terrain map data.</param>
664 /// <param name="regionID">regionID.</param>
665 public void StoreBakedTerrain(TerrainData terrData, UUID regionID)
666 {
667 //Delete old terrain map
668 string sql = @"delete from bakedterrain where ""RegionUUID""=:RegionUUID";
669 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
670 {
671 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
672 {
673 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
674 conn.Open();
675 cmd.ExecuteNonQuery();
676
677 _Log.InfoFormat("{0} Deleted bakedterrain id = {1}", LogHeader, regionID);
678 }
679 }
680
681 int terrainDBRevision;
682 Array terrainDBblob;
683 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
684
685 sql = @"insert into bakedterrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)";
686
687 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
688 {
689 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
690 {
691 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
692 cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision));
693 cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob));
694 conn.Open();
695 cmd.ExecuteNonQuery();
696
697 _Log.InfoFormat("{0} Stored bakedterrain id = {1}, terrainSize = <{2},{3}>",
698 LogHeader, regionID, terrData.SizeX, terrData.SizeY);
699 }
700 }
701 }
702
703 /// <summary>
622 /// Loads all the land objects of a region. 704 /// Loads all the land objects of a region.
623 /// </summary> 705 /// </summary>
624 /// <param name="regionUUID">The region UUID.</param> 706 /// <param name="regionUUID">The region UUID.</param>
@@ -683,11 +765,14 @@ namespace OpenSim.Data.PGSQL
683 string sql = @"INSERT INTO land 765 string sql = @"INSERT INTO land
684 (""UUID"",""RegionUUID"",""LocalLandID"",""Bitmap"",""Name"",""Description"",""OwnerUUID"",""IsGroupOwned"",""Area"",""AuctionID"",""Category"",""ClaimDate"",""ClaimPrice"", 766 (""UUID"",""RegionUUID"",""LocalLandID"",""Bitmap"",""Name"",""Description"",""OwnerUUID"",""IsGroupOwned"",""Area"",""AuctionID"",""Category"",""ClaimDate"",""ClaimPrice"",
685 ""GroupUUID"",""SalePrice"",""LandStatus"",""LandFlags"",""LandingType"",""MediaAutoScale"",""MediaTextureUUID"",""MediaURL"",""MusicURL"",""PassHours"",""PassPrice"", 767 ""GroupUUID"",""SalePrice"",""LandStatus"",""LandFlags"",""LandingType"",""MediaAutoScale"",""MediaTextureUUID"",""MediaURL"",""MusicURL"",""PassHours"",""PassPrice"",
686 ""SnapshotUUID"",""UserLocationX"",""UserLocationY"",""UserLocationZ"",""UserLookAtX"",""UserLookAtY"",""UserLookAtZ"",""AuthbuyerID"",""OtherCleanTime"") 768 ""SnapshotUUID"",""UserLocationX"",""UserLocationY"",""UserLocationZ"",""UserLookAtX"",""UserLookAtY"",""UserLookAtZ"",""AuthbuyerID"",""OtherCleanTime"",""Dwell"",
769 ""MediaType"",""MediaDescription"",""MediaSize"",""MediaLoop"",""ObscureMusic"",""ObscureMedia"",""SeeAVs"",""AnyAVSounds"",""GroupAVSounds"")
687 VALUES 770 VALUES
688 (:UUID,:RegionUUID,:LocalLandID,:Bitmap,:Name,:Description,:OwnerUUID,:IsGroupOwned,:Area,:AuctionID,:Category,:ClaimDate,:ClaimPrice, 771 (:UUID,:RegionUUID,:LocalLandID,:Bitmap,:Name,:Description,:OwnerUUID,:IsGroupOwned,:Area,:AuctionID,:Category,:ClaimDate,:ClaimPrice,
689 :GroupUUID,:SalePrice,:LandStatus,:LandFlags,:LandingType,:MediaAutoScale,:MediaTextureUUID,:MediaURL,:MusicURL,:PassHours,:PassPrice, 772 :GroupUUID,:SalePrice,:LandStatus,:LandFlags,:LandingType,:MediaAutoScale,:MediaTextureUUID,:MediaURL,:MusicURL,:PassHours,:PassPrice,
690 :SnapshotUUID,:UserLocationX,:UserLocationY,:UserLocationZ,:UserLookAtX,:UserLookAtY,:UserLookAtZ,:AuthbuyerID,:OtherCleanTime)"; 773 :SnapshotUUID,:UserLocationX,:UserLocationY,:UserLocationZ,:UserLookAtX,:UserLookAtY,:UserLookAtZ,:AuthbuyerID,:OtherCleanTime,:Dwell,
774 :MediaType,:MediaDescription,:MediaWidth::text || ',' || :MediaHeight::text,:MediaLoop,:ObscureMusic,:ObscureMedia,:SeeAVs::int::smallint,
775 :AnyAVSounds::int::smallint,:GroupAVSounds::int::smallint)";
691 776
692 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) 777 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
693 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) 778 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
@@ -1235,7 +1320,7 @@ namespace OpenSim.Data.PGSQL
1235 { 1320 {
1236 { 1321 {
1237 string sql = "DELETE FROM regionenvironment WHERE region_id = :region_id ;"; 1322 string sql = "DELETE FROM regionenvironment WHERE region_id = :region_id ;";
1238 1323
1239 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) 1324 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
1240 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) 1325 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
1241 { 1326 {
@@ -1336,17 +1421,17 @@ namespace OpenSim.Data.PGSQL
1336 { 1421 {
1337 //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB 1422 //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB
1338 sql = 1423 sql =
1339 @"UPDATE regionsettings SET block_terraform = :block_terraform ,block_fly = :block_fly ,allow_damage = :allow_damage 1424 @"UPDATE regionsettings SET block_terraform = :block_terraform ,block_fly = :block_fly ,allow_damage = :allow_damage
1340,restrict_pushing = :restrict_pushing ,allow_land_resell = :allow_land_resell ,allow_land_join_divide = :allow_land_join_divide 1425,restrict_pushing = :restrict_pushing ,allow_land_resell = :allow_land_resell ,allow_land_join_divide = :allow_land_join_divide
1341,block_show_in_search = :block_show_in_search ,agent_limit = :agent_limit ,object_bonus = :object_bonus ,maturity = :maturity 1426,block_show_in_search = :block_show_in_search ,agent_limit = :agent_limit ,object_bonus = :object_bonus ,maturity = :maturity
1342,disable_scripts = :disable_scripts ,disable_collisions = :disable_collisions ,disable_physics = :disable_physics 1427,disable_scripts = :disable_scripts ,disable_collisions = :disable_collisions ,disable_physics = :disable_physics
1343,terrain_texture_1 = :terrain_texture_1 ,terrain_texture_2 = :terrain_texture_2 ,terrain_texture_3 = :terrain_texture_3 1428,terrain_texture_1 = :terrain_texture_1 ,terrain_texture_2 = :terrain_texture_2 ,terrain_texture_3 = :terrain_texture_3
1344,terrain_texture_4 = :terrain_texture_4 ,elevation_1_nw = :elevation_1_nw ,elevation_2_nw = :elevation_2_nw 1429,terrain_texture_4 = :terrain_texture_4 ,elevation_1_nw = :elevation_1_nw ,elevation_2_nw = :elevation_2_nw
1345,elevation_1_ne = :elevation_1_ne ,elevation_2_ne = :elevation_2_ne ,elevation_1_se = :elevation_1_se ,elevation_2_se = :elevation_2_se 1430,elevation_1_ne = :elevation_1_ne ,elevation_2_ne = :elevation_2_ne ,elevation_1_se = :elevation_1_se ,elevation_2_se = :elevation_2_se
1346,elevation_1_sw = :elevation_1_sw ,elevation_2_sw = :elevation_2_sw ,water_height = :water_height ,terrain_raise_limit = :terrain_raise_limit 1431,elevation_1_sw = :elevation_1_sw ,elevation_2_sw = :elevation_2_sw ,water_height = :water_height ,terrain_raise_limit = :terrain_raise_limit
1347,terrain_lower_limit = :terrain_lower_limit ,use_estate_sun = :use_estate_sun ,fixed_sun = :fixed_sun ,sun_position = :sun_position 1432,terrain_lower_limit = :terrain_lower_limit ,use_estate_sun = :use_estate_sun ,fixed_sun = :fixed_sun ,sun_position = :sun_position
1348,covenant = :covenant ,covenant_datetime = :covenant_datetime, sunvectorx = :sunvectorx, sunvectory = :sunvectory, sunvectorz = :sunvectorz, 1433,covenant = :covenant ,covenant_datetime = :covenant_datetime, sunvectorx = :sunvectorx, sunvectory = :sunvectory, sunvectorz = :sunvectorz,
1349""Sandbox"" = :Sandbox, loaded_creation_datetime = :loaded_creation_datetime, loaded_creation_id = :loaded_creation_id, ""map_tile_ID"" = :TerrainImageID, 1434""Sandbox"" = :Sandbox, loaded_creation_datetime = :loaded_creation_datetime, loaded_creation_id = :loaded_creation_id, ""map_tile_ID"" = :TerrainImageID,
1350""TelehubObject"" = :telehubobject, ""parcel_tile_ID"" = :ParcelImageID 1435""TelehubObject"" = :telehubobject, ""parcel_tile_ID"" = :ParcelImageID
1351 WHERE ""regionUUID"" = :regionUUID"; 1436 WHERE ""regionUUID"" = :regionUUID";
1352 1437
@@ -1381,13 +1466,13 @@ namespace OpenSim.Data.PGSQL
1381 elevation_2_ne,elevation_1_se,elevation_2_se,elevation_1_sw,elevation_2_sw,water_height,terrain_raise_limit, 1466 elevation_2_ne,elevation_1_se,elevation_2_se,elevation_1_sw,elevation_2_sw,water_height,terrain_raise_limit,
1382 terrain_lower_limit,use_estate_sun,fixed_sun,sun_position,covenant,covenant_datetime,sunvectorx, sunvectory, sunvectorz, 1467 terrain_lower_limit,use_estate_sun,fixed_sun,sun_position,covenant,covenant_datetime,sunvectorx, sunvectory, sunvectorz,
1383 ""Sandbox"", loaded_creation_datetime, loaded_creation_id 1468 ""Sandbox"", loaded_creation_datetime, loaded_creation_id
1384 ) 1469 )
1385 VALUES 1470 VALUES
1386 (:regionUUID,:block_terraform,:block_fly,:allow_damage,:restrict_pushing,:allow_land_resell,:allow_land_join_divide, 1471 (:regionUUID,:block_terraform,:block_fly,:allow_damage,:restrict_pushing,:allow_land_resell,:allow_land_join_divide,
1387 :block_show_in_search,:agent_limit,:object_bonus,:maturity,:disable_scripts,:disable_collisions,:disable_physics, 1472 :block_show_in_search,:agent_limit,:object_bonus,:maturity,:disable_scripts,:disable_collisions,:disable_physics,
1388 :terrain_texture_1,:terrain_texture_2,:terrain_texture_3,:terrain_texture_4,:elevation_1_nw,:elevation_2_nw,:elevation_1_ne, 1473 :terrain_texture_1,:terrain_texture_2,:terrain_texture_3,:terrain_texture_4,:elevation_1_nw,:elevation_2_nw,:elevation_1_ne,
1389 :elevation_2_ne,:elevation_1_se,:elevation_2_se,:elevation_1_sw,:elevation_2_sw,:water_height,:terrain_raise_limit, 1474 :elevation_2_ne,:elevation_1_se,:elevation_2_se,:elevation_1_sw,:elevation_2_sw,:water_height,:terrain_raise_limit,
1390 :terrain_lower_limit,:use_estate_sun,:fixed_sun,:sun_position,:covenant, :covenant_datetime, :sunvectorx,:sunvectory, 1475 :terrain_lower_limit,:use_estate_sun,:fixed_sun,:sun_position,:covenant, :covenant_datetime, :sunvectorx,:sunvectory,
1391 :sunvectorz, :Sandbox, :loaded_creation_datetime, :loaded_creation_id )"; 1476 :sunvectorz, :Sandbox, :loaded_creation_datetime, :loaded_creation_id )";
1392 1477
1393 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) 1478 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
@@ -1515,6 +1600,8 @@ namespace OpenSim.Data.PGSQL
1515 newData.SnapshotID = new UUID((Guid)row["SnapshotUUID"]); 1600 newData.SnapshotID = new UUID((Guid)row["SnapshotUUID"]);
1516 1601
1517 newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); 1602 newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]);
1603 newData.Dwell = Convert.ToSingle(row["Dwell"]);
1604
1518 1605
1519 try 1606 try
1520 { 1607 {
@@ -1541,6 +1628,10 @@ namespace OpenSim.Data.PGSQL
1541 newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); 1628 newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]);
1542 newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); 1629 newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]);
1543 1630
1631 newData.SeeAVs = Convert.ToBoolean(row["SeeAVs"]);
1632 newData.AnyAVSounds = Convert.ToBoolean(row["AnyAVSounds"]);
1633 newData.GroupAVSounds = Convert.ToBoolean(row["GroupAVSounds"]);
1634
1544 return newData; 1635 return newData;
1545 } 1636 }
1546 1637
@@ -1588,6 +1679,12 @@ namespace OpenSim.Data.PGSQL
1588 prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); 1679 prim.OwnerID = new UUID((Guid)primRow["OwnerID"]);
1589 prim.GroupID = new UUID((Guid)primRow["GroupID"]); 1680 prim.GroupID = new UUID((Guid)primRow["GroupID"]);
1590 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
1591 prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]); 1688 prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]);
1592 prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]); 1689 prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]);
1593 prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]); 1690 prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]);
@@ -1692,6 +1789,7 @@ namespace OpenSim.Data.PGSQL
1692 prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); 1789 prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]);
1693 1790
1694 prim.PassTouches = (bool)primRow["PassTouches"]; 1791 prim.PassTouches = (bool)primRow["PassTouches"];
1792 prim.PassCollisions = (bool)primRow["PassCollisions"];
1695 1793
1696 if (!(primRow["MediaURL"] is System.DBNull)) 1794 if (!(primRow["MediaURL"] is System.DBNull))
1697 prim.MediaUrl = (string)primRow["MediaURL"]; 1795 prim.MediaUrl = (string)primRow["MediaURL"];
@@ -1699,13 +1797,20 @@ namespace OpenSim.Data.PGSQL
1699 if (!(primRow["DynAttrs"] is System.DBNull) && (string)primRow["DynAttrs"] != "") 1797 if (!(primRow["DynAttrs"] is System.DBNull) && (string)primRow["DynAttrs"] != "")
1700 prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]); 1798 prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]);
1701 else 1799 else
1702 prim.DynAttrs = new DAMap(); 1800 prim.DynAttrs = new DAMap();
1703 1801
1704 prim.PhysicsShapeType = Convert.ToByte(primRow["PhysicsShapeType"]); 1802 prim.PhysicsShapeType = Convert.ToByte(primRow["PhysicsShapeType"]);
1705 prim.Density = Convert.ToSingle(primRow["Density"]); 1803 prim.Density = Convert.ToSingle(primRow["Density"]);
1706 prim.GravityModifier = Convert.ToSingle(primRow["GravityModifier"]); 1804 prim.GravityModifier = Convert.ToSingle(primRow["GravityModifier"]);
1707 prim.Friction = Convert.ToSingle(primRow["Friction"]); 1805 prim.Friction = Convert.ToSingle(primRow["Friction"]);
1708 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;
1709 1814
1710 return prim; 1815 return prim;
1711 } 1816 }
@@ -1942,6 +2047,17 @@ namespace OpenSim.Data.PGSQL
1942 parameters.Add(_Database.CreateParameter("UserLookAtZ", land.UserLookAt.Z)); 2047 parameters.Add(_Database.CreateParameter("UserLookAtZ", land.UserLookAt.Z));
1943 parameters.Add(_Database.CreateParameter("AuthBuyerID", land.AuthBuyerID)); 2048 parameters.Add(_Database.CreateParameter("AuthBuyerID", land.AuthBuyerID));
1944 parameters.Add(_Database.CreateParameter("OtherCleanTime", land.OtherCleanTime)); 2049 parameters.Add(_Database.CreateParameter("OtherCleanTime", land.OtherCleanTime));
2050 parameters.Add(_Database.CreateParameter("Dwell", land.Dwell));
2051 parameters.Add(_Database.CreateParameter("MediaDescription", land.MediaDescription));
2052 parameters.Add(_Database.CreateParameter("MediaType", land.MediaType));
2053 parameters.Add(_Database.CreateParameter("MediaWidth", land.MediaWidth));
2054 parameters.Add(_Database.CreateParameter("MediaHeight", land.MediaHeight));
2055 parameters.Add(_Database.CreateParameter("MediaLoop", land.MediaLoop));
2056 parameters.Add(_Database.CreateParameter("ObscureMusic", land.ObscureMusic));
2057 parameters.Add(_Database.CreateParameter("ObscureMedia", land.ObscureMedia));
2058 parameters.Add(_Database.CreateParameter("SeeAVs", land.SeeAVs));
2059 parameters.Add(_Database.CreateParameter("AnyAVSounds", land.AnyAVSounds));
2060 parameters.Add(_Database.CreateParameter("GroupAVSounds", land.GroupAVSounds));
1945 2061
1946 return parameters.ToArray(); 2062 return parameters.ToArray();
1947 } 2063 }
@@ -1996,6 +2112,7 @@ namespace OpenSim.Data.PGSQL
1996 parameters.Add(_Database.CreateParameter("OwnerID", prim.OwnerID)); 2112 parameters.Add(_Database.CreateParameter("OwnerID", prim.OwnerID));
1997 parameters.Add(_Database.CreateParameter("GroupID", prim.GroupID)); 2113 parameters.Add(_Database.CreateParameter("GroupID", prim.GroupID));
1998 parameters.Add(_Database.CreateParameter("LastOwnerID", prim.LastOwnerID)); 2114 parameters.Add(_Database.CreateParameter("LastOwnerID", prim.LastOwnerID));
2115 parameters.Add(_Database.CreateParameter("RezzerID", prim.RezzerID));
1999 parameters.Add(_Database.CreateParameter("OwnerMask", prim.OwnerMask)); 2116 parameters.Add(_Database.CreateParameter("OwnerMask", prim.OwnerMask));
2000 parameters.Add(_Database.CreateParameter("NextOwnerMask", prim.NextOwnerMask)); 2117 parameters.Add(_Database.CreateParameter("NextOwnerMask", prim.NextOwnerMask));
2001 parameters.Add(_Database.CreateParameter("GroupMask", prim.GroupMask)); 2118 parameters.Add(_Database.CreateParameter("GroupMask", prim.GroupMask));
@@ -2094,28 +2211,47 @@ namespace OpenSim.Data.PGSQL
2094 2211
2095 parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound)); 2212 parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound));
2096 parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume)); 2213 parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume));
2214
2215 parameters.Add(_Database.CreateParameter("PassTouches", (bool)prim.PassTouches));
2216 parameters.Add(_Database.CreateParameter("PassCollisions", (bool)prim.PassCollisions));
2217
2097 2218
2098 parameters.Add(_Database.CreateParameter("PassTouches", prim.PassTouches)); 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));
2099 2228
2100 parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); 2229 parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum));
2101 parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); 2230 parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl));
2102 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
2237
2103 if (prim.DynAttrs.CountNamespaces > 0) 2238 if (prim.DynAttrs.CountNamespaces > 0)
2104 parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml())); 2239 parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml()));
2105 else 2240 else
2106 parameters.Add(_Database.CreateParameter("DynAttrs", null)); 2241 parameters.Add(_Database.CreateParameter("DynAttrs", null));
2107 2242
2108 parameters.Add(_Database.CreateParameter("PhysicsShapeType", prim.PhysicsShapeType)); 2243 parameters.Add(_Database.CreateParameter("PhysicsShapeType", prim.PhysicsShapeType));
2109 parameters.Add(_Database.CreateParameter("Density", (double)prim.Density)); 2244 parameters.Add(_Database.CreateParameter("Density", (double)prim.Density));
2110 parameters.Add(_Database.CreateParameter("GravityModifier", (double)prim.GravityModifier)); 2245 parameters.Add(_Database.CreateParameter("GravityModifier", (double)prim.GravityModifier));
2111 parameters.Add(_Database.CreateParameter("Friction", (double)prim.Friction)); 2246 parameters.Add(_Database.CreateParameter("Friction", (double)prim.Friction));
2112 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));
2113 2249
2114 return parameters.ToArray(); 2250 return parameters.ToArray();
2115 } 2251 }
2116 2252
2117 /// <summary> 2253 /// <summary>
2118 /// Creates the primshape parameters for stroing in DB. 2254 /// Creates the primshape parameters for storing in DB.
2119 /// </summary> 2255 /// </summary>
2120 /// <param name="prim">Basic data of SceneObjectpart prim.</param> 2256 /// <param name="prim">Basic data of SceneObjectpart prim.</param>
2121 /// <param name="sceneGroupID">The scene group ID.</param> 2257 /// <param name="sceneGroupID">The scene group ID.</param>
@@ -2227,6 +2363,11 @@ namespace OpenSim.Data.PGSQL
2227 } 2363 }
2228 } 2364 }
2229 2365
2366 public UUID[] GetObjectIDs(UUID regionID)
2367 {
2368 return new UUID[0];
2369 }
2370
2230 public void SaveExtra(UUID regionID, string name, string value) 2371 public void SaveExtra(UUID regionID, string name, string value)
2231 { 2372 {
2232 } 2373 }
diff --git a/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs b/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs
index 0a68b23..64cfff0 100644
--- a/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs
@@ -42,13 +42,13 @@ namespace OpenSim.Data.PGSQL
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 45
46 public PGSQLUserAccountData(string connectionString, string realm) : 46 public PGSQLUserAccountData(string connectionString, string realm) :
47 base(connectionString, realm, "UserAccount") 47 base(connectionString, realm, "UserAccount")
48 { 48 {
49 } 49 }
50 50
51 /* 51 /*
52 private string m_Realm; 52 private string m_Realm;
53 private List<string> m_ColumnNames = null; 53 private List<string> m_ColumnNames = null;
54 private PGSQLManager m_database; 54 private PGSQLManager m_database;
@@ -122,7 +122,7 @@ namespace OpenSim.Data.PGSQL
122 { 122 {
123 cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID)); 123 cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID));
124 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID)); 124 cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
125 125
126 conn.Open(); 126 conn.Open();
127 using (NpgsqlDataReader result = cmd.ExecuteReader()) 127 using (NpgsqlDataReader result = cmd.ExecuteReader())
128 { 128 {
@@ -158,8 +158,8 @@ namespace OpenSim.Data.PGSQL
158 } 158 }
159 return null; 159 return null;
160 } 160 }
161 161
162 162
163 public override bool Store(UserAccountData data) 163 public override bool Store(UserAccountData data)
164 { 164 {
165 if (data.Data.ContainsKey("PrincipalID")) 165 if (data.Data.ContainsKey("PrincipalID"))
@@ -214,7 +214,7 @@ namespace OpenSim.Data.PGSQL
214 catch (Exception e){ 214 catch (Exception e){
215 m_log.ErrorFormat("[USER]: ERROR opened update user {0} ", e.Message); 215 m_log.ErrorFormat("[USER]: ERROR opened update user {0} ", e.Message);
216 } 216 }
217 217
218 218
219 if (conta < 1) 219 if (conta < 1)
220 { 220 {
@@ -242,14 +242,14 @@ namespace OpenSim.Data.PGSQL
242 } 242 }
243 return true; 243 return true;
244 } 244 }
245 245
246 246
247 public bool Store(UserAccountData data, UUID principalID, string token) 247 public bool Store(UserAccountData data, UUID principalID, string token)
248 { 248 {
249 return false; 249 return false;
250 } 250 }
251 251
252 252
253 public bool SetDataItem(UUID principalID, string item, string value) 253 public bool SetDataItem(UUID principalID, string item, string value)
254 { 254 {
255 string sql = string.Format(@"update {0} set {1} = :{1} where ""UUID"" = :UUID", m_Realm, item); 255 string sql = string.Format(@"update {0} set {1} = :{1} where ""UUID"" = :UUID", m_Realm, item);
@@ -299,7 +299,7 @@ namespace OpenSim.Data.PGSQL
299 299
300 string sql = ""; 300 string sql = "";
301 UUID scope_id; 301 UUID scope_id;
302 UUID.TryParse(scopeID.ToString(), out scope_id); 302 UUID.TryParse(scopeID.ToString(), out scope_id);
303 303
304 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString)) 304 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
305 using (NpgsqlCommand cmd = new NpgsqlCommand()) 305 using (NpgsqlCommand cmd = new NpgsqlCommand())
@@ -325,5 +325,10 @@ namespace OpenSim.Data.PGSQL
325 return DoQuery(cmd); 325 return DoQuery(cmd);
326 } 326 }
327 } 327 }
328
329 public UserAccountData[] GetUsersWhere(UUID scopeID, string where)
330 {
331 return null;
332 }
328 } 333 }
329} 334}
diff --git a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
index f166976..75a51e2 100644
--- a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
@@ -412,15 +412,15 @@ namespace OpenSim.Data.PGSQL
412 query = @"WITH upsert AS ( 412 query = @"WITH upsert AS (
413 UPDATE userpicks SET 413 UPDATE userpicks SET
414 pickuuid = :PickId, creatoruuid = :CreatorId, toppick = :TopPick, parceluuid = :ParcelId, 414 pickuuid = :PickId, creatoruuid = :CreatorId, toppick = :TopPick, parceluuid = :ParcelId,
415 name = :Name, description = :Desc, snapshotuuid = :SnapshotId, ""user"" = :User, 415 name = :Name, description = :Desc, snapshotuuid = :SnapshotId, ""user"" = :User,
416 originalname = :Original, simname = :SimName, posglobal = :GlobalPos, 416 originalname = :Original, simname = :SimName, posglobal = :GlobalPos,
417 sortorder = :SortOrder, enabled = :Enabled 417 sortorder = :SortOrder, enabled = :Enabled
418 RETURNING * ) 418 RETURNING * )
419 INSERT INTO userpicks (pickuuid,creatoruuid,toppick,parceluuid,name,description, 419 INSERT INTO userpicks (pickuuid,creatoruuid,toppick,parceluuid,name,description,
420 snapshotuuid,""user"",originalname,simname,posglobal,sortorder,enabled) 420 snapshotuuid,""user"",originalname,simname,posglobal,sortorder,enabled)
421 SELECT 421 SELECT
422 :PickId,:CreatorId,:TopPick,:ParcelId,:Name,:Desc,:SnapshotId,:User, 422 :PickId,:CreatorId,:TopPick,:ParcelId,:Name,:Desc,:SnapshotId,:User,
423 :Original,:SimName,:GlobalPos,:SortOrder,:Enabled 423 :Original,:SimName,:GlobalPos,:SortOrder,:Enabled
424 WHERE NOT EXISTS ( 424 WHERE NOT EXISTS (
425 SELECT * FROM upsert )"; 425 SELECT * FROM upsert )";
426 426
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
index 4f682f0..1798d20 100644
--- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
@@ -141,7 +141,7 @@ namespace OpenSim.Data.PGSQL
141 141
142 using (NpgsqlCommand cmd = new NpgsqlCommand( 142 using (NpgsqlCommand cmd = new NpgsqlCommand(
143 @"SELECT name, description, access_time, ""AssetType"", local, temporary, asset_flags, creatorid, data 143 @"SELECT name, description, access_time, ""AssetType"", local, temporary, asset_flags, creatorid, data
144 FROM XAssetsMeta 144 FROM XAssetsMeta
145 JOIN XAssetsData ON XAssetsMeta.hash = XAssetsData.Hash WHERE id=:ID", 145 JOIN XAssetsData ON XAssetsMeta.hash = XAssetsData.Hash WHERE id=:ID",
146 dbcon)) 146 dbcon))
147 { 147 {
@@ -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
@@ -223,16 +225,16 @@ namespace OpenSim.Data.PGSQL
223 { 225 {
224 assetName = asset.Name.Substring(0, 64); 226 assetName = asset.Name.Substring(0, 64);
225 m_log.WarnFormat( 227 m_log.WarnFormat(
226 "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", 228 "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
227 asset.Name, asset.ID, asset.Name.Length, assetName.Length); 229 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
228 } 230 }
229 231
230 string assetDescription = asset.Description; 232 string assetDescription = asset.Description;
231 if (asset.Description.Length > 64) 233 if (asset.Description.Length > 64)
232 { 234 {
233 assetDescription = asset.Description.Substring(0, 64); 235 assetDescription = asset.Description.Substring(0, 64);
234 m_log.WarnFormat( 236 m_log.WarnFormat(
235 "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", 237 "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
236 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); 238 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
237 } 239 }
238 240
@@ -268,8 +270,8 @@ namespace OpenSim.Data.PGSQL
268 where not exists( Select id from XAssetsMeta where id = :ID); 270 where not exists( Select id from XAssetsMeta where id = :ID);
269 271
270 update XAssetsMeta 272 update XAssetsMeta
271 set id = :ID, hash = :Hash, name = :Name, description = :Description, 273 set id = :ID, hash = :Hash, name = :Name, description = :Description,
272 ""AssetType"" = :AssetType, local = :Local, temporary = :Temporary, create_time = :CreateTime, 274 ""AssetType"" = :AssetType, local = :Local, temporary = :Temporary, create_time = :CreateTime,
273 access_time = :AccessTime, asset_flags = :AssetFlags, creatorid = :CreatorID 275 access_time = :AccessTime, asset_flags = :AssetFlags, creatorid = :CreatorID
274 where id = :ID; 276 where id = :ID;
275 ", 277 ",
@@ -321,13 +323,13 @@ namespace OpenSim.Data.PGSQL
321 { 323 {
322 m_log.ErrorFormat("[XASSET DB]: PGSQL failure creating asset data {0} with name \"{1}\". Error: {2}", 324 m_log.ErrorFormat("[XASSET DB]: PGSQL failure creating asset data {0} with name \"{1}\". Error: {2}",
323 asset.FullID, asset.Name, e.Message); 325 asset.FullID, asset.Name, e.Message);
324 326
325 transaction.Rollback(); 327 transaction.Rollback();
326 328
327 return; 329 return;
328 } 330 }
329 } 331 }
330 332
331 transaction.Commit(); 333 transaction.Commit();
332 } 334 }
333 } 335 }
@@ -374,7 +376,7 @@ namespace OpenSim.Data.PGSQL
374 catch (Exception e) 376 catch (Exception e)
375 { 377 {
376 m_log.ErrorFormat( 378 m_log.ErrorFormat(
377 "[XASSET PGSQL DB]: Failure updating access_time for asset {0} with name {1} : {2}", 379 "[XASSET PGSQL DB]: Failure updating access_time for asset {0} with name {1} : {2}",
378 assetMetadata.ID, assetMetadata.Name, e.Message); 380 assetMetadata.ID, assetMetadata.Name, e.Message);
379 } 381 }
380 } 382 }
@@ -518,40 +520,42 @@ namespace OpenSim.Data.PGSQL
518 using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) 520 using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
519 { 521 {
520 dbcon.Open(); 522 dbcon.Open();
521 NpgsqlCommand cmd = new NpgsqlCommand( @"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid 523 using(NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid
522 FROM XAssetsMeta 524 FROM XAssetsMeta
523 LIMIT :start, :count", dbcon); 525 LIMIT :start, :count",dbcon))
524 cmd.Parameters.Add(m_database.CreateParameter("start", start));
525 cmd.Parameters.Add(m_database.CreateParameter("count", count));
526
527 try
528 { 526 {
529 using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) 527 cmd.Parameters.Add(m_database.CreateParameter("start",start));
528 cmd.Parameters.Add(m_database.CreateParameter("count", count));
529
530 try
530 { 531 {
531 while (dbReader.Read()) 532 using (NpgsqlDataReader dbReader = cmd.ExecuteReader())
532 { 533 {
533 AssetMetadata metadata = new AssetMetadata(); 534 while (dbReader.Read())
534 metadata.Name = (string)dbReader["name"]; 535 {
535 metadata.Description = (string)dbReader["description"]; 536 AssetMetadata metadata = new AssetMetadata();
536 metadata.Type = Convert.ToSByte(dbReader["AssetType"]); 537 metadata.Name = (string)dbReader["name"];
537 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); 538 metadata.Description = (string)dbReader["description"];
538 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); 539 metadata.Type = Convert.ToSByte(dbReader["AssetType"]);
539 metadata.FullID = DBGuid.FromDB(dbReader["id"]); 540 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]);
540 metadata.CreatorID = dbReader["creatorid"].ToString(); 541 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
542 metadata.FullID = DBGuid.FromDB(dbReader["id"]);
543 metadata.CreatorID = dbReader["creatorid"].ToString();
541 544
542 // We'll ignore this for now - it appears unused! 545 // We'll ignore this for now - it appears unused!
543// metadata.SHA1 = dbReader["hash"]); 546 // metadata.SHA1 = dbReader["hash"]);
544 547
545 UpdateAccessTime(metadata, (int)dbReader["access_time"]); 548 UpdateAccessTime(metadata, (int)dbReader["access_time"]);
546 549
547 retList.Add(metadata); 550 retList.Add(metadata);
551 }
548 } 552 }
549 } 553 }
550 } 554 catch (Exception e)
551 catch (Exception e) 555 {
552 { 556 m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString());
553 m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString()); 557 }
554 } 558 }
555 } 559 }
556 } 560 }
557 561
diff --git a/OpenSim/Data/PGSQL/PGSQLXInventoryData.cs b/OpenSim/Data/PGSQL/PGSQLXInventoryData.cs
index a22b882..4c10ac9 100644
--- a/OpenSim/Data/PGSQL/PGSQLXInventoryData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLXInventoryData.cs
@@ -174,7 +174,9 @@ namespace OpenSim.Data.PGSQL
174 { 174 {
175 using (NpgsqlCommand cmd = new NpgsqlCommand()) 175 using (NpgsqlCommand cmd = new NpgsqlCommand())
176 { 176 {
177 cmd.CommandText = String.Format(@"select * from inventoryitems where ""avatarID"" = :uuid and ""assetType"" = :type and ""flags"" = 1", m_Realm); 177// cmd.CommandText = String.Format(@"select * from inventoryitems where ""avatarID"" = :uuid and ""assetType"" = :type and ""flags"" = 1", m_Realm);
178
179 cmd.CommandText = String.Format(@"select * from inventoryitems where ""avatarID"" = :uuid and ""assetType"" = :type and ""flags"" = 1");
178 180
179 UUID princID = UUID.Zero; 181 UUID princID = UUID.Zero;
180 UUID.TryParse(principalID, out princID); 182 UUID.TryParse(principalID, out princID);
@@ -194,11 +196,18 @@ namespace OpenSim.Data.PGSQL
194 { 196 {
195 using (NpgsqlCommand cmd = new NpgsqlCommand()) 197 using (NpgsqlCommand cmd = new NpgsqlCommand())
196 { 198 {
197 cmd.CommandText = String.Format(@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions"" 199/*
198 from inventoryitems 200 cmd.CommandText = String.Format(@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions""
199 where ""avatarID"" = :PrincipalID 201 from inventoryitems
200 and ""assetID"" = :AssetID 202 where ""avatarID"" = :PrincipalID
203 and ""assetID"" = :AssetID
201 group by ""assetID"" ", m_Realm); 204 group by ""assetID"" ", m_Realm);
205*/
206 cmd.CommandText = String.Format(@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions""
207 from inventoryitems
208 where ""avatarID""::uuid = :PrincipalID
209 and ""assetID""::uuid = :AssetID
210 group by ""assetID"" ");
202 211
203 cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID)); 212 cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID));
204 cmd.Parameters.Add(m_database.CreateParameter("AssetID", assetID)); 213 cmd.Parameters.Add(m_database.CreateParameter("AssetID", assetID));
diff --git a/OpenSim/Data/PGSQL/Properties/AssemblyInfo.cs b/OpenSim/Data/PGSQL/Properties/AssemblyInfo.cs
index 1e88b2c..ad7ffb8 100644
--- a/OpenSim/Data/PGSQL/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/PGSQL/Properties/AssemblyInfo.cs
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
61// You can specify all the values or you can default the Revision and Build Numbers 61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below: 62// by using the '*' as shown below:
63 63
64[assembly : AssemblyVersion("0.8.2.*")] 64[assembly : AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
65 65
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/AuthStore.migrations b/OpenSim/Data/PGSQL/Resources/AuthStore.migrations
index a1f5b61..043a8f7 100644
--- a/OpenSim/Data/PGSQL/Resources/AuthStore.migrations
+++ b/OpenSim/Data/PGSQL/Resources/AuthStore.migrations
@@ -30,3 +30,11 @@ BEGIN TRANSACTION;
30 30
31COMMIT; 31COMMIT;
32 32
33:VERSION 3
34
35BEGIN TRANSACTION;
36
37CREATE UNIQUE INDEX auth_pkey ON auth USING btree (uuid);
38ALTER TABLE tokens ADD CONSTRAINT "uuid_token" UNIQUE ("uuid","token") NOT DEFERRABLE INITIALLY IMMEDIATE;
39
40COMMIT; \ No newline at end of file
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/Presence.migrations b/OpenSim/Data/PGSQL/Resources/Presence.migrations
index 5184034..5184034 100644..100755
--- a/OpenSim/Data/PGSQL/Resources/Presence.migrations
+++ b/OpenSim/Data/PGSQL/Resources/Presence.migrations
diff --git a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations
index 1284ce0..fcefb6b 100644
--- a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations
@@ -1153,10 +1153,75 @@ ALTER TABLE regionwindlight ALTER COLUMN draw_classic_clouds SET DEFAULT FALSE;
1153 1153
1154COMMIT; 1154COMMIT;
1155 1155
1156VERSION 41 #-- Change Landlags to bigint 1156:VERSION 41 #-- Change Landlags to bigint
1157 1157
1158BEGIN TRANSACTION; 1158BEGIN TRANSACTION;
1159 1159
1160ALTER TABLE land ALTER "LandFlags" TYPE bigint; 1160ALTER TABLE land ALTER "LandFlags" TYPE bigint;
1161 1161
1162COMMIT; 1162COMMIT;
1163
1164:VERSION 42 #-- avination fields
1165
1166BEGIN TRANSACTION;
1167
1168ALTER TABLE prims ADD "PassCollisions" smallint NOT NULL DEFAULT (0);
1169ALTER TABLE prims ADD "Vehicle" text COLLATE "default";
1170ALTER TABLE regionsettings ADD "block_search" smallint NOT NULL DEFAULT (0);
1171ALTER TABLE regionsettings ADD "casino" smallint NOT NULL DEFAULT (0);
1172ALTER TABLE land ADD "SeeAVs" smallint NOT NULL DEFAULT (1);
1173ALTER TABLE land ADD "AnyAVSounds" smallint NOT NULL DEFAULT (1);
1174ALTER TABLE land ADD "GroupAVSounds" smallint NOT NULL DEFAULT (1);
1175
1176COMMIT;
1177
1178:VERSION 43 #---- STATUS ROTATION axis locks
1179
1180BEGIN TRANSACTION;
1181
1182ALTER TABLE prims ADD "RotationAxisLocks" smallint NOT NULL DEFAULT (0);
1183
1184COMMIT;
1185
1186:VERSION 44 #---- add baked terrain store
1187
1188BEGIN TRANSACTION;
1189
1190CREATE TABLE bakedterrain
1191 (
1192 "RegionUUID" uuid NULL,
1193 "Revision" int NULL,
1194 "Heightfield" bytea NULL
1195 );
1196
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/PGSQL/Resources/UserAccount.migrations b/OpenSim/Data/PGSQL/Resources/UserAccount.migrations
index c785463..31358fa 100644
--- a/OpenSim/Data/PGSQL/Resources/UserAccount.migrations
+++ b/OpenSim/Data/PGSQL/Resources/UserAccount.migrations
@@ -48,4 +48,10 @@ ALTER TABLE UserAccounts ADD "UserTitle" varchar(64) NOT NULL DEFAULT '';
48 48
49COMMIT; 49COMMIT;
50 50
51:VERSION 5
51 52
53BEGIN TRANSACTION;
54
55ALTER TABLE UserAccounts ADD "active" integer NOT NULL DEFAULT 1;
56
57COMMIT;
diff --git a/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations b/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations
index a6bd8ca..26104c0 100644
--- a/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations
+++ b/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations
@@ -152,4 +152,12 @@ BEGIN;
152 152
153ALTER TABLE usersettings ALTER COLUMN imviaemail SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END; 153ALTER TABLE usersettings ALTER COLUMN imviaemail SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END;
154 154
155COMMIT; \ No newline at end of file 155COMMIT;
156
157:VERSION 6 # -------------------------------
158
159BEGIN TRANSACTION;
160
161ALTER TABLE userpicks ADD "gatekeeper" varchar(255) COLLATE "default";
162
163COMMIT;